导出test_mql总闭包关键序列
This commit is contained in:
1 parent
958d813300
commit
6953c864c4
2 files changed
+231
No files matched your search
@@ -1,11 +1,19 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from PythonModels.core.solver import SolveIVPConfig
|
||||
from PythonModels.reporting.amesim_results import load_test_mql_amesim_results
|
||||
from PythonModels.reporting.test_mql_output_schema import build_test_mql_output_schema
|
||||
from PythonModels.reporting.test_mql_output_validation import compare_validated_test_mql_output
|
||||
from PythonModels.systems.test_mql import TestMqlSystem
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
TEST_MQL_AME = REPO_ROOT / "AmesimModels" / "test_mql.ame"
|
||||
|
||||
|
||||
class TestMqlPnl0001ChamberSegmentTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.system = TestMqlSystem()
|
||||
@@ -247,6 +255,11 @@ class TestMqlPn3NodeChamberSegmentTests(unittest.TestCase):
|
||||
|
||||
|
||||
class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.amesim_results = load_test_mql_amesim_results(TEST_MQL_AME)
|
||||
cls.output_schema = build_test_mql_output_schema(cls.amesim_results)
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.system = TestMqlSystem()
|
||||
self.spec = self.system.discover_pneumatic_branch_topology().chamber_segment_specs[0]
|
||||
@@ -671,6 +684,50 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase):
|
||||
self.assertAlmostEqual(rhs[128], expected_contact_force / support_mass)
|
||||
self.assertAlmostEqual(rhs[129], 0.0)
|
||||
|
||||
def test_simulates_full_state_key_data_paths_for_amesim_comparison(self) -> None:
|
||||
data_paths = (
|
||||
"press@pn_c1_8",
|
||||
"vol@pn_c1_8",
|
||||
"vol1@pn_brp2_8",
|
||||
"vvol1@pn_brp2_8",
|
||||
"x1@mass_friction_endstops_10",
|
||||
"v1@mass_friction_endstops_10",
|
||||
"acc1@mass_friction_endstops_10",
|
||||
"x1@mass_friction_endstops_18",
|
||||
"v1@mass_friction_endstops_18",
|
||||
"acc1@mass_friction_endstops_18",
|
||||
)
|
||||
|
||||
result = self.system.simulate_full_state_series_from_spec(
|
||||
self.spec,
|
||||
inlet_node_pressure_pa=15.31e6,
|
||||
resistance_boundary_pressure_pa=15.29e6,
|
||||
config=SolveIVPConfig(t_start=0.0, t_stop=0.0),
|
||||
data_paths=data_paths,
|
||||
)
|
||||
comparison = compare_validated_test_mql_output(
|
||||
times=result.t,
|
||||
series_by_data_path={data_path: result.series[data_path] for data_path in data_paths},
|
||||
schema=self.output_schema,
|
||||
amesim_results=self.amesim_results,
|
||||
data_paths=data_paths,
|
||||
)
|
||||
|
||||
self.assertEqual(result.series["time"], [0.0])
|
||||
self.assertEqual(len(result.y), 132)
|
||||
self.assertEqual(len(comparison.metrics), len(data_paths))
|
||||
self.assertAlmostEqual(result.series["press@pn_c1_8"][0], -1300.0)
|
||||
self.assertAlmostEqual(result.series["vol@pn_c1_8"][0], 15000.0)
|
||||
self.assertAlmostEqual(result.series["vol1@pn_brp2_8"][0], 0.0)
|
||||
self.assertAlmostEqual(result.series["vvol1@pn_brp2_8"][0], 0.0)
|
||||
self.assertAlmostEqual(result.series["x1@mass_friction_endstops_10"][0], 0.0)
|
||||
self.assertAlmostEqual(result.series["v1@mass_friction_endstops_10"][0], 0.0)
|
||||
self.assertAlmostEqual(
|
||||
result.series["acc1@mass_friction_endstops_10"][0],
|
||||
-0.8167936695810917,
|
||||
)
|
||||
self.assertAlmostEqual(result.series["acc1@mass_friction_endstops_18"][0], 0.0)
|
||||
|
||||
def test_simulates_full_132_state_closure(self) -> None:
|
||||
solution = self.system.simulate_full_state_from_spec(
|
||||
self.spec,
|
||||
|
||||
Reference in new issue
Block a user