补充test_mql PNVO焓流诊断与系数校正
This commit is contained in:
1 parent
a219cddc0b
commit
331435e78a
8 files changed
+1164
-20
No files matched your search
@@ -6,6 +6,7 @@ from datetime import UTC, datetime
|
||||
from math import nextafter, sqrt
|
||||
from pathlib import Path
|
||||
|
||||
from PythonModels.components.amesim_pneumatic import AmesimPneumaticGas
|
||||
from PythonModels.core.solver import SolveIVPConfig, integrate_ode
|
||||
from PythonModels.reporting.amesim_results import AmesimResults, load_test_mql_amesim_results
|
||||
from PythonModels.reporting.test_mql_comparison import (
|
||||
@@ -353,6 +354,113 @@ class TestMqlPnl0001EnergyFlowDiagnostic:
|
||||
python_reference_pn2vol2_dtemp_node_minus_dh1_k_s: float
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TestMqlP4NodeEnthalpyBreakdownDiagnostic:
|
||||
node_alias: str
|
||||
time_s: float
|
||||
amesim_port_1_enthalpy_flow_w: float
|
||||
amesim_port_1_mass_flow_g_s: float
|
||||
amesim_port_3_enthalpy_flow_w: float
|
||||
amesim_port_3_mass_flow_g_s: float
|
||||
amesim_port_4_enthalpy_flow_w: float
|
||||
amesim_port_4_mass_flow_g_s: float
|
||||
amesim_port_2_enthalpy_flow_w: float
|
||||
amesim_port_2_mass_flow_g_s: float
|
||||
python_port_1_enthalpy_flow_w: float
|
||||
python_port_1_mass_flow_g_s: float
|
||||
python_port_3_enthalpy_flow_w: float
|
||||
python_port_3_mass_flow_g_s: float
|
||||
python_port_4_enthalpy_flow_w: float
|
||||
python_port_4_mass_flow_g_s: float
|
||||
python_port_2_enthalpy_flow_w: float
|
||||
python_port_2_mass_flow_g_s: float
|
||||
python_reference_port_1_enthalpy_flow_w: float
|
||||
python_reference_port_3_enthalpy_flow_w: float
|
||||
python_reference_port_4_enthalpy_flow_w: float
|
||||
python_reference_port_2_enthalpy_flow_w: float
|
||||
python_port_2_enthalpy_error_w: float
|
||||
python_reference_port_2_enthalpy_error_w: float
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TestMqlPnvoUpstreamEnthalpyDiagnostic:
|
||||
orifice_alias: str
|
||||
upstream_line_alias: str
|
||||
time_s: float
|
||||
amesim_orifice_port_2_enthalpy_flow_w: float
|
||||
amesim_orifice_port_2_mass_flow_g_s: float
|
||||
amesim_orifice_port_3_enthalpy_flow_w: float
|
||||
amesim_orifice_port_3_mass_flow_g_s: float
|
||||
amesim_upstream_line_center_enthalpy_flow_w: float
|
||||
amesim_upstream_line_center_mass_flow_g_s: float
|
||||
amesim_upstream_line_port_2_temperature_k: float
|
||||
amesim_upstream_line_port_2_pressure_pa: float
|
||||
amesim_orifice_port_2_implied_reference_temperature_k: float
|
||||
amesim_orifice_port_2_implied_temperature_delta_to_line_k: float
|
||||
amesim_upstream_line_port_2_reference_enthalpy_flow_w: float
|
||||
amesim_upstream_line_port_2_reference_enthalpy_error_w: float
|
||||
amesim_upstream_line_port_2_real_gas_reference_enthalpy_flow_w: float
|
||||
amesim_upstream_line_port_2_real_gas_reference_enthalpy_error_w: float
|
||||
python_orifice_to_node_flow_kg_s: float
|
||||
python_upstream_line_port_2_temperature_k: float
|
||||
python_upstream_line_port_2_pressure_pa: float
|
||||
python_current_port_2_enthalpy_flow_w: float
|
||||
python_reference_port_2_enthalpy_flow_w: float
|
||||
python_real_gas_reference_port_2_enthalpy_flow_w: float
|
||||
python_current_port_2_enthalpy_error_w: float
|
||||
python_reference_port_2_enthalpy_error_w: float
|
||||
python_real_gas_reference_port_2_enthalpy_error_w: float
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TestMqlPnl0003EnergyDiagnostic:
|
||||
line_alias: str
|
||||
time_s: float
|
||||
amesim_port_1_temperature_k: float
|
||||
amesim_port_2_temperature_k: float
|
||||
amesim_port_1_pressure_pa: float
|
||||
amesim_port_2_pressure_pa: float
|
||||
amesim_port_1_mass_flow_g_s: float
|
||||
amesim_port_1_enthalpy_flow_w: float
|
||||
amesim_center_mass_flow_g_s: float
|
||||
amesim_center_enthalpy_flow_w: float
|
||||
amesim_port_2_mass_flow_g_s: float
|
||||
amesim_port_2_enthalpy_flow_w: float
|
||||
amesim_port_1_storage_mass_derivative_g_s: float
|
||||
amesim_port_1_storage_enthalpy_sum_w: float
|
||||
amesim_port_2_storage_mass_derivative_g_s: float
|
||||
amesim_port_2_storage_enthalpy_sum_w: float
|
||||
amesim_total_mass_derivative_fd_g_s: float
|
||||
amesim_total_mass_derivative_backward_g_s: float
|
||||
amesim_total_mass_derivative_forward_g_s: float
|
||||
amesim_total_storage_mass_derivative_g_s: float
|
||||
amesim_total_storage_mass_derivative_residual_g_s: float
|
||||
amesim_center_flow_python_sign_equivalent_g_s: float
|
||||
amesim_center_flow_python_sign_error_g_s: float
|
||||
python_center_mass_flow_g_s: float
|
||||
python_total_mass_derivative_kg_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
|
||||
amesim_port_2_temperature_derivative_fd_k_s: float
|
||||
amesim_port_2_temperature_derivative_backward_k_s: float
|
||||
amesim_port_2_temperature_derivative_forward_k_s: float
|
||||
amesim_port_1_pn2vol_dtemp_k_s: float
|
||||
amesim_port_2_pn2vol_dtemp_k_s: float
|
||||
amesim_port_1_pn2vol_dtemp_residual_k_s: float
|
||||
amesim_port_2_pn2vol_dtemp_residual_k_s: float
|
||||
python_port_1_temperature_k: float
|
||||
python_port_2_temperature_k: float
|
||||
python_port_1_pressure_pa: float
|
||||
python_port_2_pressure_pa: float
|
||||
python_port_1_mass_derivative_kg_s: float
|
||||
python_port_2_mass_derivative_kg_s: float
|
||||
python_port_1_current_dtemp_k_s: float
|
||||
python_port_2_current_dtemp_k_s: float
|
||||
python_port_1_real_gas_reference_dtemp_k_s: float
|
||||
python_port_2_real_gas_reference_dtemp_k_s: float
|
||||
python_port_2_temperature_error_to_amesim_k: float
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TestMqlPnch012EnergyEquationDiagnostic:
|
||||
chamber_alias: str
|
||||
@@ -396,6 +504,15 @@ class TestMqlPnvoEventWindowSampleDiagnostic:
|
||||
pnl0001_energy_flow_diagnostics: tuple[
|
||||
TestMqlPnl0001EnergyFlowDiagnostic, ...
|
||||
] = field(default_factory=tuple)
|
||||
p4_node_enthalpy_breakdown_diagnostics: tuple[
|
||||
TestMqlP4NodeEnthalpyBreakdownDiagnostic, ...
|
||||
] = field(default_factory=tuple)
|
||||
pnvo_upstream_enthalpy_diagnostics: tuple[
|
||||
TestMqlPnvoUpstreamEnthalpyDiagnostic, ...
|
||||
] = field(default_factory=tuple)
|
||||
pnl0003_energy_diagnostics: tuple[
|
||||
TestMqlPnl0003EnergyDiagnostic, ...
|
||||
] = field(default_factory=tuple)
|
||||
pnch012_energy_equation_diagnostics: tuple[
|
||||
TestMqlPnch012EnergyEquationDiagnostic, ...
|
||||
] = field(default_factory=tuple)
|
||||
@@ -786,6 +903,51 @@ def _series_finite_difference_at(
|
||||
return (values[right] - values[left]) / dt
|
||||
|
||||
|
||||
def _series_one_sided_differences_at(
|
||||
*,
|
||||
times: tuple[float, ...] | list[float],
|
||||
values: tuple[float, ...] | list[float],
|
||||
time_s: float,
|
||||
) -> tuple[float, float]:
|
||||
if len(times) != len(values):
|
||||
raise ValueError("times and values must have equal length")
|
||||
if len(times) < 2:
|
||||
raise ValueError("at least two samples are required")
|
||||
index = min(range(len(times)), key=lambda idx: abs(times[idx] - time_s))
|
||||
left = max(index - 1, 0)
|
||||
right = min(index + 1, len(times) - 1)
|
||||
backward_dt = times[index] - times[left]
|
||||
forward_dt = times[right] - times[index]
|
||||
if backward_dt == 0.0:
|
||||
backward = (values[right] - values[index]) / forward_dt
|
||||
else:
|
||||
backward = (values[index] - values[left]) / backward_dt
|
||||
if forward_dt == 0.0:
|
||||
forward = (values[index] - values[left]) / backward_dt
|
||||
else:
|
||||
forward = (values[right] - values[index]) / forward_dt
|
||||
return backward, forward
|
||||
|
||||
|
||||
def _reference_enthalpy_flow_for_node_port(
|
||||
*,
|
||||
gas: AmesimPneumaticGas,
|
||||
reference_temperature_k: float,
|
||||
flow_kg_s: float,
|
||||
node_temperature_k: float,
|
||||
connected_temperature_k: float,
|
||||
port_mass_flow_kg_s: float,
|
||||
) -> float:
|
||||
stream_temperature_k = (
|
||||
node_temperature_k if flow_kg_s >= 0.0 else connected_temperature_k
|
||||
)
|
||||
reference_h = gas.specific_reference_enthalpy(
|
||||
stream_temperature_k,
|
||||
reference_temperature_k,
|
||||
)
|
||||
return port_mass_flow_kg_s * reference_h
|
||||
|
||||
|
||||
def _pnl0001_energy_flow_diagnostic(
|
||||
*,
|
||||
closure: object,
|
||||
@@ -854,18 +1016,10 @@ def _pnl0001_energy_flow_diagnostic(
|
||||
reference_temperature_k = 298.15
|
||||
|
||||
def reference_h(temperature_k: float) -> float:
|
||||
return line.gas.cp * (temperature_k - reference_temperature_k)
|
||||
|
||||
def reference_enthalpy_flow(
|
||||
*,
|
||||
flow_kg_s: float,
|
||||
node_temperature_k: float,
|
||||
connected_temperature_k: float,
|
||||
) -> float:
|
||||
stream_temperature_k = (
|
||||
node_temperature_k if flow_kg_s >= 0.0 else connected_temperature_k
|
||||
return line.gas.specific_reference_enthalpy(
|
||||
temperature_k,
|
||||
reference_temperature_k,
|
||||
)
|
||||
return flow_kg_s * reference_h(stream_temperature_k)
|
||||
|
||||
amesim_stream_temperature = (
|
||||
amesim_value(f"t2@{line_alias}")
|
||||
@@ -884,20 +1038,29 @@ def _pnl0001_energy_flow_diagnostic(
|
||||
)
|
||||
python_reference_node_port_2 = sum(
|
||||
(
|
||||
reference_enthalpy_flow(
|
||||
_reference_enthalpy_flow_for_node_port(
|
||||
gas=line.gas,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
flow_kg_s=snapshot.p4_port3_remote_node_to_line_flow,
|
||||
node_temperature_k=snapshot.p4_port3_remote_primary_line.T,
|
||||
connected_temperature_k=snapshot.p4_port3_line.T,
|
||||
port_mass_flow_kg_s=-snapshot.p4_port3_remote_node_to_line_flow,
|
||||
),
|
||||
reference_enthalpy_flow(
|
||||
_reference_enthalpy_flow_for_node_port(
|
||||
gas=line.gas,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
flow_kg_s=snapshot.p4_port3_remote_to_port3_line_flow,
|
||||
node_temperature_k=snapshot.p4_port3_remote_primary_line.T,
|
||||
connected_temperature_k=snapshot.p4_port3_remote_port3_line.T,
|
||||
port_mass_flow_kg_s=-snapshot.p4_port3_remote_to_port3_line_flow,
|
||||
),
|
||||
reference_enthalpy_flow(
|
||||
_reference_enthalpy_flow_for_node_port(
|
||||
gas=line.gas,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
flow_kg_s=snapshot.p4_port3_remote_orifice_to_node_flow,
|
||||
node_temperature_k=snapshot.p4_port3_remote_orifice_line_port_2.T,
|
||||
connected_temperature_k=snapshot.p4_port3_remote_primary_line.T,
|
||||
port_mass_flow_kg_s=snapshot.p4_port3_remote_orifice_to_node_flow,
|
||||
),
|
||||
)
|
||||
)
|
||||
@@ -1034,6 +1197,545 @@ def _pnl0001_energy_flow_diagnostic(
|
||||
),
|
||||
)
|
||||
|
||||
def _p4_node_enthalpy_breakdown_diagnostic(
|
||||
*,
|
||||
closure: object,
|
||||
amesim_results: AmesimResults,
|
||||
state_vector: list[float],
|
||||
node_alias: str,
|
||||
time_s: float,
|
||||
) -> TestMqlP4NodeEnthalpyBreakdownDiagnostic:
|
||||
if node_alias != "pnnode4_16":
|
||||
raise KeyError(f"Unsupported P4 node enthalpy diagnostic: {node_alias}")
|
||||
|
||||
snapshot = closure.snapshot_at(time_s, state_vector).pneumatic
|
||||
line = closure.pneumatic_closure.components.p4_port3_remote_primary_line
|
||||
balance = snapshot.p4_port3_remote_balance
|
||||
reference_temperature_k = 298.15
|
||||
|
||||
def amesim_value(data_path: str) -> float:
|
||||
return interpolate_series_value(
|
||||
amesim_results.times,
|
||||
amesim_results.series(data_path),
|
||||
time_s,
|
||||
)
|
||||
|
||||
amesim_port_1_enthalpy = amesim_value("dh1@pneumatic_83")
|
||||
amesim_port_1_mass = amesim_value("dm1@pneumatic_83")
|
||||
amesim_port_3_enthalpy = amesim_value("dh2@pneumatic_95")
|
||||
amesim_port_3_mass = amesim_value("dm2@pneumatic_95")
|
||||
amesim_port_4_enthalpy = amesim_value("dh2@pn_morifice_1")
|
||||
amesim_port_4_mass = amesim_value("dm2@pn_morifice_1")
|
||||
amesim_port_2_enthalpy = amesim_value(f"dh2@{node_alias}")
|
||||
amesim_port_2_mass = amesim_value(f"dm2@{node_alias}")
|
||||
|
||||
reference_port_1 = _reference_enthalpy_flow_for_node_port(
|
||||
gas=line.gas,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
flow_kg_s=snapshot.p4_port3_remote_node_to_line_flow,
|
||||
node_temperature_k=snapshot.p4_port3_remote_primary_line.T,
|
||||
connected_temperature_k=snapshot.p4_port3_line.T,
|
||||
port_mass_flow_kg_s=-snapshot.p4_port3_remote_node_to_line_flow,
|
||||
)
|
||||
reference_port_3 = _reference_enthalpy_flow_for_node_port(
|
||||
gas=line.gas,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
flow_kg_s=snapshot.p4_port3_remote_to_port3_line_flow,
|
||||
node_temperature_k=snapshot.p4_port3_remote_primary_line.T,
|
||||
connected_temperature_k=snapshot.p4_port3_remote_port3_line.T,
|
||||
port_mass_flow_kg_s=-snapshot.p4_port3_remote_to_port3_line_flow,
|
||||
)
|
||||
reference_port_4 = _reference_enthalpy_flow_for_node_port(
|
||||
gas=line.gas,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
flow_kg_s=snapshot.p4_port3_remote_orifice_to_node_flow,
|
||||
node_temperature_k=snapshot.p4_port3_remote_orifice_line_port_2.T,
|
||||
connected_temperature_k=snapshot.p4_port3_remote_primary_line.T,
|
||||
port_mass_flow_kg_s=snapshot.p4_port3_remote_orifice_to_node_flow,
|
||||
)
|
||||
reference_port_2 = reference_port_1 + reference_port_3 + reference_port_4
|
||||
|
||||
return TestMqlP4NodeEnthalpyBreakdownDiagnostic(
|
||||
node_alias=node_alias,
|
||||
time_s=time_s,
|
||||
amesim_port_1_enthalpy_flow_w=amesim_port_1_enthalpy,
|
||||
amesim_port_1_mass_flow_g_s=amesim_port_1_mass,
|
||||
amesim_port_3_enthalpy_flow_w=amesim_port_3_enthalpy,
|
||||
amesim_port_3_mass_flow_g_s=amesim_port_3_mass,
|
||||
amesim_port_4_enthalpy_flow_w=amesim_port_4_enthalpy,
|
||||
amesim_port_4_mass_flow_g_s=amesim_port_4_mass,
|
||||
amesim_port_2_enthalpy_flow_w=amesim_port_2_enthalpy,
|
||||
amesim_port_2_mass_flow_g_s=amesim_port_2_mass,
|
||||
python_port_1_enthalpy_flow_w=balance.port_1_enthalpy_flow_w,
|
||||
python_port_1_mass_flow_g_s=balance.port_1_mass_flow_g_s,
|
||||
python_port_3_enthalpy_flow_w=balance.port_3_enthalpy_flow_w,
|
||||
python_port_3_mass_flow_g_s=balance.port_3_mass_flow_g_s,
|
||||
python_port_4_enthalpy_flow_w=balance.port_4_enthalpy_flow_w,
|
||||
python_port_4_mass_flow_g_s=balance.port_4_mass_flow_g_s,
|
||||
python_port_2_enthalpy_flow_w=balance.port_2_enthalpy_flow_w,
|
||||
python_port_2_mass_flow_g_s=balance.port_2_mass_flow_g_s,
|
||||
python_reference_port_1_enthalpy_flow_w=reference_port_1,
|
||||
python_reference_port_3_enthalpy_flow_w=reference_port_3,
|
||||
python_reference_port_4_enthalpy_flow_w=reference_port_4,
|
||||
python_reference_port_2_enthalpy_flow_w=reference_port_2,
|
||||
python_port_2_enthalpy_error_w=(
|
||||
balance.port_2_enthalpy_flow_w - amesim_port_2_enthalpy
|
||||
),
|
||||
python_reference_port_2_enthalpy_error_w=(
|
||||
reference_port_2 - amesim_port_2_enthalpy
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _pnvo_upstream_enthalpy_diagnostic(
|
||||
*,
|
||||
closure: object,
|
||||
amesim_results: AmesimResults,
|
||||
state_vector: list[float],
|
||||
orifice_alias: str,
|
||||
upstream_line_alias: str,
|
||||
downstream_node_alias: str,
|
||||
time_s: float,
|
||||
) -> TestMqlPnvoUpstreamEnthalpyDiagnostic:
|
||||
if orifice_alias != "pn_morifice_1":
|
||||
raise KeyError(f"Unsupported PNVO upstream diagnostic: {orifice_alias}")
|
||||
if upstream_line_alias != "pneumatic_87":
|
||||
raise KeyError(f"Unsupported PNVO upstream line diagnostic: {upstream_line_alias}")
|
||||
if downstream_node_alias != "pnnode4_16":
|
||||
raise KeyError(f"Unsupported PNVO downstream node diagnostic: {downstream_node_alias}")
|
||||
|
||||
snapshot = closure.snapshot_at(time_s, state_vector).pneumatic
|
||||
line = closure.pneumatic_closure.components.p4_port3_remote_orifice_line
|
||||
flow_kg_s = snapshot.p4_port3_remote_orifice_to_node_flow
|
||||
reference_temperature_k = 298.15
|
||||
|
||||
def amesim_value(data_path: str) -> float:
|
||||
return interpolate_series_value(
|
||||
amesim_results.times,
|
||||
amesim_results.series(data_path),
|
||||
time_s,
|
||||
)
|
||||
|
||||
amesim_orifice_dh2 = amesim_value(f"dh2@{orifice_alias}")
|
||||
amesim_orifice_dm2 = amesim_value(f"dm2@{orifice_alias}")
|
||||
amesim_line_t2 = amesim_value(f"t2@{upstream_line_alias}")
|
||||
if amesim_orifice_dm2 >= 0.0:
|
||||
amesim_stream_temperature = amesim_line_t2
|
||||
amesim_stream_pressure = (
|
||||
amesim_value(f"p2@{upstream_line_alias}")
|
||||
+ AMESIM_REFERENCE_PRESSURE_PA
|
||||
)
|
||||
else:
|
||||
amesim_stream_temperature = amesim_value(f"temp1@{downstream_node_alias}")
|
||||
amesim_stream_pressure = (
|
||||
amesim_value(f"press1@{downstream_node_alias}")
|
||||
+ AMESIM_REFERENCE_PRESSURE_PA
|
||||
)
|
||||
amesim_dm2_kg_s = amesim_orifice_dm2 * 1.0e-3
|
||||
amesim_reference_dh2 = amesim_dm2_kg_s * line.gas.specific_reference_enthalpy(
|
||||
amesim_stream_temperature,
|
||||
reference_temperature_k,
|
||||
)
|
||||
amesim_real_gas_reference_dh2 = (
|
||||
amesim_dm2_kg_s
|
||||
* line.gas.pressure_reference_enthalpy(
|
||||
amesim_stream_pressure,
|
||||
amesim_stream_temperature,
|
||||
reference_pressure=AMESIM_REFERENCE_PRESSURE_PA,
|
||||
reference_temperature=reference_temperature_k,
|
||||
)
|
||||
)
|
||||
if abs(amesim_orifice_dm2) <= 1.0e-12:
|
||||
amesim_implied_temperature = amesim_stream_temperature
|
||||
else:
|
||||
amesim_implied_temperature = line.gas.reference_temperature_from_specific_enthalpy(
|
||||
amesim_orifice_dh2 / (amesim_orifice_dm2 * 1.0e-3),
|
||||
reference_temperature_k,
|
||||
)
|
||||
|
||||
python_stream_properties = (
|
||||
snapshot.p4_port3_remote_orifice_line_port_2
|
||||
if flow_kg_s >= 0.0
|
||||
else snapshot.p4_port3_remote_primary_line
|
||||
)
|
||||
python_current_dh2 = flow_kg_s * python_stream_properties.h
|
||||
python_reference_dh2 = flow_kg_s * line.gas.specific_reference_enthalpy(
|
||||
python_stream_properties.T,
|
||||
reference_temperature_k,
|
||||
)
|
||||
python_real_gas_reference_dh2 = flow_kg_s * line.gas.pressure_reference_enthalpy(
|
||||
python_stream_properties.p,
|
||||
python_stream_properties.T,
|
||||
reference_pressure=AMESIM_REFERENCE_PRESSURE_PA,
|
||||
reference_temperature=reference_temperature_k,
|
||||
)
|
||||
|
||||
return TestMqlPnvoUpstreamEnthalpyDiagnostic(
|
||||
orifice_alias=orifice_alias,
|
||||
upstream_line_alias=upstream_line_alias,
|
||||
time_s=time_s,
|
||||
amesim_orifice_port_2_enthalpy_flow_w=amesim_orifice_dh2,
|
||||
amesim_orifice_port_2_mass_flow_g_s=amesim_orifice_dm2,
|
||||
amesim_orifice_port_3_enthalpy_flow_w=amesim_value(
|
||||
f"dh3@{orifice_alias}"
|
||||
),
|
||||
amesim_orifice_port_3_mass_flow_g_s=amesim_value(
|
||||
f"dm3@{orifice_alias}"
|
||||
),
|
||||
amesim_upstream_line_center_enthalpy_flow_w=amesim_value(
|
||||
f"dhctr@{upstream_line_alias}"
|
||||
),
|
||||
amesim_upstream_line_center_mass_flow_g_s=amesim_value(
|
||||
f"dmctr@{upstream_line_alias}"
|
||||
),
|
||||
amesim_upstream_line_port_2_temperature_k=amesim_line_t2,
|
||||
amesim_upstream_line_port_2_pressure_pa=amesim_stream_pressure,
|
||||
amesim_orifice_port_2_implied_reference_temperature_k=(
|
||||
amesim_implied_temperature
|
||||
),
|
||||
amesim_orifice_port_2_implied_temperature_delta_to_line_k=(
|
||||
amesim_implied_temperature - amesim_line_t2
|
||||
),
|
||||
amesim_upstream_line_port_2_reference_enthalpy_flow_w=amesim_reference_dh2,
|
||||
amesim_upstream_line_port_2_reference_enthalpy_error_w=(
|
||||
amesim_reference_dh2 - amesim_orifice_dh2
|
||||
),
|
||||
amesim_upstream_line_port_2_real_gas_reference_enthalpy_flow_w=(
|
||||
amesim_real_gas_reference_dh2
|
||||
),
|
||||
amesim_upstream_line_port_2_real_gas_reference_enthalpy_error_w=(
|
||||
amesim_real_gas_reference_dh2 - amesim_orifice_dh2
|
||||
),
|
||||
python_orifice_to_node_flow_kg_s=flow_kg_s,
|
||||
python_upstream_line_port_2_temperature_k=(
|
||||
snapshot.p4_port3_remote_orifice_line_port_2.T
|
||||
),
|
||||
python_upstream_line_port_2_pressure_pa=python_stream_properties.p,
|
||||
python_current_port_2_enthalpy_flow_w=python_current_dh2,
|
||||
python_reference_port_2_enthalpy_flow_w=python_reference_dh2,
|
||||
python_real_gas_reference_port_2_enthalpy_flow_w=(
|
||||
python_real_gas_reference_dh2
|
||||
),
|
||||
python_current_port_2_enthalpy_error_w=(
|
||||
python_current_dh2 - amesim_orifice_dh2
|
||||
),
|
||||
python_reference_port_2_enthalpy_error_w=(
|
||||
python_reference_dh2 - amesim_orifice_dh2
|
||||
),
|
||||
python_real_gas_reference_port_2_enthalpy_error_w=(
|
||||
python_real_gas_reference_dh2 - amesim_orifice_dh2
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _pn2vol_reference_dtemp(
|
||||
*,
|
||||
gas: AmesimPneumaticGas,
|
||||
temperature_k: float,
|
||||
mass_kg: float,
|
||||
mass_derivative_kg_s: float,
|
||||
enthalpy_flow_w: float,
|
||||
heat_flow_w: float,
|
||||
reference_temperature_k: float = 298.15,
|
||||
) -> float:
|
||||
reference_offset_flow_w = (
|
||||
gas.cp * reference_temperature_k - gas.cv * temperature_k
|
||||
) * mass_derivative_kg_s
|
||||
return (enthalpy_flow_w + reference_offset_flow_w + heat_flow_w) / (
|
||||
mass_kg * gas.cv
|
||||
)
|
||||
|
||||
|
||||
def _actual_reference_enthalpy_flow(
|
||||
*,
|
||||
gas: AmesimPneumaticGas,
|
||||
port_m_flow: float,
|
||||
connected_pressure_pa: float,
|
||||
connected_temperature_k: float,
|
||||
internal_pressure_pa: float,
|
||||
internal_temperature_k: float,
|
||||
reference_temperature_k: float = 298.15,
|
||||
) -> float:
|
||||
if port_m_flow > 0.0:
|
||||
pressure = connected_pressure_pa
|
||||
temperature = connected_temperature_k
|
||||
else:
|
||||
pressure = internal_pressure_pa
|
||||
temperature = internal_temperature_k
|
||||
return port_m_flow * gas.pressure_reference_enthalpy(
|
||||
pressure,
|
||||
temperature,
|
||||
reference_pressure=AMESIM_REFERENCE_PRESSURE_PA,
|
||||
reference_temperature=reference_temperature_k,
|
||||
)
|
||||
|
||||
|
||||
def _pnl0003_energy_diagnostic(
|
||||
*,
|
||||
closure: object,
|
||||
amesim_results: AmesimResults,
|
||||
state_vector: list[float],
|
||||
line_alias: str,
|
||||
time_s: float,
|
||||
) -> TestMqlPnl0003EnergyDiagnostic:
|
||||
if line_alias != "pneumatic_87":
|
||||
raise KeyError(f"Unsupported PNL0003 energy diagnostic: {line_alias}")
|
||||
|
||||
snapshot = closure.snapshot_at(time_s, state_vector).pneumatic
|
||||
line = closure.pneumatic_closure.components.p4_port3_remote_orifice_line
|
||||
port_1 = snapshot.p4_port3_remote_orifice_line_port_1
|
||||
port_2 = snapshot.p4_port3_remote_orifice_line_port_2
|
||||
connected_port_2 = snapshot.p4_port3_remote_primary_line
|
||||
center_flow = snapshot.p4_port3_remote_orifice_line_center_flow
|
||||
port_1_flow = snapshot.p4_port3_remote_node_to_orifice_line_flow
|
||||
port_2_flow = -snapshot.p4_port3_remote_orifice_to_node_flow
|
||||
reference_temperature_k = 298.15
|
||||
|
||||
def amesim_value(data_path: str) -> float:
|
||||
return interpolate_series_value(
|
||||
amesim_results.times,
|
||||
amesim_results.series(data_path),
|
||||
time_s,
|
||||
)
|
||||
|
||||
amesim_t1 = amesim_value(f"t1@{line_alias}")
|
||||
amesim_t2 = amesim_value(f"t2@{line_alias}")
|
||||
amesim_p1 = amesim_value(f"p1@{line_alias}") + AMESIM_REFERENCE_PRESSURE_PA
|
||||
amesim_p2 = amesim_value(f"p2@{line_alias}") + AMESIM_REFERENCE_PRESSURE_PA
|
||||
amesim_dm1 = amesim_value("dm2@pn_node3_8")
|
||||
amesim_dh1 = amesim_value("dh2@pn_node3_8")
|
||||
amesim_dm2 = amesim_value("dm3@pn_morifice_1")
|
||||
amesim_dh2 = amesim_value("dh3@pn_morifice_1")
|
||||
amesim_dmctr = amesim_value(f"dmctr@{line_alias}")
|
||||
amesim_dhctr = amesim_value(f"dhctr@{line_alias}")
|
||||
amesim_sdm1_kg_s = (amesim_dm1 + amesim_dmctr) * 1.0e-3
|
||||
amesim_sdm2_kg_s = (amesim_dm2 - amesim_dmctr) * 1.0e-3
|
||||
amesim_sdh1 = amesim_dh1 + amesim_dhctr
|
||||
amesim_sdh2 = amesim_dh2 - amesim_dhctr
|
||||
amesim_mgas_series = amesim_results.series(f"mgas@{line_alias}")
|
||||
amesim_total_mass_derivative_fd = _series_finite_difference_at(
|
||||
times=amesim_results.times,
|
||||
values=amesim_mgas_series,
|
||||
time_s=time_s,
|
||||
)
|
||||
(
|
||||
amesim_total_mass_derivative_backward,
|
||||
amesim_total_mass_derivative_forward,
|
||||
) = _series_one_sided_differences_at(
|
||||
times=amesim_results.times,
|
||||
values=amesim_mgas_series,
|
||||
time_s=time_s,
|
||||
)
|
||||
amesim_total_storage_mass_derivative = (
|
||||
amesim_sdm1_kg_s + amesim_sdm2_kg_s
|
||||
) * 1.0e3
|
||||
python_center_mass_flow_g_s = center_flow * 1.0e3
|
||||
amesim_center_python_sign_equivalent_g_s = -amesim_dmctr
|
||||
amesim_mass_1 = line.gas.density(amesim_p1, amesim_t1) * line.compliance_volume
|
||||
amesim_mass_2 = line.gas.density(amesim_p2, amesim_t2) * line.compliance_volume
|
||||
heat_flow_1 = (
|
||||
line.heat_transfer_coefficient
|
||||
* line.heat_transfer_area
|
||||
* 0.5
|
||||
* (line.external_temperature - amesim_t1)
|
||||
)
|
||||
heat_flow_2 = (
|
||||
line.heat_transfer_coefficient
|
||||
* line.heat_transfer_area
|
||||
* 0.5
|
||||
* (line.external_temperature - amesim_t2)
|
||||
)
|
||||
amesim_pn2vol_dtemp_1 = _pn2vol_reference_dtemp(
|
||||
gas=line.gas,
|
||||
temperature_k=amesim_t1,
|
||||
mass_kg=amesim_mass_1,
|
||||
mass_derivative_kg_s=amesim_sdm1_kg_s,
|
||||
enthalpy_flow_w=amesim_sdh1,
|
||||
heat_flow_w=heat_flow_1,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
)
|
||||
amesim_pn2vol_dtemp_2 = _pn2vol_reference_dtemp(
|
||||
gas=line.gas,
|
||||
temperature_k=amesim_t2,
|
||||
mass_kg=amesim_mass_2,
|
||||
mass_derivative_kg_s=amesim_sdm2_kg_s,
|
||||
enthalpy_flow_w=amesim_sdh2,
|
||||
heat_flow_w=heat_flow_2,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
)
|
||||
amesim_t1_series = amesim_results.series(f"t1@{line_alias}")
|
||||
amesim_t2_series = amesim_results.series(f"t2@{line_alias}")
|
||||
amesim_fd_dtemp_1 = _series_finite_difference_at(
|
||||
times=amesim_results.times,
|
||||
values=amesim_t1_series,
|
||||
time_s=time_s,
|
||||
)
|
||||
amesim_fd_dtemp_2 = _series_finite_difference_at(
|
||||
times=amesim_results.times,
|
||||
values=amesim_t2_series,
|
||||
time_s=time_s,
|
||||
)
|
||||
amesim_backward_dtemp_1, amesim_forward_dtemp_1 = (
|
||||
_series_one_sided_differences_at(
|
||||
times=amesim_results.times,
|
||||
values=amesim_t1_series,
|
||||
time_s=time_s,
|
||||
)
|
||||
)
|
||||
amesim_backward_dtemp_2, amesim_forward_dtemp_2 = (
|
||||
_series_one_sided_differences_at(
|
||||
times=amesim_results.times,
|
||||
values=amesim_t2_series,
|
||||
time_s=time_s,
|
||||
)
|
||||
)
|
||||
|
||||
current_derivative_1, current_derivative_2 = line.derivatives_from_connections(
|
||||
port_1_m_flow=port_1_flow,
|
||||
connected_h_1=port_1.h,
|
||||
port_2_m_flow=port_2_flow,
|
||||
connected_h_2=connected_port_2.h,
|
||||
)
|
||||
python_current_dtemp_1 = (
|
||||
current_derivative_1.U - port_1.u * current_derivative_1.m
|
||||
) / (line.state_1.m * line.gas.cv)
|
||||
python_current_dtemp_2 = (
|
||||
current_derivative_2.U - port_2.u * current_derivative_2.m
|
||||
) / (line.state_2.m * line.gas.cv)
|
||||
|
||||
python_center_dh_1 = _actual_reference_enthalpy_flow(
|
||||
gas=line.gas,
|
||||
port_m_flow=-center_flow,
|
||||
connected_pressure_pa=port_2.p,
|
||||
connected_temperature_k=port_2.T,
|
||||
internal_pressure_pa=port_1.p,
|
||||
internal_temperature_k=port_1.T,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
)
|
||||
python_center_dh_2 = _actual_reference_enthalpy_flow(
|
||||
gas=line.gas,
|
||||
port_m_flow=center_flow,
|
||||
connected_pressure_pa=port_1.p,
|
||||
connected_temperature_k=port_1.T,
|
||||
internal_pressure_pa=port_2.p,
|
||||
internal_temperature_k=port_2.T,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
)
|
||||
python_port_1_dh = _actual_reference_enthalpy_flow(
|
||||
gas=line.gas,
|
||||
port_m_flow=port_1_flow,
|
||||
connected_pressure_pa=port_1.p,
|
||||
connected_temperature_k=port_1.T,
|
||||
internal_pressure_pa=port_1.p,
|
||||
internal_temperature_k=port_1.T,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
)
|
||||
python_port_2_dh = _actual_reference_enthalpy_flow(
|
||||
gas=line.gas,
|
||||
port_m_flow=port_2_flow,
|
||||
connected_pressure_pa=connected_port_2.p,
|
||||
connected_temperature_k=connected_port_2.T,
|
||||
internal_pressure_pa=port_2.p,
|
||||
internal_temperature_k=port_2.T,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
)
|
||||
python_heat_flow_1 = (
|
||||
line.heat_transfer_coefficient
|
||||
* line.heat_transfer_area
|
||||
* 0.5
|
||||
* (line.external_temperature - port_1.T)
|
||||
)
|
||||
python_heat_flow_2 = (
|
||||
line.heat_transfer_coefficient
|
||||
* line.heat_transfer_area
|
||||
* 0.5
|
||||
* (line.external_temperature - port_2.T)
|
||||
)
|
||||
python_ref_dtemp_1 = _pn2vol_reference_dtemp(
|
||||
gas=line.gas,
|
||||
temperature_k=port_1.T,
|
||||
mass_kg=line.state_1.m,
|
||||
mass_derivative_kg_s=port_1_flow - center_flow,
|
||||
enthalpy_flow_w=python_port_1_dh + python_center_dh_1,
|
||||
heat_flow_w=python_heat_flow_1,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
)
|
||||
python_ref_dtemp_2 = _pn2vol_reference_dtemp(
|
||||
gas=line.gas,
|
||||
temperature_k=port_2.T,
|
||||
mass_kg=line.state_2.m,
|
||||
mass_derivative_kg_s=port_2_flow + center_flow,
|
||||
enthalpy_flow_w=python_port_2_dh + python_center_dh_2,
|
||||
heat_flow_w=python_heat_flow_2,
|
||||
reference_temperature_k=reference_temperature_k,
|
||||
)
|
||||
|
||||
return TestMqlPnl0003EnergyDiagnostic(
|
||||
line_alias=line_alias,
|
||||
time_s=time_s,
|
||||
amesim_port_1_temperature_k=amesim_t1,
|
||||
amesim_port_2_temperature_k=amesim_t2,
|
||||
amesim_port_1_pressure_pa=amesim_p1,
|
||||
amesim_port_2_pressure_pa=amesim_p2,
|
||||
amesim_port_1_mass_flow_g_s=amesim_dm1,
|
||||
amesim_port_1_enthalpy_flow_w=amesim_dh1,
|
||||
amesim_center_mass_flow_g_s=amesim_dmctr,
|
||||
amesim_center_enthalpy_flow_w=amesim_dhctr,
|
||||
amesim_port_2_mass_flow_g_s=amesim_dm2,
|
||||
amesim_port_2_enthalpy_flow_w=amesim_dh2,
|
||||
amesim_port_1_storage_mass_derivative_g_s=amesim_sdm1_kg_s * 1.0e3,
|
||||
amesim_port_1_storage_enthalpy_sum_w=amesim_sdh1,
|
||||
amesim_port_2_storage_mass_derivative_g_s=amesim_sdm2_kg_s * 1.0e3,
|
||||
amesim_port_2_storage_enthalpy_sum_w=amesim_sdh2,
|
||||
amesim_total_mass_derivative_fd_g_s=amesim_total_mass_derivative_fd,
|
||||
amesim_total_mass_derivative_backward_g_s=(
|
||||
amesim_total_mass_derivative_backward
|
||||
),
|
||||
amesim_total_mass_derivative_forward_g_s=(
|
||||
amesim_total_mass_derivative_forward
|
||||
),
|
||||
amesim_total_storage_mass_derivative_g_s=(
|
||||
amesim_total_storage_mass_derivative
|
||||
),
|
||||
amesim_total_storage_mass_derivative_residual_g_s=(
|
||||
amesim_total_storage_mass_derivative - amesim_total_mass_derivative_fd
|
||||
),
|
||||
amesim_center_flow_python_sign_equivalent_g_s=(
|
||||
amesim_center_python_sign_equivalent_g_s
|
||||
),
|
||||
amesim_center_flow_python_sign_error_g_s=(
|
||||
python_center_mass_flow_g_s - amesim_center_python_sign_equivalent_g_s
|
||||
),
|
||||
python_center_mass_flow_g_s=python_center_mass_flow_g_s,
|
||||
python_total_mass_derivative_kg_s=(
|
||||
current_derivative_1.m + current_derivative_2.m
|
||||
),
|
||||
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,
|
||||
amesim_port_2_temperature_derivative_fd_k_s=amesim_fd_dtemp_2,
|
||||
amesim_port_2_temperature_derivative_backward_k_s=amesim_backward_dtemp_2,
|
||||
amesim_port_2_temperature_derivative_forward_k_s=amesim_forward_dtemp_2,
|
||||
amesim_port_1_pn2vol_dtemp_k_s=amesim_pn2vol_dtemp_1,
|
||||
amesim_port_2_pn2vol_dtemp_k_s=amesim_pn2vol_dtemp_2,
|
||||
amesim_port_1_pn2vol_dtemp_residual_k_s=(
|
||||
amesim_pn2vol_dtemp_1 - amesim_fd_dtemp_1
|
||||
),
|
||||
amesim_port_2_pn2vol_dtemp_residual_k_s=(
|
||||
amesim_pn2vol_dtemp_2 - amesim_fd_dtemp_2
|
||||
),
|
||||
python_port_1_temperature_k=port_1.T,
|
||||
python_port_2_temperature_k=port_2.T,
|
||||
python_port_1_pressure_pa=port_1.p,
|
||||
python_port_2_pressure_pa=port_2.p,
|
||||
python_port_1_mass_derivative_kg_s=current_derivative_1.m,
|
||||
python_port_2_mass_derivative_kg_s=current_derivative_2.m,
|
||||
python_port_1_current_dtemp_k_s=python_current_dtemp_1,
|
||||
python_port_2_current_dtemp_k_s=python_current_dtemp_2,
|
||||
python_port_1_real_gas_reference_dtemp_k_s=python_ref_dtemp_1,
|
||||
python_port_2_real_gas_reference_dtemp_k_s=python_ref_dtemp_2,
|
||||
python_port_2_temperature_error_to_amesim_k=port_2.T - amesim_t2,
|
||||
)
|
||||
|
||||
|
||||
def _pnch012_energy_equation_diagnostic(
|
||||
@@ -1407,6 +2109,35 @@ def run_test_mql_pnvo_event_window_diagnostic(
|
||||
time_s=sample_time,
|
||||
),
|
||||
)
|
||||
p4_node_enthalpy_breakdown_diagnostics = (
|
||||
_p4_node_enthalpy_breakdown_diagnostic(
|
||||
closure=closure,
|
||||
amesim_results=amesim_results,
|
||||
state_vector=state_vector_by_sample_time[sample_time],
|
||||
node_alias="pnnode4_16",
|
||||
time_s=sample_time,
|
||||
),
|
||||
)
|
||||
pnvo_upstream_enthalpy_diagnostics = (
|
||||
_pnvo_upstream_enthalpy_diagnostic(
|
||||
closure=closure,
|
||||
amesim_results=amesim_results,
|
||||
state_vector=state_vector_by_sample_time[sample_time],
|
||||
orifice_alias=orifice_alias,
|
||||
upstream_line_alias="pneumatic_87",
|
||||
downstream_node_alias="pnnode4_16",
|
||||
time_s=sample_time,
|
||||
),
|
||||
)
|
||||
pnl0003_energy_diagnostics = (
|
||||
_pnl0003_energy_diagnostic(
|
||||
closure=closure,
|
||||
amesim_results=amesim_results,
|
||||
state_vector=state_vector_by_sample_time[sample_time],
|
||||
line_alias="pneumatic_87",
|
||||
time_s=sample_time,
|
||||
),
|
||||
)
|
||||
pnch012_rhs_diagnostics = (
|
||||
closure.variable_chamber_rhs_diagnostic(
|
||||
chamber_alias="pn_c1_8",
|
||||
@@ -1436,6 +2167,13 @@ def run_test_mql_pnvo_event_window_diagnostic(
|
||||
pnl0001_pressure_loss_diagnostics=pnl0001_pressure_loss_diagnostics,
|
||||
pnvo_flow_parameter_diagnostics=pnvo_flow_parameter_diagnostics,
|
||||
pnl0001_energy_flow_diagnostics=pnl0001_energy_flow_diagnostics,
|
||||
p4_node_enthalpy_breakdown_diagnostics=(
|
||||
p4_node_enthalpy_breakdown_diagnostics
|
||||
),
|
||||
pnvo_upstream_enthalpy_diagnostics=(
|
||||
pnvo_upstream_enthalpy_diagnostics
|
||||
),
|
||||
pnl0003_energy_diagnostics=pnl0003_energy_diagnostics,
|
||||
pnch012_energy_equation_diagnostics=(
|
||||
pnch012_energy_equation_diagnostics
|
||||
),
|
||||
@@ -1535,6 +2273,104 @@ def format_test_mql_pnvo_event_window_summary(
|
||||
f"upstream_t={flow_parameter.python_upstream_temperature_k}, "
|
||||
f"amesim_gasvel={flow_parameter.amesim_gas_velocity_m_s}"
|
||||
)
|
||||
for pnvo_enthalpy in sample.pnvo_upstream_enthalpy_diagnostics:
|
||||
lines.append(
|
||||
f" - pnvo_upstream_enthalpy@{pnvo_enthalpy.orifice_alias}: "
|
||||
f"amesim_dh2="
|
||||
f"{pnvo_enthalpy.amesim_orifice_port_2_enthalpy_flow_w}, "
|
||||
f"amesim_dm2="
|
||||
f"{pnvo_enthalpy.amesim_orifice_port_2_mass_flow_g_s}, "
|
||||
f"amesim_dh3="
|
||||
f"{pnvo_enthalpy.amesim_orifice_port_3_enthalpy_flow_w}, "
|
||||
f"amesim_dm3="
|
||||
f"{pnvo_enthalpy.amesim_orifice_port_3_mass_flow_g_s}, "
|
||||
f"amesim_line_dhctr="
|
||||
f"{pnvo_enthalpy.amesim_upstream_line_center_enthalpy_flow_w}, "
|
||||
f"amesim_line_dmctr="
|
||||
f"{pnvo_enthalpy.amesim_upstream_line_center_mass_flow_g_s}, "
|
||||
f"amesim_line_t2="
|
||||
f"{pnvo_enthalpy.amesim_upstream_line_port_2_temperature_k}, "
|
||||
f"amesim_line_p2_abs="
|
||||
f"{pnvo_enthalpy.amesim_upstream_line_port_2_pressure_pa}, "
|
||||
f"amesim_implied_t2="
|
||||
f"{pnvo_enthalpy.amesim_orifice_port_2_implied_reference_temperature_k}, "
|
||||
f"amesim_implied_t2_delta="
|
||||
f"{pnvo_enthalpy.amesim_orifice_port_2_implied_temperature_delta_to_line_k}, "
|
||||
f"amesim_ref_dh2="
|
||||
f"{pnvo_enthalpy.amesim_upstream_line_port_2_reference_enthalpy_flow_w}, "
|
||||
f"amesim_ref_dh2_error="
|
||||
f"{pnvo_enthalpy.amesim_upstream_line_port_2_reference_enthalpy_error_w}, "
|
||||
f"amesim_real_ref_dh2="
|
||||
f"{pnvo_enthalpy.amesim_upstream_line_port_2_real_gas_reference_enthalpy_flow_w}, "
|
||||
f"amesim_real_ref_dh2_error="
|
||||
f"{pnvo_enthalpy.amesim_upstream_line_port_2_real_gas_reference_enthalpy_error_w}, "
|
||||
f"python_flow="
|
||||
f"{pnvo_enthalpy.python_orifice_to_node_flow_kg_s}, "
|
||||
f"python_line_t2="
|
||||
f"{pnvo_enthalpy.python_upstream_line_port_2_temperature_k}, "
|
||||
f"python_line_p2_abs="
|
||||
f"{pnvo_enthalpy.python_upstream_line_port_2_pressure_pa}, "
|
||||
f"python_current_dh2="
|
||||
f"{pnvo_enthalpy.python_current_port_2_enthalpy_flow_w}, "
|
||||
f"python_ref_dh2="
|
||||
f"{pnvo_enthalpy.python_reference_port_2_enthalpy_flow_w}, "
|
||||
f"python_real_ref_dh2="
|
||||
f"{pnvo_enthalpy.python_real_gas_reference_port_2_enthalpy_flow_w}, "
|
||||
f"python_current_dh2_error="
|
||||
f"{pnvo_enthalpy.python_current_port_2_enthalpy_error_w}, "
|
||||
f"python_ref_dh2_error="
|
||||
f"{pnvo_enthalpy.python_reference_port_2_enthalpy_error_w}, "
|
||||
f"python_real_ref_dh2_error="
|
||||
f"{pnvo_enthalpy.python_real_gas_reference_port_2_enthalpy_error_w}"
|
||||
)
|
||||
for pnl0003_energy in sample.pnl0003_energy_diagnostics:
|
||||
lines.append(
|
||||
f" - pnl0003_energy@{pnl0003_energy.line_alias}: "
|
||||
f"amesim_t1={pnl0003_energy.amesim_port_1_temperature_k}, "
|
||||
f"amesim_t2={pnl0003_energy.amesim_port_2_temperature_k}, "
|
||||
f"amesim_p1_abs={pnl0003_energy.amesim_port_1_pressure_pa}, "
|
||||
f"amesim_p2_abs={pnl0003_energy.amesim_port_2_pressure_pa}, "
|
||||
f"amesim_dm1={pnl0003_energy.amesim_port_1_mass_flow_g_s}, "
|
||||
f"amesim_dh1={pnl0003_energy.amesim_port_1_enthalpy_flow_w}, "
|
||||
f"amesim_dmctr={pnl0003_energy.amesim_center_mass_flow_g_s}, "
|
||||
f"amesim_dhctr={pnl0003_energy.amesim_center_enthalpy_flow_w}, "
|
||||
f"amesim_dm2={pnl0003_energy.amesim_port_2_mass_flow_g_s}, "
|
||||
f"amesim_dh2={pnl0003_energy.amesim_port_2_enthalpy_flow_w}, "
|
||||
f"amesim_sdm1={pnl0003_energy.amesim_port_1_storage_mass_derivative_g_s}, "
|
||||
f"amesim_sdh1={pnl0003_energy.amesim_port_1_storage_enthalpy_sum_w}, "
|
||||
f"amesim_sdm2={pnl0003_energy.amesim_port_2_storage_mass_derivative_g_s}, "
|
||||
f"amesim_sdh2={pnl0003_energy.amesim_port_2_storage_enthalpy_sum_w}, "
|
||||
f"amesim_fd_dmgas={pnl0003_energy.amesim_total_mass_derivative_fd_g_s}, "
|
||||
f"amesim_back_dmgas={pnl0003_energy.amesim_total_mass_derivative_backward_g_s}, "
|
||||
f"amesim_fwd_dmgas={pnl0003_energy.amesim_total_mass_derivative_forward_g_s}, "
|
||||
f"amesim_storage_dmgas={pnl0003_energy.amesim_total_storage_mass_derivative_g_s}, "
|
||||
f"amesim_storage_dmgas_residual={pnl0003_energy.amesim_total_storage_mass_derivative_residual_g_s}, "
|
||||
f"amesim_dmctr_py_sign={pnl0003_energy.amesim_center_flow_python_sign_equivalent_g_s}, "
|
||||
f"python_center_dm={pnl0003_energy.python_center_mass_flow_g_s}, "
|
||||
f"python_center_dm_error={pnl0003_energy.amesim_center_flow_python_sign_error_g_s}, "
|
||||
f"python_dmgas_dt={pnl0003_energy.python_total_mass_derivative_kg_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}, "
|
||||
f"amesim_fd_dT2={pnl0003_energy.amesim_port_2_temperature_derivative_fd_k_s}, "
|
||||
f"amesim_back_dT2={pnl0003_energy.amesim_port_2_temperature_derivative_backward_k_s}, "
|
||||
f"amesim_fwd_dT2={pnl0003_energy.amesim_port_2_temperature_derivative_forward_k_s}, "
|
||||
f"amesim_pn2vol_dT1={pnl0003_energy.amesim_port_1_pn2vol_dtemp_k_s}, "
|
||||
f"amesim_pn2vol_dT2={pnl0003_energy.amesim_port_2_pn2vol_dtemp_k_s}, "
|
||||
f"amesim_pn2vol_dT1_residual={pnl0003_energy.amesim_port_1_pn2vol_dtemp_residual_k_s}, "
|
||||
f"amesim_pn2vol_dT2_residual={pnl0003_energy.amesim_port_2_pn2vol_dtemp_residual_k_s}, "
|
||||
f"python_t1={pnl0003_energy.python_port_1_temperature_k}, "
|
||||
f"python_t2={pnl0003_energy.python_port_2_temperature_k}, "
|
||||
f"python_p1_abs={pnl0003_energy.python_port_1_pressure_pa}, "
|
||||
f"python_p2_abs={pnl0003_energy.python_port_2_pressure_pa}, "
|
||||
f"python_dm1_dt={pnl0003_energy.python_port_1_mass_derivative_kg_s}, "
|
||||
f"python_dm2_dt={pnl0003_energy.python_port_2_mass_derivative_kg_s}, "
|
||||
f"python_current_dT1={pnl0003_energy.python_port_1_current_dtemp_k_s}, "
|
||||
f"python_current_dT2={pnl0003_energy.python_port_2_current_dtemp_k_s}, "
|
||||
f"python_real_ref_dT1={pnl0003_energy.python_port_1_real_gas_reference_dtemp_k_s}, "
|
||||
f"python_real_ref_dT2={pnl0003_energy.python_port_2_real_gas_reference_dtemp_k_s}, "
|
||||
f"python_t2_error={pnl0003_energy.python_port_2_temperature_error_to_amesim_k}"
|
||||
)
|
||||
for energy_flow in sample.pnl0001_energy_flow_diagnostics:
|
||||
lines.append(
|
||||
f" - energy_flow@{energy_flow.line_alias}: "
|
||||
@@ -1603,6 +2439,38 @@ def format_test_mql_pnvo_event_window_summary(
|
||||
f"python_ref_pn2vol2_dT_node_minus_dh1="
|
||||
f"{energy_flow.python_reference_pn2vol2_dtemp_node_minus_dh1_k_s}"
|
||||
)
|
||||
for p4_node in sample.p4_node_enthalpy_breakdown_diagnostics:
|
||||
lines.append(
|
||||
f" - p4_node_enthalpy@{p4_node.node_alias}: "
|
||||
f"amesim_p1_dh={p4_node.amesim_port_1_enthalpy_flow_w}, "
|
||||
f"amesim_p1_dm={p4_node.amesim_port_1_mass_flow_g_s}, "
|
||||
f"amesim_p3_dh={p4_node.amesim_port_3_enthalpy_flow_w}, "
|
||||
f"amesim_p3_dm={p4_node.amesim_port_3_mass_flow_g_s}, "
|
||||
f"amesim_p4_dh={p4_node.amesim_port_4_enthalpy_flow_w}, "
|
||||
f"amesim_p4_dm={p4_node.amesim_port_4_mass_flow_g_s}, "
|
||||
f"amesim_p2_dh={p4_node.amesim_port_2_enthalpy_flow_w}, "
|
||||
f"amesim_p2_dm={p4_node.amesim_port_2_mass_flow_g_s}, "
|
||||
f"python_p1_dh={p4_node.python_port_1_enthalpy_flow_w}, "
|
||||
f"python_p1_dm={p4_node.python_port_1_mass_flow_g_s}, "
|
||||
f"python_p3_dh={p4_node.python_port_3_enthalpy_flow_w}, "
|
||||
f"python_p3_dm={p4_node.python_port_3_mass_flow_g_s}, "
|
||||
f"python_p4_dh={p4_node.python_port_4_enthalpy_flow_w}, "
|
||||
f"python_p4_dm={p4_node.python_port_4_mass_flow_g_s}, "
|
||||
f"python_p2_dh={p4_node.python_port_2_enthalpy_flow_w}, "
|
||||
f"python_p2_dm={p4_node.python_port_2_mass_flow_g_s}, "
|
||||
f"python_ref_p1_dh="
|
||||
f"{p4_node.python_reference_port_1_enthalpy_flow_w}, "
|
||||
f"python_ref_p3_dh="
|
||||
f"{p4_node.python_reference_port_3_enthalpy_flow_w}, "
|
||||
f"python_ref_p4_dh="
|
||||
f"{p4_node.python_reference_port_4_enthalpy_flow_w}, "
|
||||
f"python_ref_p2_dh="
|
||||
f"{p4_node.python_reference_port_2_enthalpy_flow_w}, "
|
||||
f"python_p2_dh_error="
|
||||
f"{p4_node.python_port_2_enthalpy_error_w}, "
|
||||
f"python_ref_p2_dh_error="
|
||||
f"{p4_node.python_reference_port_2_enthalpy_error_w}"
|
||||
)
|
||||
for chamber_energy in sample.pnch012_energy_equation_diagnostics:
|
||||
lines.append(
|
||||
f" - pnch012_energy@{chamber_energy.chamber_alias}: "
|
||||
|
||||
Reference in new issue
Block a user