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

Functions

None _add_engine_sim_to_path (Path project_root)
 _load_engine_only (Path engine_config_path)
 _load_engine_and_controller (Path engine_config_path, Path|None controller_config_path, Path|None engine_lut_path=None, Path|None project_root=None)
Tuple[List[str], List[np.ndarray]] _build_axes (ControllerLUTConfig config)
Tuple[int, int] _find_required_pressure_axes (List[str] axis_names)
float _get_axis_value (List[str] axis_names, List[float] coords, str name, float default)
float _map_engine_output (Any est, str out_name)
Tuple[float, float] _duty_from_thrust_and_mr (np.ndarray u_safe, List[str] axis_names, List[float] coords, Any eng_est, Any get_axis)
float _duty_from_thrust (np.ndarray u_safe, List[str] axis_names, List[float] coords, Any eng_est, int idx, Any get_axis)
None _init_engine_worker (str engine_config_path, str project_root, List[str] axis_names, List[np.ndarray] grids, Tuple[int,...] axis_sizes, List[str] output_names)
Tuple[Tuple[int,...], Dict[str, float]] _compute_engine_point_sequential (int flat_idx, List[str] axis_names, List[np.ndarray] grids, Tuple[int,...] axis_sizes, List[str] output_names, Any engine_wrapper)
Tuple[Tuple[int,...], Dict[str, float]] _compute_engine_point (int flat_idx)
None _init_ddp_worker (str engine_config_path, str controller_config_path, str engine_lut_path, str project_root, List[str] axis_names, List[np.ndarray] grids, Tuple[int,...] axis_sizes, List[str] output_names)
Tuple[Tuple[int,...], Dict[str, float]] _compute_ddp_point_sequential (int flat_idx, List[str] axis_names, List[np.ndarray] grids, Tuple[int,...] axis_sizes, List[str] output_names, Any controller, Any engine_wrapper, Any Measurement, Any NavState, Any Command, Any CommandType)
Tuple[Tuple[int,...], Dict[str, float]] _compute_ddp_point (int flat_idx)
None generate_lut (Path lut_config_path, Path output_path, Path project_root, int jobs=1)
None main (list[str]|None argv=None)

Variables

 _worker_controller = None
 _worker_engine_wrapper = None
 _worker_axis_names = None
 _worker_grids = None
 _worker_axis_sizes = None
 _worker_output_names = None
 _worker_Measurement = None
 _worker_NavState = None
 _worker_Command = None
 _worker_CommandType = None
float G0 = 9.80665

Function Documentation

◆ _add_engine_sim_to_path()

None controller_lut.generate_controller_lut._add_engine_sim_to_path ( Path project_root)
protected
Ensure the engine_sim submodule is importable as a Python package.

We do not modify any files inside engine_sim; we only import and use its
public APIs.

Definition at line 28 of file generate_controller_lut.py.

Referenced by _init_ddp_worker(), _init_engine_worker(), and generate_lut().

◆ _build_axes()

Tuple[List[str], List[np.ndarray]] controller_lut.generate_controller_lut._build_axes ( ControllerLUTConfig config)
protected

Definition at line 103 of file generate_controller_lut.py.

Referenced by generate_lut().

◆ _compute_ddp_point()

Tuple[Tuple[int, ...], Dict[str, float]] controller_lut.generate_controller_lut._compute_ddp_point ( int flat_idx)
protected
Compute a single DDP grid point. Uses worker globals.

Definition at line 500 of file generate_controller_lut.py.

References _duty_from_thrust(), _get_axis_value(), _worker_Command, _worker_Measurement, and _worker_NavState.

◆ _compute_ddp_point_sequential()

Tuple[Tuple[int, ...], Dict[str, float]] controller_lut.generate_controller_lut._compute_ddp_point_sequential ( int flat_idx,
List[str] axis_names,
List[np.ndarray] grids,
Tuple[int, ...] axis_sizes,
List[str] output_names,
Any controller,
Any engine_wrapper,
Any Measurement,
Any NavState,
Any Command,
Any CommandType )
protected
Compute a single DDP grid point (main process, no worker).

