Gravity-Turn Trajectory Optimization

Rocket & Launch Vehicle GNC | Interactive Engineering Problem | Intermediate → Advanced. Explore how pitch-over timing, thrust, propellant depletion, aerodynamic drag, and orbital insertion constraints shape ascent.

From vertical launch to orbital insertion

A two-stage rocket lifts off vertically, performs a brief programmed pitch-over after clearing the lower atmosphere, and then uses nearly velocity-aligned thrust to turn under gravity. Your task is to identify a pitch-over altitude and kick angle that balance downrange acceleration, aerodynamic loading, and orbital insertion.

Engineering scope: The browser solver is an educational planar, nonrotating-Earth ascent model. It includes inverse-square gravity, exponential atmosphere, drag, two-stage mass depletion, staging, and a finite pitch-over kick. It does not include Earth rotation, winds, lift, 3D guidance, throttle control, or detailed structural loads. Results are not flight-design predictions.
1 · Vertical ascent
Thrust accelerates the rocket upward; drag and gravity oppose motion.
2 · Pitch-over kick
A finite steering maneuver establishes a horizontal velocity component.
3 · Gravity turn
Thrust follows the velocity direction; gravity curves the flight path.
4 · Stage and coast
Stage 1 is discarded, stage 2 burns, and the vehicle coasts after cutoff.

Planar inertial Cartesian equations avoid the launch singularity

Let \(\mathbf r=(x,y)\) be position in an Earth-centered plane, \(\mathbf v=(v_x,v_y)\) inertial velocity, and \(m\) total instantaneous mass. The launch point is \((0,R_E)\). A nonrotating atmosphere is assumed, so atmospheric-relative velocity equals inertial velocity in this simplified model.

\[\dot{\mathbf r}=\mathbf v,\qquad \dot{\mathbf v}=\frac{T}{m}\hat{\mathbf u}-\frac{D}{m}\hat{\mathbf v}-\frac{\mu}{r^3}\mathbf r\]
\[\dot m=-\frac{T}{I_{sp}g_0},\quad D=\tfrac12\rho(h)C_D A\|\mathbf v\|^2,\quad \rho(h)=\rho_0 e^{-h/H}\]

Here \(h=\|\mathbf r\|-R_E\), \(q=\tfrac12\rho\|\mathbf v\|^2\), and \(\hat{\mathbf u}\) is thrust direction. During vertical ascent, thrust points along the local radial direction. During the kick it rotates gradually toward the downrange tangent. Afterwards it is aligned with the instantaneous velocity. The drag direction opposes velocity.

\[\gamma=\operatorname{atan2}(v_r,v_t),\quad v_r=\mathbf v\cdot\hat{\mathbf r},\quad v_t=\mathbf v\cdot\hat{\mathbf t}\]

After the pitch-over and for nonzero speed, velocity-aligned thrust yields the familiar ideal gravity-turn equation:

\[\dot\gamma=\left(\frac{v}{r}-\frac{\mu}{vr^2}\right)\cos\gamma\]
Why use Cartesian states? Flight-path-angle equations are singular at zero launch speed. Integrating \((x,y,v_x,v_y,m)\) avoids this singularity and allows the vehicle to start from rest.

Understand pitch deflection before running the full ascent

This deliberately simplified experiment uses constant net acceleration and a fixed direction after an instantaneous pitch change. It omits gravity variation, mass loss, and drag; it is not the rocket ascent solver.

0°8°45°
Final altitude—
Horizontal displacement—
Speed increment—
Horizontal speed increment—
Interpretation: A larger deflection creates more horizontal velocity at the expense of vertical climb. The full rocket model will reveal why gravity losses and aerodynamic loading change this trade-off.

Run the numerical rocket model

Set vehicle parameters, then run a time-stepped fourth-order Runge–Kutta simulation. Mass decreases continuously during burns, and dry stage 1 is dropped at staging. The pitch-over command is a finite-duration steering maneuver, not an instantaneous rotation of the velocity vector.

Ready to simulate.
Peak altitude—
Peak dynamic pressure—
Peak acceleration—
Final speed—
Stage 1 cutoff—
Stage 2 cutoff—
End radial speed—
End tangential speed—
Cutoff vs orbit: The simulation continues through the powered ascent and a short coast. It does not automatically circularize the orbit. Check altitude, radial speed, and tangential speed together before claiming insertion.

