STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
layerx_baseline Namespace Reference

Functions

Any _patched (Any config, Optional[Dict[str, Dict[str, Any]]] patch)
Optional[str] _sha256_file (Optional[Path] path)
Optional[str] _sha256_dir (Path path, str pattern="*")
Tuple[Any, Dict[str, Any]] load_engine_config (Any source=None)
Any find_drawing (str name)
Optional[float] _num (Any v)
Optional[float] _first (*Any values)
Dict[str, Any] metrics (Dict[str, Any] result, Any prep)
str _git_describe ()
Dict[str, Any] _versions ()
Dict[str, Any] run_case (str name, *, Any config=None, Any config_source=None, Optional[float] dt=None, Optional[Callable[[str, float], None]] progress=None, bool keep_result=False)
Dict[str, Any] run_baseline (Optional[Iterable[str]] cases=None, *, Any config_source=None, Optional[float] dt=None, bool embed_config=True, bool verbose=True)
str _f (Any v, int nd=1, str unit="")
str format_case (Dict[str, Any] case)
Any _json_default (Any o)
int main (Optional[List[str]] argv=None)

Variables

 ROOT = Path(__file__).resolve().parents[1]
float PSI = 6894.757293168361
str DEFAULT_CONFIG = ROOT / "configs" / "ethalox_6800N.yaml"
float STUDY_LOCKUP_PSIA = 564.7
dict CASES
 BASELINE_CASES = tuple(k for k, v in CASES.items() if not v.get("supplementary"))

Detailed Description

LE4 Layer X baseline ("golden") burns.

Runs Layer X in-process (no HTTP server) at today's default settings and reduces each burn to
the numbers a design review reads. The JSON it writes is the reference for the overnight rule
"a change that moves the LE4 baseline by more than 1 % must be reported"; the slow test
``tests/test_layerx_golden.py`` holds the pad helium case to it.

Cases (the engine is LE4, ``configs/ethalox_6800N.yaml`` unless ``--config`` says otherwise)::

    he_pad      copv_study_he on the pad, erosion replay on (the hot-fire drawing)
    he_flight   the same, flown at the design's liftoff mass (``liftoff_mass_kg`` unset: the
                config's airframe plus motor, propellant and gases)
    gn2_pad     copv_study_gn2 on the pad (the drawing the Layer X tab selects by default)

Supplementary (``--all`` or ``--case``)::

    gn2_flight           copv_study_gn2 flown: the tab's out-of-the-box run (the UI defaults flight on)
    he_flight_he_ullage  he_flight with config.{lox,fuel}_tank.ullage_gas = Helium in the run's copy
                         of the config: a what-if, because at defaults the flight prices the ullage
                         refill as nitrogen and refuses the helium bottle (see CASES)

Settings are ``LayerXSettings``'s defaults except ``drawing_id``, ``flight`` and ``--dt``. The UI's
``DEFAULT_SETTINGS`` (frontend/src/api/layerx.ts) equal them except that the UI turns ``flight``
on; the pad cases are therefore one toggle away from the tab's out-of-the-box run.

The run is the router's (backend/routers/layerx.py ``start_run``): a private deepcopy of the
config, its own ``PintleEngineRunner`` (so the Forward cross-check runs), no restated drawing
parameters, ``run_prepared(prep, runner=..., replay=settings.replay, config=...)``.

Usage::

    cd EngineDesign
    PYTHONPATH=../lib/stardesign python3 scripts/layerx_baseline.py            # the baseline's three
    PYTHONPATH=../lib/stardesign python3 scripts/layerx_baseline.py --all \\
        --out docs/layerx/baseline-2026-10-02.json                                 # + supplementary
    PYTHONPATH=../lib/stardesign python3 scripts/layerx_baseline.py --case he_pad --dt 0.02
    PYTHONPATH=../lib/stardesign python3 scripts/layerx_baseline.py --config path/to/current.json

``--config`` takes a YAML config, an app document (``.userdata/.../current.json``, its ``config``
key), or a baseline JSON written by this script (its embedded ``inputs.config``), so a baseline
can be re-burned on exactly the design it was taken on.

Importable: ``run_case`` and ``run_baseline`` return plain dicts.

Function Documentation

◆ _f()

str layerx_baseline._f ( Any v,
int nd = 1,
str unit = "" )
protected

Definition at line 436 of file layerx_baseline.py.

References _num().

◆ _first()

Optional[float] layerx_baseline._first ( *Any values)
protected

Definition at line 176 of file layerx_baseline.py.

References _num().

Referenced by metrics().

◆ _git_describe()

str layerx_baseline._git_describe ( )
protected

Definition at line 318 of file layerx_baseline.py.

Referenced by run_baseline().

◆ _json_default()

Any layerx_baseline._json_default ( Any o)
protected

Definition at line 474 of file layerx_baseline.py.

◆ _num()

Optional[float] layerx_baseline._num ( Any v)
protected

Definition at line 168 of file layerx_baseline.py.

Referenced by _f(), _first(), and metrics().

◆ _patched()

Any layerx_baseline._patched ( Any config,
Optional[Dict[str, Dict[str, Any]]] patch )
protected

Definition at line 100 of file layerx_baseline.py.

Referenced by run_case().

◆ _sha256_dir()

Optional[str] layerx_baseline._sha256_dir ( Path path,
str pattern = "*" )
protected

Definition at line 124 of file layerx_baseline.py.

Referenced by run_case().

◆ _sha256_file()

Optional[str] layerx_baseline._sha256_file ( Optional[Path] path)
protected

Definition at line 114 of file layerx_baseline.py.

Referenced by run_case().

◆ _versions()

