Algorithm Search⌘K

Techniquecore

Gravitational softening

Also called Plummer softening, softening length.

Replaces the pair potential -G m / r by -G m / sqrt(r^2 + epsilon^2), so the force stays finite in close encounters; epsilon sets the smallest resolved scale.

Gravitational softening changes the pair force of an N-body code at short distances, so that the force stays finite when two bodies come close. The usual form, due to Plummer's model of a star cluster, replaces the Newtonian pair potential −Gm/r-G m / r by

ϕ(r)=−Gmr2+ϵ2,F=−Gmimjr(r2+ϵ2)3/2,\phi(r) = -\frac{G m}{\sqrt{r^2 + \epsilon^2}}, \qquad \mathbf{F} = -G m_i m_j \frac{\mathbf{r}}{(r^2 + \epsilon^2)^{3/2}},

where r\mathbf{r} points from body jj to body ii and ϵ>0\epsilon > 0 is the softening parameter. The force is the gradient of the potential, so the softened system is still Hamiltonian and still conserves energy and momentum. Softening is used in collisionless simulations, where each body of the code is a sample of a smooth mass distribution of stars or dark matter, and the close encounters of the samples are an error of the method, not physics. It is not used in collisional simulations of star clusters and planets, which treat close encounters by regularization.

In plain words

In a computer model of a galaxy, each body stands for a large cloud of stars, not for one star. When two such bodies pass close to each other, true gravity gives them a very strong kick, and the computer must take tiny steps to follow it. Real clouds of stars do not kick each other like that.

Softening changes the pull between two very close bodies so that it becomes weak instead of very strong. Far away, the pull is almost the same as before. One number sets the distance below which the pull is weakened. A small number keeps more detail but gives more random kicks; a large number gives smoother results but blurs small structures.

When it applies

  • The bodies of the code are tracers of a smooth density, as in galaxies, dark matter halos and cosmology. The Vlasov-Poisson system is the target, and two-body encounters are noise.
  • The time step must stay bounded. With ϵ>0\epsilon > 0 the largest acceleration from one body of mass mm is 233Gm/ϵ2≈0.385 Gm/ϵ2\frac{2}{3\sqrt{3}} G m / \epsilon^2 \approx 0.385\, G m / \epsilon^2, so a shared step of order ϵ3/(Gm)\sqrt{\epsilon^3 / (G m)} resolves every pair passage (heuristic).
  • The force method has its own short-range resolution, such as a tree code or a TreePM code; softening sets this scale in a controlled way.

It does not apply to systems where close encounters are real, such as binaries, star clusters and planetary systems.

The template

  1. Choose ϵ\epsilon for the problem. Smaller ϵ\epsilon resolves smaller structures but increases the two-body noise; larger ϵ\epsilon smooths the noise but biases the force below a few ϵ\epsilon.
  2. Replace each pair potential by the softened one, ϕ(r)=−Gm/r2+ϵ2\phi(r) = -G m / \sqrt{r^2 + \epsilon^2} for the Plummer form, or by a kernel with compact support (below). Use the gradient of the same potential as the force, so that energy is conserved.
  3. Use the same softening in the far-field approximation of the force method, or show that the difference is below the force error of the method. For a tree code, the softened monopole of a far cell differs from the Newtonian one by a relative amount of about 32ϵ2/d2\frac{3}{2} \epsilon^2 / d^2.
  4. Choose the time step from ϵ\epsilon and the local density, and report the relative energy error ∣E(t)−E(0)∣/∣E(0)∣|E(t) - E(0)| / |E(0)| with the softened potential energy U=−G∑i<jmimj/rij2+ϵ2U = -G \sum_{i<j} m_i m_j / \sqrt{r_{ij}^2 + \epsilon^2}.

Classic examples

The Plummer force against Newton. The ratio of the Plummer pair force to the Newtonian one is r3/(r2+ϵ2)3/2r^3 / (r^2 + \epsilon^2)^{3/2}.

r/ϵr / \epsilon 0.5 0.7071 1 2 5 10
force ratio 0.0894 0.1925 0.3536 0.7155 0.9428 0.9852

The softened force is largest at r=ϵ/2r = \epsilon / \sqrt{2} and goes to zero linearly as r→0r \to 0. The relative error at large rr is about 32ϵ2/r2\frac{3}{2} \epsilon^2 / r^2, so it is still 1.5 percent at r=10ϵr = 10\epsilon. The Plummer potential of a point mass is the exact potential of a Plummer sphere of mass mm and scale ϵ\epsilon, with density ρ(r)=3mϵ24π(r2+ϵ2)5/2\rho(r) = \frac{3 m \epsilon^2}{4 \pi (r^2 + \epsilon^2)^{5/2}}, so the softened problem is the problem of bodies that are small spheres that pass through each other.

