Skip to content

8.7 MSD, diffusion, unwrapping and honest error bars

These are unexecuted teaching inputs and starting settings to test. Original figures are schematics, not computed results. Use licensed VASP and PAW data, replace every placeholder, record the executable version and validate convergence.

8.7.1 Model, units and provenance

Use eV for energy, Å for length and eV/Å for force; 1 kbar = 0.1 GPa. State normalization per atom, molecule, primitive cell or simulation cell. Record PAW identifiers, release, ZVAL, ENMAX and permitted hashes; never redistribute POTCAR. SCF convergence addresses the chosen electronic problem; convergence of the target property requires separate tests.

 MSD, diffusion, unwrapping and honest error bars — original conceptual schematic

Original schematic. Curves explain concepts; blank data areas await verified learner results. No calculation is claimed.

8.7.2 Worked case: procedure, interpretation and checks

Intuition

A particle can cross a periodic boundary while moving only a short distance. Wrapped coordinates make that crossing look like a jump across the box; using only the final wrapped position can instead erase a long journey. Diffusion measures accumulated displacement, so it needs a continuous, unwrapped trajectory. “Keep each molecule whole” and “unwrap the long-time path” are related but different operations.

Define the time-origin-averaged mean-squared displacement for selected particles as

\(\operatorname{MSD}(\tau)=\left\langle\left|\mathbf r_i^{\mathrm{unwrapped}}(t_0+\tau)-\mathbf r_i^{\mathrm{unwrapped}}(t_0)\right|^2\right\rangle_{i,t_0}\).

For an isotropic long-time diffusive regime in d dimensions, \(D=\frac{1}{2d}\frac{d\,\operatorname{MSD}}{d\tau}\). Use d=3 for bulk Cartesian diffusion, d=2 for in-plane isotropic surface diffusion. A confined normal coordinate is not an extra freely diffusing dimension. In anisotropic solids report directional components or a tensor rather than hiding all directions in one scalar.

Prerequisites. An equilibrated trajectory with reliable cell information, sufficiently frequent coordinates, stable particle identities and known time spacing. Distinguish atomic diffusion from molecular centre-of-mass diffusion and charge transport. Proton exchange, correlated ion motion and chemical reactions can invalidate a naive fixed-molecule interpretation. Self-diffusion is not automatically an ionic conductivity measurement.

Workflow

  1. Preserve the sampling clock. If every q integration steps is saved, \(\Delta t_{\mathrm{saved}}=q\,\mathrm{POTIM}\). Record actual file cadence, especially when ML-specific output settings or restarts are used. Never assume one saved frame equals one femtosecond.
  2. Choose a representation. For a fixed orthorhombic cell with sufficiently short intervals, accumulate minimum-image frame-to-frame displacements to obtain continuous paths. If motion between saved frames can exceed half a box, the image history is ambiguous; denser output is needed, not a clever post hoc guess.
  3. Use a tested unwrapping implementation for general cells. Variable-cell unwrapping requires care because cell deformation and particle transport are different contributions. Record whether you report lab-frame displacement, a reference-cell convention or another defined measure. Avoid inventing an algorithm by applying the initial cell to every frame.
  4. Handle collective drift deliberately. Determine whether centre-of-mass drift is a numerical artifact or physical flow. If subtracting it, state which mass-weighted group defines the drift. Removing the centre of mass of the mobile species itself can erase physically meaningful collective transport.
  5. Calculate windowed MSD. Average over many time origins, keeping count of how many contribute at each lag. At long lag, very few origins survive. More lag points do not create more independent evidence.
  6. Locate a genuine diffusive interval. Exclude ballistic short times, cage plateaus and a noisy long-lag tail. Inspect the local logarithmic slope as a diagnostic, not an automatic oracle. If no stable diffusive window exists, report that the trajectory does not support a reliable D.
  7. Estimate uncertainty from independent information. Prefer independent trajectories or long time blocks, each with a defensible fit. Compare fit windows. Adjacent MSD points share coordinates and time origins, so ordinary least-squares standard errors underestimate uncertainty if treated as independent observations.
  8. Assess physical biases. Test system size, thermostat coupling, density and electronic settings. A periodic box can bias hydrodynamic diffusion; a finite-size correction requires an appropriate model and supporting quantities, not a universal number pasted onto every material.

The MDAnalysis MSD documentation requires no-jump coordinates. Its NoJump transformation supports periodic continuity, but this still depends on valid cell data and sufficiently frequent frames. Pin a stable library version and test a known boundary crossing before applying it to the full dataset. MDAnalysis MSD, NoJump

Reporting and exercise

Report particle selection; coordinate and drift convention; number of particles; temperature and ensemble; cell dimensions; timestep and output interval; production duration; fit window; number of independent replicates; slope and uncertainty method; units. Show the MSD and fitted interval. A straight-looking line over a tiny time window is not enough.

Traps: minimum-image displacement only between first and last frames; forgetting that Ų/fs and Ų/ps differ by 1000; using 1/6 for a genuinely 2D process; fitting a caged solid plateau; reporting eight significant figures from one short trajectory; concatenating unrelated replicas into one continuous walk; interpreting no observed jumps as proof of exactly zero diffusion.

Exercise. Construct a purely synthetic unit-test walk with a particle crossing a periodic boundary. This is a software test, not material simulation data. Verify that wrapped and unwrapped MSD differ as expected. Then analyze your real trajectory, vary the fit window, and write either a qualified diffusion estimate or an honest “sampling insufficient” statement.

8.7.3 Unexecuted inputs and analysis scaffolds

These are unexecuted teaching inputs and starting settings to test. Original figures are schematics, not computed results. Use licensed VASP and PAW data, replace every placeholder, record the executable version and validate convergence.

8.7.3.1 Input block 1

# UNEXECUTED conceptual analysis; arrays supplied by a validated trajectory reader
# positions: continuous unwrapped coordinates, shape (n_frames,n_particles,3), Angstrom
# dt_ps: actual time between saved frames, in ps
for lag in selected_lags:
    dr = positions[lag:] - positions[:-lag]
    msd[lag] = mean(sum(dr * dr, axis=-1))
    time_ps[lag] = lag * dt_ps
# Fit only a justified window, and repeat the entire fit per independent replica/block.
# D_A2_per_ps = fitted_slope / 6.0  # ONLY for isotropic 3D diffusion
# D_m2_per_s = D_A2_per_ps * 1e-8

8.7.5 Technical sources