Powder diffraction crystal structure determination using generative models

Domain: earth_science
Published: 2025-08-11
Editorial outcome: major_revision

Abstract
Accurate crystal structure determination is critical across all scientific disciplines involving crystalline materials. However, solving and refining crystal structures from powder X-ray diffraction (PXRD) data is traditionally a labor-intensive process that demands substantial expertise. Here we introduce PXRDGen, an end-to-end neural network that determines crystal structures by learning joint structural distributions from experimentally stable crystals and their PXRD, producing atomically accurate structures refined through PXRD data. PXRDGen integrates a pre-trained XRD encoder, a diffusion/flow-based structure generator, and a Rietveld refinement module, solving structures with unparalleled accuracy in seconds. Evaluation on MP-20 dataset reveals a record high matching rate of 82% (1-sample) and 96% (20-samples) for valid compounds, with Root Mean Square Error (RMSE) approaching the precision limits of Rietveld refinement. PXRDGen effectively tackles key challenges in PXRD, such as the resolution of overlapping peaks, localization of light atoms, and differentiation of neighboring elements.

Introduction
Crystal structures provide critical insights into the properties and behaviors of materials1. The accurate determination of crystal structures is therefore a cornerstone of many scientific fields, including materials science, chemistry, physics, and geology, driving advancements from drug design to the development of new electronic devices2. While single-crystal X-ray diffraction (SCXRD) is the state-of-the-art method for crystal structure determination, many materials are only available in powder form3, making powder X-ray diffraction (PXRD) a more widely used technique for characterizing metals, minerals, catalysts and ceramics due to its cost-effectiveness and broad applicability4. In spite of its benefits, solving and refining unknown crystal structures from PXRD data is notoriously challenging5. For instance, over 476,000 entries in the Powder Diffraction File (PDF)6 have some unresolved coordinates of atoms, highlighting the need for improved methodologies.

In a diffraction pattern, the positions and relative intensities of the diffraction peaks depend on the lattice parameters and the distribution of individual atoms in the unit cell, respectively. PXRD can accurately determine the unit cell, but the overlap of peaks with adjacent diffraction angles causes ambiguous relative intensities, hindering the determination of unknown crystal structures. Consequently, sophisticated technologies like free electron lasers7, powder electron diffraction8, and maximum entropy algorithms9 have been proposed to separate overlapped intensities. Various global optimization algorithms based on direct space approaches, such as simulated annealing, genetic algorithms and particle swarm optimization, have been used to deduce the atomic positions10,11. However, these methods often require the knowledge of space group and structural units to infer the free parameters as much as possible. High-throughput DFT search frameworks like FPASS12 and AXS13 have been proposed to avoid coarse and faulty candidate structures, but they are computationally intensive and validated on a limited number of datasets with known space groups. Final Rietveld refinements14 also demand significant human participation and intuition, relying on good initial values for the target structure. Despite significant advancements, structure determination from PXRD remains labor-intensive, time-consuming, and requires high expertise.

Recent advances in artificial intelligence (AI) have opened promising avenues for overcoming the longstanding challenges in powder X-ray diffraction (PXRD) analysis15. AI techniques have shown promise in predicting key crystallographic features such as space group symmetry16–19, phase20–22, and cell parameters23,24 directly from PXRD patterns. Deep learning models, in particular, have shown great promise in crystal structure prediction (CSP), which aims to derive the three-dimensional structure of crystals based solely on their chemical composition25–27. However, structures generated through CSP often exhibit randomness, limited accuracy, and crucially a lack of experimental validation. Incorporating experimental data, such as PXRD, into CSP through multimodal learning28 offers a path to overcome these limitations. By allowing PXRD features to guide structure generation while simultaneously serving as a benchmark for validation, AI-driven models could achieve both high accuracy and experimental fidelity, creating an end-to-end pipeline for crystal structure determination. In the past year, a few concurrent studies have leveraged graph neural networks and generative models to enable end-to-end crystal structure determination from powder X-ray diffraction data29–31. For instance, CrystalNet29 uses a variational query-based multi-branch deep neural network to predict modified charge density for cubic and trigonal crystal systems. XtalNet30 leverages the power of contrastive learning and diffusion models to solve the structure of complex MOF materials. On the other hand, PXRDnet31 firstly demonstrates the ability to determine crystal structures from powdered crystalline samples in nanoscale regimes (down to 10Å). While these advances represent important steps forward, we note that opportunities for improvement remain, particularly in achieving atomic-level accuracy, enhancing match rates, and extending robust structure determination capabilities across common categories of crystalline materials.

