+ 2
N-body simulations getting started
I am an astrophysics student using python to study galaxies and we sometimes use n-body models in our work. I am fluent in python and know rudimentary c++ and Fortran. I want to learn how to write basic n-body simulations but most material I have found shows the mathematics without direct ways of how it is implemented. Can anyone point me in the write direction?
1 Odpowiedź
+ 1
If I were you, I would start by create a class body with attribute (mass, position and speed)
Then I would create a class Model that would take a list of bodies in its constructor and the delta T between each step.
This class would also have a function next_step() that would calculate the new position of all the bodies after delta T using gravity equation
Then if I want to see, the evolution in a more graphic way, I would look into these canvas class of tkinter (python)
Hope it helps