Source code for g3d.flow.solver.models.wall_models

"""wall models (LogLaw class definition)"""
from typing import Any, Union

import os

if os.environ.get('__USE_CUDA', '0') == '1':
    import cupy as np
    from cupy import ndarray
else:
    import numpy as np
    from numpy import ndarray

from g3d.gas import Gas
from g3d.defs import G3DEntity


[docs] class LogLaw(G3DEntity): def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self._kappa = 0.41 self._threshold = 10.67848 self._B = 4.9 self.__gas = Gas() def _set_default(self) -> None: super()._set_default() self._tag = 'log-law' @property def kappa(self) -> float: """ :return: """ return self._kappa @kappa.setter def kappa(self, val: float) -> None: self._kappa = val @property def threshold(self) -> float: """ :return: """ return self._threshold @threshold.setter def threshold(self, val: float) -> None: self._threshold = val @property def B(self) -> float: """ :return: """ return self._B @B.setter def B(self, val: float) -> None: self._B = val
[docs] def associate(self, gas: Gas) -> None: """ :param gas: """ self.__gas = gas
[docs] def evaluate(self, u_tang: Union[float, ndarray], ro_w: Union[float, ndarray], y_norm: Union[float, ndarray]) -> Union[float, ndarray, None]: """ :param u_tang: :param ro_w: :param y_norm: :return: """ viscosity = self.__gas.viscosity # initialize wall-shear stress, y+ and u+ tau_w = viscosity * u_tang / y_norm y_plus = y_norm * np.sqrt(ro_w * tau_w) / viscosity u_plus = u_tang * np.sqrt(ro_w / tau_w) if y_plus > self._threshold: d_tau_w = 10. * tau_w while np.abs(d_tau_w) > (0.0001 * tau_w): val = (1. / self._kappa) * np.log(y_plus) - u_plus + self._B d_val = 0.5 * ((1. / self._kappa) + u_plus) / tau_w d_tau_w = -val / d_val tau_w = tau_w + d_tau_w y_plus = y_norm * np.sqrt(ro_w * tau_w) / viscosity u_plus = u_tang * np.sqrt(ro_w / tau_w) return tau_w