RDF¶
Textbook guide to the radial distribution function \(g(r)\) — the probability of finding a particle at distance \(r\) from a reference particle, normalized by an ideal gas of the same density.
Conventions
- Length Å; \(g(r)\) dimensionless; keep \(r_\max \le L/2\).
- Workflow: build a NeighborList, then histogram.
1. Definition¶
For \(N\) particles in volume \(V\) with density \(\rho = N/V\),
Equivalently, if \(n(r)\,\mathrm{d}r\) is the mean neighbour count in \([r,r+\mathrm{d}r]\),
Limits: \(g\to 0\) as \(r\to 0\) (excluded volume); \(g\to 1\) as \(r\to\infty\); peaks are coordination shells. The first minimum after the first peak is the natural cutoff for Persist, Cluster, and Order.
1.1 Coordination number¶
Evaluate at the first minimum of \(g(r)\) for the first-shell coordination number.
2. Computing \(g(r)\)¶
import numpy as np
import molpy as mp
rng = np.random.default_rng(0)
xyz = rng.uniform(0.0, 20.0, size=(200, 3))
frame = mp.Frame()
frame["atoms"] = {"x": xyz[:, 0], "y": xyz[:, 1], "z": xyz[:, 2]}
frame.box = mp.Box.cubic(20.0)
from molpy.compute import NeighborList, RDF
nlist = NeighborList(cutoff=10.0)(frame)
result = RDF(n_bins=200, r_max=10.0)([frame], [nlist])
result.rdf, result.bin_centers
Average over a trajectory by passing parallel lists of frames and neighbor lists.
Neighbor cutoff must be \(\ge\) r_max.
Figure 1. Schematic liquid \(g(r)\): core exclusion, first shell peak, decay to 1.
3. Pitfalls¶
r_max > L/2→ MIC contamination.- Neighbor cutoff
< r_max→ truncated \(g(r)\). - Too few bins → low first peak / coordination number.
- Single frame → \(g(r)\) is an ensemble average.
4. References¶
- M. P. Allen, D. J. Tildesley, Computer Simulation of Liquids, 2nd ed. (2017).
- J.-P. Hansen, I. R. McDonald, Theory of Simple Liquids, 4th ed. (2013).