Pair distribution function

Where do atoms sit relative to each other? The pair distribution function answers that with one curve, and it works even for glasses and liquids where there is no lattice to index.

Real space: count your neighbors

The question: in this pile of atoms, are there preferred distances? Stand on any atom and look around. How far away do the neighbors sit, typically? Is there a favorite spacing, a second shell, or just randomness? Answering that for every atom at every distance is a complete description of local structure, and one line of bookkeeping writes it down:

\[g(r) = \frac{\rho(r)}{\rho_0}\]
  • \(\rho(r)\): local density at distance r. Stand on an atom, draw a thin ring at r, count atoms in it, divide by the ring’s area (atoms/Ų here; atoms/ų for a 3D shell)

  • \(\rho_0 = N/V\): average density, just the atom count over the box size. This widget: 64 atoms / (10 × 10) = 0.64 per unit area. Real materials: atoms per ų

  • the ratio has no units: the densities cancel, so g(r) measures arrangement, not amount. \(g(r) = 1\) means the ring is exactly as crowded as random

  • peaks: preferred distances (bond lengths, neighbor shells); \(g \approx 0\) below the first peak because atoms cannot overlap

Press Count it to watch the definition happen: a ring sweeps outward from each atom, every neighbor it crosses drops one count into the histogram at that distance, and after the last atom the raw counts are divided by ρ₀ × ring area to become g(r).

Crystal: sharp peaks forever. Liquid: a few broad shells, then flat 1. Ideal gas: 1 everywhere, even at tiny r, because these are non-interacting points. Real atoms can never do that; their electron clouds repel, which is why every real material digs the g ≈ 0 hole you see below the liquid’s first peak.

The structure factor: pair distances written as waves

In an experiment the question changes, because the atoms are invisible. A diffraction pattern is made of scattered waves, so the question becomes: what do pair distances look like when all you can record is waves?

What does the wave do at an atom?

Before any formula: what is the interaction? The incoming wave is an oscillating field, and it shakes the atom’s electrons at its own frequency, like driven pendulums. A shaken charge cannot help but radiate, so the atom re-broadcasts the wave. That is elastic scattering: nothing absorbed, nothing stored, just forced dancing that emits a new wave. Watch it happen, one atom, close up:

Each passing crest lifts the electron, each trough pulls it down (the bottom trace shows field in and motion out, locked in rhythm), and that wiggle is the source of the outgoing ripples. Use the two wave toggles to take the interaction apart: incoming alone is the world without the atom, scattered alone is what the atom adds, and both together is what actually exists.

One honesty note: the widget exaggerates wildly. Real scattering is feeble; almost all of the wave passes through untouched, and the redirected fraction is tiny (an atom’s effective target area for X-rays is about a hundred-millionth of its geometric size, which is why X-rays pass through your hand). And elastic scattering absorbs nothing: the electron borrows and re-emits in the same instant. True absorption is a separate channel that kills the photon and produces no fringes. The feebleness is a gift: it means each detected wave scattered exactly once, the hidden assumption behind every formula on this page. Electrons scatter far more strongly, which is why thick samples in electron diffraction need multiple-scattering corrections. Toggle Dipole pattern for the honest 3D shape: a wiggling charge radiates strongest sideways and not at all along its shake axis, the dashed figure-eight, which in 3D is a donut around the field direction.

One refinement beyond X-rays: electron waves (4D-STEM) scatter forward-peaked off the atomic potential instead, and neutrons really do get a sphere from the pointlike nucleus. And the atom is not a point: its electron cloud is a blob about 1 Å wide, every part of which radiates, and those internal wavelets interfere with each other. The atom is a tiny double-slit experiment with itself. Their growing cancellation at high k is exactly the decaying form factor f(k), the single-atom hill that the real-data section below has to fit away.

One atom alone just re-broadcasts. Two atoms re-broadcast from two places, and the ripples overlap: along some directions crest lands on crest (bright), along others crest lands on trough (dark). This is the double-slit experiment, atom edition. A slit in a wall and an atom do the same job, acting as a point re-broadcaster, and the slit spacing is the pair distance r:

