修正动态管与阀门诊断输出

This commit is contained in:
huojiarong committed 2026-08-18 10:24:29 +00:00
1 parent f725f038b6
commit 53f8601fec
6 files changed
+219 -16

No files matched your search

+28
View File
@@ -1,6 +1,7 @@
from __future__ import annotations
import unittest
from math import sqrt
from app.simulation.components.amesim.flow.pipes import AmesimPnl0001
from app.simulation.core.medium import IdealGasMedium
@@ -148,6 +149,33 @@ class AmesimPnl0001ComponentTests(unittest.TestCase):
{"m", "U", "p", "T", "rho", "u", "h", "re", "cm", "v", "ff"},
)
def test_result_cm_excludes_pipe_flow_coefficient(self) -> None:
pipe = AmesimPnl0001(
"pnl_1",
self.medium,
diam=0.014,
le=0.3,
rr=0.045 / 14.0,
p0=2.5e6,
T0=290.0,
)
pipe.port_1.p = 1.6e6
props = pipe.properties()
flow = pipe.mass_flow(pipe.port_1.p, props.p, props.T)
reynolds = pipe.reynolds_number(flow, props.T)
friction = pipe.friction_factor(reynolds)
raw_cq_cm = (
abs(flow)
* sqrt(props.T)
/ (pipe.area * max(pipe.port_1.p, props.p))
)
flow_coefficient = sqrt(pipe.diam / (pipe.le * friction))
actual = pipe.component_result_values()["cm"]
self.assertAlmostEqual(actual, raw_cq_cm / flow_coefficient)
self.assertNotAlmostEqual(actual, raw_cq_cm)
if __name__ == "__main__":
unittest.main()