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

Classes

class  Variable
class  OptimizeRequest
class  HardwareRequest

Functions

List[Variable] default_variables (Any prep, Any config)
List[Variable] resolve_variables (Any prep, Any config, OptimizeRequest request)
Tuple[Any, List[Any]] _candidate (Any settings, List[Variable] variables, Dict[str, float] x, Optional[str] copv_id, str objective, float center_psia)
Dict[str, Any] _figures (Dict[str, Any] res)
Dict[str, Any] _evaluate (Tuple[Any,...] args)
Dict[str, Any] grade (Dict[str, Any] e, OptimizeRequest request, Dict[str, Optional[List[float]]] band, Optional[float] design_of)
Tuple[int, float, float] _rank (Dict[str, Any] g)
Dict[str, Any] run_optimize (Any config, Any drawing, Any settings, List[Any] overrides, OptimizeRequest request, *, Optional[Callable[[str, float], None]] progress=None, Callable[[], bool] cancelled=lambda:False, Optional[int] workers=None)
Dict[str, Any] _verify (Any config, Any drawing, Any settings, List[Any] overrides, List[Variable] variables, Dict[str, float] x, Optional[str] copv_id, OptimizeRequest request, Dict[str, Optional[List[float]]] band, Optional[float] design_of, Optional[Dict[str, Any]] start_entry)
Dict[str, Any] _payload_with (Any prep)
Optional[Dict[str, Any]] _element (Dict[str, Any] payload, str target)
Optional[Dict[str, Any]] _param (Dict[str, Any] element, str name)
Optional[float] _mm (Optional[Dict[str, Any]] p)
Optional[str] _edge_side (Dict[str, Any] payload, Dict[str, Any] edge, Dict[str, str] species)
float trim_orifice_K (float line_bore_m, float orifice_bore_m, float C)
float trim_orifice_C (float line_bore_m, float orifice_bore_m, float rho, float mu, float mdot, str taps=TRIM_TAPS)
Dict[str, Any] _trim_model (str line, float D_m, float rho, float mu, float mdot, Optional[float] C_given)
Optional[Dict[str, Any]] _option_from_row (str target, Dict[str, Any] element, Dict[str, Any] row, str label)
Dict[str, Any] plan_candidates (Any prep, Any config, HardwareRequest request, Dict[str, Any] catalogs, Optional[Dict[str, Any]] baseline=None)
List[Dict[str, Any]] _trim_options (Any prep, Dict[str, Any] payload, Dict[str, Any] element, str target, str label, str side, float D_mm, Dict[str, Any] baseline, HardwareRequest request, Dict[str, Any] catalogs, int n, List[str] notes)
Optional[float] _objective (Optional[Dict[str, Any]] figs, HardwareRequest request, Optional[float] target_F, Optional[float] design_of)
Tuple[int, int, float] _hw_rank (Dict[str, Any] c)
List[Dict[str, Any]] _hw_changes (List[Dict[str, Any]] options)
Optional[Dict[str, Any]] _design_updates (List[Dict[str, Any]] options)
Optional[Dict[str, Dict[str, float]]] _merged_patch (List[Dict[str, Any]] options)
Dict[str, Any] run_hardware (Any config, Any drawing, Any settings, List[Any] overrides, HardwareRequest request, *, Optional[Dict[str, Any]] catalogs=None, Optional[Callable[[str, float], None]] progress=None, Callable[[], bool] cancelled=lambda:False, Optional[int] workers=None, Optional[Callable[[List[Dict[str, Any]]], List[Dict[str, Any]]]] evaluate=None, Any prep=None)

Variables

float PSI = 6894.757293168361
float FIRST_STEP = 0.25
float MIN_STEP = 1.0 / 32.0
int FEASIBLE = 1e-6
tuple OBJECTIVES = ("impulse", "apogee")
tuple HW_OBJECTIVES = ("target_thrust_error", "thrust_flatness", "of_error", "impulse", "bottle_margin")
str TRIM_TAPS = "corner"

Detailed Description

Phase 4: the feed hardware that gets the most out of a fixed propellant load.

