Algorithm Search⌘K

Problemintro

Gravitational N-body problem

Also called N-body simulation.

Given the masses, positions and velocities of N bodies that attract by gravity, compute their positions and velocities at later times.

The gravitational N-body problem asks for the motion of NN point masses that attract each other by Newton's law of gravity. It is an initial value problem for 6N6N ordinary differential equations. For N=2N = 2 it reduces to the Kepler problem, which has a closed-form solution. For N≥3N \ge 3 the motion is in general chaotic, and the problem is solved by numerical integration. A solver has two parts: a force method, which computes the accelerations at one instant (for example direct summation or a tree code), and a time integrator, which moves the bodies (for example leapfrog, the Hermite scheme or the Wisdom-Holman map). The problem is the model of star clusters, galaxies, planetary systems and the dark matter of the universe.

In plain words

You have a number of stars or planets. You know how heavy each one is, where it is and how fast it moves. Each one pulls on every other one, more strongly when they are close. The task is to find where all of them will be later.

With two bodies the answer is a known curve, such as an ellipse. With three or more bodies there is no simple answer, and very small changes at the start lead to large changes later. So computers find the answer step by step: compute all the pulls, move each body a little, and repeat. The two hard parts are to compute the pulls fast when there are many bodies, and to take steps that stay accurate when two bodies come very close.

Definition

The input is NN masses mi>0m_i > 0, initial positions xi(0)∈R3\mathbf{x}_i(0) \in \mathbb{R}^3, initial velocities vi(0)\mathbf{v}_i(0) and an end time TT. The gravitational constant is GG; most codes use units with G=1G = 1. The output is xi(t)\mathbf{x}_i(t) and vi(t)\mathbf{v}_i(t) for 0≤t≤T0 \le t \le T, the solution of

x˙i=vi,v˙i=G∑j≠imjxj−xi∣xj−xi∣3,i=1,…,N.\dot{\mathbf{x}}_i = \mathbf{v}_i, \qquad \dot{\mathbf{v}}_i = G \sum_{j \ne i} m_j \frac{\mathbf{x}_j - \mathbf{x}_i}{|\mathbf{x}_j - \mathbf{x}_i|^3}, \qquad i = 1, \ldots, N.

The system is Hamiltonian, with momenta pi=mivi\mathbf{p}_i = m_i \mathbf{v}_i and

H=∑i∣pi∣22mi−G∑i<jmimj∣xi−xj∣.H = \sum_i \frac{|\mathbf{p}_i|^2}{2 m_i} - G \sum_{i < j} \frac{m_i m_j}{|\mathbf{x}_i - \mathbf{x}_j|}.

The energy E=HE = H, the total momentum P=∑ipi\mathbf{P} = \sum_i \mathbf{p}_i and the angular momentum L=∑ixi×pi\mathbf{L} = \sum_i \mathbf{x}_i \times \mathbf{p}_i are constant, and the center of mass moves on a straight line at constant speed (theorem). A numerical solution is judged by the relative energy error ∣E(t)−E(0)∣/∣E(0)∣|E(t) - E(0)| / |E(0)| and by how well it keeps P\mathbf{P} and L\mathbf{L}. The solution exists until two or more bodies collide, or until a non-collision singularity occurs, where bodies go to infinity in finite time; Xia proved in 1992 that such solutions exist for N=5N = 5.

Variants

  • Collisional systems. Star clusters and planetary systems, where close encounters change the orbits and must be followed exactly. These use direct summation, individual or block time steps and regularization.
  • Collisionless systems. Galaxies and dark matter, where the bodies of the code are samples of a smooth mass distribution. The force is softened, and the limit N→∞N \to \infty is the Vlasov-Poisson system.
  • Planetary problem. One mass dominates, and the others are small. The motion is close to Kepler ellipses around the dominant mass, which the Wisdom-Holman map uses.
  • Restricted three-body problem. One body has zero mass and moves in the field of two bodies on circular or elliptic orbits.
  • Cosmological problem. The bodies are in an expanding periodic box; the long-range force is computed with particle-mesh, P3M or TreePM and periodic boundary conditions.

Examples