The strip on the right is the double-slit fringe pattern on a detector screen. Drag the atoms apart and the fringes tighten; shorten λ and they tighten too. Now press Double slit: the atoms are replaced by a wall with two gaps at the same spots, and the detector pattern does not change. That is the entire relationship: slit or atom, anything that re-broadcasts a wave from a point writes the same fringes. Diffraction from matter is the double-slit experiment with atoms as the slits.

One stitch before moving on: a screen sees every angle at once, and each angle corresponds to one value of k. So “walking along the fringe pattern” and “sweeping k at a single detector” are the same act. From here on we stand at one detector and turn k.

One pair, two waves: where the sine comes from

Take the simplest case: two atoms, one detector. Both atoms scatter the same incoming wave, so the detector receives two copies, and the copy from the farther atom arrives late. The question: when do the two copies reinforce, and when do they cancel?

Hold three physical pictures. k is a ruler: how many wave repeats fit in one unit of length (the detector angle selects it). The product kr is a count: how many wave cycles fit between the two atoms. And the rule is: whole number of cycles, the copies arrive in step, bright; an extra half cycle, they arrive opposite, dark. Sweep k and one more cycle fits every time k grows by 1/r, so the brightness rings with period 1/r. The ringing speed is the distance. The sine shape itself is just the wave’s own profile showing through (\(\Delta\varphi = 2\pi k r\) is the cycle count in radians, and the summed brightness oscillates as \(\cos(2\pi k r)\)).

One more step reaches the Debye formula. A liquid or glass holds this pair in every orientation, and a tilted pair presents a shorter projected distance to the beam, so its fringe is slower. Press Average all orientations: the fringes agree near k = 0 and disagree more and more at high k, so their average oscillates with period 1/r but decays. That average is exactly \(\sin(2\pi k r)/(2\pi k r)\).

Why sin(x)/x exactly?

Why does that average come out to a sine divided by x? A pair tilted at fraction u of full alignment reads a phase of x·u (with x = 2πkr), so running over all orientations reads a plain cosine at every phase from 0 to x, evenly. The orientation average is therefore just the average height of a cosine over the window [0, x]: area divided by length. The area under a cosine accumulates into a sine, so the average is sin(x)/x.

Short window: the cosine has not bent yet, every orientation reads about 1, fully constructive. Long window: each whole cycle cancels itself (green against red), only the last partial cycle survives, and that fixed-size leftover divided by an ever-longer window is the 1/x decay. The wiggle is just whether the window ends on a crest or a trough.

You now know everything a diffractometer knows. Time to use it: below, one pair is hidden (held at a fixed orientation, so its fringe is the plain cosine), r is invisible, and k is the only knob you have. Sweep k, watch the lamp flutter, and read the distance out of the flutter rate:

When your dashed prediction lies on your measured dots, you have measured an atomic distance without ever seeing an atom. That is the entire profession of diffraction, in one slider.

A real sample is not one pair but every pair at once. Each pair contributes its own ripple \(\sin(2\pi k r)/(2\pi k r)\), and the structure factor S(k) is the pile. The Debye formula is the bookkeeping:

\[S(k) = 1 + \frac{2}{N} \sum_{i<j} \frac{\sin(2\pi k\, r_{ij})}{2\pi k\, r_{ij}}\]
  • \(r_{ij}\): each pair distance contributes exactly one ripple

  • \(k\): how many wave oscillations per unit length; short distances write slow ripples at high k

  • \(S(k) = 1\): no structure (the ideal gas again, now in wave language)

  • the name: measured intensity factorizes as \(I(k) = N f(k)^2 S(k)\), one atom’s scattering (the form factor f) times the arrangement’s multiplier (the structure factor S). With no correlations S = 1 and the factor does nothing.

So S(k) is not a new quantity. It is g(r) rewritten in the language the detector speaks, and the translation back is a sine transform:

\[G(r) = \frac{2}{\pi}\int_0^{k_{max}} 2\pi k \left[S(k) - 1\right] \sin(2\pi k r)\, dk\]

