next up previous contents
Next: 5.1 A More General Up: II. Exploring -Body Algorithms Previous: 4.3 Finding Better Convergence

5. Exploring $N = 3$ with a Leapfrog Algorithm

With a better algorithm in hand, our friends decided to work their way up from the two-body problem to the three-body problem. And rather than hard coding the value of $N$ in their algorithm, they wrote a leapfrog code for the general $N$-body problem. The expression for the acceleration felt by particle $i$ is given by summing together the Newtonian gravitational attraction of all other particles $j$, where both $i$ and $j$ take on values from 1 up to and including $N$:


\begin{displaymath}
\frac{d^2}{dt^2}{\bf r}_i = G \sum_{j=1 \atop j \neq i}^N M_...
...ac{{\bf r}_j - {\bf r}_i}{\,\vert{\bf r}_j - {\bf r}_i\vert^3}
\end{displaymath} (5.1)

Here $M_j$ and ${\bf r}_j$ are the mass and position vector of particle $j$, and $G$ is the gravitational constant. To bring out the inverse square nature of gravity, we can define ${\bf r}_{ji} = {\bf r}_j - {\bf r}_i$, with $r_{ji} = \vert{\bf r}_{ji}\vert$, and unit vector $\hat {\bf r}_{ji} = {\bf r}_{ji} / r_{ji}$:


\begin{displaymath}
{\bf a}_i = G \sum_{j=1 \atop j \neq i}^N
\frac{M_j}{r_{ji}^2} \,\hat{\bf r}_{ji}
\end{displaymath} (5.2)

Note that the summation excludes self-interactions: every particle feels the forces of the other $N-1$ particles, but not its own force (which would be infinitely large in case of a point mass).



Subsections
next up previous contents
Next: 5.1 A More General Up: II. Exploring -Body Algorithms Previous: 4.3 Finding Better Convergence
The Art of Computational Science
2004/01/25