In this work, we present PXRDGen, an advanced end-to-end neural network developed to significantly enhance crystal structure determination from PXRD data. PXRDGen learns structural distributions from experimentally stable crystals and their corresponding PXRD patterns, producing atomically accurate structures refined through PXRD data. The network consists of three key components: a pre-trained XRD encoder, a conditional structure generator based on diffusion or flow models. These components enable PXRDGen to resolve structures with remarkable accuracy in just seconds. In evaluations on the MP-20 inorganic dataset32, which comprises experimentally stable inorganic materials with 20 or fewer atoms per primitive cell, PXRDGen achieved a record high matching rate of 82% with a single generated sample and 96% with 20 samples for valid compounds. Additionally, for thousands of structures, the Root Mean Square Error (RMSE) calculated by PXRDGen is generally less than 0.01 (a dimensionless quantity; refer to the methods section for its precise definition). This indicates that the results obtained from PXRDGen closely align with the ground truth values. PXRDGen effectively addresses key challenges in XRD, such as locating light elements like hydrogen or lithium and distinguishing neighboring elements. These findings underscore PXRDGen’s potential to automate and significantly enhance the efficiency of structure determination from powder diffraction data.

Results
Overview of PXRDGen
Crystal structure determination from diffraction data typically involves three steps: (1) unit cell determination, (2) structure solution, and (3) structure refinement. In powder X-ray diffraction, unit cell parameters (L) can be accurately determined using indexing software, but solving and refining the fractional coordinates (F i) of crystal structure remains the most challenging step. PXRDGen addresses these challenges by automatically solving and refining crystal structures using generative models conditioned on both the chemical formula and PXRD data. As shown in Fig. 1, PXRDGen comprises three key modules: the pre-trained XRD encoder (PXE) module in purple, the crystal structure generation (CSG) module in orange, and the Rietveld refinement (RR) module in green. These modules work together to create the PXRD structure determination neural network capable of generating atomically accurate structures refined by Rietveld methods.

PXRDGen utilizes highly flexible neural networks to optimize its performance. The PXE module employs contrastive learning to align the latent space of PXRD patterns with crystal structures, providing crucial information for generating conditional L and F i. In addition, two distinct XRD encoders are designed to extract diffraction features: one is based on a convolutional neural network (CNN)33 and the other leverages Transformer (T) architecture34.

The CSG module generates crystal structures by conditioning on PXRD features and chemical formulas, using either diffusion35 or flow36 generative frameworks. The main framework and the diffusion model of PXRDGen are adapted from DiffCSP26 and the flow model is inspired by FlowMM27. The flow-based CSG module achieves state-of-the-art match rate and speed in solving stable crystal structures. In addition, PXRDGen allows L to be extracted independently from PXRD data through a Conditional Cell Generation network (CellNet) or conventional indexing, further enhancing the accuracy of F i. The structures generated by the CSG module are then automatically refined using Rietveld refinement within PXRDGen, ensuring optimal alignment between the predicted crystal structure and the PXRD data.

Pre-training for XRD encoder
Pre-training is a well-established method for enhancing multimodal learning capabilities. To align the latent space of PXRD patterns with crystal structures, the contrastive learning (CL) method28 has been applied. During the process of pre-training module, the InfoNCE loss is used as follows:

Loss = - \sum_{i=1}^{N} log \frac{e^{sim(P_i, C_i)/t}}{\sum_{j=1}^{N} e^{sim(P_i, C_j)/t}} = - \sum_{i=1}^{N} log \frac{e^{sim(C_i, P_i)/t}}{\sum_{j=1}^{N} e^{sim(C_i, P_j)/t}} : (1)

Here P_i and C_i refer to the extracted feature of PXRD and crystal structure in latent space, and sim(P_i, C_i) calculates the cosine similarity between them. Besides the hyper-parameters t is named as temperature coefficients, which is vital to the outcomes of pre-training.

The heatmap of similarity metrics of random 100 samples in test dataset of MP-20 based on Transformer and CNN are depicted in Supplementary Fig. 1. Figure 2a displays the top-k retrieval hit rate with the changing temperature coefficients, showing that the hit rate increases significantly with the decreasing temperature coefficients, especially for the XRDEncoder-T. From all these pre-training outcomes, it can be concluded that encoders based on Transformer perform better than CNN, and the top-10 hit rate reaches 92.42% in XRDEncoder-T (t=0.05), while that of XRDEncoder-CNN (t=0.05) is much lower, reaching 33.57%.

Optimized strategy in the CSG module
The CSG module in PXRDGen generates crystal structures based on information extracted from XRD encoders, making the design of both the PXRD encoder and the CSG module itself crucial to structure determination. As shown in Fig. 2c, the diffusion-based CSG network exhibits varying one-sample match rates depending on different XRD encoders. For the Transformer-based XRD encoder, fixing the pre-trained parameters (striped green columns) consistently improves performance. In contrast, for the CNN-based XRD encoder, unfixing the pre-trained parameters (blank orange columns) results in a significant performance boost compared to when the parameters are fixed (striped orange columns). Notably, although CNN-based XRD encoders perform poorly during contrastive learning, they consistently outperform Transformer-based encoders in the CSG module.

