补充test_mql活塞几何计算输出
This commit is contained in:
1 parent
77e2f10cd5
commit
b3feb5c7e0
2 files changed
+176
No files matched your search
@@ -0,0 +1,67 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from PythonModels.systems.test_mql_computed import run_test_mql_computed_piston_geometry
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
TEST_MQL_AME = REPO_ROOT / "AmesimModels" / "test_mql.ame"
|
||||
|
||||
|
||||
class TestMqlComputedPistonGeometryTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.computed_run = run_test_mql_computed_piston_geometry(TEST_MQL_AME)
|
||||
|
||||
def test_computed_piston_geometry_outputs_schema_valid_series(self) -> None:
|
||||
self.assertEqual(self.computed_run.sample_count, 1002)
|
||||
self.assertEqual(len(self.computed_run.mechanical_assembly.pistons), 8)
|
||||
self.assertEqual(self.computed_run.signal_count, 24)
|
||||
self.assertEqual(len(self.computed_run.comparison.metrics), 24)
|
||||
self.assertEqual(self.computed_run.output_schema.signal_count, 858)
|
||||
|
||||
def test_computed_piston_geometry_output_paths_are_expected(self) -> None:
|
||||
paths = self.computed_run.output.data_paths
|
||||
|
||||
self.assertIn("length@pn_brp2_8", paths)
|
||||
self.assertIn("vol1@pn_brp2_8", paths)
|
||||
self.assertIn("vvol1@pn_brp2_8", paths)
|
||||
self.assertIn("length@pn_brp2_15", paths)
|
||||
self.assertEqual(len([path for path in paths if path.startswith("length@")]), 8)
|
||||
self.assertEqual(len([path for path in paths if path.startswith("vol1@")]), 8)
|
||||
self.assertEqual(len([path for path in paths if path.startswith("vvol1@")]), 8)
|
||||
|
||||
def test_computed_piston_geometry_matches_amesim_with_tight_error_bounds(self) -> None:
|
||||
for data_path in self.computed_run.output.data_paths:
|
||||
metric = self.computed_run.comparison.metric(data_path)
|
||||
with self.subTest(data_path=data_path):
|
||||
if data_path.startswith("length@"):
|
||||
self.assertLessEqual(metric.max_abs_error, 3.0e-13)
|
||||
elif data_path.startswith("vol1@"):
|
||||
self.assertLessEqual(metric.max_abs_error, 8.0e-12)
|
||||
elif data_path.startswith("vvol1@"):
|
||||
self.assertLessEqual(metric.max_abs_error, 3.0e-11)
|
||||
else:
|
||||
self.fail(f"Unexpected computed piston geometry path: {data_path}")
|
||||
|
||||
def test_computed_piston_geometry_final_samples_match_expected_values(self) -> None:
|
||||
self.assertAlmostEqual(
|
||||
self.computed_run.output.series("length@pn_brp2_8")[-1],
|
||||
1090.0013536465842,
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
self.computed_run.output.series("vol1@pn_brp2_8")[-1],
|
||||
34242.54636512914,
|
||||
delta=1.0e-9,
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
self.computed_run.output.series("vvol1@pn_brp2_8")[-1],
|
||||
8.360141002531034e-07,
|
||||
delta=1.0e-11,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user