Definition at line 352 of file generate_controller_lut.py.

References _duty_from_thrust(), and _get_axis_value().

Referenced by generate_lut().

◆ _compute_engine_point()

Tuple[Tuple[int, ...], Dict[str, float]] controller_lut.generate_controller_lut._compute_engine_point ( int flat_idx)
protected
Compute a single engine-only grid point. Uses worker globals.

Definition at line 300 of file generate_controller_lut.py.

References _map_engine_output().

◆ _compute_engine_point_sequential()

Tuple[Tuple[int, ...], Dict[str, float]] controller_lut.generate_controller_lut._compute_engine_point_sequential ( int flat_idx,
List[str] axis_names,
List[np.ndarray] grids,
Tuple[int, ...] axis_sizes,
List[str] output_names,
Any engine_wrapper )
protected
Compute a single engine-only grid point (main process, no worker).

Definition at line 280 of file generate_controller_lut.py.

References _map_engine_output().

Referenced by generate_lut().

◆ _duty_from_thrust()

float controller_lut.generate_controller_lut._duty_from_thrust ( np.ndarray u_safe,
List[str] axis_names,
List[float] coords,
Any eng_est,
int idx,
Any get_axis )
protected
Legacy: return duty_F or duty_O from MR-aware computation.

Definition at line 245 of file generate_controller_lut.py.

References _duty_from_thrust_and_mr().

Referenced by _compute_ddp_point(), and _compute_ddp_point_sequential().

◆ _duty_from_thrust_and_mr()

Tuple[float, float] controller_lut.generate_controller_lut._duty_from_thrust_and_mr ( np.ndarray u_safe,
List[str] axis_names,
List[float] coords,
Any eng_est,
Any get_axis )
protected
Compute duty_F and duty_O from (F_ref, MR_ref, F_engine) for MR-aware control.
Uses mass-flow scaling: duty_i = throttle * min(1, mdot_i_des / mdot_i_engine).
- F_ref=0: duty_F=duty_O=0
- F_ref < F_engine*0.80: throttle=0 (or 0.06 baseline if F_ref>500)
- F_ref in [F_engine*0.80, F_engine]: throttle 0.10..0.30 (maintenance)
- F_ref > F_engine: throttle 0.30 + 0.65*(deficit/7000), cap 0.95

Definition at line 182 of file generate_controller_lut.py.

References max, and min.

Referenced by _duty_from_thrust().

◆ _find_required_pressure_axes()

Tuple[int, int] controller_lut.generate_controller_lut._find_required_pressure_axes ( List[str] axis_names)
protected
Locate indices of P_u_fuel and P_u_ox axes.

These are required because EngineWrapper.estimate_from_pressures expects
tank/ullage pressures for fuel and oxidizer.

Definition at line 119 of file generate_controller_lut.py.

Referenced by generate_lut().

◆ _get_axis_value()

float controller_lut.generate_controller_lut._get_axis_value ( List[str] axis_names,
List[float] coords,
str name,
float default )
protected
Helper to read a coordinate for a named axis with a default.

Definition at line 137 of file generate_controller_lut.py.

Referenced by _compute_ddp_point(), and _compute_ddp_point_sequential().

◆ _init_ddp_worker()

None controller_lut.generate_controller_lut._init_ddp_worker ( str engine_config_path,
str controller_config_path,
str engine_lut_path,
str project_root,
List[str] axis_names,
List[np.ndarray] grids,
Tuple[int, ...] axis_sizes,
List[str] output_names )
protected
Initialize worker for DDP LUT generation.

Definition at line 315 of file generate_controller_lut.py.

References _add_engine_sim_to_path(), and _load_engine_and_controller().

◆ _init_engine_worker()

None controller_lut.generate_controller_lut._init_engine_worker ( str engine_config_path,
str project_root,
List[str] axis_names,
List[np.ndarray] grids,
Tuple[int, ...] axis_sizes,
List[str] output_names )
protected
Initialize worker for engine-only LUT generation.

Definition at line 260 of file generate_controller_lut.py.