As a benchmark, directly replacing the XRD encoder with ground truth structures in the diffusion model achieved a one-sample match rate of 67.74% (Fig. 2b). The best CNN-based encoder closely approaches this benchmark with a one-sample match rate of 66.01%, indicating its effectiveness in extracting latent structural features from PXRD data. Additionally, due to the inherent randomness of the diffusion process, generating multiple candidate structures significantly increases the match rate. The match rates for all XRD encoders rise sharply as the number of candidates increases from 1 to 20. Meanwhile, the RMSE value tends to decrease with multiple generations, averaging around 0.05, demonstrating PXRDGen’s capability to produce highly precise crystal structures for experimentally stable compounds.

Flow-based generative models, which estimate probability distributions using Riemannian Flow Matching, offer notable advantages over diffusion-based CSG modules in terms of efficiency and speed for structure determination. In PXRDGen, we implement a flow-based CSG module to harness these benefits. Figure 2d illustrates the flow model’s response to various pre-training XRD encoders in structure generation, mirroring the performance of the diffusion model. Importantly, the match rate of the flow-based CSG module significantly outperforms that of the diffusion-based module, as depicted in Fig. 2e. The flow model combined with the CNN-XRD Encoder (flow-CNN) exhibits the best performance, achieving a one-sample match rate of 68.68% and a twenty-sample match rate of 85.37%, corresponding to 75.41% and 93.74% for valid compounds, respectively. In Fig. 2f, it’s shown that the flow-CNN model converges in just 50 generative steps—20 times faster than diffusion models—and reaches an RMSE of ~0.06 after only 200 steps, whereas the diffusion-CNN model requires 1000 steps to achieve comparable accuracy. Consequently, the average time to generate a structure is reduced to approximately 1s with the flow model—approximately four orders of magnitude faster than quantum mechanical computations and five times faster than diffusion models.

Better performance with given L in solving structures
In conventional CSP tasks, structures are predicted solely from composition, leaving lattice parameters undetermined and requiring joint generation with fractional coordinates. PXRD data allows for independent determination of L from peak positions (2θ), enabling L to be used as an additional condition when predicting F i. As mentioned above, the flow-CNN module excels in the joint generation of L and F i. When provided with the true L (Fig. 3b), which can be routinely obtained through indexing software, the flow-CNN module’s performance improves significantly: the one-sample match rate increases to 75.32%, and the twenty-sample match rate rises to 88.08%, corresponding to 82.70% and 96.71% for valid compounds, respectively. This means that a large portion of previously mismatched structures can be correctly resolved by providing the correct L. For instance, in Fig. 3c, the flow-CNN module initially failed to solve the structure of NaTiVS4, with L varying across different generation steps. However, when conditioned with the correct L, the module generated a matchable structure at the 1st generative step, and a highly accurate structure with RMSE below 0.02 is obtained at the 200th generative steps.

When L cannot be obtained through indexing software, PXRDGen employs CellNet, a neural network designed to extract L directly from PXRD patterns (Fig. 3a and Supplementary Fig. 2a). CellNet generates L within milliseconds, enabling the production of multiple samples (N) to improve cell parameter precision. As shown in Supplementary Table 4, CellNet achieves a Mean Absolute Percentage Error (MAPE) of approximately 1% with N=1000. Incorporating the optimal L into the CSG module significantly enhances performance (Fig. 3d). The orange line, representing the L with the lowest MAPE, surpasses the flow-CNN module at N=20 and approaches the ground truth at N=1000. Although CellNet generates L values that closely match the ground truth, selecting the best L based on diffraction peak positions remains challenging, as slight deviations in symmetry and extinction conditions can alter the number of diffraction peaks (Supplementary Fig. 2b), complicating the comparison between L and diffraction peaks. Dynamic Time Warping (DTW), effective for comparing sequences of different lengths, has been applied here to match L values. By using the FastDTW37 algorithm, CellNet can improves the flow-CNN module’s performance, achieving a one-sample match rate of 70.39% at N=1000.

Application of PXRDGen in solving challenging crystal structures
Having demonstrated that PXRDGen can solve crystal structures with unprecedented accuracy, we show that this AI-based approach offers a superior understanding of stable structures, surpassing the detection limits of traditional XRD techniques. While XRD is a powerful tool for determining crystal structures based on reconstructing electron clouds, it has notable limitations, particularly in locating light elements amidst heavier ones and distinguishing between elements with similar atomic numbers (Z). For example, detecting hydrogen with X-ray powder diffraction is highly challenging, as its single electron often makes it nearly invisible in XRD data—even in some cases with single-crystal diffraction. Accurately locating hydrogen and distinguishing neighboring elements in a crystal structure often requires more expensive and less accessible techniques, such as neutron diffraction. Furthermore, the significant peak overlap in PXRD adds an extra challenge for conventional structure determination methods.

The AI-based PXRDGen model addresses these challenges by leveraging its understanding of stable crystal structures beyond the resolution capabilities of conventional PXRD. For instance, in the case of Zr2Ni2H6 (Fig. 4a), conventional PXRD can reliably determine the positions of the heavy elements Zr and Ni but leaves the hydrogen atoms unresolved—a common issue in hydrogen-containing structures. However, PXRDGen successfully resolved the complete structure, with the positions of all hydrogen atoms perfectly aligning with those determined by neutron diffraction38 (RMSE < 0.02). Similarly, for Li6Au2S4 (Fig. 4b), the lithium atom locations identified by PXRDGen matched precisely with results from single-crystal diffraction39. Furthermore, as shown in Fig. 4c, PXRDGen successfully generates the correct structure of SrH2O6 from PXRD data, closely matching the experimental structure determined by neutron diffraction40, while conventional structure solution methods, even using SCXRD data41, were unable to locate all the hydrogen atoms.

