Skip to content

Commit

Permalink
Merge branch 'physical-av' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson2981 committed Mar 29, 2023
2 parents 92bb2c0 + b50e3e8 commit e7416ea
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 55 deletions.
26 changes: 13 additions & 13 deletions mirgecom/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def adiabatic_slip_wall_state(
"""
return make_fluid_state(cv=cv_plus, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)
"""
return make_fluid_state(cv=cv_plus, gas_model=gas_model,
temperature_seed=state_minus.temperature)
Expand Down Expand Up @@ -667,7 +667,7 @@ def inviscid_wall_flux(self, dcoll, dd_bdry, gas_model, state_minus,
"""
wall_state = make_fluid_state(cv=wall_cv, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)
"""
wall_state = make_fluid_state(cv=wall_cv, gas_model=gas_model,
temperature_seed=state_minus.temperature)
Expand Down Expand Up @@ -827,7 +827,7 @@ def adiabatic_noslip_state(
species_mass=state_minus.species_mass_density)
return make_fluid_state(cv=cv, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

def adiabatic_noslip_grad_av(self, grad_av_minus, **kwargs):
"""Get the exterior solution on the boundary for artificial viscosity."""
Expand Down Expand Up @@ -880,7 +880,7 @@ def isothermal_noslip_state(
tseed = state_minus.temperature if state_minus.is_mixture else None
return make_fluid_state(cv=cv_plus, gas_model=gas_model,
temperature_seed=tseed,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

def temperature_bc(self, state_minus, **kwargs):
r"""Get temperature value to weakly prescribe wall bc.
Expand Down Expand Up @@ -959,7 +959,7 @@ def farfield_state(self, dcoll, dd_bdry, gas_model, state_minus, **kwargs):

return make_fluid_state(cv=cv_infinity, gas_model=gas_model,
temperature_seed=free_stream_temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

def temperature_bc(self, state_minus, **kwargs):
"""Return farfield temperature for use in grad(temperature)."""
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def outflow_state(self, dcoll, dd_bdry, gas_model, state_minus, **kwargs):

return make_fluid_state(cv=cv_outflow, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

def outflow_state_for_diffusion(self, dcoll, dd_bdry, gas_model,
state_minus, **kwargs):
Expand Down Expand Up @@ -1264,7 +1264,7 @@ def inflow_state(self, dcoll, dd_bdry, gas_model, state_minus, **kwargs):

return make_fluid_state(cv=boundary_cv, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)


class RiemannOutflowBoundary(PrescribedFluidBoundary):
Expand Down Expand Up @@ -1413,7 +1413,7 @@ def isothermal_wall_state(
)
return make_fluid_state(cv=cv_plus, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

def inviscid_wall_flux(self, dcoll, dd_bdry, gas_model, state_minus,
numerical_flux_func=inviscid_facial_flux_rusanov, **kwargs):
Expand All @@ -1427,7 +1427,7 @@ def inviscid_wall_flux(self, dcoll, dd_bdry, gas_model, state_minus,
species_mass=state_minus.species_mass_density)
wall_state = make_fluid_state(cv=wall_cv, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

state_pair = TracePair(dd_bdry, interior=state_minus, exterior=wall_state)

Expand Down Expand Up @@ -1526,7 +1526,7 @@ def adiabatic_wall_state_for_advection(self, dcoll, dd_bdry, gas_model,
)
return make_fluid_state(cv=cv_plus, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

def adiabatic_wall_state_for_diffusion(self, dcoll, dd_bdry, gas_model,
state_minus, **kwargs):
Expand All @@ -1540,7 +1540,7 @@ def adiabatic_wall_state_for_diffusion(self, dcoll, dd_bdry, gas_model,
)
return make_fluid_state(cv=cv_plus, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

def inviscid_wall_flux(self, dcoll, dd_bdry, gas_model, state_minus,
numerical_flux_func=inviscid_facial_flux_rusanov, **kwargs):
Expand Down Expand Up @@ -1672,7 +1672,7 @@ def adiabatic_wall_state_for_advection(self, dcoll, dd_bdry, gas_model,
)
return make_fluid_state(cv=cv_plus, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

def adiabatic_wall_state_for_diffusion(self, dcoll, dd_bdry, gas_model,
state_minus, **kwargs):
Expand All @@ -1699,7 +1699,7 @@ def adiabatic_wall_state_for_diffusion(self, dcoll, dd_bdry, gas_model,
)
return make_fluid_state(cv=cv_plus, gas_model=gas_model,
temperature_seed=state_minus.temperature,
smoothness=state_minus.smoothness)
smoothness_mu=state_minus.smoothness_mu)

def inviscid_wall_flux(self, dcoll, dd_bdry, gas_model, state_minus,
numerical_flux_func=inviscid_facial_flux_rusanov, **kwargs):
Expand Down
24 changes: 12 additions & 12 deletions mirgecom/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ class GasDependentVars:
.. attribute:: temperature
.. attribute:: pressure
.. attribute:: speed_of_sound
.. attribute:: smoothness
.. attribute:: smoothness_mu
"""

temperature: DOFArray
pressure: DOFArray
speed_of_sound: DOFArray
smoothness: DOFArray
smoothness_mu: DOFArray


@dataclass_array_container
Expand Down Expand Up @@ -171,7 +171,7 @@ def get_internal_energy(self, temperature, species_mass_fractions=None):
def dependent_vars(
self, cv: ConservedVars,
temperature_seed: Optional[DOFArray] = None,
smoothness: Optional[DOFArray] = None) -> GasDependentVars:
smoothness_mu: Optional[DOFArray] = None) -> GasDependentVars:
"""Get an agglomerated array of the dependent variables.
Certain implementations of :class:`GasEOS` (e.g. :class:`MixtureEOS`)
Expand All @@ -180,15 +180,15 @@ def dependent_vars(
"""
temperature = self.temperature(cv, temperature_seed)
# MJA, it doesn't appear that we can have a None field embedded inside DV,
# make a dummy smoothness in this case
if smoothness is None:
smoothness = 0. * cv.mass
# make a dummy smoothness_mu in this case
if smoothness_mu is None:
smoothness_mu = 0. * cv.mass

return GasDependentVars(
temperature=temperature,
pressure=self.pressure(cv, temperature),
speed_of_sound=self.sound_speed(cv, temperature),
smoothness=smoothness
smoothness_mu=smoothness_mu
)


Expand Down Expand Up @@ -240,7 +240,7 @@ def get_species_source_terms(self, cv: ConservedVars, temperature: DOFArray):
def dependent_vars(
self, cv: ConservedVars,
temperature_seed: Optional[DOFArray] = None,
smoothness: Optional[DOFArray] = None) -> MixtureDependentVars:
smoothness_mu: Optional[DOFArray] = None) -> MixtureDependentVars:
"""Get an agglomerated array of the dependent variables.
Certain implementations of :class:`GasEOS` (e.g. :class:`MixtureEOS`)
Expand All @@ -249,16 +249,16 @@ def dependent_vars(
"""
temperature = self.temperature(cv, temperature_seed)
# MJA, it doesn't appear that we can have a None field embedded inside DV,
# make a dummy smoothness in this case
if smoothness is None:
smoothness = 0. * cv.mass
# make a dummy smoothness_mu in this case
if smoothness_mu is None:
smoothness_mu = 0. * cv.mass

return MixtureDependentVars(
temperature=temperature,
pressure=self.pressure(cv, temperature),
speed_of_sound=self.sound_speed(cv, temperature),
species_enthalpies=self.species_enthalpies(cv, temperature),
smoothness=smoothness
smoothness_mu=smoothness_mu
)


Expand Down
54 changes: 27 additions & 27 deletions mirgecom/gas_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class FluidState:
.. autoattribute:: nspecies
.. autoattribute:: pressure
.. autoattribute:: temperature
.. autoattribute:: smoothness
.. autoattribute:: smoothness_mu
.. autoattribute:: velocity
.. autoattribute:: speed
.. autoattribute:: wavespeed
Expand Down Expand Up @@ -153,9 +153,9 @@ def temperature(self):
return self.dv.temperature

@property
def smoothness(self):
"""Return the smoothness field."""
return self.dv.smoothness
def smoothness_mu(self):
"""Return the smoothness_mu field."""
return self.dv.smoothness_mu

@property
def mass_density(self):
Expand Down Expand Up @@ -269,7 +269,7 @@ def species_diffusivity(self):
return self.tv.species_diffusivity


def make_fluid_state(cv, gas_model, temperature_seed=None, smoothness=None,
def make_fluid_state(cv, gas_model, temperature_seed=None, smoothness_mu=None,
limiter_func=None, limiter_dd=None):
"""Create a fluid state from the conserved vars and physical gas model.
Expand Down Expand Up @@ -307,14 +307,14 @@ def make_fluid_state(cv, gas_model, temperature_seed=None, smoothness=None,
dd=limiter_dd)

# FIXME work-around for now
if smoothness is None:
smoothness = cv.mass*0.0
if smoothness_mu is None:
smoothness_mu = cv.mass*0.0

dv = GasDependentVars(
temperature=temperature,
pressure=pressure,
speed_of_sound=gas_model.eos.sound_speed(cv, temperature),
smoothness=smoothness
smoothness_mu=smoothness_mu
)

from mirgecom.eos import MixtureEOS, MixtureDependentVars
Expand All @@ -323,7 +323,7 @@ def make_fluid_state(cv, gas_model, temperature_seed=None, smoothness=None,
temperature=dv.temperature,
pressure=dv.pressure,
speed_of_sound=dv.speed_of_sound,
smoothness=dv.smoothness,
smoothness_mu=dv.smoothness_mu,
species_enthalpies=gas_model.eos.species_enthalpies(cv, temperature))

if gas_model.transport is not None:
Expand Down Expand Up @@ -381,12 +381,12 @@ def project_fluid_state(dcoll, src, tgt, state, gas_model, limiter_func=None):
if state.is_mixture:
temperature_seed = op.project(dcoll, src, tgt, state.dv.temperature)

smoothness = None
if state.dv.smoothness is not None:
smoothness = op.project(dcoll, src, tgt, state.dv.smoothness)
smoothness_mu = None
if state.dv.smoothness_mu is not None:
smoothness_mu = op.project(dcoll, src, tgt, state.dv.smoothness_mu)

return make_fluid_state(cv=cv_sd, gas_model=gas_model,
temperature_seed=temperature_seed, smoothness=smoothness,
temperature_seed=temperature_seed, smoothness_mu=smoothness_mu,
limiter_func=limiter_func, limiter_dd=tgt)


Expand All @@ -398,7 +398,7 @@ def _getattr_ish(obj, name):


def make_fluid_state_trace_pairs(cv_pairs, gas_model, temperature_seed_pairs=None,
smoothness_pairs=None, limiter_func=None):
smoothness_mu_pairs=None, limiter_func=None):
"""Create a fluid state from the conserved vars and equation of state.
This routine helps create a thermally consistent fluid state out of a collection
Expand Down Expand Up @@ -436,21 +436,21 @@ def make_fluid_state_trace_pairs(cv_pairs, gas_model, temperature_seed_pairs=Non
from grudge.trace_pair import TracePair
if temperature_seed_pairs is None:
temperature_seed_pairs = [None] * len(cv_pairs)
if smoothness_pairs is None:
smoothness_pairs = [None] * len(cv_pairs)
if smoothness_mu_pairs is None:
smoothness_mu_pairs = [None] * len(cv_pairs)
return [TracePair(
cv_pair.dd,
interior=make_fluid_state(cv_pair.int, gas_model,
temperature_seed=_getattr_ish(tseed_pair, "int"),
smoothness=_getattr_ish(smoothness_pair, "int"),
smoothness_mu=_getattr_ish(smoothness_mu_pair, "int"),
limiter_func=limiter_func, limiter_dd=cv_pair.dd),
exterior=make_fluid_state(cv_pair.ext, gas_model,
temperature_seed=_getattr_ish(tseed_pair, "ext"),
smoothness=_getattr_ish(smoothness_pair, "ext"),
smoothness_mu=_getattr_ish(smoothness_mu_pair, "ext"),
limiter_func=limiter_func, limiter_dd=cv_pair.dd))
for cv_pair, tseed_pair, smoothness_pair in zip(cv_pairs,
for cv_pair, tseed_pair, smoothness_mu_pair in zip(cv_pairs,
temperature_seed_pairs,
smoothness_pairs)]
smoothness_mu_pairs)]


class _FluidCVTag:
Expand All @@ -461,7 +461,7 @@ class _FluidTemperatureTag:
pass


class _FluidSmoothnessTag:
class _FluidSmoothnessMuTag:
pass


Expand Down Expand Up @@ -569,18 +569,18 @@ def make_operator_fluid_states(
dcoll, volume_state.temperature, volume_dd=dd_vol,
comm_tag=(_FluidTemperatureTag, comm_tag))]

smoothness_interior_pairs = None
if volume_state.smoothness is not None:
smoothness_interior_pairs = [
smoothness_mu_interior_pairs = None
if volume_state.smoothness_mu is not None:
smoothness_mu_interior_pairs = [
interp_to_surf_quad(tpair=tpair)
for tpair in interior_trace_pairs(
dcoll, volume_state.smoothness, volume_dd=dd_vol,
tag=(_FluidSmoothnessTag, comm_tag))]
dcoll, volume_state.smoothness_mu, volume_dd=dd_vol,
tag=(_FluidSmoothnessMuTag, comm_tag))]

interior_boundary_states_quad = \
make_fluid_state_trace_pairs(cv_interior_pairs, gas_model,
tseed_interior_pairs,
smoothness_interior_pairs,
smoothness_mu_interior_pairs,
limiter_func=limiter_func)

# Interpolate the fluid state to the volume quadrature grid
Expand Down
6 changes: 3 additions & 3 deletions mirgecom/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def viscosity(self, cv: ConservedVars, # type: ignore[override]
dv: GasDependentVars,
eos: GasEOS) -> DOFArray:
r"""Get the gas dynamic viscosity, $\mu$."""
return (dv.smoothness*self.av_viscosity(cv, dv, eos)
return (dv.smoothness_mu*self.av_viscosity(cv, dv, eos)
+ self._physical_transport.viscosity(cv, dv))

def volume_viscosity(self, cv: ConservedVars, # type: ignore[override]
Expand All @@ -550,15 +550,15 @@ def volume_viscosity(self, cv: ConservedVars, # type: ignore[override]
$\lambda = \left(\mu_{B} - \frac{2\mu}{3}\right)$
"""
return (dv.smoothness*self.av_viscosity(cv, dv, eos)
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$."""
mu = self.av_viscosity(cv, dv, eos)
av_kappa = (dv.smoothness*mu
av_kappa = (dv.smoothness_mu*mu
* eos.heat_capacity_cp(cv, dv.temperature)/self._av_prandtl)
return av_kappa + self._physical_transport.thermal_conductivity(
cv, dv, eos)
Expand Down

0 comments on commit e7416ea

Please sign in to comment.