A Python-based physics simulation of a multi-stage rocket launch from Earth's surface to orbit, modeling a Soyuz-style launch vehicle.
- Multi-stage rocket simulation (boosters, second stage, third stage, capsule)
- Realistic physics modeling including:
- Gravity (inverse-square law)
- Atmospheric drag with pressure-dependent calculations
- Coriolis and centrifugal forces due to Earth's rotation
- Thrust and fuel consumption
- Real-time trajectory simulation with Cartesian coordinates
- Automatic stage separation when fuel is depleted
- Orbital insertion at 400km altitude
- Visualization of height, velocity, and acceleration over time
- Python 3.x
- numpy
- matplotlib
- Clone or download this repository
- Ensure all Python files are in the same directory
Run the simulation:
python main.pyOr open main.py in Spyder and execute it.
The simulation takes approximately 2 minutes to complete and will display:
- Real-time console output with rocket status
- Three plots showing:
- Rocket height over time
- Rocket velocity over time
- Rocket acceleration over time
Key parameters can be adjusted in parameters.py:
dt: Time step (default: 1 second)MAX_HEIGHT: Altitude for orbital insertion (default: 400,000m)max_simulation_time: Maximum simulation duration (default: 1000s)
The simulation models a Soyuz-style launch vehicle:
- Boosters (4x): 3,500kg empty, 40,000kg fuel
- Second Stage: 6,500kg empty, 105,000kg fuel
- Third Stage: 2,250kg empty, 25,200kg fuel
- Capsule: 7,000kg (no fuel)
- Gravity: Newton's law of universal gravitation
- Atmosphere: Pressure-based model with altitude decay
- Drag: Quadratic drag equation with atmospheric pressure
- Coriolis Force: Inertial force from Earth's rotation
- Centrifugal Force: Outward force from rotating reference frame
- Thrust: Directed perpendicular to Earth's surface
main.py: Main execution loop and visualizationrocket.py: Rocket and RocketStage classesphysics.py: Physics calculations (forces, acceleration)physics_constants.py: Physical constants (G, Earth mass, radius, etc.)coords_math.py: Coordinate transformations and vector mathparameters.py: Simulation parametersmessages.py: Console output formattingcolors.py: Terminal color codesoperations.py: Utility operations