PXRDGen significantly improves the ability to differentiate neighboring elements with similar atomic numbers, a task traditionally considered impossible for PXRD analysis. For example, in Mn2Fe2As2 (Fig. 4d), where Mn (Z=25) and Fe (Z=26) have nearly identical atomic numbers, neutron diffraction was previously essential for distinguishing them42. However, PXRDGen accurately identified the correct element assignments. This capability extends to more complex structures like Sr3Fe2Cu2Se2O5 (Fig. 4e), where distinguishing Fe from Cu is challenging due to their similar atomic numbers and coordination environments with Se and O43. PXRDGen precisely positioned Fe and Cu (RMSE=0.025), a task that would typically require neutron diffraction or advanced expertise in coordination chemistry. PXRDGen also excels in cases with overlapping peaks, which pose significant challenges for traditional PXRD-based structure determination methods. For instance, in Y6PdBr10 (Supplementary Fig. 3), where the PXRD pattern is complicated by peak overlap, PXRDGen successfully generated the correct structure with an RMSE of 0.015, a task that would normally require SCXRD44.

Influence of grain size and impurity peaks on PXRDGen
A major challenge in material science—highlighted by recent advances such as PXRDnet31—is the determination of nanometer-sized object structures. As grain size decreases, diffraction peaks broaden due to finite size broadening, progressively degrading the resolution and information content of PXRD patterns. This effect is particularly pronounced in nanocrystalline materials (grain sizes <1000Å), where severe peak overlap obscures individual diffraction signals, complicating structure resolution. To evaluate PXRDGen’s performance under these conditions, we tested it on the MP-20-PXRD benchmark dataset originally proposed by PXRDnet31, which contains simulated PXRD patterns with crystallite sizes ranging from 10Å to 1000Å. As expected, 10Å samples exhibited significantly broader peaks and greater information loss compared to 1000Å samples. Despite these challenges, PXRDGen maintained consistently high accuracy: the match rate between 200 predicted and experimentally determined structures exhibited only a modest decline from 88.00% at 1000Å to 83.50% at 10Å (Supplementary Fig. 4). These results demonstrate the method’s resilience to peak broadening effects, even under extreme nanocrystallinity conditions.

Beside the size broadening effect, the presence of minor impurity peaks in real-world PXRD data is frequently encountered and may pose a significant challenge to structure solutions. To evaluate this effect, synthetic Al2O3 impurity peaks (constituting 5% of the total intensity) were systematically introduced into the evaluation dataset. Our analysis revealed a 10.3% reduction in the match rate for the single-sample approach, compared to a notably smaller 3.5% reduction when employing a 20-sample approach. These results indicate that while the model exhibits moderate sensitivity to impurity peaks, this sensitivity can be effectively reduced through multi-sample solution.

Rietveld refinement in crystal structures determination
The initial structural model obtained from structure solution generally requires Rietveld refinement to improve its fit to experimental data. However, due to the nature of the nonlinear least-squares algorithm at the core of Rietveld refinement, the process is highly sensitive to the accuracy of the initial model. By leveraging the precise structure models generated by the CSP module, we have developed an automated Rietveld refinement module within PXRDGen. To assess its effectiveness, we have tested the predicted structures from the flow-CNN-Ltruth module in the MP-20 dataset. Out of 9046 materials in the test set, 8238 are valid entries, with PXRDGen successfully solving the structure for 7946 materials (96.5%) for the 20-sample approach. Among these, 7304 structures were successfully refined using automatic Rietveld refinement. Details of the outcomes are provided in Supplementary Data 1 and 2.

Figure 5a illustrates that the RMSE distribution for the majority of 7304 materials decreased significantly by an order of magnitude after Rietveld refinement. Figure 5b categorizes the predicted materials into six regions based on RMSE thresholds, with each region representing cases where the predicted RMSE is below a specified value. It is clear that for most predicted structures, the RMSE is below 0.05 and improves further with Rietveld refinement. However, the refinement process becomes more challenging as the initial RMSE increases. Specifically, Rietveld refinement becomes problematic when the predicted RMSE exceeds 0.3 and is largely ineffective when it surpasses 0.4, underscoring the crucial importance of initial model accuracy for successful automatic refinements. Despite these challenges, the Rietveld module significantly improves the alignment between predicted structures and PXRD data while providing a well-established benchmark (Rwp) for selecting the best structure from multiple candidates.

