diff --git a/PythonModels/systems/test_mql.py b/PythonModels/systems/test_mql.py index 0d76f1b..339927c 100644 --- a/PythonModels/systems/test_mql.py +++ b/PythonModels/systems/test_mql.py @@ -4674,6 +4674,25 @@ class TestMqlSystem: p4_port1_far_primary_chamber = self.network.components[ p4_port1_far_primary_chamber_alias ] + p4_port1_far_port1 = self._pnl0002_connection_for_node_port( + p4_port1_far_node_alias, + "port_1", + ) + p4_port1_far_port1_line = self.pnl0002_assembly.lines[ + p4_port1_far_port1.line_alias + ] + p4_port1_next_node_alias = p4_port1_far_port1.remote_node_alias + p4_port1_next_node = self.node4_assembly[p4_port1_next_node_alias] + p4_port1_next_primary = self._p4_primary_connection_for_node( + p4_port1_next_node_alias + ) + p4_port1_next_primary_line = self.pnl0001_assembly.lines[ + p4_port1_next_primary.line_alias + ] + p4_port1_next_primary_chamber_alias = p4_port1_next_primary.chamber_alias + p4_port1_next_primary_chamber = self.network.components[ + p4_port1_next_primary_chamber_alias + ] p4_port1_remote_orifice = self.pneumatic_assembly.variable_orifices[ p4_port1_remote_neighborhood.port_4.orifice_alias ] @@ -4713,6 +4732,25 @@ class TestMqlSystem: p4_port3_far_primary_chamber = self.network.components[ p4_port3_far_primary_chamber_alias ] + p4_port3_far_port3 = self._pnl0002_connection_for_node_port( + p4_port3_far_node_alias, + "port_3", + ) + p4_port3_far_port3_line = self.pnl0002_assembly.lines[ + p4_port3_far_port3.line_alias + ] + p4_port3_next_node_alias = p4_port3_far_port3.remote_node_alias + p4_port3_next_node = self.node4_assembly[p4_port3_next_node_alias] + p4_port3_next_primary = self._p4_primary_connection_for_node( + p4_port3_next_node_alias + ) + p4_port3_next_primary_line = self.pnl0001_assembly.lines[ + p4_port3_next_primary.line_alias + ] + p4_port3_next_primary_chamber_alias = p4_port3_next_primary.chamber_alias + p4_port3_next_primary_chamber = self.network.components[ + p4_port3_next_primary_chamber_alias + ] p4_port3_remote_orifice = self.pneumatic_assembly.variable_orifices[ p4_port3_remote_neighborhood.port_4.orifice_alias ] @@ -4751,6 +4789,14 @@ class TestMqlSystem: raise TypeError( f"{p4_port3_far_primary_chamber_alias} is not an AMESim pneumatic volume" ) + if not isinstance(p4_port1_next_primary_chamber, AmesimPneumaticVolume): + raise TypeError( + f"{p4_port1_next_primary_chamber_alias} is not an AMESim pneumatic volume" + ) + if not isinstance(p4_port3_next_primary_chamber, AmesimPneumaticVolume): + raise TypeError( + f"{p4_port3_next_primary_chamber_alias} is not an AMESim pneumatic volume" + ) if not isinstance(inlet_orifice, AmesimPneumaticOrifice): raise TypeError( f"{spec.inlet_orifice_alias} is not an AMESim pneumatic orifice" @@ -4778,6 +4824,10 @@ class TestMqlSystem: p4_port1_far_node=p4_port1_far_node, p4_port1_far_primary_line=p4_port1_far_primary_line, p4_port1_far_primary_chamber=p4_port1_far_primary_chamber, + p4_port1_far_port1_line=p4_port1_far_port1_line, + p4_port1_next_node=p4_port1_next_node, + p4_port1_next_primary_line=p4_port1_next_primary_line, + p4_port1_next_primary_chamber=p4_port1_next_primary_chamber, p4_port1_remote_orifice=p4_port1_remote_orifice, p4_port1_remote_orifice_line=p4_port1_remote_orifice_line, p4_port1_remote_orifice_node=p4_port1_remote_orifice_node, @@ -4789,6 +4839,10 @@ class TestMqlSystem: p4_port3_far_node=p4_port3_far_node, p4_port3_far_primary_line=p4_port3_far_primary_line, p4_port3_far_primary_chamber=p4_port3_far_primary_chamber, + p4_port3_far_port3_line=p4_port3_far_port3_line, + p4_port3_next_node=p4_port3_next_node, + p4_port3_next_primary_line=p4_port3_next_primary_line, + p4_port3_next_primary_chamber=p4_port3_next_primary_chamber, p4_port3_remote_orifice=p4_port3_remote_orifice, p4_port3_remote_orifice_line=p4_port3_remote_orifice_line, p4_port3_remote_orifice_node=p4_port3_remote_orifice_node, diff --git a/PythonModels/systems/test_mql_closure.py b/PythonModels/systems/test_mql_closure.py index 1bd9345..ea8fac0 100644 --- a/PythonModels/systems/test_mql_closure.py +++ b/PythonModels/systems/test_mql_closure.py @@ -207,6 +207,10 @@ class TestMqlPn3P4NodeChamberSegmentComponents: p4_port1_far_node: TestMqlPneumaticNode4 p4_port1_far_primary_line: AmesimPnl0001Pipe p4_port1_far_primary_chamber: AmesimPneumaticVolume + p4_port1_far_port1_line: AmesimPnl0002Pipe + p4_port1_next_node: TestMqlPneumaticNode4 + p4_port1_next_primary_line: AmesimPnl0001Pipe + p4_port1_next_primary_chamber: AmesimPneumaticVolume p4_port1_remote_orifice: AmesimPneumaticOrifice p4_port1_remote_orifice_line: AmesimPnl0003Pipe p4_port1_remote_orifice_node: TestMqlPneumaticNode3 @@ -218,6 +222,10 @@ class TestMqlPn3P4NodeChamberSegmentComponents: p4_port3_far_node: TestMqlPneumaticNode4 p4_port3_far_primary_line: AmesimPnl0001Pipe p4_port3_far_primary_chamber: AmesimPneumaticVolume + p4_port3_far_port3_line: AmesimPnl0002Pipe + p4_port3_next_node: TestMqlPneumaticNode4 + p4_port3_next_primary_line: AmesimPnl0001Pipe + p4_port3_next_primary_chamber: AmesimPneumaticVolume p4_port3_remote_orifice: AmesimPneumaticOrifice p4_port3_remote_orifice_line: AmesimPnl0003Pipe p4_port3_remote_orifice_node: TestMqlPneumaticNode3 @@ -244,6 +252,9 @@ class TestMqlPn3P4NodeChamberSegmentSnapshot: p4_port1_remote_port1_line: ThermodynamicProperties p4_port1_far_primary_line: ThermodynamicProperties p4_port1_far_primary_chamber: ThermodynamicProperties + p4_port1_far_port1_line: ThermodynamicProperties + p4_port1_next_primary_line: ThermodynamicProperties + p4_port1_next_primary_chamber: ThermodynamicProperties p4_port1_remote_orifice_line_port_1: ThermodynamicProperties p4_port1_remote_orifice_line_port_2: ThermodynamicProperties p4_port3_line: ThermodynamicProperties @@ -252,6 +263,9 @@ class TestMqlPn3P4NodeChamberSegmentSnapshot: p4_port3_remote_port3_line: ThermodynamicProperties p4_port3_far_primary_line: ThermodynamicProperties p4_port3_far_primary_chamber: ThermodynamicProperties + p4_port3_far_port3_line: ThermodynamicProperties + p4_port3_next_primary_line: ThermodynamicProperties + p4_port3_next_primary_chamber: ThermodynamicProperties p4_port3_remote_orifice_line_port_1: ThermodynamicProperties p4_port3_remote_orifice_line_port_2: ThermodynamicProperties inlet_node: ThermodynamicProperties @@ -260,9 +274,11 @@ class TestMqlPn3P4NodeChamberSegmentSnapshot: p4_balance: TestMqlPneumaticNode4Balance p4_port1_remote_balance: TestMqlPneumaticNode4Balance p4_port1_far_balance: TestMqlPneumaticNode4Balance + p4_port1_next_balance: TestMqlPneumaticNode4Balance p4_port1_remote_orifice_node_balance: TestMqlPneumaticNode3Balance p4_port3_remote_balance: TestMqlPneumaticNode4Balance p4_port3_far_balance: TestMqlPneumaticNode4Balance + p4_port3_next_balance: TestMqlPneumaticNode4Balance p4_port3_remote_orifice_node_balance: TestMqlPneumaticNode3Balance inlet_node_to_line_flow: float inlet_line_to_chamber_flow: float @@ -282,6 +298,10 @@ class TestMqlPn3P4NodeChamberSegmentSnapshot: p4_port1_far_node_to_line_flow: float p4_port1_far_chamber_to_line_flow: float p4_port1_far_node_to_primary_line_flow: float + p4_port1_far_to_next_line_flow: float + p4_port1_next_node_to_line_flow: float + p4_port1_next_chamber_to_line_flow: float + p4_port1_next_node_to_primary_line_flow: float p4_port1_remote_node_to_orifice_line_flow: float p4_port1_remote_orifice_line_center_flow: float p4_port1_remote_orifice_to_node_flow: float @@ -293,6 +313,10 @@ class TestMqlPn3P4NodeChamberSegmentSnapshot: p4_port3_far_node_to_line_flow: float p4_port3_far_chamber_to_line_flow: float p4_port3_far_node_to_primary_line_flow: float + p4_port3_far_to_next_line_flow: float + p4_port3_next_node_to_line_flow: float + p4_port3_next_chamber_to_line_flow: float + p4_port3_next_node_to_primary_line_flow: float p4_port3_remote_node_to_orifice_line_flow: float p4_port3_remote_node_to_resistance_flow: float p4_port3_remote_orifice_line_center_flow: float @@ -332,6 +356,9 @@ class TestMqlPn3P4NodeChamberSegmentClosure: *self.components.p4_port1_remote_port1_line.get_state_vector(), *self.components.p4_port1_far_primary_line.get_state_vector(), *self.components.p4_port1_far_primary_chamber.get_state_vector(), + *self.components.p4_port1_far_port1_line.get_state_vector(), + *self.components.p4_port1_next_primary_line.get_state_vector(), + *self.components.p4_port1_next_primary_chamber.get_state_vector(), *self.components.p4_port1_remote_orifice_line.get_state_vector(), *self.components.p4_port3_line.get_state_vector(), *self.components.p4_port3_remote_primary_line.get_state_vector(), @@ -339,12 +366,15 @@ class TestMqlPn3P4NodeChamberSegmentClosure: *self.components.p4_port3_remote_port3_line.get_state_vector(), *self.components.p4_port3_far_primary_line.get_state_vector(), *self.components.p4_port3_far_primary_chamber.get_state_vector(), + *self.components.p4_port3_far_port3_line.get_state_vector(), + *self.components.p4_port3_next_primary_line.get_state_vector(), + *self.components.p4_port3_next_primary_chamber.get_state_vector(), *self.components.p4_port3_remote_orifice_line.get_state_vector(), ] def apply_state_vector(self, values: list[float]) -> None: - if len(values) != 46: - raise ValueError("PN3/P4 node chamber segment state vector requires forty-six values") + if len(values) != 58: + raise ValueError("PN3/P4 node chamber segment state vector requires fifty-eight values") self.components.inlet_line.set_state_vector(values[:2]) self.components.volume.set_state_vector(values[2:4]) self.components.outlet_line.set_state_vector(values[4:6]) @@ -357,14 +387,20 @@ class TestMqlPn3P4NodeChamberSegmentClosure: self.components.p4_port1_remote_port1_line.set_state_vector(values[20:22]) self.components.p4_port1_far_primary_line.set_state_vector(values[22:24]) self.components.p4_port1_far_primary_chamber.set_state_vector(values[24:26]) - self.components.p4_port1_remote_orifice_line.set_state_vector(values[26:30]) - self.components.p4_port3_line.set_state_vector(values[30:32]) - self.components.p4_port3_remote_primary_line.set_state_vector(values[32:34]) - self.components.p4_port3_remote_primary_chamber.set_state_vector(values[34:36]) - self.components.p4_port3_remote_port3_line.set_state_vector(values[36:38]) - self.components.p4_port3_far_primary_line.set_state_vector(values[38:40]) - self.components.p4_port3_far_primary_chamber.set_state_vector(values[40:42]) - self.components.p4_port3_remote_orifice_line.set_state_vector(values[42:]) + self.components.p4_port1_far_port1_line.set_state_vector(values[26:28]) + self.components.p4_port1_next_primary_line.set_state_vector(values[28:30]) + self.components.p4_port1_next_primary_chamber.set_state_vector(values[30:32]) + self.components.p4_port1_remote_orifice_line.set_state_vector(values[32:36]) + self.components.p4_port3_line.set_state_vector(values[36:38]) + self.components.p4_port3_remote_primary_line.set_state_vector(values[38:40]) + self.components.p4_port3_remote_primary_chamber.set_state_vector(values[40:42]) + self.components.p4_port3_remote_port3_line.set_state_vector(values[42:44]) + self.components.p4_port3_far_primary_line.set_state_vector(values[44:46]) + self.components.p4_port3_far_primary_chamber.set_state_vector(values[46:48]) + self.components.p4_port3_far_port3_line.set_state_vector(values[48:50]) + self.components.p4_port3_next_primary_line.set_state_vector(values[50:52]) + self.components.p4_port3_next_primary_chamber.set_state_vector(values[52:54]) + self.components.p4_port3_remote_orifice_line.set_state_vector(values[54:]) def snapshot( self, @@ -393,6 +429,11 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port1_far_primary_chamber = ( self.components.p4_port1_far_primary_chamber.properties() ) + p4_port1_far_port1_line = self.components.p4_port1_far_port1_line.properties() + p4_port1_next_primary_line = self.components.p4_port1_next_primary_line.properties() + p4_port1_next_primary_chamber = ( + self.components.p4_port1_next_primary_chamber.properties() + ) p4_port1_remote_orifice_line_port_1 = ( self.components.p4_port1_remote_orifice_line.properties_1() ) @@ -413,6 +454,11 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port3_far_primary_chamber = ( self.components.p4_port3_far_primary_chamber.properties() ) + p4_port3_far_port3_line = self.components.p4_port3_far_port3_line.properties() + p4_port3_next_primary_line = self.components.p4_port3_next_primary_line.properties() + p4_port3_next_primary_chamber = ( + self.components.p4_port3_next_primary_chamber.properties() + ) p4_port3_remote_orifice_line_port_1 = ( self.components.p4_port3_remote_orifice_line.properties_1() ) @@ -511,6 +557,24 @@ class TestMqlPn3P4NodeChamberSegmentClosure: port_1_temperature_k=p4_port1_far_primary_chamber.T, ) ) + p4_port1_far_to_next_line_flow = ( + self.components.p4_port1_far_port1_line.port_mass_flow( + port_pressure_pa=p4_port1_far_primary_line.p, + port_temperature_k=p4_port1_far_primary_line.T, + ) + ) + p4_port1_next_node_to_line_flow = ( + self.components.p4_port1_far_port1_line.port_mass_flow( + port_pressure_pa=p4_port1_next_primary_line.p, + port_temperature_k=p4_port1_next_primary_line.T, + ) + ) + p4_port1_next_chamber_to_line_flow = ( + self.components.p4_port1_next_primary_line.resistance_mass_flow( + port_1_pressure_pa=p4_port1_next_primary_chamber.p, + port_1_temperature_k=p4_port1_next_primary_chamber.T, + ) + ) p4_port1_remote_node_to_orifice_line_flow = -self.components.p4_port1_remote_orifice_node.balance( port_2_temperature_k=p4_port1_remote_orifice_line_port_1.T, port_2_pressure_pa=p4_port1_remote_orifice_line_port_1.p, @@ -565,6 +629,24 @@ class TestMqlPn3P4NodeChamberSegmentClosure: port_1_temperature_k=p4_port3_far_primary_chamber.T, ) ) + p4_port3_far_to_next_line_flow = ( + self.components.p4_port3_far_port3_line.port_mass_flow( + port_pressure_pa=p4_port3_far_primary_line.p, + port_temperature_k=p4_port3_far_primary_line.T, + ) + ) + p4_port3_next_node_to_line_flow = ( + self.components.p4_port3_far_port3_line.port_mass_flow( + port_pressure_pa=p4_port3_next_primary_line.p, + port_temperature_k=p4_port3_next_primary_line.T, + ) + ) + p4_port3_next_chamber_to_line_flow = ( + self.components.p4_port3_next_primary_line.resistance_mass_flow( + port_1_pressure_pa=p4_port3_next_primary_chamber.p, + port_1_temperature_k=p4_port3_next_primary_chamber.T, + ) + ) p4_port3_remote_node_to_resistance_flow = ( self.components.p4_port3_remote_orifice_resistance.mass_flow( port_1_pressure_pa=p4_port3_remote_orifice_line_port_1.p, @@ -667,8 +749,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port1_far_balance = self.components.p4_port1_far_node.balance( port_2_temperature_k=p4_port1_far_primary_line.T, port_2_pressure_pa=p4_port1_far_primary_line.p, - port_1_enthalpy_flow_w=0.0, - port_1_mass_flow_g_s=0.0, + port_1_enthalpy_flow_w=self._enthalpy_flow_from_node( + flow_kg_s=p4_port1_far_to_next_line_flow, + node_h=p4_port1_far_primary_line.h, + connected_h=p4_port1_far_port1_line.h, + ), + port_1_mass_flow_g_s=-p4_port1_far_to_next_line_flow * 1.0e3, port_3_enthalpy_flow_w=self._enthalpy_flow_from_node( flow_kg_s=p4_port1_far_node_to_line_flow, node_h=p4_port1_far_primary_line.h, @@ -681,6 +767,23 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port1_far_node_to_primary_line_flow = ( p4_port1_far_balance.port_2_mass_flow_g_s * 1.0e-3 ) + p4_port1_next_balance = self.components.p4_port1_next_node.balance( + port_2_temperature_k=p4_port1_next_primary_line.T, + port_2_pressure_pa=p4_port1_next_primary_line.p, + port_1_enthalpy_flow_w=0.0, + port_1_mass_flow_g_s=0.0, + port_3_enthalpy_flow_w=self._enthalpy_flow_from_node( + flow_kg_s=p4_port1_next_node_to_line_flow, + node_h=p4_port1_next_primary_line.h, + connected_h=p4_port1_far_port1_line.h, + ), + port_3_mass_flow_g_s=-p4_port1_next_node_to_line_flow * 1.0e3, + port_4_enthalpy_flow_w=0.0, + port_4_mass_flow_g_s=0.0, + ) + p4_port1_next_node_to_primary_line_flow = ( + p4_port1_next_balance.port_2_mass_flow_g_s * 1.0e-3 + ) p4_port3_remote_balance = self.components.p4_port3_remote_node.balance( port_2_temperature_k=p4_port3_remote_primary_line.T, port_2_pressure_pa=p4_port3_remote_primary_line.p, @@ -715,14 +818,35 @@ class TestMqlPn3P4NodeChamberSegmentClosure: connected_h=p4_port3_remote_port3_line.h, ), port_1_mass_flow_g_s=-p4_port3_far_node_to_line_flow * 1.0e3, - port_3_enthalpy_flow_w=0.0, - port_3_mass_flow_g_s=0.0, + port_3_enthalpy_flow_w=self._enthalpy_flow_from_node( + flow_kg_s=p4_port3_far_to_next_line_flow, + node_h=p4_port3_far_primary_line.h, + connected_h=p4_port3_far_port3_line.h, + ), + port_3_mass_flow_g_s=-p4_port3_far_to_next_line_flow * 1.0e3, port_4_enthalpy_flow_w=0.0, port_4_mass_flow_g_s=0.0, ) p4_port3_far_node_to_primary_line_flow = ( p4_port3_far_balance.port_2_mass_flow_g_s * 1.0e-3 ) + p4_port3_next_balance = self.components.p4_port3_next_node.balance( + port_2_temperature_k=p4_port3_next_primary_line.T, + port_2_pressure_pa=p4_port3_next_primary_line.p, + port_1_enthalpy_flow_w=self._enthalpy_flow_from_node( + flow_kg_s=p4_port3_next_node_to_line_flow, + node_h=p4_port3_next_primary_line.h, + connected_h=p4_port3_far_port3_line.h, + ), + port_1_mass_flow_g_s=-p4_port3_next_node_to_line_flow * 1.0e3, + port_3_enthalpy_flow_w=0.0, + port_3_mass_flow_g_s=0.0, + port_4_enthalpy_flow_w=0.0, + port_4_mass_flow_g_s=0.0, + ) + p4_port3_next_node_to_primary_line_flow = ( + p4_port3_next_balance.port_2_mass_flow_g_s * 1.0e-3 + ) snapshot = TestMqlPn3P4NodeChamberSegmentSnapshot( inlet_line=inlet_line, @@ -739,6 +863,9 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port1_remote_port1_line=p4_port1_remote_port1_line, p4_port1_far_primary_line=p4_port1_far_primary_line, p4_port1_far_primary_chamber=p4_port1_far_primary_chamber, + p4_port1_far_port1_line=p4_port1_far_port1_line, + p4_port1_next_primary_line=p4_port1_next_primary_line, + p4_port1_next_primary_chamber=p4_port1_next_primary_chamber, p4_port1_remote_orifice_line_port_1=p4_port1_remote_orifice_line_port_1, p4_port1_remote_orifice_line_port_2=p4_port1_remote_orifice_line_port_2, p4_port3_line=p4_port3_line, @@ -747,6 +874,9 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port3_remote_port3_line=p4_port3_remote_port3_line, p4_port3_far_primary_line=p4_port3_far_primary_line, p4_port3_far_primary_chamber=p4_port3_far_primary_chamber, + p4_port3_far_port3_line=p4_port3_far_port3_line, + p4_port3_next_primary_line=p4_port3_next_primary_line, + p4_port3_next_primary_chamber=p4_port3_next_primary_chamber, p4_port3_remote_orifice_line_port_1=p4_port3_remote_orifice_line_port_1, p4_port3_remote_orifice_line_port_2=p4_port3_remote_orifice_line_port_2, inlet_node=inlet_node, @@ -755,9 +885,11 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_balance=p4_balance, p4_port1_remote_balance=p4_port1_remote_balance, p4_port1_far_balance=p4_port1_far_balance, + p4_port1_next_balance=p4_port1_next_balance, p4_port1_remote_orifice_node_balance=p4_port1_remote_orifice_node_balance, p4_port3_remote_balance=p4_port3_remote_balance, p4_port3_far_balance=p4_port3_far_balance, + p4_port3_next_balance=p4_port3_next_balance, p4_port3_remote_orifice_node_balance=p4_port3_remote_orifice_node_balance, inlet_node_to_line_flow=inlet_node_to_line_flow, inlet_line_to_chamber_flow=inlet_line_to_chamber_flow, @@ -781,6 +913,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port1_far_node_to_primary_line_flow=( p4_port1_far_node_to_primary_line_flow ), + p4_port1_far_to_next_line_flow=p4_port1_far_to_next_line_flow, + p4_port1_next_node_to_line_flow=p4_port1_next_node_to_line_flow, + p4_port1_next_chamber_to_line_flow=p4_port1_next_chamber_to_line_flow, + p4_port1_next_node_to_primary_line_flow=( + p4_port1_next_node_to_primary_line_flow + ), p4_port1_remote_node_to_orifice_line_flow=( p4_port1_remote_node_to_orifice_line_flow ), @@ -800,6 +938,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure: p4_port3_far_node_to_primary_line_flow=( p4_port3_far_node_to_primary_line_flow ), + p4_port3_far_to_next_line_flow=p4_port3_far_to_next_line_flow, + p4_port3_next_node_to_line_flow=p4_port3_next_node_to_line_flow, + p4_port3_next_chamber_to_line_flow=p4_port3_next_chamber_to_line_flow, + p4_port3_next_node_to_primary_line_flow=( + p4_port3_next_node_to_primary_line_flow + ), p4_port3_remote_node_to_orifice_line_flow=( p4_port3_remote_node_to_orifice_line_flow ), @@ -1003,6 +1147,27 @@ class TestMqlPn3P4NodeChamberSegmentClosure: 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 + 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 + + 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 + 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 p4_port1_remote_orifice_line.port_1.m_flow = snapshot.p4_port1_remote_node_to_orifice_line_flow @@ -1079,6 +1244,27 @@ class TestMqlPn3P4NodeChamberSegmentClosure: 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 + 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 + + 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 + p4_port3_remote_orifice_line = self.components.p4_port3_remote_orifice_line p4_port3_remote_orifice_line.port_1.p = snapshot.p4_port3_remote_orifice_line_port_1.p p4_port3_remote_orifice_line.port_1.m_flow = snapshot.p4_port3_remote_node_to_orifice_line_flow @@ -1207,6 +1393,31 @@ class TestMqlPn3P4NodeChamberSegmentClosure: internal_h=snapshot.p4_port1_far_primary_chamber.h, ) ) + 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_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_remote_orifice_derivative_1, p4_port1_remote_orifice_derivative_2 = ( self.components.p4_port1_remote_orifice_line.derivatives_from_connections( port_1_m_flow=snapshot.p4_port1_remote_node_to_orifice_line_flow, @@ -1263,6 +1474,31 @@ class TestMqlPn3P4NodeChamberSegmentClosure: internal_h=snapshot.p4_port3_far_primary_chamber.h, ) ) + 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_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_remote_orifice_derivative_1, p4_port3_remote_orifice_derivative_2 = ( self.components.p4_port3_remote_orifice_line.derivatives_from_connections( port_1_m_flow=snapshot.p4_port3_remote_node_to_orifice_line_flow, @@ -1285,6 +1521,9 @@ class TestMqlPn3P4NodeChamberSegmentClosure: *p4_port1_remote_port1_derivative.as_vector(), *p4_port1_far_primary_derivative.as_vector(), *p4_port1_far_chamber_derivative.as_vector(), + *p4_port1_far_port1_derivative.as_vector(), + *p4_port1_next_primary_derivative.as_vector(), + *p4_port1_next_chamber_derivative.as_vector(), *p4_port1_remote_orifice_derivative_1.as_vector(), *p4_port1_remote_orifice_derivative_2.as_vector(), *p4_port3_derivative.as_vector(), @@ -1293,6 +1532,9 @@ class TestMqlPn3P4NodeChamberSegmentClosure: *p4_port3_remote_port3_derivative.as_vector(), *p4_port3_far_primary_derivative.as_vector(), *p4_port3_far_chamber_derivative.as_vector(), + *p4_port3_far_port3_derivative.as_vector(), + *p4_port3_next_primary_derivative.as_vector(), + *p4_port3_next_chamber_derivative.as_vector(), *p4_port3_remote_orifice_derivative_1.as_vector(), *p4_port3_remote_orifice_derivative_2.as_vector(), ] diff --git a/tests/test_test_mql_pnl0001_segment.py b/tests/test_test_mql_pnl0001_segment.py index 7d0c240..21d4124 100644 --- a/tests/test_test_mql_pnl0001_segment.py +++ b/tests/test_test_mql_pnl0001_segment.py @@ -288,6 +288,16 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase): closure.components.p4_port1_far_primary_chamber.name, "pn_c1_11", ) + self.assertEqual(closure.components.p4_port1_far_port1_line.name, "pneumatic_85") + self.assertEqual(closure.components.p4_port1_next_node.alias, "pnnode4_23") + self.assertEqual( + closure.components.p4_port1_next_primary_line.name, + "pneumatic_71", + ) + self.assertEqual( + closure.components.p4_port1_next_primary_chamber.name, + "pn_c1_12", + ) self.assertEqual( closure.components.p4_port1_remote_orifice.name, "pn_morifice_10", @@ -323,6 +333,16 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase): closure.components.p4_port3_far_primary_chamber.name, "pn_c1_15", ) + self.assertEqual(closure.components.p4_port3_far_port3_line.name, "pneumatic_82") + self.assertEqual(closure.components.p4_port3_next_node.alias, "pnnode4_21") + self.assertEqual( + closure.components.p4_port3_next_primary_line.name, + "pneumatic_73", + ) + self.assertEqual( + closure.components.p4_port3_next_primary_chamber.name, + "pn_c1_14", + ) self.assertEqual( closure.components.p4_port3_remote_orifice.name, "pn_morifice_1", @@ -339,8 +359,8 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase): closure.components.p4_port3_remote_orifice_resistance.name, "pneumatic_105", ) - self.assertEqual(len(closure.initial_state_vector()), 46) - self.assertEqual(len(rhs), 46) + self.assertEqual(len(closure.initial_state_vector()), 58) + self.assertEqual(len(rhs), 58) self.assertAlmostEqual( snapshot.p4_balance.pressure_pa, snapshot.p4_primary_line.p, @@ -391,6 +411,24 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase): port1_remote_neighborhood.port_1.remote_node_alias ).line_alias, ) + port1_far_port1 = self.system._pnl0002_connection_for_node_port( + closure.components.p4_port1_far_node.alias, + "port_1", + ) + self.assertEqual( + closure.components.p4_port1_far_port1_line.name, + port1_far_port1.line_alias, + ) + self.assertEqual( + closure.components.p4_port1_next_node.alias, + port1_far_port1.remote_node_alias, + ) + self.assertEqual( + closure.components.p4_port1_next_primary_line.name, + self.system._p4_primary_connection_for_node( + port1_far_port1.remote_node_alias + ).line_alias, + ) self.assertEqual( closure.components.p4_port1_remote_orifice.name, port1_remote_neighborhood.port_4.orifice_alias, @@ -428,6 +466,24 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase): port3_remote_neighborhood.port_3.remote_node_alias ).line_alias, ) + port3_far_port3 = self.system._pnl0002_connection_for_node_port( + closure.components.p4_port3_far_node.alias, + "port_3", + ) + self.assertEqual( + closure.components.p4_port3_far_port3_line.name, + port3_far_port3.line_alias, + ) + self.assertEqual( + closure.components.p4_port3_next_node.alias, + port3_far_port3.remote_node_alias, + ) + self.assertEqual( + closure.components.p4_port3_next_primary_line.name, + self.system._p4_primary_connection_for_node( + port3_far_port3.remote_node_alias + ).line_alias, + ) self.assertEqual( closure.components.p4_port3_remote_orifice.name, port3_remote_neighborhood.port_4.orifice_alias, @@ -491,7 +547,14 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase): ) self.assertAlmostEqual( snapshot.p4_port1_far_node_to_primary_line_flow - + snapshot.p4_port1_far_node_to_line_flow, + + snapshot.p4_port1_far_node_to_line_flow + + snapshot.p4_port1_far_to_next_line_flow, + 0.0, + delta=1.0e-12, + ) + self.assertAlmostEqual( + snapshot.p4_port1_next_node_to_primary_line_flow + + snapshot.p4_port1_next_node_to_line_flow, 0.0, delta=1.0e-12, ) @@ -517,18 +580,25 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase): ) self.assertAlmostEqual( snapshot.p4_port3_far_node_to_primary_line_flow - + snapshot.p4_port3_far_node_to_line_flow, + + snapshot.p4_port3_far_node_to_line_flow + + snapshot.p4_port3_far_to_next_line_flow, 0.0, delta=1.0e-12, ) - mass_derivative_sum = sum(rhs[index] for index in range(0, 46, 2)) + self.assertAlmostEqual( + snapshot.p4_port3_next_node_to_primary_line_flow + + snapshot.p4_port3_next_node_to_line_flow, + 0.0, + delta=1.0e-12, + ) + mass_derivative_sum = sum(rhs[index] for index in range(0, 58, 2)) self.assertAlmostEqual( mass_derivative_sum, -snapshot.p4_port3_remote_node_to_resistance_flow, delta=1.0e-12, ) - def test_simulates_forty_six_state_pn3_p4_node_chamber_segment(self) -> None: + def test_simulates_fifty_eight_state_pn3_p4_node_chamber_segment(self) -> None: solution = self.system.simulate_pn3_p4_node_chamber_segment_from_spec( self.spec, inlet_node_pressure_pa=15.31e6, @@ -543,8 +613,8 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase): self.assertTrue(solution.success) self.assertEqual(len(solution.t), 3) - self.assertEqual(len(solution.y), 46) - self.assertEqual([len(row) for row in solution.y], [3] * 46) + self.assertEqual(len(solution.y), 58) + self.assertEqual([len(row) for row in solution.y], [3] * 58) if __name__ == "__main__":