Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 47 Ā· Molecular Dynamics

Forces and boundaries: Lennard-Jones and the minimum image

Compute Lennard-Jones forces in Python, apply a cut-off, and use periodic boundaries with the minimum image convention to simulate a bulk fluid.

Two neutral atoms attract each other when they are a little apart and repel strongly when they get too close. The attraction comes from fluctuating electric charge (the London dispersion force); the repulsion comes from overlapping electron clouds and the Pauli principle. In 1924, John Lennard-Jones proposed a simple formula that captures both. It is still the standard model for noble gases and the first potential every simulator learns.

Left: the Lennard-Jones potential and force curves with the minimum marked. Right: a periodic box where the nearest image of a neighbour lies through the box edge
The potential has a well of depth ε at about 1.12 σ; in a periodic box each atom interacts with the nearest copy of every other atom.

What you will learn

  • The Lennard-Jones potential, its two parameters and the position of its minimum.
  • How to get the force from the potential, and how to write it without square roots.
  • Why we cut the potential off and how to shift it.
  • How periodic boundaries and the minimum image convention work in code.

Key terms

Lennard-Jones potential: U(r) = 4ε[(σ/r)¹² āˆ’ (σ/r)⁶].

σ (sigma): the distance at which U = 0, roughly the atom's diameter.

ε (epsilon): the depth of the potential well.

Cut-off radius (r_c): beyond this distance the pair interaction is ignored; 2.5 σ is a common choice.

Minimum image convention: each atom interacts only with the nearest periodic copy of every other atom.

The potential and the force

Text
U(r) = 4ε [ (σ/r)¹² āˆ’ (σ/r)⁶ ]

The r⁻¹² term is a steep repulsive wall. It is chosen for computational convenience (it is the square of the other term) and is not derived from theory. The r⁻⁶ term is the physical long-range attraction. Setting dU/dr = 0 gives the minimum at

Text
r_min = 2^(1/6) σ ā‰ˆ 1.1225 σ,    U(r_min) = āˆ’Īµ

The force along the line between the atoms is F(r) = āˆ’dU/dr:

Text
F(r) = (24ε / r) [ 2 (σ/r)¹² āˆ’ (σ/r)⁶ ]

Positive means repulsive, negative attractive. To get the force vector on atom i due to atom j, multiply F/r by the displacement r_i āˆ’ r_j. Notice the trick: compute everything from r², and you never need a square root, which is the cheapest way to program it:

Text
inv6 = 1 / r2**3
F_over_r = 24 * (2 * inv6**2 - inv6) / r2
force_on_i = F_over_r * (r_i - r_j)

By Newton's third law force_on_j = āˆ’force_on_i.

Cutting off the potential

At r = 2.5σ the potential is only about āˆ’0.016ε, around 1.6 percent of the well depth. Pairs further apart barely matter, but computing them costs time. So we ignore all pairs beyond a cut-off r_c. This introduces a small jump in the energy where the potential suddenly drops to zero. To avoid spurious energy changes when a pair crosses r_c, shift the potential: use U(r) āˆ’ U(r_c) inside the cut-off. The forces are not changed by a constant shift.

Periodic boundaries

A simulation box of a few hundred atoms has most atoms close to a wall; the results would describe a tiny droplet, not a liquid. The standard remedy is to surround the box by copies of itself in every direction. When an atom leaves through the right face, it re-enters through the left face. Two things follow:

  1. Wrapping positions: pos = pos % L keeps every coordinate in [0, L).
  2. Minimum image: the distance between atoms is measured to the nearest copy: d = d āˆ’ L Ā· round(d / L). Each component of d then lies in [āˆ’L/2, L/2].

The minimum image convention only works if the cut-off is at most L/2; otherwise an atom could interact with two copies of the same neighbor.

Common misconceptions

  • "Periodic boundaries make the system a ring or torus in real space." The atoms live in ordinary space; the torus is just a bookkeeping trick that removes walls.
  • "The r⁻¹² term is exact physics." It is a convenient model. Real repulsion is closer to exponential.
  • "A bigger cut-off is always better." Past about 2.5 σ the gain is tiny while the cost grows with the cube of the radius in 3D.
  • "The box can be any size." If L is smaller than twice the cut-off, the minimum image rule breaks.

Try it

First check the mathematics of the potential numerically: the minimum is at 2^(1/6), the depth is āˆ’1, the force vanishes there and U(σ) = 0.

Python Checking the Lennard-Jones facts

Press Run (or Ctrl + Enter) to see the result here.

Program input Ā· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Next, an interactive picture. Move the sliders to change σ and ε in real argon units (nanometers and kelvin) and watch the well move. This is a visualization of the formula, not a simulation.

Move the well: σ and ε sliders

Finally, the periodic box. We place two atoms close to opposite walls and compare the direct distance with the minimum-image distance. Then we check that the force on each atom is equal and opposite.

Python Minimum image in action

Press Run (or Ctrl + Enter) to see the result here.

Program input Ā· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check Ā· 5 questions

of 5 answered You scored / 5 Ā· perfect!

  1. 1. Where is the minimum of the Lennard-Jones potential?

    Setting dU/dr = 0 gives r = 2^(1/6) σ ā‰ˆ 1.12 σ, where U = āˆ’Īµ.
  2. 2. Why is the force usually computed from r² and not r?

    Both the potential and F/r depend only on r², so no square root is needed.
  3. 3. A box has side L = 8σ. What is the largest allowed cut-off for the minimum image convention?

    The cut-off must not exceed L/2 = 4σ.
  4. 4. Atoms at x = 0.5 and x = 9.2 in a periodic box of length 10. What is the minimum-image separation along x?

    The direct difference is āˆ’8.7; adding L = 10 gives 1.3.
  5. 5. Why shift the potential at the cut-off?

    Without a shift, the total energy jumps whenever a pair moves across the cut-off distance.

Summary

  • U(r) = 4ε[(σ/r)¹² āˆ’ (σ/r)⁶]: minimum āˆ’Īµ at r = 2^(1/6)σ; the force is F = (24ε/r)[2(σ/r)¹² āˆ’ (σ/r)⁶].
  • Compute from r² to avoid square roots; apply Newton's third law to save half the work.
  • Cut the potential at about 2.5 σ and shift it so the energy is continuous.
  • Periodic boundaries remove walls; the minimum image rule d āˆ’ LĀ·round(d/L) picks the nearest copy, valid for r_c ≤ L/2.

Next: Velocity Verlet and energy conservation