补充test_mql pneumatic_69局部参考RHS候选

This commit is contained in:
huojiarong committed 2026-07-29 09:23:05 +00:00
1 parent e17a952bee
commit 420bafeb4e
4 files changed
+186 -7

No files matched your search

+109 -6
View File
@@ -491,11 +491,15 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
inlet_node: TestMqlPneumaticBoundaryCondition,
resistance_boundary: TestMqlPneumaticBoundaryCondition,
use_inlet_line_reference_rhs: bool = False,
use_p4_port3_remote_primary_reference_rhs: bool = False,
) -> None:
self.components = components
self.inlet_node = inlet_node
self.resistance_boundary = resistance_boundary
self.use_inlet_line_reference_rhs = use_inlet_line_reference_rhs
self.use_p4_port3_remote_primary_reference_rhs = (
use_p4_port3_remote_primary_reference_rhs
)
def initial_state_vector(self) -> list[float]:
return [
@@ -1937,6 +1941,69 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
return fallback_h
return balance.port_2_enthalpy_flow_w / mass_flow_kg_s
@staticmethod
def _reference_enthalpy_flow_for_node_port(
*,
gas,
node_properties: ThermodynamicProperties,
connected_properties: ThermodynamicProperties,
flow_kg_s: float,
port_mass_flow_kg_s: float,
reference_temperature_k: float = 298.15,
) -> float:
stream_properties = (
node_properties if flow_kg_s >= 0.0 else connected_properties
)
return port_mass_flow_kg_s * gas.pressure_reference_enthalpy(
stream_properties.p,
stream_properties.T,
reference_temperature=reference_temperature_k,
)
def _p4_port3_remote_port_2_reference_h(
self,
*,
snapshot: TestMqlPn3P4NodeChamberSegmentSnapshot,
reference_temperature_k: float = 298.15,
) -> float:
gas = self.components.p4_port3_remote_primary_line.gas
port_2_mass_flow = snapshot.p4_port3_remote_balance.port_2_mass_flow_g_s * 1.0e-3
if abs(port_2_mass_flow) <= 1.0e-12:
return gas.pressure_reference_enthalpy(
snapshot.p4_port3_remote_primary_line.p,
snapshot.p4_port3_remote_primary_line.T,
reference_temperature=reference_temperature_k,
)
port_2_enthalpy_flow = sum(
(
self._reference_enthalpy_flow_for_node_port(
gas=gas,
node_properties=snapshot.p4_port3_remote_primary_line,
connected_properties=snapshot.p4_port3_line,
flow_kg_s=snapshot.p4_port3_remote_node_to_line_flow,
port_mass_flow_kg_s=-snapshot.p4_port3_remote_node_to_line_flow,
reference_temperature_k=reference_temperature_k,
),
self._reference_enthalpy_flow_for_node_port(
gas=gas,
node_properties=snapshot.p4_port3_remote_primary_line,
connected_properties=snapshot.p4_port3_remote_port3_line,
flow_kg_s=snapshot.p4_port3_remote_to_port3_line_flow,
port_mass_flow_kg_s=-snapshot.p4_port3_remote_to_port3_line_flow,
reference_temperature_k=reference_temperature_k,
),
self._reference_enthalpy_flow_for_node_port(
gas=gas,
node_properties=snapshot.p4_port3_remote_orifice_line_port_2,
connected_properties=snapshot.p4_port3_remote_primary_line,
flow_kg_s=snapshot.p4_port3_remote_orifice_to_node_flow,
port_mass_flow_kg_s=snapshot.p4_port3_remote_orifice_to_node_flow,
reference_temperature_k=reference_temperature_k,
),
)
)
return port_2_enthalpy_flow / port_2_mass_flow
def _p4_node_balance(
self,
*,
@@ -2097,25 +2164,42 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
port_1_flow: float,
port_2_properties: ThermodynamicProperties,
port_2_flow: float,
port_1_connected_reference_h: float | None = None,
port_2_connected_reference_h: float | None = None,
reference_temperature_k: float = 298.15,
) -> VolumeState:
def reference_enthalpy_flow(
def specific_reference_h(
*,
port_flow: float,
connected: ThermodynamicProperties,
connected_reference_h: float | None,
) -> float:
if port_flow > 0.0 and connected_reference_h is not None:
return connected_reference_h
if port_flow > 0.0:
pressure = connected.p
temperature = connected.T
else:
pressure = line_properties.p
temperature = line_properties.T
return port_flow * line.gas.pressure_reference_enthalpy(
return line.gas.pressure_reference_enthalpy(
pressure,
temperature,
reference_temperature=reference_temperature_k,
)
def reference_enthalpy_flow(
*,
port_flow: float,
connected: ThermodynamicProperties,
connected_reference_h: float | None,
) -> float:
return port_flow * specific_reference_h(
port_flow=port_flow,
connected=connected,
connected_reference_h=connected_reference_h,
)
mass_derivative = port_1_flow + port_2_flow
heat_flow = (
line.heat_transfer_coefficient
@@ -2125,9 +2209,11 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
enthalpy_flow = reference_enthalpy_flow(
port_flow=port_1_flow,
connected=port_1_properties,
connected_reference_h=port_1_connected_reference_h,
) + reference_enthalpy_flow(
port_flow=port_2_flow,
connected=port_2_properties,
connected_reference_h=port_2_connected_reference_h,
)
reference_offset_flow = (
line.gas.cp * reference_temperature_k - line.gas.cv * line_properties.T
@@ -2880,6 +2966,10 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
port_2_properties=snapshot.p4_primary_line,
port_2_flow=snapshot.p4_to_port3_line_flow,
)
p4_port3_remote_node_connected_h = self._p4_node_port_2_connected_h(
balance=snapshot.p4_port3_remote_balance,
fallback_h=snapshot.p4_port3_remote_primary_line.h,
)
(
p4_port3_remote_primary_derivative,
p4_port3_remote_chamber_derivative,
@@ -2890,11 +2980,24 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
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,
node_connected_h=self._p4_node_port_2_connected_h(
balance=snapshot.p4_port3_remote_balance,
fallback_h=snapshot.p4_port3_remote_primary_line.h,
),
node_connected_h=p4_port3_remote_node_connected_h,
)
if self.use_p4_port3_remote_primary_reference_rhs:
p4_port3_remote_primary_derivative = (
self._pnl0001_reference_enthalpy_derivative(
line=self.components.p4_port3_remote_primary_line,
line_properties=snapshot.p4_port3_remote_primary_line,
port_1_properties=snapshot.p4_port3_remote_primary_chamber,
port_1_flow=snapshot.p4_port3_remote_chamber_to_line_flow,
port_2_properties=snapshot.p4_port3_remote_primary_line,
port_2_flow=snapshot.p4_port3_remote_node_to_primary_line_flow,
port_2_connected_reference_h=(
self._p4_port3_remote_port_2_reference_h(
snapshot=snapshot
)
),
)
)
p4_port3_remote_port3_derivative = self._connection_line_derivative(
line=self.components.p4_port3_remote_port3_line,
port_1_properties=snapshot.p4_port3_far_primary_line,