From 989ae9e945d04d1f4cca101f7dab46c1a45ef6e3 Mon Sep 17 00:00:00 2001 From: Mike Anderson Date: Wed, 29 Mar 2023 18:11:54 -0500 Subject: [PATCH 1/2] updating transport class to use new smoothness --- mirgecom/transport.py | 99 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/mirgecom/transport.py b/mirgecom/transport.py index a7c51310b..dc75b9035 100644 --- a/mirgecom/transport.py +++ b/mirgecom/transport.py @@ -389,3 +389,102 @@ def species_diffusivity(self, cv: ConservedVars, eos: Optional[GasEOS] = None) -> DOFArray: r"""Get the vector of species diffusivities, ${d}_{\alpha}$.""" return self._physical_transport.species_diffusivity(cv, dv, eos) + + +class ArtificialViscosityTransportDiv2(TransportModel): + r"""Transport model for add artificial viscosity. + + Inherits from (and implements) :class:`TransportModel`. + + Takes a physical transport model and adds the artificial viscosity + contribution to it. Defaults to simple transport with inviscid settings. + This is equivalent to inviscid flow with artifical viscosity enabled. + + .. automethod:: __init__ + .. automethod:: bulk_viscosity + .. automethod:: viscosity + .. automethod:: volume_viscosity + .. automethod:: species_diffusivity + .. automethod:: thermal_conductivity + """ + + def __init__(self, + av_mu, av_kappa, av_beta, av_prandtl, + physical_transport=None, + av_species_diffusivity=None): + """Initialize uniform, constant transport properties.""" + if physical_transport is None: + self._physical_transport = SimpleTransport() + else: + self._physical_transport = physical_transport + + if av_species_diffusivity is None: + av_species_diffusivity = np.empty((0,), dtype=object) + + self._av_mu = av_mu + self._av_beta = av_beta + self._av_kappa = av_kappa + self._av_prandtl = av_prandtl + + def av_mu(self, cv, dv, eos): + r"""Get the shear artificial viscosity for the gas.""" + actx = cv.array_context + return (self._av_mu * cv.mass + * actx.np.sqrt(np.dot(cv.velocity, cv.velocity) + + dv.speed_of_sound**2)) + + def av_beta(self, cv, dv, eos): + r"""Get the shear artificial viscosity for the gas.""" + actx = cv.array_context + return (self._av_beta * cv.mass + * actx.np.sqrt(np.dot(cv.velocity, cv.velocity) + + dv.speed_of_sound**2)) + + def av_kappa(self, cv, dv, eos): + r"""Get the shear artificial viscosity for the gas.""" + actx = cv.array_context + return (self._av_kappa * cv.mass + * actx.np.sqrt(np.dot(cv.velocity, cv.velocity) + + dv.speed_of_sound**2)) + + def bulk_viscosity(self, cv: ConservedVars, # type: ignore[override] + dv: GasDependentVars, + eos: GasEOS) -> DOFArray: + r"""Get the bulk viscosity for the gas, $\mu_{B}$.""" + return (dv.smoothness_beta*self.av_beta(cv, dv, eos) + + self._physical_transport.bulk_viscosity(cv, dv)) + + def viscosity(self, cv: ConservedVars, # type: ignore[override] + dv: GasDependentVars, + eos: GasEOS) -> DOFArray: + r"""Get the gas dynamic viscosity, $\mu$.""" + return (dv.smoothness_mu*self.av_mu(cv, dv, eos) + + self._physical_transport.viscosity(cv, dv)) + + def volume_viscosity(self, cv: ConservedVars, # type: ignore[override] + dv: GasDependentVars, + eos: GasEOS) -> DOFArray: + r"""Get the 2nd viscosity coefficent, $\lambda$. + + In this transport model, the second coefficient of viscosity is defined as: + + $\lambda = \left(\mu_{B} - \frac{2\mu}{3}\right)$ + """ + return (dv.smoothness_mu*self.av_viscosity(cv, dv, eos) + + self._physical_transport.volume_viscosity(cv, dv)) + + def thermal_conductivity(self, cv: ConservedVars, # type: ignore[override] + dv: GasDependentVars, + eos: GasEOS) -> DOFArray: + r"""Get the gas thermal_conductivity, $\kappa$.""" + cp = eos.heat_capacity_cp(cv, dv.temperature) + av_kappa = cp*(dv.smoothness_beta*self.av_beta(cv, dv, eos)/self._av_prandtl + + dv.smoothness_kappa*self.av_kappa(cv, dv, eos)) + + return av_kappa + self._physical_transport.thermal_conductivity(cv, dv, eos) + + def species_diffusivity(self, cv: ConservedVars, + dv: Optional[GasDependentVars] = None, + eos: Optional[GasEOS] = None) -> DOFArray: + r"""Get the vector of species diffusivities, ${d}_{\alpha}$.""" + return self._physical_transport.species_diffusivity(cv, dv, eos) From f145d13c8d008fe9b4451511281e191199723b87 Mon Sep 17 00:00:00 2001 From: Mike Anderson Date: Thu, 30 Mar 2023 21:18:10 -0500 Subject: [PATCH 2/2] updates to new transport class --- mirgecom/transport.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mirgecom/transport.py b/mirgecom/transport.py index dc75b9035..20e3e6311 100644 --- a/mirgecom/transport.py +++ b/mirgecom/transport.py @@ -14,6 +14,7 @@ .. autoclass:: SimpleTransport .. autoclass:: PowerLawTransport .. autoclass:: ArtificialViscosityTransportDiv +.. autoclass:: ArtificialViscosityTransportDiv2 Exceptions ^^^^^^^^^^ @@ -431,21 +432,21 @@ def av_mu(self, cv, dv, eos): actx = cv.array_context return (self._av_mu * cv.mass * actx.np.sqrt(np.dot(cv.velocity, cv.velocity) - + dv.speed_of_sound**2)) + + dv.speed_of_sound**2)) def av_beta(self, cv, dv, eos): r"""Get the shear artificial viscosity for the gas.""" actx = cv.array_context return (self._av_beta * cv.mass * actx.np.sqrt(np.dot(cv.velocity, cv.velocity) - + dv.speed_of_sound**2)) + + dv.speed_of_sound**2)) def av_kappa(self, cv, dv, eos): r"""Get the shear artificial viscosity for the gas.""" actx = cv.array_context return (self._av_kappa * cv.mass * actx.np.sqrt(np.dot(cv.velocity, cv.velocity) - + dv.speed_of_sound**2)) + + dv.speed_of_sound**2)) def bulk_viscosity(self, cv: ConservedVars, # type: ignore[override] dv: GasDependentVars, @@ -466,11 +467,11 @@ def volume_viscosity(self, cv: ConservedVars, # type: ignore[override] eos: GasEOS) -> DOFArray: r"""Get the 2nd viscosity coefficent, $\lambda$. - In this transport model, the second coefficient of viscosity is defined as: + In this transport model, the second coefficient of viscosity is: $\lambda = \left(\mu_{B} - \frac{2\mu}{3}\right)$ """ - return (dv.smoothness_mu*self.av_viscosity(cv, dv, eos) + return (dv.smoothness_mu*self.av_mu(cv, dv, eos) + self._physical_transport.volume_viscosity(cv, dv)) def thermal_conductivity(self, cv: ConservedVars, # type: ignore[override] @@ -478,10 +479,13 @@ def thermal_conductivity(self, cv: ConservedVars, # type: ignore[override] eos: GasEOS) -> DOFArray: r"""Get the gas thermal_conductivity, $\kappa$.""" cp = eos.heat_capacity_cp(cv, dv.temperature) - av_kappa = cp*(dv.smoothness_beta*self.av_beta(cv, dv, eos)/self._av_prandtl - + dv.smoothness_kappa*self.av_kappa(cv, dv, eos)) + av_kappa = ( + cp*(dv.smoothness_beta*self.av_beta(cv, dv, eos)/self._av_prandtl + + dv.smoothness_kappa*self.av_kappa(cv, dv, eos)) + ) - return av_kappa + self._physical_transport.thermal_conductivity(cv, dv, eos) + return (av_kappa + + self._physical_transport.thermal_conductivity(cv, dv, eos)) def species_diffusivity(self, cv: ConservedVars, dv: Optional[GasDependentVars] = None,