STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_preset_fluid_drift.py
Go to the documentation of this file.
1"""A design whose fluid block disagrees with its propellant preset says so.
2
3An explicit ``fluids`` block wins over the preset on load, so a design saved before the ethalox
4preset was corrected against CoolProp keeps LOX cp 2300 (CoolProp Oxygen 90 K: 1699 J/(kg K)),
5bulk modulus 1.5e9 (rho a^2: 0.94e9 Pa) and viscosity 1.8e-4 (1.96e-4 Pa s) with no word. The LE4
6(3) stand's engine carries that block: forward thrust barely moves, but its chug gate goes 1.445 ->
71.420, the LOX water hammer 3182 -> 2561 psi and the line quarter-wave 2697 -> 2170 Hz.
8"""
9
10from __future__ import annotations
11
12from pathlib import Path
13
14import pytest
15
16REPO = Path(__file__).resolve().parents[1]
17STALE_LOX = {"specific_heat": 2300.0, "bulk_modulus_pa": 1.5e9, "viscosity": 1.8e-4}
18
19
20def _cfg(path):
21 from engine.pipeline.io import load_config
22
23 return load_config(str(path))
24
25
27 from engine.pipeline.config_switch import design_staleness
28
29 cfg = _cfg(REPO / "configs" / "ethalox_doublet_7000N.yaml")
30 for k, v in STALE_LOX.items():
31 setattr(cfg.fluids["oxidizer"], k, v)
32 w = design_staleness(cfg) or ""
33 assert "ethalox preset" in w, w
34 assert "specific_heat 2300 (preset 1700)" in w
35 assert "bulk_modulus_pa 1.5e+09 (preset 9.4e+08)" in w
36 assert "viscosity 0.00018 (preset 0.0002)" in w
37
38
40 from engine.pipeline.config_switch import design_staleness
41
42 assert design_staleness(_cfg(REPO / "configs" / "default.yaml")) is None
43
44
46 """default.yaml's LOX boiling point is 90.19 against the methalox preset's 90.2."""
47 from engine.pipeline.config_switch import preset_fluid_drift
48
49 cfg = _cfg(REPO / "configs" / "default.yaml")
50 cfg.fluids["oxidizer"].temperature = 92.0 # a couple of kelvin warmer: still quiet
51 assert preset_fluid_drift(cfg) is None
52
53
55 from engine.pipeline.config_switch import preset_fluid_drift
56
57 cfg = _cfg(REPO / "configs" / "ethalox_doublet_7000N.yaml")
58 cfg.fluids["oxidizer"].specific_heat = 2300.0
59 cfg.propellant_preset = None
60 assert preset_fluid_drift(cfg) is None
61
62
63@pytest.mark.parametrize("name", ["ethalox_doublet_7000N.yaml", "ethalox_8000N_designpoint.yaml"])
65 from engine.pipeline.config_switch import preset_fluid_drift
66
67 cfg = _cfg(REPO / "configs" / name)
68 lox = cfg.fluids["oxidizer"]
69 assert (lox.specific_heat, lox.bulk_modulus_pa, lox.viscosity) == pytest.approx((1700.0, 0.94e9, 2.0e-4))
70 assert preset_fluid_drift(cfg) is None
test_the_shipped_ethalox_designs_carry_the_corrected_lox(name)