A live, interactive lesson in the two things that matter most in powder diffraction: how a crystal structure turns into an XRD pattern, and how that pattern is refined back into structural parameters. Nothing here is pre-rendered — the lattice, the diffraction peaks and the refinement statistics are recomputed in your browser as you move the sliders, so you can watch every parameter act on the result.
The frame above is the real thing, not a recording. Switch between the two modes with the tabs, drag the 3D lattice to rotate it, and hover a diffraction peak to read off the Miller index that produced it.
| Feature | What you can do with it |
|---|---|
| Crystal structures | Simple cubic, body-centred cubic and face-centred cubic, rendered live in 3D |
| Instrument parameters | Lattice parameter a (2.0–8.0 Å), wavelength λ (0.1–2.5 Å), peak width (FWHM) |
| Live XRD pattern | Peaks computed from Bragg’s law, with multiplicities, the Lorentz–polarization factor and the structure factor |
| Miller indices | Hover any peak to read off the (hkl) that produced it |
| Refinement | Import a simulated pattern, choose a structural model, refine manually or automatically |
| Optimisers | Hill climbing, simulated annealing and gradient descent — three genuinely different search strategies |
| Statistics | Rwp, Rp and χ² update live while the refinement runs |
| Interface | Chinese and English, switchable at any time |
The left panel holds the parameters; the centre holds the answer. Pick a structure and the 3D lattice redraws immediately. Change a and the peaks slide; change λ and everything moves to higher or lower angles.
This mode takes the pattern you just produced, corrupts it the way a real measurement would be corrupted, and asks how you would get the answer back.
Bragg law: nλ = 2d sinθ
n diffraction order (integer)
λ X-ray wavelength (Å)
d spacing of the reflecting planes
θ Bragg angle
Plane spacing: d = a / √(h² + k² + l²)
The extinction rules follow directly from the structure factor:
Peak intensities account for multiplicity, the Lorentz–polarization factor and the structure factor. Noise is added as a slowly varying background plus Poisson counting statistics, so the refinement is exercised on realistic data rather than on a clean synthetic curve.
Vue.js 2.6, Three.js and Plotly.js are loaded from a CDN; all physical calculations and the optimisation algorithms run in the browser. The 3D view keeps its aspect ratio in step with the frame, so the demo stays legible whether it is opened full size or embedded in this page.
Materials science courses, XRD training, undergraduate crystallography, and self-study of refinement methods. A natural sequence is to work through mode 1 first, then use mode 2 to compare the three algorithms and build intuition about how they behave.