拆解test_mql变容气室RHS

This commit is contained in:
huojiarong committed 2026-07-20 10:12:07 +00:00
1 parent a6e1faa2d8
commit 2c2952cff1
4 files changed
+205

No files matched your search

@@ -59,6 +59,16 @@ class RunTestMqlFullStateComparisonScriptTests(unittest.TestCase):
run.diagnostics_by_final_abs_error()[0].data_path,
"press@pn_c1_8",
)
chamber_diagnostic = run.chamber_rhs_diagnostic("pn_c1_8")
self.assertEqual(chamber_diagnostic.chamber_alias, "pn_c1_8")
self.assertEqual(chamber_diagnostic.piston_alias, "pn_brp2_8")
self.assertAlmostEqual(chamber_diagnostic.chamber_volume_m3, 0.015)
self.assertAlmostEqual(
chamber_diagnostic.energy_derivative_w,
chamber_diagnostic.port_a_energy_flow_w
+ chamber_diagnostic.port_b_energy_flow_w
+ chamber_diagnostic.boundary_work_w,
)
self.assertTrue(csv_summary_exists)
self.assertIn("Mode: Python 132 full-state closure comparison", summary)
self.assertIn("Compared signals: 2", summary)
@@ -66,6 +76,10 @@ class RunTestMqlFullStateComparisonScriptTests(unittest.TestCase):
self.assertIn("Largest final endpoint error: press@pn_c1_8=", summary)
self.assertIn("Metrics by max absolute error:", summary)
self.assertIn("Endpoint diagnostics by final absolute error:", summary)
self.assertIn("Largest endpoint chamber RHS breakdown: pn_c1_8", summary)
self.assertIn("piston_alias=pn_brp2_8", summary)
self.assertIn("mass_derivative_kg_s=", summary)
self.assertIn("boundary_work_w=", summary)
self.assertIn("final_python=", summary)
self.assertIn("final_amesim=", summary)
self.assertIn("python.press@pn_c1_8", csv_header)
@@ -118,6 +132,7 @@ class RunTestMqlFullStateComparisonScriptTests(unittest.TestCase):
self.assertIn("Largest final endpoint error: press@pn_c1_8=", summary)
self.assertIn("Metrics by max absolute error:", summary)
self.assertIn("Endpoint diagnostics by final absolute error:", summary)
self.assertIn("Largest endpoint chamber RHS breakdown: pn_c1_8", summary)
self.assertTrue(summary.endswith("\n"))
+26
View File
@@ -684,6 +684,32 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase):
self.assertAlmostEqual(rhs[128], expected_contact_force / support_mass)
self.assertAlmostEqual(rhs[129], 0.0)
def test_full_state_closure_diagnoses_variable_chamber_rhs_terms(self) -> None:
closure = self.system.full_state_closure_from_spec(
self.spec,
inlet_node_pressure_pa=15.31e6,
resistance_boundary_pressure_pa=15.29e6,
)
state = closure.initial_state_vector()
diagnostic = closure.variable_chamber_rhs_diagnostic(
chamber_alias="pn_c1_8",
state_vector=state,
)
rhs = closure.rhs(state)
self.assertEqual(diagnostic.piston_alias, "pn_brp2_8")
self.assertAlmostEqual(diagnostic.chamber_volume_m3, 0.015)
self.assertAlmostEqual(diagnostic.chamber_volume_rate_m3_s, 0.0)
self.assertAlmostEqual(diagnostic.mass_derivative_kg_s, rhs[46])
self.assertAlmostEqual(diagnostic.energy_derivative_w, rhs[47])
self.assertAlmostEqual(
diagnostic.energy_derivative_w,
diagnostic.port_a_energy_flow_w
+ diagnostic.port_b_energy_flow_w
+ diagnostic.boundary_work_w,
)
def test_simulates_full_state_key_data_paths_for_amesim_comparison(self) -> None:
data_paths = (
"press@pn_c1_8",