STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
engine.layerx.diag.regulator Namespace Reference

Functions

str coolprop_name (str fluid)
Tuple[float, float] gas_state (str fluid, float p_pa, float T_K)
Dict[str, Any] iec_gas_flow (float p1_pa, float p2_pa, float rho1, float gamma, float cv, float xT=DEFAULT_XT)
float iec_gas_drop (float mdot, float p1_pa, float rho1, float gamma, float cv, float xT=DEFAULT_XT)
str _provenance (Any component, str name)
Any _built (Any prep)
Optional[str] regulator_id (Mapping[str, Any] net)
Dict[str, Tuple[float, str]] regulator_params (Any prep, str reg_id)
str _pressurant (Any prep, Mapping[str, Any] net, str node)
Dict[str, Any] build_regulator (Mapping[str, Any] result, Any prep=None, Any config=None, *, Optional[str] reg_id=None, Optional[float] xT=None, Optional[Mapping[str, Tuple[float, str]]] params=None, Optional[str] gas=None)
Tuple[List[str], Optional[str]] _gas_reach (Mapping[str, Any] net, str side, str reg)
Any build_solenoids (Mapping[str, Any] result, Any prep=None, Any config=None, *, Optional[str] gas=None, Optional[float] xT=None)

Variables

tuple IEC_SOURCE
float DEFAULT_XT = 0.7
float MODE_BAND = 0.005
dict COOLPROP_NAMES

Detailed Description

The dome regulator's operating point and the press solenoids' drops, per twin step.

``build_regulator(result, prep, config=None, ...)`` -> ``diagnostics.regulator``;
``build_solenoids(result, prep=None, config=None, ...)`` -> ``diagnostics.solenoids``
(DATA-CONTRACT 3). Both read ``result["network"]`` (node pressures and temperatures, branch flows)
and, for the regulator, the drawing's own regulator parameters from the prepared model.

Two models, each named in its block:

* **The regulator's outlet law is feedtwin's** (``feedtwin.comps.regulator.Regulator``,
  ``outlet_setpoint``): ``p_set + S (p_ref - p_in) - D |m| / m_rated`` with ``p_set = dome + bias``
  and the dome from the control regulator's zero-flow outlet. It is evaluated here on the
  recorded inlet and flow, so the supply-pressure effect (``spe_psi``) and the droop
  (``droop_psi``) are split out of the outlet the twin produced, and ``residual_psi`` (recorded
  outlet minus that law) shows when the regulator was not on it. In feedtwin a flowing regulator
  leaves its law only when its seat's drop exceeds inlet minus target (``Regulator.is_saturated``,
  no band), which puts the outlet *under* the law, so under the law while flowing is **wide open**.
  A tolerance of 0.5 % of the setpoint is allowed before calling it (the size of the band feedtwin's
  ``Regulator.is_choked`` uses between shut and regulating), so solver noise is not read as
  saturation; the recorded residual is there for anything finer.
* **Capacity is IEC 60534-2-1 gas sizing** at the inlet node's state: the mass flow the seat
  passes wide open at this instant's inlet and outlet pressures,
  ``W = N6 Fp Kv Y sqrt(x p1 rho1)``, ``Y = 1 - x / (3 F_gamma x_T)``, ``F_gamma = gamma / 1.40``,
  ``x`` capped at ``F_gamma x_T`` where the flow chokes (IEC 60534-2-1:2011, the compressible-flow
  sizing equations; constants and the choke test from ``fluids.control_valve``). ``rho1`` and
  ``gamma`` (real gas, cp/cv) are CoolProp's at the regulator inlet node. ``use_frac`` is the
  recorded flow over that capacity. Feedtwin's own seat law is incompressible (no Y, no choke;
  AUDIT 9.6 C1), so this is the physics check the twin does not make.

