Skip to content

Commit

Permalink
Merge branch 'build-production' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
MTCam committed Sep 9, 2024
2 parents 66c5713 + 6f9e0e3 commit c99d72d
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 124 deletions.
18 changes: 10 additions & 8 deletions examples/ablation-workshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def bulk_viscosity(self, cv: ConservedVars, # type: ignore[override]
def volume_viscosity(self, cv: ConservedVars, # type: ignore[override]
dv: GasDependentVars, eos: GasEOS) -> DOFArray:
r"""Get the 2nd viscosity coefficent, $\lambda$."""
return (self.bulk_viscosity(cv, dv, eos) - 2./3.)*self.viscosity(cv, dv, eos)
return (self.bulk_viscosity(cv, dv, eos) # type: ignore
- 2./3.)*self.viscosity(cv, dv, eos) # type: ignore

def viscosity(self, cv: ConservedVars, # type: ignore[override]
dv: GasDependentVars, eos: GasEOS) -> DOFArray:
Expand All @@ -342,7 +343,7 @@ def thermal_conductivity(self, cv: ConservedVars, # type: ignore[override]
def species_diffusivity(self, cv: ConservedVars, # type: ignore[override]
dv: GasDependentVars, eos: GasEOS) -> DOFArray:
"""Return the (empty) species mass diffusivities."""
return cv.species_mass # empty array
return cv.species_mass # type: ignore


class TabulatedGasEOS(MixtureEOS):
Expand Down Expand Up @@ -414,7 +415,7 @@ def get_internal_energy(self, temperature: DOFArray,
e(T) = h(T) - \frac{R}{M} T
"""
gas_const = self.gas_const(cv=None, temperature=temperature)
return self.enthalpy(temperature) - gas_const*temperature
return self.enthalpy(temperature) - gas_const*temperature # type: ignore

def heat_capacity_cp(self, cv: ConservedVars, temperature: DOFArray) -> DOFArray:
r"""Return the gas heat capacity at constant pressure $C_{p_g}$.
Expand All @@ -429,7 +430,8 @@ def heat_capacity_cp(self, cv: ConservedVars, temperature: DOFArray) -> DOFArray

def heat_capacity_cv(self, cv: ConservedVars, temperature: DOFArray) -> DOFArray:
r"""Return the gas heat capacity at constant volume $C_{v_g}$."""
return self.heat_capacity_cp(cv, temperature)/self.gamma(cv, temperature)
mcp = self.heat_capacity_cp(cv, temperature)
return mcp/self.gamma(cv, temperature) # type: ignore

def gamma(self, cv: Optional[ConservedVars] = None,
temperature: Optional[DOFArray] = None) -> DOFArray:
Expand All @@ -445,7 +447,7 @@ def pressure(self, cv: ConservedVars, temperature: DOFArray) -> DOFArray:
P = \frac{\epsilon_g \rho_g}{\epsilon_g} \frac{R}{M} T
"""
gas_const = self.gas_const(cv, temperature)
return cv.mass*gas_const*temperature
return cv.mass*gas_const*temperature # type: ignore

def gas_const(self, cv: Optional[ConservedVars] = None,
temperature: Optional[DOFArray] = None,
Expand All @@ -454,7 +456,7 @@ def gas_const(self, cv: Optional[ConservedVars] = None,
coeffs = self._cs_molar_mass.c
bnds = self._cs_molar_mass.x
molar_mass = eval_spline(temperature, bnds, coeffs)
return 8314.46261815324/molar_mass
return 8314.46261815324/molar_mass # type: ignore

def temperature(self, cv: ConservedVars, temperature_seed=None):
raise NotImplementedError
Expand Down Expand Up @@ -565,7 +567,7 @@ def pressure_diffusivity(self, cv: ConservedVars, wv: PorousWallVars,
where $\mu$ is the gas viscosity, $\epsilon_g$ is the void fraction
and $\mathbf{K}$ is the permeability matrix.
"""
return cv.mass*wv.permeability/(viscosity*wv.void_fraction)
return cv.mass*wv.permeability/(viscosity*wv.void_fraction) # type: ignore


class TacotEOS(OriginalTacotEOS):
Expand All @@ -575,7 +577,7 @@ def permeability(self, tau: DOFArray) -> DOFArray:
r"""Permeability $K$ of the composite material."""
virgin = 1.6e-11
char = 2.0e-11
return virgin*tau + char*(1.0 - tau)
return virgin*tau + char*(1.0 - tau) # type: ignore


def binary_sum(ary):
Expand Down
20 changes: 10 additions & 10 deletions mirgecom/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def internal_energy(self, cv: ConservedVars) -> DOFArray:
e = \rho{E} - \frac{1}{2\rho}(\rho\vec{V} \cdot \rho\vec{V})
"""
return (cv.energy - self.kinetic_energy(cv))
return (cv.energy - self.kinetic_energy(cv)) # type: ignore

def pressure(self, cv: ConservedVars,
temperature: Optional[DOFArray] = None) -> DOFArray:
Expand Down Expand Up @@ -520,7 +520,7 @@ def total_energy(self, cv: ConservedVars, pressure: DOFArray,
+ self.kinetic_energy(cv))

def get_internal_energy(self, temperature: DOFArray,
species_mass_fractions: Optional[DOFArray] = None) -> DOFArray:
species_mass_fractions: Optional[np.ndarray] = None) -> DOFArray:
r"""Get the gas thermal energy from temperature.
The gas internal energy $e$ is calculated from:
Expand Down Expand Up @@ -601,7 +601,7 @@ def __init__(self, pyrometheus_mech, temperature_guess=300.0):
self._tguess = temperature_guess

def get_temperature_seed(self, ary: Optional[DOFArray] = None,
temperature_seed: Optional[DOFArray] = None) -> DOFArray:
temperature_seed: Optional[Union[float, DOFArray]] = None) -> DOFArray:
"""Get a *cv*-shaped array with which to seed temperature calcuation.
Parameters
Expand All @@ -626,7 +626,7 @@ def get_temperature_seed(self, ary: Optional[DOFArray] = None,
else:
if ary is None:
raise ValueError("Requires *ary* for shaping temperature seed.")
return tseed * (0*ary + 1.0)
return tseed * (0. * ary + 1.0) # type: ignore

def heat_capacity_cp(self, cv: ConservedVars, temperature: DOFArray) -> DOFArray:
r"""Get mixture-averaged specific heat capacity at constant pressure."""
Expand Down Expand Up @@ -692,7 +692,7 @@ def internal_energy(self, cv: ConservedVars) -> DOFArray:
e = \rho{E} - \frac{1}{2\rho}(\rho\vec{V} \cdot \rho\vec{V})
"""
return (cv.energy - self.kinetic_energy(cv))
return (cv.energy - self.kinetic_energy(cv)) # type: ignore

def get_density(self, pressure: DOFArray, # type: ignore[override]
temperature: DOFArray, species_mass_fractions: np.ndarray) -> DOFArray:
Expand Down Expand Up @@ -770,7 +770,7 @@ def sound_speed(self, cv: ConservedVars, temperature: DOFArray) -> DOFArray:
c = \sqrt{\frac{\gamma_{\mathtt{mix}}{p}}{\rho}}
"""
actx = cv.array_context
return actx.np.sqrt((self.gamma(cv, temperature)
return actx.np.sqrt((self.gamma(cv, temperature) # type: ignore
* self.pressure(cv, temperature))
/ cv.mass)

Expand Down Expand Up @@ -799,7 +799,7 @@ def temperature(self, cv: ConservedVars,
tseed = self.get_temperature_seed(cv.mass, temperature_seed)

y = cv.species_mass_fractions
e = self.internal_energy(cv) / cv.mass
e = self.internal_energy(cv) / cv.mass # type: ignore
return self._pyrometheus_mech.get_temperature(e, tseed, y)

def temperature_from_enthalpy(self, enthalpy: DOFArray,
Expand Down Expand Up @@ -852,7 +852,7 @@ def total_energy(self, cv: ConservedVars, pressure: DOFArray,
inversion interfaces.
"""
y = cv.species_mass_fractions
return (cv.mass * self.get_internal_energy(temperature, y)
return (cv.mass * self.get_internal_energy(temperature, y) # type: ignore
+ self.kinetic_energy(cv))

def get_species_source_terms(self, cv: ConservedVars, temperature: DOFArray):
Expand All @@ -867,9 +867,9 @@ def get_species_source_terms(self, cv: ConservedVars, temperature: DOFArray):
w = self.get_species_molecular_weights()
dim = cv.dim
species_sources = w * omega
rho_source = 0 * cv.mass
rho_source = 0 * cv.mass # type: ignore
mom_source = 0 * cv.momentum
energy_source = 0 * cv.energy
energy_source = 0 * cv.energy # type: ignore

return make_conserved(dim, rho_source, energy_source, mom_source,
species_sources)
Expand Down
12 changes: 6 additions & 6 deletions mirgecom/inviscid.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ def entropy_conserving_flux_chandrashekar(gas_model, state_ll, state_rr):
gamma_rr = gas_model.eos.gamma(state_rr.cv, state_rr.temperature)

def ln_mean(x: DOFArray, y: DOFArray, epsilon=1e-4):
f2 = (x * (x - 2 * y) + y * y) / (x * (x + 2 * y) + y * y)
f2 = (x * (x - 2 * y) + y * y) / (x * (x + 2 * y) + y * y) # type: ignore
return actx.np.where(
actx.np.less(f2, epsilon),
(x + y) / (2 + f2*2/3 + f2*f2*2/5 + f2*f2*f2*2/7),
(y - x) / actx.np.log(y / x)
(x + y) / (2 + f2*2/3 + f2*f2*2/5 + f2*f2*f2*2/7), # type: ignore
(y - x) / actx.np.log(y / x) # type: ignore
)

# Primitive variables for left and right states
Expand Down Expand Up @@ -501,11 +501,11 @@ def entropy_conserving_flux_renac(gas_model, state_ll, state_rr):
pot_avg = 0.5*(pot_ll + pot_rr)

def ln_mean(x: DOFArray, y: DOFArray, epsilon=1e-4):
f2 = (x * (x - 2 * y) + y * y) / (x * (x + 2 * y) + y * y)
f2 = (x * (x - 2 * y) + y * y) / (x * (x + 2 * y) + y * y) # type: ignore
return actx.np.where(
actx.np.less(f2, epsilon),
(x + y) / (2 + f2*2/3 + f2*f2*2/5 + f2*f2*f2*2/7),
(y - x) / actx.np.log(y / x)
(x + y) / (2 + f2*2/3 + f2*f2*2/5 + f2*f2*f2*2/7), # type: ignore
(y - x) / actx.np.log(y / x) # type: ignore
)

theta_mean = ln_mean(theta_ll, theta_rr)
Expand Down
53 changes: 32 additions & 21 deletions mirgecom/materials/carbon_fiber.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def puma_effective_surface_area(self, tau: DOFArray) -> DOFArray:
"""Polynomial fit based on PUMA data."""
# Original fit function: -1.1012e5*x**2 - 0.0646e5*x + 1.1794e5
# Rescale by x==0 value and rearrange
progress = 1.0-tau
return 1.1794e5*(1.0 - 0.0547736137*progress - 0.9336950992*progress**2)
progress = 1.0-tau # type: ignore
return 1.1794e5*(1.0 - 0.0547736137*progress # type: ignore
- 0.9336950992*progress**2)

def _get_wall_effective_surface_area_fiber(self, tau: DOFArray) -> DOFArray:
"""Evaluate the effective surface of the fibers."""
Expand All @@ -92,11 +93,11 @@ def get_source_terms(self, temperature: DOFArray, tau: DOFArray,

eff_surf_area = self._get_wall_effective_surface_area_fiber(tau)
alpha = (
(0.00143+0.01*actx.np.exp(-1450.0/temperature))
/ (1.0+0.0002*actx.np.exp(13000.0/temperature)))
(0.00143+0.01*actx.np.exp(-1450.0/temperature)) # type: ignore
/ (1.0+0.0002*actx.np.exp(13000.0/temperature))) # type: ignore
k = alpha*actx.np.sqrt(
(univ_gas_const*temperature)/(2.0*np.pi*mw_o2))
return (mw_co/mw_o2 + mw_o/mw_o2 - 1)*rhoY_o2*k*eff_surf_area
(univ_gas_const*temperature)/(2.0*np.pi*mw_o2)) # type: ignore
return (mw_co/mw_o2 + mw_o/mw_o2 - 1)*rhoY_o2*k*eff_surf_area # type: ignore


class FiberEOS(PorousWallEOS):
Expand Down Expand Up @@ -152,15 +153,17 @@ def void_fraction(self, tau: DOFArray) -> DOFArray:
$\epsilon_g + \epsilon_s = 1$. Both depend only on the oxidation
progress ratio $\tau$.
"""
return 1.0 - self.volume_fraction(tau)
return 1.0 - self.volume_fraction(tau) # type: ignore

def enthalpy(self, temperature: DOFArray,
tau: Optional[DOFArray] = None) -> DOFArray:
r"""Evaluate the solid enthalpy $h_s$ of the fibers."""
return (
- 3.37112113e-11*temperature**5 + 3.13156695e-07*temperature**4
- 1.17026962e-03*temperature**3 + 2.29194901e+00*temperature**2
- 3.62422269e+02*temperature**1 - 5.96993843e+04)
- 3.37112113e-11*temperature**5 # type: ignore
+ 3.13156695e-07*temperature**4 # type: ignore
- 1.17026962e-03*temperature**3 # type: ignore
+ 2.29194901e+00*temperature**2 # type: ignore
- 3.62422269e+02*temperature**1 - 5.96993843e+04) # type: ignore

def heat_capacity(self, temperature: DOFArray,
tau: Optional[DOFArray] = None) -> DOFArray:
Expand All @@ -170,8 +173,10 @@ def heat_capacity(self, temperature: DOFArray,
enthalpy fit.
"""
return (
- 1.68556056e-10*temperature**4 + 1.25262678e-06*temperature**3
- 3.51080885e-03*temperature**2 + 4.58389802e+00*temperature**1
- 1.68556056e-10*temperature**4 # type: ignore
+ 1.25262678e-06*temperature**3 # type: ignore
- 3.51080885e-03*temperature**2 # type: ignore
+ 4.58389802e+00*temperature**1 # type: ignore
- 3.62422269e+02)

# ~~~~~~~~ fiber conductivity
Expand All @@ -181,13 +186,17 @@ def thermal_conductivity(self, temperature, tau) -> np.ndarray:
It accounts for anisotropy and oxidation progress.
"""
kappa_ij = (
+ 2.86518890e-24*temperature**5 - 2.13976832e-20*temperature**4
+ 3.36320767e-10*temperature**3 - 6.14199551e-07*temperature**2
+ 2.86518890e-24*temperature**5
- 2.13976832e-20*temperature**4
+ 3.36320767e-10*temperature**3
- 6.14199551e-07*temperature**2
+ 7.92469194e-04*temperature**1 + 1.18270446e-01)

kappa_k = (
- 1.89693642e-24*temperature**5 + 1.43737973e-20*temperature**4
+ 1.93072961e-10*temperature**3 - 3.52595953e-07*temperature**2
- 1.89693642e-24*temperature**5
+ 1.43737973e-20*temperature**4
+ 1.93072961e-10*temperature**3
- 3.52595953e-07*temperature**2
+ 4.54935976e-04*temperature**1 + 5.08960039e-02)

# initialize with the in-plane value
Expand All @@ -201,7 +210,7 @@ def thermal_conductivity(self, temperature, tau) -> np.ndarray:
# ~~~~~~~~ other properties
def volume_fraction(self, tau: DOFArray) -> DOFArray:
r"""Fraction $\phi$ occupied by the solid."""
return 0.12*tau
return 0.12*tau # type: ignore

def permeability(self, tau: DOFArray) -> np.ndarray:
r"""Permeability $K$ of the porous material."""
Expand All @@ -217,17 +226,19 @@ def emissivity(self, temperature: DOFArray, # type: ignore[override]
tau: Optional[DOFArray] = None) -> DOFArray:
"""Emissivity for energy radiation."""
return (
+ 2.26413679e-18*temperature**5 - 2.03008004e-14*temperature**4
+ 7.05300324e-11*temperature**3 - 1.22131715e-07*temperature**2
+ 1.21137817e-04*temperature**1 + 8.66656964e-01)
+ 2.26413679e-18*temperature**5 # type: ignore
- 2.03008004e-14*temperature**4 # type: ignore
+ 7.05300324e-11*temperature**3 # type: ignore
- 1.22131715e-07*temperature**2 # type: ignore
+ 1.21137817e-04*temperature**1 + 8.66656964e-01) # type: ignore

def tortuosity(self, tau: DOFArray) -> DOFArray:
r"""Tortuosity $\eta$ affects the species diffusivity.
.. math:
D_{eff} = \frac{D_i^(m)}{\eta}
"""
return 1.1*tau + 1.0*(1.0 - tau)
return 1.1*tau + 1.0*(1.0 - tau) # type: ignore

def decomposition_progress(self, mass: DOFArray) -> DOFArray:
r"""Evaluate the mass loss progress ratio $\tau$ of the oxidation."""
Expand Down
7 changes: 4 additions & 3 deletions mirgecom/materials/prescribed_porous_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,19 @@ def void_fraction(self, tau: DOFArray) -> DOFArray:
$\epsilon_g + \epsilon_s = 1$. Both depend only on the oxidation
progress ratio $\tau$.
"""
return 1.0 - self.volume_fraction(tau)
return 1.0 - self.volume_fraction(tau) # type: ignore

def enthalpy(self, temperature: DOFArray, tau: Optional[DOFArray]) -> DOFArray:
r"""Evaluate the solid enthalpy $h_s$."""
return self._enthalpy_func(temperature)

def heat_capacity(self, temperature: DOFArray,
tau: Optional[DOFArray]) -> DOFArray:
tau: Optional[DOFArray] = None) -> DOFArray:
r"""Evaluate the heat capacity $C_{p_s}$."""
return self._heat_capacity_func(temperature)

def thermal_conductivity(self, temperature: DOFArray, tau: DOFArray) -> DOFArray:
def thermal_conductivity(self, temperature: DOFArray,
tau: Optional[DOFArray] = None) -> DOFArray:
r"""Evaluate the thermal conductivity $\kappa$"""
return self._thermal_conductivity_func(temperature)

Expand Down
Loading

0 comments on commit c99d72d

Please sign in to comment.