A high-fidelity 2D physics simulation of SpaceX's Falcon 9 first stage booster, featuring realistic rocket dynamics, autonomous landing algorithms, and real-time telemetry visualization.
Experience the complete Falcon 9 mission profile from liftoff to precision landing, all running in your browser with zero installation required.
- Newtonian mechanics with gravity, drag, and thrust modeling
- Mass dynamics including propellant consumption and stage separation
- Atmospheric effects with altitude-dependent air density
- Exhaust particle system with realistic plume physics
- Suicide burn algorithm for fuel-optimal descent
- Dynamic throttle control responding to altitude and velocity
- Grid fin simulation for atmospheric steering
- Precision landing targeting with real-time trajectory adjustment
The simulation accurately models all 10 phases of a Falcon 9 booster mission:
- Phase 0: Liftoff and initial ascent
- Phase 1: Powered ascent with full thrust
- Phase 2: Continued ascent toward stage separation
- Phase 3: MECO (Main Engine Cutoff) and stage separation
- Phase 4: Boostback burn initiation
- Phase 5: Atmospheric re-entry
- Phase 6: Grid fin deployment and aerodynamic guidance
- Phase 7: Entry burn to reduce velocity
- Phase 8: Landing burn with precision throttle control
- Phase 9: Touchdown and landing leg deployment
- 10 phase-specific rocket sprites showing mission progression
- Chroma-keyed background images for launchpad and landing pad
- Dynamic camera system with 4 zoom levels (1.0x, 0.7x, 0.4x, 0.2x)
- Real-time exhaust effects with particle-based plume rendering
- Smooth animations at 60 FPS
- Altitude tracking with live graphing
- Velocity monitoring (vertical and horizontal components)
- Acceleration vectors in real-time
- Fuel consumption and remaining propellant mass
- Throttle percentage display
- Mission phase indicators
- Interactive charts powered by Chart.js
- LAUNCH: Start the mission sequence
- RESET: Return to launchpad for another attempt
- ZOOM: Cycle through 4 camera zoom levels
- PAUSE/RESUME: Control simulation playback
- Frontend: HTML5 Canvas for rendering
- Physics Engine: Custom JavaScript implementation
- Visualization: Chart.js for telemetry graphs
- Deployment: GitHub Pages (static hosting)
- Development: Flask (local development server)
- Initial Mass: ~25,600 kg (wet mass with propellant)
- Dry Mass: ~22,200 kg (empty booster)
- Thrust: Variable (0-100% throttle control)
- Fuel: RP-1/LOX (modeled as combined propellant)
- Engine: Merlin 1D cluster (9 engines)
- Max Velocity: ~2,000 m/s at MECO
- Landing Accuracy: <10 meters from target
- Liftoff: Full throttle ascent from Launch Complex 39A
- Ascent: Powered flight to ~80 km altitude
- MECO: Main engine cutoff and stage separation
- Boostback: Flip maneuver and boostback burn
- Coast: Ballistic trajectory through upper atmosphere
- Re-entry: Grid fin deployment at ~70 km
- Entry Burn: High-altitude deceleration burn
- Landing Burn: Precision suicide burn for soft touchdown
- Landing: Autonomous landing on drone ship or landing pad
# Clone the repository
git clone https://github.com/reversesingularity/falcon9sim.git
cd falcon9sim
# Run local Flask server
cd webapp
python app.py
# Open browser to http://localhost:5000falcon9sim/
โโโ docs/ # GitHub Pages deployment
โ โโโ index.html # Static HTML for web hosting
โ โโโ js/ # JavaScript simulation engine
โ โโโ css/ # Styling
โ โโโ images/ # Rocket sprites and backgrounds
โโโ webapp/ # Flask development version
โ โโโ app.py # Flask server
โ โโโ templates/ # HTML templates
โ โโโ static/ # Static assets
โโโ scripts/ # Trajectory optimization scripts
โ โโโ falcon9_trajectory_optimization.py
โ โโโ brachistochrone_dymos.py
โโโ aircraft/ # JSBSim flight dynamics models
โโโ Falcon9Booster/ # Falcon 9 XML configuration
The simulation implements a fuel-optimal landing algorithm that calculates the precise moment to initiate the final landing burn:
landing_burn_start = sqrt(2 * altitude / (thrust/mass - g))
This ensures the rocket reaches zero velocity exactly at ground level, minimizing fuel consumption.
Air density decreases exponentially with altitude:
ฯ(h) = ฯโ * exp(-h / H)
where H = 8,500m (scale height)
F_drag = 0.5 * ฯ * vยฒ * C_d * A
The scripts/ directory contains advanced trajectory optimization tools using:
- OpenMDAO: Multidisciplinary optimization framework
- Dymos: Dynamic optimization library
- pyOptSparse: Sparse optimization algorithms
These tools can generate optimal ascent and descent trajectories for the Falcon 9 booster.
- 3D visualization mode
- Multiple landing sites (OCISLY, JRTI, LZ-1, LZ-2)
- Weather conditions (wind, turbulence)
- Failure modes and emergency abort scenarios
- Replay system with saved missions
- Leaderboard for landing accuracy
- VR/AR support
This project is open source and available for educational and demonstration purposes.
- SpaceX for inspiring this simulation
- The aerospace engineering community
- JSBSim flight dynamics engine
- NASA for trajectory optimization tools
Created by @reversesingularity
Ready for liftoff? Try the simulation now!