The solenoids' drops are the twin's (the branch's recorded ``dp_psi``), set against the
regulator-outlet-to-tank drop on the same side (``share_of_reg_to_tank``), with the IEC 60534
drop at the recorded flow alongside, and the drop the same flow would cost through a valve of
twice the Cv (the "upgrade the 1.7 Cv solenoids?" question, AUDIT 9.6 D).

Function Documentation

◆ _built()

Any engine.layerx.diag.regulator._built ( Any prep)
protected

Definition at line 144 of file regulator.py.

Referenced by _pressurant(), build_solenoids(), and regulator_params().

◆ _gas_reach()

Tuple[List[str], Optional[str]] engine.layerx.diag.regulator._gas_reach ( Mapping[str, Any] net,
str side,
str reg )
protected
The branches from the regulator's outlet to the tank on one side, and the tank's node.

Definition at line 358 of file regulator.py.

Referenced by build_solenoids().

◆ _pressurant()

str engine.layerx.diag.regulator._pressurant ( Any prep,
Mapping[str, Any] net,
str node )
protected

Definition at line 189 of file regulator.py.

References _built().

Referenced by build_regulator(), and build_solenoids().

◆ _provenance()

str engine.layerx.diag.regulator._provenance ( Any component,
str name )
protected
'<source>: <reference>' for one of a component's declared parameters.

Definition at line 130 of file regulator.py.

Referenced by build_solenoids(), and regulator_params().

◆ build_regulator()

Dict[str, Any] engine.layerx.diag.regulator.build_regulator ( Mapping[str, Any] result,
Any prep = None,
Any config = None,
* ,
Optional[str] reg_id = None,
Optional[float] xT = None,
Optional[Mapping[str, Tuple[float, str]]] params = None,
Optional[str] gas = None )
``diagnostics.regulator``. Never raises.

``params`` ({name: (SI value, provenance)}, the names of :func:`regulator_params`) and ``gas``
stand in for ``prep`` (tests, or a saved run re-read without its model). ``xT`` overrides the
drawing's / :data:`DEFAULT_XT`.

Definition at line 204 of file regulator.py.

References _pressurant(), gas_state(), iec_gas_flow(), regulator_id(), and regulator_params().

◆ build_solenoids()

Any engine.layerx.diag.regulator.build_solenoids ( Mapping[str, Any] result,
Any prep = None,
Any config = None,
* ,
Optional[str] gas = None,
Optional[float] xT = None )
``diagnostics.solenoids``: one row per solenoid between the regulator and a tank. Never
raises (a failure is ``{available: false, error}`` in place of the list).

Definition at line 376 of file regulator.py.

References _built(), _gas_reach(), _pressurant(), _provenance(), gas_state(), iec_gas_drop(), and regulator_id().

◆ coolprop_name()

str engine.layerx.diag.regulator.coolprop_name ( str fluid)

Definition at line 67 of file regulator.py.

Referenced by gas_state().

◆ gas_state()

Tuple[float, float] engine.layerx.diag.regulator.gas_state ( str fluid,
float p_pa,
float T_K )
(rho [kg/m^3], gamma = cp/cv) from CoolProp; NaNs where CoolProp cannot answer.

Definition at line 71 of file regulator.py.

References coolprop_name().

Referenced by build_regulator(), and build_solenoids().

◆ iec_gas_drop()

float engine.layerx.diag.regulator.iec_gas_drop ( float mdot,
float p1_pa,
float rho1,
float gamma,
float cv,
float xT = DEFAULT_XT )
Pressure drop [Pa] that passes ``mdot`` [kg/s] through a valve of ``cv`` by IEC 60534-2-1,
the inverse of :func:`iec_gas_flow`. NaN when the flow exceeds the choked capacity.

Definition at line 106 of file regulator.py.

References iec_gas_flow().

Referenced by build_solenoids().

◆ iec_gas_flow()

Dict[str, Any] engine.layerx.diag.regulator.iec_gas_flow ( float p1_pa,
float p2_pa,
float rho1,
float gamma,
float cv,
float xT = DEFAULT_XT )
Mass flow [kg/s] a valve of flow coefficient ``cv`` (US Cv) passes wide open from ``p1`` to
``p2``, by IEC 60534-2-1 (turbulent, Fp = 1). Returns {mdot, choked, Y, x, x_choke}.

Definition at line 86 of file regulator.py.

References max, and min.

Referenced by build_regulator(), and iec_gas_drop().

◆ regulator_id()

Optional[str] engine.layerx.diag.regulator.regulator_id ( Mapping[str, Any] net)
The regulator both feed paths pass through (the dome regulator), else the first one.

Definition at line 148 of file regulator.py.

Referenced by build_regulator(), and build_solenoids().

◆ regulator_params()

Dict[str, Tuple[float, str]] engine.layerx.diag.regulator.regulator_params ( Any prep,
str reg_id )
{name: (SI value, provenance)} of the regulator branch's component on the prepared model,
plus ``dome`` (the control regulator's loading at the dial) and the loader's own law.

Definition at line 156 of file regulator.py.

References _built(), and _provenance().

Referenced by build_regulator().

Variable Documentation

◆ COOLPROP_NAMES

dict engine.layerx.diag.regulator.COOLPROP_NAMES
Initial value:
1= {"helium": "Helium", "nitrogen": "Nitrogen", "oxygen": "Oxygen", "ethanol": "Ethanol",
2 "water": "Water", "argon": "Argon"}

Definition at line 63 of file regulator.py.

◆ DEFAULT_XT

float engine.layerx.diag.regulator.DEFAULT_XT = 0.7

Definition at line 54 of file regulator.py.

◆ IEC_SOURCE

tuple engine.layerx.diag.regulator.IEC_SOURCE
Initial value:
1= ("IEC 60534-2-1:2011, Industrial-process control valves - Part 2-1: Flow capacity - Sizing "
2 "equations for fluid flow under installed conditions; compressible flow, turbulent, no "
3 "attached fittings (Fp = 1): W = N6 Fp Kv Y sqrt(x p1 rho1), Y = 1 - x/(3 F_gamma x_T), "
4 "F_gamma = gamma/1.40, choked at x >= F_gamma x_T. Constants (N6, Cv->Kv) and the choke test "
5 "from fluids.control_valve.")

Definition at line 48 of file regulator.py.

◆ MODE_BAND

float engine.layerx.diag.regulator.MODE_BAND = 0.005

Definition at line 58 of file regulator.py.