导出test_mql机械节点总力
This commit is contained in:
1 parent
8782f96baf
commit
c8de46fac2
2 files changed
+64
-5
No files matched your search
@@ -3841,6 +3841,7 @@ class TestMqlSimulationResult:
|
||||
class TestMqlFullStateSnapshot:
|
||||
pneumatic: object
|
||||
mechanical: object
|
||||
mechanical_node_total_force_by_alias: dict[str, float]
|
||||
|
||||
@property
|
||||
def state_count(self) -> int:
|
||||
@@ -3906,9 +3907,17 @@ 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)
|
||||
return TestMqlFullStateSnapshot(
|
||||
pneumatic=self.pneumatic_closure.snapshot(pneumatic_state),
|
||||
mechanical=self.mechanical_closure.snapshot(mechanical_state),
|
||||
pneumatic=pneumatic_snapshot,
|
||||
mechanical=mechanical_snapshot,
|
||||
mechanical_node_total_force_by_alias=(
|
||||
self._mechanical_node_total_force_by_alias(
|
||||
pneumatic_snapshot,
|
||||
mechanical_snapshot,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
def rhs(self, state_vector: list[float]) -> list[float]:
|
||||
@@ -3931,6 +3940,31 @@ class TestMqlFullStateClosure:
|
||||
pneumatic_snapshot: object,
|
||||
mechanical_snapshot: object,
|
||||
) -> dict[str, float]:
|
||||
force_by_mass_alias = self._piston_force_by_mass_alias(pneumatic_snapshot)
|
||||
elastic_force_by_mass_alias = self._elastic_endstop_force_by_mass_alias(
|
||||
mechanical_snapshot
|
||||
)
|
||||
for mass_alias, contact_force in elastic_force_by_mass_alias.items():
|
||||
force_by_mass_alias[mass_alias] = (
|
||||
force_by_mass_alias.get(mass_alias, 0.0) - contact_force
|
||||
)
|
||||
return force_by_mass_alias
|
||||
|
||||
def _mechanical_node_total_force_by_alias(
|
||||
self,
|
||||
pneumatic_snapshot: object,
|
||||
mechanical_snapshot: object,
|
||||
) -> dict[str, float]:
|
||||
return {
|
||||
"dynamic_mechanical_node_alternative_2": sum(
|
||||
self._elastic_endstop_force_by_mass_alias(mechanical_snapshot).values()
|
||||
),
|
||||
"dynamic_mechanical_node_alternative_3": sum(
|
||||
self._piston_force_by_mass_alias(pneumatic_snapshot).values()
|
||||
),
|
||||
}
|
||||
|
||||
def _piston_force_by_mass_alias(self, pneumatic_snapshot: object) -> dict[str, float]:
|
||||
from PythonModels.systems.test_mql_pneumatic import pressure_to_amesim_gauge_pa
|
||||
|
||||
force_by_mass_alias: dict[str, float] = {}
|
||||
@@ -3940,8 +3974,14 @@ class TestMqlFullStateClosure:
|
||||
force_by_mass_alias[mass_alias] = (
|
||||
pressure_to_amesim_gauge_pa(chamber.p) * piston.annulus_area_m2
|
||||
)
|
||||
return force_by_mass_alias
|
||||
|
||||
def _elastic_endstop_force_by_mass_alias(
|
||||
self,
|
||||
mechanical_snapshot: object,
|
||||
) -> dict[str, float]:
|
||||
state_by_alias = {state.alias: state for state in mechanical_snapshot.states}
|
||||
force_by_mass_alias: dict[str, float] = {}
|
||||
for mass_alias, support_mass_alias, endstop_alias in _ELASTIC_ENDSTOP_FORCE_BINDINGS:
|
||||
mass_state = state_by_alias[mass_alias]
|
||||
support_state = state_by_alias[support_mass_alias]
|
||||
@@ -3952,9 +3992,9 @@ class TestMqlFullStateClosure:
|
||||
penetration_velocity_m_s = (
|
||||
mass_state.velocity_m_s - support_state.velocity_m_s
|
||||
)
|
||||
force_by_mass_alias[mass_alias] = (
|
||||
force_by_mass_alias.get(mass_alias, 0.0)
|
||||
- endstop.contact_force(gap_mm, penetration_velocity_m_s)
|
||||
force_by_mass_alias[mass_alias] = endstop.contact_force(
|
||||
gap_mm,
|
||||
penetration_velocity_m_s,
|
||||
)
|
||||
return force_by_mass_alias
|
||||
|
||||
|
||||
Reference in new issue
Block a user