Lesson 1.2 · 12 min
Atoms and forces: the Lennard-Jones potential
Two neutral atoms still feel each other: a gentle pull when they are near, a hard push when they overlap. One simple curve captures both.
- Why neutral atoms attract at a distance and repel up close
- What the two parameters σ and ε mean
- How to compute the Lennard-Jones energy and force in code
The idea
Argon atoms have no charge, yet argon still turns into a liquid when it is cold enough. Something must hold the atoms together.
When two atoms are far apart, they hardly notice each other. A bit closer, the electron clouds of each atom shift slightly and create tiny, fluctuating dipoles that attract each other. This is the van der Waals (dispersion) pull. If they come too close, the electron clouds overlap and a very strong repulsion pushes them apart.
The Lennard-Jones potential puts all of this into one curve V(r), the energy of the pair at distance r. It has just two numbers:
- σ (sigma), the size: the distance where V = 0. Atoms cannot get much closer than this.
- ε (epsilon), the stickiness: the depth of the energy well. A bigger ε means atoms hold on to each other more strongly.
The bottom of the well, at r ≈ 1.12σ, is where the push and pull balance and the force is zero. Atoms in a liquid or solid jiggle around this distance.
The algorithm
To get the force on every atom, add up the Lennard-Jones force from every other atom:
- Set all forces to zero.
- Loop over every pair i < j, so each pair is counted once.
- Find the distance vector d = ri − rj and its length r.
- If r is larger than the cutoff (usually 2.5σ), skip the pair. The force there is almost zero.
- Compute the force size F(r) and add F·d/r to atom i.
- Subtract the same amount from atom j. Newton's third law: equal and opposite.
forces = zeros(N, 3)
for i in range(N):
for j in range(i + 1, N):
d = pos[i] - pos[j]
r = length(d)
if r < r_cut:
f = F(r) * d / r # vector along the line between the atoms
forces[i] += f
forces[j] -= f
This double loop costs about N²/2 pair checks. That is fine for a few hundred atoms. Lesson 2.6 shows how neighbour lists make it much faster.
See it inside LAMMPS
The same idea in the real code, run live in your browser and checked by hand.