STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
feedtwin.props.backends.coolprop Namespace Reference

Classes

class  _Dome
class  CoolPropBackend

Functions

float warm_tables (SpeciesSpec species)
PropertyBackend _heos (SpeciesSpec species)
PropertyBackend _bicubic (SpeciesSpec species)

Variables

float R_UNIVERSAL = 8.31446261815324
dict _INPUT_PAIRS
frozenset _SWAPPED = frozenset({StatePair.PH, StatePair.TQ, StatePair.PD})
frozenset _GUARDED = frozenset({StatePair.PT, StatePair.PH, StatePair.DT})
dict _PHASES
dict _GETTERS
tuple _OUT_OF_RANGE_MARKERS = ("not in range", "outside", "out of range")
tuple _UNSUPPORTED_MARKERS = ("is not implemented", "not implemented for this backend")
float DOME_LIQUID_K = 16.0
float DOME_VAPOUR_K = 16.0
tuple DOME_CRITICAL_SHARE = (0.75, 2.5)
float DOME_CRITICAL_K = 30.0
float DOME_DENSE_SHARE = 0.25
int DOME_POINTS = 400

Detailed Description

CoolProp-backed properties: Helmholtz equations of state, and tables over them.

One class serves both. ``HEOS`` evaluates the Helmholtz energy directly and
covers everything the equation of state is defined over; ``BICUBIC&HEOS``
interpolates precomputed tables over the same equation and is 10-30x faster
inside a bounded region. They differ by a backend string, not by a code path,
which is what keeps "fast where possible, exact where necessary" from turning
into two implementations that drift.

Measured on the development host, nitrogen, per call (update + read):

=============  ========  ===========  =========
property         HEOS      BICUBIC     speedup
=============  ========  ===========  =========
density         3.17 us     0.128 us     24.8x
viscosity       3.39 us     0.129 us     26.2x
conductivity    4.25 us     0.127 us     33.5x
cp              3.35 us     0.188 us     17.8x
speed of sound  3.16 us     0.331 us      9.6x
=============  ========  ===========  =========

Two behaviours of the tabulated backend shape the design:

**It refuses rather than extrapolates.** Outside its envelope it raises
``ValueError: inputs are not in range`` instead of returning a plausible wrong
number. That is the good failure, and it is what makes the fallback chain in
:mod:`feedtwin.props.fluid` sound -- translated here into :class:`OutOfRange`.

**It does not implement every property.** ``compressibility_factor`` is missing
on BICUBIC. Rather than special-case that, Z is *derived* here for every backend
as ``p / (rho . R_specific . T)``, which reproduces CoolProp's own value to
3e-6. Deriving it means one definition of Z regardless of backend.

Building tables costs 2-3 s per fluid on first use and about 17 MB on disk, in
CoolProp's own cache. See :func:`warm_tables`.

Function Documentation

◆ _bicubic()

PropertyBackend feedtwin.props.backends.coolprop._bicubic ( SpeciesSpec species)
protected

Definition at line 429 of file coolprop.py.

◆ _heos()

PropertyBackend feedtwin.props.backends.coolprop._heos ( SpeciesSpec species)
protected

Definition at line 425 of file coolprop.py.

◆ warm_tables()

float feedtwin.props.backends.coolprop.warm_tables ( SpeciesSpec species)
Build this species' interpolation tables now instead of on first use.

Returns the seconds spent. Costs 2-3 s and ~17 MB per fluid the first time
on a machine, then loads from CoolProp's cache.

Worth calling explicitly in a worker process, for the same reason
EngineDesign's accelerator front-loads its JIT: paying it lazily means the
cost lands inside whatever call happens to be first, which is usually a
solve someone is timing.

Definition at line 404 of file coolprop.py.

Variable Documentation

◆ _GETTERS

