Methods for handling close approaches in $N$-body simulations

In direct gravitational $N$-body simulations, what are the preferred methods for handling close approaches between bodies in order to preserve the accuracy of the evolution of the system?

• Do you mean aside from just having the bodies collide? – M. Enns Apr 9 '16 at 20:49
• Yes. Such encounters aren't always close enough to result in collisions. – Dave Apr 9 '16 at 22:25
• Almost certainly already answered on Computational Science, which is generally a better site for questions that mostly concern programming technique. – dmckee Apr 9 '16 at 23:52

I assume you're talking about the numerical instabilities that arise from having an infinite potential at $r=0$. Here are three common solutions:
1. Use a soft-core potential that behaves like $1/r$ except very close to $r=0$ where it levels off to a finite value. For example, $1/\sqrt{\epsilon+r^2}$ instead of $1/r$ is common.
• 1,2 is avoiding the problem rather than addressing it; changing the potential means the problem being solved is changed and the solution of the new problem will depend on $\epsilon$ or radius of the spheres. 3. working with variable time steps is in the right direction, but the choice of step cannot be done independently of the numerical method. Step is not usually function of distances only; velocities and previous states may play role in the choice as well. – Ján Lalinský Apr 10 '16 at 10:31