Figure 5c, d illustrates two representative cases among the 7304 materials, showcasing structures with varying initial RMSE values and structural complexities. For structures devoid of light elements, the Rietveld refinement module typically reduces the RMSE significantly, aligning the predicted structures more closely with PXRD data. Although Rietveld refinement generally reduces the RMSE for most structures, a small fraction (<5%) exhibited increased RMSE after refinement (Supplementary Fig. 5). In such cases, the CSG module may more effectively capture stable structures compared to Rietveld refinement alone, which relies solely on X-ray diffraction data and does not assess the rationality of the crystal structure. Future integration of AI into Rietveld refinement could address these limitations.

Methods
Details of dataset and evaluation
PXRDGen is designed to solve experimentally stable inorganic compounds. The dataset used for inorganic crystal structures comes from the Materials Project (MP)32, specifically the MP-20 dataset, which predominantly consists of experimentally stable structures. The dataset features crystal structures in their primitive cells, with no more than 20 atoms per cell. The corresponding PXRD patterns are calculated using GSASII46 with default instrument parameters, employing both CuKα1 and Kα2 radiation. Each PXRD pattern is simulated over a 2θ range of 5° to 80° with a step size of 0.01°, and normalized by maximum peak intensity. The MP-20 dataset comprises 45,229 structures, split into 60% training data, 20% validation data, and 20% test data. Besides, the automatic Rietveld refinement is applied to the predicted structures using GSASII scriptable.

To evaluate the outcomes, the resolved and refined structures are compared with the ground truth using the StructureMatcher in Pymatgen47, with settings of stol=0.5, angle_tol=10, and ltol=0.3. The match rate and RMSE are provided to assess the quality of the predicted inorganic crystal structures. The RMSE output by StructureMatcher represents the distances from the best matching candidate to the ground truth, normalized by (V/atom)1/3, making it dimensionless. Notably, a noticeable portion of compounds in MP-20 (8.93%) is invalid and not matchable, so that the actual match rate is underestimated without removing the invalid entries. To provide a more accurate assessment, the match rate for the valid entries in MP-20 is also reported.

In this work, we apply diffusion and flow matching models in PXRDGen to jointly generate the lattice matrices (L) and fractional coordinates (F i) of crystal structures in a condition of chemical composition (A) and PXRD pattern, which are adapted from DiffCSP26 and FlowMM27.

Diffusion models
The lattice diffusion is applied via the standard DDPM35 process, which includes a forward diffusion process and a backward generation process. The forward process gradually adds noise to L towards a Gaussian prior as

q(L_t | L_0) = N(L_t; \sqrt{\bar{\alpha}_t} L_0, (1-\bar{\alpha}_t) I), (2)

where \bar{\alpha}_t = \prod_{s=1}^{t} (1-\beta_s), \beta_s \in (0,1) determines the standard deviation of each step.

And the backward process progressively denoises from the Gaussian prior via

p(L_{t-1} | M_t) = N(L_{t-1}; \mu(M_t), \sigma^2(M_t) I), (3)

where M_t is the intermediate state of timestep t, and the time-dependent mean and standard deviation \mu(M_t) and \sigma^2(M_t) are defined by

\mu(M_t) = \frac{1}{\sqrt{\alpha_t}} (L_t - \frac{\beta_t}{\sqrt{1-\bar{\alpha}_t}} \hat{\epsilon}(M_t, t)), (4)

\sigma^2(M_t) = \beta_t \frac{1-\bar{\alpha}_{t-1}}{1-\bar{\alpha}_t}, (5)

where the denoising term \hat{\epsilon}(M_t, t) is predicted by the model. And the training objective is defined as

L_{L, diffusion} = E_{\epsilon \sim N(0,I), t \sim U(1,T)} ||\epsilon - \hat{\epsilon}(M_t, t)||^2_2, (6)

The diffusion process of fractional coordinates utilizes score matching48 on the wrapped normal distribution. The forward process is defined as

q(F_t | F_0) \propto \exp(-\frac{||F_t - F_0 + Z||^2}{2\sigma_t^2}), (7)

where \sigma_t = \sigma_1 (\frac{\sigma_T}{\sigma_1})^{\frac{t-1}{T-1}} is the noise scale at time step t. The generation process is constructed via the predictor-corrector algorithm49 as

F_{t-0.5} = w(F_t + \frac{\sigma_t^2 - \sigma_{t-1}^2}{\sigma_{t-1}} \hat{\epsilon}_F + \sigma_{t-1} \epsilon_F), (8)

F_{t-1} = w(F_{t-0.5} + \gamma \frac{\sigma_{t-1}}{\sigma_t} \hat{\epsilon}_F + \sqrt{2 \gamma} \sigma_{t-1} \epsilon_F^0), (9)

where w(.) projects fractional coordinates back to R [0,1), and \epsilon_F, \epsilon_F^0 are Gaussian noises, \hat{\epsilon}_F is yielded by the model with training objective as

L_{F, diffusion} = E_{F_t \sim q(F_t | F_0), t \sim U(1,T)} \lambda_t ||\nabla_{F_t} log q(F_t | F_0) - \hat{\epsilon}_F(M_t, t)||^2_2, (10)

Flow matching models
As the lattices are defined in the Euclidean space, the flow path can be simply constructed as

