修正test_mql事件窗口插值诊断
This commit is contained in:
1 parent
331435e78a
commit
01b606df30
5 files changed
+103
-3
No files matched your search
@@ -55,6 +55,17 @@ class AmesimPneumaticComponentsTest(unittest.TestCase):
|
||||
delta=0.1,
|
||||
)
|
||||
|
||||
def test_pressure_transport_enthalpy_restores_absolute_energy_offset(self) -> None:
|
||||
gas = HELIUM_PNEUMATIC_GAS
|
||||
pressure = 13_839_965.0
|
||||
temperature = 287.7322
|
||||
|
||||
self.assertAlmostEqual(
|
||||
gas.pressure_transport_enthalpy(pressure, temperature),
|
||||
gas.pressure_reference_enthalpy(pressure, temperature)
|
||||
+ gas.cp * 298.15,
|
||||
)
|
||||
|
||||
def test_reference_temperature_from_enthalpy_rejects_non_positive_cp(self) -> None:
|
||||
gas = AmesimPneumaticGas(cp=0.0, cv=3116.0)
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ from PythonModels.scripts.run_test_mql_full_state_comparison import (
|
||||
format_test_mql_pnvo_event_boundary_summary,
|
||||
format_test_mql_pnvo_event_window_summary,
|
||||
run_test_mql_full_state_comparison,
|
||||
_series_sample_bracket,
|
||||
)
|
||||
|
||||
|
||||
@@ -34,6 +35,23 @@ TEST_MQL_AME = REPO_ROOT / "AmesimModels" / "test_mql.ame"
|
||||
|
||||
|
||||
class RunTestMqlFullStateComparisonScriptTests(unittest.TestCase):
|
||||
def test_series_sample_bracket_distinguishes_exact_and_interpolated_times(self) -> None:
|
||||
times = (0.04000000000000009, 0.050000000000000114)
|
||||
|
||||
exact_left, exact_right = _series_sample_bracket(
|
||||
times=times,
|
||||
time_s=0.04,
|
||||
)
|
||||
interpolated_left, interpolated_right = _series_sample_bracket(
|
||||
times=times,
|
||||
time_s=0.041,
|
||||
)
|
||||
|
||||
self.assertEqual(exact_left, exact_right)
|
||||
self.assertAlmostEqual(exact_left, 0.04)
|
||||
self.assertAlmostEqual(interpolated_left, 0.04)
|
||||
self.assertAlmostEqual(interpolated_right, 0.05)
|
||||
|
||||
def test_full_state_script_writes_summary_and_comparison_csv(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
output_dir = Path(tmpdir)
|
||||
@@ -231,6 +249,8 @@ class RunTestMqlFullStateComparisonScriptTests(unittest.TestCase):
|
||||
"xv@pn_morifice_1": 1.0,
|
||||
"dm2@pn_morifice_1": 456.8,
|
||||
},
|
||||
amesim_sample_left_time_s=0.05,
|
||||
amesim_sample_right_time_s=0.05,
|
||||
pnl0001_rhs_diagnostics=(
|
||||
TestMqlPnl0001LineRhsDiagnostic(
|
||||
line_alias="pneumatic_69",
|
||||
@@ -497,7 +517,8 @@ class RunTestMqlFullStateComparisonScriptTests(unittest.TestCase):
|
||||
self.assertAlmostEqual(sample.abs_error("press@pn_c1_8"), 32067.9)
|
||||
self.assertIn("PNVO event window diagnostic (pn_morifice_1)", summary)
|
||||
self.assertIn("Sample comparisons:", summary)
|
||||
self.assertIn("t=0.05", summary)
|
||||
self.assertFalse(sample.amesim_values_are_interpolated)
|
||||
self.assertIn("t=0.05 (amesim=exact@0.05)", summary)
|
||||
self.assertIn("rhs=8154", summary)
|
||||
self.assertIn("rhs@pneumatic_69", summary)
|
||||
self.assertIn("dm_dt=-0.0222", summary)
|
||||
|
||||
@@ -8,6 +8,9 @@ from PythonModels.reporting.test_mql_orifice_observations import (
|
||||
G_PER_S_TO_KG_PER_S,
|
||||
build_test_mql_orifice_observation_catalog,
|
||||
)
|
||||
from PythonModels.systems.test_mql_pneumatic import (
|
||||
TEST_MQL_PNVO001_FLOW_COEFFICIENT_MULTIPLIER,
|
||||
)
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -55,7 +58,10 @@ class TestMqlOrificeObservationCatalogTests(unittest.TestCase):
|
||||
last = binding.observation_at(self.amesim_results, -1)
|
||||
|
||||
self.assertAlmostEqual(binding.nominal_area_m2, 78.5e-6)
|
||||
self.assertAlmostEqual(binding.flow_coefficient, 0.45)
|
||||
self.assertAlmostEqual(
|
||||
binding.flow_coefficient,
|
||||
0.45 * TEST_MQL_PNVO001_FLOW_COEFFICIENT_MULTIPLIER,
|
||||
)
|
||||
self.assertEqual(first.opening, 0.0)
|
||||
self.assertEqual(first.effective_area_m2, 0.0)
|
||||
self.assertEqual(last.opening, 1.0)
|
||||
|
||||
Reference in new issue
Block a user