The project implements three different methods of a gravitational n-body particle simulation .
The solvers are implemented in C language where one version is serial and the other two are parallel versions, using OpenMP and MPI.
All the commands should be executed on the root directory of the project.
The -lm flag is required when compiling the parallel code to link the math library.
Serial
$ gcc -fopenmp -o simpar simpar.c -lm
Parallel
$ gcc -fopenmp -o simpar-omp simpar-omp.c -lm
All the commands can receive the following arguments:
seed
required Seed for the random number generator
ncside
required Size of the grid (number of cells on the side)
npart
required Number of particles
nstep
required number of time-steps
- On Linux/macOS:
$ ./simpar seed ncside npart nstep
# Example
$ ./simpar 1 3 10 1
Use the command line / terminal to set the number of threads when running the OpenMP implementation.
On the command line
export OMP_NUM_THREADS=2
All the implementations follow the same input and output format.
Output
The program output consists of two lines where the first line is the final position of particle #0 and the second line is center of mass of the overall space at the end of simulation.
Output File Example:
0.87 0.42
0.55 0.59
Run all the tests in the input directory by executing the following commands. The parallel can receive, as an optional argument, the number of desired threads nthreads.
Serial
$ ./run-tests.sh simpar
Parallel
$ ./run-tests.sh simpar-omp [nthreads]
Licensed under MIT. See LICENSE for more information.