Circular two-body orbit. Take G=1G = 1, two bodies of mass 1/21/2 at (∓1/2,0,0)(\mp 1/2, 0, 0) with velocities (0,∓1/2,0)(0, \mp 1/2, 0). The separation is r=1r = 1, the total mass is M=1M = 1 and the relative speed is GM/r=1\sqrt{G M / r} = 1, so the bodies move on a circle with period 2π2\pi. The kinetic energy is K=1/8K = 1/8, the potential energy is U=−1/4U = -1/4, and E=−1/8E = -1/8. Here 2K+U=02K + U = 0 at each instant, which is the virial relation for a bound system on average.

The figure-eight orbit. Three equal masses can follow one figure-eight curve, each one a third of a period behind the next. Chenciner and Montgomery proved in 2000 that this periodic solution exists. It is a common test for integrators because it is stable and its period is known to many digits.

A star cluster. A Plummer sphere of N=104N = 10^4 equal masses in the standard units (G=1G = 1, total mass 11, E=−1/4E = -1/4) has a crossing time of a few time units. It evolves by two-body encounters over many crossing times, and after many relaxation times its core collapses.

Known algorithms

The force part:

The time part:

Bounds

  • No useful closed form (theorem). Sundman found in 1912 a convergent power series for the solution of the three-body problem with nonzero angular momentum, and Wang extended it in 1991 to N>3N > 3 for solutions without singularities. The series converge so slowly that they are of no use in practice (Diacu 1996).
  • Force cost. One exact evaluation of all accelerations costs Θ(N2)\Theta(N^2) operations by direct summation. The approximate methods reach O(Nlog⁡N)O(N \log N) or O(N)O(N) with a controlled error.
  • Sensitivity (measurement). In numerical experiments, two nearby solutions of a system of many bodies separate at an exponential rate, with an e-folding time of the order of the crossing time. So a single solution can not be computed accurately for long times, and the results of a simulation are statistical.
  • Relaxation time (estimate). Two-body encounters change the orbits of a system of NN equal stars in about trelax≈N8ln⁡Ntcrosst_{\mathrm{relax}} \approx \frac{N}{8 \ln N} t_{\mathrm{cross}} (Binney and Tremaine, Chapter 1). For N=105N = 10^5 this is about 1100 crossing times, and for a galaxy with N=1011N = 10^{11} it is about 5×1085 \times 10^8 crossing times, so galaxies are collisionless.

Reductions

  • N=2N = 2 to the Kepler problem. The relative position r=x2−x1\mathbf{r} = \mathbf{x}_2 - \mathbf{x}_1 obeys r¨=−G(m1+m2)r/∣r∣3\ddot{\mathbf{r}} = -G (m_1 + m_2) \mathbf{r} / |\mathbf{r}|^3, and the center of mass moves uniformly. The orbit is a conic section.
  • N→∞N \to \infty to the Vlasov-Poisson system. With the total mass fixed and the masses mi=M/Nm_i = M / N, the distribution of the bodies in phase space tends to a solution of the collisionless Boltzmann equation coupled to the Poisson equation for the potential.
  • Softened problem. Replacing 1/r1/r by 1/r2+ϵ21/\sqrt{r^2 + \epsilon^2} gives a smooth Hamiltonian system with no collisions, at the cost of a wrong force at distances below about ϵ\epsilon.

Applications

Star clusters and the growth of black holes in their cores; the stability of planetary systems over billions of years; the formation of galaxies and of the large-scale structure of the universe; the orbits of spacecraft and asteroids. The same structure, with a different pair force, is the basis of molecular dynamics and of smoothed particle hydrodynamics.

References

  1. Sverre J. Aarseth, Gravitational N-Body Simulations, Tools and Algorithms, Cambridge University Press, 2003, Section 1.2 (historical developments), Section 1.3 (basic concepts)
  2. James Binney and Scott Tremaine, Galactic Dynamics, 2nd edition, Princeton University Press, 2008, Chapter 1 (relaxation time), Chapter 4 (collisionless systems)
  3. Florin Diacu, The solution of the n-body problem, The Mathematical Intelligencer 18, 1996, 66-70, the convergent series of Sundman and Wang

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a known algorithm
  • a contract.yaml