Skip to content

CamiloAT/space-orbit-dynamics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Space with Explosion: N-Body Gravity Simulator

A realistic, real-time 2D simulation of the Sun-Earth-Moon system with interactive asteroid impacts.


About the Project

Space with Explosion is a physics-based, interactive graphical simulation built in Python using Matplotlib. It accurately models an N-Body system (primarily focused on the Sun, Earth, and Moon) by implementing a custom numerical integrator (Runge-Kutta 4th order) to solve a system of coupled first-order Ordinary Differential Equations (ODEs). The project is designed for educational and visualization purposes, demonstrating orbital mechanics, real-time total mechanical energy conservation, and dynamic events like hyperbolic asteroid intrusions and explosive collisions.

Key Features

  • Real Physics Engine: Implements a custom RK4 (Runge-Kutta 4th order) integrator, avoiding generic black-box solvers to provide a fully transparent gravitational physics core.
  • Energy Conservation Tracking: Includes a real-time plot of the Total Mechanical Energy error ($\Delta E / E_0$) to monitor the stability and accuracy of the numerical integration over time.
  • Dynamic Asteroid Events: Interactively spawn asteroids from outside the system. Watch them enter on fast hyperbolic trajectories, interact gravitationally with the planets, and generate animated visual explosions upon collision!
  • Interactive Controls: Use sliders to adjust simulation variables like the initial velocities of the Earth and Moon and the integration time step (dt). It features a dashboard monitoring physical orbital parameters side-by-side with live metrics.
  • Polished Visualization: Features a deep-space dark theme with static starfields, scalable glowing halos, atmosphere layers, dynamic motion trails for celestial bodies, and dynamic particle-like explosion animations.

Architecture & Technologies

  • Language: Python 3
  • Core Libraries: NumPy (for vector math and array manipulation)
  • Visualization: Matplotlib (Pyplot, Animation, Widgets, Patches)
  • Integration Method: Manual 4-stage Runge-Kutta (RK4)

Installation & Usage Guide

Follow these steps to start the simulation on your local machine:

  1. Open your terminal in the project directory:

    cd "space-orbit-dynamics"
  2. Install all required dependencies: Make sure you have Python installed, then run:

    pip install numpy matplotlib
  3. Run the simulation:

    python space.py
  4. Interact: Once the Matplotlib window opens, you can observe the system. Use the bottom sliders to alter the speeds or the computational time step. Click the Añadir Asteroide button to spawn an independent body on a hyperbolic trajectory.


Explore classical mechanics and celestial systems visually.

About

A small Python project for simulating and visualizing orbital dynamics. Includes numerical orbit propagation, Keplerian examples, and plotting/animation utilities for satellites and spacecraft. Useful for education, research demos, and prototyping orbital maneuvers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages