Skip to content
barkmPublic

About

Parallel Barnes-Hut Algorithm

Topics

Resources

Stars

17 stars

Watchers

0 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 an MPI library such as OpenMPI or MPICH. On macOS this can be done with Homebrew:

$ brew install mpich

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

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

To start the program on two processes run

$ 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

Topics

Resources

Stars

17 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages