                          The nbody Simulator
                     Stephen F. Siegel, August 2009

=============================== USAGE ====================================

  nbody_seq <config_filename> <output_filename>
  mpiexec -n <nprocs> nbody_par <config_filename> <output_filename>

This program simulates the motions of a number of bodies whose motion
is governed by the law of gravitation.  The universe is a
2-dimensional torus, i.e., a rectangle in which the bottom edge is
identified with the top edge, and the left edge is identified with the
right edge.  The program produces a movie (animated gif) showing what
happens in a fixed "window" in the universe.

There are two versions of the program, a sequential and a parallel
version.  They should be functionally equivalent.

To keep things simple, the unit of distance is one pixel.

The universe is identified with a rectange in the x-y plane.  The
bottom-left coordinate is (x_min,y_min).  The top-right coordinate is
(x_max,y_max).

The window is a rectangle contained in the universe.  Its bottom-left
coordinate is the origin (0,0).  Its top-right coordinate is (nx,ny).

Each body has a mass, color and size.  The mass of course effects the
gravitational force.  The color and size are just used to represent
the body in the movie.  The body is represented as a circle with
diameter size (in pixels).

Configuration constants and initial data are specified in a config
file.  The file has the following format (leaving out the dashed
lines):

-------------------------------------------------------------------
x_min  x_max  y_min  y_max  nx  ny  K  nsteps  period  numBodies

mass_1  color_1  size_1  x_1  y_1  vx_1  vy_1
mass_2  color_2  size_2  x_2  y_2  vx_2  vy_2
mass_3  color_3  size_3  x_3  y_3  vx_3  vy_3
.
.
.
-------------------------------------------------------------------

Where:

x_min     : x-coordinate of left edge of universe (double)
x_max     : x-coordinate of right edge of universe (double)
y_min     : y-coordinate of bottom edge of universe (double)
y_max     : y-coordinate of top edge of universe (double)
nx        : width of view window in pixels (int)
ny        : height of view window in pixels (int)
K         : constant encoding G, distance between grid points,
            time step.  The bigger K, the stronger the gravitational
            attraction (double)
nsteps    : number of time steps (int)
period    : write a frame every this many time steps (int)
numBodies : number of bodies (int)
mass_i:   : mass of body i (double)
color_i   : color index of body i (int in range 0..254)
size_i    : diameter in pixels of circle representing body i (int)
x_i       : x-coord of initial position of body i (double)
y_i       : y-coord of initial position of body i (double)
vx_i      : initial velocity of body i, x-direction (double)
vy_i      : initial velocity of body i, y-direction (double)


========================== Installation Instructions =====================

There is a sequential and a parallel version.

You need to have the following libraries installed: gd (a graphics
library, http://www.libgd.org/), mpi (for the parallel version), and
various other standard things.  See the Makefile if you have to adjust
any paths.

make: builds the executables nbody_seq and nbody_par
make seq : runs the example config files and produces a gif for each
make test : run the sequential and parallel versions with various parameters
  and diffs the output.   They should be equivalent.
