58 lines
2.5 KiB
Python
58 lines
2.5 KiB
Python
"""Gas identities and constants passed to the native compiler."""
|
||
from __future__ import annotations
|
||
from collections.abc import Callable
|
||
from dataclasses import dataclass
|
||
from typing import ClassVar
|
||
from app.simulation.core.medium import GasMedium, IdealGasMedium
|
||
|
||
@dataclass(frozen=True)
|
||
class AmesimIdealAirMedium(IdealGasMedium):
|
||
SUBSTANCE_ID: ClassVar[str] = 'air'
|
||
PROPERTY_METHOD_ID: ClassVar[str] = 'ideal_gas'
|
||
name: str = 'AMESimAirIdealGas'
|
||
R_gas: float = 287.0
|
||
cp_ref: float = 1005.0
|
||
T_ref: float = 300.0
|
||
cp_slope: float = 0.0
|
||
viscosity_ref: float = 1.82e-05
|
||
viscosity_T_ref: float = 293.15
|
||
sutherland_constant: float = 110.4
|
||
|
||
@dataclass(frozen=True)
|
||
class AmesimHeliumPengRobinsonMedium(IdealGasMedium):
|
||
"""Helium identity; reference constants below describe the lower range.
|
||
|
||
The native evaluator uses Amesim's piecewise NASA heat capacity/enthalpy
|
||
(6000 K transition) and viscosity (1000/5000 K transitions), together
|
||
with PR departure properties. ``cp_ref`` is not a global constant Cp.
|
||
"""
|
||
SUBSTANCE_ID: ClassVar[str] = 'helium'
|
||
PROPERTY_METHOD_ID: ClassVar[str] = 'peng_robinson'
|
||
nasa_cp_over_R: ClassVar[float] = 2.5
|
||
nasa_enthalpy_constant_K: ClassVar[float] = -745.375
|
||
nasa_viscosity_coefficients: ClassVar[tuple[float, float, float, float]] = (0.7501594, 35.76324, -2212.129, 0.9212635)
|
||
name: str = 'AMESimHeliumPengRobinson'
|
||
R_gas: float = 8.31446261815324 / 0.004002602
|
||
cp_ref: float = 2.5 * (8.31446261815324 / 0.004002602)
|
||
T_ref: float = 293.15
|
||
cp_slope: float = 0.0
|
||
viscosity_ref: float = 1.96e-05
|
||
viscosity_T_ref: float = 293.15
|
||
sutherland_constant: float = 79.4
|
||
|
||
@dataclass(frozen=True)
|
||
class AmesimGasPropertyModelSpec:
|
||
"""A selectable calculation method for one AMESim gas substance."""
|
||
value: int
|
||
label: str
|
||
method_id: str
|
||
factory: Callable[[], GasMedium]
|
||
eos_type: int
|
||
|
||
def build_medium(self) -> GasMedium:
|
||
return self.factory()
|
||
AMESIM_AIR_IDEAL_GAS_PROPERTY_MODEL = 0
|
||
AMESIM_AIR_PROPERTY_MODELS = (AmesimGasPropertyModelSpec(value=AMESIM_AIR_IDEAL_GAS_PROPERTY_MODEL, label='理想气体', method_id=AmesimIdealAirMedium.PROPERTY_METHOD_ID, factory=AmesimIdealAirMedium, eos_type=1),)
|
||
AMESIM_HELIUM_PENG_ROBINSON_PROPERTY_MODEL = 0
|
||
AMESIM_HELIUM_PROPERTY_MODELS = (AmesimGasPropertyModelSpec(value=AMESIM_HELIUM_PENG_ROBINSON_PROPERTY_MODEL, label='Peng–Robinson', method_id=AmesimHeliumPengRobinsonMedium.PROPERTY_METHOD_ID, factory=AmesimHeliumPengRobinsonMedium, eos_type=6),)
|