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

Classes

class  EngineSampler
class  _ExpansionScaling

Functions

Any line_exit_config (Any config)
 _rbf (np.ndarray points, np.ndarray values)
 _table (fn, np.ndarray x_axis, np.ndarray y_axis, Callable[[np.ndarray], np.ndarray] transform)
Tuple[Tuple[float, float],...] _hull (np.ndarray points)
np.ndarray _axis (np.ndarray values, int n)
 fit_card (Sequence[Dict[str, float]] samples, *, float throat_area, float exit_area, float ambient_pa, str name)
Optional[Dict[str, float]] solve_card (Any card, float p_O, float p_F, float ambient_pa)
Dict[str, float] check_card (Any card, Sequence[Dict[str, float]] points, float ambient_pa)
List[Dict[str, float]] _scan (EngineSampler sampler, float center_pa, Tuple[float, float, int] levels, Tuple[float, float, int] ratios)
List[Dict[str, float]] _random (EngineSampler sampler, float center_pa, int n, Tuple[float, float] levels, Tuple[float, float] ratios, int seed)
Any build_card (Any config, *, float center_pa, float ambient_pa, int holdout=40, int seed=7)
type expansion_chamber_class ()
Any __getattr__ (str name)
Any expansion_chamber (Any card, Any cea_cache, *, float ambient_pressure, float volume=0.0)
Any card_for (Any config, *, float center_pa, float ambient_pa)
Dict[str, Any] card_for_config_text (str text, *, Optional[float] center_psia=None)

Variables

float PSI = 6894.757293168361
float TOLERANCE = 2.0e-3
tuple LEVELS = (0.40, 1.30, 21)
tuple RATIOS = (0.75, 1.30, 13)
tuple ENVELOPE_LEVELS = (0.70, 1.15)
tuple ENVELOPE_RATIOS = (0.90, 1.12)
tuple CHAMBER_GRID = (41, 41)
tuple INJECTOR_GRID = (41, 21)
tuple BOUNDARY
str _CACHE = OrderedDict()
 _CACHE_LOCK = threading.Lock()
int _CACHE_SIZE = 8

Detailed Description

EngineDesign's engine as an engine card for the feed twin (Layer X, phase 2).

A card (:mod:`feedtwin.engine.card`) is this engine downstream of its feed lines, tabulated so the
twin can run it at every coupling step of a burn. This module builds one by sampling EngineDesign
and fitting the tables, and measures how wrong the card is before anything uses it.

The boundary: the line exit
---------------------------
The twin's lines end at the injector face node, at line-end pressure in the lumped K-factor
convention. EngineDesign's ``feed_system`` is a tank-to-manifold model: ``K_eff`` along the
line, plus a Borda dump of the exit bore's velocity head into the manifold.

The card samples a copy of the config with every line loss zeroed (``K0``, ``K1``, fittings,
friction) and the exit dump kept. Its "tank" pressure is then exactly the line-exit pressure,
and the card owns everything downstream:
* the dump;
* the ring manifold;
* the plate passages and their Cd;
* the spray, mixing and heat-loss efficiency;
* the stagnation loss;
* the nozzle.

The drawing owns the lines. On the 6.8 kN engine the dump alone is ~26 psi on the LOX side,
which is why it cannot be left on neither side or put on both.

Sampling and fitting
--------------------
EngineDesign is solved on a grid of line-exit pressures around the T-0 point. Each solve is
~5-20 ms on the numba chamber kernel, which has 1e-9 parity with the Python solve. The fitted
quantities are each nearly constant over the burn, which is why they tabulate well:
* injector flow capacity ``mdot/sqrt(dp)`` over ``(mdot, p_inlet)``;
* ``c*_eff = Pc A_t/mdot`` over ``(O/F, mdot)``;
* the vacuum exhaust velocity ``(F + p_a A_e)/mdot`` over ``(O/F, mdot)``. EngineDesign's thrust
  is exactly linear in ambient pressure for a full-flowing nozzle, so a card built at one
  ambient serves any.

The fit is thin-plate RBF through the samples, resampled onto uniform grids, which the twin
evaluates with Catmull-Rom.