Tree codes for galaxies. Collisionless tree codes such as Barnes-Hut use a softened monopole for each accepted cell and a softened pair force for each nearby body (Aarseth 2003, Chapter 6).

Spline softening. TREESPH (Hernquist and Katz 1989) and GADGET-2 (Springel 2005) soften gravity with the cubic spline kernel of smoothed particle hydrodynamics. Each body is a spline mass distribution of finite radius, so the force is exactly Newtonian beyond that radius, unlike the Plummer force, which is wrong at every distance.

Variations

  • Kernels with compact support. A smooth mass distribution with a finite radius hh, such as the spline, gives exactly the Newtonian force at r≥hr \ge h. Codes quote the Plummer-equivalent ϵ\epsilon, the one with the same potential at r=0r = 0.
  • Optimal softening. Dehnen (2001) splits the force error into a bias, which grows with ϵ\epsilon, and a noise, which falls with ϵ\epsilon. Their sum has a minimum at an ϵ\epsilon that depends on the mass distribution and becomes smaller as NN grows (measurement and asymptotic analysis).
  • Adaptive softening. Each body gets its own ϵi\epsilon_i, from the local density, as for the smoothing length of SPH. The pair force then uses a symmetric combination, such as the mean or the maximum of ϵi\epsilon_i and ϵj\epsilon_j, to keep Newton's third law. A force that is not the gradient of one potential no longer conserves energy, and extra terms are needed to restore it.
  • Comoving softening. In cosmology ϵ\epsilon is fixed in comoving coordinates at early times and in physical coordinates later.
  • Softening by type. Codes with stars, gas and dark matter use a different ϵ\epsilon for each type of body.

Pitfalls

  • Results below the softening scale. Structures smaller than about 2ϵ2\epsilon to 3ϵ3\epsilon are not resolved, and the density profiles of halos are wrong inside this radius.
  • Too small for the time step. If ϵ\epsilon is small and the step is not, close pairs gain energy at each step, and the energy error grows. Choose hh from ϵ\epsilon, or use adaptive block time steps.
  • Two-body relaxation still happens. Softening reduces the effect of close encounters only; the distant encounters still relax the system on a time scale of the order of N/ln⁡NN / \ln N crossing times.
  • Mixing potentials. The energy must use the same softened potential as the force. A Newtonian UU with a softened force shows an energy error that is not an error of the integrator.
  • Not physics for collisional systems. Softening a binary or a planetary system changes its orbits. Use regularization instead.

Exercises

  1. Show that the Plummer potential −Gm/r2+ϵ2-G m / \sqrt{r^2 + \epsilon^2} solves the Poisson equation ∇2ϕ=4πGρ\nabla^2 \phi = 4 \pi G \rho with ρ(r)=3mϵ24π(r2+ϵ2)5/2\rho(r) = \frac{3 m \epsilon^2}{4 \pi (r^2 + \epsilon^2)^{5/2}}, and that this density has total mass mm.
  2. Show that the magnitude of the Plummer pair force is largest at r=ϵ/2r = \epsilon / \sqrt{2}, with the value 233Gmimj/ϵ2\frac{2}{3\sqrt{3}} G m_i m_j / \epsilon^2.
  3. Show that the relative force error at r≫ϵr \gg \epsilon is 32ϵ2/r2+O(ϵ4/r4)\frac{3}{2} \epsilon^2 / r^2 + O(\epsilon^4 / r^4), and find the radius where the exact error is 1 percent. (Answer: r≈12.2 ϵr \approx 12.2\,\epsilon.)
  4. Two bodies of mass mm start at rest at distance DD and fall toward each other with the Plummer potential. Show that they pass through each other with the finite relative speed v=4Gm(1/ϵ−1/D2+ϵ2)v = \sqrt{4 G m (1/\epsilon - 1/\sqrt{D^2 + \epsilon^2})}.

References

  1. Sverre J. Aarseth, Gravitational N-Body Simulations, Tools and Algorithms, Cambridge University Press, 2003, Chapter 6 (tree codes), Section 6.2 (basic formulation)
  2. Walter Dehnen, Towards optimal softening in three-dimensional N-body codes - I. Minimizing the force error, Monthly Notices of the Royal Astronomical Society 324(2), 2001, 273-291, the bias and noise parts of the force error and the optimal softening as a function of N
  3. Lars Hernquist and Neal Katz, TREESPH: a unification of SPH with the hierarchical tree method, Astrophysical Journal Supplement Series 70, 1989, 419-446, the spline kernel softening
  4. Volker Springel, The cosmological simulation code GADGET-2, Monthly Notices of the Royal Astronomical Society 364(4), 2005, 1105-1134, the spline softening of the gravitational force

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
  • three classic examples