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 7b9d28c0ee - Show all commits
+263 -255
View File
@@ -1770,40 +1770,121 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
connected_h=connected_h, connected_h=connected_h,
) )
def _write_port_states( def _write_fixed_chamber_segment(
self, self,
snapshot: TestMqlPn3P4NodeChamberSegmentSnapshot, *,
spec: TestMqlPneumaticChamberSegmentSpec,
chamber: AmesimPneumaticVolume,
chamber_properties: ThermodynamicProperties,
inlet_line: AmesimPnl0001Pipe,
inlet_line_properties: ThermodynamicProperties,
inlet_node_properties: ThermodynamicProperties,
inlet_node_to_line_flow: float,
inlet_line_to_chamber_flow: float,
inlet_orifice: AmesimPneumaticOrifice,
outlet_line: AmesimPnl0001Pipe,
outlet_line_properties: ThermodynamicProperties,
outlet_node_properties: ThermodynamicProperties,
outlet_node_to_line_flow: float,
outlet_line_to_chamber_flow: float,
outlet_orifice: AmesimPneumaticOrifice,
) -> None: ) -> None:
spec = self.components.spec
chamber = self.components.volume
chamber_inlet_port = self._port(chamber, spec.volume_inlet_port) chamber_inlet_port = self._port(chamber, spec.volume_inlet_port)
chamber_outlet_port = self._port(chamber, spec.volume_outlet_port) chamber_outlet_port = self._port(chamber, spec.volume_outlet_port)
TestMqlPnl0001PairChamberSegmentClosure._write_line_side( TestMqlPnl0001PairChamberSegmentClosure._write_line_side(
self, self,
line=self.components.inlet_line, line=inlet_line,
line_properties=snapshot.inlet_line, line_properties=inlet_line_properties,
node_properties=snapshot.p4_port3_remote_orifice_line_port_1, node_properties=inlet_node_properties,
node_to_line_flow=snapshot.inlet_node_to_line_flow, node_to_line_flow=inlet_node_to_line_flow,
line_to_chamber_flow=snapshot.inlet_line_to_chamber_flow, line_to_chamber_flow=inlet_line_to_chamber_flow,
orifice=self.components.inlet_orifice, orifice=inlet_orifice,
orifice_boundary_port=spec.inlet_orifice_boundary_port, orifice_boundary_port=spec.inlet_orifice_boundary_port,
orifice_volume_port=spec.inlet_orifice_volume_port, orifice_volume_port=spec.inlet_orifice_volume_port,
chamber_port=chamber_inlet_port, chamber_port=chamber_inlet_port,
chamber_properties=snapshot.chamber, chamber_properties=chamber_properties,
) )
TestMqlPnl0001PairChamberSegmentClosure._write_line_side( TestMqlPnl0001PairChamberSegmentClosure._write_line_side(
self, self,
line=self.components.outlet_line, line=outlet_line,
line_properties=snapshot.outlet_line, line_properties=outlet_line_properties,
node_properties=snapshot.node_line_port_1, node_properties=outlet_node_properties,
node_to_line_flow=snapshot.outlet_node_to_line_flow, node_to_line_flow=outlet_node_to_line_flow,
line_to_chamber_flow=snapshot.outlet_line_to_chamber_flow, line_to_chamber_flow=outlet_line_to_chamber_flow,
orifice=self.components.outlet_orifice, orifice=outlet_orifice,
orifice_boundary_port=spec.outlet_orifice_boundary_port, orifice_boundary_port=spec.outlet_orifice_boundary_port,
orifice_volume_port=spec.outlet_orifice_volume_port, orifice_volume_port=spec.outlet_orifice_volume_port,
chamber_port=chamber_outlet_port, chamber_port=chamber_outlet_port,
chamber_properties=chamber_properties,
)
def _fixed_chamber_segment_derivatives(
self,
*,
spec: TestMqlPneumaticChamberSegmentSpec,
chamber: AmesimPneumaticVolume,
chamber_properties: ThermodynamicProperties,
inlet_line: AmesimPnl0001Pipe,
inlet_line_properties: ThermodynamicProperties,
inlet_connected_properties: ThermodynamicProperties,
inlet_node_to_line_flow: float,
inlet_line_to_chamber_flow: float,
outlet_line: AmesimPnl0001Pipe,
outlet_line_properties: ThermodynamicProperties,
outlet_connected_properties: ThermodynamicProperties,
outlet_node_to_line_flow: float,
outlet_line_to_chamber_flow: float,
) -> tuple[VolumeState, VolumeState, VolumeState]:
inlet_derivative = inlet_line.derivatives_from_connections(
port_1_m_flow=inlet_node_to_line_flow,
connected_h_1=inlet_connected_properties.h,
port_2_m_flow=-inlet_line_to_chamber_flow,
connected_h_2=chamber_properties.h,
)
chamber_derivative = chamber.derivatives_from_two_connections(
port_a_m_flow=self._port(chamber, "port_1").m_flow,
connected_h_a=(
inlet_line_properties.h
if spec.volume_inlet_port == "port_1"
else outlet_line_properties.h
),
port_b_m_flow=self._port(chamber, "port_2").m_flow,
connected_h_b=(
inlet_line_properties.h
if spec.volume_inlet_port == "port_2"
else outlet_line_properties.h
),
internal_h=chamber_properties.h,
)
outlet_derivative = outlet_line.derivatives_from_connections(
port_1_m_flow=outlet_node_to_line_flow,
connected_h_1=outlet_connected_properties.h,
port_2_m_flow=-outlet_line_to_chamber_flow,
connected_h_2=chamber_properties.h,
)
return inlet_derivative, chamber_derivative, outlet_derivative
def _write_port_states(
self,
snapshot: TestMqlPn3P4NodeChamberSegmentSnapshot,
) -> None:
self._write_fixed_chamber_segment(
spec=self.components.spec,
chamber=self.components.volume,
chamber_properties=snapshot.chamber, chamber_properties=snapshot.chamber,
inlet_line=self.components.inlet_line,
inlet_line_properties=snapshot.inlet_line,
inlet_node_properties=snapshot.p4_port3_remote_orifice_line_port_1,
inlet_node_to_line_flow=snapshot.inlet_node_to_line_flow,
inlet_line_to_chamber_flow=snapshot.inlet_line_to_chamber_flow,
inlet_orifice=self.components.inlet_orifice,
outlet_line=self.components.outlet_line,
outlet_line_properties=snapshot.outlet_line,
outlet_node_properties=snapshot.node_line_port_1,
outlet_node_to_line_flow=snapshot.outlet_node_to_line_flow,
outlet_line_to_chamber_flow=snapshot.outlet_line_to_chamber_flow,
outlet_orifice=self.components.outlet_orifice,
) )
node_line = self.components.node_line node_line = self.components.node_line
@@ -1980,57 +2061,42 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
p4_port1_next_orifice_resistance_orifice.port_b.m_flow = -snapshot.p4_port1_next_orifice_resistance_to_p4_flow p4_port1_next_orifice_resistance_orifice.port_b.m_flow = -snapshot.p4_port1_next_orifice_resistance_to_p4_flow
p4_port1_next_orifice_resistance_orifice.port_b.h_outflow = snapshot.p4_port1_far_primary_line.h p4_port1_next_orifice_resistance_orifice.port_b.h_outflow = snapshot.p4_port1_far_primary_line.h
resistance_chamber_spec = ( self._write_fixed_chamber_segment(
self.components.p4_port1_next_orifice_resistance_chamber_spec spec=self.components.p4_port1_next_orifice_resistance_chamber_spec,
) chamber=self.components.p4_port1_next_orifice_resistance_chamber,
p4_port1_next_orifice_resistance_chamber = ( chamber_properties=snapshot.p4_port1_next_orifice_resistance_chamber,
self.components.p4_port1_next_orifice_resistance_chamber inlet_line=self.components.p4_port1_next_orifice_resistance_chamber_inlet_line,
) inlet_line_properties=(
p4_port1_next_orifice_resistance_chamber_inlet_port = self._port(
p4_port1_next_orifice_resistance_chamber,
resistance_chamber_spec.volume_inlet_port,
)
p4_port1_next_orifice_resistance_chamber_outlet_port = self._port(
p4_port1_next_orifice_resistance_chamber,
resistance_chamber_spec.volume_outlet_port,
)
TestMqlPnl0001PairChamberSegmentClosure._write_line_side(
self,
line=self.components.p4_port1_next_orifice_resistance_chamber_inlet_line,
line_properties=(
snapshot.p4_port1_next_orifice_resistance_chamber_inlet_line snapshot.p4_port1_next_orifice_resistance_chamber_inlet_line
), ),
node_properties=snapshot.p4_port1_remote_orifice_line_port_1, inlet_node_properties=snapshot.p4_port1_remote_orifice_line_port_1,
node_to_line_flow=( inlet_node_to_line_flow=(
snapshot.p4_port1_next_orifice_resistance_chamber_inlet_node_to_line_flow snapshot.p4_port1_next_orifice_resistance_chamber_inlet_node_to_line_flow
), ),
line_to_chamber_flow=( inlet_line_to_chamber_flow=(
snapshot.p4_port1_next_orifice_resistance_chamber_inlet_line_to_chamber_flow snapshot.p4_port1_next_orifice_resistance_chamber_inlet_line_to_chamber_flow
), ),
orifice=self.components.p4_port1_next_orifice_resistance_chamber_inlet_orifice, inlet_orifice=(
orifice_boundary_port=resistance_chamber_spec.inlet_orifice_boundary_port, self.components.p4_port1_next_orifice_resistance_chamber_inlet_orifice
orifice_volume_port=resistance_chamber_spec.inlet_orifice_volume_port, ),
chamber_port=p4_port1_next_orifice_resistance_chamber_inlet_port, outlet_line=(
chamber_properties=snapshot.p4_port1_next_orifice_resistance_chamber, self.components.p4_port1_next_orifice_resistance_chamber_outlet_line
) ),
TestMqlPnl0001PairChamberSegmentClosure._write_line_side( outlet_line_properties=(
self,
line=self.components.p4_port1_next_orifice_resistance_chamber_outlet_line,
line_properties=(
snapshot.p4_port1_next_orifice_resistance_chamber_outlet_line snapshot.p4_port1_next_orifice_resistance_chamber_outlet_line
), ),
node_properties=snapshot.p4_port1_next_orifice_resistance_line_port_1, outlet_node_properties=(
node_to_line_flow=( snapshot.p4_port1_next_orifice_resistance_line_port_1
),
outlet_node_to_line_flow=(
snapshot.p4_port1_next_orifice_resistance_chamber_outlet_node_to_line_flow snapshot.p4_port1_next_orifice_resistance_chamber_outlet_node_to_line_flow
), ),
line_to_chamber_flow=( outlet_line_to_chamber_flow=(
snapshot.p4_port1_next_orifice_resistance_chamber_outlet_line_to_chamber_flow snapshot.p4_port1_next_orifice_resistance_chamber_outlet_line_to_chamber_flow
), ),
orifice=self.components.p4_port1_next_orifice_resistance_chamber_outlet_orifice, outlet_orifice=(
orifice_boundary_port=resistance_chamber_spec.outlet_orifice_boundary_port, self.components.p4_port1_next_orifice_resistance_chamber_outlet_orifice
orifice_volume_port=resistance_chamber_spec.outlet_orifice_volume_port, ),
chamber_port=p4_port1_next_orifice_resistance_chamber_outlet_port,
chamber_properties=snapshot.p4_port1_next_orifice_resistance_chamber,
) )
p4_bridge_primary_line = self.components.p4_bridge_primary_line p4_bridge_primary_line = self.components.p4_bridge_primary_line
@@ -2175,41 +2241,30 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
p4_port3_next_orifice_output_line.port_2.m_flow = -snapshot.p4_port3_next_orifice_output_to_p4_flow p4_port3_next_orifice_output_line.port_2.m_flow = -snapshot.p4_port3_next_orifice_output_to_p4_flow
p4_port3_next_orifice_output_line.port_2.h_outflow = snapshot.p4_port3_next_orifice_output_line.h p4_port3_next_orifice_output_line.port_2.h_outflow = snapshot.p4_port3_next_orifice_output_line.h
chamber_spec = self.components.p4_port3_next_chamber_spec self._write_fixed_chamber_segment(
p4_port3_next_chamber = self.components.p4_port3_next_chamber spec=self.components.p4_port3_next_chamber_spec,
p4_port3_next_chamber_inlet_port = self._port( chamber=self.components.p4_port3_next_chamber,
p4_port3_next_chamber,
chamber_spec.volume_inlet_port,
)
p4_port3_next_chamber_outlet_port = self._port(
p4_port3_next_chamber,
chamber_spec.volume_outlet_port,
)
TestMqlPnl0001PairChamberSegmentClosure._write_line_side(
self,
line=self.components.p4_port3_next_chamber_inlet_line,
line_properties=snapshot.p4_port3_next_chamber_inlet_line,
node_properties=snapshot.p4_port3_next_orifice_line_port_1,
node_to_line_flow=snapshot.p4_port3_next_chamber_inlet_node_to_line_flow,
line_to_chamber_flow=snapshot.p4_port3_next_chamber_inlet_line_to_chamber_flow,
orifice=self.components.p4_port3_next_chamber_inlet_orifice,
orifice_boundary_port=chamber_spec.inlet_orifice_boundary_port,
orifice_volume_port=chamber_spec.inlet_orifice_volume_port,
chamber_port=p4_port3_next_chamber_inlet_port,
chamber_properties=snapshot.p4_port3_next_chamber,
)
TestMqlPnl0001PairChamberSegmentClosure._write_line_side(
self,
line=self.components.p4_port3_next_chamber_outlet_line,
line_properties=snapshot.p4_port3_next_chamber_outlet_line,
node_properties=snapshot.p4_port3_remote_resistance_node_line_port_1,
node_to_line_flow=snapshot.p4_port3_next_chamber_outlet_node_to_line_flow,
line_to_chamber_flow=snapshot.p4_port3_next_chamber_outlet_line_to_chamber_flow,
orifice=self.components.p4_port3_next_chamber_outlet_orifice,
orifice_boundary_port=chamber_spec.outlet_orifice_boundary_port,
orifice_volume_port=chamber_spec.outlet_orifice_volume_port,
chamber_port=p4_port3_next_chamber_outlet_port,
chamber_properties=snapshot.p4_port3_next_chamber, chamber_properties=snapshot.p4_port3_next_chamber,
inlet_line=self.components.p4_port3_next_chamber_inlet_line,
inlet_line_properties=snapshot.p4_port3_next_chamber_inlet_line,
inlet_node_properties=snapshot.p4_port3_next_orifice_line_port_1,
inlet_node_to_line_flow=(
snapshot.p4_port3_next_chamber_inlet_node_to_line_flow
),
inlet_line_to_chamber_flow=(
snapshot.p4_port3_next_chamber_inlet_line_to_chamber_flow
),
inlet_orifice=self.components.p4_port3_next_chamber_inlet_orifice,
outlet_line=self.components.p4_port3_next_chamber_outlet_line,
outlet_line_properties=snapshot.p4_port3_next_chamber_outlet_line,
outlet_node_properties=snapshot.p4_port3_remote_resistance_node_line_port_1,
outlet_node_to_line_flow=(
snapshot.p4_port3_next_chamber_outlet_node_to_line_flow
),
outlet_line_to_chamber_flow=(
snapshot.p4_port3_next_chamber_outlet_line_to_chamber_flow
),
outlet_orifice=self.components.p4_port3_next_chamber_outlet_orifice,
) )
p4_port3_next_orifice_resistance = self.components.p4_port3_next_orifice_resistance p4_port3_next_orifice_resistance = self.components.p4_port3_next_orifice_resistance
@@ -2244,49 +2299,38 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
p4_port3_next_resistance_output_line.port_2.m_flow = -snapshot.p4_port3_next_resistance_output_to_p4_flow p4_port3_next_resistance_output_line.port_2.m_flow = -snapshot.p4_port3_next_resistance_output_to_p4_flow
p4_port3_next_resistance_output_line.port_2.h_outflow = snapshot.p4_port3_next_resistance_output_line.h p4_port3_next_resistance_output_line.port_2.h_outflow = snapshot.p4_port3_next_resistance_output_line.h
resistance_chamber_spec = self.components.p4_port3_next_resistance_chamber_spec self._write_fixed_chamber_segment(
p4_port3_next_resistance_chamber = self.components.p4_port3_next_resistance_chamber spec=self.components.p4_port3_next_resistance_chamber_spec,
p4_port3_next_resistance_chamber_inlet_port = self._port( chamber=self.components.p4_port3_next_resistance_chamber,
p4_port3_next_resistance_chamber, chamber_properties=snapshot.p4_port3_next_resistance_chamber,
resistance_chamber_spec.volume_inlet_port, inlet_line=self.components.p4_port3_next_resistance_chamber_inlet_line,
) inlet_line_properties=(
p4_port3_next_resistance_chamber_outlet_port = self._port( snapshot.p4_port3_next_resistance_chamber_inlet_line
p4_port3_next_resistance_chamber, ),
resistance_chamber_spec.volume_outlet_port, inlet_node_properties=snapshot.p4_port1_next_orifice_line_port_1,
) inlet_node_to_line_flow=(
TestMqlPnl0001PairChamberSegmentClosure._write_line_side(
self,
line=self.components.p4_port3_next_resistance_chamber_inlet_line,
line_properties=snapshot.p4_port3_next_resistance_chamber_inlet_line,
node_properties=snapshot.p4_port1_next_orifice_line_port_1,
node_to_line_flow=(
snapshot.p4_port3_next_resistance_chamber_inlet_node_to_line_flow snapshot.p4_port3_next_resistance_chamber_inlet_node_to_line_flow
), ),
line_to_chamber_flow=( inlet_line_to_chamber_flow=(
snapshot.p4_port3_next_resistance_chamber_inlet_line_to_chamber_flow snapshot.p4_port3_next_resistance_chamber_inlet_line_to_chamber_flow
), ),
orifice=self.components.p4_port3_next_resistance_chamber_inlet_orifice, inlet_orifice=(
orifice_boundary_port=resistance_chamber_spec.inlet_orifice_boundary_port, self.components.p4_port3_next_resistance_chamber_inlet_orifice
orifice_volume_port=resistance_chamber_spec.inlet_orifice_volume_port, ),
chamber_port=p4_port3_next_resistance_chamber_inlet_port, outlet_line=self.components.p4_port3_next_resistance_chamber_outlet_line,
chamber_properties=snapshot.p4_port3_next_resistance_chamber, outlet_line_properties=(
) snapshot.p4_port3_next_resistance_chamber_outlet_line
TestMqlPnl0001PairChamberSegmentClosure._write_line_side( ),
self, outlet_node_properties=snapshot.p4_port3_next_resistance_node_line_port_1,
line=self.components.p4_port3_next_resistance_chamber_outlet_line, outlet_node_to_line_flow=(
line_properties=snapshot.p4_port3_next_resistance_chamber_outlet_line,
node_properties=snapshot.p4_port3_next_resistance_node_line_port_1,
node_to_line_flow=(
snapshot.p4_port3_next_resistance_chamber_outlet_node_to_line_flow snapshot.p4_port3_next_resistance_chamber_outlet_node_to_line_flow
), ),
line_to_chamber_flow=( outlet_line_to_chamber_flow=(
snapshot.p4_port3_next_resistance_chamber_outlet_line_to_chamber_flow snapshot.p4_port3_next_resistance_chamber_outlet_line_to_chamber_flow
), ),
orifice=self.components.p4_port3_next_resistance_chamber_outlet_orifice, outlet_orifice=(
orifice_boundary_port=resistance_chamber_spec.outlet_orifice_boundary_port, self.components.p4_port3_next_resistance_chamber_outlet_orifice
orifice_volume_port=resistance_chamber_spec.outlet_orifice_volume_port, ),
chamber_port=p4_port3_next_resistance_chamber_outlet_port,
chamber_properties=snapshot.p4_port3_next_resistance_chamber,
) )
p4_port3_remote_orifice_line = self.components.p4_port3_remote_orifice_line p4_port3_remote_orifice_line = self.components.p4_port3_remote_orifice_line
@@ -2621,40 +2665,34 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
connected_h_2=snapshot.p4_port3_next_primary_line.h, connected_h_2=snapshot.p4_port3_next_primary_line.h,
) )
) )
p4_port3_next_chamber_inlet_derivative = ( (
self.components.p4_port3_next_chamber_inlet_line.derivatives_from_connections( p4_port3_next_chamber_inlet_derivative,
port_1_m_flow=snapshot.p4_port3_next_chamber_inlet_node_to_line_flow, p4_port3_next_fixed_chamber_derivative,
connected_h_1=snapshot.p4_port3_next_orifice_line_port_1.h, p4_port3_next_chamber_outlet_derivative,
port_2_m_flow=-snapshot.p4_port3_next_chamber_inlet_line_to_chamber_flow, ) = self._fixed_chamber_segment_derivatives(
connected_h_2=snapshot.p4_port3_next_chamber.h, spec=self.components.p4_port3_next_chamber_spec,
) chamber=self.components.p4_port3_next_chamber,
) chamber_properties=snapshot.p4_port3_next_chamber,
p4_port3_next_chamber_spec = self.components.p4_port3_next_chamber_spec inlet_line=self.components.p4_port3_next_chamber_inlet_line,
p4_port3_next_chamber = self.components.p4_port3_next_chamber inlet_line_properties=snapshot.p4_port3_next_chamber_inlet_line,
p4_port3_next_fixed_chamber_derivative = ( inlet_connected_properties=snapshot.p4_port3_next_orifice_line_port_1,
p4_port3_next_chamber.derivatives_from_two_connections( inlet_node_to_line_flow=(
port_a_m_flow=self._port(p4_port3_next_chamber, "port_1").m_flow, snapshot.p4_port3_next_chamber_inlet_node_to_line_flow
connected_h_a=( ),
snapshot.p4_port3_next_chamber_inlet_line.h inlet_line_to_chamber_flow=(
if p4_port3_next_chamber_spec.volume_inlet_port == "port_1" snapshot.p4_port3_next_chamber_inlet_line_to_chamber_flow
else snapshot.p4_port3_next_chamber_outlet_line.h ),
), outlet_line=self.components.p4_port3_next_chamber_outlet_line,
port_b_m_flow=self._port(p4_port3_next_chamber, "port_2").m_flow, outlet_line_properties=snapshot.p4_port3_next_chamber_outlet_line,
connected_h_b=( outlet_connected_properties=(
snapshot.p4_port3_next_chamber_inlet_line.h snapshot.p4_port3_remote_resistance_node_line_port_1
if p4_port3_next_chamber_spec.volume_inlet_port == "port_2" ),
else snapshot.p4_port3_next_chamber_outlet_line.h outlet_node_to_line_flow=(
), snapshot.p4_port3_next_chamber_outlet_node_to_line_flow
internal_h=snapshot.p4_port3_next_chamber.h, ),
) outlet_line_to_chamber_flow=(
) snapshot.p4_port3_next_chamber_outlet_line_to_chamber_flow
p4_port3_next_chamber_outlet_derivative = ( ),
self.components.p4_port3_next_chamber_outlet_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_port3_next_chamber_outlet_node_to_line_flow,
connected_h_1=snapshot.p4_port3_remote_resistance_node_line_port_1.h,
port_2_m_flow=-snapshot.p4_port3_next_chamber_outlet_line_to_chamber_flow,
connected_h_2=snapshot.p4_port3_next_chamber.h,
)
) )
( (
p4_port3_next_resistance_derivative_1, p4_port3_next_resistance_derivative_1,
@@ -2673,48 +2711,36 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
connected_h_2=snapshot.p4_bridge_primary_line.h, connected_h_2=snapshot.p4_bridge_primary_line.h,
) )
) )
p4_port3_next_resistance_chamber_inlet_derivative = ( (
self.components.p4_port3_next_resistance_chamber_inlet_line.derivatives_from_connections( p4_port3_next_resistance_chamber_inlet_derivative,
port_1_m_flow=snapshot.p4_port3_next_resistance_chamber_inlet_node_to_line_flow, p4_port3_next_resistance_fixed_chamber_derivative,
connected_h_1=snapshot.p4_port1_next_orifice_line_port_1.h, p4_port3_next_resistance_chamber_outlet_derivative,
port_2_m_flow=( ) = self._fixed_chamber_segment_derivatives(
-snapshot.p4_port3_next_resistance_chamber_inlet_line_to_chamber_flow spec=self.components.p4_port3_next_resistance_chamber_spec,
), chamber=self.components.p4_port3_next_resistance_chamber,
connected_h_2=snapshot.p4_port3_next_resistance_chamber.h, chamber_properties=snapshot.p4_port3_next_resistance_chamber,
) inlet_line=self.components.p4_port3_next_resistance_chamber_inlet_line,
) inlet_line_properties=(
p4_port3_next_resistance_chamber_spec = ( snapshot.p4_port3_next_resistance_chamber_inlet_line
self.components.p4_port3_next_resistance_chamber_spec ),
) inlet_connected_properties=snapshot.p4_port1_next_orifice_line_port_1,
p4_port3_next_resistance_chamber = ( inlet_node_to_line_flow=(
self.components.p4_port3_next_resistance_chamber snapshot.p4_port3_next_resistance_chamber_inlet_node_to_line_flow
) ),
p4_port3_next_resistance_fixed_chamber_derivative = ( inlet_line_to_chamber_flow=(
p4_port3_next_resistance_chamber.derivatives_from_two_connections( snapshot.p4_port3_next_resistance_chamber_inlet_line_to_chamber_flow
port_a_m_flow=self._port(p4_port3_next_resistance_chamber, "port_1").m_flow, ),
connected_h_a=( outlet_line=self.components.p4_port3_next_resistance_chamber_outlet_line,
snapshot.p4_port3_next_resistance_chamber_inlet_line.h outlet_line_properties=(
if p4_port3_next_resistance_chamber_spec.volume_inlet_port == "port_1" snapshot.p4_port3_next_resistance_chamber_outlet_line
else snapshot.p4_port3_next_resistance_chamber_outlet_line.h ),
), outlet_connected_properties=snapshot.p4_port3_next_resistance_node_line_port_1,
port_b_m_flow=self._port(p4_port3_next_resistance_chamber, "port_2").m_flow, outlet_node_to_line_flow=(
connected_h_b=( snapshot.p4_port3_next_resistance_chamber_outlet_node_to_line_flow
snapshot.p4_port3_next_resistance_chamber_inlet_line.h ),
if p4_port3_next_resistance_chamber_spec.volume_inlet_port == "port_2" outlet_line_to_chamber_flow=(
else snapshot.p4_port3_next_resistance_chamber_outlet_line.h snapshot.p4_port3_next_resistance_chamber_outlet_line_to_chamber_flow
), ),
internal_h=snapshot.p4_port3_next_resistance_chamber.h,
)
)
p4_port3_next_resistance_chamber_outlet_derivative = (
self.components.p4_port3_next_resistance_chamber_outlet_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_port3_next_resistance_chamber_outlet_node_to_line_flow,
connected_h_1=snapshot.p4_port3_next_resistance_node_line_port_1.h,
port_2_m_flow=(
-snapshot.p4_port3_next_resistance_chamber_outlet_line_to_chamber_flow
),
connected_h_2=snapshot.p4_port3_next_resistance_chamber.h,
)
) )
( (
p4_port1_next_orifice_derivative_1, p4_port1_next_orifice_derivative_1,
@@ -2742,60 +2768,42 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
port_2_m_flow=-snapshot.p4_port1_next_orifice_resistance_to_p4_flow, port_2_m_flow=-snapshot.p4_port1_next_orifice_resistance_to_p4_flow,
connected_h_2=snapshot.p4_port1_far_primary_line.h, connected_h_2=snapshot.p4_port1_far_primary_line.h,
) )
p4_port1_next_orifice_resistance_chamber_inlet_derivative = ( (
self.components.p4_port1_next_orifice_resistance_chamber_inlet_line.derivatives_from_connections( p4_port1_next_orifice_resistance_chamber_inlet_derivative,
port_1_m_flow=( p4_port1_next_orifice_resistance_fixed_chamber_derivative,
snapshot.p4_port1_next_orifice_resistance_chamber_inlet_node_to_line_flow p4_port1_next_orifice_resistance_chamber_outlet_derivative,
), ) = self._fixed_chamber_segment_derivatives(
connected_h_1=snapshot.p4_port1_remote_orifice_line_port_1.h, spec=self.components.p4_port1_next_orifice_resistance_chamber_spec,
port_2_m_flow=( chamber=self.components.p4_port1_next_orifice_resistance_chamber,
-snapshot.p4_port1_next_orifice_resistance_chamber_inlet_line_to_chamber_flow chamber_properties=snapshot.p4_port1_next_orifice_resistance_chamber,
), inlet_line=(
connected_h_2=snapshot.p4_port1_next_orifice_resistance_chamber.h, self.components.p4_port1_next_orifice_resistance_chamber_inlet_line
) ),
) inlet_line_properties=(
p4_port1_next_orifice_resistance_chamber_spec = ( snapshot.p4_port1_next_orifice_resistance_chamber_inlet_line
self.components.p4_port1_next_orifice_resistance_chamber_spec ),
) inlet_connected_properties=snapshot.p4_port1_remote_orifice_line_port_1,
p4_port1_next_orifice_resistance_chamber = ( inlet_node_to_line_flow=(
self.components.p4_port1_next_orifice_resistance_chamber snapshot.p4_port1_next_orifice_resistance_chamber_inlet_node_to_line_flow
) ),
p4_port1_next_orifice_resistance_fixed_chamber_derivative = ( inlet_line_to_chamber_flow=(
p4_port1_next_orifice_resistance_chamber.derivatives_from_two_connections( snapshot.p4_port1_next_orifice_resistance_chamber_inlet_line_to_chamber_flow
port_a_m_flow=self._port( ),
p4_port1_next_orifice_resistance_chamber, outlet_line=(
"port_1", self.components.p4_port1_next_orifice_resistance_chamber_outlet_line
).m_flow, ),
connected_h_a=( outlet_line_properties=(
snapshot.p4_port1_next_orifice_resistance_chamber_inlet_line.h snapshot.p4_port1_next_orifice_resistance_chamber_outlet_line
if p4_port1_next_orifice_resistance_chamber_spec.volume_inlet_port ),
== "port_1" outlet_connected_properties=(
else snapshot.p4_port1_next_orifice_resistance_chamber_outlet_line.h snapshot.p4_port1_next_orifice_resistance_line_port_1
), ),
port_b_m_flow=self._port( outlet_node_to_line_flow=(
p4_port1_next_orifice_resistance_chamber, snapshot.p4_port1_next_orifice_resistance_chamber_outlet_node_to_line_flow
"port_2", ),
).m_flow, outlet_line_to_chamber_flow=(
connected_h_b=( snapshot.p4_port1_next_orifice_resistance_chamber_outlet_line_to_chamber_flow
snapshot.p4_port1_next_orifice_resistance_chamber_inlet_line.h ),
if p4_port1_next_orifice_resistance_chamber_spec.volume_inlet_port
== "port_2"
else snapshot.p4_port1_next_orifice_resistance_chamber_outlet_line.h
),
internal_h=snapshot.p4_port1_next_orifice_resistance_chamber.h,
)
)
p4_port1_next_orifice_resistance_chamber_outlet_derivative = (
self.components.p4_port1_next_orifice_resistance_chamber_outlet_line.derivatives_from_connections(
port_1_m_flow=(
snapshot.p4_port1_next_orifice_resistance_chamber_outlet_node_to_line_flow
),
connected_h_1=snapshot.p4_port1_next_orifice_resistance_line_port_1.h,
port_2_m_flow=(
-snapshot.p4_port1_next_orifice_resistance_chamber_outlet_line_to_chamber_flow
),
connected_h_2=snapshot.p4_port1_next_orifice_resistance_chamber.h,
)
) )
return [ return [
*inlet_derivative.as_vector(), *inlet_derivative.as_vector(),