Skip to content

MSD

Textbook guide to the mean-squared displacement and the Einstein route to self-diffusion.

Conventions

  • Time in fs (LAMMPS real); length Å.
  • Displacement kernels need unwrapped coordinates.
  • \(d=3\); Einstein factor \(1/(2d)=1/6\).

1. Random walk and Einstein relation

\[ \mathrm{MSD}(\tau) = \big\langle |\mathbf{r}_i(t+\tau)-\mathbf{r}_i(t)|^2 \big\rangle_{i,t}. \]
\[ \boxed{D = \lim_{\tau\to\infty} \frac{1}{6\tau}\,\mathrm{MSD}(\tau)} \]

Regimes: ballistic \(\propto\tau^2\)diffusive \(\propto\tau\) (fit here) → noisy long lag. Use MSD(method="window") to average every time origin.

Periodic images must be unwrapped before MSD. Crossing a box face by \(L\) is a continuous path, not a jump.

Figure 1. Schematic MSD with regimes marked by scale bars: ballistic \(\propto\tau^{2}\), linear diffusive window (fit here), noisy long lag.


2. Usage

import numpy as np
import molpy as mp
from molpy.compute import MSD, LinearFit

rng = np.random.default_rng(0)
frames = []
for step in range(20):
    xyz = rng.uniform(0.0, 10.0, size=(40, 3)) + 0.05 * step
    f = mp.Frame()
    f["atoms"] = {"x": xyz[:, 0], "y": xyz[:, 1], "z": xyz[:, 2]}
    f.box = mp.Box.cubic(10.0)
    frames.append(f)

series = MSD(method="window")(frames)
# D = slope / 6 after LinearFit on the linear window of series.mean vs lag

Green–Kubo \(D\) from velocities: VACF. Collective coupling: Onsager.