补充test_mql pneumatic_69局部参考RHS候选
This commit is contained in:
1 parent
e17a952bee
commit
420bafeb4e
4 files changed
+186
-7
No files matched your search
@@ -4803,6 +4803,7 @@ class TestMqlSystem:
|
||||
inlet_node_temperature_k: float = 293.15,
|
||||
resistance_boundary_temperature_k: float = 293.15,
|
||||
use_pneumatic_96_reference_rhs: bool = False,
|
||||
use_pneumatic_69_reference_rhs: bool = False,
|
||||
) -> TestMqlFullStateClosure:
|
||||
return TestMqlFullStateClosure(
|
||||
pneumatic_closure=self.pn3_p4_node_chamber_segment_closure_from_spec(
|
||||
@@ -4812,6 +4813,9 @@ class TestMqlSystem:
|
||||
inlet_node_temperature_k=inlet_node_temperature_k,
|
||||
resistance_boundary_temperature_k=resistance_boundary_temperature_k,
|
||||
use_inlet_line_reference_rhs=use_pneumatic_96_reference_rhs,
|
||||
use_p4_port3_remote_primary_reference_rhs=(
|
||||
use_pneumatic_69_reference_rhs
|
||||
),
|
||||
),
|
||||
mechanical_closure=self.mechanical_mass_closure(),
|
||||
pneumatic_assembly=self.pneumatic_assembly,
|
||||
@@ -4826,6 +4830,7 @@ class TestMqlSystem:
|
||||
inlet_node_temperature_k: float = 293.15,
|
||||
resistance_boundary_temperature_k: float = 293.15,
|
||||
use_pneumatic_96_reference_rhs: bool = False,
|
||||
use_pneumatic_69_reference_rhs: bool = False,
|
||||
config: SolveIVPConfig | None = None,
|
||||
t_eval: list[float] | None = None,
|
||||
):
|
||||
@@ -4836,6 +4841,7 @@ class TestMqlSystem:
|
||||
inlet_node_temperature_k=inlet_node_temperature_k,
|
||||
resistance_boundary_temperature_k=resistance_boundary_temperature_k,
|
||||
use_pneumatic_96_reference_rhs=use_pneumatic_96_reference_rhs,
|
||||
use_pneumatic_69_reference_rhs=use_pneumatic_69_reference_rhs,
|
||||
)
|
||||
return integrate_ode(
|
||||
rhs=lambda t, state: closure.rhs_at(t, state),
|
||||
@@ -4856,6 +4862,7 @@ class TestMqlSystem:
|
||||
t_eval: list[float] | None = None,
|
||||
data_paths: tuple[str, ...] | list[str] | None = None,
|
||||
use_pneumatic_96_reference_rhs: bool = False,
|
||||
use_pneumatic_69_reference_rhs: bool = False,
|
||||
) -> TestMqlSimulationResult:
|
||||
closure = self.full_state_closure_from_spec(
|
||||
spec,
|
||||
@@ -4864,6 +4871,7 @@ class TestMqlSystem:
|
||||
inlet_node_temperature_k=inlet_node_temperature_k,
|
||||
resistance_boundary_temperature_k=resistance_boundary_temperature_k,
|
||||
use_pneumatic_96_reference_rhs=use_pneumatic_96_reference_rhs,
|
||||
use_pneumatic_69_reference_rhs=use_pneumatic_69_reference_rhs,
|
||||
)
|
||||
solution = integrate_ode(
|
||||
rhs=lambda t, state: closure.rhs_at(t, state),
|
||||
@@ -5336,6 +5344,7 @@ class TestMqlSystem:
|
||||
inlet_node_temperature_k: float = 293.15,
|
||||
resistance_boundary_temperature_k: float = 293.15,
|
||||
use_inlet_line_reference_rhs: bool = False,
|
||||
use_p4_port3_remote_primary_reference_rhs: bool = False,
|
||||
):
|
||||
"""Close a PN3 chamber segment through the adjacent real P4 node.
|
||||
|
||||
@@ -6082,6 +6091,9 @@ class TestMqlSystem:
|
||||
temperature_k=resistance_boundary_temperature_k,
|
||||
),
|
||||
use_inlet_line_reference_rhs=use_inlet_line_reference_rhs,
|
||||
use_p4_port3_remote_primary_reference_rhs=(
|
||||
use_p4_port3_remote_primary_reference_rhs
|
||||
),
|
||||
)
|
||||
|
||||
def simulate_pn3_p4_node_chamber_segment_from_spec(
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user