接入test_mql机械质量状态闭包
This commit is contained in:
1 parent
7cb050d235
commit
3d1de6d5d0
4 files changed
+180
-1
No files matched your search
@@ -4,8 +4,11 @@ import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from PythonModels.reporting.amesim_results import load_test_mql_amesim_results
|
||||
from PythonModels.core.solver import SolveIVPConfig
|
||||
from PythonModels.reporting.test_mql_variables import build_test_mql_variable_catalog
|
||||
from PythonModels.systems.test_mql import TestMqlSystem
|
||||
from PythonModels.systems.test_mql_mechanical import (
|
||||
TestMqlMechanicalMassClosure,
|
||||
build_test_mql_mechanical_assembly,
|
||||
circular_area,
|
||||
mm_to_m,
|
||||
@@ -37,6 +40,43 @@ class TestMqlMechanicalAssemblyTests(unittest.TestCase):
|
||||
self.assertEqual(len(self.assembly.force_connectors), 2)
|
||||
self.assertEqual(self.assembly.component_count, 46)
|
||||
|
||||
def test_mechanical_mass_closure_exposes_all_mecmas21_states(self) -> None:
|
||||
closure = TestMqlMechanicalMassClosure(self.assembly)
|
||||
state = closure.initial_state_vector()
|
||||
snapshot = closure.snapshot(state)
|
||||
rhs = closure.rhs(state)
|
||||
|
||||
self.assertEqual(closure.mass_aliases, tuple(self.assembly.masses))
|
||||
self.assertEqual(len(closure.mass_aliases), 10)
|
||||
self.assertEqual(len(state), 20)
|
||||
self.assertEqual(snapshot.state_count, 20)
|
||||
self.assertEqual(len(rhs), 20)
|
||||
self.assertEqual(snapshot.states[0].alias, "mass_friction_endstops_10")
|
||||
self.assertAlmostEqual(
|
||||
snapshot.states[0].velocity_m_s,
|
||||
self.amesim_results.series("v1@mass_friction_endstops_10")[0],
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
snapshot.states[0].displacement_m,
|
||||
self.amesim_results.series("x1@mass_friction_endstops_10")[0],
|
||||
)
|
||||
for index, mass_state in enumerate(snapshot.states):
|
||||
self.assertAlmostEqual(rhs[2 * index + 1], mass_state.velocity_m_s)
|
||||
|
||||
def test_system_simulates_mechanical_mass_state_closure(self) -> None:
|
||||
system = TestMqlSystem()
|
||||
|
||||
solution = system.simulate_mechanical_masses(
|
||||
config=SolveIVPConfig(t_start=0.0, t_stop=1.0e-5, max_step=1.0e-6),
|
||||
t_eval=[0.0, 1.0e-5],
|
||||
)
|
||||
|
||||
self.assertTrue(solution.success)
|
||||
self.assertEqual(len(system.mechanical_state_vector()), 20)
|
||||
self.assertEqual(len(solution.t), 2)
|
||||
self.assertEqual(len(solution.y), 20)
|
||||
self.assertEqual([len(row) for row in solution.y], [2] * 20)
|
||||
|
||||
def test_piston_geometry_is_converted_to_si_units(self) -> None:
|
||||
piston = self.assembly.pistons["pn_brp2_8"]
|
||||
|
||||
|
||||
Reference in new issue
Block a user