q(L_t | L_0) = N(L_t; (1-t)L_0, tI), (11)

The training objective is defined as

L_{L, flow} = E_{\epsilon \sim N(0,I), t \sim U(1,T)} ||\epsilon - \hat{\epsilon}_L(M_t, t)||^2_2, (12)

The generative ODE process follows

L_{t-\Delta t} = L_t - \hat{\epsilon}_L(M_t, t) \Delta t, (13)

For the fractional coordinates, we first sample F_1 from the uniform distribution on the torus, and connect the shortest path from the data F_0 to F_1 via the logarithmic transformation F_{0,1} = log(F_1 - F_0 + 0.5) - Mean(log(F_1 - F_0 + 0.5)). The training objective on coordinates is

L_{F, flow} = E_{t \sim U(1,T), F_1 \sim U(0,1)} ||\hat{\epsilon}_F(M_t, t) - v(F_0, F_1)||^2_2, (14)

Inspired by FlowMM3, we apply the anti-annealing strategy during the generative ODE as

F_{t-\Delta t} = F_t + (1+5(1-t)) \hat{\epsilon}_F \Delta t, (15)

Decoder in generating structures in PXRDGen
We adapt CSPNet in DiffCSP26 as the backbone decoder model, which is a graph neural network to jointly model L and F i. It takes atom types f atom, time embeddings f pos(t), and XRD features f XRD from the XRD encoder as inputs, and acquires the initial atom representations via multi-layer perceptron (MLP) as h_i^{(0)} = \rho(f atom, f pos(t), f XRD).

The message passing mechanism is modeled as

m_{ij}^{(s)} = \phi_m(h_i^{(s-1)}, h_j^{(s-1)}, L, \psi_{FT}(f_j - f_i)), (16)

m_i^{(s)} = \sum_{j=1}^N m_{ij}^{(s)}, (17)

h_i^{(s)} = h_i^{(s-1)} + \phi_h(h_i^{(s-1)} + m_i^{(s)}), (18)

where \phi_m, \phi_h, MLP, and \psi_{FT} is the Fourier transformation. For the final output, we have

\hat{\epsilon}_L = \phi_L(\frac{1}{N} \sum_{i=1}^N h_i^{(S)}), (19)

\hat{\epsilon}_F[:, i] = \phi_F(h_i^{(S)}), (20)

where \phi_L, \phi_F are MLPs.

Decoder in generating lattice in CellNet of PXRDGen
We adopt diffusion model to generate L in the CellNet, which means that the L can be generated given only the XRD data. It takes time embeddings f pos(t), XRD features f XRD from the XRD encoder as inputs, and is modeled as

\hat{\epsilon}_L = \phi_L(f pos(t), f XRD), (21)

where \phi_L is MLP.

Details of training neural networks are available in Supplementary Information.

