- Simulation code is written in C++, see
celestial_mechanics.h
,celestial_mechanics.cc
, and the driver codedriver.cc
. Outputs trajectories to CSV file. - Simulation code is templated by space dimension to simultaneously implement both 2D and 3D dynamics in a dimension-independent way.
- Python code to plot and animate the CSV trajectory output can be found in
animations.ipynb
.
I enjoyed writing this and it helped me get a better feel for n-body dynamics. Pull requests welcome :-)
In this directory,
- run
cmake .
- compile and run
driver.cc
withmake run
- run the jupyter notebook to plot and animate the simulation trajectories
- C++:
cmake 3.11+
gcc 10.2+
- python, jupyter, numpy, scipy, matplotlib, pandas