Limit, measured: EngineDesign's efficiency has slope kinks at its CEA table's O/F nodes (its
own trilinear lookup). No smooth table reproduces those, which sets a floor of a few hundredths
of a percent in chamber pressure. The card reports its measured error, and a card whose error
on held-out solves exceeds :data:`TOLERANCE` is flagged, not used quietly.

Function Documentation

◆ __getattr__()

Any engine.layerx.card.__getattr__ ( str name)

Definition at line 488 of file card.py.

References expansion_chamber_class().

◆ _axis()

np.ndarray engine.layerx.card._axis ( np.ndarray values,
int n )
protected

Definition at line 184 of file card.py.

Referenced by fit_card().

◆ _hull()

Tuple[Tuple[float, float], ...] engine.layerx.card._hull ( np.ndarray points)
protected

Definition at line 177 of file card.py.

Referenced by fit_card().

◆ _random()

List[Dict[str, float]] engine.layerx.card._random ( EngineSampler sampler,
float center_pa,
int n,
Tuple[float, float] levels,
Tuple[float, float] ratios,
int seed )
protected

Definition at line 306 of file card.py.

Referenced by build_card().

◆ _rbf()

engine.layerx.card._rbf ( np.ndarray points,
np.ndarray values )
protected
Thin-plate RBF through ``values`` at ``points`` (columns normalised), as a callable.

Definition at line 156 of file card.py.

Referenced by fit_card().

◆ _scan()

List[Dict[str, float]] engine.layerx.card._scan ( EngineSampler sampler,
float center_pa,
Tuple[float, float, int] levels,
Tuple[float, float, int] ratios )
protected

Definition at line 294 of file card.py.

Referenced by build_card().

◆ _table()

engine.layerx.card._table ( fn,
np.ndarray x_axis,
np.ndarray y_axis,
Callable[[np.ndarray], np.ndarray] transform )
protected

Definition at line 166 of file card.py.

Referenced by fit_card().

◆ build_card()

Any engine.layerx.card.build_card ( Any config,
* ,
float center_pa,
float ambient_pa,
int holdout = 40,
int seed = 7 )
Sample, fit, check. Returns an :class:`~feedtwin.engine.card.EngineCard` whose ``fit``
holds its measured errors (``envelope_*`` inside the operating envelope, ``box_*`` over the
whole scan) and whose ``provenance`` says how it was made.

Definition at line 321 of file card.py.

References _random(), _scan(), check_card(), fit_card(), max, and time.time().

Referenced by card_for().

◆ card_for()

Any engine.layerx.card.card_for ( Any config,
* ,
float center_pa,
float ambient_pa )
:func:`build_card`, remembered per (config, T-0, ambient). Preflight and the run that follows
it share one card; a changed config is a different key, so a stale card is never served.

Definition at line 512 of file card.py.

References build_card().

Referenced by card_for_config_text().

◆ card_for_config_text()

Dict[str, Any] engine.layerx.card.card_for_config_text ( str text,
* ,
Optional[float] center_psia = None )
The engine card for an engine config given as YAML text: what the feed-twin cockpit asks
for when it imports an engine, so the stand fires the engine EngineDesign designed rather than
feedtwin's own simplified one.

Centred on the config's tank pressure (``lox_tank.initial_pressure_psi``) unless told
otherwise; the scan then covers 40-130 % of it, which is every dome the cockpit's regulator
can be set to. Sampled at the site's ambient (``environment.elevation``), as Layer X does.

Definition at line 531 of file card.py.

References card_for().

◆ check_card()

Dict[str, float] engine.layerx.card.check_card ( Any card,
Sequence[Dict[str, float]] points,
float ambient_pa )
Largest relative errors of ``card`` against EngineDesign solves ``points`` (each with p_O, p_F).

* ``chamber_*``: the chamber tables given EngineDesign's own flows.
* ``dp_*``: each injector table given EngineDesign's flow and line pressure.
* ``closed_*``: the card solved as a whole at the line pressures (:func:`solve_card`), against
  EngineDesign at the same pressures. This is what a burn sees.

Definition at line 260 of file card.py.

References max, and solve_card().

Referenced by build_card().

◆ expansion_chamber()

