r/madeinpython • u/EventHorizon-dev • 2m ago
I built a 2D N-body gravitational solar system and accretion disk simulator from scratch in Python
Hey everyone,
I wanted to share a physics simulation project I built using Python and Pygame: a real-time 2D N-body solar system and accretion disk simulator.
Instead of hardcoding circular orbits, the simulation models true gravitational interactions, collision mechanics, and particle accretion between thousands of bodies in real time.
Key features:
- Real-time N-body gravitational force calculations using Newton's law.
- Dynamic particle merging and accretion (smaller dust particles clump together into larger asteroids and planetoids while conserving momentum).
- Procedural nebula generation with randomized orbital speeds and chaos factors around a massive central sun.
- Lightweight and smooth rendering entirely built from scratch with Python and Pygame.
I'll drop the link to the GitHub repository in the comments below. Let me know what you think or what orbital mechanics features I should add next!