接入test_mql变容气室机械反馈
This commit is contained in:
1 parent
d4edf1ccb3
commit
958d813300
4 files changed
+109
-10
No files matched your search
@@ -115,6 +115,9 @@ class AmesimPneumaticVolume(DynamicComponent):
|
||||
def volume_cm3(self) -> float:
|
||||
return m3_to_cm3(self.volume)
|
||||
|
||||
def volume_rate_m3_s(self) -> float:
|
||||
return 0.0
|
||||
|
||||
def gas_mass_g(self) -> float:
|
||||
return kg_to_g(self.state.m)
|
||||
|
||||
@@ -146,6 +149,7 @@ class AmesimPneumaticVolume(DynamicComponent):
|
||||
port_b_m_flow: float,
|
||||
connected_h_b: float,
|
||||
internal_h: float,
|
||||
volume_rate_m3_s: float | None = None,
|
||||
) -> VolumeState:
|
||||
inlet_h_a = self.connection_inlet_enthalpy(
|
||||
port_m_flow=port_a_m_flow,
|
||||
@@ -159,7 +163,15 @@ class AmesimPneumaticVolume(DynamicComponent):
|
||||
)
|
||||
return VolumeState(
|
||||
m=port_a_m_flow + port_b_m_flow,
|
||||
U=port_a_m_flow * inlet_h_a + port_b_m_flow * inlet_h_b,
|
||||
U=(
|
||||
port_a_m_flow * inlet_h_a
|
||||
+ port_b_m_flow * inlet_h_b
|
||||
- self.properties().p * (
|
||||
self.volume_rate_m3_s()
|
||||
if volume_rate_m3_s is None
|
||||
else volume_rate_m3_s
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -177,10 +189,11 @@ class AmesimVariablePneumaticVolume(AmesimPneumaticVolume):
|
||||
) -> None:
|
||||
if dead_volume <= 0.0:
|
||||
raise ValueError("dead_volume must be positive.")
|
||||
if external_volume < 0.0:
|
||||
raise ValueError("external_volume must be non-negative.")
|
||||
if dead_volume + external_volume <= 0.0:
|
||||
raise ValueError("total volume must be positive.")
|
||||
self.dead_volume = dead_volume
|
||||
self.external_volume = external_volume
|
||||
self.external_volume_rate = 0.0
|
||||
super().__init__(
|
||||
name=name,
|
||||
volume=dead_volume + external_volume,
|
||||
@@ -208,10 +221,18 @@ class AmesimVariablePneumaticVolume(AmesimPneumaticVolume):
|
||||
external_volume=liters_to_m3(external_volume_liters),
|
||||
)
|
||||
|
||||
def set_external_volume_m3(self, external_volume: float) -> None:
|
||||
if external_volume < 0.0:
|
||||
raise ValueError("external_volume must be non-negative.")
|
||||
def volume_rate_m3_s(self) -> float:
|
||||
return self.external_volume_rate
|
||||
|
||||
def set_external_volume_m3(
|
||||
self,
|
||||
external_volume: float,
|
||||
external_volume_rate_m3_s: float = 0.0,
|
||||
) -> None:
|
||||
if self.dead_volume + external_volume <= 0.0:
|
||||
raise ValueError("total volume must be positive.")
|
||||
self.external_volume = external_volume
|
||||
self.external_volume_rate = external_volume_rate_m3_s
|
||||
self.volume = self.dead_volume + self.external_volume
|
||||
|
||||
|
||||
|
||||
@@ -3907,8 +3907,9 @@ class TestMqlFullStateClosure:
|
||||
def snapshot(self, 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)
|
||||
pneumatic_snapshot = self.pneumatic_closure.snapshot(pneumatic_state)
|
||||
mechanical_snapshot = self.mechanical_closure.snapshot(mechanical_state)
|
||||
self._sync_variable_chamber_kinematics(mechanical_snapshot)
|
||||
pneumatic_snapshot = self.pneumatic_closure.snapshot(pneumatic_state)
|
||||
return TestMqlFullStateSnapshot(
|
||||
pneumatic=pneumatic_snapshot,
|
||||
mechanical=mechanical_snapshot,
|
||||
@@ -3925,8 +3926,9 @@ class TestMqlFullStateClosure:
|
||||
|
||||
def rhs_at(self, time_s: float, state_vector: list[float]) -> list[float]:
|
||||
pneumatic_state, mechanical_state = self._split_state(list(state_vector))
|
||||
pneumatic_snapshot = self.pneumatic_closure.snapshot(pneumatic_state)
|
||||
mechanical_snapshot = self.mechanical_closure.snapshot(mechanical_state)
|
||||
self._sync_variable_chamber_kinematics(mechanical_snapshot)
|
||||
pneumatic_snapshot = self.pneumatic_closure.snapshot(pneumatic_state)
|
||||
return [
|
||||
*self.pneumatic_closure.rhs(pneumatic_state),
|
||||
*self.mechanical_closure.rhs(
|
||||
@@ -3943,6 +3945,22 @@ class TestMqlFullStateClosure:
|
||||
),
|
||||
]
|
||||
|
||||
def _sync_variable_chamber_kinematics(self, mechanical_snapshot: object) -> None:
|
||||
for _mass_alias, piston_alias, chamber_field in _PISTON_FORCE_BINDINGS:
|
||||
piston = self.mechanical_closure.assembly.pistons[piston_alias]
|
||||
kinematics = mechanical_snapshot.piston_kinematics_by_alias[piston_alias]
|
||||
chamber = getattr(self.pneumatic_closure.components, chamber_field)
|
||||
chamber.set_external_volume_m3(
|
||||
piston.geometry().chamber_volume_m3(
|
||||
kinematics.port_3_displacement_m,
|
||||
kinematics.port_2_displacement_m,
|
||||
),
|
||||
piston.geometry().chamber_volume_rate_m3_s(
|
||||
kinematics.port_3_velocity_m_s,
|
||||
kinematics.port_2_velocity_m_s,
|
||||
),
|
||||
)
|
||||
|
||||
def _force_by_mass_alias(
|
||||
self,
|
||||
time_s: float,
|
||||
|
||||
Reference in new issue
Block a user