Open Access Article
Nofit Segal
a,
Akshay Subramanian
a,
Mingda Li
b,
Benjamin Kurt Miller
c and
Rafael Gómez-Bombarelli
*a
aDepartment of Materials Science and Engineering, MIT, Cambridge, MA, USA. E-mail: rafagb@mit.edu
bDepartment of Nuclear Science and Engineering, MIT, Cambridge, MA, USA
cFAIR, Meta, San Francisco, USA
First published on 10th April 2026
Solving crystal structures from powder X-ray diffraction (XRD) is a critical inverse problem in materials characterization. This work studies the mapping from diffractogram to crystal structure using gradient-based optimization of the structure with XRD similarity as the objective, and evaluates the retrieval of ground-truth geometries from moderately distorted structures. We find that commonly used XRD similarity metrics result in an ill-posed, highly non-convex loss landscape where high signal agreement does not necessarily imply structural accuracy, a phenomenon driven by spurious peak overlaps. Constraining the optimization to the ground-truth crystal family significantly improves retrieval, and yields higher correlation between structural similarity and XRD similarity. Nevertheless, the landscape may remain non-convex along certain symmetry axes. Finally, we contrast this with the interatomic potential energy landscape, which exhibits smooth, locally convex behavior for identical structural perturbations.
Experimental phenomena such as preferred orientation, peak overlap, crystal twinning, and instrumental noise further complicate structural determination from powder XRD patterns.9–11 Furthermore, the formation of phase mixtures further complicates interpretation, as diffraction peaks from multiple phases become superimposed.4,12
From a computational perspective, structural ambiguity remains even under idealized experimental conditions. Distinct compositions can exhibit highly correlated XRD patterns when they share similar crystal symmetry and lattice parameters, a behavior that is common in both minerals and metallic alloys. This frequently occurs in solid solutions, where the same atomic species occupy crystallographic sites but with slightly different stoichiometric ratios, leading to only minor lattice perturbations and nearly indistinguishable diffraction patterns across a composition range.4,13–18 A related but distinct source of ambiguity arises in isomorphous compounds, in which one atomic species is fully substituted by another—typically of similar valence and ionic radius—while preserving the same crystal structure and lattice geometry.17,18 In both cases, different compositions map to highly similar diffraction signatures, rendering the XRD-to-structure mapping inherently one-to-many.
Moreover, even when the atomic composition is fixed, a material may crystallize into different phases with related but distinct symmetries. Such polymorphs can be described by different space groups yet still produce strongly correlated diffraction patterns, further complicating structural inference.2,9
Notably, small distortions in lattice parameters or displacements of atomic coordinates do not induce uniformly smooth changes in the diffraction signal. While some distortions lead to gradual shifts in peak positions or intensities, others can trigger discontinuous changes, such as peak splitting, appearance, or disappearance, through abrupt changes in Bragg conditions.4 This introduces a non-smooth relationship between structure and XRD signal.
Recently, there has been a surge of interest in crystal structure determination from XRD patterns using generative modeling.19–25 A growing body of work applies gradient-based optimization approaches that leverage differentiable physics to refine generated or otherwise-obtained crystal structures by minimizing the difference between simulated and target XRD patterns. For example, Riesel et al.20 generate crystals conditioned on a given XRD pattern and post-process them using a differentiable XRD simulator to update lattice parameters via gradient descent (GD). Parackal et al.26 systematically enumerate candidate crystals given composition and space group inputs, and restricts the GD optimization to atomic positions along Wyckoff degrees of freedom. Lee et al.27 create candidate crystals using an evolutionary algorithm, followed by crystals morphing by maximizing the cosine similarity between the XRD patterns. Outside the powder diffraction setting, GD has further been applied to determine lattice parameters from single-crystal diffraction patterns.28
As gradient-based refinement relies on comparing simulated and target diffraction patterns, recent work has also focused on developing more robust XRD-similarity metrics. Otero-de-la Roza29 introduced a cross-correlation-based metric that captures equivalence between diffraction patterns while remaining invariant to lattice distortions. Building on this work, Racioppi et al.30 applied the metric to crystal structure prediction from XRD data, jointly optimizing the structure by minimizing both this similarity metric and the structure's enthalpy. Hernández-Rivera et al.31 systematically analyzed the sensitivity of different families of similarity metrics under isotropic lattice strain. Li et al.32 proposed an entropy-based similarity measure for spectra and demonstrated its utility for molecular database retrieval from mass spectrometry data.
In this work, we explore the powder XRD-to-structure mapping through the lens of GD optimization. The task is to recover correct structures from moderately deviated ones based solely on XRD similarity. This work investigates whether the XRD landscape is locally smooth enough for GD to guide back to the correct configuration.
Inspired by experimentally observed symmetry-breaking effects such as thermal expansion from lattice vibrations and thermal fluctuations, we introduce two types of distortions: random lattice distortions and uncorrelated atomic displacements.8,33–35 These distortions resemble crystal structures predicted by generative models, which often produce nearly correct geometries but with imperfect symmetry.36–38 Through this study, we examine the challenge of “the last mile” in structure elucidation from XRD.
We find that mapping XRD patterns to crystal structures is challenging because high diffraction agreement, as currently measured in literature, does not ensure geometrical accuracy. We show that commonly used XRD similarity measures, such as cosine similarity, mean squared error (MSE), entropy similarity, and cross-correlation, are sensitive to both lattice and coordinate noise distortions, and optimization between distorted structures and ground-truth XRD diffraction can become trapped in local minima.
Fig. 1 illustrates match rates obtained through crystal structure optimization w.r.t XRD similarity metrics. For lattice distortions, the largest drop in match rate occurs between noise levels of 0.05 and 0.1. Although 0.1 corresponds to the lattice tolerance used by the structure matching criterion (see Section 4), the noise level controls the maximum applied strain, such that lattice parameters typically remain within the matching tolerance. Using different similarity objectives makes little to no difference in performance.
![]() | ||
| Fig. 1 Results of XRD-based optimization under two types of noise. Crystal structures were optimized with respect to XRD similarity metrics using the snap method,20 which struggles to recover the correct structure under both lattice and coordinate perturbations. The plots show match rates computed with StructureMatcher (ltol = 0.1, stol = 0.2, angle_tol = 5°) under random lattice (a) and coordinate (b) perturbations. Error bars represent 95% Jeffreys binomial credible intervals.39 For lattice distortions, incorporating lattice constraints significantly improves robustness, even at high noise levels. | ||
Fig. 2 shows distortions of the lattice parameters a and c of U2Ti, a hexagonal structure with space group P6/mmm (no. 191). The heatmap color indicates the cosine similarity loss between the XRD spectra of the distorted structures and the ground truth. The resulting contour map reveals multiple deep local minima, indicating the optimizer's potential to get trapped in suboptimal solutions. The three most prominent local minima are highlighted, and their corresponding XRD patterns are shown in the right panel. Despite their structural deviation from the true lattice parameters, the patterns show high cosine similarity to the ground truth due to subtle shifts and peak splittings that preserve the overall spectral profile.
Fig. 3 provides two illustrative examples demonstrating how symmetry constraints can facilitate correct structure reconstruction. In these cases, only a two-dimensional slice of the optimization landscape is visualized for clarity. This is a simplification of the full optimization process, which, for the distorted lattice case, occurs in a six-dimensional space. We show simulated GD trajectories for two representative structures under three settings: (i) unconstrained GD, (ii) unconstrained GD initialized at a constrained point, and (iii) fully constrained GD.
In Fig. 3a, we perturb the lattice parameters a and α of Au2S, a cubic structure with space group Pn
m (no. 224). The unconstrained GD trajectory converges to a distant local minimum, whereas unconstrained GD with constrained initialization at a = b reaches a nearby local minimum. By contrast, the fully constrained GD trajectory successfully recovers the ground truth.
Fig. 3b shows distortions of the lattice parameters a and γ of Na3MnCoNiO6, a monoclinic structure with space group Cm (no. 8). Similarly, the unconstrained GD trajectory, even when initialized at a constrained point with γ = 90°, converges to a local minimum, while the constrained GD trajectory, which enforces γ = 90° throughout optimization, reaches the ground truth.
The initialization points for both cases were chosen for illustration, though points for multiple regions would yield similar behavior. These visualizations illustrate how symmetry-constrained XRD-based optimization can better reach the correct phase, yielding higher match rates than its unconstrained counterpart (Fig. 1). This highlights the value of incorporating symmetry constraints into learning schemes that navigate the structure-to-XRD mapping.
Notably, in Fig. S2, we observe roughness that poses challenges for symmetry-constrained GD along symmetry axes such as a = b and α = 90°. While fluctuations along a = b are pronounced, those along α = 90° are comparatively shallow and may be mitigated through techniques such as momentum40 or regularization, which were not studied in this work. Although symmetry constraints generally improve refinement performance, the landscape visualized here highlights that XRD-based GD may remain sensitive to initialization and prone to local minima in some cases.
In this work, we use an idealized simulated XRD representation (see SI Section 4.7) to isolate the intrinsic properties of the XRD similarity landscape without additional experimental noise. In practice, counting noise in measured diffraction intensities would introduce fluctuations in the similarity metric, further increasing landscape roughness and degrading gradient quality during optimization.
Correspondence between higher XRD similarity and lower AMD would indicate that diffraction-space similarity aligns with crystal structure similarity. MI captures overall statistical dependence between the two quantities, while Pearson and Spearman correlations describe linear and monotonic relationships, respectively.
As shown in Table 1, the relationship between geometrical and diffraction-based similarity is not uniform across metrics or noise levels. For lattice distortions, cosine similarity yields the highest MI at lowest noise, whereas entropy similarity performs better at moderate noise levels. At higher noise levels, all metrics exhibit similarly low MI, indicating a loss of geometrical correspondence. For coordinate distortions, cosine similarity yields the highest MI at low noise, cross-correlation performs better at moderate noise levels, and entropy performs better at the highest noise level. In contrast, when symmetry constraints are enforced during optimization, MI increases substantially across all lattice noise levels, underscoring the benefit of restricting the search space to symmetry-consistent configurations.
| Noise type | Noise level | Cosine | MSE | Entropy | Cross corr. | Cosine + constr. |
|---|---|---|---|---|---|---|
| Lattice | 0.01 | 1.09 | 0.25 | 0.76 | 0.22 | 1.40 |
| 0.05 | 0.12 | 0.16 | 0.53 | 0.08 | 1.55 | |
| 0.10 | 0.09 | 0.06 | 0.21 | 0.07 | 1.12 | |
| 0.15 | 0.03 | 0.02 | 0.02 | 0.0 | 0.90 | |
| 0.20 | 0.07 | 0.02 | 0.01 | 0.03 | 0.85 | |
| Coords | 0.001 | 1.05 | 0.32 | 0.68 | 1.02 | — |
| 0.005 | 0.83 | 0.48 | 0.53 | 0.82 | — | |
| 0.010 | 0.44 | 0.67 | 0.56 | 1.01 | — | |
| 0.050 | 0.96 | 0.36 | 1.41 | 1.81 | — | |
| 0.100 | 0.77 | 0.32 | 1.06 | 1.00 | — |
The correlation results reported in Tables S1 and S2 exhibit similar trends. For lattice distortions, no single XRD similarity metric consistently correlates with AMD in the unconstrained setting, whereas enforcing symmetry constraints improves both Pearson and Spearman correlations.
For coordinate distortions, cosine and entropy similarity metrics show negative correlations with AMD, while the MSE-based metric yields a positive and relatively high Spearman correlation. This behavior can be attributed to the fact that MSE more strongly penalizes differences in peak intensities. Since low-level coordinate noise mainly affects peak heights through modifications to the structure factors rather than shifting peak positions, MSE captures these subtle symmetry perturbations more effectively.
Fig. 4 visualizes these relationships. MSE exhibits the weakest correlation with AMD (low Pearson and Spearman coefficients), while cosine and entropy similarities show comparable correlations. Entropy similarity achieves slightly higher MI (0.20 vs. 0.09 for cosine), indicating a modestly stronger dependence between diffraction and geometric similarity under these conditions. Nevertheless, the data remain broadly scattered, revealing that all tested similarity metrics struggle to consistently distinguish geometrically distinct configurations. When symmetry constraints are enforced (Fig. 4d), the correspondence between AMD and cosine similarity improves substantially, both in MI (1.12) and correlation coefficients.
![]() | ||
| Fig. 4 Average minimum distance (AMD) vs. XRD similarity metrics. (a) Mean squared error (MSE). (b) Entropy similarity. (c) Cross correlation. (d) Cosine similarity. (e) Cosine similarity with lattice constraints applied during optimization. All panels compare structures obtained from XRD-based optimization following lattice distortions of 0.1. Entropy similarity yields higher mutual information (MI) than cosine similarity or MSE at this noise level, though this trend does not generalize across all settings (Table 1). Applying lattice constraints improves MI as well as linear and Spearman correlations. | ||
, thereby contributing to the similarity score. This discrepancy in interatomic distances seems to remain within the tolerance.
In Fig. S4, the unconstrained GD optimizer converges to a distinct structure whose peaks overlap with those of the ground truth, achieving a deceptively high cosine similarity (0.71). In contrast, the symmetry-constrained optimization successfully recovers a matched structure, but the resulting diffraction pattern shows slightly shifted peaks, leading to a much lower cosine similarity (0.05). The convergence to this shallow minimum is likely driven by roughness along the symmetry axis, as elaborated in Subsection 2.1.
This counterintuitive outcome highlights a key limitation of using XRD pattern similarity metrics such as cosine similarity, MSE, and entropy similarity as the sole reconstruction objective: similar structures can yield dissimilar patterns, and conversely, distinct structures may appear similar, under such metrics. Because these metrics are insensitive to whether aligned peaks arise from the same atomic geometry, distinct structures can yield high similarity scores, while small geometric deviations can produce low ones. This results in a highly non-convex optimization landscape prone to spurious minima.
This limitation suggests that purely signal-based metrics are unlikely to yield a well-behaved (e.g., convex) optimization landscape. In the absence of smoother metrics, enforcing symmetry-based constraints (see Section 4.4) on the optimizer remains an effective way to navigate otherwise rugged landscapes.
![]() | ||
| Fig. 6 Comparing XRD-based optimization with energy relaxation. (Top) Match rates from StructureMatcher with (ltol = 0.1, stol = 0.2, angle_tol = 5°) under random lattice and coordinate distortions. Snapped bars are the same as presented in Fig. 1. Energy-based optimization consistently recovers the correct phase, except for high levels of coordinate noise, whereas XRD-based optimization struggles. (Bottom) 2D landscape of CHGNet42 predicted energy as a function of lattice parameters of U2Ti. Along lattice vectors, the energy landscape is smooth and locally convex. | ||
These results highlight an important contrast between energy relaxation and XRD-based optimization. Potential-energy landscapes are typically smooth because they arise from local interatomic interactions that vary continuously with atomic positions. Consequently, small perturbations in atomic coordinates generally lead to correspondingly small and continuous changes in the energy.
Cross-sections of the energy optimization landscape are shown in Fig. 6b and S5, which exhibit a smooth and largely convex behavior around the ground-truth structure. This contrast with the highly rugged landscape observed for XRD similarity helps explain why gradient-based relaxation methods are effective for energy minimization but often struggle when applied directly to diffraction-based objectives.
Energy relaxation and XRD-based optimization provide complementary signals: relaxation drives structures toward physically stable configurations, while XRD-based optimization attempts to match an observed pattern. Possible directions for future work can therefore include multi-objective optimization, which can combine the smoothness of the energy landscape with the structure-specific information captured by diffraction.
While XRD provides a direct experimental link for generative modeling and the identification of novel phases—a topic of surging interest—current models often produce “near-miss” structures that require further refinement. Our results demonstrate why post hoc optimization based solely on XRD similarity is often insufficient for this “last mile” of refinement. While generative models may introduce more complex biases than the physically motivated distortions studied here, our results characterize a loss landscape that is more rugged than the corresponding potential energy surface.
These observations suggest that progress in inverse XRD may be better achieved through generative architectures that condition on XRD patterns while embedding symmetry-aware inductive biases. In this framework, generative models could provide a robust initialization within the correct structural basin, with final precision guided by the smoother gradients of energy relaxation.
m, I
, Cm, I4/mmm, Fm
m, C2/m, P63/mmc, Pm
m, Pm.
The selected structures also span a range of unit-cell sizes and numbers of atoms while remaining small enough to enable controlled optimization experiments.
For each structure, we generated 50 distorted versions of the conventional cell using two noise models.
be the ground-truth lattice matrix (columns are the lattice vectors). The lattice is distorted by a random deformation matrix
,Thus, diagonal entries produce uniaxial expansion/compression, whereas off-diagonal entries induce shear. By construction, these distortions do not preserve crystal symmetry and can introduce diverse deformation modes. If f denotes a fractional coordinate, then the Cartesian position changes from x = Lf to
=
f with f unchanged.
| xf(n) = w(xi(n) + εn), w(u) = u − ⌊u⌋∈[0,1)3, |
.
Either the lattice parameters or atomic coordinates are refined, in accordance with the noise applied. The structure is passed through a differentiable diffraction pipeline to produce a simulated pattern, which is then compared to the ground-truth pattern using a chosen loss function. Given distorted-structure XRD
and ground-truth XRD x (see SI Section 4.7 for details on XRD calculation), one of the following objective functions is minimized. These include point-wise losses, namely negative cosine similarity, mean squared error (MSE), and negative entropy similarity,32 as well as cross-correlation, which enables shift-based comparison:
. Gradients of the loss are backpropagated to update the parameters using PyTorch's autograd.
Using projected optimization,58 each gradient step is followed by projection onto the constrained values.
Let θ = (a, b, c, α, β, γ) be the lattice parameters. Simple constrained gradient descent on a proposed crystal
using user-selected loss
and symmetry projection operator
would be:
is the representation of our proposed crystal structure, which depends on current lattice parameters θk; xrd is a map from crystal to computed powder X-ray diffraction pattern; xrd0 is the XRD pattern of the reference we aim to recover. The projection operator
is defined by relevant crystal family, e.g.,Thus, a, b, and c are first updated independently according to their gradients, then set to the mean value ā, while angles are fixed to 90°. Similar projectors are defined for the remaining crystal families (see SI Section 4.8 for projector definitions).
Supplementary information is available. See DOI: https://doi.org/10.1039/d6dd00017g
| This journal is © The Royal Society of Chemistry 2026 |