STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_people_read_psia.py
Go to the documentation of this file.
1"""People read psia (ADR 0007): one formatter, and the words that use it.
2
3Checked against arithmetic, not against the code: a standard atmosphere is
4101,325 Pa and a psi is 6,894.757 Pa, so the stand's 500 psig dome is 514.696
5psia and a vented tank reads 14.7. The wire keeps gauge -- :func:`psig` and
6:func:`from_psig` are untouched -- and nothing here may move a number in the
7model: a session's words change, not its state.
8"""
9
10from __future__ import annotations
11
12import pytest
13
14from feedtwin.model import pressure
15from feedtwin.session import gauge
16from feedtwin.session.gauge import (
17 ATMOSPHERE,
18 ATMOSPHERE_PSI,
19 PSI,
20 from_psig,
21 psia,
22 psig,
23 say,
24)
25
26
28 # 101325 / 6894.757293168361, by hand: 14.69594877551...
29 assert ATMOSPHERE_PSI == pytest.approx(14.695948775513, abs=1e-12)
30 assert psia(ATMOSPHERE) == pytest.approx(ATMOSPHERE_PSI, rel=1e-15)
31 assert PSI == 6894.757293168361
32
33
35 assert psia(from_psig(500.0)) == pytest.approx(514.695949, abs=1e-6)
36 assert psia(from_psig(0.0)) == pytest.approx(ATMOSPHERE_PSI)
37 # The wire is untouched: gauge in, gauge out.
38 assert psig(from_psig(473.5)) == pytest.approx(473.5, abs=1e-12)
39
40
41@pytest.mark.parametrize(
42 "pascal, places, said",
43 [
44 (from_psig(500.0), 1, "514.7 psia"),
45 (from_psig(500.0), 0, "515 psia"),
46 (from_psig(4500.0), 1, "4,514.7 psia"),
47 (ATMOSPHERE, 1, "14.7 psia"),
48 (0.0, 0, "0 psia"),
49 (-1e-6, 2, "0.00 psia"), # a vacuum's rounding never says "-0"
50 (750.0 * PSI + ATMOSPHERE, 1, "764.7 psia"),
51 ],
52)
53def test_say_spells_a_pressure_in_psia(pascal: float, places: int, said: str) -> None:
54 assert say(pascal, places) == said
55
56
58 """The session's address is the drawing reader's function, not a copy."""
59 assert gauge.say is pressure.say
60 assert gauge.psia is pressure.psia
61
62
64 """Burst over the factor of safety is a limit across the wall: 1,500 psi of
65 burst over two is 750 psi across it, which a person reads as 764.7 psia."""
66 from feedtwin.model.param import Param, Provenance
67 from feedtwin.session.core import _trip_limit
68
69 class Node:
70 id = "TK"
71 label = "TK-OX"
72 params = {
73 "burst_pressure": Param(
74 1500.0, "psig", Provenance.ESTIMATED, "test: a burst rating"
75 )
76 }
77
78 notes: list[str] = []
79 limit = _trip_limit(Node(), 2.0, notes)
80 assert limit == pytest.approx(750.0 * PSI + ATMOSPHERE)
81 assert notes == [
82 "TK-OX trip limit: burst pressure / 2 across the wall (764.7 psia)."
83 ]
None test_a_gauge_number_reads_an_atmosphere_higher()
None test_say_spells_a_pressure_in_psia(float pascal, int places, str said)