XtalPaint borrows image inpainting to find missing crystal atoms
Researchers at Switzerland's Paul Scherrer Institute just built XtalPaint, an open-source model that reconstructs missing atoms in crystal lattices with a 97% success rate. Adapted from Microsoft's MatterGen, it treats crystal gaps like erased parts of an image, applying diffusion noise only to unknown spots while using known atoms as anchors. Why it matters: X-rays often miss light elements like hydrogen, locking thousands of promising compounds out of computer simulations; this tool could unlock them for battery and clean-energy research.

XtalPaint is an open-source AI model designed to solve one of the most frustrating bottlenecks in materials science: putting missing atoms back into incomplete crystal structures.
To run computer simulations for material properties like thermal and electrical conductivity, researchers need exact 3D coordinates for every single atom. The trouble is, standard X-ray diffraction barely registers ultralight elements like hydrogen. As a result, thousands of promising materials in public databases sit completely unusable simply because their hydrogen positions were never recorded.
A research team at Switzerland's Paul Scherrer Institute (PSI), led by Giovanni Pizzi alongside Italian collaborators, built XtalPaint to fill those exact blanks.
Borrowing inpainting from computer vision
The breakthrough comes down to borrowing a well-known trick from image generation: selective inpainting. When an AI tool restores a damaged photo, it doesn't scrap the entire image. It adds diffusion noise only to the missing patch and uses the surrounding pixels as visual clues.
Most existing crystal models, by contrast, cover the entire lattice in noise and attempt to rebuild the whole structure from scratch. That approach burns heavy compute and often distorts perfectly good atomic coordinates.
XtalPaint, adapted from Microsoft's MatterGen, leaves the known atomic framework intact. It injects diffusion noise strictly into the empty spots where atoms are suspected missing, using the rest of the crystal lattice as an unmoving anchor throughout the step-by-step reconstruction.
A 97% hit rate on missing atoms
To test the tool, the researchers took known crystal structures, stripped out their hydrogen coordinates, and tasked XtalPaint with putting them back.
The model hit the bullseye. In 87% of tests, it recovered the exact original positions. In another 10% of cases, it actually generated atomic arrangements that were energetically more stable than the real-world lab records. That pushed its overall success rate to 97%.
Beyond hydrogen, the team confirmed the same inpainting technique works for other light elements crucial to battery design, like lithium and sodium. It has even helped spot clerical errors in scientific databases where coordinates were copied incorrectly from original papers.
The work is published in npj Computational Materials and released as an open-source tool.
Why it matters
If you work in computational materials, solid-state batteries, or hydrogen storage, XtalPaint is an immediate quality-of-life upgrade. It unlocks thousands of real-world materials that were previously sidelined from simulations, turning incomplete historical records into actionable digital candidates without requiring expensive lab re-testing.
What makes XtalPaint particularly smart is its restraint. Instead of trying to build an oversized model that generates entire materials from a blank canvas, it adapts a mature computer-vision technique to solve a precise data-cleaning problem. By anchoring the generation to known physical coordinates, it slashes compute costs while virtually eliminating hallucination risks.
Sources (1)
- scitechdaily.com(opens in a new tab)Originalscitechdaily.com