barkm / n-body

Parallel Barnes-Hut Algorithm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

n-body

Parallel Barnes-Hut Algorithm

Description

Program for simulating N-body systems. The algorithm is a parallel implemenation of the Barnes-Hut algorithm inspired by Salmon, John K. Parallel hierarchical N-body methods. Diss. California Institute of Technology, 1991. The program can run on 2d process using MPI.

A simulation of two spinning disks and a visualization of the Barnes-Hut tree.

Installation

Install a MPI library such as OpenMPI or MPICH. On Mac OS X this can be done through Homebrew:

$ brew install mpich

Download the git repository and build the program in a some directory, e.g. build

$ git clone https://github.com/pbarkm/n-body.git  
$ cd n-body  
$ mkdir build
$ cd build
$ cmake ..
$ make

To check if the program runs (on 2 processes):

$ mpirun -np 2 ./n_body

The supplied python files for plotting require matplotlib and numpy.

Running

To display the command line options run

$ mpirun -np 1 ./n_body -?

The following command runs a simulation of 1000 bodies for 10000 time steps. The sampled positions of the bodies are stored in positions.txt and the program is run with the verbose flag (-v).

$ mpirun -np 2 ./n_body -N 1000 -s 10000 -v -o positions.txt

A python script is supplied to animate the simulation.

$ python py/plot.py positions.txt

About

Parallel Barnes-Hut Algorithm


Languages

Language:C++ 89.6%Language:Python 8.2%Language:CMake 1.2%Language:C 1.0%