STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_layer1_of_target_range.py
Go to the documentation of this file.
1"""Layer 1 refuses a target O/F outside the propellant's CEA table instead of optimizing garbage."""
2
3import pytest
4
5from engine.optimizer.layers.layer1_static_optimization import _layer1_check_of_target_in_cea_range
6from engine.pipeline.config_switch import load_canonical_config, apply_propellant
7from engine.pipeline.config_schemas import PintleEngineConfig
8
9
11 return PintleEngineConfig(**load_canonical_config("pintle")) # ethalox, MR_range [1.0, 2.5]
12
13
15 cfg = _ethalox_pintle()
16 lo, hi = cfg.combustion.cea.MR_range
17 _layer1_check_of_target_in_cea_range(cfg, 0.5 * (lo + hi))
18 _layer1_check_of_target_in_cea_range(cfg, lo)
19 _layer1_check_of_target_in_cea_range(cfg, hi)
20
21
23 cfg = _ethalox_pintle()
24 with pytest.raises(ValueError, match=r"outside the CEA table for ethalox .*\‍[1\.00, 2\.50\‍]"):
25 _layer1_check_of_target_in_cea_range(cfg, 3.5)
26
27
29 """The ethalox canonical carries optimal_of_ratio 1.4. A methalox overlay (table 2.4-4.2) now
30 moves the target to the preset's design O/F (DEF-06), which the check accepts; an ethalox
31 target put back on the methalox design must still be refused, not pinned at the table edge."""
32 switched = PintleEngineConfig(**apply_propellant(load_canonical_config("pintle"), "methalox"))
33 assert switched.design_requirements.optimal_of_ratio == pytest.approx(2.8)
34 _layer1_check_of_target_in_cea_range(switched, switched.design_requirements.optimal_of_ratio)
35 with pytest.raises(ValueError, match="outside the CEA table for methalox"):
36 _layer1_check_of_target_in_cea_range(switched, 1.4)
37
38
40 cfg = _ethalox_pintle()
41 cfg.combustion.cea.MR_range = None
42 _layer1_check_of_target_in_cea_range(cfg, 99.0)