Next: The Code Up: Basic MPI Previous: Exercises

Interacting Particles

In this section we are going to take a shot at the problem of interacting particles. A typical application of this problem is to the motion of charged plasma particles that interact electrostatically with each other. Plasmas are actually even more complex, because accelerated particles radiate and some of this radiation may be captured by other particles, and this adds enormous complexity to the models. Other applications include molecular dynamics and, right at the other end of the spectrum, galactic dynamics.

As far as MPI is concerned, we are going to take another look at defining MPI types and at collective communications. We are going to arrange all particles into an array and the way that this array is going to be partitioned between processes of the computational pool is very reminiscent of how MPI-IO partitions files. So this section may be thought of as a preparation to MPI-IO as well.

Let me begin by reminding you about the Coulomb law. If you have two electrically charged particles, with charges q1 and q2, then the force with which particle 2 acts on particle 1 is given by

 F12 = (5.4) r12 = r12 =

where is the dialectric constant of vacuum and vector r12 points from particle 1 to particle 2 (this is easy to see - simply assume that particle 1 sits in the middle of the world so that r1 = 0). If the particle charges are of the opposite sign, then q1 q2 is negative. This cancels the minus in front of and particle 1 ends up being accelerated towards particle 2. The particles attract each other. If the particles have charges of the same sign, q1 q2 > 0 and then particle 1 is accelerated in the direction that is opposite to where particle 2 is. The particles repel each other.

The force with which particle 1 acts on particle 2 is the opposite to F12, i.e.,

F21 = - F12

Sometimes equation (5.4) is printed without the minus in front of . Whether the minus should or should not be there depends on the definitions of F12 and r12. If r12 is the vector that points from particle 1 to particle 2, i.e., r2 - r1, and if F12 is the force with which particle 2 acts on particle 1, then the minus should be there. Physics is one of these somewhat troubling disciplines, where you need to understand what happens and where you need to be very precise about what is what, otherwise it's easy to get confused.

Consider N particles of various charges scattered at random in some region of space. In order to evaluate the total force that acts on particle number i we have to evaluate the sum:

 (5.5)

This sum has N-1 terms in it, because we assume that particle i does not act on itself. In order to evaluate forces that act on all N particles we have to evaluate N (N - 1) such terms. We say that this computation is going to scale like . This is going to turn very expensive if N gets very large.

We are going to distribute the computation over n processes by making each process evaluate the force for N/n particles. Each process is therefore going to evaluate N/n (N - 1) terms, which may result in considerable speed up of the computation for a sufficiently large value of n. In particular, if we could make n = N, the computation would scale as instead of . This is how nature goes about parallelizing'' this problem. You can think of each particle as being a separate processor that calculates its own evolution.

Within this example program we are going to push all N particles for 20 short time steps using a very simplistic numerical procedure that corresponds to the following equations of motion for particle i:

We can always choose to use such time units in our computation that

We are going to discretize the equations of motion by replacing dt with a final time interval , so that:

Next: The Code Up: Basic MPI Previous: Exercises
Zdzislaw Meglicki
2004-04-29
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}