Manages the multi-phase rocket flight simulation with event-driven transitions.
Functions¶
simulate_ascent¶
Main simulation entry point.
def simulate_ascent(config: AscentConfig) -> Trajectory:
Phases:
- Vertical Ascent → Event: Pitchover altitude
- Gravity Turn → Event: Stage 1 burnout
- Coast → Fixed duration
- Stage 2 Burn → Events: Time limit, fuel depletion
Returns: Complete trajectory with all phase data concatenated.
simulate_ascent_final¶
Simulation for optimization (returns only final state).
def simulate_ascent_final(config: AscentConfig) -> FinalState:
More efficient when only the terminal state is needed.
Event Functions¶
def _cond_ground(t, y, args, **kwargs):
"""Ground impact detection."""
return y[_R] - args["earth"].r_e
def _cond_pitch_over(t, y, args, **kwargs):
"""Pitchover altitude reached."""
return y[_R] - (args["earth"].r_e + args["h_pitch"])
def _cond_stage1_burnout(t, y, args, **kwargs):
"""Stage 1 propellant exhausted."""
return y[_M] - args["m1_end"]
def _cond_fuel_depletion(t, y, args, **kwargs):
"""All propellant exhausted."""
return y[_M] - args["m_min"]
ODE Solver Configuration¶
| Parameter | Value | Purpose |
|---|---|---|
| Solver | Tsit5 | Tsitouras 5(4) RK |
| rtol | 1e-6 | Relative tolerance |
| atol | 1e-6 | Absolute tolerance |
| max_steps | 100,000 | Safety limit |