Crystal growth and grain boundaries with the phase-field crystal model
Plant a seed in a supercooled liquid and watch a crystal of atoms grow, meet its neighbours and leave grain boundaries behind. One smooth field, one equation, running live in the browser.
- Published
- 16 November 2026
- Run
- In the browser
- Model
- Phase-field crystal (Elder & Grant)
- Stack
- Rust, webassembly, webgl
- Download
- 250 KB
Most metals are not one crystal but many. Polish and etch a piece of steel and look at it under a microscope and it breaks up into patches, grains, each a crystal with its rows of atoms running a different way. The seams between them, grain boundaries, decide a good deal of how the metal behaves: how strong it is, how it corrodes, how it creeps when hot.
Grains form as a melt solidifies. Crystals start at many points at once, each with its own orientation, and grow until they run into each other. Simulating that is awkward. Molecular dynamics follows every atom, but its time step is a femtosecond, so watching a crystal grow takes far too long. Classical phase-field models are fast, but they treat the solid as a smooth blob with no atoms in it, so there are no rows and no grain boundaries to see.
The phase-field crystal model, introduced by Elder and colleagues in 2002, sits in between. The app described here, crystal, runs it live in the browser. Open it, click the liquid, and watch.
One field instead of many atoms
The model does not track atoms. It tracks one smooth quantity, ψ, the density of material at each point, averaged over the fast vibrations of the atoms. In a liquid ψ is flat. In a crystal it piles up into regular peaks, and each peak is an atom. Everything follows from one equation:
The outer ∇² means material only moves from place to place; it is never made or destroyed. The (1 + ∇²)² term rewards ripples of one particular wavelength, and that wavelength becomes the spacing between atoms. The ψ³ term stops the peaks growing without limit. In two dimensions the pattern that wins is a hexagonal lattice, so each peak sits among six neighbours.
The payoff is time scale. Because ψ is averaged over vibrations, a step can be thousands of times longer than in molecular dynamics, and crystals grow, meet and settle in seconds on screen. The model keeps what matters for grains: elasticity, dislocations and grain boundaries all come out of it, without being put in.
Two numbers set the scene
The model has two parameters, and the app shows them as Temperature and Amount of material. Temperature is r: the more negative, the colder, and the stronger the pull towards a crystal. Amount of material is the average density ψ̄. Between them they decide whether the box wants to be liquid, crystal, or a mix of the two.
Because material is conserved, a crystal can only grow by drawing material out of the liquid around it. A crystal is denser than the liquid, so as it grows the liquid nearby thins, and a lone crystal slows and stops once there is no spare material left. That is why, at the starting settings, grains grow to a fixed size with liquid left between them, and why nudging the amount of material up makes them press together. Push further, past the point where |ψ̄| falls below √(−r/3), and the liquid becomes unstable: it crystallises everywhere at once with no seed needed. The Flash freeze scene does exactly that.
Seeds, tilt and grain boundaries
A click stamps a small patch of perfect hexagonal crystal into the liquid, turned by a random angle. The cold liquid beside it copies the pattern, so the whole crystal keeps that angle as it grows. A hexagon looks the same after a sixth of a turn, so angles run from 0 to 60°.
When two crystals with different angles meet, their rows cannot join up. The seam is a grain boundary, and along it are atoms with five or seven neighbours instead of six: the cores of dislocations. The app finds them by locating every atom, a peak in ψ, and measuring the directions to its neighbours. Averaging those directions the hexagonal way (the bond-orientational order of Steinhardt, Nelson and Ronchetti) gives each atom an angle, and counting neighbours picks out the misfits, which glow.
Seeing the grains
In a flat picture every grain looks the same, a field of dots. Two things make them stand apart. The view is drawn in 3D, with ψ as height, so each atom is a lit bump on a surface, much as a scanning tunnelling microscope shows a real crystal face. And each grain responds to light according to its angle. In the default sheen mode a grain glints when its rows line up with the light, the way grains flash when a piece of galvanised steel is turned in the sun; turning the view turns the light with it. A rainbow mode gives each angle its own colour instead.
A grain’s angle can still drift. Small grains squeezed between large ones slowly rotate to fit them better, which real grains do too.
Solved in Fourier space
The box wraps round at its edges, which suits a Fourier method. Each step transforms ψ, where every ∇² becomes a multiplication, updates it, and transforms back. The stiff linear part is treated implicitly, so the step can be large, with part of the cubic term moved across to keep it stable at deep undercooling. One step on a 256 × 256 grid takes a few milliseconds in WebAssembly, so several fit in each frame.
The engine is tested for the things that would show a mistake: the average density must stay fixed to ten decimal places over thousands of steps; a single seed must grow into one grain whose measured angle matches the seed’s to within a few degrees.
Small enough to just open
The engine is about 300 lines of Rust compiled to WebAssembly, and the app is a quarter of a megabyte. It is written from the published equations; it shares no code with the research codes listed below.
Try it
Open crystal. Start with One crystal, then Many grains and Close up, and drag to turn the light across the grains. How it works, on the page, has the details.
Further reading
- K. R. Elder, M. Katakowski, M. Haataja and M. Grant, Modeling elasticity in crystal growth, Physical Review Letters 88 (2002) 245701. The model introduced.
- K. R. Elder and M. Grant, Modeling elastic and plastic deformations in nonequilibrium processing using phase field crystals, Physical Review E 70 (2004) 051605. The model in full, with its phase diagram.
- H. Emmerich et al., Phase-field-crystal models for condensed matter dynamics on atomic length and diffusive time scales: an overview, Advances in Physics 61 (2012). A review of the field.
- N. Provatas and K. Elder, Phase-Field Methods in Materials Science and Engineering, Wiley-VCH (2010). The textbook.
- P. J. Steinhardt, D. R. Nelson and M. Ronchetti, Bond-orientational order in liquids and glasses, Physical Review B 28 (1983). The measure used for each atom’s angle.
- H. Hallberg et al., pyPFC, Modelling and Simulation in Materials Science and Engineering (2025), and T. Pinomaa et al., OpenPFC, Modelling and Simulation in Materials Science and Engineering (2024). Two recent open-source phase-field crystal codes, in Python and in C++ for supercomputers.