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

Functions

Tuple[np.ndarray, np.ndarray] generate_segmented_pressure_curve (List[Dict[str, Any]] segments, int n_points=200)
List[Dict[str, Any]] segments_from_optimizer_vars (np.ndarray x_segments, int n_segments, float base_pressure_psi, float target_burn_time, bool use_initial_as_base=False)
np.ndarray optimizer_vars_from_segments (List[Dict[str, Any]] segments, float max_pressure_psi, float target_burn_time)

Detailed Description

Helper functions for optimization layers.

Contains:
- Pressure curve generation and manipulation
- Optimization variable conversion
- Utility functions shared across layers

Function Documentation

◆ generate_segmented_pressure_curve()

Tuple[np.ndarray, np.ndarray] engine.optimizer.helpers.generate_segmented_pressure_curve ( List[Dict[str, Any]] segments,
int n_points = 200 )
Generate a pressure curve from a list of segments.

Each segment can be 'linear' or 'blowdown' with its own duration and pressures.

Args:
    segments: List of segment dicts with keys:
        - type: 'linear' or 'blowdown'
        - duration: segment duration in seconds
        - start_pressure_psi: pressure at start of segment
        - end_pressure_psi: pressure at end of segment
        - decay_tau: time constant for blowdown (only for blowdown type)
    n_points: Total number of points in output array

Returns:
    time_array: Array of time points [s]
    pressure_array: Array of pressures [psi]

Definition at line 15 of file helpers.py.

◆ optimizer_vars_from_segments()

np.ndarray engine.optimizer.helpers.optimizer_vars_from_segments ( List[Dict[str, Any]] segments,
float max_pressure_psi,
float target_burn_time )
Convert segment list to optimizer variables.

Inverse of segments_from_optimizer_vars.

Definition at line 183 of file helpers.py.

◆ segments_from_optimizer_vars()

List[Dict[str, Any]] engine.optimizer.helpers.segments_from_optimizer_vars ( np.ndarray x_segments,
int n_segments,
float base_pressure_psi,
float target_burn_time,
bool use_initial_as_base = False )
Convert optimizer variables to segment list.

For each segment, optimizer provides:
- type (0=linear, 1=blowdown) - rounded to int
- duration_ratio (0-1, fraction of total burn time)
- start_pressure_ratio (0.7-1.0 for regulation, 0.3-1.0 for blowdown, ratio of base pressure)
- end_pressure_ratio (0.7-1.0 for regulation, 0.3-1.0 for blowdown, ratio of base pressure)
- decay_tau_ratio (0-1, fraction of segment duration, only for blowdown)

Args:
    x_segments: Array of optimizer variables for segments
    n_segments: Number of segments (1-20)
    base_pressure_psi: Base pressure [psi] - either max (blowdown) or initial (regulation)
    target_burn_time: Total burn time [s]
    use_initial_as_base: If True, base_pressure_psi is initial pressure (for regulation)
                       If False, base_pressure_psi is max pressure (for blowdown)

Returns:
    List of segment dicts

Definition at line 84 of file helpers.py.

References min.