补充test_mql机械零力计算输出
This commit is contained in:
1 parent
3ac83d9f00
commit
bef9dce55e
2 files changed
+63
-4
No files matched your search
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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__":
|
||||
|
||||
Reference in new issue
Block a user