Algorithm Search⌘K

Techniqueadvanced

Kustaanheimo-Stiefel regularization

Also called KS regularization.

Maps the Kepler problem to a harmonic oscillator in four dimensions with a new time variable, so close binaries can be integrated without singularity.

Kustaanheimo-Stiefel (KS) regularization removes the 1/r21/r^2 singularity of the two-body force. It replaces the relative position x∈R3\mathbf{x} \in \mathbb{R}^3 of a close pair by a vector u∈R4\mathbf{u} \in \mathbb{R}^4 with ∣x∣=∣u∣2|\mathbf{x}| = |\mathbf{u}|^2, and the physical time tt by a fictitious time ss with dt=r dsdt = r\, ds. In these variables the unperturbed Kepler motion becomes a harmonic oscillator, u′′=h2u\mathbf{u}'' = \frac{h}{2} \mathbf{u}, where hh is the two-body energy per unit reduced mass. The equations are smooth and linear even through a collision, so a step in ss of fixed size follows a binary of any eccentricity with the same relative accuracy. Direct N-body codes for star clusters use KS for hard binaries and close encounters, where an ordinary step would have to shrink by many orders of magnitude.

In plain words

When two stars pass very close, the pull between them becomes huge and changes very fast. A normal integrator must then take tiny steps, and at a collision it fails.

KS regularization changes the variables of the pair. The position is written as the "square" of a new vector with four entries, and the clock is slowed in proportion to the distance, so the close passage takes many small physical moments but a normal amount of new time. With both changes, the orbit of the pair becomes the motion of a weight on a spring, which has no bad points at all. The pair is integrated in the new variables, and the result is changed back when the positions are needed.

When it applies

  • Two bodies are much closer to each other than to all other bodies, so their motion is a Kepler orbit plus a small perturbation P\mathbf{P} from the rest of the system.
  • The forces are point-mass gravity, without softening, and collisions or very eccentric binaries must be followed accurately.
  • The integrator can use its own time variable for the pair, as in the NBODY codes with block time steps, where the KS pair is a single body for the rest of the system.

It does not apply to three or more bodies at once, unless they are put in a chain of pairs; and when the pair is far from isolated, the perturbation dominates and the regularized equations lose their advantage.

The template

Write μ=G(m1+m2)\mu = G(m_1 + m_2), x=x2−x1\mathbf{x} = \mathbf{x}_2 - \mathbf{x}_1, v=x˙\mathbf{v} = \dot{\mathbf{x}} and r=∣x∣r = |\mathbf{x}|.

  1. The map. For u=(u1,u2,u3,u4)\mathbf{u} = (u_1, u_2, u_3, u_4) let
L(u)=(u1−u2−u3u4u2u1−u4−u3u3u4u1u2u4−u3u2−u1),L(\mathbf{u}) = \begin{pmatrix} u_1 & -u_2 & -u_3 & u_4 \\ u_2 & u_1 & -u_4 & -u_3 \\ u_3 & u_4 & u_1 & u_2 \\ u_4 & -u_3 & u_2 & -u_1 \end{pmatrix},