Where is Max-Q and why does it matter?

Dynamic pressure \(q=\frac12\rho v^2\) increases as the rocket accelerates but decreases as the atmosphere thins. The maximum is an important load indicator, though a complete structural assessment also needs bending, angle of attack, and vehicle-specific limits.

Run the ascent to evaluate the limits.

Early, nominal, and late pitch-over

Use identical vehicle and atmosphere parameters for all three trajectories; only the kick altitude changes. Compare peak pressure, altitude, downrange motion, and orbital residuals.

StrategyPeak Q (kPa)Peak altitude (km)End radial v (m/s)End tangential v (m/s)
Run comparison to populate.
Interpretation: Early turning can increase horizontal velocity earlier but may increase atmospheric exposure. Late turning can waste more energy fighting gravity. The actual result depends on the selected vehicle and is not assumed in advance.

Search pitch-over altitude and kick angle

A bounded grid search evaluates candidate trajectories. It ranks them by a normalized circular-orbit insertion residual and penalizes violations of the user-selected Max-Q and acceleration limits. This is a parameter sweep, not a globally optimal guidance solution.

Run the search to identify a candidate.
Feasibility: A low score does not mean orbital insertion. We separately test target altitude (±10 km), radial velocity (±50 m/s), tangential velocity (±100 m/s), Max-Q, and acceleration. A fixed vehicle may have no feasible solution within the searched parameter bounds.

Try to meet measurable mission requirements

Challenge 1 · Max-Q

Keep peak dynamic pressure below the selected Max-Q limit and proper acceleration below its limit.

Challenge 2 · Strategy comparison

Compare early and late pitch-over using identical vehicle parameters, and identify the lower peak-Q case.

Challenge 3 · Circular insertion

At the stage-2 cutoff state, target altitude within 10 km, radial speed within 50 m/s, and tangential speed within 100 m/s of circular speed.

Run the simulation and strategy comparison first.

Translate the dynamics into engineering software

These are minimal reference implementations of the core continuous dynamics, not complete event-driven staging or optimization scripts. The browser page uses a fixed-step RK4 solver with event handling.

import numpy as np
from scipy.integrate import solve_ivp
mu, Re, g0 = 3.986004418e14, 6371000.0, 9.80665
rho0, H, Cd, A = 1.225, 8500.0, 0.35, 10.0
T, Isp = 7.6e6, 300.0

def ascent_rhs(t, s):
    x, y, vx, vy, m = s
    r = np.hypot(x, y)
    v = np.hypot(vx, vy)
    h = max(0.0, r - Re)
    rho = rho0*np.exp(-h/H)
    drag = 0.5*rho*v*v*Cd*A
    radial = np.array([x, y])/r
    direction = np.array([vx, vy])/v if v > 1e-6 else radial
    acc = (T*direction - drag*direction)/m - mu*radial/r**2
    return [vx, vy, acc[0], acc[1], -T/(Isp*g0)]

# Example only: start after vertical liftoff with nonzero speed.
# A full solver must handle pitch-over, propellant exhaustion,
# dry-mass separation, and cutoff as explicit events.
Numerical note: MATLAB ode45 and SciPy solve_ivp(method='RK45') are adaptive solvers. The browser model uses fixed-step RK4; vary the timestep and compare outputs to assess numerical convergence.

A smooth trajectory is not proof of successful insertion

1 · Check model physics

Verify thrust-to-weight at liftoff, propellant consumption, dry-mass drop, gravity direction, and atmospheric drag.

2 · Check numerical convergence

Repeat with smaller RK4 timesteps; compare peak-Q, cutoff altitude, and final velocity. Event timing introduces additional discretization error.

3 · Check orbital state

For a circular orbit, radial velocity must be near zero and tangential velocity near \(\sqrt{\mu/r}\). Altitude alone is insufficient.

Final engineering insight: Gravity-turn optimization is a constrained guidance problem. The best pitch program must satisfy the mission endpoint and loads simultaneously, and every candidate must be checked against the model assumptions.