merge/model-development-into-main #2
No files matched your search
@@ -1544,6 +1544,16 @@ def _pnl0003_energy_diagnostic(
|
|||||||
port_1_flow = snapshot.p4_port3_remote_node_to_orifice_line_flow
|
port_1_flow = snapshot.p4_port3_remote_node_to_orifice_line_flow
|
||||||
port_2_flow = -snapshot.p4_port3_remote_orifice_to_node_flow
|
port_2_flow = -snapshot.p4_port3_remote_orifice_to_node_flow
|
||||||
reference_temperature_k = 298.15
|
reference_temperature_k = 298.15
|
||||||
|
pn3_port_2_mass_flow_kg_s = (
|
||||||
|
snapshot.p4_port3_remote_orifice_node_balance.port_2_mass_flow_g_s * 1.0e-3
|
||||||
|
)
|
||||||
|
if abs(pn3_port_2_mass_flow_kg_s) <= 1.0e-12:
|
||||||
|
port_1_connected_h = port_1.h
|
||||||
|
else:
|
||||||
|
port_1_connected_h = (
|
||||||
|
snapshot.p4_port3_remote_orifice_node_balance.port_2_enthalpy_flow_w
|
||||||
|
/ pn3_port_2_mass_flow_kg_s
|
||||||
|
)
|
||||||
|
|
||||||
def amesim_value(data_path: str) -> float:
|
def amesim_value(data_path: str) -> float:
|
||||||
return interpolate_series_value(
|
return interpolate_series_value(
|
||||||
@@ -1646,7 +1656,7 @@ def _pnl0003_energy_diagnostic(
|
|||||||
|
|
||||||
current_derivative_1, current_derivative_2 = line.derivatives_from_connections(
|
current_derivative_1, current_derivative_2 = line.derivatives_from_connections(
|
||||||
port_1_m_flow=port_1_flow,
|
port_1_m_flow=port_1_flow,
|
||||||
connected_h_1=port_1.h,
|
connected_h_1=port_1_connected_h,
|
||||||
port_2_m_flow=port_2_flow,
|
port_2_m_flow=port_2_flow,
|
||||||
connected_h_2=connected_port_2.h,
|
connected_h_2=connected_port_2.h,
|
||||||
)
|
)
|
||||||
@@ -1675,15 +1685,20 @@ def _pnl0003_energy_diagnostic(
|
|||||||
internal_temperature_k=port_2.T,
|
internal_temperature_k=port_2.T,
|
||||||
reference_temperature_k=reference_temperature_k,
|
reference_temperature_k=reference_temperature_k,
|
||||||
)
|
)
|
||||||
python_port_1_dh = _actual_reference_enthalpy_flow(
|
if port_1_flow > 0.0:
|
||||||
gas=line.gas,
|
python_port_1_dh = port_1_flow * (
|
||||||
port_m_flow=port_1_flow,
|
port_1_connected_h - line.gas.cp * reference_temperature_k
|
||||||
connected_pressure_pa=port_1.p,
|
)
|
||||||
connected_temperature_k=port_1.T,
|
else:
|
||||||
internal_pressure_pa=port_1.p,
|
python_port_1_dh = _actual_reference_enthalpy_flow(
|
||||||
internal_temperature_k=port_1.T,
|
gas=line.gas,
|
||||||
reference_temperature_k=reference_temperature_k,
|
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(
|
python_port_2_dh = _actual_reference_enthalpy_flow(
|
||||||
gas=line.gas,
|
gas=line.gas,
|
||||||
port_m_flow=port_2_flow,
|
port_m_flow=port_2_flow,
|
||||||
|
|||||||
@@ -1913,6 +1913,17 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
|
|||||||
port_3_mass_flow_g_s=port_3.port_mass_flow_kg_s * 1.0e3,
|
port_3_mass_flow_g_s=port_3.port_mass_flow_kg_s * 1.0e3,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _pn3_node_port_2_connected_h(
|
||||||
|
*,
|
||||||
|
balance: TestMqlPneumaticNode3Balance,
|
||||||
|
fallback_h: float,
|
||||||
|
) -> float:
|
||||||
|
mass_flow_kg_s = balance.port_2_mass_flow_g_s * 1.0e-3
|
||||||
|
if abs(mass_flow_kg_s) <= 1.0e-12:
|
||||||
|
return fallback_h
|
||||||
|
return balance.port_2_enthalpy_flow_w / mass_flow_kg_s
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _p4_node_port_2_connected_h(
|
def _p4_node_port_2_connected_h(
|
||||||
*,
|
*,
|
||||||
@@ -2197,10 +2208,15 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
|
|||||||
port_1_flow: float,
|
port_1_flow: float,
|
||||||
port_2_connected_properties: ThermodynamicProperties,
|
port_2_connected_properties: ThermodynamicProperties,
|
||||||
port_2_flow: float,
|
port_2_flow: float,
|
||||||
|
port_1_connected_h: float | None = None,
|
||||||
) -> tuple[VolumeState, VolumeState]:
|
) -> tuple[VolumeState, VolumeState]:
|
||||||
return line.derivatives_from_connections(
|
return line.derivatives_from_connections(
|
||||||
port_1_m_flow=port_1_flow,
|
port_1_m_flow=port_1_flow,
|
||||||
connected_h_1=port_1_properties.h,
|
connected_h_1=(
|
||||||
|
port_1_properties.h
|
||||||
|
if port_1_connected_h is None
|
||||||
|
else port_1_connected_h
|
||||||
|
),
|
||||||
port_2_m_flow=port_2_flow,
|
port_2_m_flow=port_2_flow,
|
||||||
connected_h_2=port_2_connected_properties.h,
|
connected_h_2=port_2_connected_properties.h,
|
||||||
)
|
)
|
||||||
@@ -2884,6 +2900,10 @@ class TestMqlPn3P4NodeChamberSegmentClosure:
|
|||||||
port_1_flow=snapshot.p4_port3_remote_node_to_orifice_line_flow,
|
port_1_flow=snapshot.p4_port3_remote_node_to_orifice_line_flow,
|
||||||
port_2_connected_properties=snapshot.p4_port3_remote_primary_line,
|
port_2_connected_properties=snapshot.p4_port3_remote_primary_line,
|
||||||
port_2_flow=-snapshot.p4_port3_remote_orifice_to_node_flow,
|
port_2_flow=-snapshot.p4_port3_remote_orifice_to_node_flow,
|
||||||
|
port_1_connected_h=self._pn3_node_port_2_connected_h(
|
||||||
|
balance=snapshot.p4_port3_remote_orifice_node_balance,
|
||||||
|
fallback_h=snapshot.p4_port3_remote_orifice_line_port_1.h,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
p4_port3_next_orifice_derivative_1,
|
p4_port3_next_orifice_derivative_1,
|
||||||
|
|||||||
@@ -792,6 +792,33 @@ class TestMqlPn3P4NodeChamberSegmentTests(unittest.TestCase):
|
|||||||
].opening,
|
].opening,
|
||||||
1.0,
|
1.0,
|
||||||
)
|
)
|
||||||
|
remote_orifice_line = (
|
||||||
|
closure.pneumatic_closure.components.p4_port3_remote_orifice_line
|
||||||
|
)
|
||||||
|
custom_port_1_h = open_snapshot.p4_port3_remote_orifice_line_port_1.h + 1234.0
|
||||||
|
custom_d1, _ = closure.pneumatic_closure._two_state_connection_line_derivatives(
|
||||||
|
line=remote_orifice_line,
|
||||||
|
port_1_properties=open_snapshot.p4_port3_remote_orifice_line_port_1,
|
||||||
|
port_1_flow=0.01,
|
||||||
|
port_2_connected_properties=open_snapshot.p4_port3_remote_primary_line,
|
||||||
|
port_2_flow=-open_snapshot.p4_port3_remote_orifice_to_node_flow,
|
||||||
|
port_1_connected_h=custom_port_1_h,
|
||||||
|
)
|
||||||
|
expected_custom_d1, _ = remote_orifice_line.derivatives_from_connections(
|
||||||
|
port_1_m_flow=0.01,
|
||||||
|
connected_h_1=custom_port_1_h,
|
||||||
|
port_2_m_flow=-open_snapshot.p4_port3_remote_orifice_to_node_flow,
|
||||||
|
connected_h_2=open_snapshot.p4_port3_remote_primary_line.h,
|
||||||
|
)
|
||||||
|
default_d1, _ = closure.pneumatic_closure._two_state_connection_line_derivatives(
|
||||||
|
line=remote_orifice_line,
|
||||||
|
port_1_properties=open_snapshot.p4_port3_remote_orifice_line_port_1,
|
||||||
|
port_1_flow=0.01,
|
||||||
|
port_2_connected_properties=open_snapshot.p4_port3_remote_primary_line,
|
||||||
|
port_2_flow=-open_snapshot.p4_port3_remote_orifice_to_node_flow,
|
||||||
|
)
|
||||||
|
self.assertAlmostEqual(custom_d1.U, expected_custom_d1.U)
|
||||||
|
self.assertNotAlmostEqual(custom_d1.U, default_d1.U)
|
||||||
closure.snapshot_at(0.0, state)
|
closure.snapshot_at(0.0, state)
|
||||||
self.assertAlmostEqual(
|
self.assertAlmostEqual(
|
||||||
self.system.pneumatic_assembly.variable_orifices[
|
self.system.pneumatic_assembly.variable_orifices[
|
||||||
|
|||||||
Reference in new issue
Block a user