/N-Body-Gravity-Simulation

This is a simple 2D simulation where you can spawn particles of both positive and negative energies and they'll interact with each other due to their gravitational forces.

Primary LanguagePython

N-Body Gravity Simulation

This is a simple 2D simulation where you can spawn particles of both positive and negative energies and they'll interact with each other due to their gravitational forces. The calculation follows Newtonian mechanics with the value of the universal gravitational constant, G, set to 0.01.

Since this is a 2D world, the force is inversely proportional to R instead of R^2. If two particles come too close, they won't collide but instead will pass through each other. Also keep in mind that spawning too many particles may cause some serious CPU load.

The directory contains an executable in the zip file and the python source folder. You need to have installed Python 3.9 or later along with Numpy and Pygame libraries to run the Python file.

Here's a demo of this project: https://www.youtube.com/watch?v=7g-jVOLUh2o