C++ implementation of the Barnes-Hut algorithm for N-body simulations. Project work for 402-0812-00L Computational Statistical Physics FS2025, ETH Zürich.
To compile the C++ software use the provided makefile
$ make
$ ./a.out
The default setup integrates the solar system over 25 years.
To test the benchmarking program, change the SRC inside the makefile from main.cpp to benchmark.cpp. When using data from the Gaia Archive make sure to change the gravitational constant
To enable naive #define USE_NAIVE in const.h.
root: README, makefile, shell run script, python plotting scripts
/input: Simulation input data (JPL Horizons & Gaia Archive data, python query scripts)
/output: Simulation output data (benchmarking data, binary snapshots, CSV frames for animation, tree metadata)
/results: Plots and animations
/src: C++ code
Three types of output files can be written by the IOHandler to /output:
data.csvcontains the position, velocity, mass and radius for each body at different points in time used for debug and/or to visualize the systemtree.csvcontains the octree metadata, storing every node with its position, size, center of mass and mass to inspect, debug and visualize the tree at different points in time- binary snapshots (
.bin): more efficient format to store particle data for evaluation that does not require human readability (verification, performance study, etc)
pandas matplotlib numpy astropy astroquery