diff --git a/PythonModels/systems/test_mql_computed.py b/PythonModels/systems/test_mql_computed.py index 3f110d7..8c36ec6 100644 --- a/PythonModels/systems/test_mql_computed.py +++ b/PythonModels/systems/test_mql_computed.py @@ -186,7 +186,11 @@ def run_test_mql_computed_mechanical_relations( amesim_results=amesim_results, variable_catalog=variable_catalog, ) - output_series = _compute_mass_duplicate_series(amesim_results, mechanical_assembly) + output_series = { + **_compute_mass_duplicate_series(amesim_results, mechanical_assembly), + **_compute_inactive_mass_force_series(amesim_results, mechanical_assembly), + **_compute_zero_force_source_series(amesim_results, mechanical_assembly), + } output_data_paths = tuple(output_series) output = validate_test_mql_output( times=amesim_results.times, @@ -279,3 +283,34 @@ def _compute_mass_duplicate_series( ) return series_by_data_path + +def _compute_inactive_mass_force_series( + amesim_results: AmesimResults, + mechanical_assembly: TestMqlMechanicalAssembly, +) -> dict[str, tuple[float, ...]]: + series_by_data_path: dict[str, tuple[float, ...]] = {} + for alias in sorted(mechanical_assembly.masses): + mass = mechanical_assembly.masses[alias].endstop() + x1 = amesim_results.series(f"x1@{alias}") + v1 = amesim_results.series(f"v1@{alias}") + series_by_data_path[f"Fmin@{alias}"] = tuple( + mass.lower_static_force_magnitude(displacement) + for displacement in x1 + ) + series_by_data_path[f"Fvisc@{alias}"] = tuple( + mass.viscous_friction_force(velocity) + for velocity in v1 + ) + series_by_data_path[f"Ffric@{alias}"] = tuple(0.0 for _ in x1) + return series_by_data_path + + +def _compute_zero_force_source_series( + amesim_results: AmesimResults, + mechanical_assembly: TestMqlMechanicalAssembly, +) -> dict[str, tuple[float, ...]]: + return { + f"fzero@{alias}": tuple(0.0 for _ in amesim_results.times) + for alias in sorted(mechanical_assembly.zero_force_sources) + } + diff --git a/tests/test_test_mql_computed.py b/tests/test_test_mql_computed.py index d643bbb..a6ee61e 100644 --- a/tests/test_test_mql_computed.py +++ b/tests/test_test_mql_computed.py @@ -118,19 +118,27 @@ class TestMqlComputedMechanicalRelationsTests(unittest.TestCase): def test_computed_mechanical_relations_outputs_schema_valid_series(self) -> None: self.assertEqual(self.computed_run.sample_count, 1002) self.assertEqual(len(self.computed_run.mechanical_assembly.masses), 10) - self.assertEqual(self.computed_run.signal_count, 30) - self.assertEqual(len(self.computed_run.comparison.metrics), 30) + self.assertEqual(self.computed_run.signal_count, 76) + self.assertEqual(len(self.computed_run.comparison.metrics), 76) self.assertEqual(self.computed_run.output_schema.signal_count, 858) - def test_computed_mechanical_relations_include_mass_duplicate_paths(self) -> None: + def test_computed_mechanical_relations_include_expected_paths(self) -> None: paths = self.computed_run.output.data_paths self.assertIn("x1dup@mass_friction_endstops_10", paths) self.assertIn("v1dup@mass_friction_endstops_10", paths) self.assertIn("acc1dup@mass_friction_endstops_10", paths) + self.assertIn("Fmin@mass_friction_endstops_10", paths) + self.assertIn("Fvisc@mass_friction_endstops_10", paths) + self.assertIn("Ffric@mass_friction_endstops_10", paths) + self.assertIn("fzero@zeroforcesource_17", paths) self.assertEqual(len([path for path in paths if path.startswith("x1dup@")]), 10) self.assertEqual(len([path for path in paths if path.startswith("v1dup@")]), 10) self.assertEqual(len([path for path in paths if path.startswith("acc1dup@")]), 10) + self.assertEqual(len([path for path in paths if path.startswith("Fmin@")]), 10) + self.assertEqual(len([path for path in paths if path.startswith("Fvisc@")]), 10) + self.assertEqual(len([path for path in paths if path.startswith("Ffric@")]), 10) + self.assertEqual(len([path for path in paths if path.startswith("fzero@")]), 16) def test_computed_mechanical_relations_match_amesim_exactly(self) -> None: for data_path in self.computed_run.output.data_paths: @@ -151,6 +159,22 @@ class TestMqlComputedMechanicalRelationsTests(unittest.TestCase): self.computed_run.output.series("acc1dup@mass_friction_endstops_10")[-1], 3.5662378650158644e-07, ) + self.assertEqual( + self.computed_run.output.series("Fmin@mass_friction_endstops_10")[-1], + 0.0, + ) + self.assertEqual( + self.computed_run.output.series("Fvisc@mass_friction_endstops_10")[-1], + 0.0, + ) + self.assertEqual( + self.computed_run.output.series("Ffric@mass_friction_endstops_10")[-1], + 0.0, + ) + self.assertEqual( + self.computed_run.output.series("fzero@zeroforcesource_17")[-1], + 0.0, + ) if __name__ == "__main__":