Peer review rounds
[{"round": 1, "reviewer_comments": {"reviewer_1": "Since it doesn’t actually take much diffraction data to distinguish the correct structure from a library of potential structures yielded by a crystal structure prediction exercise, the idea of incorporating powder diffraction data into intimately into the crystal structure prediction process has a lot of merit.\nThe performance of the software described here is a significant-enough advancement to warrant publication in a Nature journal. As a communication, many of the details are relegated to supplementary material, but the overall process is clear.\nThe performance on predicting/determining the structures of the intermetallic compounds in the supplementary material is impressive. What additional challenges might be presented by more-complicated oxide etc structures? I am not yet worried that this methodology will work on organic structures.\nSeveral times, the time to obtain a result is given as “seconds”. Perhaps a better unit would be cpu-seconds. The computer mentioned in the supplementary information is beyond those normally available to a powder diffractionist, so some comments need to be made about the scale of computation involved here.\nAs there are several tens of thousands of entries in the Powder Diffraction File database without atomic coordinates, this software should be very useful in “completing” that database. I suspect that ICDD would be interested in a joint project to that end.\nA few technical editing suggestions:\npage 2, line 14 ambiguous relative intensities\n3, 15 I presume that the units on 0.01 are angstroms; they should be given.\n3, 22 fractional coordinates\n(Remarks on code availability)\nI have looked at the code, but not in detail. The fact that it is/will be available is enough.", "reviewer_2": "The authors\n- developed a diffusion model conditioned on powder x-ray diffraction data\n- trained it on MP20\n- the model is able to predict atomic structures given a powder diffraction pattern with good agreement to the input powder\ndata after a refinement step\nThe authors\n- developed a diffusion model conditioned on powder x-ray diffraction data\n- trained it on MP20\n- the model is able to predict atomic structures given a powder diffraction pattern with good agreement to the input powder\ndata after a refinement step\n- This work is quite similar to a related paper on arxiv: arXiv:2406-10796. It is nature policy that papers in preprint servers\ncannot be used to assert precedent, so the existence of the arxiv paper should not affect whether the current manuscript is\naccepted. The authors do cite that paper but do not discuss it or place their paper in context (other than saying it is a parallel\ndevelopment) They claim higher accuracy as a justification for publication of their model, but they are solving a different,\neasier problem, so it is not a valid comparison. Since they are parallel developments, the current paper would benefit from a\ndeeper discussion, if not indeed quantitative benchmarking.\n- The problem the current authors tackled was, given a known unit cell and composition, what are the fractional coordinates\nof the atoms in the unit cell. This is not completely unreasonable, but in many interesting cases it is actually not super\nstraightforward to get the unit cell for powder patterns, especially when the unit cell is larger (not considered in this work).\nThis is a limitation of the broader applicability of the current work.\n- The model is well described with clear diagrams. It uses a diffusion model for the crystal structure generation (CSG)\nmodule and a transformer in the structure encoder (which out-performed a CNN)\n- I like that the authors attempted a final Rietveld refinement step and compared refined values, though given that the unit\ncell was known, the Bragg peaks are guaranteed to be in the right location.\n- It is interesting that their model made the correct elemental assignments for Mn2Fe2As2, which can't be done with x-ray\ndata alone. The diffusion model is bringing addtional value in that it is successfully learning stable elemental arrangements\nfrom the training set that augments the information in the diffraction input.\n(Remarks on code availability)\nsorry, didn't have time."}, "author_response": ""}, {"round": 2, "reviewer_comments": {"reviewer_1": "Indexing a powder pattern (determining the unit cell from the peak positions) is often a major hurdle in solving a crystal structure from powder diffraction data. The output of a crystal structure prediction generally is a library of potential structures. It actually does not take much (or very good) powder data to distinguish among these predicted structures. So including both lattice parameters (or their generation) and powder data into a structure solution process makes a lot of sense.\nThe authors demonstrate impressive success rate on “simple” inorganic and intermetallic structures, and realize that more work is necessary to solve more-complex structures. They have addressed the previous reviewers’ comments adequately.\nI would like to see a comment on how sensitive the results are to impurity peaks in the powder pattern.\nOne minor point. On page 84, 309, and 310 most reviewers (including this one) are going to assume that the RMSE is in Angstroms, when apparently (on page 370) it is a dimensionless number. The units should be clarified at the first mention of this quantity.\n(Remarks on code availability)", "reviewer_2": "It is disappointing to see the way that the authors have responded to the referee comments. I cannot recommend accepting the manuscript in the current form.\nScience is built by sharing information and knowledge and is not a competition. The paper is written as if the authors have to establish priority and superiority of their work, even when it is built on knowledge and advances made by others. It is possibly a function of a competitive environment that they feel themselves in, to publish in a high impact journal, but it is then the responsibility of the journal to guide authors towards a more balanced presentation. The future of science depends on this.\nIf the authors do a better job of acknowledging developments and innovations made by others, that they were able to build upon in the current work, it helps the community to move forward because others may then, in their turn, acknowledge and cite the author's work in the future without a bad feeling that they are citing work that didn't properly acknowledge what came before. The authors may be afraid that it makes their work look less novel or exciting, but it will have the opposite outcome. People will think more highly of them and their work if they are able to build up the work of others and then show how their own innovations move things forward and advance knowledge.\nThe authors may argue that they did cite the literature, but this is not the point. Yes, you must cite the literature, but not in a way that is dismissive or divisive. If the authors were to rewrite sections of the paper in a style where they celebrate the foundational work of others before describing the advances they themselves make, I believe that the developments are sufficiently interesting for and worthy of publication in Nature Communications. It doesn't have to be a review paper, just a few words. But if they cannot do this, my recommendation is to reject.\n(Remarks on code availability)"}, "author_response": "Response Letter\nReviewer #1 (Remarks to the Author):\nIndexing a powder pattern (determining the unit cell from the peak positions) is often a major\nhurdle in solving a crystal structure from powder diffraction data. The output of a crystal structure\nprediction generally is a library of potential structures. It actually does not take much (or very\ngood) powder data to distinguish among these predicted structures. So including both lattice\nparameters (or their generation) and powder data into a structure solution process makes a lot of\nsense.\nThe authors demonstrate impressive success rate on “simple” inorganic and intermetallic structures,\nand realize that more work is necessary to solve more-complex structures. They have addressed\nthe previous reviewers’ comments adequately.\nResponse: We sincerely appreciate your encouraging remarks and insightful comments on our\nwork.\nI would like to see a comment on how sensitive the results are to impurity peaks in the powder\npattern.\nResponse: Indeed, the presence of impurity peaks in PXRD data is frequently encountered and\nmay pose a significant challenge to structure solutions. To evaluate this effect, synthetic Al O\n2 3\nimpurity peaks (constituting 5% of the total intensity) were systematically introduced into the\nevaluation dataset. Our analysis revealed a 10.3% reduction in the match rate for the single-sample\napproach, compared to a notably smaller 3.5% reduction when employing a 20-sample approach.\nThese results indicate that while the current model exhibits moderate sensitivity to impurity peaks,\nthis sensitivity can be substantially reduced through multiple sampling solution. In the revised\nmanuscript, we have followed your suggestions and added a comment on the sensitivity of the\nresults on impurity peaks.\nOne minor point. On page 84, 309, and 310 most reviewers (including this one) are going to\nassume that the RMSE is in Angstroms, when apparently (on page 370) it is a dimensionless\nnumber. The units should be clarified at the first mention of this quantity.\nResponse: In response to your suggestion, the revised manuscript now explicitly specifies that the\nRMSE (Root Mean Square Error) employed in this analysis is a dimensionless metric upon its first\nmention (page 3), ensuring clarity and preventing potential confusion in subsequent sections.\nThanks again for your time and encouraging comments!\nReviewer #2 (Remarks to the Author):\nIt is disappointing to see the way that the authors have responded to the referee comments. I\ncannot recommend accepting the manuscript in the current form.\nScience is built by sharing information and knowledge and is not a competition. The paper is\nwritten as if the authors have to establish priority and superiority of their work, even when it is\nbuilt on knowledge and advances made by others. It is possibly a function of a competitive\nenvironment that they feel themselves in, to publish in a high impact journal, but it is then the\nresponsibility of the journal to guide authors towards a more balanced presentation. The future of\nscience depends on this.\nIf the authors do a better job of acknowledging developments and innovations made by others, that\nthey were able to build upon in the current work, it helps the community to move forward because\nothers may then, in their turn, acknowledge and cite the author's work in the future without a bad\nfeeling that they are citing work that didn't properly acknowledge what came before. The authors\nmay be afraid that it makes their work look less novel or exciting, but it will have the opposite\noutcome. People will think more highly of them and their work if they are able to build up the\nwork of others and then show how their own innovations move things forward and advance\nknowledge.\nThe authors may argue that they did cite the literature, but this is not the point. Yes, you must cite\nthe literature, but not in a way that is dismissive or divisive. If the authors were to rewrite sections\nof the paper in a style where they celebrate the foundational work of others before describing the\nadvances they themselves make, I believe that the developments are sufficiently interesting for\nand worthy of publication in Nature Communications. It doesn't have to be a review paper, just a\nfew words. But if they cannot do this, my recommendation is to reject.\nResponse: We sincerely regret that our language inadvertently conveyed a tone that overshadowed\nthe collaborative spirit of scientific community and fell short in adequately honoring the\nfoundational contributions of other researches. We fully agree that scientific progress is inherently\ncollaborative, and our work is indebted to the contributions of researchers who laid the\ngroundwork in this field.\nIn line with your suggestions, we have revised the manuscript to emphasize the critical\nadvancements made by concurrent studies before introducing our findings. Specifically:\n1. Page 3: “In the past year, a few concurrent studies have leveraged graph neural networks and\ngenerative models to enable end-to-end crystal structure determination from powder X-ray\ndiffraction data 29-31. For instance, CrystalNet29 uses a variational query-based multi-branch\ndeep neural network to predict modified charge density for cubic and trigonal crystal systems.\nXtalNet30 leverages the power of contrastive learning and diffusion models to solve the\nstructure of complex MOF materials. On the other hand, PXRDnet31 firstly demonstrates the\nability to determine crystal structures from powdered crystalline samples in nanoscale regimes\n(down to 10 Å). While these advances represent important steps forward, we note that\nopportunities for improvement remain, particularly in achieving atomic-level accuracy,\nenhancing match rates, and extending robust structure determination capabilities across\ncommon categories of crystalline materials.”\n2. Page 9: “A major challenge in materials science—highlighted by recent advances such as\nPXRDnet31—is the determination of nanometer-sized object structures. …… To evaluate\nPXRDGen's performance under these conditions, we tested it on the MP-20-PXRD\nbenchmark dataset originally proposed by PXRDnet31, which contains simulated PXRD\npatterns with crystallite sizes ranging from 10 Å to 1000 Å. ……”\nAdditionally, we have removed the direct benchmark comparison between PXRDGen and\nPXRDnet, as their differing network architectures and objectives (e.g., PXRDnet focuses on\nnanoscale regimes, while our work targets more on conventional polycrystalline) could lead to\nmisinterpretation.\nYour critique has profoundly improved the manuscript’s tone and scholarly rigor. We sincerely\nappreciate your expert guidance in refining the manuscript's academic rigor and your recognition\nof our work’s potential value to the community."}, {"round": 3, "reviewer_comments": {"reviewer_1": "(Remarks to the Author)\n(Remarks on code availability)", "reviewer_2": "The authors have done a a nice job updating the manuscript a further time in response to my comments. I feel that the presentation is much more balanced and properly reflects other work that their work was built on or that provides context for their work. This is exactly what I had in mind when I made by comments.\n(Remarks on code availability)"}, "author_response": "Response Letter\nReviewer #2 (Remarks to the Author):\nThe authors have done a nice job updating the manuscript a further time in response to my\ncomments. I feel that the presentation is much more balanced and properly reflects other work that\ntheir work was built on or that provides context for their work. This is exactly what I had in mind\nwhen I made by comments.\nResponse:Thank you for your valuable feedback."}]

Decision letter