Skip to content

An interactive Python simulation of the N-body problem with real astronomical data and multiple integration methods. Watch planets dance, trace space missions, and explore the cosmos! ๐Ÿš€

License

Notifications You must be signed in to change notification settings

Damien3008/N-bodies-problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

N-Body Gravitational Simulation ๐ŸŒŒ

Python License

A stunning Python-based interactive simulation of the N-body gravitational problem, featuring real astronomical data and multiple numerical integration methods. Watch the dance of planets, trace historic space missions, and explore the cosmos! ๐Ÿš€

N-Body Simulation Demo

โœจ Key Features

Feature Description
๐ŸŽฎ Interactive 3D Visualization Dynamic real-time animation with adjustable speed
๐ŸŒ Real Astronomical Data Accurate planetary positions from NASA
๐Ÿงฎ Multiple Integration Methods Choose from Euler, RK2, RK4, or advanced symplectic methods
๐Ÿ›ธ Historic Space Missions Simulate Voyager trajectories
โšก High Performance Optimized calculations with NumPy

๐Ÿš€ Quick Start

Prerequisites

Python 3.8 or higher
pip (Python package installer)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/n-body-simulation.git
cd n-body-simulation
  1. Install dependencies:
pip install -r requirements.txt

Running the Application

Development Mode

python src/main.py

Production Mode

For production deployment, we use Gunicorn as our WSGI server:

  1. Make the production script executable:
chmod +x run_production.sh
  1. Create logs directory:
mkdir logs
  1. Run the application:
./run_production.sh

The application will be available at http://localhost:8050

๐ŸŽฏ The Science Behind It

The Core Equation

$\vec{a}i = G \sum{j \neq i} \frac{m_j(\vec{r}_j - \vec{r}_i)}{|\vec{r}_j - \vec{r}_i|^3}$

Parameter Description
๐Ÿ”ฐ G 1.4872e-34 AUยณ/(Mโ˜‰ยทdayยฒ) - Gravitational constant
โญ $m_j$ Mass in solar masses (Mโ˜‰)
๐Ÿ“ $\vec{r}$ Position in astronomical units (AU)

๐Ÿงฎ Numerical Methods

Method Equation Characteristics
Euler $y_{n+1} = y_n + h f(t_n, y_n)$ โœ… Fast computation
โœ… Minimal memory
โš ๏ธ Basic accuracy
RK4 $y_{n+1} = y_n + \frac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4)$ โœ… High accuracy
โœ… Stable
โš ๏ธ Computationally intensive
Verlet $\vec{r}_{n+1} = \vec{r}_n + \vec{v}_n\Delta t + \frac{1}{2}\vec{a}_n\Delta t^2$ โœ… Energy conservation
โœ… Long-term stability
โš ๏ธ Ideal for orbits
Adams-Bashforth $y_{n+1} = y_n + \frac{h}{24}(55f_n - 59f_{n-1} + 37f_{n-2} - 9f_{n-3})$ โœ… Efficient
โœ… High accuracy
โš ๏ธ Best for smooth systems

๐Ÿ“š Included Scenarios

Scenario Features
๐ŸŒž Solar System โ€ข Complete planetary system
โ€ข Major moons and asteroids
โ€ข Accurate orbital parameters
๐Ÿ›ธ Space Missions โ€ข Voyager 1 & 2 trajectories
โ€ข Historic planetary encounters
โ€ข Mission timeline recreation
โ˜„๏ธ Cometary Orbits โ€ข Halley's Comet simulation
โ€ข Planetary perturbations
โ€ข Long-term orbital evolution

๐Ÿ”ง Configuration

The production server can be configured through run_production.sh:

  • Port: 8050 (default)
  • Workers: 4 (default)
  • Timeout: 120 seconds
  • Log files location: logs/ directory

๐Ÿ“ License

This project is licensed under the GNU License - see the LICENSE file for details.

About

An interactive Python simulation of the N-body problem with real astronomical data and multiple integration methods. Watch planets dance, trace space missions, and explore the cosmos! ๐Ÿš€

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published