advanced32 min studyLesson 924 in Physics

N-body force calculation and softening

Separate pair-force symmetry, approximation error and the physical bias introduced by gravitational softening.

On this page

What you’ll understand

  • Differentiate a softened pair potential with the correct attractive sign.
  • Check pair momentum balance before dividing forces by unequal masses.
  • Distinguish softening bias, force-approximation error and time-integration error.

An N-body calculation combines a physical model, a force evaluator and a time integrator. Errors in these ingredients are different. Reducing the time step does not remove a bias introduced by changing Newton's potential, and evaluating a chosen force very accurately does not establish that its smoothing length is physically appropriate. Softening is often useful when massive numerical particles represent a smooth collisionless distribution. It is a modeling and resolution decision, not merely protection against division by zero or a universal prescription for literal stellar collisions.

Derive a symmetric attractive pair force

Let the displacement from particle i to particle j point toward j. A fixed positive Plummer softening length replaces the inverse separation in the pair potential by the inverse square root of squared separation plus squared softening. Differentiating the potential with respect to the first position gives an attractive force along that displacement. Swapping particle labels reverses the displacement, so the forces are opposite. The accelerations are generally not opposite when the masses differ.

Calculating a pair once and applying equal and opposite momentum increments enforces the pair symmetry up to floating-point accumulation. A central pair force also has zero net torque about a common origin. These statements concern the specified force law, not exact energy conservation by an arbitrary integrator. If the softening changes with particle configuration or time, differentiating the resulting potential may require additional terms; simply substituting changing lengths into a fixed-softening force is not automatically energy consistent.

Uij=−Gmimj∣rj−ri∣2+ϵ2,Fij=Gmimj(rj−ri)(∣rj−ri∣2+ϵ2)3/2,Fji=−FijU_{ij}=-\frac{Gm_im_j}{\sqrt{|r_j-r_i|^2+\epsilon^2}},\qquad F_{ij}=\frac{Gm_im_j(r_j-r_i)}{(|r_j-r_i|^2+\epsilon^2)^{3/2}},\qquad F_{ji}=-F_{ij}
ε is a fixed common length and Fij is the force on i due to j. Positions and ε have length units, U energy units and F force units. The force is attractive for positive masses.↔ Scroll wide equations horizontally.

Balance discreteness against smoothing bias

For a smooth collisionless target, a finite set of particles samples a distribution rather than resolving every microscopic encounter. Too little smoothing can make nearby numerical particles produce large fluctuating forces; too much removes real spatial structure and systematically weakens attraction at resolved separations. The best compromise depends on particle number, density, kernel and the observable. There is no single universal optimal softening length independent of the physical system or desired resolution.

Plummer smoothing is noncompact: its force differs from Newton's at every finite radius, although the relative change becomes small far outside the softening scale. Other kernels can recover Newton's law beyond a finite support. Softening studies should therefore vary the length and particle sampling, rather than interpret the time-step convergence of one softened model as convergence to the unsoftened continuum. Statistical sampling fluctuations also need ensembles or justified estimators; deterministic integrator error is not the same uncertainty.

∣Fϵ(r)∣∣F0(r)∣=(1+ϵ2r2)−3/2(r>0),Fϵ(0)=0(ϵ>0)\frac{|F_\epsilon(r)|}{|F_0(r)|}=\left(1+\frac{\epsilon^2}{r^2}\right)^{-3/2}\quad(r>0),\qquad F_\epsilon(0)=0\quad(\epsilon>0)
The ratio compares the same pair of positive masses at a nonzero separation. The zero-separation force is finite by continuity for fixed ε; it is not a physical treatment of a point-particle collision.↔ Scroll wide equations horizontally.

Keep force approximations separate from time stepping

Direct summation evaluates all unordered pairs, requiring a number of pair interactions proportional to N squared. Tree methods approximate distant groups and fast multipole methods organize higher-order spatial expansions. Their force tolerances are separate from integration time steps. Some approximate evaluations do not preserve exact pair antisymmetry, so total momentum drift can diagnose an implementation choice rather than a defect of Newtonian mechanics. Boundary treatment also matters: isolated and periodic gravitational systems have different long-range force problems.

