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

Functions

Tuple[Tuple[float, float], Tuple[float, float]] injector_dp_bands_from_requirements (Dict[str, Any] requirements, *, Tuple[float, float] default_o=_DEFAULT_DP_O_BAND, Tuple[float, float] default_f=_DEFAULT_DP_F_BAND)
Optional[bool] injector_dp_ratio_within_gate (Optional[float] r, float lo, float hi, *, float rtol=_DEFAULT_INJECTOR_DP_GATE_RTOL, float atol_floor=5.0e-7)
float stream_injector_dp_soft_floor_squared (Optional[float] r, Optional[float] floor)
float stream_injector_dp_band_hinge_squared (Optional[float] r, float lo, float hi)
float stream_injector_dp_center_squared (Optional[float] r, float lo, float hi)
float injector_dp_ratio_penalty_weighted (Optional[float] ratio_o, Optional[float] ratio_f, float w_dp, float w_dp_high=0.0, *, Tuple[float, float] o_band=(0.20, 0.40), Tuple[float, float] f_band=(0.50, 1.20), Optional[float] w_dp_o=None, Optional[float] w_dp_f=None, Optional[float] o_soft_floor=None, float w_dp_o_floor=0.0, float w_dp_center=0.0)
Tuple[float, float] stream_injector_dp_raw_terms (float r)
Tuple[Optional[float], Optional[float]] injector_dp_ratios_from_eval_result (float pc, Dict[str, Any] result)

Variables

float _DEFAULT_INJECTOR_DP_GATE_RTOL = 2.0e-4
tuple _DEFAULT_DP_O_BAND = (0.20, 0.40)
tuple _DEFAULT_DP_F_BAND = (0.20, 0.40)
tuple _LEGACY_DP_BAND = (0.15, 0.35)

Detailed Description

Layer-1 injector pressure-drop ratio penalty: per-stream quadratic hinge on ΔP_inj / Pc.

Function Documentation

◆ injector_dp_bands_from_requirements()

Tuple[Tuple[float, float], Tuple[float, float]] engine.optimizer.injector_dp_penalty.injector_dp_bands_from_requirements ( Dict[str, Any] requirements,
* ,
Tuple[float, float] default_o = _DEFAULT_DP_O_BAND,
Tuple[float, float] default_f = _DEFAULT_DP_F_BAND )
Read oxidizer/fuel ΔP_inj/Pc bands; migrate legacy [0.15, 0.35] yaml to [0.20, 0.40].

Definition at line 20 of file injector_dp_penalty.py.

◆ injector_dp_ratio_penalty_weighted()

float engine.optimizer.injector_dp_penalty.injector_dp_ratio_penalty_weighted ( Optional[float] ratio_o,
Optional[float] ratio_f,
float w_dp,
float w_dp_high = 0.0,
* ,
Tuple[float, float] o_band = (0.20, 0.40),
Tuple[float, float] f_band = (0.50, 1.20),
Optional[float] w_dp_o = None,
Optional[float] w_dp_f = None,
Optional[float] o_soft_floor = None,
float w_dp_o_floor = 0.0,
float w_dp_center = 0.0 )
Soft weighted penalty for oxidizer and fuel ΔP_inj/Pc ratios (independent bands).

Per-stream weights: if ``w_dp_o`` / ``w_dp_f`` are None, both streams use ``w_dp``.
Otherwise ``injector_penalty = w_dp_o * hinge_O + w_dp_f * hinge_F``.

Optionally adds ``w_dp_o_floor * (max(0, o_soft_floor - ratio_o))**2`` when
``o_soft_floor`` is set (stronger discourage very low oxidizer ΔP/Pc).

``w_dp_center`` (>0) adds a gentle ``w_dp_center * ((r - mid)/span)**2`` per stream that
pulls each ratio toward the CENTRE of its pass band — the "soft target" so the optimizer
settles near the middle (~0.30 for a [0.20,0.40] band) rather than the 0.40 edge. It is
deliberately small relative to the band hinge so it only breaks ties inside the band and
never overrides feasibility/thrust/O-F.

``w_dp_high`` is retained for call-site compatibility but does not contribute (legacy tier removed).

Definition at line 128 of file injector_dp_penalty.py.

References stream_injector_dp_band_hinge_squared(), stream_injector_dp_center_squared(), and stream_injector_dp_soft_floor_squared().

