接入test_mql PNVO孔口边界
This commit is contained in:
1 parent
78013b25c9
commit
5c3ad50090
3 files changed
+89
-39
No files matched your search
@@ -90,17 +90,6 @@ class TestMqlPneumaticBoundaryCondition:
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TestMqlPneumaticFlowBoundaryCondition:
|
||||
mass_flow_kg_s: float
|
||||
temperature_k: float = 293.15
|
||||
|
||||
def connected_enthalpy(self, gas: AmesimPneumaticGas) -> float:
|
||||
if self.temperature_k <= 0.0:
|
||||
raise ValueError("flow boundary temperature must be positive")
|
||||
return gas.specific_enthalpy(self.temperature_k)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TestMqlPneumaticChamberSegmentComponents:
|
||||
volume: AmesimPneumaticVolume
|
||||
@@ -167,6 +156,7 @@ class TestMqlPn3NodeChamberSegmentComponents:
|
||||
outlet_line: AmesimPnl0001Pipe
|
||||
node_line: AmesimPnl0003Pipe
|
||||
node_resistance: AmesimPnl00rPipe
|
||||
node_orifice: AmesimPneumaticOrifice
|
||||
node: TestMqlPneumaticNode3
|
||||
volume: AmesimPneumaticVolume
|
||||
inlet_orifice: AmesimPneumaticOrifice
|
||||
@@ -183,6 +173,7 @@ class TestMqlPn3NodeChamberSegmentSnapshot:
|
||||
node_line_port_2: ThermodynamicProperties
|
||||
inlet_node: ThermodynamicProperties
|
||||
resistance_boundary: ThermodynamicProperties
|
||||
p4_boundary: ThermodynamicProperties
|
||||
node_balance: TestMqlPneumaticNode3Balance
|
||||
inlet_node_to_line_flow: float
|
||||
inlet_line_to_chamber_flow: float
|
||||
@@ -191,8 +182,7 @@ class TestMqlPn3NodeChamberSegmentSnapshot:
|
||||
node_to_resistance_flow: float
|
||||
node_to_pnl0003_flow: float
|
||||
pnl0003_center_flow: float
|
||||
pnl0003_port_2_flow: float
|
||||
pnl0003_port_2_connected_h: float
|
||||
pnl0003_to_p4_flow: float
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -550,6 +540,16 @@ class TestMqlPnl0001ChamberSegmentClosure:
|
||||
self._write_port_states(snapshot)
|
||||
return snapshot
|
||||
|
||||
@staticmethod
|
||||
def _line_to_p4_flow(
|
||||
*,
|
||||
line: ThermodynamicProperties,
|
||||
p4_boundary: ThermodynamicProperties,
|
||||
orifice: AmesimPneumaticOrifice,
|
||||
) -> float:
|
||||
upstream_temperature = line.T if line.p >= p4_boundary.p else p4_boundary.T
|
||||
return orifice.mass_flow(line.p, p4_boundary.p, upstream_temperature)
|
||||
|
||||
@staticmethod
|
||||
def _port(
|
||||
component: AmesimPneumaticVolume | AmesimPneumaticOrifice,
|
||||
@@ -720,6 +720,16 @@ class TestMqlPnl0001PairChamberSegmentClosure:
|
||||
upstream_temperature = line.T if line.p >= chamber.p else chamber.T
|
||||
return orifice.mass_flow(line.p, chamber.p, upstream_temperature)
|
||||
|
||||
@staticmethod
|
||||
def _line_to_p4_flow(
|
||||
*,
|
||||
line: ThermodynamicProperties,
|
||||
p4_boundary: ThermodynamicProperties,
|
||||
orifice: AmesimPneumaticOrifice,
|
||||
) -> float:
|
||||
upstream_temperature = line.T if line.p >= p4_boundary.p else p4_boundary.T
|
||||
return orifice.mass_flow(line.p, p4_boundary.p, upstream_temperature)
|
||||
|
||||
@staticmethod
|
||||
def _port(
|
||||
component: AmesimPneumaticVolume | AmesimPneumaticOrifice,
|
||||
@@ -844,12 +854,12 @@ class TestMqlPn3NodeChamberSegmentClosure:
|
||||
components: TestMqlPn3NodeChamberSegmentComponents,
|
||||
inlet_node: TestMqlPneumaticBoundaryCondition,
|
||||
resistance_boundary: TestMqlPneumaticBoundaryCondition,
|
||||
pnl0003_port_2_flow: TestMqlPneumaticFlowBoundaryCondition,
|
||||
p4_boundary: TestMqlPneumaticBoundaryCondition,
|
||||
) -> None:
|
||||
self.components = components
|
||||
self.inlet_node = inlet_node
|
||||
self.resistance_boundary = resistance_boundary
|
||||
self.pnl0003_port_2_flow = pnl0003_port_2_flow
|
||||
self.p4_boundary = p4_boundary
|
||||
|
||||
def initial_state_vector(self) -> list[float]:
|
||||
return [
|
||||
@@ -882,6 +892,7 @@ class TestMqlPn3NodeChamberSegmentClosure:
|
||||
resistance_boundary = self.resistance_boundary.properties(
|
||||
self.components.node_resistance.gas
|
||||
)
|
||||
p4_boundary = self.p4_boundary.properties(self.components.node_line.gas)
|
||||
inlet_node_to_line_flow = self.components.inlet_line.resistance_mass_flow(
|
||||
port_1_pressure_pa=inlet_node.p,
|
||||
port_1_temperature_k=inlet_node.T,
|
||||
@@ -924,8 +935,10 @@ class TestMqlPn3NodeChamberSegmentClosure:
|
||||
)
|
||||
node_to_pnl0003_flow = -node_balance.port_2_mass_flow_g_s * 1.0e-3
|
||||
pnl0003_center_flow = self.components.node_line.resistance_mass_flow()
|
||||
pnl0003_port_2_connected_h = self.pnl0003_port_2_flow.connected_enthalpy(
|
||||
self.components.node_line.gas
|
||||
pnl0003_to_p4_flow = self._line_to_p4_flow(
|
||||
line=node_line_port_2,
|
||||
p4_boundary=p4_boundary,
|
||||
orifice=self.components.node_orifice,
|
||||
)
|
||||
snapshot = TestMqlPn3NodeChamberSegmentSnapshot(
|
||||
inlet_line=inlet_line,
|
||||
@@ -935,6 +948,7 @@ class TestMqlPn3NodeChamberSegmentClosure:
|
||||
node_line_port_2=node_line_port_2,
|
||||
inlet_node=inlet_node,
|
||||
resistance_boundary=resistance_boundary,
|
||||
p4_boundary=p4_boundary,
|
||||
node_balance=node_balance,
|
||||
inlet_node_to_line_flow=inlet_node_to_line_flow,
|
||||
inlet_line_to_chamber_flow=inlet_line_to_chamber_flow,
|
||||
@@ -943,8 +957,7 @@ class TestMqlPn3NodeChamberSegmentClosure:
|
||||
node_to_resistance_flow=node_to_resistance_flow,
|
||||
node_to_pnl0003_flow=node_to_pnl0003_flow,
|
||||
pnl0003_center_flow=pnl0003_center_flow,
|
||||
pnl0003_port_2_flow=self.pnl0003_port_2_flow.mass_flow_kg_s,
|
||||
pnl0003_port_2_connected_h=pnl0003_port_2_connected_h,
|
||||
pnl0003_to_p4_flow=pnl0003_to_p4_flow,
|
||||
)
|
||||
self._write_port_states(snapshot)
|
||||
return snapshot
|
||||
@@ -962,6 +975,16 @@ class TestMqlPn3NodeChamberSegmentClosure:
|
||||
orifice=orifice,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _line_to_p4_flow(
|
||||
*,
|
||||
line: ThermodynamicProperties,
|
||||
p4_boundary: ThermodynamicProperties,
|
||||
orifice: AmesimPneumaticOrifice,
|
||||
) -> float:
|
||||
upstream_temperature = line.T if line.p >= p4_boundary.p else p4_boundary.T
|
||||
return orifice.mass_flow(line.p, p4_boundary.p, upstream_temperature)
|
||||
|
||||
@staticmethod
|
||||
def _port(
|
||||
component: AmesimPneumaticVolume | AmesimPneumaticOrifice,
|
||||
@@ -1018,9 +1041,17 @@ class TestMqlPn3NodeChamberSegmentClosure:
|
||||
node_line.port_1.m_flow = snapshot.node_to_pnl0003_flow
|
||||
node_line.port_1.h_outflow = snapshot.node_line_port_1.h
|
||||
node_line.port_2.p = snapshot.node_line_port_2.p
|
||||
node_line.port_2.m_flow = snapshot.pnl0003_port_2_flow
|
||||
node_line.port_2.m_flow = -snapshot.pnl0003_to_p4_flow
|
||||
node_line.port_2.h_outflow = snapshot.node_line_port_2.h
|
||||
|
||||
node_orifice = self.components.node_orifice
|
||||
node_orifice.port_a.p = snapshot.node_line_port_2.p
|
||||
node_orifice.port_a.m_flow = snapshot.pnl0003_to_p4_flow
|
||||
node_orifice.port_a.h_outflow = snapshot.node_line_port_2.h
|
||||
node_orifice.port_b.p = snapshot.p4_boundary.p
|
||||
node_orifice.port_b.m_flow = -snapshot.pnl0003_to_p4_flow
|
||||
node_orifice.port_b.h_outflow = snapshot.p4_boundary.h
|
||||
|
||||
resistance = self.components.node_resistance
|
||||
resistance.port_1.p = snapshot.node_line_port_1.p
|
||||
resistance.port_1.m_flow = snapshot.node_to_resistance_flow
|
||||
@@ -1064,8 +1095,8 @@ class TestMqlPn3NodeChamberSegmentClosure:
|
||||
self.components.node_line.derivatives_from_connections(
|
||||
port_1_m_flow=snapshot.node_to_pnl0003_flow,
|
||||
connected_h_1=snapshot.node_line_port_1.h,
|
||||
port_2_m_flow=snapshot.pnl0003_port_2_flow,
|
||||
connected_h_2=snapshot.pnl0003_port_2_connected_h,
|
||||
port_2_m_flow=-snapshot.pnl0003_to_p4_flow,
|
||||
connected_h_2=snapshot.p4_boundary.h,
|
||||
)
|
||||
)
|
||||
return [
|
||||
|
||||
Reference in new issue
Block a user