From d02dacae0f01a2744127129dd2966e851c7b4103 Mon Sep 17 00:00:00 2001 From: huojiarong Date: Sun, 19 Jul 2026 10:34:38 +0000 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E8=B1=A1test=5Fmql=E4=B8=BB=E7=BA=BF?= =?UTF-8?q?=E6=B0=94=E5=AE=A4=E9=97=AD=E5=8C=85=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PythonModels/systems/test_mql_closure.py | 434 ++++++++++------------- 1 file changed, 188 insertions(+), 246 deletions(-) diff --git a/PythonModels/systems/test_mql_closure.py b/PythonModels/systems/test_mql_closure.py index 6f6523a..845f8e9 100644 --- a/PythonModels/systems/test_mql_closure.py +++ b/PythonModels/systems/test_mql_closure.py @@ -1865,6 +1865,52 @@ class TestMqlPn3P4NodeChamberSegmentClosure: ) return inlet_derivative, chamber_derivative, outlet_derivative + @staticmethod + def _write_primary_chamber_line( + *, + line: AmesimPnl0001Pipe, + line_properties: ThermodynamicProperties, + chamber: AmesimPneumaticVolume, + chamber_properties: ThermodynamicProperties, + chamber_to_line_flow: float, + node_to_line_flow: float, + ) -> None: + line.port_1.p = chamber_properties.p + line.port_1.m_flow = chamber_to_line_flow + line.port_1.h_outflow = line_properties.h + line.port_2.p = line_properties.p + line.port_2.m_flow = node_to_line_flow + line.port_2.h_outflow = line_properties.h + + chamber.port_a.p = chamber_properties.p + chamber.port_a.m_flow = -chamber_to_line_flow + chamber.port_a.h_outflow = chamber_properties.h + + @staticmethod + def _primary_chamber_line_derivatives( + *, + line: AmesimPnl0001Pipe, + line_properties: ThermodynamicProperties, + chamber: AmesimPneumaticVolume, + chamber_properties: ThermodynamicProperties, + chamber_to_line_flow: float, + node_to_line_flow: float, + ) -> tuple[VolumeState, VolumeState]: + line_derivative = line.derivatives_from_connections( + port_1_m_flow=chamber_to_line_flow, + connected_h_1=chamber_properties.h, + port_2_m_flow=node_to_line_flow, + connected_h_2=line_properties.h, + ) + chamber_derivative = chamber.derivatives_from_two_connections( + port_a_m_flow=-chamber_to_line_flow, + connected_h_a=line_properties.h, + port_b_m_flow=0.0, + connected_h_b=chamber_properties.h, + internal_h=chamber_properties.h, + ) + return line_derivative, chamber_derivative + def _write_port_states( self, snapshot: TestMqlPn3P4NodeChamberSegmentSnapshot, @@ -1911,18 +1957,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure: resistance.port_2.m_flow = -snapshot.node_to_resistance_flow resistance.port_2.h_outflow = snapshot.p4_port1_remote_orifice_line_port_1.h - p4_primary_line = self.components.p4_primary_line - p4_primary_line.port_1.p = snapshot.p4_primary_chamber.p - p4_primary_line.port_1.m_flow = snapshot.p4_primary_chamber_to_line_flow - p4_primary_line.port_1.h_outflow = snapshot.p4_primary_line.h - p4_primary_line.port_2.p = snapshot.p4_primary_line.p - p4_primary_line.port_2.m_flow = snapshot.p4_node_to_primary_line_flow - p4_primary_line.port_2.h_outflow = snapshot.p4_primary_line.h - - p4_primary_chamber = self.components.p4_primary_chamber - p4_primary_chamber.port_a.p = snapshot.p4_primary_chamber.p - p4_primary_chamber.port_a.m_flow = -snapshot.p4_primary_chamber_to_line_flow - p4_primary_chamber.port_a.h_outflow = snapshot.p4_primary_chamber.h + self._write_primary_chamber_line( + line=self.components.p4_primary_line, + line_properties=snapshot.p4_primary_line, + chamber=self.components.p4_primary_chamber, + chamber_properties=snapshot.p4_primary_chamber, + chamber_to_line_flow=snapshot.p4_primary_chamber_to_line_flow, + 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 @@ -1932,29 +1974,13 @@ class TestMqlPn3P4NodeChamberSegmentClosure: 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 - p4_port1_remote_primary_line = self.components.p4_port1_remote_primary_line - p4_port1_remote_primary_line.port_1.p = snapshot.p4_port1_remote_primary_chamber.p - p4_port1_remote_primary_line.port_1.m_flow = ( - snapshot.p4_port1_remote_chamber_to_line_flow - ) - p4_port1_remote_primary_line.port_1.h_outflow = ( - snapshot.p4_port1_remote_primary_line.h - ) - p4_port1_remote_primary_line.port_2.p = snapshot.p4_port1_remote_primary_line.p - p4_port1_remote_primary_line.port_2.m_flow = ( - snapshot.p4_port1_remote_node_to_primary_line_flow - ) - p4_port1_remote_primary_line.port_2.h_outflow = ( - snapshot.p4_port1_remote_primary_line.h - ) - - p4_port1_remote_primary_chamber = self.components.p4_port1_remote_primary_chamber - p4_port1_remote_primary_chamber.port_a.p = snapshot.p4_port1_remote_primary_chamber.p - p4_port1_remote_primary_chamber.port_a.m_flow = ( - -snapshot.p4_port1_remote_chamber_to_line_flow - ) - p4_port1_remote_primary_chamber.port_a.h_outflow = ( - snapshot.p4_port1_remote_primary_chamber.h + self._write_primary_chamber_line( + line=self.components.p4_port1_remote_primary_line, + line_properties=snapshot.p4_port1_remote_primary_line, + chamber=self.components.p4_port1_remote_primary_chamber, + chamber_properties=snapshot.p4_port1_remote_primary_chamber, + 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_line = self.components.p4_port1_remote_port1_line @@ -1971,18 +1997,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure: snapshot.p4_port1_remote_port1_line.h ) - p4_port1_far_primary_line = self.components.p4_port1_far_primary_line - p4_port1_far_primary_line.port_1.p = snapshot.p4_port1_far_primary_chamber.p - p4_port1_far_primary_line.port_1.m_flow = snapshot.p4_port1_far_chamber_to_line_flow - p4_port1_far_primary_line.port_1.h_outflow = snapshot.p4_port1_far_primary_line.h - p4_port1_far_primary_line.port_2.p = snapshot.p4_port1_far_primary_line.p - p4_port1_far_primary_line.port_2.m_flow = snapshot.p4_port1_far_node_to_primary_line_flow - p4_port1_far_primary_line.port_2.h_outflow = snapshot.p4_port1_far_primary_line.h - - p4_port1_far_primary_chamber = self.components.p4_port1_far_primary_chamber - p4_port1_far_primary_chamber.port_a.p = snapshot.p4_port1_far_primary_chamber.p - p4_port1_far_primary_chamber.port_a.m_flow = -snapshot.p4_port1_far_chamber_to_line_flow - p4_port1_far_primary_chamber.port_a.h_outflow = snapshot.p4_port1_far_primary_chamber.h + self._write_primary_chamber_line( + line=self.components.p4_port1_far_primary_line, + line_properties=snapshot.p4_port1_far_primary_line, + chamber=self.components.p4_port1_far_primary_chamber, + chamber_properties=snapshot.p4_port1_far_primary_chamber, + 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_line = self.components.p4_port1_far_port1_line p4_port1_far_port1_line.port_1.p = snapshot.p4_port1_far_primary_line.p @@ -1992,18 +2014,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure: 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 - p4_port1_next_primary_line = self.components.p4_port1_next_primary_line - p4_port1_next_primary_line.port_1.p = snapshot.p4_port1_next_primary_chamber.p - p4_port1_next_primary_line.port_1.m_flow = snapshot.p4_port1_next_chamber_to_line_flow - p4_port1_next_primary_line.port_1.h_outflow = snapshot.p4_port1_next_primary_line.h - p4_port1_next_primary_line.port_2.p = snapshot.p4_port1_next_primary_line.p - p4_port1_next_primary_line.port_2.m_flow = snapshot.p4_port1_next_node_to_primary_line_flow - p4_port1_next_primary_line.port_2.h_outflow = snapshot.p4_port1_next_primary_line.h - - p4_port1_next_primary_chamber = self.components.p4_port1_next_primary_chamber - p4_port1_next_primary_chamber.port_a.p = snapshot.p4_port1_next_primary_chamber.p - p4_port1_next_primary_chamber.port_a.m_flow = -snapshot.p4_port1_next_chamber_to_line_flow - p4_port1_next_primary_chamber.port_a.h_outflow = snapshot.p4_port1_next_primary_chamber.h + self._write_primary_chamber_line( + line=self.components.p4_port1_next_primary_line, + line_properties=snapshot.p4_port1_next_primary_line, + chamber=self.components.p4_port1_next_primary_chamber, + chamber_properties=snapshot.p4_port1_next_primary_chamber, + 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_line = self.components.p4_port1_next_port1_line p4_port1_next_port1_line.port_1.p = snapshot.p4_port1_next_primary_line.p @@ -2099,18 +2117,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure: ), ) - p4_bridge_primary_line = self.components.p4_bridge_primary_line - p4_bridge_primary_line.port_1.p = snapshot.p4_bridge_primary_chamber.p - p4_bridge_primary_line.port_1.m_flow = snapshot.p4_bridge_chamber_to_line_flow - p4_bridge_primary_line.port_1.h_outflow = snapshot.p4_bridge_primary_line.h - p4_bridge_primary_line.port_2.p = snapshot.p4_bridge_primary_line.p - p4_bridge_primary_line.port_2.m_flow = snapshot.p4_bridge_node_to_primary_line_flow - p4_bridge_primary_line.port_2.h_outflow = snapshot.p4_bridge_primary_line.h - - p4_bridge_primary_chamber = self.components.p4_bridge_primary_chamber - p4_bridge_primary_chamber.port_a.p = snapshot.p4_bridge_primary_chamber.p - p4_bridge_primary_chamber.port_a.m_flow = -snapshot.p4_bridge_chamber_to_line_flow - p4_bridge_primary_chamber.port_a.h_outflow = snapshot.p4_bridge_primary_chamber.h + self._write_primary_chamber_line( + line=self.components.p4_bridge_primary_line, + line_properties=snapshot.p4_bridge_primary_line, + chamber=self.components.p4_bridge_primary_chamber, + chamber_properties=snapshot.p4_bridge_primary_chamber, + chamber_to_line_flow=snapshot.p4_bridge_chamber_to_line_flow, + node_to_line_flow=snapshot.p4_bridge_node_to_primary_line_flow, + ) p4_port1_remote_orifice_line = self.components.p4_port1_remote_orifice_line p4_port1_remote_orifice_line.port_1.p = snapshot.p4_port1_remote_orifice_line_port_1.p @@ -2136,29 +2150,13 @@ class TestMqlPn3P4NodeChamberSegmentClosure: 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 - p4_port3_remote_primary_line = self.components.p4_port3_remote_primary_line - p4_port3_remote_primary_line.port_1.p = snapshot.p4_port3_remote_primary_chamber.p - p4_port3_remote_primary_line.port_1.m_flow = ( - snapshot.p4_port3_remote_chamber_to_line_flow - ) - p4_port3_remote_primary_line.port_1.h_outflow = ( - snapshot.p4_port3_remote_primary_line.h - ) - p4_port3_remote_primary_line.port_2.p = snapshot.p4_port3_remote_primary_line.p - p4_port3_remote_primary_line.port_2.m_flow = ( - snapshot.p4_port3_remote_node_to_primary_line_flow - ) - p4_port3_remote_primary_line.port_2.h_outflow = ( - snapshot.p4_port3_remote_primary_line.h - ) - - p4_port3_remote_primary_chamber = self.components.p4_port3_remote_primary_chamber - p4_port3_remote_primary_chamber.port_a.p = snapshot.p4_port3_remote_primary_chamber.p - p4_port3_remote_primary_chamber.port_a.m_flow = ( - -snapshot.p4_port3_remote_chamber_to_line_flow - ) - p4_port3_remote_primary_chamber.port_a.h_outflow = ( - snapshot.p4_port3_remote_primary_chamber.h + self._write_primary_chamber_line( + line=self.components.p4_port3_remote_primary_line, + line_properties=snapshot.p4_port3_remote_primary_line, + chamber=self.components.p4_port3_remote_primary_chamber, + chamber_properties=snapshot.p4_port3_remote_primary_chamber, + 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_line = self.components.p4_port3_remote_port3_line @@ -2175,18 +2173,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure: snapshot.p4_port3_remote_port3_line.h ) - p4_port3_far_primary_line = self.components.p4_port3_far_primary_line - p4_port3_far_primary_line.port_1.p = snapshot.p4_port3_far_primary_chamber.p - p4_port3_far_primary_line.port_1.m_flow = snapshot.p4_port3_far_chamber_to_line_flow - p4_port3_far_primary_line.port_1.h_outflow = snapshot.p4_port3_far_primary_line.h - p4_port3_far_primary_line.port_2.p = snapshot.p4_port3_far_primary_line.p - p4_port3_far_primary_line.port_2.m_flow = snapshot.p4_port3_far_node_to_primary_line_flow - p4_port3_far_primary_line.port_2.h_outflow = snapshot.p4_port3_far_primary_line.h - - p4_port3_far_primary_chamber = self.components.p4_port3_far_primary_chamber - p4_port3_far_primary_chamber.port_a.p = snapshot.p4_port3_far_primary_chamber.p - p4_port3_far_primary_chamber.port_a.m_flow = -snapshot.p4_port3_far_chamber_to_line_flow - p4_port3_far_primary_chamber.port_a.h_outflow = snapshot.p4_port3_far_primary_chamber.h + self._write_primary_chamber_line( + line=self.components.p4_port3_far_primary_line, + line_properties=snapshot.p4_port3_far_primary_line, + chamber=self.components.p4_port3_far_primary_chamber, + chamber_properties=snapshot.p4_port3_far_primary_chamber, + 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_line = self.components.p4_port3_far_port3_line p4_port3_far_port3_line.port_1.p = snapshot.p4_port3_next_primary_line.p @@ -2196,18 +2190,14 @@ class TestMqlPn3P4NodeChamberSegmentClosure: 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 - p4_port3_next_primary_line = self.components.p4_port3_next_primary_line - p4_port3_next_primary_line.port_1.p = snapshot.p4_port3_next_primary_chamber.p - p4_port3_next_primary_line.port_1.m_flow = snapshot.p4_port3_next_chamber_to_line_flow - p4_port3_next_primary_line.port_1.h_outflow = snapshot.p4_port3_next_primary_line.h - p4_port3_next_primary_line.port_2.p = snapshot.p4_port3_next_primary_line.p - p4_port3_next_primary_line.port_2.m_flow = snapshot.p4_port3_next_node_to_primary_line_flow - p4_port3_next_primary_line.port_2.h_outflow = snapshot.p4_port3_next_primary_line.h - - p4_port3_next_primary_chamber = self.components.p4_port3_next_primary_chamber - p4_port3_next_primary_chamber.port_a.p = snapshot.p4_port3_next_primary_chamber.p - p4_port3_next_primary_chamber.port_a.m_flow = -snapshot.p4_port3_next_chamber_to_line_flow - p4_port3_next_primary_chamber.port_a.h_outflow = snapshot.p4_port3_next_primary_chamber.h + self._write_primary_chamber_line( + line=self.components.p4_port3_next_primary_line, + line_properties=snapshot.p4_port3_next_primary_line, + chamber=self.components.p4_port3_next_primary_chamber, + chamber_properties=snapshot.p4_port3_next_primary_chamber, + 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_line = self.components.p4_port3_next_port3_line p4_port3_next_port3_line.port_1.p = snapshot.p4_bridge_primary_line.p @@ -2420,22 +2410,16 @@ class TestMqlPn3P4NodeChamberSegmentClosure: connected_h_2=snapshot.p4_primary_line.h, ) ) - p4_primary_derivative = ( - self.components.p4_primary_line.derivatives_from_connections( - port_1_m_flow=snapshot.p4_primary_chamber_to_line_flow, - connected_h_1=snapshot.p4_primary_chamber.h, - port_2_m_flow=snapshot.p4_node_to_primary_line_flow, - connected_h_2=snapshot.p4_primary_line.h, - ) - ) - p4_primary_chamber_derivative = ( - self.components.p4_primary_chamber.derivatives_from_two_connections( - port_a_m_flow=-snapshot.p4_primary_chamber_to_line_flow, - connected_h_a=snapshot.p4_primary_line.h, - port_b_m_flow=0.0, - connected_h_b=snapshot.p4_primary_chamber.h, - internal_h=snapshot.p4_primary_chamber.h, - ) + ( + p4_primary_derivative, + p4_primary_chamber_derivative, + ) = self._primary_chamber_line_derivatives( + line=self.components.p4_primary_line, + line_properties=snapshot.p4_primary_line, + chamber=self.components.p4_primary_chamber, + chamber_properties=snapshot.p4_primary_chamber, + 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, @@ -2443,22 +2427,16 @@ class TestMqlPn3P4NodeChamberSegmentClosure: port_2_m_flow=snapshot.p4_port1_remote_node_to_line_flow, connected_h_2=snapshot.p4_port1_remote_primary_line.h, ) - p4_port1_remote_primary_derivative = ( - self.components.p4_port1_remote_primary_line.derivatives_from_connections( - port_1_m_flow=snapshot.p4_port1_remote_chamber_to_line_flow, - connected_h_1=snapshot.p4_port1_remote_primary_chamber.h, - port_2_m_flow=snapshot.p4_port1_remote_node_to_primary_line_flow, - connected_h_2=snapshot.p4_port1_remote_primary_line.h, - ) - ) - p4_port1_remote_chamber_derivative = ( - self.components.p4_port1_remote_primary_chamber.derivatives_from_two_connections( - port_a_m_flow=-snapshot.p4_port1_remote_chamber_to_line_flow, - connected_h_a=snapshot.p4_port1_remote_primary_line.h, - port_b_m_flow=0.0, - connected_h_b=snapshot.p4_port1_remote_primary_chamber.h, - internal_h=snapshot.p4_port1_remote_primary_chamber.h, - ) + ( + p4_port1_remote_primary_derivative, + p4_port1_remote_chamber_derivative, + ) = self._primary_chamber_line_derivatives( + line=self.components.p4_port1_remote_primary_line, + line_properties=snapshot.p4_port1_remote_primary_line, + chamber=self.components.p4_port1_remote_primary_chamber, + chamber_properties=snapshot.p4_port1_remote_primary_chamber, + 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( @@ -2468,22 +2446,16 @@ class TestMqlPn3P4NodeChamberSegmentClosure: connected_h_2=snapshot.p4_port1_far_primary_line.h, ) ) - p4_port1_far_primary_derivative = ( - self.components.p4_port1_far_primary_line.derivatives_from_connections( - port_1_m_flow=snapshot.p4_port1_far_chamber_to_line_flow, - connected_h_1=snapshot.p4_port1_far_primary_chamber.h, - port_2_m_flow=snapshot.p4_port1_far_node_to_primary_line_flow, - connected_h_2=snapshot.p4_port1_far_primary_line.h, - ) - ) - p4_port1_far_chamber_derivative = ( - self.components.p4_port1_far_primary_chamber.derivatives_from_two_connections( - port_a_m_flow=-snapshot.p4_port1_far_chamber_to_line_flow, - connected_h_a=snapshot.p4_port1_far_primary_line.h, - port_b_m_flow=0.0, - connected_h_b=snapshot.p4_port1_far_primary_chamber.h, - internal_h=snapshot.p4_port1_far_primary_chamber.h, - ) + ( + p4_port1_far_primary_derivative, + p4_port1_far_chamber_derivative, + ) = self._primary_chamber_line_derivatives( + line=self.components.p4_port1_far_primary_line, + line_properties=snapshot.p4_port1_far_primary_line, + chamber=self.components.p4_port1_far_primary_chamber, + chamber_properties=snapshot.p4_port1_far_primary_chamber, + 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( @@ -2493,22 +2465,16 @@ class TestMqlPn3P4NodeChamberSegmentClosure: connected_h_2=snapshot.p4_port1_next_primary_line.h, ) ) - p4_port1_next_primary_derivative = ( - self.components.p4_port1_next_primary_line.derivatives_from_connections( - port_1_m_flow=snapshot.p4_port1_next_chamber_to_line_flow, - connected_h_1=snapshot.p4_port1_next_primary_chamber.h, - port_2_m_flow=snapshot.p4_port1_next_node_to_primary_line_flow, - connected_h_2=snapshot.p4_port1_next_primary_line.h, - ) - ) - p4_port1_next_chamber_derivative = ( - self.components.p4_port1_next_primary_chamber.derivatives_from_two_connections( - port_a_m_flow=-snapshot.p4_port1_next_chamber_to_line_flow, - connected_h_a=snapshot.p4_port1_next_primary_line.h, - port_b_m_flow=0.0, - connected_h_b=snapshot.p4_port1_next_primary_chamber.h, - internal_h=snapshot.p4_port1_next_primary_chamber.h, - ) + ( + p4_port1_next_primary_derivative, + p4_port1_next_chamber_derivative, + ) = self._primary_chamber_line_derivatives( + line=self.components.p4_port1_next_primary_line, + line_properties=snapshot.p4_port1_next_primary_line, + chamber=self.components.p4_port1_next_primary_chamber, + chamber_properties=snapshot.p4_port1_next_primary_chamber, + 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( @@ -2518,22 +2484,16 @@ class TestMqlPn3P4NodeChamberSegmentClosure: connected_h_2=snapshot.p4_bridge_primary_line.h, ) ) - p4_bridge_primary_derivative = ( - self.components.p4_bridge_primary_line.derivatives_from_connections( - port_1_m_flow=snapshot.p4_bridge_chamber_to_line_flow, - connected_h_1=snapshot.p4_bridge_primary_chamber.h, - port_2_m_flow=snapshot.p4_bridge_node_to_primary_line_flow, - connected_h_2=snapshot.p4_bridge_primary_line.h, - ) - ) - p4_bridge_chamber_derivative = ( - self.components.p4_bridge_primary_chamber.derivatives_from_two_connections( - port_a_m_flow=-snapshot.p4_bridge_chamber_to_line_flow, - connected_h_a=snapshot.p4_bridge_primary_line.h, - port_b_m_flow=0.0, - connected_h_b=snapshot.p4_bridge_primary_chamber.h, - internal_h=snapshot.p4_bridge_primary_chamber.h, - ) + ( + p4_bridge_primary_derivative, + p4_bridge_chamber_derivative, + ) = self._primary_chamber_line_derivatives( + line=self.components.p4_bridge_primary_line, + line_properties=snapshot.p4_bridge_primary_line, + chamber=self.components.p4_bridge_primary_chamber, + chamber_properties=snapshot.p4_bridge_primary_chamber, + chamber_to_line_flow=snapshot.p4_bridge_chamber_to_line_flow, + node_to_line_flow=snapshot.p4_bridge_node_to_primary_line_flow, ) p4_port1_remote_orifice_derivative_1, p4_port1_remote_orifice_derivative_2 = ( self.components.p4_port1_remote_orifice_line.derivatives_from_connections( @@ -2549,22 +2509,16 @@ class TestMqlPn3P4NodeChamberSegmentClosure: port_2_m_flow=snapshot.p4_to_port3_line_flow, connected_h_2=snapshot.p4_primary_line.h, ) - p4_port3_remote_primary_derivative = ( - self.components.p4_port3_remote_primary_line.derivatives_from_connections( - port_1_m_flow=snapshot.p4_port3_remote_chamber_to_line_flow, - connected_h_1=snapshot.p4_port3_remote_primary_chamber.h, - port_2_m_flow=snapshot.p4_port3_remote_node_to_primary_line_flow, - connected_h_2=snapshot.p4_port3_remote_primary_line.h, - ) - ) - p4_port3_remote_chamber_derivative = ( - self.components.p4_port3_remote_primary_chamber.derivatives_from_two_connections( - port_a_m_flow=-snapshot.p4_port3_remote_chamber_to_line_flow, - connected_h_a=snapshot.p4_port3_remote_primary_line.h, - port_b_m_flow=0.0, - connected_h_b=snapshot.p4_port3_remote_primary_chamber.h, - internal_h=snapshot.p4_port3_remote_primary_chamber.h, - ) + ( + p4_port3_remote_primary_derivative, + p4_port3_remote_chamber_derivative, + ) = self._primary_chamber_line_derivatives( + line=self.components.p4_port3_remote_primary_line, + line_properties=snapshot.p4_port3_remote_primary_line, + chamber=self.components.p4_port3_remote_primary_chamber, + chamber_properties=snapshot.p4_port3_remote_primary_chamber, + 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( @@ -2574,22 +2528,16 @@ class TestMqlPn3P4NodeChamberSegmentClosure: connected_h_2=snapshot.p4_port3_remote_primary_line.h, ) ) - p4_port3_far_primary_derivative = ( - self.components.p4_port3_far_primary_line.derivatives_from_connections( - port_1_m_flow=snapshot.p4_port3_far_chamber_to_line_flow, - connected_h_1=snapshot.p4_port3_far_primary_chamber.h, - port_2_m_flow=snapshot.p4_port3_far_node_to_primary_line_flow, - connected_h_2=snapshot.p4_port3_far_primary_line.h, - ) - ) - p4_port3_far_chamber_derivative = ( - self.components.p4_port3_far_primary_chamber.derivatives_from_two_connections( - port_a_m_flow=-snapshot.p4_port3_far_chamber_to_line_flow, - connected_h_a=snapshot.p4_port3_far_primary_line.h, - port_b_m_flow=0.0, - connected_h_b=snapshot.p4_port3_far_primary_chamber.h, - internal_h=snapshot.p4_port3_far_primary_chamber.h, - ) + ( + p4_port3_far_primary_derivative, + p4_port3_far_chamber_derivative, + ) = self._primary_chamber_line_derivatives( + line=self.components.p4_port3_far_primary_line, + line_properties=snapshot.p4_port3_far_primary_line, + chamber=self.components.p4_port3_far_primary_chamber, + chamber_properties=snapshot.p4_port3_far_primary_chamber, + 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( @@ -2599,22 +2547,16 @@ class TestMqlPn3P4NodeChamberSegmentClosure: connected_h_2=snapshot.p4_port3_far_primary_line.h, ) ) - p4_port3_next_primary_derivative = ( - self.components.p4_port3_next_primary_line.derivatives_from_connections( - port_1_m_flow=snapshot.p4_port3_next_chamber_to_line_flow, - connected_h_1=snapshot.p4_port3_next_primary_chamber.h, - port_2_m_flow=snapshot.p4_port3_next_node_to_primary_line_flow, - connected_h_2=snapshot.p4_port3_next_primary_line.h, - ) - ) - p4_port3_next_chamber_derivative = ( - self.components.p4_port3_next_primary_chamber.derivatives_from_two_connections( - port_a_m_flow=-snapshot.p4_port3_next_chamber_to_line_flow, - connected_h_a=snapshot.p4_port3_next_primary_line.h, - port_b_m_flow=0.0, - connected_h_b=snapshot.p4_port3_next_primary_chamber.h, - internal_h=snapshot.p4_port3_next_primary_chamber.h, - ) + ( + p4_port3_next_primary_derivative, + p4_port3_next_chamber_derivative, + ) = self._primary_chamber_line_derivatives( + line=self.components.p4_port3_next_primary_line, + line_properties=snapshot.p4_port3_next_primary_line, + chamber=self.components.p4_port3_next_primary_chamber, + chamber_properties=snapshot.p4_port3_next_primary_chamber, + 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(