STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_timeseries_copv_charge.py
Go to the documentation of this file.
1
"""The Time-Series COPV panel checks the charge the config loads, and labels a sized number as one.
2
3
It always SIZED: the P0 that just meets the curve in the configured volume, so the margin is zero
4
by construction -- and the panel showed that as "P0 2644 psia, Min Margin 0.1 psi" in green on the
5
LE4 (3) stand, whose press_tank.initial_gas_mass of 1.312 kg in 4.619 L is a ~3,800 psia charge.
6
"""
7
8
from
__future__
import
annotations
9
10
import
numpy
as
np
11
import
pytest
12
13
from
backend.routers
import
timeseries
as
ts
14
15
CFG =
"tests/fixtures/ethalox_6500N_doublet_cad_2026-09-28.yaml"
16
R_N2, T0 = 296.8, 300.0
17
18
19
@pytest.fixture
20
def
cfg
():
21
from
engine.pipeline.io
import
load_config
22
23
return
load_config(CFG)
24
25
26
def
_run
(cfg):
27
t = np.linspace(0.0, 4.0, 41)
28
return
ts._run_copv_analysis(cfg, t, [1.87] * 41, [1.24] * 41, 578.0 * np.ones(41), 578.0 * np.ones(41))
29
30
31
def
test_a_configured_charge_is_checked_not_sized
(cfg):
32
assert
cfg.press_tank.initial_gas_mass == pytest.approx(1.312)
33
out =
_run
(cfg)
34
assert
out[
"copv_mode"
] ==
"configured"
35
assert
out[
"copv_initial_mass_kg"
] == pytest.approx(1.312)
36
# P0 is the charge's own state at T0: m0 = P0 V / (Z R T0), Z from the solver's own table.
37
V = cfg.press_tank.free_volume_L / 1000.0
38
P0 = out[
"copv_initial_pressure_psi"
] * 6894.757
39
Z = P0 * V / (1.312 * R_N2 * T0)
40
assert
0.95 < Z < 1.3, Z
41
assert
out[
"copv_pressure_psi"
][0] == pytest.approx(out[
"copv_initial_pressure_psi"
], rel=1e-6)
42
# the requirement still reported beside it, and below it: this charge has margin to spare
43
assert
out[
"copv_required_mass_kg"
] < 1.312
44
assert
out[
"copv_required_pressure_psi"
] < out[
"copv_initial_pressure_psi"
]
45
assert
out[
"copv_min_margin_psi"
] > 500.0,
"the check returned the sized (zero) margin"
46
47
48
def
test_without_a_charge_the_panel_sizes_and_says_so
(cfg):
49
cfg.press_tank.initial_gas_mass =
None
50
cfg.press_tank.mass =
None
51
out =
_run
(cfg)
52
assert
out[
"copv_mode"
] ==
"sized"
53
assert
out[
"copv_initial_pressure_psi"
] == pytest.approx(out[
"copv_required_pressure_psi"
])
54
assert
abs(out[
"copv_min_margin_psi"
]) < 5.0,
"sized for zero margin"
55
56
57
def
test_the_check_and_the_sizing_agree_on_the_sized_charge
(cfg):
58
"""Checking the charge the sizing asks for gives back the sizing's P0 and a ~zero margin."""
59
cfg.press_tank.initial_gas_mass =
None
60
cfg.press_tank.mass =
None
61
sized =
_run
(cfg)
62
cfg.press_tank.initial_gas_mass = sized[
"copv_required_mass_kg"
]
63
checked =
_run
(cfg)
64
assert
checked[
"copv_mode"
] ==
"configured"
65
assert
checked[
"copv_initial_pressure_psi"
] == pytest.approx(sized[
"copv_required_pressure_psi"
], rel=1e-4)
66
assert
abs(checked[
"copv_min_margin_psi"
]) < 5.0
backend.routers
Definition
__init__.py:1
engine.pipeline.io
Definition
io.py:1
test_timeseries_copv_charge._run
_run(cfg)
Definition
test_timeseries_copv_charge.py:26
test_timeseries_copv_charge.test_the_check_and_the_sizing_agree_on_the_sized_charge
test_the_check_and_the_sizing_agree_on_the_sized_charge(cfg)
Definition
test_timeseries_copv_charge.py:57
test_timeseries_copv_charge.cfg
cfg()
Definition
test_timeseries_copv_charge.py:20
test_timeseries_copv_charge.test_a_configured_charge_is_checked_not_sized
test_a_configured_charge_is_checked_not_sized(cfg)
Definition
test_timeseries_copv_charge.py:31
test_timeseries_copv_charge.test_without_a_charge_the_panel_sizes_and_says_so
test_without_a_charge_the_panel_sizes_and_says_so(cfg)
Definition
test_timeseries_copv_charge.py:48
EngineDesign
tests
test_timeseries_copv_charge.py
Generated by
1.15.0