Layer 1 sizes the engine at one operating point. This searches the *hardware around it*, with
the whole burn simulated for every candidate. The decision variables are things a person can
set or buy:

* **tank lockup** [psia]: the dome dial, solved per candidate from the drawing's regulators;
* **COPV fill** [psig]: how full the bottle is at T-0;
* **COPV volume** [L], off by default: a different bottle. Its structure scales with its volume
  in the flight (``flight._flight_config``).

The pressurant gas is the drawing's, so to compare GN2 against helium, run each drawing.

The objective is **total impulse** (the tanks burnt dry) or, with the flight on, **apogee**, both at
the fixed load.
Every constraint is checked over the whole burn:

* **regulator headroom**: the bottle at burnout stays above the lockup by a stated margin;
* **injector stiffness**: each side's lowest ΔP/Pc stays above the config's band floor (chug);
* **O/F band** (optional): the burn's O/F within a stated fraction of the design O/F;
* **apogee ceiling**, when the config declares one (``design_requirements.max_apogee_m``);
* everything preflight fails on, such as a tank or bottle MAWP or a load that does not fit.

**Search.** A parallel compass search over the variables scaled to [0, 1]. Each iteration burns
the centre's 2k neighbours at once on a process pool. It moves to the best one when that beats
the centre; otherwise it halves the step. It stops when the step falls below 1/32 of the range or
the evaluation budget runs out. Candidates are ranked feasible-first, then by total constraint
violation, then by objective (Deb's rules), so no penalty weight has to be tuned. The search is
derivative-free because a burn's answer moves in steps: the burn ends on a time step, and a
regulator either holds lockup or drops out. Deterministic: the same request gives the same
path.

**Fidelity.** Candidates burn on one engine card, centred on the lockup range, without the
erosion replay. The replay moves every candidate by nearly the same amount, so leaving it out
does not reorder them. The winner is then **verified**: burned again with its own card, the
replay, and the flight if the objective is apogee. The verified numbers are the ones reported
as the answer.

Function Documentation

◆ _candidate()

Tuple[Any, List[Any]] engine.layerx.optimize._candidate ( Any settings,
List[Variable] variables,
Dict[str, float] x,
Optional[str] copv_id,
str objective,
float center_psia )
protected

Definition at line 158 of file optimize.py.

Referenced by _evaluate(), and _verify().

◆ _design_updates()

Optional[Dict[str, Any]] engine.layerx.optimize._design_updates ( List[Dict[str, Any]] options)
protected

Definition at line 899 of file optimize.py.

Referenced by run_hardware().

◆ _edge_side()

Optional[str] engine.layerx.optimize._edge_side ( Dict[str, Any] payload,
Dict[str, Any] edge,
Dict[str, str] species )
protected

Definition at line 568 of file optimize.py.

Referenced by plan_candidates().

◆ _element()

Optional[Dict[str, Any]] engine.layerx.optimize._element ( Dict[str, Any] payload,
str target )
protected

Definition at line 551 of file optimize.py.

Referenced by plan_candidates().

◆ _evaluate()

Dict[str, Any] engine.layerx.optimize._evaluate ( Tuple[Any, ...] args)
protected
Burn one candidate, start to finish, in whatever process runs it.

Definition at line 206 of file optimize.py.

References _candidate(), and _figures().

◆ _figures()

Dict[str, Any] engine.layerx.optimize._figures ( Dict[str, Any] res)
protected
What a candidate's burn says, flat.

Definition at line 174 of file optimize.py.

Referenced by _evaluate(), and _verify().

◆ _hw_changes()

List[Dict[str, Any]] engine.layerx.optimize._hw_changes ( List[Dict[str, Any]] options)
protected

Definition at line 873 of file optimize.py.

Referenced by run_hardware().

◆ _hw_rank()

Tuple[int, int, float] engine.layerx.optimize._hw_rank ( Dict[str, Any] c)
protected

Definition at line 863 of file optimize.py.

◆ _merged_patch()

Optional[Dict[str, Dict[str, float]]] engine.layerx.optimize._merged_patch ( List[Dict[str, Any]] options)
protected

Definition at line 918 of file optimize.py.

Referenced by run_hardware().

◆ _mm()

Optional[float] engine.layerx.optimize._mm ( Optional[Dict[str, Any]] p)
protected

Definition at line 562 of file optimize.py.

Referenced by plan_candidates().

◆ _objective()

Optional[float] engine.layerx.optimize._objective ( Optional[Dict[str, Any]] figs,
HardwareRequest request,
Optional[float] target_F,
Optional[float] design_of )
protected
Smaller is better.

Definition at line 843 of file optimize.py.

Referenced by run_hardware().

◆ _option_from_row()

Optional[Dict[str, Any]] engine.layerx.optimize._option_from_row ( str target,
Dict[str, Any] element,
Dict[str, Any] row,
str label )
protected
A catalogue row as one option: the drawing restatements it makes, and the change records.

Definition at line 624 of file optimize.py.

References _param(), and max.

Referenced by plan_candidates().

◆ _param()

Optional[Dict[str, Any]] engine.layerx.optimize._param ( Dict[str, Any] element,
str name )
protected

Definition at line 557 of file optimize.py.

Referenced by _option_from_row(), _trim_options(), and plan_candidates().

◆ _payload_with()

Dict[str, Any] engine.layerx.optimize._payload_with ( Any prep)
protected
The drawing as this burn reads it: the person's restatements written in.

Definition at line 543 of file optimize.py.

Referenced by plan_candidates().

◆ _rank()

Tuple[int, float, float] engine.layerx.optimize._rank ( Dict[str, Any] g)
protected

Definition at line 294 of file optimize.py.

Referenced by run_optimize().

◆ _trim_model()

Dict[str, Any] engine.layerx.optimize._trim_model ( str line,
float D_m,
float rho,
float mu,
float mdot,
Optional[float] C_given )
protected

Definition at line 596 of file optimize.py.

Referenced by _trim_options().

◆ _trim_options()

List[Dict[str, Any]] engine.layerx.optimize._trim_options ( Any prep,
Dict[str, Any] payload,
Dict[str, Any] element,
str target,
str label,
str side,
float D_mm,
Dict[str, Any] baseline,
HardwareRequest request,
Dict[str, Any] catalogs,
int n,
List[str] notes )
protected
Trim bores around the one that would take O/F to the design's, priced as K_minor.

Definition at line 770 of file optimize.py.

References _param(), _trim_model(), max, trim_orifice_C(), and trim_orifice_K().

Referenced by plan_candidates().

◆ _verify()

Dict[str, Any] engine.layerx.optimize._verify ( Any config,
Any drawing,
Any settings,
List[Any] overrides,
List[Variable] variables,
Dict[str, float] x,
Optional[str] copv_id,
OptimizeRequest request,
Dict[str, Optional[List[float]]] band,
Optional[float] design_of,
Optional[Dict[str, Any]] start_entry )
protected
The winner, and the starting point, burned the way a Layer X run burns them.

Definition at line 449 of file optimize.py.

References _candidate(), _figures(), and grade().

Referenced by run_optimize().

◆ default_variables()

List[Variable] engine.layerx.optimize.default_variables ( Any prep,
Any config )
The decision variables and their bounds, each bound with its reason.

Definition at line 100 of file optimize.py.

References max, and min.

Referenced by resolve_variables().

◆ grade()

Dict[str, Any] engine.layerx.optimize.grade ( Dict[str, Any] e,
OptimizeRequest request,
Dict[str, Optional[List[float]]] band,
Optional[float] design_of )
Objective and constraints for one evaluated candidate. Violations are relative, so they add
without weights; ``violation`` is their sum.

Definition at line 232 of file optimize.py.

References max.

Referenced by _verify(), and run_optimize().

◆ plan_candidates()

Dict[str, Any] engine.layerx.optimize.plan_candidates ( Any prep,
Any config,
HardwareRequest request,
Dict[str, Any] catalogs,
Optional[Dict[str, Any]] baseline = None )
Every component's options, and the candidates (one option each, or combinations).

Raises ``ValueError`` for a component the drawing or design does not have, or one no catalogue
row fits. A trim orifice is sized from the ``baseline`` burn's flow; without one it is listed as
pending.

Definition at line 654 of file optimize.py.

References _edge_side(), _element(), _mm(), _option_from_row(), _param(), _payload_with(), _trim_options(), max, and split().

Referenced by run_hardware().

◆ resolve_variables()

List[Variable] engine.layerx.optimize.resolve_variables ( Any prep,
Any config,
OptimizeRequest request )

Definition at line 142 of file optimize.py.

References default_variables(), max, and min.

Referenced by run_optimize().

◆ run_hardware()

Dict[str, Any] engine.layerx.optimize.run_hardware ( Any config,
Any drawing,
Any settings,
List[Any] overrides,
HardwareRequest request,
* ,
Optional[Dict[str, Any]] catalogs = None,
Optional[Callable[[str, float], None]] progress = None,
Callable[[], bool] cancelled = lambda: False,
Optional[int] workers = None,
Optional[Callable[[List[Dict[str, Any]]], List[Dict[str, Any]]]] evaluate = None,
Any prep = None )
Catalogue parts for the marked components, each a whole burn, ranked by ``request.objective``.

``evaluate(args_list)`` replaces the burns and ``prep`` the preflight (tests).

Definition at line 926 of file optimize.py.

References _design_updates(), _hw_changes(), _merged_patch(), _objective(), max, and plan_candidates().

◆ run_optimize()

Dict[str, Any] engine.layerx.optimize.run_optimize ( Any config,
Any drawing,
Any settings,
List[Any] overrides,
OptimizeRequest request,
* ,
Optional[Callable[[str, float], None]] progress = None,
Callable[[], bool] cancelled = lambda: False,
Optional[int] workers = None )

Definition at line 302 of file optimize.py.

References _rank(), _verify(), grade(), max, min, and resolve_variables().

◆ trim_orifice_C()

float engine.layerx.optimize.trim_orifice_C ( float line_bore_m,
float orifice_bore_m,
float rho,
float mu,
float mdot,
str taps = TRIM_TAPS )
Reader-Harris/Gallagher discharge coefficient (``fluids.flow_meter.C_Reader_Harris_Gallagher``,
ISO 5167-2:2003). Outside its range here (D < 50 mm, beta > 0.75): an extrapolation.

Definition at line 587 of file optimize.py.

Referenced by _trim_options().

◆ trim_orifice_K()

float engine.layerx.optimize.trim_orifice_K ( float line_bore_m,
float orifice_bore_m,
float C )
Permanent-loss coefficient of a thin orifice plate, referred to the line's velocity head:
K = [sqrt(1 - beta^4 (1 - C^2)) / (C beta^2) - 1]^2 (``fluids.flow_meter.discharge_coefficient_to_K``,
after ASME MFC-3M-2004 and ISO 5167-2:2003).

Definition at line 578 of file optimize.py.

Referenced by _trim_options().

Variable Documentation

◆ FEASIBLE

int engine.layerx.optimize.FEASIBLE = 1e-6

Definition at line 56 of file optimize.py.

◆ FIRST_STEP

float engine.layerx.optimize.FIRST_STEP = 0.25

Definition at line 50 of file optimize.py.

◆ HW_OBJECTIVES

tuple engine.layerx.optimize.HW_OBJECTIVES = ("target_thrust_error", "thrust_flatness", "of_error", "impulse", "bottle_margin")

Definition at line 490 of file optimize.py.

◆ MIN_STEP

float engine.layerx.optimize.MIN_STEP = 1.0 / 32.0

Definition at line 51 of file optimize.py.

◆ OBJECTIVES

tuple engine.layerx.optimize.OBJECTIVES = ("impulse", "apogee")

Definition at line 58 of file optimize.py.

◆ PSI

float engine.layerx.optimize.PSI = 6894.757293168361

Definition at line 47 of file optimize.py.

◆ TRIM_TAPS

str engine.layerx.optimize.TRIM_TAPS = "corner"

Definition at line 496 of file optimize.py.