Any engine.layerx.card.expansion_chamber ( Any card,
Any cea_cache,
* ,
float ambient_pressure,
float volume = 0.0 )
``ExpansionCardChamber`` on EngineDesign's CEA table (``cea_cache.eval_cf_vac``): the chamber
to put in the twin in place of ``card.chamber_model(...)`` when the option is on.

Definition at line 494 of file card.py.

References expansion_chamber_class().

◆ expansion_chamber_class()

type engine.layerx.card.expansion_chamber_class ( )
``ExpansionCardChamber``: :class:`_ExpansionScaling` over feedtwin's ``CardChamber``.

Definition at line 477 of file card.py.

Referenced by __getattr__(), and expansion_chamber().

◆ fit_card()

engine.layerx.card.fit_card ( Sequence[Dict[str, float]] samples,
* ,
float throat_area,
float exit_area,
float ambient_pa,
str name )
Tables through ``samples`` (line-exit operating points with ``p_O``, ``p_F``).

Definition at line 189 of file card.py.

References _axis(), _hull(), _rbf(), and _table().

Referenced by build_card().

◆ line_exit_config()

Any engine.layerx.card.line_exit_config ( Any config)
A copy of ``config`` whose feed lines lose nothing but the exit dump into the manifold.

``supply_K`` goes with ``K0``: it is the share of ``K0`` that is the pressurant supply sagging
under flow (Layer X's feed fit writes it), and the chug loop subtracts it from the feed drop it
takes as line resistance (stability/analysis.py ``_chug_feed_drop``). With ``K0`` zeroed the
drop left is the exit dump alone, which holds no supply share; left in, a feed-fit write took
the chug gate from 1.330 to 1.248 with nothing physical changed (audit D7, 5.3). A config with
``supply_K`` 0 (LE4) is unchanged by this.

Definition at line 86 of file card.py.

◆ solve_card()

Optional[Dict[str, float]] engine.layerx.card.solve_card ( Any card,
float p_O,
float p_F,
float ambient_pa )
The card's own operating point at line-exit pressures ``p_O``, ``p_F``: Pc such that the
flows each injector passes at that Pc are the flows that make that Pc. Independent of the twin's
network, so it checks the card and nothing else.

Definition at line 228 of file card.py.

References g, max, and min.

Referenced by check_card().

Variable Documentation

◆ _CACHE

str engine.layerx.card._CACHE = OrderedDict()
protected

Definition at line 507 of file card.py.

◆ _CACHE_LOCK

engine.layerx.card._CACHE_LOCK = threading.Lock()
protected

Definition at line 508 of file card.py.

◆ _CACHE_SIZE

int engine.layerx.card._CACHE_SIZE = 8
protected

Definition at line 509 of file card.py.

◆ BOUNDARY

tuple engine.layerx.card.BOUNDARY
Initial value:
1= ("line exit: EngineDesign's feed_system with K0, K1, fittings and friction zeroed and "
2 "the Borda exit dump kept; the drawing's lines carry every loss upstream of it")

Definition at line 79 of file card.py.

◆ CHAMBER_GRID

tuple engine.layerx.card.CHAMBER_GRID = (41, 41)

Definition at line 76 of file card.py.

◆ ENVELOPE_LEVELS

tuple engine.layerx.card.ENVELOPE_LEVELS = (0.70, 1.15)

Definition at line 73 of file card.py.

◆ ENVELOPE_RATIOS

tuple engine.layerx.card.ENVELOPE_RATIOS = (0.90, 1.12)

Definition at line 74 of file card.py.

◆ INJECTOR_GRID

tuple engine.layerx.card.INJECTOR_GRID = (41, 21)

Definition at line 77 of file card.py.

◆ LEVELS

tuple engine.layerx.card.LEVELS = (0.40, 1.30, 21)

Definition at line 65 of file card.py.

◆ PSI

float engine.layerx.card.PSI = 6894.757293168361

Definition at line 57 of file card.py.

◆ RATIOS

tuple engine.layerx.card.RATIOS = (0.75, 1.30, 13)

Definition at line 66 of file card.py.

◆ TOLERANCE

float engine.layerx.card.TOLERANCE = 2.0e-3

Definition at line 61 of file card.py.