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

Classes

class  Fluid

Functions

None _validate (str name, float value)

Variables

dict _PAIR_BY_KWARGS
dict _PAIR_BY_ORDERED
tuple _SNAPSHOT_PROPS = ("p", "T", "rho", "h", "s", "u", "cp", "cv", "mu", "k", "a", "Z")
dict _STRICTLY_POSITIVE
dict _UNIT_FRACTION = {"q": "vapour quality [-]"}
dict _FAST_LOW = {name: 0.0 for name in (*_STRICTLY_POSITIVE, "q")}
dict _FAST_HIGH = {"q": 1.0}
dict _FAST_RESOLVE
 ChainEntry = str | PropertyBackend
int _MEMO_ENTRIES = 512

Detailed Description

The caller-facing handle: a fluid you can ask for properties.

``Fluid`` is a thin thing over a *chain* of backends::

    n2 = Fluid("nitrogen")            # ["bicubic", "heos"]
    n2.get("rho", p=3.1e7, T=293.0)   # ~0.13 us, from tables
    n2.get("rho", p=5.0e9, T=293.0)   # tables refuse; the EOS answers

The chain is the whole design. "Fast where possible, exact where necessary,
measured where we have data" is a list, not a branch -- so adding a source means
adding an element, and no call site learns about it.

Threading
---------
Backends wrap mutable cursors: ``update`` moves them, ``value`` reads wherever
they were last moved. Two threads sharing one would interleave into nonsense
that never raises -- each would read the other's state point. Every backend is
therefore **thread-confined**: built per thread, on demand, and never handed
across. A ``Fluid`` is safe to share; the backends underneath it are not, and
never leave.

Function Documentation

◆ _validate()

None feedtwin.props.fluid._validate ( str name,
float value )
protected

Variable Documentation

◆ _FAST_HIGH

dict feedtwin.props.fluid._FAST_HIGH = {"q": 1.0}
protected

Definition at line 91 of file fluid.py.

◆ _FAST_LOW

dict feedtwin.props.fluid._FAST_LOW = {name: 0.0 for name in (*_STRICTLY_POSITIVE, "q")}
protected

Definition at line 90 of file fluid.py.

◆ _FAST_RESOLVE

dict feedtwin.props.fluid._FAST_RESOLVE
protected
Initial value:
1= {
2 order: (
3 pair,
4 order == names,
5 order[0],
6 _FAST_LOW.get(order[0], -math.inf),
7 _FAST_HIGH.get(order[0], math.inf),
8 order[1],
9 _FAST_LOW.get(order[1], -math.inf),
10 _FAST_HIGH.get(order[1], math.inf),
11 )
12 for order, (pair, names) in _PAIR_BY_ORDERED.items()
13}

Definition at line 92 of file fluid.py.

◆ _MEMO_ENTRIES

int feedtwin.props.fluid._MEMO_ENTRIES = 512
protected

Definition at line 143 of file fluid.py.

◆ _PAIR_BY_KWARGS

dict feedtwin.props.fluid._PAIR_BY_KWARGS
protected
Initial value:
1= {
2 frozenset({"p", "T"}): (StatePair.PT, ("p", "T")),
3 frozenset({"p", "h"}): (StatePair.PH, ("p", "h")),
4 frozenset({"p", "s"}): (StatePair.PS, ("p", "s")),
5 frozenset({"p", "q"}): (StatePair.PQ, ("p", "q")),
6 frozenset({"T", "q"}): (StatePair.TQ, ("T", "q")),
7 frozenset({"p", "rho"}): (StatePair.PD, ("p", "rho")),
8 frozenset({"h", "s"}): (StatePair.HS, ("h", "s")),
9 frozenset({"rho", "T"}): (StatePair.DT, ("rho", "T")),
10 frozenset({"rho", "u"}): (StatePair.DU, ("rho", "u")),
11}

Definition at line 41 of file fluid.py.

◆ _PAIR_BY_ORDERED

dict feedtwin.props.fluid._PAIR_BY_ORDERED
protected
Initial value:
1= {
2 order: entry
3 for keys, entry in _PAIR_BY_KWARGS.items()
4 for order in ((tuple(sorted(keys))), tuple(reversed(sorted(keys))))
5}

Definition at line 59 of file fluid.py.

◆ _SNAPSHOT_PROPS

tuple feedtwin.props.fluid._SNAPSHOT_PROPS = ("p", "T", "rho", "h", "s", "u", "cp", "cv", "mu", "k", "a", "Z")
protected

Definition at line 66 of file fluid.py.

◆ _STRICTLY_POSITIVE

dict feedtwin.props.fluid._STRICTLY_POSITIVE
protected
Initial value:
1= {
2 "p": "pressure [Pa]",
3 "T": "temperature [K]",
4 "rho": "density [kg/m^3]",
5}

Definition at line 75 of file fluid.py.

◆ _UNIT_FRACTION

dict feedtwin.props.fluid._UNIT_FRACTION = {"q": "vapour quality [-]"}
protected

Definition at line 81 of file fluid.py.

◆ ChainEntry

feedtwin.props.fluid.ChainEntry = str | PropertyBackend

Definition at line 130 of file fluid.py.