dict feedtwin.props.backends.coolprop._GETTERS
protected
Initial value:
1= {
2 "p": lambda s: float(s.p()),
3 "T": lambda s: float(s.T()),
4 "rho": lambda s: float(s.rhomass()),
5 "h": lambda s: float(s.hmass()),
6 "s": lambda s: float(s.smass()),
7 "u": lambda s: float(s.umass()),
8 "cp": lambda s: float(s.cpmass()),
9 "cv": lambda s: float(s.cvmass()),
10 "mu": lambda s: float(s.viscosity()),
11 "k": lambda s: float(s.conductivity()),
12 "a": lambda s: float(s.speed_sound()),
13 "molar_mass": lambda s: float(s.molar_mass()),
14}

Definition at line 99 of file coolprop.py.

◆ _GUARDED

frozenset feedtwin.props.backends.coolprop._GUARDED = frozenset({StatePair.PT, StatePair.PH, StatePair.DT})
protected

Definition at line 85 of file coolprop.py.

◆ _INPUT_PAIRS

dict feedtwin.props.backends.coolprop._INPUT_PAIRS
protected
Initial value:
1= {
2 StatePair.PT: CP.PT_INPUTS,
3 StatePair.PH: CP.HmassP_INPUTS,
4 StatePair.PS: CP.PSmass_INPUTS,
5 StatePair.PQ: CP.PQ_INPUTS,
6 StatePair.TQ: CP.QT_INPUTS,
7 StatePair.PD: CP.DmassP_INPUTS,
8 StatePair.HS: CP.HmassSmass_INPUTS,
9 StatePair.DT: CP.DmassT_INPUTS,
10 StatePair.DU: CP.DmassUmass_INPUTS,
11}

Definition at line 65 of file coolprop.py.

◆ _OUT_OF_RANGE_MARKERS

tuple feedtwin.props.backends.coolprop._OUT_OF_RANGE_MARKERS = ("not in range", "outside", "out of range")
protected

Definition at line 118 of file coolprop.py.

◆ _PHASES

dict feedtwin.props.backends.coolprop._PHASES
protected
Initial value:
1= {
2 CP.iphase_liquid: Phase.LIQUID,
3 CP.iphase_gas: Phase.GAS,
4 CP.iphase_twophase: Phase.TWO_PHASE,
5 CP.iphase_supercritical: Phase.SUPERCRITICAL,
6 CP.iphase_supercritical_gas: Phase.SUPERCRITICAL_GAS,
7 CP.iphase_supercritical_liquid: Phase.SUPERCRITICAL_LIQUID,
8 CP.iphase_critical_point: Phase.CRITICAL_POINT,
9}

Definition at line 88 of file coolprop.py.

◆ _SWAPPED

frozenset feedtwin.props.backends.coolprop._SWAPPED = frozenset({StatePair.PH, StatePair.TQ, StatePair.PD})
protected

Definition at line 80 of file coolprop.py.

◆ _UNSUPPORTED_MARKERS

tuple feedtwin.props.backends.coolprop._UNSUPPORTED_MARKERS = ("is not implemented", "not implemented for this backend")
protected

Definition at line 120 of file coolprop.py.

◆ DOME_CRITICAL_K

float feedtwin.props.backends.coolprop.DOME_CRITICAL_K = 30.0

Definition at line 146 of file coolprop.py.

◆ DOME_CRITICAL_SHARE

tuple feedtwin.props.backends.coolprop.DOME_CRITICAL_SHARE = (0.75, 2.5)

Definition at line 144 of file coolprop.py.

◆ DOME_DENSE_SHARE

float feedtwin.props.backends.coolprop.DOME_DENSE_SHARE = 0.25

Definition at line 150 of file coolprop.py.

◆ DOME_LIQUID_K

float feedtwin.props.backends.coolprop.DOME_LIQUID_K = 16.0

Definition at line 132 of file coolprop.py.

◆ DOME_POINTS

int feedtwin.props.backends.coolprop.DOME_POINTS = 400

Definition at line 152 of file coolprop.py.

◆ DOME_VAPOUR_K

float feedtwin.props.backends.coolprop.DOME_VAPOUR_K = 16.0

Definition at line 133 of file coolprop.py.

◆ R_UNIVERSAL

float feedtwin.props.backends.coolprop.R_UNIVERSAL = 8.31446261815324

Definition at line 54 of file coolprop.py.