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

Functions

List[Path] _preset_search_dirs (Path config_dir)
List[str] _available_presets (Path config_dir)
Any _deep_merge_preset (Any preset, Any override, str path="")
None _check_preset_coherence (str name, Dict[str, Any] preset, Dict[str, Any] merged)
str _canon_fluid (name)
None _check_fluid_cea_coherence (Dict[str, Any] data)
Dict[str, Any] _apply_propellant_preset (Dict[str, Any] data, Path config_dir)
PintleEngineConfig load_config (Union[str, Path] config_path)
None save_results (Dict[str, Any] results, Union[str, Path] output_path)

Variables

 _log = logging.getLogger(__name__)
 _PROJECT_ROOT = Path(__file__).resolve().parents[2]
dict _FLUID_ALIASES

Detailed Description

Configuration loading and result saving

Function Documentation

◆ _apply_propellant_preset()

Dict[str, Any] engine.pipeline.io._apply_propellant_preset ( Dict[str, Any] data,
Path config_dir )
protected
If ``propellant_preset`` is set, merge the preset under explicit-YAML-wins semantics.

Definition at line 146 of file io.py.

References _check_preset_coherence(), _deep_merge_preset(), and _preset_search_dirs().

Referenced by load_config().

◆ _available_presets()

List[str] engine.pipeline.io._available_presets ( Path config_dir)
protected

Definition at line 22 of file io.py.

References _preset_search_dirs().

◆ _canon_fluid()

str engine.pipeline.io._canon_fluid ( name)
protected
Canonical key for a fluid name, or the lowercased name when unrecognised.

Definition at line 85 of file io.py.

Referenced by _check_fluid_cea_coherence().

◆ _check_fluid_cea_coherence()

None engine.pipeline.io._check_fluid_cea_coherence ( Dict[str, Any] data)
protected
Fail when ``fluids`` and ``combustion.cea`` describe DIFFERENT propellants.

This used to live inside _check_preset_coherence, which only runs when a config names a
``propellant_preset``. Leave the preset unset -- which is exactly what the UI does when no
propellant is picked -- and the guard was skipped entirely: a config could carry methane
fluid properties while the chemistry came from the LOX/Ethanol CEA table, and it loaded
without a word. The injector would flow one propellant's density and the chamber would burn
another's thermochemistry, and every number downstream would look completely plausible.

The physics does not care whether a preset was named, so neither does this check.

Definition at line 96 of file io.py.

References _canon_fluid().

Referenced by load_config().

◆ _check_preset_coherence()

None engine.pipeline.io._check_preset_coherence ( str name,
Dict[str, Any] preset,
Dict[str, Any] merged )
protected
Hard-fail when explicit config fields contradict the preset's PROPELLANT IDENTITY.

Explicit-wins is fine for property tweaks (density, viscosity, …), but a stale explicit CEA
section or fluid *name* from a previous propellant produces physically-wrong results that look
plausible (the hardcoded-Cd bug class). Identity mismatches are errors, not overrides.

Definition at line 46 of file io.py.

Referenced by _apply_propellant_preset().

◆ _deep_merge_preset()

Any engine.pipeline.io._deep_merge_preset ( Any preset,
Any override,
str path = "" )
protected
Recursive merge: ``override`` (explicit config) wins on every leaf; overridden preset leaves
are logged so silently-differing values stay visible (UNIFICATION_PLAN Phase 2a).

Definition at line 30 of file io.py.

References _deep_merge_preset().

Referenced by _apply_propellant_preset(), and _deep_merge_preset().

◆ _preset_search_dirs()

List[Path] engine.pipeline.io._preset_search_dirs ( Path config_dir)
protected
Preset lookup order: next to the config file first, then the repo's configs/propellants.

Definition at line 17 of file io.py.

Referenced by _apply_propellant_preset(), and _available_presets().

◆ load_config()

PintleEngineConfig engine.pipeline.io.load_config ( Union[str, Path] config_path)
Load engine configuration from YAML file.

If the YAML carries ``propellant_preset: <name>`` (e.g. methalox, ethalox, kerolox), the file
``configs/propellants/<name>.yaml`` is deep-merged in BEFORE validation: the preset supplies the
propellant baseline (fluids, CEA setup) and any field given explicitly in the config wins (each
such override is logged). ``custom`` or absent = no preset (legacy behavior, unchanged).

Parameters:
-----------
config_path : str | Path
    Path to YAML configuration file

Returns:
--------
config : PintleEngineConfig
    Validated configuration object

Definition at line 168 of file io.py.

References _apply_propellant_preset(), and _check_fluid_cea_coherence().

◆ save_results()

None engine.pipeline.io.save_results ( Dict[str, Any] results,
Union[str, Path] output_path )
Save pipeline results to file (JSON or CSV).

Parameters:
-----------
results : Dict[str, Any]
    Results dictionary from pipeline
output_path : str | Path
    Output file path

Definition at line 223 of file io.py.

Variable Documentation

◆ _FLUID_ALIASES

dict engine.pipeline.io._FLUID_ALIASES
protected
Initial value:
1= {
2 "lox": {"lox", "o2(l)", "oxygen", "loxygen", "lo2"},
3 "methane": {"methane", "ch4", "lch4", "ch4(l)"},
4 "ethanol": {"ethanol", "c2h5oh", "etoh", "c2h5oh(l)"},
5 "rp1": {"rp1", "rp-1", "kerosene", "jet-a", "jeta"},
6 "nitrousoxide": {"n2o", "nitrousoxide", "nitrous oxide"},
7 "ipa": {"ipa", "isopropanol", "isopropyl alcohol", "c3h8o"},
8}

Definition at line 75 of file io.py.

◆ _log

engine.pipeline.io._log = logging.getLogger(__name__)
protected

Definition at line 11 of file io.py.

◆ _PROJECT_ROOT

engine.pipeline.io._PROJECT_ROOT = Path(__file__).resolve().parents[2]
protected

Definition at line 14 of file io.py.