Dict[str, Any] layerx_baseline._versions ( )
protected

Definition at line 326 of file layerx_baseline.py.

Referenced by run_baseline().

◆ find_drawing()

Any layerx_baseline.find_drawing ( str name)

Definition at line 156 of file layerx_baseline.py.

Referenced by run_case().

◆ format_case()

str layerx_baseline.format_case ( Dict[str, Any] case)

Definition at line 441 of file layerx_baseline.py.

Referenced by run_baseline().

◆ load_engine_config()

Tuple[Any, Dict[str, Any]] layerx_baseline.load_engine_config ( Any source = None)
``(config, info)``. ``source``: None (LE4's YAML), a path (YAML, an app document JSON, or a
baseline JSON from this script), or an already-built config dict.

Definition at line 135 of file layerx_baseline.py.

Referenced by run_baseline(), and run_case().

◆ main()

int layerx_baseline.main ( Optional[List[str]] argv = None)

Definition at line 480 of file layerx_baseline.py.

References main(), and run_baseline().

◆ metrics()

Dict[str, Any] layerx_baseline.metrics ( Dict[str, Any] result,
Any prep )
The baseline's figures from a ``run_prepared`` result.

Engine quantities (impulse, thrust, Pc, Isp) are the *delivered* ones, EngineDesign's eroding
replay, exactly as the Layer X tab's headline reads them (LayerXResult.tsx ``figureCells``);
the twin's own are kept beside them. Feed quantities (burn time, tanks, bottle, O/F, stiffness)
are the twin's last pass, also as the tab reads them.

Definition at line 184 of file layerx_baseline.py.

References _first(), _num(), and max.

Referenced by run_case().

◆ run_baseline()

Dict[str, Any] layerx_baseline.run_baseline ( Optional[Iterable[str]] cases = None,
* ,
Any config_source = None,
Optional[float] dt = None,
bool embed_config = True,
bool verbose = True )
Every case in ``cases`` (all by default) on one config. The config is embedded so the
baseline can be burned again on exactly this design (``--config <baseline.json>``).

Definition at line 398 of file layerx_baseline.py.

References _git_describe(), _versions(), format_case(), load_engine_config(), and run_case().

Referenced by main().

◆ run_case()

Dict[str, Any] layerx_baseline.run_case ( str name,
* ,
Any config = None,
Any config_source = None,
Optional[float] dt = None,
Optional[Callable[[str, float], None]] progress = None,
bool keep_result = False )
Burn one case and return ``{"case", "settings", "inputs", "metrics", ...}``.

``config``: an engine config to use (it is deep-copied, as the router does); otherwise
``config_source`` is loaded with :func:`load_engine_config`. ``dt`` overrides the default step.

Definition at line 337 of file layerx_baseline.py.

References _patched(), _sha256_dir(), _sha256_file(), find_drawing(), load_engine_config(), and metrics().

Referenced by run_baseline().

Variable Documentation

◆ BASELINE_CASES

layerx_baseline.BASELINE_CASES = tuple(k for k, v in CASES.items() if not v.get("supplementary"))

Definition at line 97 of file layerx_baseline.py.

◆ CASES

dict layerx_baseline.CASES
Initial value:
1= {
2 "he_pad": {"drawing": "copv_study_he", "flight": False,
3 "label": "Helium hot-fire drawing, on the pad, erosion replay on"},
4 "he_flight": {"drawing": "copv_study_he", "flight": True,
5 "label": "Helium hot-fire drawing, flown at the design liftoff mass"},
6 # Nitrogen over LOX is refused for a hot fire since 2026-10-03 (prepare.gn2_on_lox); the GN2 study
7 # cases burn it anyway, acknowledged, so they stay comparable with the baseline (``settings``).
8 "gn2_pad": {"drawing": "copv_study_gn2", "flight": False, "settings": {"ack_gn2_condensation": True},
9 "label": "GN2 drawing (the Layer X tab's default drawing), on the pad"},
10 # The tab's out-of-the-box run: the GN2 drawing with the UI's flight: true.
11 "gn2_flight": {"drawing": "copv_study_gn2", "flight": True, "supplementary": True,
12 "settings": {"ack_gn2_condensation": True},
13 "label": "GN2 drawing flown at the design liftoff mass (the UI's DEFAULT_SETTINGS run)"},
14 # The flight simulation prices the ullage refill with config.<tank>.ullage_gas (Nitrogen in LE4's # config) whatever gas the drawing's bottle holds, so he_flight fails its COPV budget at defaults.
15 # This what-if names the drawing's gas in the run's copy of the config so the helium burn can fly.
16 "he_flight_he_ullage": {"drawing": "copv_study_he", "flight": True, "supplementary": True,
17 "config_patch": {"lox_tank": {"ullage_gas": "Helium"},
18 "fuel_tank": {"ullage_gas": "Helium"}},
19 "label": "Helium drawing flown, config ullage_gas set to Helium (what-if, not default)"},
20}

Definition at line 76 of file layerx_baseline.py.

◆ DEFAULT_CONFIG

str layerx_baseline.DEFAULT_CONFIG = ROOT / "configs" / "ethalox_6800N.yaml"

Definition at line 65 of file layerx_baseline.py.

◆ PSI

float layerx_baseline.PSI = 6894.757293168361

Definition at line 64 of file layerx_baseline.py.

◆ ROOT

layerx_baseline.ROOT = Path(__file__).resolve().parents[1]

Definition at line 60 of file layerx_baseline.py.

◆ STUDY_LOCKUP_PSIA

float layerx_baseline.STUDY_LOCKUP_PSIA = 564.7

Definition at line 74 of file layerx_baseline.py.