and set (x,0)=L(u)u(\mathbf{x}, 0) = L(\mathbf{u}) \mathbf{u}, that is, x1=u12−u22−u32+u42x_1 = u_1^2 - u_2^2 - u_3^2 + u_4^2, x2=2(u1u2−u3u4)x_2 = 2(u_1 u_2 - u_3 u_4) and x3=2(u1u3+u2u4)x_3 = 2(u_1 u_3 + u_2 u_4). The matrix satisfies L(u)TL(u)=∣u∣2IL(\mathbf{u})^T L(\mathbf{u}) = |\mathbf{u}|^2 I, so r=∣u∣2r = |\mathbf{u}|^2.

  1. The inverse map. If x1≥0x_1 \ge 0, take u1=(r+x1)/2u_1 = \sqrt{(r + x_1)/2}, u2=x2/(2u1)u_2 = x_2 / (2u_1), u3=x3/(2u1)u_3 = x_3 / (2u_1) and u4=0u_4 = 0. Otherwise take u2=(r−x1)/2u_2 = \sqrt{(r - x_1)/2}, u1=x2/(2u2)u_1 = x_2 / (2u_2), u3=0u_3 = 0 and u4=x3/(2u2)u_4 = x_3 / (2u_2). Each x≠0\mathbf{x} \ne 0 has a circle of preimages; this choice is one of them.

  2. The new time and the velocity. Set dt=r dsdt = r\, ds and write ′=d/ds' = d/ds. Then v=2L(u)u′/r\mathbf{v} = 2 L(\mathbf{u}) \mathbf{u}' / r, and from v\mathbf{v} take u′=12L(u)T(v,0)\mathbf{u}' = \frac{1}{2} L(\mathbf{u})^T (\mathbf{v}, 0). This u′\mathbf{u}' satisfies the bilinear relation u4u1′−u3u2′+u2u3′−u1u4′=0u_4 u_1' - u_3 u_2' + u_2 u_3' - u_1 u_4' = 0, which is the fourth row of L(u)u′=0L(\mathbf{u}) \mathbf{u}' = 0 and which the equations of motion keep.

  3. The equations of motion. With h=v2/2−μ/r=(2∣u′∣2−μ)/rh = v^2/2 - \mu/r = (2|\mathbf{u}'|^2 - \mu)/r and a perturbing acceleration P\mathbf{P} on the relative motion,

u′′=h2u+r2L(u)T(P,0),h′=2 u′⋅L(u)T(P,0),t′=∣u∣2.\mathbf{u}'' = \frac{h}{2} \mathbf{u} + \frac{r}{2} L(\mathbf{u})^T (\mathbf{P}, 0), \qquad h' = 2\, \mathbf{u}' \cdot L(\mathbf{u})^T (\mathbf{P}, 0), \qquad t' = |\mathbf{u}|^2.

These ten equations have no singularity at u=0\mathbf{u} = 0. Integrate them with any accurate method in ss, for example Runge-Kutta or a Hermite scheme in ss.

  1. Back to physical variables. When the positions of the pair are needed at a physical time, map u\mathbf{u} and u′\mathbf{u}' back with steps 1 and 3 and place the two bodies about their center of mass.

Classic examples

A circular orbit. Take μ=1\mu = 1, x=(1,0,0)\mathbf{x} = (1, 0, 0) and v=(0,1,0)\mathbf{v} = (0, 1, 0), so h=−12h = -\frac{1}{2}. Step 2 gives u=(1,0,0,0)\mathbf{u} = (1, 0, 0, 0), and step 3 gives u′=(0,12,0,0)\mathbf{u}' = (0, \frac{1}{2}, 0, 0). The equation u′′=−14u\mathbf{u}'' = -\frac{1}{4} \mathbf{u} has the solution u(s)=(cos⁡s2,sin⁡s2,0,0)\mathbf{u}(s) = (\cos \frac{s}{2}, \sin \frac{s}{2}, 0, 0), and the map gives x(s)=(cos⁡s,sin⁡s,0)\mathbf{x}(s) = (\cos s, \sin s, 0). Here r=1r = 1, so t=st = s, and the orbit closes after t=2πt = 2\pi while u\mathbf{u} makes only half a turn. In the plane u3=u4=0u_3 = u_4 = 0 the map is the square u1+iu2↦(u1+iu2)2u_1 + i u_2 \mapsto (u_1 + i u_2)^2 of a complex number, which is the Levi-Civita map.

Kepler's third law. For any bound orbit, ω2=−h/2\omega^2 = -h/2 and u(s)=u0cos⁡ωs+(u0′/ω)sin⁡ωs\mathbf{u}(s) = \mathbf{u}_0 \cos \omega s + (\mathbf{u}'_0 / \omega) \sin \omega s. Since x\mathbf{x} is quadratic in u\mathbf{u}, the orbit closes after s=π/ωs = \pi / \omega, and

