diff --git a/PythonModels/systems/test_mql_closure.py b/PythonModels/systems/test_mql_closure.py index 3109bb4..cc557cd 100644 --- a/PythonModels/systems/test_mql_closure.py +++ b/PythonModels/systems/test_mql_closure.py @@ -280,6 +280,12 @@ class TestMqlPn3P4NodeChamberSegmentComponents: spec: TestMqlPneumaticChamberSegmentSpec +@dataclass(frozen=True) +class TestMqlTwoStateOrificeLineFlows: + line_center_flow: float + line_to_boundary_flow: float + + @dataclass(frozen=True) class TestMqlFixedChamberSegmentFlows: inlet_node_to_line_flow: float @@ -911,14 +917,18 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port1_remote_node_to_orifice_line_flow = ( -p4_port1_remote_orifice_node_balance.port_2_mass_flow_g_s * 1.0e-3 ) - p4_port1_remote_orifice_line_center_flow = ( - self.components.p4_port1_remote_orifice_line.resistance_mass_flow() - ) - p4_port1_remote_orifice_to_node_flow = self._line_to_p4_flow( - line=p4_port1_remote_orifice_line_port_2, - p4_boundary=p4_port1_remote_primary_line, + p4_port1_remote_orifice_line_flows = self._two_state_orifice_line_flows( + line=self.components.p4_port1_remote_orifice_line, + line_port_2_properties=p4_port1_remote_orifice_line_port_2, + boundary_properties=p4_port1_remote_primary_line, orifice=self.components.p4_port1_remote_orifice, ) + p4_port1_remote_orifice_line_center_flow = ( + p4_port1_remote_orifice_line_flows.line_center_flow + ) + p4_port1_remote_orifice_to_node_flow = ( + p4_port1_remote_orifice_line_flows.line_to_boundary_flow + ) p4_to_port3_line_flow = self.components.p4_port3_line.port_mass_flow( port_pressure_pa=p4_primary_line.p, port_temperature_k=p4_primary_line.T, @@ -1033,14 +1043,18 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port3_next_orifice_node_to_line_flow = ( -p4_port3_next_orifice_node_balance.port_2_mass_flow_g_s * 1.0e-3 ) - p4_port3_next_orifice_line_center_flow = ( - self.components.p4_port3_next_orifice_line.resistance_mass_flow() - ) - p4_port3_next_orifice_to_output_line_flow = self._line_to_p4_flow( - line=p4_port3_next_orifice_line_port_2, - p4_boundary=p4_port3_next_orifice_output_line, + p4_port3_next_orifice_line_flows = self._two_state_orifice_line_flows( + line=self.components.p4_port3_next_orifice_line, + line_port_2_properties=p4_port3_next_orifice_line_port_2, + boundary_properties=p4_port3_next_orifice_output_line, orifice=self.components.p4_port3_next_orifice, ) + p4_port3_next_orifice_line_center_flow = ( + p4_port3_next_orifice_line_flows.line_center_flow + ) + p4_port3_next_orifice_to_output_line_flow = ( + p4_port3_next_orifice_line_flows.line_to_boundary_flow + ) p4_port3_next_orifice_output_to_p4_flow = ( p4_port3_next_orifice_to_output_line_flow ) @@ -1106,14 +1120,18 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port1_next_orifice_node_to_line_flow = ( -p4_port1_next_orifice_node_balance.port_2_mass_flow_g_s * 1.0e-3 ) - p4_port1_next_orifice_line_center_flow = ( - self.components.p4_port1_next_orifice_line.resistance_mass_flow() - ) - p4_port1_next_orifice_to_output_line_flow = self._line_to_p4_flow( - line=p4_port1_next_orifice_line_port_2, - p4_boundary=p4_port1_next_orifice_output_line, + p4_port1_next_orifice_line_flows = self._two_state_orifice_line_flows( + line=self.components.p4_port1_next_orifice_line, + line_port_2_properties=p4_port1_next_orifice_line_port_2, + boundary_properties=p4_port1_next_orifice_output_line, orifice=self.components.p4_port1_next_orifice, ) + p4_port1_next_orifice_line_center_flow = ( + p4_port1_next_orifice_line_flows.line_center_flow + ) + p4_port1_next_orifice_to_output_line_flow = ( + p4_port1_next_orifice_line_flows.line_to_boundary_flow + ) p4_port1_next_orifice_resistance_node_balance = self._pn3_node_balance( node=self.components.p4_port1_next_orifice_resistance_node, primary_properties=p4_port1_next_orifice_resistance_line_port_1, @@ -1138,13 +1156,21 @@ class TestMqlPn3P4NodeChamberSegmentClosure: -p4_port1_next_orifice_resistance_node_balance.port_2_mass_flow_g_s * 1.0e-3 ) - p4_port1_next_orifice_resistance_line_center_flow = ( - self.components.p4_port1_next_orifice_resistance_line.resistance_mass_flow() + p4_port1_next_orifice_resistance_line_flows = ( + self._two_state_orifice_line_flows( + line=self.components.p4_port1_next_orifice_resistance_line, + line_port_2_properties=( + p4_port1_next_orifice_resistance_line_port_2 + ), + boundary_properties=p4_port1_far_primary_line, + orifice=self.components.p4_port1_next_orifice_resistance_orifice, + ) ) - p4_port1_next_orifice_resistance_to_p4_flow = self._line_to_p4_flow( - line=p4_port1_next_orifice_resistance_line_port_2, - p4_boundary=p4_port1_far_primary_line, - orifice=self.components.p4_port1_next_orifice_resistance_orifice, + p4_port1_next_orifice_resistance_line_center_flow = ( + p4_port1_next_orifice_resistance_line_flows.line_center_flow + ) + p4_port1_next_orifice_resistance_to_p4_flow = ( + p4_port1_next_orifice_resistance_line_flows.line_to_boundary_flow ) p4_port3_next_resistance_node_balance = self._pn3_node_balance( node=self.components.p4_port3_next_resistance_node, @@ -1167,14 +1193,18 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port3_next_resistance_node_to_line_flow = ( -p4_port3_next_resistance_node_balance.port_2_mass_flow_g_s * 1.0e-3 ) - p4_port3_next_resistance_line_center_flow = ( - self.components.p4_port3_next_resistance_node_line.resistance_mass_flow() - ) - p4_port3_next_resistance_to_output_line_flow = self._line_to_p4_flow( - line=p4_port3_next_resistance_node_line_port_2, - p4_boundary=p4_port3_next_resistance_output_line, + p4_port3_next_resistance_line_flows = self._two_state_orifice_line_flows( + line=self.components.p4_port3_next_resistance_node_line, + line_port_2_properties=p4_port3_next_resistance_node_line_port_2, + boundary_properties=p4_port3_next_resistance_output_line, orifice=self.components.p4_port3_next_resistance_orifice, ) + p4_port3_next_resistance_line_center_flow = ( + p4_port3_next_resistance_line_flows.line_center_flow + ) + p4_port3_next_resistance_to_output_line_flow = ( + p4_port3_next_resistance_line_flows.line_to_boundary_flow + ) p4_port3_next_resistance_output_to_p4_flow = ( p4_port3_next_resistance_to_output_line_flow ) @@ -1224,25 +1254,33 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port3_remote_resistance_node_to_line_flow = ( -p4_port3_remote_resistance_node_balance.port_2_mass_flow_g_s * 1.0e-3 ) - p4_port3_remote_resistance_line_center_flow = ( - self.components.p4_port3_remote_resistance_node_line.resistance_mass_flow() - ) - p4_port3_remote_resistance_to_output_line_flow = self._line_to_p4_flow( - line=p4_port3_remote_resistance_node_line_port_2, - p4_boundary=p4_port3_remote_resistance_output_line, + p4_port3_remote_resistance_line_flows = self._two_state_orifice_line_flows( + line=self.components.p4_port3_remote_resistance_node_line, + line_port_2_properties=p4_port3_remote_resistance_node_line_port_2, + boundary_properties=p4_port3_remote_resistance_output_line, orifice=self.components.p4_port3_remote_resistance_orifice, ) + p4_port3_remote_resistance_line_center_flow = ( + p4_port3_remote_resistance_line_flows.line_center_flow + ) + p4_port3_remote_resistance_to_output_line_flow = ( + p4_port3_remote_resistance_line_flows.line_to_boundary_flow + ) p4_port3_remote_resistance_output_to_p4_flow = ( p4_port3_remote_resistance_to_output_line_flow ) - p4_port3_remote_orifice_line_center_flow = ( - self.components.p4_port3_remote_orifice_line.resistance_mass_flow() - ) - p4_port3_remote_orifice_to_node_flow = self._line_to_p4_flow( - line=p4_port3_remote_orifice_line_port_2, - p4_boundary=p4_port3_remote_primary_line, + p4_port3_remote_orifice_line_flows = self._two_state_orifice_line_flows( + line=self.components.p4_port3_remote_orifice_line, + line_port_2_properties=p4_port3_remote_orifice_line_port_2, + boundary_properties=p4_port3_remote_primary_line, orifice=self.components.p4_port3_remote_orifice, ) + p4_port3_remote_orifice_line_center_flow = ( + p4_port3_remote_orifice_line_flows.line_center_flow + ) + p4_port3_remote_orifice_to_node_flow = ( + p4_port3_remote_orifice_line_flows.line_to_boundary_flow + ) p4_balance = self._p4_node_balance( node=self.components.p4_node, primary_properties=p4_primary_line, @@ -1774,6 +1812,23 @@ class TestMqlPn3P4NodeChamberSegmentClosure: connected_h=connected_h, ) + def _two_state_orifice_line_flows( + self, + *, + line: AmesimPnl0003Pipe, + line_port_2_properties: ThermodynamicProperties, + boundary_properties: ThermodynamicProperties, + orifice: AmesimPneumaticOrifice, + ) -> TestMqlTwoStateOrificeLineFlows: + return TestMqlTwoStateOrificeLineFlows( + line_center_flow=line.resistance_mass_flow(), + line_to_boundary_flow=self._line_to_p4_flow( + line=line_port_2_properties, + p4_boundary=boundary_properties, + orifice=orifice, + ), + ) + def _fixed_chamber_segment_flows( self, *,