补充test_mql变容气室体积计算输出

This commit is contained in:
huojiarong committed 2026-07-16 08:23:12 +00:00
1 parent b3feb5c7e0
commit 999d840615
2 files changed
+146 -1

No files matched your search

+47 -1
View File
@@ -3,7 +3,10 @@ from __future__ import annotations
import unittest
from pathlib import Path
from PythonModels.systems.test_mql_computed import run_test_mql_computed_piston_geometry
from PythonModels.systems.test_mql_computed import (
run_test_mql_computed_geometry,
run_test_mql_computed_piston_geometry,
)
REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -63,5 +66,48 @@ class TestMqlComputedPistonGeometryTests(unittest.TestCase):
)
class TestMqlComputedGeometryTests(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.computed_run = run_test_mql_computed_geometry(TEST_MQL_AME)
def test_computed_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(len(self.computed_run.pneumatic_assembly.variable_chambers), 8)
self.assertEqual(self.computed_run.signal_count, 32)
self.assertEqual(len(self.computed_run.comparison.metrics), 32)
self.assertEqual(self.computed_run.output_schema.signal_count, 858)
def test_computed_geometry_includes_variable_chamber_volume_paths(self) -> None:
paths = self.computed_run.output.data_paths
self.assertIn("vol@pn_c1_8", paths)
self.assertIn("vol@pn_c1_15", paths)
self.assertEqual(len([path for path in paths if path.startswith("vol@pn_c1")]), 8)
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_variable_chamber_volumes_match_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("vol@pn_c1"):
self.assertLessEqual(metric.max_abs_error, 8.0e-12)
def test_computed_variable_chamber_volume_final_samples_match_expected_values(self) -> None:
self.assertAlmostEqual(
self.computed_run.output.series("vol@pn_c1_8")[-1],
49242.54636512914,
delta=1.0e-9,
)
self.assertAlmostEqual(
self.computed_run.output.series("vol@pn_c1_15")[-1],
49242.546365149814,
delta=1.0e-9,
)
if __name__ == "__main__":
unittest.main()