STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
engine.control.robust_ddp.engine_wrapper.EngineWrapper Class Reference

Public Member Functions

 __init__ (self, PintleEngineConfig config, int cache_size=128)
EngineEstimate estimate_from_pressures (self, float P_d_F, float P_d_O, bool use_cache=True)
None clear_cache (self)
Dict[str, Any] get_cache_stats (self)

Public Attributes

 config = config
 runner = PintleEngineRunner(config)
 cache_size = cache_size

Protected Member Functions

 _create_cached_evaluator (self)
str _make_cache_key (self, float P_d_F, float P_d_O, int precision=3)

Protected Attributes

 _cached_evaluate = self._create_cached_evaluator()
dict _result_cache

Detailed Description

Wrapper around PintleEngineRunner with caching for DDP rollouts.

Definition at line 42 of file engine_wrapper.py.

Constructor & Destructor Documentation

◆ __init__()

engine.control.robust_ddp.engine_wrapper.EngineWrapper.__init__ ( self,
PintleEngineConfig config,
int cache_size = 128 )
Initialize engine wrapper.

Parameters:
-----------
config : PintleEngineConfig
    Engine configuration
cache_size : int
    Maximum number of cached results (LRU cache size)

Definition at line 45 of file engine_wrapper.py.

Member Function Documentation

◆ _create_cached_evaluator()

engine.control.robust_ddp.engine_wrapper.EngineWrapper._create_cached_evaluator ( self)
protected
Create LRU-cached evaluator function.

Definition at line 63 of file engine_wrapper.py.

◆ _make_cache_key()

str engine.control.robust_ddp.engine_wrapper.EngineWrapper._make_cache_key ( self,
float P_d_F,
float P_d_O,
int precision = 3 )
protected
Create cache key from feed pressures.

Parameters:
-----------
P_d_F : float
    Fuel feed pressure [Pa]
P_d_O : float
    Oxidizer feed pressure [Pa]
precision : int
    Decimal places for rounding (reduces cache misses from floating point)

Returns:
--------
key : str
    Cache key string

Definition at line 74 of file engine_wrapper.py.

Referenced by estimate_from_pressures().

◆ clear_cache()

None engine.control.robust_ddp.engine_wrapper.EngineWrapper.clear_cache ( self)
Clear the evaluation cache.

Definition at line 290 of file engine_wrapper.py.

References _result_cache.

◆ estimate_from_pressures()

EngineEstimate engine.control.robust_ddp.engine_wrapper.EngineWrapper.estimate_from_pressures ( self,
float P_d_F,
float P_d_O,
bool use_cache = True )
Estimate engine performance from tank/ullage pressures.

**IMPORTANT**: Despite the parameter names (P_d_F, P_d_O), these represent
TANK/ULLAGE PRESSURES (P_u_F, P_u_O), NOT feed/downstream pressures.
The engine physics pipeline expects tank pressures and internally calculates
feed line losses.

Parameters:
-----------
P_d_F : float
    Fuel tank/ullage pressure [Pa] (P_u_F in state vector)
    NOTE: Parameter name is misleading - this is actually tank pressure, not feed pressure
P_d_O : float
    Oxidizer tank/ullage pressure [Pa] (P_u_O in state vector)
    NOTE: Parameter name is misleading - this is actually tank pressure, not feed pressure
use_cache : bool
    Whether to use caching (default: True)

Returns:
--------
estimate : EngineEstimate
    Engine performance estimate with validated thrust, MR, and mass flows

Notes:
------
The engine physics pipeline (PintleEngineRunner.evaluate) expects tank pressures
as input. The controller state uses P_u_F and P_u_O for tank/ullage pressures,
which are passed directly to this function. Feed pressures (P_d_F, P_d_O) are
downstream and lag behind tank pressures due to line dynamics.

The estimate is validated to ensure consistency:
- If mass flows are invalid, MR is set to NaN
- If MR is invalid, thrust and mass flows are set to NaN
- If thrust is invalid, MR and mass flows are set to NaN
This prevents inconsistent estimates like non-zero thrust with zero MR.

Definition at line 100 of file engine_wrapper.py.

References _make_cache_key().

◆ get_cache_stats()

Dict[str, Any] engine.control.robust_ddp.engine_wrapper.EngineWrapper.get_cache_stats ( self)
Get cache statistics.

Definition at line 295 of file engine_wrapper.py.

References _result_cache, and cache_size.

Member Data Documentation

◆ _cached_evaluate

engine.control.robust_ddp.engine_wrapper.EngineWrapper._cached_evaluate = self._create_cached_evaluator()
protected

Definition at line 61 of file engine_wrapper.py.

◆ _result_cache

engine.control.robust_ddp.engine_wrapper.EngineWrapper._result_cache
protected

Definition at line 147 of file engine_wrapper.py.

Referenced by clear_cache(), and get_cache_stats().

◆ cache_size

engine.control.robust_ddp.engine_wrapper.EngineWrapper.cache_size = cache_size

Definition at line 58 of file engine_wrapper.py.

Referenced by get_cache_stats().

