STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_regulator_supply_zero.py
Go to the documentation of this file.
1"""The supply-pressure effect, measured from zero inlet.
2
3``outlet = dome + bias - S x inlet``, the inlet in gauge: a 1092-50 loaded to
4500 psi with 4,500 psi behind it at 17 psi per 1000 holds 473.5 psi, and comes
5up as the bottle falls (the team, 2026-10-07). It used to be measured from a
6datum -- a drawn ``inlet_reference``, or the COPV charge -- which zeroed it at a
7full bottle; the study drawings declare one, 4,500 psi, and it is no longer
8read.
9"""
10
11from __future__ import annotations
12
13import copy
14import json
15from pathlib import Path
16
17import pytest
18
19STAR = Path(__file__).resolve().parents[3]
20HE = STAR / "feed-twin" / "backend" / "diagrams" / "copv_study_he.json"
21TABLES = STAR / "feed-twin" / "backend" / "statemachines"
22
23
24def _drawing(datum: bool) -> dict: # type: ignore[type-arg]
25 raw = json.loads(HE.read_text())
26 if datum:
27 return raw
28 raw = copy.deepcopy(raw)
29 for node in raw["nodes"]:
30 node["data"].get("params", {}).pop("inlet_reference", None)
31 return raw
32
33
34def _lockup(datum: bool, copv_psi: float) -> dict[str, float]:
35 from feedtwin.pid import read_diagram
36 from feedtwin.session import assemble_model, load_machine
37 from feedtwin.session.burn import burn_setup, jump_to_t0, open_session
38
39 model = assemble_model(read_diagram(_drawing(datum), name="he"), diagram_id="he")
40 session = open_session(
41 model, load_machine(tables=TABLES), setup=burn_setup(dome_psi=500.0)
42 )
43 return jump_to_t0(session, copv_psi=copv_psi, fill_fraction=0.95).lockup_psi
44
45
46@pytest.mark.skipif(
47 not (HE.exists() and TABLES.is_dir()), reason="helium drawing or tables absent"
48)
50 """Dome 500 + the 1092-50's 50 - 17 x 4.5 at a 4,500 psig bottle; 34 psi
51 higher off a 2,500 psig one."""
52 full = _lockup(True, 4500.0)
53 half = _lockup(True, 2500.0)
54 assert full and set(full) == set(half)
55 for tank, psig in full.items():
56 assert psig == pytest.approx(500.0 + 50.0 - 17.0 * 4.5, abs=0.5), tank
57 assert half[tank] - psig == pytest.approx(17.0 * 2.0, abs=0.05), tank
58
59
60@pytest.mark.skipif(
61 not (HE.exists() and TABLES.is_dir()), reason="helium drawing or tables absent"
62)
64 assert _lockup(True, 3000.0) == _lockup(False, 3000.0)
dict[str, float] _lockup(bool datum, float copv_psi)