T=∫0π/ω∣u(s)∣2 ds=π2ω(∣u0∣2+∣u0′∣2ω2)=π2ω⋅2a=2πa3/μ,T = \int_0^{\pi/\omega} |\mathbf{u}(s)|^2\, ds = \frac{\pi}{2\omega} \left( |\mathbf{u}_0|^2 + \frac{|\mathbf{u}'_0|^2}{\omega^2} \right) = \frac{\pi}{2\omega} \cdot 2a = 2\pi \sqrt{a^3 / \mu},

with a=−μ/(2h)a = -\mu / (2h), because ∣u0∣2=r0|\mathbf{u}_0|^2 = r_0 and ∣u0′∣2/ω2=2a−r0|\mathbf{u}'_0|^2 / \omega^2 = 2a - r_0. For x=(1.5,0.2,−0.3)\mathbf{x} = (1.5, 0.2, -0.3), v=(0.1,0.6,0.25)\mathbf{v} = (0.1, 0.6, 0.25) and μ=1\mu = 1, the oscillator returns x\mathbf{x} to its start at s=π/ωs = \pi/\omega to rounding, and a numerical quadrature of t′t' gives T=7.8249044T = 7.8249044, equal to 2πa3/22\pi a^{3/2} with a=1.15753a = 1.15753 (measurement).

Binaries in star cluster codes. The NBODY codes of Aarseth treat each hard binary and each close encounter as a KS pair, with its perturbation from the neighbors, and they switch the pair back to ordinary bodies when it separates (Aarseth 2003, Section 4.4).

Variations

  • Levi-Civita regularization. The same idea in the plane, with u∈R2\mathbf{u} \in \mathbb{R}^2 and the complex square x1+ix2=(u1+iu2)2x_1 + i x_2 = (u_1 + i u_2)^2 (Aarseth 2003, Section 4.3). There is no quadratic map of this kind from R3\mathbb{R}^3 to R3\mathbb{R}^3 with ∣x∣=∣u∣2|\mathbf{x}| = |\mathbf{u}|^2 and a matrix LL with orthogonal columns, which is why KS goes to four dimensions (theorem of Hurwitz on composition of quadratic forms).
  • Sundman time transformation alone. Only dt=r dsdt = r\, ds, or dt=rαdsdt = r^\alpha ds, without the change of position. It spreads the steps more evenly around the pericenter but does not remove the singularity of the equations.
  • Stumpff function solutions. For a weakly perturbed pair, the oscillator part can be advanced exactly with Stumpff functions, and only the perturbation is integrated (Aarseth 2003, Section 4.7).
  • Chain and many-body regularization. For three or more close bodies, regularize each pair along a chain of the closest neighbors (Mikkola and Aarseth), or use a time transformation with the Lagrangian, as in the algorithmic regularization of Mikkola and Tanikawa.
  • Hamiltonian form. KS can also be written as a canonical transformation of an extended Hamiltonian, so that a symplectic integrator applies in the new variables.

Pitfalls

  • The bilinear relation. The equations keep ℓ(u,u′)=u4u1′−u3u2′+u2u3′−u1u4′=0\ell(\mathbf{u}, \mathbf{u}') = u_4 u_1' - u_3 u_2' + u_2 u_3' - u_1 u_4' = 0 only if it holds at the start. Starting with any other u′\mathbf{u}' gives a velocity v\mathbf{v} that is not the derivative of x\mathbf{x}. Always take u′\mathbf{u}' from step 3.
  • Energy as a variable. The coefficient hh must be integrated with its own equation h′=2 u′⋅LTPh' = 2\, \mathbf{u}' \cdot L^T \mathbf{P}, not recomputed from u\mathbf{u} and u′\mathbf{u}', or the oscillator equation picks up errors near pericenter where rr is small.
  • Physical time output. The step is fixed in ss, not in tt. To get the state at a given tt, iterate on ss with the equation t′=∣u∣2t' = |\mathbf{u}|^2, for example by Newton's method.
  • Strong perturbations. When a third body comes close, P\mathbf{P} becomes as large as the pair force, the oscillator form gives no gain, and the pair must be ended or put into a chain.
  • Unbound pairs. For h>0h > 0 the oscillator becomes u′′=h2u\mathbf{u}'' = \frac{h}{2} \mathbf{u} with exponential solutions; the equations stay regular, but the closed-form solutions use cosh⁡\cosh and sinh⁡\sinh.

Exercises

  1. Show that L(u)TL(u)=∣u∣2IL(\mathbf{u})^T L(\mathbf{u}) = |\mathbf{u}|^2 I, and conclude that ∣x∣=∣u∣2|\mathbf{x}| = |\mathbf{u}|^2 and ∣v∣2=4∣u′∣2/r|\mathbf{v}|^2 = 4 |\mathbf{u}'|^2 / r.
  2. Show that u\mathbf{u} and (u1cos⁡φ−u4sin⁡φ, u2cos⁡φ+u3sin⁡φ, u3cos⁡φ−u2sin⁡φ, u4cos⁡φ+u1sin⁡φ)(u_1 \cos\varphi - u_4 \sin\varphi,\ u_2 \cos\varphi + u_3 \sin\varphi,\ u_3 \cos\varphi - u_2 \sin\varphi,\ u_4 \cos\varphi + u_1 \sin\varphi) map to the same x\mathbf{x} for every φ\varphi.
  3. Starting from x¨=−μx/r3\ddot{\mathbf{x}} = -\mu \mathbf{x} / r^3, dt=r dsdt = r\, ds and the bilinear relation, derive u′′=h2u\mathbf{u}'' = \frac{h}{2} \mathbf{u}.
  4. A radial orbit starts at rest at x=(1,0,0)\mathbf{x} = (1, 0, 0) with μ=1\mu = 1. Show that u(s)=(cos⁡s2,0,0,0)\mathbf{u}(s) = (\cos \frac{s}{\sqrt{2}}, 0, 0, 0), that u\mathbf{u} passes through 0 smoothly at s=π/2s = \pi / \sqrt{2}, and that the time to the collision is t=π/(22)t = \pi / (2\sqrt{2}). What happens to x\mathbf{x} after the collision?

References

  1. Paul Kustaanheimo and Eduard Stiefel, Perturbation theory of Kepler motion based on spinor regularization, Journal fur die reine und angewandte Mathematik 218, 1965, 204-219, the four-dimensional map and the regularized equations of motion
  2. Sverre J. Aarseth, Gravitational N-Body Simulations, Tools and Algorithms, Cambridge University Press, 2003, Section 4.3 (Levi-Civita regularization), Section 4.4 (Kustaanheimo-Stiefel regularization), Section 4.7 (Stumpff functions)

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