STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
injector_layout.py
Go to the documentation of this file.
1"""Print the injector layout (engine/core/injectors/layout.py) for a config, as JSON.
2
3 python3 scripts/injector_layout.py configs/ethalox_8kN_SHIP.yaml
4
5The config is evaluated at its tank pressures (lox_tank / fuel_tank ``initial_pressure_psi``) and
6the solve's flows go to the layout, so it also reports the channels' velocity head, the orifices'
7cavitation margin and the plate's bending at the solved Pc. ``--no-flows`` skips the solve:
8geometry only, with the plate checked at ``target_chamber_pressure_psi``.
9
10Regenerate the frontend's drawing fixture (geometry only, so it does not move with the physics):
11
12 python3 scripts/injector_layout.py --no-flows configs/ethalox_6500N.yaml \
13 > frontend/src/components/__fixtures__/layout_6500N.json
14"""
15import copy
16import json
17import sys
18from pathlib import Path
19
20import yaml
21
22sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
23from engine.core.injectors.layout import flows_from_result, layout_from_config # noqa: E402
24
25PSI = 6894.757
26
27
28def solved_flows(path: str):
29 """The flows of ``path`` evaluated at its tank pressures."""
30 from engine.core.runner import PintleEngineRunner
31 from engine.pipeline.io import load_config
32 c = load_config(path)
33 r = PintleEngineRunner(copy.deepcopy(c)).evaluate(
34 c.lox_tank.initial_pressure_psi * PSI, c.fuel_tank.initial_pressure_psi * PSI, silent=True)
35 return flows_from_result(r, c)
36
37
38if __name__ == "__main__":
39 args = [a for a in sys.argv[1:] if a != "--no-flows"]
40 path = args[0]
41 flows = None if "--no-flows" in sys.argv[1:] else solved_flows(path)
42 with open(path) as fh:
43 print(json.dumps(layout_from_config(yaml.safe_load(fh), flows=flows), indent=1, sort_keys=True))
solved_flows(str path)