STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_handcheck_without_rocketcea.py
Go to the documentation of this file.
1"""Forward mode's independent check runs where rocketcea is not installed.
2
3The API image leaves rocketcea out on purpose (it builds CEA from Fortran; requirements-base.txt),
4and handcheck imported it first thing: POST /api/evaluate on the LE4 (3) stand came back with
5``handcheck = {"rows": [], "error": "ModuleNotFoundError: No module named 'rocketcea'"}`` and the
6page said only "Independent check: unavailable". Nothing tested handcheck at all.
7
8Without rocketcea the textbook rows (mass balance, F = Cf Pc_ns At, Isp, the injector's Sutton 8-1,
9Rupe M, stay time) need no CEA and must run; c* is checked against the committed wide CEA table;
10the rows that need live CEA say so, and ``note`` says why.
11"""
12
13from __future__ import annotations
14
15import copy
16import sys
17
18import pytest
19
20PSI = 6894.757
21CFG = "tests/fixtures/ethalox_6500N_doublet_cad_2026-09-28.yaml"
22
23
24@pytest.fixture(scope="module")
25def solved():
26 from engine.core.runner import PintleEngineRunner
27 from engine.pipeline.io import load_config
28
29 cfg = load_config(CFG)
30 P = 578.0 * PSI
31 r = PintleEngineRunner(copy.deepcopy(cfg)).evaluate(P, P, silent=True)
32 return cfg, r, P
33
34
35@pytest.fixture
36def no_rocketcea(monkeypatch):
37 """Make ``import rocketcea`` fail here even where it is installed."""
38 monkeypatch.setitem(sys.modules, "rocketcea", None)
39 monkeypatch.setitem(sys.modules, "rocketcea.cea_obj", None)
40
41
42def _rows(hc):
43 return {row["quantity"]: row for row in hc["rows"]}
44
45
47 from engine.pipeline.handcheck import handcheck
48
49 cfg, r, P = solved
50 hc = handcheck(cfg, r, P, P)
51 assert "error" not in hc
52 assert "rocketcea" in hc["note"]
53 rows = _rows(hc)
54 for q in ("mdot = Pc_ns At / c*", "F = Cf Pc_ns At", "Isp = F / (mdot g0)", "Rupe M"):
55 assert rows[q]["kind"] == "compare" and rows[q]["ok"], rows[q]
56 for q in ("Tc ideal", "gamma chamber", "exit pressure", "Cf (zeta_n on vacuum Cf)"):
57 assert rows[q]["kind"] == "info" and rows[q]["hand"] == "needs rocketcea", rows[q]
58
59
61 from engine.pipeline.handcheck import handcheck
62
63 cfg, r, P = solved
64 rows = _rows(handcheck(cfg, r, P, P))
65 c = rows["c* ideal"]
66 assert c["kind"] == "compare" and c["ok"] and "wide" in c["source"], c
67 assert rows["eta c*"]["ok"], rows["eta c*"]
68
69
71 """The wide table spans O/F 0.1-20 where the design's cache stops at 2.5: past the edge the
72 model's c* is the edge's, the table's is the point's, and the row says so."""
73 from engine.core.runner import PintleEngineRunner
74 from engine.pipeline.handcheck import handcheck
75
76 cfg, _, _ = solved
77 PO, PF = 578.0 * PSI, 300.0 * PSI
78 r = PintleEngineRunner(copy.deepcopy(cfg)).evaluate(PO, PF, silent=True)
79 assert r["MR"] > 2.5
80 c = _rows(handcheck(cfg, r, PO, PF))["c* ideal"]
81 assert c["kind"] == "compare" and not c["ok"], c
test_a_clamped_mixture_ratio_shows_up_as_a_c_star_disagreement(solved, no_rocketcea)
test_c_star_is_checked_against_the_committed_wide_table(solved, no_rocketcea)
test_the_check_runs_and_says_what_it_could_not_check(solved, no_rocketcea)