STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
design_handcheck.py
Go to the documentation of this file.
1"""Re-derive a design's headline numbers by hand and set them beside the model's.
2
3 python3 scripts/design_handcheck.py configs/ethalox_6500N.yaml [--pamb 94070]
4
5The checks are engine/pipeline/handcheck.py (forward mode shows the same rows). Nothing there calls
6the engine's physics: CEA through rocketcea, and the textbook relation named on each row.
7
8Exits non-zero on any flag.
9"""
10from __future__ import annotations
11
12import argparse
13import copy
14import sys
15from pathlib import Path
16
17sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
18
19PSI = 6894.757
20
21
22def main():
23 ap = argparse.ArgumentParser()
24 ap.add_argument("config")
25 ap.add_argument("--pamb", type=float, default=None, help="ambient pressure [Pa]; default: the config's")
26 a = ap.parse_args()
27
28 from engine.pipeline.io import load_config
29 from engine.core.runner import PintleEngineRunner
30 from engine.pipeline.handcheck import handcheck
31
32 cfg = load_config(a.config)
33 PO = cfg.lox_tank.initial_pressure_psi * PSI
34 PF = cfg.fuel_tank.initial_pressure_psi * PSI
35 kw = {} if a.pamb is None else {"P_ambient": a.pamb}
36 r = PintleEngineRunner(copy.deepcopy(cfg)).evaluate(PO, PF, silent=True, **kw)
37 out = handcheck(cfg, r, PO, PF)
38 rows = [(x["quantity"], x["model"], x["hand"], x["diff"], x["source"]) for x in out["rows"]]
39 hdr = ("quantity", "model", "hand/bound", "diff", "source")
40 w = [max(len(x[i]) for x in rows + [hdr]) for i in range(5)]
41 print(" ".join(h.ljust(w[i]) for i, h in enumerate(hdr)))
42 for row in rows:
43 print(" ".join(c.ljust(w[i]) for i, c in enumerate(row)))
44 s = out["summary"]
45 print()
46 print(f"{a.config}: Pc {s['Pc_psia']:.1f} psia, O/F {s['OF']:.3f}, F {s['F']:.0f} N, Isp {s['Isp']:.1f} s "
47 f"at pa {s['Pa'] / 1000:.1f} kPa")
48 if out["flags"]:
49 print("FLAGS:")
50 for f in out["flags"]:
51 print(" " + f)
52 sys.exit(1)
53 print("no flags")
54
55
56if __name__ == "__main__":
57 main()
#define max(a, b)
Definition Arduino.h:43