A practical comparison fixes the target distribution and boundaries, measures force error against a more accurate evaluation, and then studies time integration with that force prescription. Close binary dynamics may demand a collisional method rather than stronger smoothing. The fields lab displays a softened planar source with an optional rotational term. Its radial power and sign convention differ from three-dimensional gravity, and it contains neither particle pairs nor their backreaction. Only its linear response to source strength is the intended comparison.

ai=1mi∑j≠iFij,ddt∑imivi=∑i<j(Fij+Fji)=0a_i=\frac1{m_i}\sum_{j\ne i}F_{ij},\qquad \frac{d}{dt}\sum_i m_i v_i=\sum_{i<j}(F_{ij}+F_{ji})=0
The momentum identity presumes isolated internal pair forces without external forcing and exact antisymmetry. Numerical roundoff and force approximations can change the implemented balance.↔ Scroll wide equations horizontally.

A softened unequal-mass pair

Use dimensionless gravitational units with G = 1. Put masses m1 = 2 and m2 = 3 at (0,0,0) and (3,0,0), and use fixed ε = 4. Find the pair potential, both forces and both accelerations.

  1. The softened distance is 32+42=5\sqrt{3^2+4^2}=5, so the potential is −6/5 = −1.2. The force denominator is 125, not 25.

  2. The force on mass one points toward mass two and has x component 6(3)/125=0.1446(3)/125=0.144. The force on mass two is −0.144 along x.

  3. Dividing by the appropriate masses gives a1x = 0.072 and a2x = −0.048. Their mass-weighted sum is 2(0.072) + 3(−0.048) = 0, confirming momentum balance even though their accelerations differ.

The result

U12 = −1.2, F1x = 0.144, F2x = −0.144, a1x = 0.072 and a2x = −0.048 in the declared scaled units.

Explore the model

Interactive lab

Interactive lab · fields

Source scaling without a gravity solver

Reset and set BOTH Source strength q = 1 and Rotation Ω = 0; note the numerical Fx, Fy and magnitude readouts at the fixed probe. Reset and set q = 2 and Ω = 0; predict the components and magnitude double to displayed precision. Visible arrow lengths are compressed, so they do not double. This is a softened planar source field, not a gravitational N-body force evaluator or a momentum-balance simulation.

Source scaling without a gravity solverThe softened illustration is q·r/(r² + 0.2) + Ω(−y, x). Moving markers indicate local direction, not integrated particle paths or a Maxwell solution. Current readings: Fx at (1, 0): 0.833; Fy at (1, 0): 0.5; Field magnitude there: 0.972. All parameters are adjustable with the labeled controls below.−3.2−1.601.63.2−1.5−0.7500.751.5xyq = 1
Local field directionSource strength
Fx at (1, 0)
0.833
Fy at (1, 0)
0.5
Field magnitude there
0.972
t = 0 s

The softened illustration is q·r/(r² + 0.2) + Ω(−y, x). Moving markers indicate local direction, not integrated particle paths or a Maxwell solution. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forCheck numerical field components when testing proportionality; graphical arrow scaling need not be linear.

Check your understanding

If unequal masses interact through a symmetric attractive pair potential, what cancels in the isolated pair momentum balance?

Try it yourself

Keep G = 1, masses 2 and 3 and separation 3, but set ε = 0. Find the Newtonian force magnitude and potential, and compare them with the softened values from the worked example. Does softening itself invalidate pair momentum balance?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

For nonzero separation the unsoftened magnitudes are Gm1m2/r² and Gm1m2/r. Compare forces before dividing by masses.

Compare with the solution

The Newtonian force magnitude is 6/9=2/3≈0.6666676/9=2/3\approx0.666667 and the potential is −6/3 = −2. The softened force 0.144 is only 0.216 of the Newtonian magnitude, while its potential is less negative. This is a deliberate bias at a separation smaller than ε, not a time-integration error. Both force laws retain equal and opposite pair forces for the stated fixed symmetric softening, so each has zero net internal momentum change. More accurate stepping of the softened model cannot restore the missing Newtonian attraction.

Take it with you

  • Fixed symmetric softened pair forces preserve pair momentum balance.
  • Softening trades sampling fluctuations for a model-dependent bias.
  • Force accuracy, boundary treatment and integration accuracy require separate studies.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.