◆ config

engine.control.robust_ddp.engine_wrapper.EngineWrapper.config = config

Definition at line 56 of file engine_wrapper.py.

Referenced by engine.layerx.card.EngineSampler.__call__(), engine.core.chamber_solver.ChamberSolver._accel_chamber_pc(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver._advance_walls(), engine.pipeline.cea_cache.CEACache._build_cache(), engine.pipeline.cea_cache.CEACache._build_cache_parallel(), engine.pipeline.cea_cache.CEACache._build_cache_sequential(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver._build_walls(), engine.core.chamber_solver.ChamberSolver._compute_cooling_efficiency(), engine.core.chamber_solver.ChamberSolver._evaluate_cooling_models(), engine.core.runner.PintleEngineRunner._evaluate_internal(), engine.core.chamber_solver.ChamberSolver._fluid_props(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver._geometry(), engine.core.runner.PintleEngineRunner._get_ambient_pressure(), engine.core.chamber_solver.ChamberSolver._get_chamber_geometry(), engine.core.runner.PintleEngineRunner._get_elevation(), engine.core.chamber_solver.ChamberSolver._get_fuel_props(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver._graphite_layers(), engine.core.chamber_solver.ChamberSolver._infer_injector_diameter(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver._insert_backing(), engine.core.chamber_solver.ChamberSolver._liner_end(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver._liner_layers(), engine.pipeline.cea_cache.CEACache._load_cache(), engine.core.chamber_solver.ChamberSolver._raise_supply_exceeds_demand(), engine.core.chamber_solver.ChamberSolver._rupe_R_opt(), engine.pipeline.cea_cache.CEACache._save_cache(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver._station_loads(), engine.core.chamber_solver.ChamberSolver._wall_contour(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver._wall_report(), engine.pipeline.cea_cache.CEACache.aux(), engine.pipeline.system_diagnostics.SystemDiagnostics.diagnose_all(), engine.pipeline.cea_cache.CEACache.eval(), engine.pipeline.cea_cache.CEACache.eval_cf_vac(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver.liner_end(), engine.core.chamber_solver.ChamberSolver.residual(), engine.core.chamber_solver.ChamberSolver.solve(), engine.pipeline.time_varying_solver.TimeVaryingCoupledSolver.solve_time_step(), test_robust_ddp_constraints.TestConstraints.test_all_constraints_safe(), test_robust_ddp_engine_wrapper.TestEngineWrapper.test_cache_stats(), test_robust_ddp_engine_wrapper.TestEngineWrapper.test_caching(), test_robust_ddp_engine_wrapper.TestEngineWrapper.test_clear_cache(), test_robust_ddp_constraints.TestConstraints.test_constraint_summary(), test_robust_ddp_engine_wrapper.TestEngineWrapper.test_convenience_function(), test_robust_ddp_constraints.TestConstraints.test_copv_minimum_constraint(), test_robust_ddp_constraints.TestConstraints.test_edge_cases(), test_robust_ddp_engine_wrapper.TestEngineWrapper.test_estimate_error_handling(), test_robust_ddp_engine_wrapper.TestEngineWrapper.test_estimate_from_pressures_mock(), test_robust_ddp_engine_wrapper.TestEngineWrapper.test_estimate_without_stability(), test_robust_ddp_constraints.TestConstraints.test_headroom_constraints(), test_robust_ddp_constraints.TestConstraints.test_injector_stiffness_constraints(), test_robust_ddp_constraints.TestConstraints.test_mixture_ratio_constraints(), test_robust_ddp_robustness.TestRobustness.test_multiple_updates_convergence(), test_robust_ddp_constraints.TestConstraints.test_multiple_violations(), test_robust_ddp_constraints.TestConstraints.test_nan_handling(), test_robust_ddp_dynamics.TestDynamics.test_regulator_behavior(), test_robust_ddp_robustness.TestRobustness.test_tube_propagate_basic(), test_robust_ddp_robustness.TestRobustness.test_tube_propagate_validation(), test_robust_ddp_robustness.TestRobustness.test_tube_propagate_widens(), test_robust_ddp_robustness.TestRobustness.test_tube_propagate_with_large_w_bar(), test_robust_ddp_constraints.TestConstraints.test_ullage_maximum_constraints(), test_robust_ddp_robustness.TestRobustness.test_update_bounds_basic(), test_robust_ddp_robustness.TestRobustness.test_update_bounds_beta(), test_robust_ddp_robustness.TestRobustness.test_update_bounds_ema_behavior(), test_robust_ddp_robustness.TestRobustness.test_update_bounds_inflation(), test_robust_ddp_robustness.TestRobustness.test_update_bounds_requires_mass_flow(), test_robust_ddp_robustness.TestRobustness.test_update_bounds_residual_spike(), test_robust_ddp_robustness.TestRobustness.test_update_bounds_with_engine_wrapper(), and test_robust_ddp_engine_wrapper.TestEngineWrapper.test_wrapper_initialization().

◆ runner


The documentation for this class was generated from the following file: