A small but powerful nbody gravity simulator with a built-in renderer
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
images
.gitignore
BarnzNhutt.cpp
Bhtree.cpp
Constants.h
Octant.cpp
README.md
build.bash
createVideo.bash
deleteImgs.bash

README.md

Nbody Gravity Simulator

Implements the Barnes–Hut algorithim to handle the gravitional interaction of over a million particles in 3D space. Currently set up to generate disks of particles Includes a renderer that produces high quailty PPM images of the simulation. These can be compiled into animations. Example

Setup

Use build.bash to create the program. That's it! Executing "run" will immediately start simulating and rendering to the images folder until canceled or frame limit is reached. Note: This may consume significant storage space.

Note: Some versions of clang on MacOS do not support openmp. You can build using another compiler or simply by removing the -fopenmp option from build.sh (this will incur a performance decrease of course)

Initial conditions parameters can be modified in the Constants.h file, and are baked into the program so build must be run again after making changes.

If you have ffmpeg you can use createVideo.bash to generate a video from the images.

Images

Initialized as a uniform disk alt tag

Higher disk mass alt tag

"Hot" Disk alt tag

Outtakes

Many interesting things happened as I frequenty broke my code alt tag alt tag alt tag alt tag