This is a two-part programming assignment. The first part is due at 11:30PM on Tuesday, October 10 (right before fall break), and the second is due at 11:30PM on Tuesday, October 17 (right at the end of fall break). The goal is to get some experience writing MPI code, and to get a sense of different issues that come up in simulations.
You should submit everything by making it available on a web page and emailing me a pointer. When I get to work on October 11 and October 18 I will print out your writeups for the two parts.
The physical process we will consider is that of particles moving subject to various forces.
First go here and download the files:
If you look at particles.c, you'll see that it takes multiple time steps and approximates the new location and velocity of each particle at each time step using Euler's method. If you look to see how the code is parallelized, you'll find that it's rather trivial . . . each processor updates the location of its set of particles. The only communication is in distributing the particles' initial location and velocity, and in computing the new time step (question to consider: why isn't the time step a constant?).
If you compile the code using the Makefile and then run it as follows:
% mpirun -np 1 ./particlesyou should see a nice display showing the movement of the particles. (To get the display you may need to 'ssh -X' into a different machine from the one you're on.) If you run it again on two processors:
% mpirun -np 2 ./particlesthe overall picture should look similar, but now in two colors (each processor plots its particles in a different color).
Turn in commented code for both version 1 and version 2 (described above), together with a Makefile and any supporting files (eg, header files), and a writeup addressing the items above.
Now we're going to modify the simulation. In this case not only do the particles move according to Newton's law and a current, but they also attract each other with a force that's similar to gravity in that it's also proportional to the inverse square of the distance between them. Note that every particle is affected by every other particle, although it's affected more by those that are closer.
We'll use the following formula for the force that two particles feel towards each other (in the x and y directions):
F_attract_x = dist_x(part_1,part_2) * (G*mass_1*mass_2 / dist(part_1,part_2)) F_attract_y = dist_y(part_1,part_2) * (G*mass_1*mass_2 / dist(part_1,part_2))For the purposes of this problem, we'll define the constant G to be .01.
Turn in the commented code as well as a writeup explaining: