fix: align PNL0003 Reynolds diagnostic with AMESim
This commit is contained in:
1 parent
60b743dd81
commit
27f9f4add8
5 files changed
+100
-3
No files matched your search
@@ -1667,6 +1667,16 @@ class AmesimPnl0003(DynamicComponent):
|
||||
viscosity = self._dynamic_viscosity(temperature)
|
||||
return 4.0 * abs(mass_flow) / (pi * self.diam * viscosity)
|
||||
|
||||
def reported_reynolds_number(
|
||||
self,
|
||||
mass_flow: float,
|
||||
temperature: float,
|
||||
) -> float:
|
||||
"""Return AMESim's derived re without changing pipe dynamics."""
|
||||
|
||||
viscosity = self.medium.diagnostic_dynamic_viscosity(temperature)
|
||||
return 4.0 * abs(mass_flow) / (pi * self.diam * viscosity)
|
||||
|
||||
def friction_factor(self, reynolds_number: float) -> float:
|
||||
return AmesimPnl00r.friction_factor(self, reynolds_number)
|
||||
|
||||
@@ -1734,6 +1744,7 @@ class AmesimPnl0003(DynamicComponent):
|
||||
center_flow = self.resistance_mass_flow()
|
||||
upstream = port_1 if center_flow >= 0.0 else port_2
|
||||
reynolds = self.reynolds_number(center_flow, upstream.T)
|
||||
reported_reynolds = self.reported_reynolds_number(center_flow, upstream.T)
|
||||
friction = self.friction_factor(reynolds)
|
||||
return {
|
||||
"m1": self.state_1.m,
|
||||
@@ -1751,7 +1762,7 @@ class AmesimPnl0003(DynamicComponent):
|
||||
"u2": port_2.u,
|
||||
"h2": port_2.h,
|
||||
"dmctr": center_flow,
|
||||
"re": reynolds,
|
||||
"re": reported_reynolds,
|
||||
"cm": _bare_pipe_mass_flow_parameter(
|
||||
center_flow,
|
||||
area=self.area,
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Sequence
|
||||
from dataclasses import dataclass
|
||||
from math import isfinite
|
||||
from math import exp, isfinite, log
|
||||
from typing import ClassVar
|
||||
|
||||
from app.simulation.core.errors import RecoverableTrialStateError
|
||||
@@ -55,6 +55,12 @@ class AmesimHeliumPengRobinsonMedium(IdealGasMedium):
|
||||
fluid: ClassVar[PengRobinsonFluid] = HELIUM_PR
|
||||
nasa_cp_over_R: ClassVar[float] = 2.5
|
||||
nasa_enthalpy_constant_K: ClassVar[float] = -745.375
|
||||
nasa_viscosity_coefficients: ClassVar[tuple[float, float, float, float]] = (
|
||||
0.7501594,
|
||||
35.76324,
|
||||
-2212.129,
|
||||
0.9212635,
|
||||
)
|
||||
|
||||
name: str = "AMESimHeliumPengRobinson"
|
||||
R_gas: float = HELIUM_PR.specific_gas_constant
|
||||
@@ -73,6 +79,19 @@ class AmesimHeliumPengRobinsonMedium(IdealGasMedium):
|
||||
del T
|
||||
return self.cv
|
||||
|
||||
def diagnostic_dynamic_viscosity(self, T: float) -> float:
|
||||
"""Return the AMESim NASA-table viscosity used by pipe diagnostics.
|
||||
|
||||
pn2pipefr reports Reynolds number with sagum viscosity. Keep this
|
||||
separate from dynamic_viscosity so matching that diagnostic cannot
|
||||
alter the already-validated pipe flow or friction dynamics.
|
||||
"""
|
||||
|
||||
if T <= 0.0:
|
||||
raise ValueError("Temperature must be positive.")
|
||||
a, b, c, d = self.nasa_viscosity_coefficients
|
||||
return 1.0e-7 * exp(a * log(T) + b / T + c / (T * T) + d)
|
||||
|
||||
@profile_property("density")
|
||||
@cache_property_calculation("density")
|
||||
def density(self, p: float, T: float) -> float:
|
||||
|
||||
Reference in new issue
Block a user