References _add_engine_sim_to_path(), and _load_engine_only().

◆ _load_engine_and_controller()

controller_lut.generate_controller_lut._load_engine_and_controller ( Path engine_config_path,
Path | None controller_config_path,
Path | None engine_lut_path = None,
Path | None project_root = None )
protected
Load engine + controller configs and construct a RobustDDPController.
When engine_lut_path is set, controller uses EngineLUTWrapper for fast lookups.

Definition at line 57 of file generate_controller_lut.py.

Referenced by _init_ddp_worker(), and generate_lut().

◆ _load_engine_only()

controller_lut.generate_controller_lut._load_engine_only ( Path engine_config_path)
protected
Import engine_sim components and load the engine configuration
for pure engine-performance LUTs (no DDP).

Returns
-------
(engine_config, EngineWrapper)

Definition at line 40 of file generate_controller_lut.py.

Referenced by _init_engine_worker(), and generate_lut().

◆ _map_engine_output()

float controller_lut.generate_controller_lut._map_engine_output ( Any est,
str out_name )
protected
Map EngineEstimate to a single output value.

Definition at line 147 of file generate_controller_lut.py.

Referenced by _compute_engine_point(), and _compute_engine_point_sequential().

◆ generate_lut()

None controller_lut.generate_controller_lut.generate_lut ( Path lut_config_path,
Path output_path,
Path project_root,
int jobs = 1 )
Generate a high-dimensional LUT.

Modes:
- Engine-only mode (no controller_config_path): map tank pressures to
  engine performance (F, MR, Pc, mdots, stability, etc.) using EngineWrapper.
- DDP mode (controller_config_path set): run RobustDDPController for each
  grid point and record both engine predictions and optimal control
  quantities (duty cycles, relaxed controls, etc.).

Definition at line 647 of file generate_controller_lut.py.

References _add_engine_sim_to_path(), _build_axes(), _compute_ddp_point_sequential(), _compute_engine_point_sequential(), _find_required_pressure_axes(), _load_engine_and_controller(), _load_engine_only(), and max.

Referenced by main().

◆ main()

None controller_lut.generate_controller_lut.main ( list[str] | None argv = None)

Definition at line 849 of file generate_controller_lut.py.

References generate_lut(), and main().

Variable Documentation

◆ _worker_axis_names

controller_lut.generate_controller_lut._worker_axis_names = None
protected

Definition at line 18 of file generate_controller_lut.py.

◆ _worker_axis_sizes

controller_lut.generate_controller_lut._worker_axis_sizes = None
protected

Definition at line 20 of file generate_controller_lut.py.

◆ _worker_Command

controller_lut.generate_controller_lut._worker_Command = None
protected

Definition at line 24 of file generate_controller_lut.py.

Referenced by _compute_ddp_point().

◆ _worker_CommandType

controller_lut.generate_controller_lut._worker_CommandType = None
protected

Definition at line 25 of file generate_controller_lut.py.

◆ _worker_controller

controller_lut.generate_controller_lut._worker_controller = None
protected

Definition at line 16 of file generate_controller_lut.py.

◆ _worker_engine_wrapper

controller_lut.generate_controller_lut._worker_engine_wrapper = None
protected

Definition at line 17 of file generate_controller_lut.py.

◆ _worker_grids

controller_lut.generate_controller_lut._worker_grids = None
protected

Definition at line 19 of file generate_controller_lut.py.

◆ _worker_Measurement

controller_lut.generate_controller_lut._worker_Measurement = None
protected

Definition at line 22 of file generate_controller_lut.py.

Referenced by _compute_ddp_point().

◆ _worker_NavState

controller_lut.generate_controller_lut._worker_NavState = None
protected

Definition at line 23 of file generate_controller_lut.py.

Referenced by _compute_ddp_point().

◆ _worker_output_names

controller_lut.generate_controller_lut._worker_output_names = None
protected

Definition at line 21 of file generate_controller_lut.py.

◆ G0

float controller_lut.generate_controller_lut.G0 = 9.80665

Definition at line 179 of file generate_controller_lut.py.