Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 39 · Non-Equilibrium and Monte Carlo Methods

Random Walks and Diffusion

Connect random walks to the diffusion equation, derive mean-square displacement 2Dt, use the Stokes-Einstein relation D = kT/(6 pi eta a), and simulate Brownian motion in Python.

Equilibrium statistical mechanics tells you what a system looks like once everything has settled. This lesson starts on the path toward how systems move: the random jiggling of a pollen grain, the spreading of ink in water, the thermal motion of a particle kicked by molecules. The central object is the random walk, and its large-scale limit is diffusion. The key result, Einstein's relation, links the diffusion constant D to temperature and friction.

The one-dimensional random walk

A walker sits at x = 0. Every time step τ it jumps +a or -a with equal probability, independently. After n steps the position is x_n = a Σ ξ_i with ξ_i = ±1. Because the steps are independent with zero mean:

Text
⟨x_n⟩ = 0,       ⟨x_n²⟩ = n a²

With t = nτ the mean-square displacement (MSD) is ⟨x²⟩ = (a²/τ) t. We define the diffusion coefficient by ⟨x²⟩ = 2 D t in one dimension, so D = a²/(2τ). In two and three dimensions the MSD is 4Dt and 6Dt. The crucial feature is that the MSD is linear in time: displacement grows like √t, not t, which is why diffusion is fast over short distances and hopelessly slow over long ones.

By the central limit theorem, for large n the distribution of x_n is Gaussian with variance 2Dt:

Text
P(x, t) = (4π D t)^(-1/2) exp( -x² / (4 D t) )

This function solves the diffusion equation ∂P/∂t = D ∂²P/∂x², also called Fick's second law. Its derivation from the walk is one of the simplest examples of a microscopic stochastic process producing a macroscopic deterministic law.

Simulating walkers

The code simulates 20,000 independent 1D walkers with a = 1 and τ = 1 (so D = 1/2), checks that the MSD is linear, and compares the histogram at a fixed time with the Gaussian.

Python Random walkers: MSD and the Gaussian limit

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.

The fitted D agrees with 0.5 within about a percent, and the histogram follows the Gaussian (the histogram bins have width 2 because x_n has a fixed parity, so every second integer is empty).

The Einstein relation

A small particle suspended in a fluid is bombarded by molecules at random. Einstein (1905) combined two ideas. Over long times the particle diffuses, with D. In a steady state under a force F, it drifts with velocity v = F/γ, where γ is the friction coefficient. Balancing diffusion against drift in a potential and requiring the Boltzmann distribution gives the Einstein relation:

Text
D = k T / γ

For a sphere of radius a in a fluid of viscosity η, Stokes' law gives γ = 6π η a, so

Text
D = k T / (6π η a)       (Stokes-Einstein)

This connects a microscopic quantity (k, the Boltzmann constant) to something you can measure by watching particles under a microscope. Jean Perrin used measurements of this kind in the early 1900s to determine Avogadro's number and so confirm the molecular theory of matter.

Stokes' law applies to a sphere moving slowly through a fluid that can be treated as a continuum, which is a good description for micrometer particles in water but not for molecules comparable in size to the solvent.

Brownian motion at real scales

For a bead of diameter 1 µm (a = 0.5 µm) in water at 293 K (η ≈ 1.00 × 10⁻³ Pa·s), the formula gives D ≈ 4.3 × 10⁻¹³ m²/s. In one second the 1D rms displacement is √(2Dt) ≈ 0.9 µm. The code builds a two-dimensional trajectory with those parameters, then does something an experimenter could do: estimates D from the MSD and, from it, recovers k (a simulation, not a real measurement, but the logic is Perrin's).

Python Brownian bead: simulate, fit D, recover the Boltzmann constant

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.

The recovered k lands within a few percent of the true value. With real data, the main uncertainties are the bead radius, the viscosity and the temperature, which is why Perrin's measurements had errors of tens of percent.

What comes next

Diffusion is a macroscopic average of a microscopic random process. To describe the motion of a single particle with inertia, friction and random forces, you need the Langevin equation, which is the subject of the next lesson.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. In 1D diffusion with coefficient D, the mean-square displacement after time t is

    ⟨x²⟩ = 2Dt in one dimension; it is linear in t (and equals 4Dt in 2D, 6Dt in 3D).
  2. 2. Why is the displacement of a random walker proportional to √t?

    Independent random contributions give variance ∝ n, so the typical size is ∝ √n.
  3. 3. The Stokes-Einstein relation gives D equal to

    D = kT/γ with Stokes friction γ = 6πηa.
  4. 4. If you double the viscosity of the fluid (same T and bead), D

    D is inversely proportional to η.

Summary

  • Independent random steps give ⟨x²⟩ = 2Dt (1D), a Gaussian profile and the diffusion equation ∂P/∂t = D ∂²P/∂x².
  • Einstein: D = kT/γ, and for a sphere D = kT/(6πηa).
  • Fitting the MSD of tracked particles gives D, hence k: the idea behind Perrin's experiments.

Next: The Langevin Equation and Fluctuation-Dissipation