完善AMESim组件界面与仿真求解稳定性
This commit is contained in:
1 parent
e7177ab03e
commit
410ef535e8
34 files changed
+3340
-251
No files matched your search
@@ -84,6 +84,126 @@ def amesim_pnvo001_signal_project() -> ReactFlowProjectPayload:
|
||||
)
|
||||
|
||||
|
||||
def high_pressure_helium_step_project() -> ReactFlowProjectPayload:
|
||||
chamber_ports = [
|
||||
physical_port("port_1", "bidirectional", "left"),
|
||||
physical_port("port_2", "bidirectional", "right"),
|
||||
]
|
||||
return ReactFlowProjectPayload(
|
||||
name="amesim-pnvo001-helium-step-regression",
|
||||
nodes=[
|
||||
component_node(
|
||||
"helium_1",
|
||||
"amesim_helium_medium",
|
||||
[],
|
||||
{"gi": 1.0, "property_model": 0.0},
|
||||
),
|
||||
component_node(
|
||||
"step_1",
|
||||
"amesim_step0",
|
||||
[signal_port("out", "output", "right")],
|
||||
{"initial": 0.0, "final": 1.0, "time": 0.04},
|
||||
),
|
||||
component_node(
|
||||
"high_chamber",
|
||||
"amesim_pnch023",
|
||||
chamber_ports,
|
||||
{
|
||||
"gi": 1.0,
|
||||
"cvol": 0.057,
|
||||
"kth": 0.0,
|
||||
"sth": 0.1,
|
||||
"extemp": 293.15,
|
||||
"p0": 15_300_000.0,
|
||||
"T0": 293.15,
|
||||
},
|
||||
),
|
||||
component_node(
|
||||
"low_chamber",
|
||||
"amesim_pnch023",
|
||||
chamber_ports,
|
||||
{
|
||||
"gi": 1.0,
|
||||
"cvol": 0.015,
|
||||
"kth": 1500.0,
|
||||
"sth": 0.7,
|
||||
"extemp": 293.15,
|
||||
"p0": 100_000.0,
|
||||
"T0": 293.15,
|
||||
},
|
||||
),
|
||||
component_node(
|
||||
"valve_1",
|
||||
"amesim_pnvo001",
|
||||
[
|
||||
signal_port("res", "input", "left"),
|
||||
physical_port("port_2", "bidirectional", "left"),
|
||||
physical_port("port_3", "bidirectional", "right"),
|
||||
],
|
||||
{
|
||||
"gi": 1.0,
|
||||
"cq": 0.45,
|
||||
"area0": 7.85e-5,
|
||||
"Cv": 0.5,
|
||||
"Kv": 0.4,
|
||||
"flowset": 1.0,
|
||||
"opening0": 1.0,
|
||||
},
|
||||
),
|
||||
component_node(
|
||||
"high_plug",
|
||||
"amesim_pnpl01",
|
||||
[physical_port("port_1", "bidirectional", "left")],
|
||||
{},
|
||||
),
|
||||
component_node(
|
||||
"low_plug",
|
||||
"amesim_pnpl01",
|
||||
[physical_port("port_1", "bidirectional", "left")],
|
||||
{},
|
||||
),
|
||||
],
|
||||
edges=[
|
||||
signal_edge("signal-1", "step_1", "out", "valve_1", "res"),
|
||||
physical_edge(
|
||||
"edge-high-plug",
|
||||
"high_plug",
|
||||
"port_1",
|
||||
"high_chamber",
|
||||
"port_1",
|
||||
),
|
||||
physical_edge(
|
||||
"edge-high-valve",
|
||||
"high_chamber",
|
||||
"port_2",
|
||||
"valve_1",
|
||||
"port_2",
|
||||
),
|
||||
physical_edge(
|
||||
"edge-valve-low",
|
||||
"valve_1",
|
||||
"port_3",
|
||||
"low_chamber",
|
||||
"port_1",
|
||||
),
|
||||
physical_edge(
|
||||
"edge-low-plug",
|
||||
"low_chamber",
|
||||
"port_2",
|
||||
"low_plug",
|
||||
"port_1",
|
||||
),
|
||||
],
|
||||
simulation={
|
||||
"t_start": 0.0,
|
||||
"t_stop": 0.042,
|
||||
"step": 0.002,
|
||||
"max_step": 0.002,
|
||||
"method": "BDF",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class AmesimPnvo001SignalXmlTests(unittest.TestCase):
|
||||
def test_signal_project_compiles_with_signal_connection(self) -> None:
|
||||
network = compile_reactflow_network(amesim_pnvo001_signal_project())
|
||||
@@ -107,6 +227,26 @@ class AmesimPnvo001SignalXmlTests(unittest.TestCase):
|
||||
self.assertIn("valve_1.xv", result["series"])
|
||||
self.assertGreater(result["diagnostics"]["signal"]["propagations"], 0)
|
||||
|
||||
def test_high_pressure_helium_step_restarts_solver_at_event(self) -> None:
|
||||
xml = build_reactflow_system_xml(high_pressure_helium_step_project())
|
||||
result = run_system_xml_simulation(xml)
|
||||
|
||||
self.assertTrue(result["success"], result["message"])
|
||||
self.assertEqual(result["simulatedUntil"], 0.042)
|
||||
self.assertEqual(result["diagnostics"]["signal"]["eventTimes"], [0.04])
|
||||
|
||||
times = result["series"]["time"]
|
||||
before_event = times.index(0.038)
|
||||
at_event = times.index(0.04)
|
||||
self.assertEqual(result["series"]["step_1.out.signal"][before_event], 0.0)
|
||||
self.assertEqual(result["series"]["step_1.out.signal"][at_event], 1.0)
|
||||
self.assertEqual(result["series"]["valve_1.xv"][before_event], 0.0)
|
||||
self.assertEqual(result["series"]["valve_1.xv"][at_event], 1.0)
|
||||
self.assertGreater(
|
||||
result["series"]["valve_1.port_2.m_flow"][at_event],
|
||||
0.45,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user