添加test_mql pneumatic_96局部参考RHS候选

This commit is contained in:
huojiarong committed 2026-07-29 08:38:37 +00:00
1 parent 71da73ef70
commit a8a68f6dd4
5 files changed
+162 -2

No files matched your search

+8
View File
@@ -4802,6 +4802,7 @@ class TestMqlSystem:
resistance_boundary_pressure_pa: float,
inlet_node_temperature_k: float = 293.15,
resistance_boundary_temperature_k: float = 293.15,
use_pneumatic_96_reference_rhs: bool = False,
) -> TestMqlFullStateClosure:
return TestMqlFullStateClosure(
pneumatic_closure=self.pn3_p4_node_chamber_segment_closure_from_spec(
@@ -4810,6 +4811,7 @@ class TestMqlSystem:
resistance_boundary_pressure_pa=resistance_boundary_pressure_pa,
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,
),
mechanical_closure=self.mechanical_mass_closure(),
pneumatic_assembly=self.pneumatic_assembly,
@@ -4823,6 +4825,7 @@ class TestMqlSystem:
resistance_boundary_pressure_pa: float,
inlet_node_temperature_k: float = 293.15,
resistance_boundary_temperature_k: float = 293.15,
use_pneumatic_96_reference_rhs: bool = False,
config: SolveIVPConfig | None = None,
t_eval: list[float] | None = None,
):
@@ -4832,6 +4835,7 @@ class TestMqlSystem:
resistance_boundary_pressure_pa=resistance_boundary_pressure_pa,
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,
)
return integrate_ode(
rhs=lambda t, state: closure.rhs_at(t, state),
@@ -4851,6 +4855,7 @@ class TestMqlSystem:
config: SolveIVPConfig | None = None,
t_eval: list[float] | None = None,
data_paths: tuple[str, ...] | list[str] | None = None,
use_pneumatic_96_reference_rhs: bool = False,
) -> TestMqlSimulationResult:
closure = self.full_state_closure_from_spec(
spec,
@@ -4858,6 +4863,7 @@ class TestMqlSystem:
resistance_boundary_pressure_pa=resistance_boundary_pressure_pa,
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,
)
solution = integrate_ode(
rhs=lambda t, state: closure.rhs_at(t, state),
@@ -5329,6 +5335,7 @@ class TestMqlSystem:
resistance_boundary_pressure_pa: float,
inlet_node_temperature_k: float = 293.15,
resistance_boundary_temperature_k: float = 293.15,
use_inlet_line_reference_rhs: bool = False,
):
"""Close a PN3 chamber segment through the adjacent real P4 node.
@@ -6074,6 +6081,7 @@ class TestMqlSystem:
pressure_pa=resistance_boundary_pressure_pa,
temperature_k=resistance_boundary_temperature_k,
),
use_inlet_line_reference_rhs=use_inlet_line_reference_rhs,
)
def simulate_pn3_p4_node_chamber_segment_from_spec(
+64
View File
@@ -490,10 +490,12 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
components: TestMqlPn3P4NodeChamberSegmentComponents,
inlet_node: TestMqlPneumaticBoundaryCondition,
resistance_boundary: TestMqlPneumaticBoundaryCondition,
use_inlet_line_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
def initial_state_vector(self) -> list[float]:
return [
@@ -2086,6 +2088,59 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
chamber.port_a.m_flow = -chamber_to_line_flow
chamber.port_a.h_outflow = chamber_properties.h
@staticmethod
def _pnl0001_reference_enthalpy_derivative(
*,
line: AmesimPnl0001Pipe,
line_properties: ThermodynamicProperties,
port_1_properties: ThermodynamicProperties,
port_1_flow: float,
port_2_properties: ThermodynamicProperties,
port_2_flow: float,
reference_temperature_k: float = 298.15,
) -> VolumeState:
def reference_enthalpy_flow(
*,
port_flow: float,
connected: ThermodynamicProperties,
) -> float:
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(
pressure,
temperature,
reference_temperature=reference_temperature_k,
)
mass_derivative = port_1_flow + port_2_flow
heat_flow = (
line.heat_transfer_coefficient
* line.heat_transfer_area
* (line.external_temperature - line_properties.T)
)
enthalpy_flow = reference_enthalpy_flow(
port_flow=port_1_flow,
connected=port_1_properties,
) + reference_enthalpy_flow(
port_flow=port_2_flow,
connected=port_2_properties,
)
reference_offset_flow = (
line.gas.cp * reference_temperature_k - line.gas.cv * line_properties.T
) * mass_derivative
temperature_derivative = (
enthalpy_flow + reference_offset_flow + heat_flow
) / (line.state.m * line.gas.cv)
return VolumeState(
m=mass_derivative,
U=line.gas.cv
* (line.state.m * temperature_derivative + line_properties.T * mass_derivative),
)
@staticmethod
def _primary_chamber_line_derivatives(
*,
@@ -2706,6 +2761,15 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
outlet_node_to_line_flow=snapshot.outlet_node_to_line_flow,
outlet_line_to_chamber_flow=snapshot.outlet_line_to_chamber_flow,
)
if self.use_inlet_line_reference_rhs:
inlet_derivative = self._pnl0001_reference_enthalpy_derivative(
line=self.components.inlet_line,
line_properties=snapshot.inlet_line,
port_1_properties=snapshot.p4_port3_remote_orifice_line_port_1,
port_1_flow=snapshot.inlet_node_to_line_flow,
port_2_properties=snapshot.chamber,
port_2_flow=-snapshot.inlet_line_to_chamber_flow,
)
(
node_line_derivative_1,
node_line_derivative_2,