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

Classes

class  EngineImportError

Functions

Any _require (Mapping[str, Any] config, str path, str source)
float _optional (Mapping[str, Any] config, str path, float default=0.0)
DischargeModel _discharge (Mapping[str, Any]|None block)
EngineDesign engine_from_config (Mapping[str, Any] config, *, str name="engine")
EngineDesign load_engine (str|Path path)

Detailed Description

Reading an EngineDesign Layer-1 config into a feed-system boundary.

The contract this module keeps is narrow and worth stating: **an engine design
is imported, never re-typed, and never edited on the way in.** Whatever Layer 1
optimised to is what gets fired. If a number is missing the import says which
one and stops; it does not substitute a plausible default, because a plausible
default here produces a run that looks right and is not the engine anybody
designed.

What is read, and what is ignored
---------------------------------
Read: ``injector.type`` and ``injector.geometry``, ``discharge.*``,
``fluids.*.name`` and ``.temperature``, ``chamber_geometry.A_throat``,
``expansion_ratio``, ``volume``, ``design_pressure``, ``design_MR`` and
``design_thrust``.

Ignored, on purpose: ablative cooling, spray SMD correlations, optimizer
weights, structural margins, CEA cache paths, stability scores. None of them is
a feed-system boundary condition, and reading them would create a coupling that
has to be maintained for no benefit.

The file is YAML because EngineDesign writes YAML. That is the one place this
library touches it -- and it is read with ``safe_load`` into plain dicts, so an
engine config cannot execute anything on import.

Function Documentation

◆ _discharge()

DischargeModel feedtwin.engine.importer._discharge ( Mapping[str, Any] | None block)
protected
One side's discharge block, read literally.

EngineDesign does not read it literally. Its ``load_config`` re-stamps the
injector type's baseline over the Cd fields on every load
(``engine.pipeline.config_switch.apply_injector_type``; impinging: Cd_inf
0.60, a_Re 0.18, Cd_min 0.35, geometry Cd on, small-hole exponent 0.20),
keeping only a declared ``use_geometry_cd`` and the correction settings.
So this agrees with EngineDesign only where the block *is* that baseline --
every shipped ethalox config and LE4's engine -- and not on the older
methalox configs, nor on ``default.yaml``'s exponent of 0.0 (which the
``or 0.20`` below happens to read as EngineDesign does). Matching
EngineDesign's schema defaults instead was tried and is wrong for the same
reason (2026-10-08). The engine card carries EngineDesign's own Cd; this is
the simplified engine's.

Definition at line 86 of file importer.py.

Referenced by engine_from_config().

◆ _optional()

float feedtwin.engine.importer._optional ( Mapping[str, Any] config,
str path,
float default = 0.0 )
protected

Definition at line 77 of file importer.py.

Referenced by engine_from_config().

◆ _require()

Any feedtwin.engine.importer._require ( Mapping[str, Any] config,
str path,
str source )
protected
Fetch a dotted path, or fail naming exactly what was missing.

Definition at line 55 of file importer.py.

Referenced by engine_from_config().

◆ engine_from_config()

EngineDesign feedtwin.engine.importer.engine_from_config ( Mapping[str, Any] config,
* ,
str name = "engine" )
Build a feed-system boundary from an already-parsed engine config.

Separated from :func:`load_engine` so a config that arrived over HTTP, or
one assembled in a test, imports through exactly the same path as one read
off disk. The parser is not the interesting part; the extraction is.

Definition at line 126 of file importer.py.

References _discharge(), _optional(), _require(), and max.

Referenced by load_engine().

◆ load_engine()

EngineDesign feedtwin.engine.importer.load_engine ( str | Path path)
Import a Layer-1 engine config from disk.

The whole Phase 08 promise in one call: point it at what the optimizer
wrote and get a feed-system boundary, with nothing retyped.

Raises:
    EngineImportError: the file is unreadable as an engine boundary, naming
        the key that was missing and where it looked.

Definition at line 331 of file importer.py.

References engine_from_config().