merge/model-development-into-main #2

Merged
lujingze merged 126 commits from merge/model-development-into-main into main 2026-07-31 09:52:44 +08:00
Showing only changes of commit 13f37bfd0f - Show all commits
+143 -118
View File
@@ -1911,6 +1911,39 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
)
return line_derivative, chamber_derivative
@staticmethod
def _write_connection_line(
*,
line: AmesimPnl0001Pipe,
line_properties: ThermodynamicProperties,
port_1_properties: ThermodynamicProperties,
port_1_flow: float,
port_2_properties: ThermodynamicProperties,
port_2_flow: float,
) -> None:
line.port_1.p = port_1_properties.p
line.port_1.m_flow = port_1_flow
line.port_1.h_outflow = line_properties.h
line.port_2.p = port_2_properties.p
line.port_2.m_flow = port_2_flow
line.port_2.h_outflow = line_properties.h
@staticmethod
def _connection_line_derivative(
*,
line: AmesimPnl0001Pipe,
port_1_properties: ThermodynamicProperties,
port_1_flow: float,
port_2_properties: ThermodynamicProperties,
port_2_flow: float,
) -> VolumeState:
return line.derivatives_from_connections(
port_1_m_flow=port_1_flow,
connected_h_1=port_1_properties.h,
port_2_m_flow=port_2_flow,
connected_h_2=port_2_properties.h,
)
def _write_port_states(
self,
snapshot: TestMqlPn3P4NodeChamberSegmentSnapshot,
@@ -1966,13 +1999,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_to_line_flow=snapshot.p4_node_to_primary_line_flow,
)
p4_port1_line = self.components.p4_port1_line
p4_port1_line.port_1.p = snapshot.p4_primary_line.p
p4_port1_line.port_1.m_flow = snapshot.p4_to_port1_line_flow
p4_port1_line.port_1.h_outflow = snapshot.p4_port1_line.h
p4_port1_line.port_2.p = snapshot.p4_port1_remote_primary_line.p
p4_port1_line.port_2.m_flow = snapshot.p4_port1_remote_node_to_line_flow
p4_port1_line.port_2.h_outflow = snapshot.p4_port1_line.h
self._write_connection_line(
line=self.components.p4_port1_line,
line_properties=snapshot.p4_port1_line,
port_1_properties=snapshot.p4_primary_line,
port_1_flow=snapshot.p4_to_port1_line_flow,
port_2_properties=snapshot.p4_port1_remote_primary_line,
port_2_flow=snapshot.p4_port1_remote_node_to_line_flow,
)
self._write_primary_chamber_line(
line=self.components.p4_port1_remote_primary_line,
@@ -1983,18 +2017,13 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_to_line_flow=snapshot.p4_port1_remote_node_to_primary_line_flow,
)
p4_port1_remote_port1_line = self.components.p4_port1_remote_port1_line
p4_port1_remote_port1_line.port_1.p = snapshot.p4_port1_remote_primary_line.p
p4_port1_remote_port1_line.port_1.m_flow = (
snapshot.p4_port1_remote_to_port1_line_flow
)
p4_port1_remote_port1_line.port_1.h_outflow = (
snapshot.p4_port1_remote_port1_line.h
)
p4_port1_remote_port1_line.port_2.p = snapshot.p4_port1_far_primary_line.p
p4_port1_remote_port1_line.port_2.m_flow = snapshot.p4_port1_far_node_to_line_flow
p4_port1_remote_port1_line.port_2.h_outflow = (
snapshot.p4_port1_remote_port1_line.h
self._write_connection_line(
line=self.components.p4_port1_remote_port1_line,
line_properties=snapshot.p4_port1_remote_port1_line,
port_1_properties=snapshot.p4_port1_remote_primary_line,
port_1_flow=snapshot.p4_port1_remote_to_port1_line_flow,
port_2_properties=snapshot.p4_port1_far_primary_line,
port_2_flow=snapshot.p4_port1_far_node_to_line_flow,
)
self._write_primary_chamber_line(
@@ -2006,13 +2035,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_to_line_flow=snapshot.p4_port1_far_node_to_primary_line_flow,
)
p4_port1_far_port1_line = self.components.p4_port1_far_port1_line
p4_port1_far_port1_line.port_1.p = snapshot.p4_port1_far_primary_line.p
p4_port1_far_port1_line.port_1.m_flow = snapshot.p4_port1_far_to_next_line_flow
p4_port1_far_port1_line.port_1.h_outflow = snapshot.p4_port1_far_port1_line.h
p4_port1_far_port1_line.port_2.p = snapshot.p4_port1_next_primary_line.p
p4_port1_far_port1_line.port_2.m_flow = snapshot.p4_port1_next_node_to_line_flow
p4_port1_far_port1_line.port_2.h_outflow = snapshot.p4_port1_far_port1_line.h
self._write_connection_line(
line=self.components.p4_port1_far_port1_line,
line_properties=snapshot.p4_port1_far_port1_line,
port_1_properties=snapshot.p4_port1_far_primary_line,
port_1_flow=snapshot.p4_port1_far_to_next_line_flow,
port_2_properties=snapshot.p4_port1_next_primary_line,
port_2_flow=snapshot.p4_port1_next_node_to_line_flow,
)
self._write_primary_chamber_line(
line=self.components.p4_port1_next_primary_line,
@@ -2023,13 +2053,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_to_line_flow=snapshot.p4_port1_next_node_to_primary_line_flow,
)
p4_port1_next_port1_line = self.components.p4_port1_next_port1_line
p4_port1_next_port1_line.port_1.p = snapshot.p4_port1_next_primary_line.p
p4_port1_next_port1_line.port_1.m_flow = snapshot.p4_port1_next_to_bridge_line_flow
p4_port1_next_port1_line.port_1.h_outflow = snapshot.p4_port1_next_port1_line.h
p4_port1_next_port1_line.port_2.p = snapshot.p4_bridge_primary_line.p
p4_port1_next_port1_line.port_2.m_flow = snapshot.p4_bridge_to_port1_next_line_flow
p4_port1_next_port1_line.port_2.h_outflow = snapshot.p4_port1_next_port1_line.h
self._write_connection_line(
line=self.components.p4_port1_next_port1_line,
line_properties=snapshot.p4_port1_next_port1_line,
port_1_properties=snapshot.p4_port1_next_primary_line,
port_1_flow=snapshot.p4_port1_next_to_bridge_line_flow,
port_2_properties=snapshot.p4_bridge_primary_line,
port_2_flow=snapshot.p4_bridge_to_port1_next_line_flow,
)
p4_port1_next_orifice_line = self.components.p4_port1_next_orifice_line
p4_port1_next_orifice_line.port_1.p = snapshot.p4_port1_next_orifice_line_port_1.p
@@ -2142,13 +2173,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
p4_port1_remote_orifice.port_b.m_flow = -snapshot.p4_port1_remote_orifice_to_node_flow
p4_port1_remote_orifice.port_b.h_outflow = snapshot.p4_port1_remote_primary_line.h
p4_port3_line = self.components.p4_port3_line
p4_port3_line.port_1.p = snapshot.p4_port3_remote_primary_line.p
p4_port3_line.port_1.m_flow = snapshot.p4_port3_remote_node_to_line_flow
p4_port3_line.port_1.h_outflow = snapshot.p4_port3_line.h
p4_port3_line.port_2.p = snapshot.p4_primary_line.p
p4_port3_line.port_2.m_flow = snapshot.p4_to_port3_line_flow
p4_port3_line.port_2.h_outflow = snapshot.p4_port3_line.h
self._write_connection_line(
line=self.components.p4_port3_line,
line_properties=snapshot.p4_port3_line,
port_1_properties=snapshot.p4_port3_remote_primary_line,
port_1_flow=snapshot.p4_port3_remote_node_to_line_flow,
port_2_properties=snapshot.p4_primary_line,
port_2_flow=snapshot.p4_to_port3_line_flow,
)
self._write_primary_chamber_line(
line=self.components.p4_port3_remote_primary_line,
@@ -2159,18 +2191,13 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_to_line_flow=snapshot.p4_port3_remote_node_to_primary_line_flow,
)
p4_port3_remote_port3_line = self.components.p4_port3_remote_port3_line
p4_port3_remote_port3_line.port_1.p = snapshot.p4_port3_far_primary_line.p
p4_port3_remote_port3_line.port_1.m_flow = snapshot.p4_port3_far_node_to_line_flow
p4_port3_remote_port3_line.port_1.h_outflow = (
snapshot.p4_port3_remote_port3_line.h
)
p4_port3_remote_port3_line.port_2.p = snapshot.p4_port3_remote_primary_line.p
p4_port3_remote_port3_line.port_2.m_flow = (
snapshot.p4_port3_remote_to_port3_line_flow
)
p4_port3_remote_port3_line.port_2.h_outflow = (
snapshot.p4_port3_remote_port3_line.h
self._write_connection_line(
line=self.components.p4_port3_remote_port3_line,
line_properties=snapshot.p4_port3_remote_port3_line,
port_1_properties=snapshot.p4_port3_far_primary_line,
port_1_flow=snapshot.p4_port3_far_node_to_line_flow,
port_2_properties=snapshot.p4_port3_remote_primary_line,
port_2_flow=snapshot.p4_port3_remote_to_port3_line_flow,
)
self._write_primary_chamber_line(
@@ -2182,13 +2209,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_to_line_flow=snapshot.p4_port3_far_node_to_primary_line_flow,
)
p4_port3_far_port3_line = self.components.p4_port3_far_port3_line
p4_port3_far_port3_line.port_1.p = snapshot.p4_port3_next_primary_line.p
p4_port3_far_port3_line.port_1.m_flow = snapshot.p4_port3_next_node_to_line_flow
p4_port3_far_port3_line.port_1.h_outflow = snapshot.p4_port3_far_port3_line.h
p4_port3_far_port3_line.port_2.p = snapshot.p4_port3_far_primary_line.p
p4_port3_far_port3_line.port_2.m_flow = snapshot.p4_port3_far_to_next_line_flow
p4_port3_far_port3_line.port_2.h_outflow = snapshot.p4_port3_far_port3_line.h
self._write_connection_line(
line=self.components.p4_port3_far_port3_line,
line_properties=snapshot.p4_port3_far_port3_line,
port_1_properties=snapshot.p4_port3_next_primary_line,
port_1_flow=snapshot.p4_port3_next_node_to_line_flow,
port_2_properties=snapshot.p4_port3_far_primary_line,
port_2_flow=snapshot.p4_port3_far_to_next_line_flow,
)
self._write_primary_chamber_line(
line=self.components.p4_port3_next_primary_line,
@@ -2199,13 +2227,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_to_line_flow=snapshot.p4_port3_next_node_to_primary_line_flow,
)
p4_port3_next_port3_line = self.components.p4_port3_next_port3_line
p4_port3_next_port3_line.port_1.p = snapshot.p4_bridge_primary_line.p
p4_port3_next_port3_line.port_1.m_flow = snapshot.p4_bridge_to_port3_next_line_flow
p4_port3_next_port3_line.port_1.h_outflow = snapshot.p4_port3_next_port3_line.h
p4_port3_next_port3_line.port_2.p = snapshot.p4_port3_next_primary_line.p
p4_port3_next_port3_line.port_2.m_flow = snapshot.p4_port3_next_to_bridge_line_flow
p4_port3_next_port3_line.port_2.h_outflow = snapshot.p4_port3_next_port3_line.h
self._write_connection_line(
line=self.components.p4_port3_next_port3_line,
line_properties=snapshot.p4_port3_next_port3_line,
port_1_properties=snapshot.p4_bridge_primary_line,
port_1_flow=snapshot.p4_bridge_to_port3_next_line_flow,
port_2_properties=snapshot.p4_port3_next_primary_line,
port_2_flow=snapshot.p4_port3_next_to_bridge_line_flow,
)
p4_port3_next_orifice_line = self.components.p4_port3_next_orifice_line
p4_port3_next_orifice_line.port_1.p = snapshot.p4_port3_next_orifice_line_port_1.p
@@ -2421,11 +2450,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
chamber_to_line_flow=snapshot.p4_primary_chamber_to_line_flow,
node_to_line_flow=snapshot.p4_node_to_primary_line_flow,
)
p4_port1_derivative = self.components.p4_port1_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_to_port1_line_flow,
connected_h_1=snapshot.p4_primary_line.h,
port_2_m_flow=snapshot.p4_port1_remote_node_to_line_flow,
connected_h_2=snapshot.p4_port1_remote_primary_line.h,
p4_port1_derivative = self._connection_line_derivative(
line=self.components.p4_port1_line,
port_1_properties=snapshot.p4_primary_line,
port_1_flow=snapshot.p4_to_port1_line_flow,
port_2_properties=snapshot.p4_port1_remote_primary_line,
port_2_flow=snapshot.p4_port1_remote_node_to_line_flow,
)
(
p4_port1_remote_primary_derivative,
@@ -2438,13 +2468,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
chamber_to_line_flow=snapshot.p4_port1_remote_chamber_to_line_flow,
node_to_line_flow=snapshot.p4_port1_remote_node_to_primary_line_flow,
)
p4_port1_remote_port1_derivative = (
self.components.p4_port1_remote_port1_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_port1_remote_to_port1_line_flow,
connected_h_1=snapshot.p4_port1_remote_primary_line.h,
port_2_m_flow=snapshot.p4_port1_far_node_to_line_flow,
connected_h_2=snapshot.p4_port1_far_primary_line.h,
)
p4_port1_remote_port1_derivative = self._connection_line_derivative(
line=self.components.p4_port1_remote_port1_line,
port_1_properties=snapshot.p4_port1_remote_primary_line,
port_1_flow=snapshot.p4_port1_remote_to_port1_line_flow,
port_2_properties=snapshot.p4_port1_far_primary_line,
port_2_flow=snapshot.p4_port1_far_node_to_line_flow,
)
(
p4_port1_far_primary_derivative,
@@ -2457,13 +2486,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
chamber_to_line_flow=snapshot.p4_port1_far_chamber_to_line_flow,
node_to_line_flow=snapshot.p4_port1_far_node_to_primary_line_flow,
)
p4_port1_far_port1_derivative = (
self.components.p4_port1_far_port1_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_port1_far_to_next_line_flow,
connected_h_1=snapshot.p4_port1_far_primary_line.h,
port_2_m_flow=snapshot.p4_port1_next_node_to_line_flow,
connected_h_2=snapshot.p4_port1_next_primary_line.h,
)
p4_port1_far_port1_derivative = self._connection_line_derivative(
line=self.components.p4_port1_far_port1_line,
port_1_properties=snapshot.p4_port1_far_primary_line,
port_1_flow=snapshot.p4_port1_far_to_next_line_flow,
port_2_properties=snapshot.p4_port1_next_primary_line,
port_2_flow=snapshot.p4_port1_next_node_to_line_flow,
)
(
p4_port1_next_primary_derivative,
@@ -2476,13 +2504,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
chamber_to_line_flow=snapshot.p4_port1_next_chamber_to_line_flow,
node_to_line_flow=snapshot.p4_port1_next_node_to_primary_line_flow,
)
p4_port1_next_port1_derivative = (
self.components.p4_port1_next_port1_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_port1_next_to_bridge_line_flow,
connected_h_1=snapshot.p4_port1_next_primary_line.h,
port_2_m_flow=snapshot.p4_bridge_to_port1_next_line_flow,
connected_h_2=snapshot.p4_bridge_primary_line.h,
)
p4_port1_next_port1_derivative = self._connection_line_derivative(
line=self.components.p4_port1_next_port1_line,
port_1_properties=snapshot.p4_port1_next_primary_line,
port_1_flow=snapshot.p4_port1_next_to_bridge_line_flow,
port_2_properties=snapshot.p4_bridge_primary_line,
port_2_flow=snapshot.p4_bridge_to_port1_next_line_flow,
)
(
p4_bridge_primary_derivative,
@@ -2503,11 +2530,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
connected_h_2=snapshot.p4_port1_remote_primary_line.h,
)
)
p4_port3_derivative = self.components.p4_port3_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_port3_remote_node_to_line_flow,
connected_h_1=snapshot.p4_port3_remote_primary_line.h,
port_2_m_flow=snapshot.p4_to_port3_line_flow,
connected_h_2=snapshot.p4_primary_line.h,
p4_port3_derivative = self._connection_line_derivative(
line=self.components.p4_port3_line,
port_1_properties=snapshot.p4_port3_remote_primary_line,
port_1_flow=snapshot.p4_port3_remote_node_to_line_flow,
port_2_properties=snapshot.p4_primary_line,
port_2_flow=snapshot.p4_to_port3_line_flow,
)
(
p4_port3_remote_primary_derivative,
@@ -2520,13 +2548,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
chamber_to_line_flow=snapshot.p4_port3_remote_chamber_to_line_flow,
node_to_line_flow=snapshot.p4_port3_remote_node_to_primary_line_flow,
)
p4_port3_remote_port3_derivative = (
self.components.p4_port3_remote_port3_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_port3_far_node_to_line_flow,
connected_h_1=snapshot.p4_port3_far_primary_line.h,
port_2_m_flow=snapshot.p4_port3_remote_to_port3_line_flow,
connected_h_2=snapshot.p4_port3_remote_primary_line.h,
)
p4_port3_remote_port3_derivative = self._connection_line_derivative(
line=self.components.p4_port3_remote_port3_line,
port_1_properties=snapshot.p4_port3_far_primary_line,
port_1_flow=snapshot.p4_port3_far_node_to_line_flow,
port_2_properties=snapshot.p4_port3_remote_primary_line,
port_2_flow=snapshot.p4_port3_remote_to_port3_line_flow,
)
(
p4_port3_far_primary_derivative,
@@ -2539,13 +2566,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
chamber_to_line_flow=snapshot.p4_port3_far_chamber_to_line_flow,
node_to_line_flow=snapshot.p4_port3_far_node_to_primary_line_flow,
)
p4_port3_far_port3_derivative = (
self.components.p4_port3_far_port3_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_port3_next_node_to_line_flow,
connected_h_1=snapshot.p4_port3_next_primary_line.h,
port_2_m_flow=snapshot.p4_port3_far_to_next_line_flow,
connected_h_2=snapshot.p4_port3_far_primary_line.h,
)
p4_port3_far_port3_derivative = self._connection_line_derivative(
line=self.components.p4_port3_far_port3_line,
port_1_properties=snapshot.p4_port3_next_primary_line,
port_1_flow=snapshot.p4_port3_next_node_to_line_flow,
port_2_properties=snapshot.p4_port3_far_primary_line,
port_2_flow=snapshot.p4_port3_far_to_next_line_flow,
)
(
p4_port3_next_primary_derivative,
@@ -2558,13 +2584,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
chamber_to_line_flow=snapshot.p4_port3_next_chamber_to_line_flow,
node_to_line_flow=snapshot.p4_port3_next_node_to_primary_line_flow,
)
p4_port3_next_port3_derivative = (
self.components.p4_port3_next_port3_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_bridge_to_port3_next_line_flow,
connected_h_1=snapshot.p4_bridge_primary_line.h,
port_2_m_flow=snapshot.p4_port3_next_to_bridge_line_flow,
connected_h_2=snapshot.p4_port3_next_primary_line.h,
)
p4_port3_next_port3_derivative = self._connection_line_derivative(
line=self.components.p4_port3_next_port3_line,
port_1_properties=snapshot.p4_bridge_primary_line,
port_1_flow=snapshot.p4_bridge_to_port3_next_line_flow,
port_2_properties=snapshot.p4_port3_next_primary_line,
port_2_flow=snapshot.p4_port3_next_to_bridge_line_flow,
)
(
p4_port3_remote_resistance_derivative_1,