HuBBLE (Hut-Barnes N-Body Lagrangian Engine) is a 2D galactic dynamics simulator for N-body stellar systems employing the Barnes-Hut scheme for efficient force computation.
This implementation is a simplified and refactored version of the code originally developed for my final project in the Galactic Dynamics and Dark Matter mini-course offered by my universityโs Honours Programmes.
The code features a QuadTree data structure implementation, as well as the 2D Barnes-Hut algorithm for efficient force computation. To generate the galaxy profiles, a selected amount of stars is sampled such that the radial profiles match with the Plummer distribution.
Here you can access the small presentation I made, explaining the algorithms and comparing results between different benchmarks.
It should be noted, however, that this code DOES NOT implement automatic tree rescaling, and out-of-bound bodies are simply removed from the simulation, resulting in loss of energy and angular momentum despite employing the Velocity-Verlet algorithm to update the star trajectories.
This project features GLEW to render the simulation in real time using OpenGL. The code has only been tested on macOS, hence the makefile is suited to work on this system (provided you have GLEW installed). Feel free to update the paths accordingly to allow compilation on different operating systems.
You can get GLEW via Homebrew:
brew install glew
then, you simply clone and run the project:
git clone git@github.com:Ciriphys/HuBBLE.git
make run
You can use the Esc/Q, D and Shift+D keys to quit, enable grid and draw force vectors respectively. You can click, drag and scroll to use 2D camera controls.
This project is licensed under the MIT License.
