Skip to content

CamiloAT/space-orbit-dynamics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Space Orbit Dynamics

Python NumPy Matplotlib License

A real-time 2D N-Body gravitational simulator that models the Sun-Earth-Moon system with interactive asteroid impacts, powered by a custom RK4 numerical integrator.


Main Features

  • Custom RK4 Integrator: A hand-coded 4th-order Runge-Kutta solver for coupled ODEs, avoiding black-box solvers to provide full transparency over the physics engine.
  • Real-Time Energy Conservation: Live tracking of total mechanical energy error (ΔE/E₀) to monitor numerical integration accuracy and stability over time.
  • Dynamic Asteroid Events: Spawn asteroids on hyperbolic trajectories that interact gravitationally with planets and generate animated explosion effects upon collision.
  • Interactive Controls: Adjustable sliders for Earth/Moon velocities and integration time step (dt), with buttons to reset, apply stable conditions, or inject asteroids.
  • Polished Visualization: Deep-space dark theme with static starfields, glowing halos, atmosphere layers, motion trails, and particle-like explosion animations.
  • N-Body Gravity Engine: Full pairwise gravitational interaction between all bodies using Newtonian gravity with softening to prevent singularities.

Pages & Views

This project does not contain multiple UI screens. The entire simulation runs in a single Matplotlib window divided into three panels:

View Description
Space View Main simulation area displaying the Sun, Earth, Moon, asteroids, orbital trails, and explosion effects on a dark starfield background.
Energy Panel Real-time plot of the relative total mechanical energy error (ΔE/E₀) over simulation time.
Info Panel Displays physical parameters, orbital constants, integrator settings, and live simulation metrics (time and energy error).

Execution and Development Guide

  1. Clone the repository:

    git clone https://github.com/CamiloAT/space-orbit-dynamics.git
    cd space-orbit-dynamics
  2. Install dependencies:

    Make sure you have Python 3.8 or later installed, then run:

    pip install numpy matplotlib
  3. Run the simulation:

    python space.py
  4. Interact with the simulation:

    • Use the bottom sliders to adjust Earth velocity, Moon velocity, and the integration time step (dt).
    • Click Aplicar Cambios to apply new slider values and restart the simulation.
    • Click Condiciones Estables to reset to default stable orbital parameters.
    • Click Añadir Asteroide to inject an asteroid on a hyperbolic trajectory into the system.

Note: The simulation window must be kept open for the animation to run. Close the window to terminate the program.


Project Structure

space-orbit-dynamics/
├── space.py        ← Main simulation: physics engine, RK4 integrator, visualization, and interactive controls
└── README.md       ← Project documentation and usage guide

Tech Stack

Layer Technology
Language Python 3.8+
Numerical Computation NumPy (vector math, array manipulation)
Visualization Matplotlib (Pyplot, Animation, Widgets, Patches)
Integration Method Manual 4-stage Runge-Kutta (RK4)
Physics Model Newtonian N-Body Gravity with softening

Authors

Name GitHub
Camilo Andres Arias Tenjo @CamiloAT
Jose Luis Ortega Castillo @JoseOrtegaUPTC

Computer Simulation

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