Skip to content

Repository files navigation

Cohete3 - Rocket Simulation

A Python-based physics simulation of a multi-stage rocket launch from Earth's surface to orbit, modeling a Soyuz-style launch vehicle.

Features

  • 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

Requirements

  • Python 3.x
  • numpy
  • matplotlib

Installation

  1. Clone or download this repository
  2. Ensure all Python files are in the same directory

Usage

Run the simulation:

python main.py

Or 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

Configuration

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)

Rocket Stages

The simulation models a Soyuz-style launch vehicle:

  1. Boosters (4x): 3,500kg empty, 40,000kg fuel
  2. Second Stage: 6,500kg empty, 105,000kg fuel
  3. Third Stage: 2,250kg empty, 25,200kg fuel
  4. Capsule: 7,000kg (no fuel)

Physics Models

  • 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

File Structure

  • main.py: Main execution loop and visualization
  • rocket.py: Rocket and RocketStage classes
  • physics.py: Physics calculations (forces, acceleration)
  • physics_constants.py: Physical constants (G, Earth mass, radius, etc.)
  • coords_math.py: Coordinate transformations and vector math
  • parameters.py: Simulation parameters
  • messages.py: Console output formatting
  • colors.py: Terminal color codes
  • operations.py: Utility operations

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages