对齐PNVO近等压层流平滑
This commit is contained in:
1 parent
e9fc855a1c
commit
40c72422ff
2 files changed
+149
-15
No files matched your search
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
from math import isclose, sqrt
|
||||
from math import isclose, log, sqrt, tanh
|
||||
|
||||
from app.simulation.components.amesim.gases import (
|
||||
AMESIM_GAS_INDEX_PARAMETER,
|
||||
@@ -32,6 +32,8 @@ _FLOW_COEFFICIENT_OPTIONS = (
|
||||
_FLOWSET_USES_CQ = (ParameterCondition("flowset", (1.0,)),)
|
||||
_FLOWSET_USES_CV = (ParameterCondition("flowset", (2.0,)),)
|
||||
_FLOWSET_USES_KV = (ParameterCondition("flowset", (3.0,)),)
|
||||
_PN_PRESSURE_RATIO_ACCURACY = 0.9999
|
||||
_PN_LAMINAR_SMOOTHING_GAIN = 12.0
|
||||
_PNOR001_FLOW_COEFFICIENT_GROUP = ParameterGroupDisplaySpec(
|
||||
id="flow_coefficient",
|
||||
label="流量系数",
|
||||
@@ -565,6 +567,31 @@ class AmesimPnvo001FixedOpening(AlgebraicComponent):
|
||||
1.0,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _subsonic_mass_flow_parameter(
|
||||
*,
|
||||
pressure_ratio: float,
|
||||
gamma_s: float,
|
||||
density: float,
|
||||
upstream_temperature: float,
|
||||
upstream_pressure: float,
|
||||
) -> float:
|
||||
expansion = (
|
||||
pressure_ratio ** (2.0 * gamma_s)
|
||||
- pressure_ratio ** (1.0 + gamma_s)
|
||||
)
|
||||
return sqrt(
|
||||
max(
|
||||
2.0
|
||||
/ (1.0 - gamma_s)
|
||||
* density
|
||||
* upstream_temperature
|
||||
/ upstream_pressure
|
||||
* expansion,
|
||||
0.0,
|
||||
)
|
||||
)
|
||||
|
||||
def mass_flow(self, p_2: float, p_3: float) -> float:
|
||||
if p_2 == p_3 or self.effective_area == 0.0:
|
||||
return 0.0
|
||||
@@ -602,6 +629,7 @@ class AmesimPnvo001FixedOpening(AlgebraicComponent):
|
||||
1.0 / (1.0 - gamma_s)
|
||||
)
|
||||
if pressure_ratio <= critical_ratio:
|
||||
effective_pressure_ratio = critical_ratio
|
||||
mass_flow_parameter = (
|
||||
sqrt(2.0 / (1.0 + gamma_s) * density * T_up / p_up)
|
||||
* (2.0 * gamma_s / (gamma_s + 1.0))
|
||||
@@ -611,20 +639,13 @@ class AmesimPnvo001FixedOpening(AlgebraicComponent):
|
||||
2.0 / (1.0 + gamma_s) * p_up / density
|
||||
)
|
||||
else:
|
||||
expansion = (
|
||||
pressure_ratio ** (2.0 * gamma_s)
|
||||
- pressure_ratio ** (1.0 + gamma_s)
|
||||
)
|
||||
mass_flow_parameter = sqrt(
|
||||
max(
|
||||
2.0
|
||||
/ (1.0 - gamma_s)
|
||||
* density
|
||||
* T_up
|
||||
/ p_up
|
||||
* expansion,
|
||||
0.0,
|
||||
)
|
||||
effective_pressure_ratio = pressure_ratio
|
||||
mass_flow_parameter = self._subsonic_mass_flow_parameter(
|
||||
pressure_ratio=pressure_ratio,
|
||||
gamma_s=gamma_s,
|
||||
density=density,
|
||||
upstream_temperature=T_up,
|
||||
upstream_pressure=p_up,
|
||||
)
|
||||
gas_velocity = sqrt(
|
||||
max(
|
||||
@@ -636,6 +657,29 @@ class AmesimPnvo001FixedOpening(AlgebraicComponent):
|
||||
0.0,
|
||||
)
|
||||
)
|
||||
|
||||
# AMESim's gas_cm_prc_ applies this factor continuously over the
|
||||
# complete pressure-ratio range. It is effectively one outside the
|
||||
# near-equal-pressure region and makes Cm (and vena-contracta
|
||||
# velocity) approach zero quadratically as the pressure ratio tends
|
||||
# to one. The reference Cm intentionally reuses the current gamma_s.
|
||||
reference_mass_flow_parameter = self._subsonic_mass_flow_parameter(
|
||||
pressure_ratio=_PN_PRESSURE_RATIO_ACCURACY,
|
||||
gamma_s=gamma_s,
|
||||
density=density,
|
||||
upstream_temperature=T_up,
|
||||
upstream_pressure=p_up,
|
||||
)
|
||||
if mass_flow_parameter > 0.0 and reference_mass_flow_parameter > 0.0:
|
||||
smoothing_argument = (
|
||||
_PN_LAMINAR_SMOOTHING_GAIN
|
||||
* abs(mass_flow_parameter / reference_mass_flow_parameter)
|
||||
* log(effective_pressure_ratio)
|
||||
/ log(_PN_PRESSURE_RATIO_ACCURACY)
|
||||
)
|
||||
smoothing_factor = tanh(max(smoothing_argument, 0.0))
|
||||
mass_flow_parameter *= smoothing_factor
|
||||
gas_velocity *= smoothing_factor
|
||||
return mass_flow_parameter, gas_velocity
|
||||
|
||||
def _one_way_mass_flow(
|
||||
|
||||
Reference in new issue
Block a user