Skip to content

Anay2005/solar-system

Repository files navigation

Solar System N-Body Simulator (Beeman vs Euler)

This project simulates the motion of the Solar System in 2D using both the Beeman and Euler integration methods.
It models gravitational interactions between the Sun, planets, and a satellite performing a Hohmann transfer from Earth to Mars, and compares:

  • Orbital periods vs real values
  • Energy conservation for Beeman vs Euler
  • Minimum distance between the satellite and Mars
  • Time taken for the satellite to reach Mars

The simulation produces an animated plot of the Solar System and writes out energy and orbital period data to text files.


Features

  • 🌍 Full Solar System model (Sun + 8 planets + satellite)
  • 🛰️ Satellite launch using Hohmann transfer parameters from Earth to Mars
  • ⚙️ Two numerical integrators:
    • Beeman method (Simulate_beeman)
    • Euler method (Simulate_Euler)
  • 📉 Energy analysis:
    • Total energy vs time for Beeman and Euler
    • Plotted on the same graph for comparison
  • 📆 Orbital period analysis:
    • Computes average orbital periods from the simulation
    • Compares with real orbital periods (in Earth years)
    • Outputs a nicely formatted table using tabulate
  • 🎥 Matplotlib animation of planetary orbits, including an inset for inner planets

Project Structure

Typical layout of this repository:

project/
├── main.py                     # The main simulation script (your current file)
├── planets.json                # Input data: masses, orbital radii, colours, etc.
├── energy_data_beeman.txt      # Output: energy vs time for Beeman (generated)
├── energy_data_euler.txt       # Output: energy vs time for Euler (generated)
├── orbital_periods.txt         # Output: orbital period table (generated)
├── README.md                   # Project documentation
└── requirements.txt            # Python dependencies

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages