Lesson 2.5 · 13 min

Cutoffs and the minimum image

Computing every pair of atoms costs N², which quickly becomes impossible. The Lennard-Jones interaction fades so fast that pairs beyond a cutoff can be ignored, if you handle the edge carefully and add back what you left out.

The idea

N atoms have N(N−1)/2 pairs. For 100,000 atoms that is 5 × 109 pair calculations every step: far too many. Luckily the Lennard-Jones attraction falls off as r−6. At 2.5σ it is only −0.016ε, about 1.6% of the well depth. So we introduce a cutoff rc and simply ignore pairs beyond it.

Each atom then only interacts with neighbours inside a sphere of radius rc. That is about ρ·(4/3)πrc³ atoms, roughly 55 at 2.5σ in a liquid. The cost grows as rc³: doubling the cutoff makes the run eight times slower.

How you cut matters:

Pairs beyond rc still add a small attraction. The tail correction adds it back analytically, assuming the liquid is uniform beyond rc. It matters for energy and especially for pressure.

Key idea. Cut the Lennard-Jones interaction at about 2.5σ (or 1.0–1.2 nm in force fields), make the edge smooth, and add tail corrections. Coulomb forces decay only as 1/r, so they cannot be cut. They need Ewald summation (Chapter 5).

The algorithm

The force loop with a cutoff, using a shifted potential:

rc2 = rc * rc
V_rc = 4 * (rc**-12 - rc**-6)
for each pair i < j:
    d = min_image(pos[i] - pos[j])
    r2 = dot(d, d)
    if r2 >= rc2: continue              # the cutoff
    inv6 = 1 / r2**3
    U += 4 * (inv6**2 - inv6) - V_rc    # shifted energy
    f = 24 * (2 * inv6**2 - inv6) / r2 * d
    F[i] += f;  F[j] -= f
  1. Compare r² with rc² and avoid the square root, which is slow.
  2. Keep rc ≤ L/2 (Lesson 2.4).
  3. Report energies with the tail correction, or state clearly which cutoff and scheme you used. Results are not comparable otherwise.
  4. The loop above still checks all N² pairs. Lesson 2.6 uses neighbour lists so each atom only checks atoms that are nearby.