对齐PNL0002上游温度并稳定热流体闭合
This commit is contained in:
1 parent
6abcc220de
commit
0f73d5b568
5 files changed
+224
-13
No files matched your search
@@ -45,6 +45,80 @@ class AmesimPnl0002ComponentTests(unittest.TestCase):
|
||||
self.assertGreater(forward, 0.0)
|
||||
self.assertLess(reverse, 0.0)
|
||||
|
||||
def test_external_upstream_flow_uses_connected_stream_temperature(self) -> None:
|
||||
pipe = AmesimPnl0002("pnl_2", self.medium, p0=100000.0, T0=350.0)
|
||||
center = pipe.properties()
|
||||
external_pressure = 15.3e6
|
||||
external_temperature = 293.15
|
||||
external_h = self.medium.specific_enthalpy_at_pressure(
|
||||
external_pressure,
|
||||
external_temperature,
|
||||
)
|
||||
pipe.update_stream_outflows(
|
||||
{"port_1": external_h, "port_2": center.h}
|
||||
)
|
||||
|
||||
flow = pipe.port_mass_flow(
|
||||
external_pressure,
|
||||
center.p,
|
||||
center.T,
|
||||
port_name="port_1",
|
||||
)
|
||||
expected = pipe.mass_flow(
|
||||
external_pressure,
|
||||
center.p,
|
||||
external_temperature,
|
||||
)
|
||||
center_temperature_flow = pipe.mass_flow(
|
||||
external_pressure,
|
||||
center.p,
|
||||
center.T,
|
||||
)
|
||||
|
||||
self.assertAlmostEqual(flow, expected)
|
||||
self.assertNotAlmostEqual(flow, center_temperature_flow)
|
||||
|
||||
def test_missing_stream_cache_preserves_center_temperature_fallback(self) -> None:
|
||||
pipe = AmesimPnl0002("pnl_2", self.medium, p0=100000.0, T0=350.0)
|
||||
center = pipe.properties()
|
||||
external_pressure = 15.3e6
|
||||
|
||||
flow = pipe.port_mass_flow(
|
||||
external_pressure,
|
||||
center.p,
|
||||
center.T,
|
||||
port_name="port_1",
|
||||
)
|
||||
|
||||
self.assertAlmostEqual(
|
||||
flow,
|
||||
pipe.mass_flow(external_pressure, center.p, center.T),
|
||||
)
|
||||
|
||||
def test_center_upstream_flow_keeps_center_temperature(self) -> None:
|
||||
pipe = AmesimPnl0002("pnl_2", self.medium, p0=15.3e6, T0=350.0)
|
||||
center = pipe.properties()
|
||||
external_pressure = 1.0e5
|
||||
external_h = self.medium.specific_enthalpy_at_pressure(
|
||||
external_pressure,
|
||||
293.15,
|
||||
)
|
||||
pipe.update_stream_outflows(
|
||||
{"port_1": external_h, "port_2": center.h}
|
||||
)
|
||||
|
||||
flow = pipe.port_mass_flow(
|
||||
external_pressure,
|
||||
center.p,
|
||||
center.T,
|
||||
port_name="port_1",
|
||||
)
|
||||
|
||||
self.assertAlmostEqual(
|
||||
flow,
|
||||
pipe.mass_flow(external_pressure, center.p, center.T),
|
||||
)
|
||||
|
||||
def test_pressure_flow_residuals_use_two_port_resistances(self) -> None:
|
||||
pipe = AmesimPnl0002("pnl_2", self.medium, p0=100000.0, T0=293.15)
|
||||
center = pipe.properties()
|
||||
|
||||
@@ -464,7 +464,10 @@ class ComponentCatalogTests(unittest.TestCase):
|
||||
with self.subTest(model_type=model_type):
|
||||
component = self.components[model_type]
|
||||
model_parameters = parameters(model_type)
|
||||
self.assertEqual(component["modelVersion"], "0.2.0")
|
||||
expected_version = (
|
||||
"0.3.0" if model_type == "amesim_pnl0002" else "0.2.0"
|
||||
)
|
||||
self.assertEqual(component["modelVersion"], expected_version)
|
||||
self.assertEqual(model_parameters["mode"]["editor"], "choice")
|
||||
self.assertEqual(model_parameters["mode"]["options"], thermal_options)
|
||||
self.assertEqual(
|
||||
|
||||
@@ -11,6 +11,8 @@ from app.simulation.components.amesim.flow.orifices import (
|
||||
)
|
||||
from app.simulation.components.amesim.flow.pipes import AmesimPnl00r
|
||||
from app.simulation.components.amesim.flow.pipes import AmesimPnl0001
|
||||
from app.simulation.components.amesim.flow.pipes import AmesimPnl0002
|
||||
from app.simulation.components.amesim.junctions.nodes import AmesimPn3Node2
|
||||
from app.simulation.components.amesim.media.mediums import (
|
||||
AmesimHeliumPengRobinsonMedium,
|
||||
)
|
||||
@@ -142,6 +144,49 @@ class PressureFlowSolverInitializationTests(unittest.TestCase):
|
||||
)
|
||||
self.assertAlmostEqual(valve.port_3.m_flow, -valve.port_2.m_flow, places=12)
|
||||
|
||||
def test_stream_dependent_pipe_flow_closes_with_junction_mixing_in_one_rhs(self) -> None:
|
||||
medium = IdealGasMedium()
|
||||
hot = Cylinder("hot", medium, V=0.1, p0=500_000.0, T0=400.0)
|
||||
cold = Cylinder("cold", medium, V=0.1, p0=500_000.0, T0=250.0)
|
||||
sink = Tank("sink", medium, V=0.1, p0=100_000.0, T0=300.0)
|
||||
hot_line = AmesimPnl00r("hot_line", medium, diam=0.01, le=0.5)
|
||||
cold_line = AmesimPnl00r("cold_line", medium, diam=0.01, le=0.5)
|
||||
junction = AmesimPn3Node2("junction")
|
||||
pipe = AmesimPnl0002(
|
||||
"pipe",
|
||||
medium,
|
||||
diam=0.01,
|
||||
le=1.0,
|
||||
p0=200_000.0,
|
||||
T0=300.0,
|
||||
)
|
||||
network = SimulationNetwork("stream-flow-fixed-point")
|
||||
for component in (
|
||||
hot,
|
||||
cold,
|
||||
sink,
|
||||
hot_line,
|
||||
cold_line,
|
||||
junction,
|
||||
pipe,
|
||||
):
|
||||
network.add_component(component)
|
||||
network.connect("hot", "port_b", "hot_line", "port_1")
|
||||
network.connect("hot_line", "port_2", "junction", "port_1")
|
||||
network.connect("cold", "port_b", "cold_line", "port_1")
|
||||
network.connect("cold_line", "port_2", "junction", "port_3")
|
||||
network.connect("junction", "port_2", "pipe", "port_1")
|
||||
network.connect("pipe", "port_2", "sink", "port_a")
|
||||
|
||||
system = GenericFluidSystem(network)
|
||||
state = system.consistent_initial_state_vector()
|
||||
first = system.rhs(0.0, state)
|
||||
second = system.rhs(0.0, state)
|
||||
|
||||
self.assertGreater(system.max_thermofluid_iterations, 1)
|
||||
for first_value, second_value in zip(first, second):
|
||||
self.assertAlmostEqual(first_value, second_value, places=10)
|
||||
|
||||
def test_current_storage_pressure_reseeds_stale_orifice_ports_and_flow(self) -> None:
|
||||
network, medium, high, low, valve = self._near_equal_pressure_network()
|
||||
solver = PressureFlowSolver(network, max_evaluations=10)
|
||||
|
||||
Reference in new issue
Block a user