Rocket Flight Simulator

A C++17 point-mass (3-DOF) flight simulator for high-power rockets.

Source on GitHub

burnout 3.358 stotal impulse 1,290.54 N·s01230200400600time (s)N
AeroTech J415W · 26 measured points · test-stand data: ThrustCurve.org

Overview

I wrote all 11 commits, from June to August 2026. The simulator integrates a vertical launch using its thrust, motor-mass and gravity models.

How it’s built

  • Fourth-order Runge-Kutta integrator written as a C++ template over the state type and the derivative function.
  • Propulsion model parsed from RASP .eng files of measured test-stand data (AeroTech J415W, 26-point curve), with piecewise-linear thrust interpolation.
  • Propellant mass computed from delivered impulse, using a cumulative-impulse array built by trapezoidal integration at parse time.
  • Seven-layer US Standard Atmosphere 1976 with geometric-to-geopotential altitude conversion.
  • Inverse-square gravity with altitude.
  • Vertical launch integrated to apogee in an Eigen 6-element state vector with RK4 at a fixed 0.01 s step.
  • Math, vehicle and dynamics namespaces. Single-command CMake build that pins Eigen 3.4.0 and GoogleTest 1.14.0 with FetchContent.

Testing

11 GoogleTest cases in 3 suites (RK4, MOTOR, ENVIRONMENT), all passing in 23 ms.

  • RK4 vs. closed-form harmonic oscillator (cos t, −sin t) Within 1e-5 at all 1,000 steps, dt = 0.01.
  • RK4 order of accuracy Halving dt from 0.01 to 0.005 reduces global error by a ratio asserted to lie in [12, 20]. Fourth order gives 16.
  • Thrust interpolation vs. hand-computed values Within 1e-6, with zero thrust after burnout.
  • J415W parsed model Total impulse 1,290.54 N·s, burnout 3.358 s, propellant mass 0.68634 kg, dry mass 0.47084 kg. The total impulse is within the motor’s rated class.
  • Atmosphere density vs. six published reference values (0, 5, 11, 15, 20, 30 km) Within 1e-3 kg/m³.
  • Gravity vs. reference values Matches at 0, 10 km and 100 km.
  • Monotonicity Density and gravity decrease strictly over swept altitudes (120 points to 60 km, 200 points to 100 km).

Status

In progress.