接入test_mql PNVO阶跃控制与流量诊断

This commit is contained in:
huojiarong committed 2026-07-21 07:28:28 +00:00
1 parent 65f6d6dd87
commit 7c68caed27
7 files changed
+298 -24

No files matched your search

+38 -5
View File
@@ -3908,7 +3908,9 @@ def _default_full_state_data_paths() -> tuple[str, ...]:
for index in range(10, 20)
for signal in ("x1", "v1", "acc1")
]
return tuple([*chamber_paths, *piston_paths, *mass_paths])
return tuple(
[*chamber_paths, *piston_paths, *mass_paths, "dm1@pneumatic_69"]
)
_PNCH012_ALIAS_BY_SNAPSHOT_FIELD = {
@@ -3967,10 +3969,22 @@ _PRIMARY_CHAMBER_DIAGNOSTIC_FIELDS = {
}
_PNL0001_MASS_FLOW_DIAGNOSTIC_FIELDS = {
"pneumatic_69": "p4_port3_remote_chamber_to_line_flow",
}
class TestMqlFullStateClosure:
def __init__(self, *, pneumatic_closure: object, mechanical_closure: object) -> None:
def __init__(
self,
*,
pneumatic_closure: object,
mechanical_closure: object,
pneumatic_assembly: object,
) -> None:
self.pneumatic_closure = pneumatic_closure
self.mechanical_closure = mechanical_closure
self.pneumatic_assembly = pneumatic_assembly
self.pneumatic_state_count = len(pneumatic_closure.initial_state_vector())
self.mechanical_state_count = len(mechanical_closure.initial_state_vector())
@@ -3993,10 +4007,18 @@ class TestMqlFullStateClosure:
)
def snapshot(self, state_vector: list[float] | None = None) -> TestMqlFullStateSnapshot:
return self.snapshot_at(0.0, state_vector)
def snapshot_at(
self,
time_s: float,
state_vector: list[float] | None = None,
) -> TestMqlFullStateSnapshot:
values = self.initial_state_vector() if state_vector is None else list(state_vector)
pneumatic_state, mechanical_state = self._split_state(values)
mechanical_snapshot = self.mechanical_closure.snapshot(mechanical_state)
self._sync_variable_chamber_kinematics(mechanical_snapshot)
self.pneumatic_assembly.set_variable_orifice_openings(time_s)
pneumatic_snapshot = self.pneumatic_closure.snapshot(pneumatic_state)
return TestMqlFullStateSnapshot(
pneumatic=pneumatic_snapshot,
@@ -4016,6 +4038,7 @@ class TestMqlFullStateClosure:
pneumatic_state, mechanical_state = self._split_state(list(state_vector))
mechanical_snapshot = self.mechanical_closure.snapshot(mechanical_state)
self._sync_variable_chamber_kinematics(mechanical_snapshot)
self.pneumatic_assembly.set_variable_orifice_openings(time_s)
pneumatic_snapshot = self.pneumatic_closure.snapshot(pneumatic_state)
return [
*self.pneumatic_closure.rhs(pneumatic_state),
@@ -4054,6 +4077,7 @@ class TestMqlFullStateClosure:
*,
chamber_alias: str,
state_vector: list[float],
time_s: float = 0.0,
) -> TestMqlVariableChamberRhsDiagnostic:
if chamber_alias not in _PRIMARY_CHAMBER_DIAGNOSTIC_FIELDS:
raise KeyError(chamber_alias)
@@ -4065,7 +4089,7 @@ class TestMqlFullStateClosure:
for _mass_alias, piston_alias, bound_chamber_field in _PISTON_FORCE_BINDINGS
if bound_chamber_field == chamber_field
)
snapshot = self.snapshot(state_vector)
snapshot = self.snapshot_at(time_s, state_vector)
chamber = getattr(self.pneumatic_closure.components, chamber_field)
chamber_properties = getattr(snapshot.pneumatic, chamber_field)
line_properties = getattr(snapshot.pneumatic, line_field)
@@ -4113,7 +4137,7 @@ class TestMqlFullStateClosure:
from PythonModels.systems.test_mql_pneumatic import pressure_to_amesim_gauge_pa
selected_paths = tuple(data_paths) if data_paths is not None else _default_full_state_data_paths()
snapshot = self.snapshot(state_vector)
snapshot = self.snapshot_at(time_s, state_vector)
rhs = self.rhs_at(time_s, state_vector)
chamber_properties_by_alias = {}
chamber_by_alias = {}
@@ -4130,7 +4154,15 @@ class TestMqlFullStateClosure:
values_by_data_path = {}
for data_path in selected_paths:
signal, alias = self._split_data_path(data_path)
if alias in chamber_properties_by_alias:
if alias in _PNL0001_MASS_FLOW_DIAGNOSTIC_FIELDS:
if signal != "dm1":
raise KeyError(data_path)
canonical_flow_kg_s = getattr(
snapshot.pneumatic,
_PNL0001_MASS_FLOW_DIAGNOSTIC_FIELDS[alias],
)
values_by_data_path[data_path] = -canonical_flow_kg_s * 1.0e3
elif alias in chamber_properties_by_alias:
chamber_properties = chamber_properties_by_alias[alias]
chamber = chamber_by_alias[alias]
if signal == "press":
@@ -4631,6 +4663,7 @@ class TestMqlSystem:
resistance_boundary_temperature_k=resistance_boundary_temperature_k,
),
mechanical_closure=self.mechanical_mass_closure(),
pneumatic_assembly=self.pneumatic_assembly,
)
def simulate_full_state_from_spec(