This is an advanced orbital dynamics and n-body simulation program. Through simple rules of physics complex and beautiful behaviours can occur.
The main file is main.py
wich has to be run to be started.
SolarSystem.py
and BarnesHut.py
supplies the program with functions.
The Barnes hut algorythm is highly optimised for many bodies and makes larger scale n-body simulations possible.
Example runs can be found at YouTube.
Any help or assistance is greatly appreciated. Kindly share this project!
-
clicking on objects
-
data handling with json
-
placing objects
-
ui package
please ask for features in discussions!
-
download the code from github (either with .zip or git clone)
-
install requirements.txt
This can be done with the command
py -m pip install -r requirements.txt
using cmd in the directory of the code.
A python installation is also needed. Version 3.10 or above peferred.
Run the file main.py either from the file explorer, an IDE or CMD/shell.
There are easily exchangeable variables in the init function of the Interface class in the "UI with solar system.py". Possible options include a barnes hut overlay or random planet system generation rather than the solar system.
Gravity Physics
The Python Coding Book - Simulating a 3D Solar System In Python Using Matplotlib
Stack Exchange - Velocity verlet pseudo code
Barnes Hut
Lewis Cole Blog - Barnes-Hut Algorithm
beltoforion - The Barnes-Hut Galaxy Simulator
OpenGenus - Octree data structure
Energy
Stack Exchange - Gravitational potential energy of an n-body
LibreTexts - Work and Kinetic Energy for a Many-Body System
Collision
Plasmaphysics.org.uk - Elastic and Inelastic Collision in Three Dimensions