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.
- Why a cutoff makes MD affordable, and how its cost grows as rc³
- Truncated, shifted, force-shifted and switched potentials
- Tail corrections, and why charges cannot simply be cut off
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:
- Truncate: V = 0 beyond rc. The energy jumps when a pair crosses rc, which spoils energy conservation (Lesson 1.6).
- Shift: subtract V(rc) so the energy is continuous. The force still jumps at rc.
- Force-shift: also subtract the force at rc, so both energy and force go smoothly to zero. It changes the potential slightly everywhere.
- Switch: leave V untouched up to ron, then smoothly bend it to zero by rc. Common in force fields (CHARMM, GROMACS).
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.
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
- Compare r² with rc² and avoid the square root, which is slow.
- Keep rc ≤ L/2 (Lesson 2.4).
- Report energies with the tail correction, or state clearly which cutoff and scheme you used. Results are not comparable otherwise.
- The loop above still checks all N² pairs. Lesson 2.6 uses neighbour lists so each atom only checks atoms that are nearby.
See it inside LAMMPS
The same idea in the real code, run live in your browser and checked by hand.