接入AMESim help文档与PNVO流量诊断
This commit is contained in:
1 parent
f0f8f40c7a
commit
84d1675292
17 files changed
+450
-7
No files matched your search
@@ -332,7 +332,8 @@ class AmesimPneumaticOrifice(AlgebraicComponent):
|
||||
|
||||
@property
|
||||
def effective_area(self) -> float:
|
||||
return self.area * max(self.opening, 0.0)
|
||||
opening = min(max(self.opening, 0.0), 1.0)
|
||||
return self.area * opening
|
||||
|
||||
def mass_flow(self, p_a: float, p_b: float, upstream_temperature: float) -> float:
|
||||
if p_a == p_b or self.effective_area == 0.0 or self.flow_coefficient == 0.0:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from math import log10, pi
|
||||
from math import log10, pi, sqrt
|
||||
|
||||
from PythonModels.components.amesim_pneumatic import (
|
||||
HELIUM_PNEUMATIC_GAS,
|
||||
@@ -112,10 +112,11 @@ class AmesimPnl0001Pipe(_DarcyPipeResistanceMixin, DynamicComponent):
|
||||
resistance. Both connection mass flows use the PythonModels convention:
|
||||
positive values enter the pipe storage.
|
||||
|
||||
AMESim's proprietary pressure-loss calibration is not available in the
|
||||
archive. This implementation therefore uses an explicit Darcy-Weisbach
|
||||
law while preserving the real geometry, state count, mass/energy balance,
|
||||
heat-transfer parameter, and observable diagnostics.
|
||||
AMESim's proprietary ``pn2pipefr`` utility is represented by an
|
||||
optional calibrated linear conductance when a model-specific baseline
|
||||
supports it; otherwise the component falls back to an auditable
|
||||
Darcy-Weisbach law. Both paths preserve the real geometry, state count,
|
||||
mass/energy balance, heat-transfer parameter, and observable diagnostics.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@@ -128,6 +129,7 @@ class AmesimPnl0001Pipe(_DarcyPipeResistanceMixin, DynamicComponent):
|
||||
polytropic_constant: float = 1.35,
|
||||
heat_transfer_coefficient: float = 0.0,
|
||||
external_temperature_k: float = 293.15,
|
||||
calibrated_linear_conductance: float | None = None,
|
||||
gas: AmesimPneumaticGas = HELIUM_PNEUMATIC_GAS,
|
||||
p0: float = 101_325.0,
|
||||
T0: float = 293.15,
|
||||
@@ -144,6 +146,11 @@ class AmesimPnl0001Pipe(_DarcyPipeResistanceMixin, DynamicComponent):
|
||||
raise ValueError("heat_transfer_coefficient must be non-negative")
|
||||
if external_temperature_k <= 0.0:
|
||||
raise ValueError("external_temperature_k must be positive")
|
||||
if (
|
||||
calibrated_linear_conductance is not None
|
||||
and calibrated_linear_conductance <= 0.0
|
||||
):
|
||||
raise ValueError("calibrated_linear_conductance must be positive")
|
||||
|
||||
super().__init__(name=name)
|
||||
self.diameter = diameter_mm * 1.0e-3
|
||||
@@ -152,6 +159,7 @@ class AmesimPnl0001Pipe(_DarcyPipeResistanceMixin, DynamicComponent):
|
||||
self.polytropic_constant = polytropic_constant
|
||||
self.heat_transfer_coefficient = heat_transfer_coefficient
|
||||
self.external_temperature = external_temperature_k
|
||||
self.calibrated_linear_conductance = calibrated_linear_conductance
|
||||
self.gas = gas
|
||||
self.area = diameter_mm_to_area_m2(diameter_mm)
|
||||
self.volume = self.area * self.length
|
||||
@@ -210,6 +218,12 @@ class AmesimPnl0001Pipe(_DarcyPipeResistanceMixin, DynamicComponent):
|
||||
pressure_difference = port_1_pressure_pa - internal.p
|
||||
if pressure_difference == 0.0:
|
||||
return 0.0
|
||||
if self.calibrated_linear_conductance is not None:
|
||||
return (
|
||||
self.calibrated_linear_conductance
|
||||
* pressure_difference
|
||||
/ sqrt(internal.T)
|
||||
)
|
||||
upstream_pressure = max(port_1_pressure_pa, internal.p)
|
||||
upstream_temperature = (
|
||||
port_1_temperature_k if pressure_difference > 0.0 else internal.T
|
||||
@@ -246,6 +260,24 @@ class AmesimPnl0001Pipe(_DarcyPipeResistanceMixin, DynamicComponent):
|
||||
pressure_drop_pa=pressure_drop,
|
||||
)
|
||||
|
||||
def darcy_pressure_drop_for_state(
|
||||
self,
|
||||
*,
|
||||
mass_flow_kg_s: float,
|
||||
pressure_pa: float,
|
||||
temperature_k: float,
|
||||
) -> float:
|
||||
if pressure_pa <= 0.0:
|
||||
raise ValueError("pressure_pa must be positive")
|
||||
if temperature_k <= 0.0:
|
||||
raise ValueError("temperature_k must be positive")
|
||||
density = self.gas.density(pressure_pa, temperature_k)
|
||||
return self._darcy_pressure_drop(
|
||||
mass_flow_kg_s,
|
||||
density=density,
|
||||
temperature=temperature_k,
|
||||
)
|
||||
|
||||
def derivatives_from_connections(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in new issue
Block a user