接入test_mql P4主线气室

This commit is contained in:
huojiarong committed 2026-07-17 09:58:59 +00:00
1 parent fafce0af87
commit 8af0a27e4c
3 files changed
+57 -38

No files matched your search

+34 -20
View File
@@ -198,6 +198,7 @@ class TestMqlPn3P4NodeChamberSegmentComponents:
node: TestMqlPneumaticNode3
p4_node: TestMqlPneumaticNode4
p4_primary_line: AmesimPnl0001Pipe
p4_primary_chamber: AmesimPneumaticVolume
p4_port1_line: AmesimPnl0002Pipe
p4_port3_line: AmesimPnl0002Pipe
volume: AmesimPneumaticVolume
@@ -215,11 +216,11 @@ class TestMqlPn3P4NodeChamberSegmentSnapshot:
node_line_port_2: ThermodynamicProperties
p4_primary_line: ThermodynamicProperties
p4_boundary: ThermodynamicProperties
p4_primary_chamber: ThermodynamicProperties
p4_port1_line: ThermodynamicProperties
p4_port3_line: ThermodynamicProperties
inlet_node: ThermodynamicProperties
resistance_boundary: ThermodynamicProperties
p4_primary_boundary: ThermodynamicProperties
p4_port1_boundary: ThermodynamicProperties
p4_port3_boundary: ThermodynamicProperties
node_balance: TestMqlPneumaticNode3Balance
@@ -232,7 +233,7 @@ class TestMqlPn3P4NodeChamberSegmentSnapshot:
node_to_pnl0003_flow: float
pnl0003_center_flow: float
pnl0003_to_p4_flow: float
p4_boundary_to_primary_line_flow: float
p4_primary_chamber_to_line_flow: float
p4_node_to_primary_line_flow: float
p4_to_port1_line_flow: float
p4_port1_boundary_to_line_flow: float
@@ -254,14 +255,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
components: TestMqlPn3P4NodeChamberSegmentComponents,
inlet_node: TestMqlPneumaticBoundaryCondition,
resistance_boundary: TestMqlPneumaticBoundaryCondition,
p4_primary_boundary: TestMqlPneumaticBoundaryCondition,
p4_port1_boundary: TestMqlPneumaticBoundaryCondition,
p4_port3_boundary: TestMqlPneumaticBoundaryCondition,
) -> None:
self.components = components
self.inlet_node = inlet_node
self.resistance_boundary = resistance_boundary
self.p4_primary_boundary = p4_primary_boundary
self.p4_port1_boundary = p4_port1_boundary
self.p4_port3_boundary = p4_port3_boundary
@@ -272,20 +271,22 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
*self.components.outlet_line.get_state_vector(),
*self.components.node_line.get_state_vector(),
*self.components.p4_primary_line.get_state_vector(),
*self.components.p4_primary_chamber.get_state_vector(),
*self.components.p4_port1_line.get_state_vector(),
*self.components.p4_port3_line.get_state_vector(),
]
def apply_state_vector(self, values: list[float]) -> None:
if len(values) != 16:
raise ValueError("PN3/P4 node chamber segment state vector requires sixteen values")
if len(values) != 18:
raise ValueError("PN3/P4 node chamber segment state vector requires eighteen 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])
self.components.node_line.set_state_vector(values[6:10])
self.components.p4_primary_line.set_state_vector(values[10:12])
self.components.p4_port1_line.set_state_vector(values[12:14])
self.components.p4_port3_line.set_state_vector(values[14:])
self.components.p4_primary_chamber.set_state_vector(values[12:14])
self.components.p4_port1_line.set_state_vector(values[14:16])
self.components.p4_port3_line.set_state_vector(values[16:])
def snapshot(
self,
@@ -299,15 +300,13 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_line_port_1 = self.components.node_line.properties_1()
node_line_port_2 = self.components.node_line.properties_2()
p4_primary_line = self.components.p4_primary_line.properties()
p4_primary_chamber = self.components.p4_primary_chamber.properties()
p4_port1_line = self.components.p4_port1_line.properties()
p4_port3_line = self.components.p4_port3_line.properties()
inlet_node = self.inlet_node.properties(self.components.inlet_line.gas)
resistance_boundary = self.resistance_boundary.properties(
self.components.node_resistance.gas
)
p4_primary_boundary = self.p4_primary_boundary.properties(
self.components.p4_primary_line.gas
)
p4_port1_boundary = self.p4_port1_boundary.properties(
self.components.p4_port1_line.gas
)
@@ -363,10 +362,10 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
orifice=self.components.node_orifice,
)
p4_boundary_to_primary_line_flow = (
p4_primary_chamber_to_line_flow = (
self.components.p4_primary_line.resistance_mass_flow(
port_1_pressure_pa=p4_primary_boundary.p,
port_1_temperature_k=p4_primary_boundary.T,
port_1_pressure_pa=p4_primary_chamber.p,
port_1_temperature_k=p4_primary_chamber.T,
)
)
p4_to_port1_line_flow = self.components.p4_port1_line.port_mass_flow(
@@ -417,11 +416,11 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_line_port_2=node_line_port_2,
p4_primary_line=p4_primary_line,
p4_boundary=p4_primary_line,
p4_primary_chamber=p4_primary_chamber,
p4_port1_line=p4_port1_line,
p4_port3_line=p4_port3_line,
inlet_node=inlet_node,
resistance_boundary=resistance_boundary,
p4_primary_boundary=p4_primary_boundary,
p4_port1_boundary=p4_port1_boundary,
p4_port3_boundary=p4_port3_boundary,
node_balance=node_balance,
@@ -434,7 +433,7 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
node_to_pnl0003_flow=node_to_pnl0003_flow,
pnl0003_center_flow=pnl0003_center_flow,
pnl0003_to_p4_flow=pnl0003_to_p4_flow,
p4_boundary_to_primary_line_flow=p4_boundary_to_primary_line_flow,
p4_primary_chamber_to_line_flow=p4_primary_chamber_to_line_flow,
p4_node_to_primary_line_flow=p4_node_to_primary_line_flow,
p4_to_port1_line_flow=p4_to_port1_line_flow,
p4_port1_boundary_to_line_flow=p4_port1_boundary_to_line_flow,
@@ -497,13 +496,18 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
TestMqlPn3NodeChamberSegmentClosure._write_port_states(self, snapshot)
p4_primary_line = self.components.p4_primary_line
p4_primary_line.port_1.p = snapshot.p4_primary_boundary.p
p4_primary_line.port_1.m_flow = snapshot.p4_boundary_to_primary_line_flow
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
p4_port1_line = self.components.p4_port1_line
p4_port1_line.port_1.p = snapshot.p4_primary_line.p
p4_port1_line.port_1.m_flow = snapshot.p4_to_port1_line_flow
@@ -525,12 +529,21 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
base_rhs = TestMqlPn3NodeChamberSegmentClosure.rhs(self, state_vector)[:10]
p4_primary_derivative = (
self.components.p4_primary_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_boundary_to_primary_line_flow,
connected_h_1=snapshot.p4_primary_boundary.h,
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_port1_derivative = self.components.p4_port1_line.derivatives_from_connections(
port_1_m_flow=snapshot.p4_to_port1_line_flow,
connected_h_1=snapshot.p4_primary_line.h,
@@ -546,6 +559,7 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
return [
*base_rhs,
*p4_primary_derivative.as_vector(),
*p4_primary_chamber_derivative.as_vector(),
*p4_port1_derivative.as_vector(),
*p4_port3_derivative.as_vector(),
]