STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_n2_z_table.py
Go to the documentation of this file.
1"""copv/n2_Z_lookup.csv covers the pressures a COPV holds, not only a propellant tank's.
2
3The table stopped at 8.3 MPa; RegularGridInterpolator(fill_value=None) extrapolates linearly past
4it, so the COPV solvers read Z 1.039 at 26 MPa and 300 K where CoolProp gives 1.105. On the LE4 (3)
5stand's 1.312 kg in 4.619 L that put the charge at 3810 psia instead of 4141 (CoolProp, 300 K,
6284 kg/m3), and shifted every COPV sizing in the Time-Series panel and Layer 2 by the same few
7per cent. Extended to 60 MPa from CoolProp, the rows inside the old range untouched.
8"""
9
10from __future__ import annotations
11
12from pathlib import Path
13
14import pytest
15
16TABLE = Path(__file__).resolve().parents[1] / "copv" / "n2_Z_lookup.csv"
17
18
19@pytest.fixture(scope="module")
20def interp():
21 from copv.blowdown_solver import load_Z_lookup_table
22
23 return load_Z_lookup_table(str(TABLE))[0]
24
25
26@pytest.mark.parametrize("T,P", [(300.0, 26e6), (300.0, 45e6), (250.0, 20e6), (90.0, 30e6)])
28 CP = pytest.importorskip("CoolProp.CoolProp")
29 from copv.blowdown_solver import Z_lookup
30
31 # On a tabulated temperature (90, 300) the value is CoolProp's own; 250 K sits between rows.
32 tol = 1e-9 if T in (90.0, 300.0) else 2e-4
33 assert Z_lookup(T, P, interp) == pytest.approx(CP.PropsSI("Z", "T", T, "P", P, "Nitrogen"), abs=tol)
34
35
37 """A propellant-tank state (300 K, 5 MPa) still reads the original grid."""
38 CP = pytest.importorskip("CoolProp.CoolProp")
39 from copv.blowdown_solver import Z_lookup
40
41 assert Z_lookup(300.0, 5003015.075376884, interp) == pytest.approx(
42 CP.PropsSI("Z", "T", 300.0, "P", 5003015.075376884, "Nitrogen"), abs=1e-12
43 )
test_copv_pressures_read_coolprop_not_an_extrapolation(interp, T, P)
test_the_tank_range_is_unchanged(interp)