STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
gauge.py
Go to the documentation of this file.
1"""Where gauge and absolute pressure meet, and what a person is shown.
2
3Every pressure inside the model is absolute -- the equation of state, the
4choking ratios and the regulator all need it that way. Every pressure a person
5reads or types is absolute too, in psia (ADR 0007): the slides, the datasheets
6and EngineDesign all quote psia, and a screen that said psig sat 14.7 psi off
7every one of them.
8
9What crosses the wire and what is saved stays **gauge**: a knob's ``psig``, the
10API's ``*_psi`` fields, run records, hookups, stand documents. That is what the
11stand's DAQ logs and what every saved file already holds; changing it would
12make each old record mean something else. :func:`psig` and :func:`from_psig`
13are the only two places the wire meets the model. Moved here from the
14feed-twin app when the marching session became library code, so a second
15caller -- EngineDesign's Layer X -- converts through the same two functions
16rather than its own.
17
18Text meant for people goes through :func:`say`, which prints psia from the
19model's own absolute pascals (it and :func:`psia` live in
20:mod:`feedtwin.model.pressure`, so the drawing reader can use them without
21importing the session; this is their address). A difference -- a bias, a
22droop, a sag, a residual -- is the same size either way and is written in
23plain psi.
24
25The zero is the **standard** atmosphere, deliberately and only for gauge
26readings: it is the convention the stand's DAQ and the cockpit share. A caller
27that knows the absolute pressure it wants (an engine config states psia) should
28convert with :func:`from_psig` of ``(p_abs - ATMOSPHERE) / PSI`` -- which is
29exact -- rather than assume its site's atmosphere is this one.
30"""
31
32from __future__ import annotations
33
34from feedtwin.model.pressure import psia as psia
35from feedtwin.model.pressure import say as say
36from feedtwin.model.units import get_unit
37
38#: One psi [Pa].
39PSI: float = get_unit("psi").factor
40
41#: Standard atmosphere [Pa]. The zero of every gauge on the stand.
42ATMOSPHERE = 101325.0
43
44#: Standard atmosphere [psia], 14.696: what a gauge number on the wire gains to
45#: be shown as psia, and what a vented vessel reads.
46ATMOSPHERE_PSI: float = ATMOSPHERE / PSI
47
48
49def psig(pascal: float) -> float:
50 """Absolute pressure [Pa] as the stand's transducers log it [psig].
51
52 A vented vessel reads 0.0, not 14.7. For the wire and saved files; text a
53 person reads goes through :func:`say`.
54 """
55 return (pascal - ATMOSPHERE) / PSI
56
57
58def from_psig(gauge: float) -> float:
59 """A gauge reading or dial setting [psig] as the absolute pressure the model
60 integrates [Pa]."""
61 return gauge * PSI + ATMOSPHERE
62
63
64def psig_from_psia(psia: float) -> float:
65 """An absolute pressure stated in psia, as the gauge reading [psig] that
66 :func:`from_psig` turns back into exactly ``psia * PSI`` pascals."""
67 return (psia * PSI - ATMOSPHERE) / PSI
float psig(float pascal)
Definition gauge.py:49
float from_psig(float gauge)
Definition gauge.py:58
float psig_from_psia(float psia)
Definition gauge.py:64