Three things to know about G(r), because it looks different from g(r):

  • G is the deviation from average density, scaled by r: \(G(r) = 4\pi r \rho_0 [g(r) - 1]\). It oscillates around zero, and negative simply means “emptier than average at this distance”. Recover the familiar curve as \(g(r) = 1 + G(r)/(4\pi r \rho_0)\), which needs the density \(\rho_0\) (quantem estimates it from the data).

  • The transform prefers G over g because multiplying by r and subtracting the boring baseline is exactly what makes the sine transform clean.

  • Convention warning for reading papers: this page uses k = 1/λ (cycles per length). Most PDF literature uses \(Q = 2\pi k\) in Å⁻¹, so their \(\sin(Qr)\) is our \(\sin(2\pi k r)\). Same physics, shifted axis labels.

Start with Two atoms: one pair, one ripple; drag them apart and the ripple quickens. Switch to Crystal or Liquid: many pairs pile into peaks, and the bottom panel recovers the same peaks g(r) had, from waves alone. Lower k_max to see the price of a limited detector: fewer waves, blurrier and wigglier G(r).

Two kinds of atoms

One more honesty step before real data. Real materials rarely have a single atom type: WS2 has tungsten and sulfur, which means three kinds of pairs (W–W, W–S, S–S) and three partial g(r) curves. The question: which of them does the experiment actually see?

Each pair is weighted by the scattering power of its two atoms, \(w_{ij} \propto c_i c_j f_i f_j\). Heavy atoms shout, light atoms whisper:

Slide f(S) down and the S–S peak fades out of the measured curve while the atoms never move: the structure is unchanged, the measurement just stops seeing part of it. This is why light elements (H, Li, O, S) are hard next to heavy ones, why a measured PDF peak can be a blend of two pair types, and why neutron PDF (which weighs elements differently) is the classic complement to X-rays.

From a real pattern to g(r)

The question changes one last time: a real detector does not hand you S(k). It hands you intensity

\[I(k) = N f(k)^2 S(k) + \text{background}\]

where the arrangement’s ripples ride on a big smooth decaying hill: the single-atom scattering f(k)² plus incoherent background. The incoherent part is scattering that changed frequency on the way out (inelastic); waves of a different rhythm cannot hold a fixed phase against their neighbors, so they carry no fringes and no pair information, only smooth glow. That is why it belongs to B(k) and can be fitted away without losing structure. The job is to strip the hill without damaging the ripples. The recipe (the one implemented in quantem’s PairDistributionFunction):

  1. Fit a smooth curve B(k) through the measured I(k) over a chosen range [k_min, k_max]

  2. Take the single-atom part as f² ≈ B − c and expose the structure: \(S(k) = 1 + [I(k) - B(k)] / f^2\)

  3. Sine-transform \(F(k) = 2\pi k [S(k) - 1]\) to get G(r)

Below, the “measured” pattern is synthetic, built from a liquid you know, so the truth is available for comparison. Your only job is the step that makes or breaks everything in real work: choosing the background fit range.

How to read the result, and how it fails:

  • The first honest peak of G(r) is the nearest-neighbor bond length. And its size is not decoration: integrating \(4\pi r^2 \rho_0\, g(r)\) across the first peak counts the neighbors in the first shell (the coordination number, ~4 for amorphous Si, ~12 for a metallic glass). Everything below the first peak should be near zero; peaks there are artifacts, not atoms.

  • Slide k_min up or k_max down and watch the damage flow: a background fitted over the wrong range tilts S(k) away from 1, and the transform converts that slow tilt into large fake structure at low r.

  • Push k_max to 3 and the noise-amplified tail of S(k) (where f² is tiny, so [I − B]/f² divides by almost nothing) pours grass into G(r). Real pipelines add a taper window (Lorch) here.

  • The same math serves X-rays and electrons; only the single-atom factor f(k) differs. In quantem this recipe runs per scan position on 4D-STEM data, with a two-term background and a batched fitter.