◆ injector_dp_ratio_within_gate()

Optional[bool] engine.optimizer.injector_dp_penalty.injector_dp_ratio_within_gate ( Optional[float] r,
float lo,
float hi,
* ,
float rtol = _DEFAULT_INJECTOR_DP_GATE_RTOL,
float atol_floor = 5.0e-7 )
True if finite ``r`` lies in ``[lo, hi]`` with a small symmetric margin at the edges.

Definition at line 41 of file injector_dp_penalty.py.

References max.

◆ injector_dp_ratios_from_eval_result()

Tuple[Optional[float], Optional[float]] engine.optimizer.injector_dp_penalty.injector_dp_ratios_from_eval_result ( float pc,
Dict[str, Any] result )
ΔP_inj / Pc using **injector-face** ΔP only (not tank−Pc).

Impinging feed coupling produces ``diagnostics['delta_p_injector_{O,F}']`` =
``P_inj − Pc``, where ``P_inj`` is stagnation **after** ``delta_p_feed`` from the tank.
Ratios used for Layer‑1 gates and penalties are ``delta_p_injector_* / Pc``.

Definition at line 181 of file injector_dp_penalty.py.

◆ stream_injector_dp_band_hinge_squared()

float engine.optimizer.injector_dp_penalty.stream_injector_dp_band_hinge_squared ( Optional[float] r,
float lo,
float hi )
Normalized squared hinge penalty outside [lo, hi]. Zero when lo <= r <= hi.

Normalization by band width keeps penalty strength consistent across different
configured bands and avoids under-penalizing small absolute misses.

Definition at line 81 of file injector_dp_penalty.py.

References max.

Referenced by injector_dp_ratio_penalty_weighted(), and stream_injector_dp_raw_terms().

◆ stream_injector_dp_center_squared()

float engine.optimizer.injector_dp_penalty.stream_injector_dp_center_squared ( Optional[float] r,
float lo,
float hi )
Normalized squared deviation from the band CENTRE: ``((r - mid)/span)**2``.

Unlike the hinge (which is zero everywhere inside the band), this is nonzero inside the
band too, so a small weight on it gives the optimizer a gentle preference for the middle
of the pass band instead of parking on an edge (e.g. 0.40). Zero for missing/non-finite
``r`` or an invalid band.

Definition at line 104 of file injector_dp_penalty.py.

References max.

Referenced by injector_dp_ratio_penalty_weighted().

◆ stream_injector_dp_raw_terms()

Tuple[float, float] engine.optimizer.injector_dp_penalty.stream_injector_dp_raw_terms ( float r)
Deprecated: symmetric LOX-style band (0.20, 0.35). Returns (hinge, 0).

Definition at line 175 of file injector_dp_penalty.py.

References stream_injector_dp_band_hinge_squared().

◆ stream_injector_dp_soft_floor_squared()

float engine.optimizer.injector_dp_penalty.stream_injector_dp_soft_floor_squared ( Optional[float] r,
Optional[float] floor )
Squared shortfall when ratio < floor (extra cost for LOX ΔP_inj/Pc too low).

Returns 0 when ``floor`` is None or ``r`` is missing/non-finite.

Definition at line 66 of file injector_dp_penalty.py.

References max.

Referenced by injector_dp_ratio_penalty_weighted().

Variable Documentation

◆ _DEFAULT_DP_F_BAND

tuple engine.optimizer.injector_dp_penalty._DEFAULT_DP_F_BAND = (0.20, 0.40)
protected

Definition at line 16 of file injector_dp_penalty.py.

◆ _DEFAULT_DP_O_BAND

tuple engine.optimizer.injector_dp_penalty._DEFAULT_DP_O_BAND = (0.20, 0.40)
protected

Definition at line 15 of file injector_dp_penalty.py.

◆ _DEFAULT_INJECTOR_DP_GATE_RTOL

float engine.optimizer.injector_dp_penalty._DEFAULT_INJECTOR_DP_GATE_RTOL = 2.0e-4
protected

Definition at line 12 of file injector_dp_penalty.py.

◆ _LEGACY_DP_BAND

tuple engine.optimizer.injector_dp_penalty._LEGACY_DP_BAND = (0.15, 0.35)
protected

Definition at line 17 of file injector_dp_penalty.py.