fix: bound reported pipe friction diagnostics

This commit is contained in:
Codex committed 2026-08-16 11:03:21 +00:00
1 parent 5332a788f3
commit f09dfcf542
2 files changed
+18 -19

No files matched your search

+11 -4
View File
@@ -27,6 +27,13 @@ from app.simulation.core.ports import PortDefinition
from app.simulation.core.state import VolumeState
_MAX_REPORTED_FRICTION_FACTOR = 64_000_000.0
def _reported_friction_factor(value: float) -> float:
return min(float(value), _MAX_REPORTED_FRICTION_FACTOR)
_DYNAMIC_PIPE_POLYTROPIC_MODE = ParameterCondition("mode", (1.0,))
_DYNAMIC_PIPE_HEAT_EXCHANGE_MODE = ParameterCondition("mode", (2.0,))
_DYNAMIC_PIPE_PARAMETER_GROUPS = (
@@ -315,7 +322,7 @@ class AmesimPnl00r(AlgebraicComponent):
"re": reynolds,
"cm": cm,
"v": velocity,
"ff": self.friction_factor(reynolds),
"ff": _reported_friction_factor(self.friction_factor(reynolds)),
}
def pressure_flow_equation_values(self) -> tuple[float, ...]:
@@ -842,7 +849,7 @@ class AmesimPnl0001(ThermodynamicVolumeComponent):
/ max(self.area * upstream_pressure, 1.0e-18)
),
"v": flow / (density * self.area),
"ff": self.friction_factor(reynolds),
"ff": _reported_friction_factor(self.friction_factor(reynolds)),
}
def pressure_flow_equation_values(self) -> tuple[float, ...]:
@@ -1092,7 +1099,7 @@ class AmesimPnl0002(AmesimPnl0001):
"re": reynolds,
"cm": cm,
"v": velocity,
"ff": friction,
"ff": _reported_friction_factor(friction),
}
def pressure_flow_equation_values(self) -> tuple[float, ...]:
@@ -1442,7 +1449,7 @@ class AmesimPnl0003(DynamicComponent):
/ max(self.area * max(port_1.p, port_2.p, 1.0), 1.0e-18)
),
"v": center_flow / (max(upstream.rho, 1.0e-12) * self.area),
"ff": self.friction_factor(reynolds),
"ff": _reported_friction_factor(self.friction_factor(reynolds)),
}
def pressure_flow_equation_values(self) -> tuple[float, ...]: