diff --git a/PythonModels/scripts/run_test_mql_full_state_comparison.py b/PythonModels/scripts/run_test_mql_full_state_comparison.py index ac40e14..7250c67 100644 --- a/PythonModels/scripts/run_test_mql_full_state_comparison.py +++ b/PythonModels/scripts/run_test_mql_full_state_comparison.py @@ -472,6 +472,14 @@ class TestMqlPnl0003EnergyDiagnostic: python_port_2_reference_center_enthalpy_flow_w: float python_port_2_reference_storage_enthalpy_sum_w: float python_port_2_reference_storage_enthalpy_error_w: float + amesim_port_2_external_enthalpy_dtemp_component_k_s: float + amesim_port_2_center_enthalpy_dtemp_component_k_s: float + amesim_port_2_mass_offset_dtemp_component_k_s: float + amesim_port_2_heat_dtemp_component_k_s: float + python_port_2_external_enthalpy_dtemp_component_k_s: float + python_port_2_center_enthalpy_dtemp_component_k_s: float + python_port_2_mass_offset_dtemp_component_k_s: float + python_port_2_heat_dtemp_component_k_s: float amesim_port_1_temperature_derivative_fd_k_s: float amesim_port_1_temperature_derivative_backward_k_s: float amesim_port_1_temperature_derivative_forward_k_s: float @@ -1901,6 +1909,49 @@ def _pnl0003_energy_diagnostic( heat_flow_w=python_heat_flow_2, reference_temperature_k=reference_temperature_k, ) + + def dtemp_component(flow_w: float, mass_kg: float) -> float: + return flow_w / (mass_kg * line.gas.cv) + + amesim_port_2_mass_offset_flow_w = ( + line.gas.cp * reference_temperature_k - line.gas.cv * amesim_t2 + ) * amesim_sdm2_kg_s + python_port_2_mass_offset_flow_w = ( + line.gas.cp * reference_temperature_k - line.gas.cv * port_2.T + ) * (port_2_flow + center_flow) + amesim_port_2_external_dtemp_component = dtemp_component( + amesim_dh2, + amesim_mass_2, + ) + amesim_port_2_center_dtemp_component = dtemp_component( + -amesim_dhctr, + amesim_mass_2, + ) + amesim_port_2_mass_offset_dtemp_component = dtemp_component( + amesim_port_2_mass_offset_flow_w, + amesim_mass_2, + ) + amesim_port_2_heat_dtemp_component = dtemp_component( + heat_flow_2, + amesim_mass_2, + ) + python_port_2_external_dtemp_component = dtemp_component( + python_port_2_dh, + line.state_2.m, + ) + python_port_2_center_dtemp_component = dtemp_component( + python_center_dh_2, + line.state_2.m, + ) + python_port_2_mass_offset_dtemp_component = dtemp_component( + python_port_2_mass_offset_flow_w, + line.state_2.m, + ) + python_port_2_heat_dtemp_component = dtemp_component( + python_heat_flow_2, + line.state_2.m, + ) + amesim_center_flow_python_sign_kg_s = ( amesim_center_python_sign_equivalent_g_s * 1.0e-3 ) @@ -2035,6 +2086,26 @@ def _pnl0003_energy_diagnostic( python_port_2_reference_storage_enthalpy_error_w=( python_port_2_dh + python_center_dh_2 - amesim_sdh2 ), + amesim_port_2_external_enthalpy_dtemp_component_k_s=( + amesim_port_2_external_dtemp_component + ), + amesim_port_2_center_enthalpy_dtemp_component_k_s=( + amesim_port_2_center_dtemp_component + ), + amesim_port_2_mass_offset_dtemp_component_k_s=( + amesim_port_2_mass_offset_dtemp_component + ), + amesim_port_2_heat_dtemp_component_k_s=amesim_port_2_heat_dtemp_component, + python_port_2_external_enthalpy_dtemp_component_k_s=( + python_port_2_external_dtemp_component + ), + python_port_2_center_enthalpy_dtemp_component_k_s=( + python_port_2_center_dtemp_component + ), + python_port_2_mass_offset_dtemp_component_k_s=( + python_port_2_mass_offset_dtemp_component + ), + python_port_2_heat_dtemp_component_k_s=python_port_2_heat_dtemp_component, amesim_port_1_temperature_derivative_fd_k_s=amesim_fd_dtemp_1, amesim_port_1_temperature_derivative_backward_k_s=amesim_backward_dtemp_1, amesim_port_1_temperature_derivative_forward_k_s=amesim_forward_dtemp_1, @@ -2753,6 +2824,14 @@ def format_test_mql_pnvo_event_window_summary( f"python_ref_ctr2={pnl0003_energy.python_port_2_reference_center_enthalpy_flow_w}, " f"python_ref_sdh2={pnl0003_energy.python_port_2_reference_storage_enthalpy_sum_w}, " f"python_ref_sdh2_error={pnl0003_energy.python_port_2_reference_storage_enthalpy_error_w}, " + f"amesim_dT2_ext_h={pnl0003_energy.amesim_port_2_external_enthalpy_dtemp_component_k_s}, " + f"amesim_dT2_ctr_h={pnl0003_energy.amesim_port_2_center_enthalpy_dtemp_component_k_s}, " + f"amesim_dT2_m_offset={pnl0003_energy.amesim_port_2_mass_offset_dtemp_component_k_s}, " + f"amesim_dT2_heat={pnl0003_energy.amesim_port_2_heat_dtemp_component_k_s}, " + f"python_dT2_ext_h={pnl0003_energy.python_port_2_external_enthalpy_dtemp_component_k_s}, " + f"python_dT2_ctr_h={pnl0003_energy.python_port_2_center_enthalpy_dtemp_component_k_s}, " + f"python_dT2_m_offset={pnl0003_energy.python_port_2_mass_offset_dtemp_component_k_s}, " + f"python_dT2_heat={pnl0003_energy.python_port_2_heat_dtemp_component_k_s}, " f"amesim_fd_dT1={pnl0003_energy.amesim_port_1_temperature_derivative_fd_k_s}, " f"amesim_back_dT1={pnl0003_energy.amesim_port_1_temperature_derivative_backward_k_s}, " f"amesim_fwd_dT1={pnl0003_energy.amesim_port_1_temperature_derivative_forward_k_s}, " diff --git a/tests/test_run_test_mql_full_state_comparison.py b/tests/test_run_test_mql_full_state_comparison.py index 155906b..a72d9a5 100644 --- a/tests/test_run_test_mql_full_state_comparison.py +++ b/tests/test_run_test_mql_full_state_comparison.py @@ -417,6 +417,14 @@ class RunTestMqlFullStateComparisonScriptTests(unittest.TestCase): python_port_2_reference_center_enthalpy_flow_w=-15800.0, python_port_2_reference_storage_enthalpy_sum_w=3200.0, python_port_2_reference_storage_enthalpy_error_w=172.0, + amesim_port_2_external_enthalpy_dtemp_component_k_s=6000.0, + amesim_port_2_center_enthalpy_dtemp_component_k_s=-5000.0, + amesim_port_2_mass_offset_dtemp_component_k_s=-1500.0, + amesim_port_2_heat_dtemp_component_k_s=0.0, + python_port_2_external_enthalpy_dtemp_component_k_s=6100.0, + python_port_2_center_enthalpy_dtemp_component_k_s=-5100.0, + python_port_2_mass_offset_dtemp_component_k_s=-1650.0, + python_port_2_heat_dtemp_component_k_s=0.0, amesim_port_1_temperature_derivative_fd_k_s=-210.0, amesim_port_1_temperature_derivative_backward_k_s=-420.0, amesim_port_1_temperature_derivative_forward_k_s=100.0, @@ -628,6 +636,12 @@ class RunTestMqlFullStateComparisonScriptTests(unittest.TestCase): self.assertIn("python_dmgas_dt=-0.47", summary) self.assertIn("python_ref_sdh1=15880.0", summary) self.assertIn("python_ref_sdh2_error=172.0", summary) + self.assertIn("amesim_dT2_ext_h=6000.0", summary) + self.assertIn("amesim_dT2_ctr_h=-5000.0", summary) + self.assertIn("amesim_dT2_m_offset=-1500.0", summary) + self.assertIn("python_dT2_ext_h=6100.0", summary) + self.assertIn("python_dT2_ctr_h=-5100.0", summary) + self.assertIn("python_dT2_m_offset=-1650.0", summary) self.assertIn("amesim_back_dT2=-600.0", summary) self.assertIn("amesim_fwd_dT2=120.0", summary) self.assertIn("amesim_pn2vol_dT2=-530.0", summary)