STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
run_evaluate_cd_cases_7435n_geometry.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2"""Evaluate fixed ~7435 N impinging geometry under four Cd scenarios (no Layer-1 optimization)."""
3
4from __future__ import annotations
5
6import copy
7import sys
8from pathlib import Path
9
10ROOT = Path(__file__).resolve().parents[1]
11sys.path.insert(0, str(ROOT))
12
13from engine.pipeline.io import load_config
14from engine.core.runner import PintleEngineRunner
15
16# Frozen optimum from Layer-1 follow-up (~7435 N, dP_O/Pc ~ 0.156)
17_AT = 0.0018378315868177425
18_AE = 0.011028325556581661
19_EPS = float(_AE) / float(_AT)
20
21_LS = 0.83704
22_DIN = 0.15159999999999998
23_PO_PSI = 514.6808186275356
24_PF_PSI = 536.3821987535601
25
26
28 cg = cfg.chamber_geometry
29 cg.A_throat = _AT
30 cg.expansion_ratio = _EPS
31 cg.A_exit = float(cg.A_throat) * float(cg.expansion_ratio)
32 cg.Lstar = _LS
33 cg.chamber_diameter = _DIN
34 ox = cfg.injector.geometry.oxidizer
35 fu = cfg.injector.geometry.fuel
36 ox.n_elements = 77
37 ox.d_jet = 0.0013685
38 ox.impingement_angle = 82.30
39 ox.spacing = 0.0041361
40 fu.n_elements = 119
41 fu.d_jet = 8.142e-4
42 fu.impingement_angle = 56.83
43 fu.spacing = 0.0038040
44 cfg.lox_tank.initial_pressure_psi = float(_PO_PSI)
45 cfg.fuel_tank.initial_pressure_psi = float(_PF_PSI)
46
47
48def _set_flat_cd(cfg, cd_o: float, cd_f: float) -> None:
49 """Flatten Cd(Re) so effective discharge matches targets (Cd_inf bound, zero Re slope)."""
50 o = cfg.discharge["oxidizer"]
51 f = cfg.discharge["fuel"]
52 o.Cd_inf = float(cd_o)
53 o.Cd_min = float(cd_o)
54 o.a_Re = 0.0
55 f.Cd_inf = float(cd_f)
56 f.Cd_min = float(cd_f)
57 f.a_Re = 0.0
58
59
60CASES = {
61 "A": (0.40, 0.30),
62 "B": (0.40, 0.40),
63 "C": (0.50, 0.50),
64 "D": (0.40, 0.45),
65}
66
67
68def main() -> None:
69 base_path = ROOT / "configs" / "impinging_lox_ch4_8000N.yaml"
70 Po_pa = float(_PO_PSI) * 6894.76
71 Pf_pa = float(_PF_PSI) * 6894.76
72
73 print("Fixed geometry: 7435 N optimum (throat/exit/sync, 77 LOX / 119 CH4 jets)")
74 print(f"A_exit/A_throat = {_EPS:.6f}\n")
75
76 for name, (c_o, c_f) in CASES.items():
77 cfg = load_config(str(base_path))
79 _set_flat_cd(cfg, c_o, c_f)
80 rnr = PintleEngineRunner(cfg)
81 res = rnr.evaluate(Po_pa, Pf_pa, silent=True)
82 d = res.get("diagnostics") or {}
83 pc = float(res.get("Pc", 0))
84 dp_o = d.get("delta_p_injector_O")
85 dp_f = d.get("delta_p_injector_F")
86 r_o = float(dp_o) / pc if dp_o is not None and pc > 0 else float("nan")
87 r_f = float(dp_f) / pc if dp_f is not None and pc > 0 else float("nan")
88
89 cd_o_eff = float(d.get("Cd_O", float("nan")))
90 cd_f_eff = float(d.get("Cd_F", float("nan")))
91
92 print(
93 f"Case {name}: target Cd_O={c_o} Cd_F={c_f} "
94 f"(diagnostics Cd_O={cd_o_eff:.4f} Cd_F={cd_f_eff:.4f})"
95 )
96 print(f" thrust [N]={res.get('F'):.4f}")
97 print(f" MR={res.get('MR'):.6f}")
98 print(f" momentum_ratio_R={d.get('momentum_ratio_R')}")
99 print(f" ΔP_O/Pc={r_o:.6g}")
100 print(f" ΔP_F/Pc={r_f:.6g}")
101 print()
102
103
104if __name__ == "__main__":
105 main()