对齐Amesim氦气PR物性与PNVO流量

This commit is contained in:
huojiarong committed 2026-08-03 15:34:33 +00:00
1 parent 18d9802f03
commit 046aa49814
13 files changed
+730 -73

No files matched your search

@@ -3,6 +3,9 @@ from __future__ import annotations
import unittest
from app.simulation.components.amesim.flow.orifices import AmesimPnvo001FixedOpening
from app.simulation.components.amesim.media.mediums import (
AmesimHeliumPengRobinsonMedium,
)
from app.simulation.core.medium import IdealGasMedium
from app.simulation.registry import COMPONENT_MODEL_REGISTRY
@@ -61,6 +64,86 @@ class AmesimPnvo001FixedOpeningComponentTests(unittest.TestCase):
self.assertLess(reverse, 0.0)
self.assertAlmostEqual(forward, -reverse)
def test_mass_flow_uses_connected_enthalpy_from_the_upstream_side(self) -> None:
valve = AmesimPnvo001FixedOpening("valve_1", self.medium, opening=0.5)
hot_h = self.medium.specific_enthalpy(600.0)
cold_h = self.medium.specific_enthalpy(200.0)
valve.update_stream_outflows({"port_2": hot_h, "port_3": cold_h})
self.assertEqual(valve.port_2.h_outflow, cold_h)
self.assertEqual(valve.port_3.h_outflow, hot_h)
self.assertAlmostEqual(
valve.mass_flow(500000.0, 100000.0),
valve._one_way_mass_flow(
upstream_pressure=500000.0,
downstream_pressure=100000.0,
upstream_temperature=600.0,
),
)
self.assertAlmostEqual(
valve.mass_flow(100000.0, 500000.0),
-valve._one_way_mass_flow(
upstream_pressure=500000.0,
downstream_pressure=100000.0,
upstream_temperature=200.0,
),
)
def test_helium_flow_uses_pressure_enthalpy_and_real_gas_factor(self) -> None:
medium = AmesimHeliumPengRobinsonMedium()
valve = AmesimPnvo001FixedOpening(
"valve_1",
medium,
cq=0.45,
area0=78.5e-6,
opening=1.0,
)
upstream_pressure = 15_201_996.778497815
downstream_pressure = 405_072.8123335606
upstream_temperature = 292.3997890954483
valve.port_2.p = upstream_pressure
valve.port_3.p = downstream_pressure
upstream_enthalpy = medium.specific_enthalpy_at_pressure(
upstream_pressure,
upstream_temperature,
)
valve.update_stream_outflows(
{
"port_2": upstream_enthalpy,
"port_3": medium.specific_enthalpy_at_pressure(
downstream_pressure,
393.46713105173205,
),
}
)
self.assertLess(upstream_enthalpy, 0.0)
self.assertAlmostEqual(
valve._upstream_temperature("port_2"),
upstream_temperature,
delta=1.0e-8,
)
self.assertAlmostEqual(
valve.mass_flow(upstream_pressure, downstream_pressure),
0.49551308906777447,
delta=1.0e-9,
)
results = valve.component_result_values()
self.assertAlmostEqual(
results["cm"],
0.015778323343746598,
delta=1.0e-11,
)
self.assertAlmostEqual(
results["gasvel"],
894.7011595213406,
delta=1.0e-8,
)
if __name__ == "__main__":
unittest.main()