Introduction
Scanning X-ray diffraction microscopy (SXDM) is an advanced imaging technique that spatially resolves structural information by diffraction contrast. A coherent, nano-focused X-ray beam is raster-scanned across an extended sample, and the diffraction patterns collected at each point elucidate the localized strain gradients and crystal lattice orientation. This characterization method is particularly useful for studying thin films with heterogeneous domains, such as ferroelectrics1,2, photovoltaics3,4, magnetic oxides5,6, and Mott insulators7,8. SXDM may also be extended to ptychography in the Bragg geometry for enhanced resolution9,10. Yet, a critical challenge in interpreting SXDM data is the convolution of the beam shape with the local crystal lattice information. The convergence angle of the probe due to nanoscale focusing optics results in simultaneous dependency of the far-field scattering data on the lattice strain and two rigid-body rotations of the unit cell with respect to the normal of the Bragg planes. Conventionally, these components are disentangled by fitting to simulated data, a process that is computationally expensive and highly dependent on data pre-processing.
With the widespread use of two-dimensional pixelated area detectors at synchrotron facilities, X-ray scattering data is acquired in the form of images, which lends well to computer vision methods for processing. Supervised machine learning (ML) has achieved great improvements in analysis speed across many scientific disciplines, including Bragg coherent diffractive imaging (BCDI)11, X-ray ptychography12, coherent surface scattering13, and 4D scanning transmission electron microscopy14. Nonetheless, supervised models face a fundamental bottleneck: the requirement for large, well-labeled training datasets. Acquiring labeled data for synchrotron X-ray scattering techniques can be difficult, as it often requires extensive domain expertise to generate simulated data or is vastly time-consuming and computationally costly experimental analysis. Furthermore, simulated data may not accurately represent the complexity of experimental data. The reliance on labeled data limits the flexibility and broader applicability of supervised learning models for X-ray science. Unsupervised learning methods, by contrast, do not require labeled data and can automatically discover patterns within datasets. Techniques such as clustering, dimensionality reduction, autoencoders, and generative models have been applied to coherent X-ray scattering experiments, such as BCDI15, ptychography16, computed tomography17, and X-ray photon correlation spectroscopy18, illustrating the effectiveness of unsupervised learning combined with a physical model for a specific task in improving analysis efficiency.
For a physical model to guide a neural network’s training, gradients must be calculated not only through the network’s parameters but also through the simulation itself. This is made possible by automatic differentiation (AD), a computational technique that efficiently and accurately computes derivatives of complex functions19. While unsupervised learning enables training on data without labels, AD facilitates optimization by eliminating the need to manually compute and update gradients. AD has recently seen widespread use in computational imaging20, including image reconstruction problems, with workflows specifically developed for coherent X-ray techniques21,22. By implementing the forward scattering model in a fully differentiable manner, AD allows the error between the model’s prediction and the experimental data to be backpropagated through the entire physics-aware architecture, enabling end-to-end optimization.
In this study, we leverage this approach to develop diffraction with optics for nanobeam by unsupervised training (DONUT). DONUT is a physics-aware autoencoder that directly embeds a differentiable SXDM forward model into its architecture. It learns to extract strain and lattice tilt by minimizing the difference between its physics-based diffraction output and the measured experimental data, eliminating the need for pre-generated labels. We demonstrate that DONUT can be trained solely on experimental data, achieving analysis speeds over 200 times faster than conventional methods while providing improved accuracy in disentangling convoluted structural parameters. This framework provides a versatile and robust pathway for real-time, automated analysis of SXDM data, accelerating discovery in the study of complex materials under dynamic conditions.
Results
Model approach
The DONUT architecture is founded on a physics-aware autoencoder. Standard autoencoders are power tools for unsupervised feature extraction23,24, noise reduction25, and anomaly detection26. These neural networks learn a compact latent space representation of high-dimensional imaging data, capturing essential structural and compositional features while filtering out irrelevant noise. A key challenge with autoencoders, however, is the interpretability of the latent space, as purely data-driven embeddings may lack direct physical significance. To address this, physics-based constraints such as enforced symmetries, conservation laws, or domain-specific priors are incorporated into the network architecture27,28,29 or loss function30. DONUT applies a similar approach by directly building a physics-based X-ray scattering simulation into the forward pass of the neural network and restricting the dimensionality of the latent space to the quantities of interest. By forcing the network to learn through the lens of a physical model, we ensure that the extracted features are not just abstract representations but are directly tied to the structural properties of the material.
As illustrated in Fig. 1a, the network takes a 2D diffraction pattern as input. This image is passed through a convolutional neural network (CNN) encoder (Fig. 1b), which compresses it into a low-dimensional latent space vector. By design, this latent vector of three elements represents the physical quantities of interest: strain (\(\varepsilon\), relative magnitude of the momentum transfer vector \(Q\)), in-plane rotation (\(\omega\), relative rotation angle of \(Q\) within the horizontal scattering plane), and out-of-plane rotation (\(\chi\), relative rotation angle of \(Q\) perpendicular to the scattering plane). The contribution of each of the three independent quantities to the physics-based simulated intensity constrains the encoder to predict only physically meaningful values. The latent vector then simultaneously feeds into two parallel branches: 1) a decoder, symmetric to the encoder, which reconstructs a denoised version of the input diffraction intensity from the latent vector, and 2) a physics-based forward model, which uses the latent parameters (\(\varepsilon\), \(\omega\), and \(\chi\)) to simulate diffraction intensity.
a Schematic illustration of the model architecture and self-supervised training process of DONUT. The input diffraction pattern (experimental data shown here) is passed through an autoencoder, and the bottleneck layer, which is the target prediction output, is fed to the physics-based forward scattering model, which is a convolution of an approximation of the convergent probe and the Bragg peak projected onto the detector. The simulated diffraction and decoder reconstruction are compared against the input diffraction in a weighted mean absolute error loss function. b Diagram of the layers in the CNN-based autoencoder (box dimensions not drawn to scale w.r.t. layer dimensions).
The network is trained by minimizing a composite loss function (See Methods, Neural Network Architecture and Training for details). This loss is the weighted mean absolute error (MAE) between the original input image and the outputs of both branches (the decoder reconstruction and the physics-based simulation, the latter of which does not have trainable parameters). During training, the network iteratively adjusts the autoencoder weights until both the generated images and the input data match. This dual-objective optimization ensures that the encoder learns to populate the latent space with physically accurate and robust values for the desired structural parameters.
The effectiveness of DONUT depends on its physics-based forward scattering model. This model is initialized with a set of fixed experimental and sample parameters, which include: 1) sample properties: the bulk out-of-plane lattice parameter and film thickness, measured prior to the experiment by lab-source X-ray diffraction and X-ray reflectivity, respectively, 2) diffraction geometry: Bragg peak (incident and exit beam angles), X-ray energy, sample-detector distance, and detector pixel size, and 3) focusing optics: zone plate module dimensions and outermost zone width, which define the convergent nature of the incident beam.
These static parameters are used to construct the reciprocal space coordinates for the detector frame. During the forward pass, the model takes the predicted strain and tilt values from the encoder’s latent space to define the orientation of the 3D Bragg peak in reciprocal space. The shape of the Bragg peak (Fig. 1a) is modeled using the known shape of the sample: a quasi-infinite crystal in the plane of the film (Dirac delta, or sharp Gaussian in reciprocal space) and a truncated crystal in the direction of the normal to the sample surface (sinc function in reciprocal space). This computationally efficient geometric approach does not compute Fourier transforms or use complex arithmetic. The final diffraction intensity is then calculated by projecting the intersection of the 3D Bragg peak with the Ewald sphere construction onto the 2D detector, accounting for the beam’s angular divergence (Fig. 1a). By embedding this entire, differentiable physical process into the network, we force the latent space to correspond to concrete physical quantities, ensuring the model’s predictions are not just computationally efficient but also scientifically interpretable.
Performance on simulated data
To directly compare the performance of DONUT against the conventional correlation analysis method, we simulate features in strain and lattice rotation across a real-space coordinate system indexed \((i,j)\). These spatially distributed ground truth features are then used to generate simulated diffraction patterns representative of an SXDM measurement. Each pixel in the sample grid is associated with one diffraction pattern described by \({I}_{{ijxy}}({\varepsilon }_{{ij}},{\chi }_{{ij}},{\omega }_{{ij}},{Q}_{{xy}})\), where \((x,y)\) denote the detector coordinates (see Methods, Physics-informed forward model). Figure 2 shows the comparison between DONUT predictions and the conventional correlation fitting analysis31. All the data were simulated to have a maximum intensity of seven photons per pixel (according to the average maximum counts per pixel of the experimental data presented in the following section) before introducing noise by sampling from a Poisson distribution. In the conventional correlation analysis method, the correlation between a simulated diffraction library of 41 values each in strain, in-plane rotation, and out-of-plane rotation, and each of the diffraction patterns in the simulated SXDM scan was calculated by a weighted sum interpolation according to the technique described in Methods, Experimental data analysis. Figure 2b shows that features in strain and in-plane lattice rotation are systematically, incompletely disentangled by conventional analysis, with the periodicity of strain features markedly visible in the in-plane lattice rotation map (middle) and vice versa. Conversely, DONUT (Fig. 2c) cleanly separates the strain and in-plane lattice rotation signal, as well as correctly predicting the magnitude of strain, which is overestimated by conventional analysis. Additional statistics on model prediction accuracy are provided in the Supplementary Information, Fig. S1, Fig. S12, and Table S1. We note that both analysis methods are applied directly to diffraction space independently of the scan position on the sample. Consequently, the real space domain structure does not influence either conventional fitting or DONUT feature extraction (Fig. S11a), but some combinations of strain and lattice rotations result in diffraction patterns where the features are more difficult to disentangle (Fig. 2). The primary limitation of the correlation method is whether the entire peak in correlation is captured by the simulation parameter range. One could expand the parameter range for potentially improved accuracy at the cost of computational time (simulated diffraction generation and calculation of the correlation matrix both scale linearly with the number of parameter combinations); however, as shown in Figure S11b, expanding the parameter ranges may not completely solve the problem of parameter cross-talk because the maximum in correlation may not exactly match the actual parameter value. Therefore, DONUT is not only more computationally efficient than fitting the correlation between the data and simulation library, but also qualitatively more accurate and quantitatively more precise (SI, Table 1).
a Simulated spatial distribution of strains \(\varepsilon \left(i,j\right)\) and tilts \(\omega \left(i,j\right)\), and \(\chi \left(i,j\right)\), which mimic extended features present in a scanning X-ray nanoprobe diffraction microscopy measurement, where there is one diffraction pattern for each unique pixel coordinate. b \(\varepsilon \left(i,j\right)\), \(\omega \left(i,j\right)\), and \(\chi \left(i,j\right)\), as analyzed by conventional fitting of the correlation between measured and simulated diffraction. c \(\varepsilon \left(i,j\right)\), \(\omega \left(i,j\right)\), and \(\chi (i,j)\), predicted by DONUT. The numbers in the bottom right corners of the maps in (b) and (c) indicate the MAE between the analyzed result and the ground truth.
Performance on experimental data
We next evaluate DONUT on experimental SXDM data from a SrIrO3 thin film and compare its performance against both conventional correlation fitting and a previously developed supervised deep learning model32. The experiment is described in another previous study33; here, we present a more generalizable approach to SXDM data analysis using the previously published data. As shown in Fig. 3, DONUT’s predictions (Fig. 3b) are qualitatively consistent with the conventional analysis (Fig. 3a) but offer significant improvements. Critically, where the conventional method exhibits clear crosstalk artifacts—with rotational features incorrectly appearing in the strain map—DONUT provides a clean, independent separation of the parameters. This disentanglement matches the performance of our prior supervised model; however, DONUT further demonstrates its superior fidelity by resolving the fine striped features between the two larger rotational domains present in the diffraction center-of-mass spatial maps, the supervised approach could not do (cf. ref. 32, Fig. 4, S5). This indicates that the physics-constrained unsupervised approach not only eliminates the need for labeled data but can also achieve a higher level of accuracy in feature extraction. Uncertainty from this physics-informed model architecture was characterized by Monte Carlo dropout34 (Fig. S2), which shows that the standard deviation of 30 predictions with 10% of model weights randomly set to zero produces no systematic trends in errors. Although the previously reported supervised deep learning model has an overall smaller model uncertainty (lower standard deviation across predictions by multiple models) than DONUT, the former has systematic prediction errors in strain and in-plane lattice rotation, while the latter has uniform prediction errors, indicating no systematic bias between features.
a Diffraction contrast features of the SrIrO3 002 pc peak measured by scanning X-ray nanoprobe diffraction microscopy as analyzed by conventional fitting of the correlation between measured and simulated diffraction. b DONUT evaluations of the experimental data shown in (a). The labels in the top right of the maps are the Pearson correlation coefficients between the two analyses results for each structural parameter.
a Top left: simulated ground truth values of film thickness \(t\left(i,j\right)\) across a spatial region of a sample. Bottom left: predicted values of \(t\left(i,j\right)\) using a version of DONUT trained only on simulated data. Top right: conventional analysis of film thickness from the SrIrO3 002 pc peak measured by scanning X-ray nanoprobe diffraction microscopy. Bottom right: predicted values of film thickness by DONUT trained on experimental data. b Schematic depiction of real-time analysis workflow during a scanning X-ray nanodiffraction microscopy experiment.
In this study, we extend SXDM analysis further by adding film thickness prediction to the established parameter axes of strain and lattice rotation. SXDM is sensitive to non-uniformities in film thickness of a crystalline thin film through local variations in total intensity and periodicity of the Laue oscillations (changing fringe positions within the detector frame). Many factors may cause local heterogeneities in film thickness in thin films, including imperfectly controlled growth kinetics during deposition35, growth modes, and substrate properties36. Locally non-uniform film thickness may, in turn, affect material properties. Figure 4a shows DONUT’s predictions of film thickness for simulated (left) and experimentally measured (right) samples. The top left panel is a map of the ground truth thickness values used to simulate diffraction patterns corresponding to each pixel coordinate. The bottom left panel is the corresponding map of predictions by DONUT. The top right panel shows the conventional analysis by fitting the correlation between measured and simulated diffraction of film thickness for the same sample and scan in Fig. 3, while the bottom right panel shows DONUT predictions of the SrIrO3 film thickness. The extension of thickness prediction to DONUT’s existing prediction axes of strain, in-plane tilt, and out-of-plane tilt makes no changes to the CNN-based autoencoder structure other than to increase the dimensionality of the bottleneck layer to include a fourth parameter. We omit the other parameters here for brevity, but the full predictions may be found in the Supplementary Information (Figs. S3, S4). We introduce minor changes to the scaling of the encoder output nodes (inputs to the physics-based diffraction model) to achieve numerical stability for training. Rather than the previous direct scaling by dividing by set factors, we take the exponent of the natural logarithm of the factors.
Figure S5 shows predictions of thickness on simulated and experimental data by DONUT trained on a combined simulated and experimental dataset. The discrepancy in intensity normalization in the physics-informed forward model with experimentally measured counts results in simultaneous overprediction of thickness on simulated diffraction and underprediction on experimental data because thickness greatly affects the relative total intensity of the forward model output diffraction pattern. Thus, the bottom left and right panels of Fig. 4a show predictions made by DONUT trained only on simulated or experimental data, respectively. The noise in the predictions on simulated diffraction, as well as the large error bars on the leftmost parity plot of Fig. S3b, demonstrates the relatively high prediction uncertainty at this thickness regime governed by the detector pixel size in reciprocal space (Methods, Physics-informed forward model). In addition to relative total intensity, film thickness also changes the periodicity of the Laue oscillations present in diffraction from a truncated crystal (Figs. S5b, S6c). Both factors affect DONUT training and inference: at low film thickness, the model only has intensity to compare between input and output diffraction; however, at higher film thickness, fringe spacing becomes an additional learned feature. We hypothesize that thickness prediction is therefore more useful for thicker films, where the dips in intensity in the thickness fringes are within the measured detector frame, as demonstrated in Fig. S6.
Unlike with strain and lattice rotation, the conventional analysis of film thickness differs greatly from the neural network inference (Fig. 4a, right), with each method offering its own advantages. The correlation fitting result shows a highly uniform film thickness, which is expected of a highly crystalline film synthesized by molecular beam epitaxy; however, the thickness is far overestimated at 136 Angstroms from the 30 unit cells or 120 Angstroms as measured by in situ reflection high-energy electron diffraction (RHEED), a highly accurate method of surface characterization37, during synthesis. Conversely, DONUT more reasonably predicts the film thickness to be around an average of 110 Angstroms, within the uncertainty window both of diffraction resolution and crystal growth on different regions of the substrate. Nonetheless, the neural network predictions show a diagonal stripe of higher thickness located at the lower portion of the stripe of large lattice rotations. This is consistent with regions of higher total intensity33, which may indicate higher film thickness, but we cannot completely rule out the possibility of cross-talk between parameter predictions without further experimental measurements outside the scope of this study, particularly because lattice tilting at a given incident angle may rotate the lattice planes into or out of the Bragg condition (thereby greatly affecting the total intensity). For instance, intensity is not the sole proxy for film thickness as the structure factor also depends on distortions and crystal defects. The conventional fitting result and DONUT prediction are only moderately correlated with a Pearson correlation coefficient of ~0.55 (unlike the other parameters, where both analyses are highly correlated), so we recommend testing the thickness analysis on films with a higher degree of non-uniformity.
DONUT may be trained on simulated diffraction, experimental data, or a combination of both. The key advantage of this self-supervised learning approach is that it eliminates the need for pre-generating a simulated dataset with labels for training. Practically, this means that DONUT enables not only real-time analysis of crystalline lattice structure from SXDM experiments, but also simultaneous validation of the accuracy of prediction results through the MAE loss between the input experimental and output model-simulated diffraction. We demonstrate that although the model may be trained on part of a single measured scan (Fig. S7a), the best results, according to a balance between high accuracy, low prediction uncertainty, and full dynamic range of predicted values, come from combining noisy simulated and experimental data during the training process (Fig. S7b). We hypothesize that augmenting the experimental data with simulations is likely effective for our specific experimental case because the measured diffraction has a limited range of features caused by strain and lattice tilting. The physics model within DONUT thus only learns the distribution across features present in the input training experimental data and cannot extrapolate to potential outliers during inference. By adding simulated data to the model training, we can ensure that the model learns a sufficient range of features to cover the solution space of all experimental measurements on a sample, which produces more accurate predictions38,39. Nonetheless, training convergence may be reached up to six times faster using the smaller experimental training dataset instead of a combined dataset (see Methods, Neural network architecture and training). Training on noisy simulated data also requires more hyperparameter tuning and does not converge as easily compared to using experimental data; however, this is mitigated by using a combined dataset of clean simulated diffraction and experimental data (adds noise), which also produces accurate predictions with slightly higher uncertainty (Fig. S7b) while still reaching convergence quickly (Fig. S8). Therefore, a realistic workflow at the instrument may involve training the model on the first 20,000 diffraction patterns collected under experimental conditions, deploying the trained model on an edge device to perform inference on the following measurements, continually training the model as more data is collected using other computing resources, and periodically updating the local encoder for real-time predictions, such as illustrated schematically in Fig. 4b and previously demonstrated for transmission X-ray ptychography40. Final structural analysis may then be refined post-experiment by further augmenting the training dataset with simulated diffraction if necessary.
Discussion
While AD offers crucial flexibility of model architecture design and integration of physics awareness, scaling of the encoder output nodes that make up forward model inputs to their physically appropriate orders of magnitude may introduce numerical instabilities in the gradients. Although CNN-based autoencoders are commonly implemented for image compression applications, the fundamental goal of SXDM analysis is not compression but rather the extraction of lattice quantities from diffraction data. This requires the physics model to constrain the latent space representation produced by the encoder, but theoretically should not require a decoder. We demonstrate that while it is possible to train DONUT implemented in PyTorch without the decoder, the model can take up to five times as long to reach convergence (Fig. S8c). Therefore, we find empirically that the inclusion of a decoder symmetric to the encoder regularizes the optimization process and facilitates convergence during training without adding significant computation time per epoch. We hypothesize that a combination of gradient instabilities and poor conditioning caused by the complexity of the physics-based component of the model, as well as the constrained latent space, leads to optimization difficulties. The scaling of encoder outputs to physically relevant ranges directly affects the gradient calculation during the backpropagation step, as multiplication of large derivatives, which spikes the gradients. Furthermore, despite the convex loss landscape (Fig. S9), our choice of activation function for the encoder prediction head also stabilizes gradients. A modified hyperbolic tangent41 softly constrains the encoder output, which prevents arbitrary predictions while simultaneously discouraging the vanishing gradients of more restrictive activation functions such as the symmetric sigmoid hyperbolic tangent, piecewise hard tanh, and standard logistic functions. Thus, the decoder likely plays a similar role in regularizing the learned features by the encoder, as suggested by the evident denoising of the input image by the full autoencoder (Fig. 1a). By disproportionately heavily weighing the physics component of the loss function (See Methods, Model architecture and training) against the decoder component, the encoder output is still majority governed by the forward scattering model. Additionally, extreme sensitivity to the learning rate during training supports the case for adding a decoder (trained at a lower learning rate than the encoder), as the range of viable learning rates is very narrow even with a decoder.
DONUT significantly improves the computational efficiency of analyzing SXDM data compared to conventional methods. Using a single NVIDIA GeForce RTX 3090 GPU, the conventional correlation fitting analysis requires 5.6 ± 0.4 ms per frame, where each frame is 64 × 64 pixels in single-precision floating-point format (32 bits). The computation time scales linearly with the number of data points, and the bottleneck is memory, not including the time required to generate a simulated diffraction library (also scales linearly with the number of parameter combinations). Inference by the DONUT encoder, conversely, takes 0.024 ± 0.001 ms, over 230 times faster than conventional analysis using the same GPU hardware and comparable to the 0.019 ± 0.001 ms previously reported for NanobeamNN, the supervised deep learning approach. On CPU, the DONUT encoder predicts structural parameters from diffraction data at a rate of 0.27 ± 0.07 ms per frame, more than fast enough to keep up with the maximum detector acquisition rate of 1 kHz without overhead. Thus, the proposed experimental analysis workflow outlined in Fig. 4b allows for local inference on CPU by the encoder and simultaneous training of the full model on GPU, constantly updating the model with the most recent data while offloading costly backpropagation to separate hardware and preventing data transfer bottlenecks. Although NanobeamNN has 20% faster inference and roughly 75% faster training than DONUT, NanobeamNN requires pre-simulating a diffraction library, whereas DONUT may be trained on experimental data alone. This key advantage of DONUT, which trains in a self-supervised manner, allows for more flexible extension to additional prediction parameters, such as in the case of film thickness, as shown in Fig. 4, because the model can be retrained without generating additional simulated data. Adding parameter axes to simulated data generation increases the computational time for that step exponentially, as well as increasing the model retraining time due to training dataset expansion, while DONUT may be retrained on the same experimental dataset. Therefore, DONUT offers a greater degree of data analysis customization during an SXDM experiment by combining physics-based analytical methods with deep learning-accelerated optimization, compared to both conventional methods and supervised learning.
SXDM is a powerful and widely applicable technique for imaging spatially distributed structural heterogeneity. Nevertheless, with coherent X-rays, one can study materials at higher resolutions not limited by the sizes of the probe and scanning step by ptychography42,43. Bragg reflection geometry ptychography is particularly useful for imaging strain in extended samples44,45, but the technique is limited by difficult and computationally intensive phase retrieval. Here, we briefly discuss the potential opportunities, challenges, limitations, and advantages of physics-aware ML methods for scanning probe Bragg diffraction imaging. Conventional phase retrieval for ptychography is an optimization problem with several constraints, including overlapping of the object illumination while scanning. In the context of physics-aware ML, one could apply a similar approach to PtychoPINN16, demonstrated for transmission ptychography, with the appropriate geometric transformations necessary for reflection geometry. The probe positions are tracked and diffraction patterns batched into overlapping “mini-object” patches. Conversely, DONUT processes each diffraction frame independently without regard for real-space position. DONUT predicts one set of lattice quantities per diffraction pattern; in other words, each diffraction pattern corresponds to a single scan coordinate on an X-ray micrograph of the sample (a zero-dimensional point in space). Ptychography would require predicting amplitude and phase patches (or multiple strain/rotation values in 2D or 3D), necessitating a modified forward model with coherent summation: \(I={\left|{\mathcal{F}}\left[O(r-{r}_{i})\cdot P(r)\right]\right|}^{2}\), with the full probe illumination function \(P\) and object \(O\) at each position \(r\). This is a challenging problem, even if the probe is assumed to be constant and known. DONUT’s computational efficiency comes from avoiding FFTs by using approximate shapes of the probe and Bragg peak based on diffraction geometry and reasonable sample constraints (quasi-infinite truncated crystal). Ptychography requires full far-field propagation calculations, significantly increasing computational cost (increased memory usage and mathematical overhead of complex arithmetic operations). Furthermore, for 3D structural prediction, training and inference times would increase greatly. Therefore, we position DONUT as optimal for real-time analysis and applications where sample feature sizes do not require ptychographic resolution, leveraging its generalizability and computational efficiency. Ptychographic applications warrant dedicated framework development to address these distinct challenges.
In conclusion, this work introduces DONUT, a physics-aware unsupervised deep learning framework designed for the rapid and accurate analysis of scanning X-ray nanodiffraction microscopy data. By integrating a differentiable geometric diffraction model directly into an autoencoder architecture, DONUT successfully extracts crystal lattice strain and orientation information in real time, achieving analysis speeds significantly faster than conventional correlation fitting methods without the need for labeled training data. We demonstrate that DONUT not only matches the accuracy of traditional methodologies but also offers improved disentanglement of convoluted structural features and can be effectively trained on experimental data with customization of prediction axes or augmented with simulations for enhanced dynamic range and robustness. This approach significantly lowers the barrier to real-time feedback during complex nanodiffraction experiments, paving the way for an accelerated understanding of fundamental material properties and enabling the study of nanoscale dynamic processes across various scientific domains.
Methods
Neural network architecture and training
DONUT is a CNN-based autoencoder with a physics-informed forward model that predicts crystalline lattice information from SXDM data. The model, implemented in PyTorch, can be trained on simulated diffraction, experimental data, or a combination of both. As shown in Fig. 1b, the encoder compresses information from 2D diffraction patterns into a latent space of three components and is comprised of blocks of convolution, batch normalization, rectified linear unit (ReLU), dropout, and maximum pooling layers. These blocks are followed by a fully connected layer and modified hyperbolic tangent activation41 \(f\left(x\right)=1.7159\tanh (\tfrac{2}{3}x)\), which imposes a soft constraint on the range of values in the bottleneck layer. The bottleneck layer, or latent space representation, is passed to the decoder, which is symmetric to the encoder and acts as a regularization for the optimizer across the loss landscape. Additionally, the physics-based X-ray nanodiffraction scattering model is incorporated into the forward pass of the neural network, taking the latent space representation as input. All elements of the latent space are weighted equally for the autoencoder and scaled appropriately to sensible ranges for expected lattice values for the scattering model. Thus, the full DONUT has three final outputs: 1) the latent space tensor of input diffraction consisting of strain, in-plane lattice rotation, and out-of-plane lattice rotation elements, 2) the decoder-reconstructed image of the input (denoises the input), and 3) the simulated diffraction pattern from the physics-aware diffraction model. The loss function for training is a custom weighted MAE, specifically weighted SmoothL1Loss in PyTorch (which interpolates between L1 and L2), between the input diffraction and the latter two model output images. The final target outcome for prediction is the tensor of accurate lattice strain and orientation.
The full loss function is formulated as:
$${\rm{WMAE}}\left({x}_{i}\right)=\frac{1}{n}\mathop{\sum }\limits_{i=1}^{n}{w}_{d}\left|{x}_{i}-{D}_{{x}_{i}}\left[{E}_{\theta }\left({x}_{i}\right)\right]\right|+{w}_{f}\left|{x}_{i}-f\left[{E}_{\theta }\left({x}_{i}\right)\right]\right|$$
(1)
where \({x}_{i}\) is the input diffraction intensity, \(n\) is the number of images in the dataset, \({E}_{\theta }\) is the encoder with parameters \(\theta\), \({D}_{{x}_{i}}\) is the decoder, \(f\) is the physics-based forward model, \({w}_{d}\) is the relative weight of the decoder MAE loss (set to 1 in our implementation), and \({w}_{f}\) is the relative weight of the physics model loss (set to 5 or 9, see Figure S8c for study on effects of varying weights).
MAE loss is used over conventional mean squared error (MSE) loss because, keeping all other hyperparameters constant, the authors are unable to train DONUT to convergence with L2 (MSE) loss (Figure S8d). One possible explanation for this observation is that L2 normalizes the loss for all “features” (pixels), thereby weighing them all equally when in our case, specific features should be prioritized. Many computer vision studies empirically find that L1 (MAE) outperforms L2 loss in CNN-based models for image super-resolution, object detection, and landmark localization, because L2 is highly sensitive to noise and pixel-level outliers46. A recent study on implicit neural representations for X-ray ptychography47 also shows SmoothL1 optimizes the performance trade-offs between L1 and L2. We hypothesize that for DONUT, because the location of the donut-shaped Bragg peak within the detector (image field-of-view) is a critical feature directly corresponding to lattice tilts, SmoothL1 becomes favorable.
The training dataset of simulated diffraction patterns spans ranges of 41 images each in strain \(\varepsilon\), in-plane lattice tilt \(\omega\), and out-of-plane lattice tilt \(\chi\), for a total of 68,921 images of 64 × 64 pixels, where \(\varepsilon \in \left[-\mathrm{0.005,0.005}\right]\), \(\omega \in [-0.05^\circ ,0.05^\circ ]\), and \(\chi \in [-0.1^\circ ,0.1^\circ ]\) (appropriate values for structural heterogeneities often observed in experiments). Each simulated diffraction pattern is scaled to match experimentally measured intensities, then sampled from a Poisson distribution for realistic noise approximation. The experimental dataset consists of one scan of 165 × 165 positions across a sample, where a 128 × 128 pixel region of interest (ROI) is selected on the detector and downsampled to 64 × 64 pixels to improve the signal-to-noise ratio. The final working dataset (simulated, experimental, or combination) is randomly split into training (80%), validation (10%), and test (10%) sets. The training cycle uses the adaptive moment estimation optimizer with decoupled weight decay regularization48 (AdamW) with a learning rate of 10-4 for the global (encoder + forward model) weights and biases and a learning rate of 10-5 for the decoder parameters. These learning rate values are for DONUT trained on simulated data and require adjustment for training on experimental and combined data. A dropout ratio of 0.1 is applied to both the encoder and decoder to characterize the model error by Monte Carlo dropout (here 10% of the weights are randomly turned off in both training and testing), but dropout is not recommended in any final models for analysis due to slowing down the training process and increasing the difficulty of reaching convergence. We do not observe significant overfitting without dropout (Fig. S7b), likely due to the strong physics-based constraint from the forward scattering model. The network trains on four NVIDIA GeForce RTX 3090 GPUs for 30 epochs, which takes four hours with a batch size of 16. Alternatively, training exclusively on experimental data can be accomplished with the same hardware in 40 minutes.
Physics-based forward model
The neural network is initialized with constants pertaining to the bulk sample information (lattice constant, Bragg reflection, and film thickness) as well as the instrument parameters (photon energy, detector pixel size, sample-detector distance, and zone plate information). Model initialization also includes construction of the detector reciprocal space and zone plate coordinate systems, which are required for the diffraction simulation but remain constant for a single-angle SXDM experiment and are therefore not trainable model weights. For a detailed derivation of the diffraction geometry with a diverging beam caused by zone plate focusing optics, please refer to previous work. Briefly:
Detector coordinates: Each pixel on the 2D area detector is associated with a value of \(Q\). Coordinate matrices \(X\) and \(Y\) are created as 2D meshes, and the detector Q-space mapping is defined below, where the wavevector \(k=\frac{2\pi }{\lambda }\), \(\theta\) is the angle of the incident X-ray beam, \(\gamma\) is the angle of exit beam, \(p\) is the detector pixel size, \(R\) is the sample-detector distance, and \(\tau =k\frac{p}{R}\) is the detector pixel size in reciprocal space (theoretical reciprocal space resolution of the instrument under given conditions).
$${D}_{{Qx}}=k\left[\cos \left(\theta \right)-\cos \left(\gamma \right)\right]$$
(2)
$${D}_{{Qy}}=Y\tau$$
(3)
$${D}_{{Qz}}=k\left[\sin \left(\gamma \right)+\sin \left(\theta \right)\right]$$
(4)
Zone plate coordinates: the angular divergence in the diffracted beam created by the zone plate focusing optics is calculated as a shifting of the origin of reciprocal space (due to varying angles in the convergent incident beam), where the origin \({O}_{Q}\) is defined for each coordinate and a binary mask \({O}_{{donut}}\) sets the divergence angle boundaries according to the parameters of the optics suite. The complete formulation may be found in previous work, while here we detail a slight numerical optimization to define the zone plate effects by applying the mask at this step rather than in the final intensity function, reducing the number of dimensions in the calculation. The result, however, remains equivalent across both approaches.
$${Z}_{{Qx}}={O}_{{Qx}}(u,v)\left[{O}_{{donut}}\left(u,v\right)\right]={(o}_{{Qx},{uv}})(u,v)\,\begin{array}{c}\in \{\left(u,v\right)\left|{o}_{donut,uv}=True\right\},{Z}_{Qy}=\ldots ,{Z}_{Qz}=\ldots \end{array}$$
(5)
In this work, we introduce optimizations that not only improve upon the computational efficiency of the forward model (and thus greatly cut down on the backpropagation time49 using AD), but also provide flexibility for customization of sample-specific features. While the coordinate systems defined above are initialized with the neural network, the remainder of the physics-based diffraction model is calculated with the encoder output in every forward pass.
Diffraction intensity function: The Bragg diffraction is defined by the geometry of the crystal along each component of \(Q\). For a non-specific specular reflection, the \({Q}_{x}\) and \({Q}_{y}\) directions correspond to the lattice tilts. Due to the quasi-infinite nature of the plane of a thin film sample, the shape of the Bragg peak along those directions is approximated by very sharp Gaussian functions. The \({Q}_{z}\) direction corresponds to the direction normal to the sample surface, and the sinc function comes from diffraction by a truncated crystal. These thin-film geometry constraints allow for modeling the diffraction intensity without the use of Fourier transforms or complex arithmetic.
Define the components of the momentum transfer vector containing lattice information as meshes of masked projections on the detector (three axes in each component: mask dimension containing the zone plate effects and two detector coordinates). \(\varepsilon\), \(\omega\), and \(\chi\) are the strain, in-plane tilt, and out-of-plane tilt, respectively, scaled from the bottleneck layer of the encoder. \(c\) is the bulk out-of-plane lattice parameter in angstroms and \(l\) refers to the \(00l\) Bragg peak.
$${q}_{x}={D}_{{Qx}}+\frac{2\pi l\omega }{c\left(1+\varepsilon \right)}-{Z}_{{Qx}}$$
(6)
$${q}_{y}={D}_{{Qy}}+\frac{2\pi l\chi }{c\left(1+\varepsilon \right)}-{Z}_{{Qy}}$$
(7)
$${q}_{z}={D}_{{Qz}}-\frac{2\pi l}{c\left(1+\varepsilon \right)}-{Z}_{{Qz}}$$
(8)
Define the intensity function as the intersection between three shape functions in \(Q\) projected on the detector frame with the angular divergence of the diffracted beam, where \(m\) represents the mask axis due to the zone plate effects, and \(x\) and \(y\) are the detector coordinates.
$$I(\varepsilon ,\omega ,\chi {)}_{m,x,y}=\mathop{\sum }\limits_{m}t\cdot {\mathrm{sinc}}^{2}\left(\frac{t}{2\pi }{q}_{z}\right)\cdot {e}^{-{q}_{x}^{2}/{\sigma }_{x}^{2}}\cdot {e}^{-{q}_{y}^{2}/{\sigma }_{y}^{2}}$$
(9)
where: \(t\) is the film thickness, \({\rm{sinc}}\left(x\right)=\frac{\sin (\pi x)}{\pi x}\), \({\sigma }_{x}\), \({\sigma }_{y}\) control the width of the Bragg peak in \({Q}_{x}\), \({Q}_{y}\), respectively, and thus also serve as a proxy for the crystalline quality of the sample. For a highly crystalline, in-plane isotropic thin film: \({\sigma }_{x}={\sigma }_{y}\approx \frac{\tau }{10}\).
Automatic differentiation
Differentiation is essential in ML because it provides the mechanism by which models learn. Computing gradients of the loss function with respect to model parameters enables optimization algorithms to iteratively adjust those parameters to minimize error and improve predictive performance. AD computes precise derivatives through computational graphs and the systematic application of the chain rule, and is implemented in ML libraries, including TensorFlow, PyTorch, and JAX. Nonetheless, the smoothness and differentiability of the functions involved significantly affect their effectiveness50,51. Smooth, continuously differentiable functions facilitate stable, accurate, and efficient gradient computations, allowing for reliable convergence during optimization. In contrast, using piecewise functions may introduce non-differentiable points or sharp transitions. One of the key differences between the simulated data generation method reported in the supervised deep learning approach to SXDM analysis and the forward scattering model employed by DONUT lies in the differentiability of the 3D Bragg intensity formulation. The previously reported simulation treats the two dimensions of the Bragg peak relating to the extended plane of the thin film as a 2D rectangle function along \({Q}_{x}\) and \({Q}_{y}\). This comes from the theoretical representation of an infinite crystal in reciprocal space, where the diffraction should be an infinitely sharp Dirac delta function. A real epitaxial thin film is not a perfect infinite crystal, but the lattice is sufficiently ordered at the length scale of the X-ray probe size to approximate the local diffraction as a tightly bound box of intensity. Practically, this means that two piecewise absolute value functions, which are not differentiable at the boundaries, constrain the Bragg peak in \({Q}_{x}\) and \({Q}_{y}\) within a sharp rectangle propagated along the \({Q}_{z}\) axis into a prism. While this is irrelevant to the supervised approach and does not affect the computational efficiency of the forward pass, backpropagation becomes significantly slower in self-supervised learning, where the X-ray scattering model is incorporated into the neural network architecture. Thus, the forward model in DONUT approximates the Bragg peak along \({Q}_{x}\) and \({Q}_{y}\) as two independent sharp Gaussian functions, which are continuously differentiable and more physics-based approximations of Bragg diffraction from a semi-infinite crystal.
Data acquisition
The experimental methods, including sample synthesis and scanning X-ray nanodiffraction microscopy data acquisition for SrIrO3 have been reported previously33.
Experimental data analysis
Experimental data is used to test the performance of DONUT against state-of-the-art conventional data analysis methods. An ROI of detector pixels is selected to encompass the entire measured diffraction peak. The pixels of this ROI are binned by aggregating each 2 × 2 pixel array into one value to improve the signal-to-noise ratio. A simulated diffraction library of patterns spanning the space of lattice quantities is generated using the physics-based forward scattering model. Each experimentally measured diffraction pattern is multiplied by each simulated diffraction pattern to form a series of correlation matrices. Projections of the correlation matrices are made along each lattice quantity axis and the highest correlation value for each parameter is obtained by a weighted sum interpolation for the center of mass of the projection.
The experimental data shown in Figs. 3 and 4 is a 10 × 10 μm2 field of view of the 002 pc Bragg peak of a 30 unit cell SrIrO3 thin film grown on (001)-terminated single-crystal (LaAlO3)0.3(SrAl0.5Ta0.5O3)0.7 (LSAT) and electrochemically cycled in 0.1 M KOH. As previously reported (cf. ref. 33, Fig. 4), the large diagonal stripes in lattice rotation are attributed to the substrate steps. The finer features present in lattice rotation and intensity modulations between the steps are likely caused by ex situ cyclic voltammetry measurements and could be due to defects or amorphization of the surface (electrocatalytically-induced surface reconstruction).
Data availability
The simulated and experimental datasets that support the findings of this study are available at this public Zenodo repository: https://doi.org/10.5281/zenodo.17586299.
Code availability
The code and trained model are available at this public GitHub repository: https://github.com/AdvancedPhotonSource/DONUT.
References
Zhang, Q. et al. Thermal fluctuations of ferroelectric nanodomains in a ferroelectric-dielectric PbTiO 3/SrTiO 3 superlattice. Phys. Rev. Lett. 118, 097601 (2017).
Hruszkewycz, S. O. et al. Imaging local polarization in ferroelectric thin films by coherent X-ray Bragg projection ptychography. Phys. Rev. Lett. 110, 177601 (2013).
Luo, Y. et al. Spatially heterogeneous chlorine incorporation in organic–inorganic perovskite solar cells. Chem. Mater. 28, 6536–6543 (2016).
Correa-Baena, J.-P. et al. Homogenized halides and alkali cation segregation in alloyed organic-inorganic perovskites. Science 363, 627–631 (2019).
Rippy, G. et al. X-ray nanodiffraction studies of ionically controlled nanoscale phase separation in cobaltites. Phys. Rev. Mater. 3, 082001 (2019).
Roy, P. et al. Origin of topological hall-like feature in epitaxial SrRuO3 thin films. Adv. Electron. Mater. 9, 2300020 (2023).
Shao, Z. et al. X-ray nanoimaging of a heterogeneous structural phase transition in V2O3. Nano Lett. 25, 1466–1472 (2025).
Gorobtsov, O. Y. et al. Spontaneous supercrystal formation during a strain-engineered metal–insulator transition. Adv. Mater. 36, 2403873 (2024).
Godard, P. et al. Three-dimensional high-resolution quantitative microscopy of extended crystals. Nat. Commun. 2, 568 (2011).
Hruszkewycz, S. O. et al. Quantitative nanoscale imaging of lattice distortions in epitaxial semiconductor heterostructures using nanofocused X-ray Bragg projection ptychography. Nano Lett. 12, 5148–5154 (2012).
Cherukara, M. J., Nashed, Y. S. G. & Harder, R. J. Real-time coherent diffraction inversion using deep generative networks. Sci. Rep. 8, 16520 (2018).
Cherukara, M. J. et al. AI-enabled high-resolution scanning coherent diffraction imaging. Appl. Phys. Lett. 117, 044103 (2020).
Kim, J. W., Cherukara, M. J., Tripathi, A., Jiang, Z. & Wang, J. Inversion of coherent surface scattering images via deep learning network. Appl. Phys. Lett. 119, 191601 (2021).
Yuan, R., Zhang, J., He, L. & Zuo, J.-M. Training artificial neural networks for precision orientation and strain mapping using 4D electron diffraction datasets. Ultramicroscopy 231, 113256 (2021).
Yao, Y. et al. AutoPhaseNN: unsupervised physics-aware deep learning of 3D nanoscale Bragg coherent diffraction imaging. npj Comput. Mater. 8, 124 (2022).
Hoidn, O., Mishra, A. A. & Mehta, A. Physics constrained unsupervised deep learning for rapid, high resolution scanning coherent diffraction reconstruction. Sci. Rep. 13, 22789 (2023).
Li, F. et al. Physics-informed deep neural network reconstruction framework for propagation-based x ray phase-contrast computed tomography with sparse-view projections. Opt. Lett. 47, 4259 (2022).
Horwath, J. P. et al. AI-NERD: elucidation of relaxation dynamics beyond equilibrium through AI-informed X-ray photon correlation spectroscopy. Nat. Commun. 15, 5945 (2024).
Baydin, A. G., Pearlmutter, B. A., Radul, A. A. & Siskind, J. M. Automatic differentiation in machine learning: a survey. J. Mach. Learn. Res. 18, 1–43 (2018).
Chen, N., Brady, D. J. & Lam, E. Y. Differentiable Imaging: Progress, Challenges, and Outlook. Adv. Devices Instrum 6, 0117 (2025).
Du, M. et al. Adorym: a multi-platform generic X-ray image reconstruction framework based on automatic differentiation. Opt. Express 29, 10000 (2021).
Zhou, T. et al. Extending the Takagi-Taupin equations for x-ray nanobeam Bragg coherent diffraction. Phys. Rev. B 110, 054116 (2024).
Le Cun, Y. & Fogelman-Soulié, F. Modèles connexionnistes de l’apprentissage. Intellectica Rev. Assoc. Pour Rech. Cogn. 2, 114–143 (1987).
Hinton, G. E. & Salakhutdinov, R. R. Reducing the dimensionality of data with neural networks. Science 313, 504–507 (2006).
Gondara, L. Medical Image Denoising Using Convolutional Denoising Autoencoders. in 2016 IEEE 16th International Conference on Data Mining Workshops (ICDMW) 241–246 (IEEE, Barcelona, Spain, 2016). https://doi.org/10.1109/ICDMW.2016.0041.
Chen, Z., Yeo, C. K., Lee, B. S. & Lau, C. T. Autoencoder-based network anomaly detection. in 2018 Wireless Telecommunications Symposium (WTS) 1–5 (IEEE, 2018). https://doi.org/10.1109/WTS.2018.8363930.
Hu, Y., Olsen, A., Funke, J., Turaga, S. & Ganapati, V. Physics-Informed Variational Autoencoder for Undersampled Fourier Ptychography. in Imaging and Applied Optics Congress 2022 (3D, AOA, COSI, ISA, pcAOP) CF1D.8 (Optica Publishing Group, 2022). https://doi.org/10.1364/COSI.2022.CF1D.8.
McEvoy, L., Tafone, D., Sua, Y. M. & Huang, Y. Physics-informed masked autoencoder for active sparse imaging. Sci. Rep. 14, 20078 (2024).
Ahmad, Z. et al. Enhanced Confocal Laser Scanning Microscopy with Adaptive Physics Informed Deep Autoencoders. Preprint at https://doi.org/10.48550/ARXIV.2501.14709 (2025).
Biswas, A., Ziatdinov, M. & Kalinin, S. V. Combining variational autoencoders and physical bias for improved microscopy data analysis∗. Mach. Learn. Sci. Technol. 4, 045004 (2023).
Zheng, H. et al. Heterogeneous field response of hierarchical polar laminates in relaxor ferroelectrics. Science 384, 1447–1452 (2024).
Luo, A., Zhou, T., Holt, M. V., Singer, A. & Cherukara, M. J. Deep learning of structural morphology imaged by scanning X-ray diffraction microscopy. Sci. Rep. 15, 21736 (2025).
Luo, A. et al. X-ray nano-imaging of defects in thin film catalysts via cluster analysis. Appl. Phys. Lett. 121, 153904 (2022).
Gal, Y. & Ghahramani, Z. Dropout as a Bayesian approximation: representing model uncertainty in deep learning. in Proceedings of the 33rd International Conference on International Conference on Machine Learning - Volume 48 1050–1059 (JMLR, 2016).
Tolubayev, K., Zhautikov, B., Zobnin, N., Dairbekova, G. & Kabiyeva, S. Kinetics of thickness growth of silicon films during pulsed magnetron sputtering using the Caroline D12C system. Condens. Matter 10, 19 (2025).
Liu, H. Growth Kinetics of Thin Film Epitaxy. in 21st Century Surface Science - a Handbook (eds Pham, P., Goel, P., Kumar, S. & Yadav, K.) (IntechOpen, 2020). https://doi.org/10.5772/intechopen.91224.
Braun, W. Applied RHEED. vol. 154 (Springer, 1999).
Zhang, C., Bengio, S., Hardt, M., Recht, B. & Vinyals, O. Understanding deep learning (still) requires rethinking generalization. Commun. ACM 64, 107–115 (2021).
Ma, W., Papadakis, M., Tsakmalis, A., Cordy, M. & Traon, Y. L. Test Selection for Deep Learning Systems. ACM Trans. Softw. Eng. Methodol. 30, 1–22 (2021).
Babu, A. V. et al. Deep learning at the edge enables real-time streaming ptychographic imaging. Nat. Commun. 14, 7059 (2023).
LeCun, Y. A., Bottou, L., Orr, G. B. & Müller, K.-R. Efficient BackProp. in Neural Networks: Tricks of the Trade (eds Montavon, G., Orr, G. B. & Müller, K.-R.) vol. 7700 9–48 (Springer, 2012).
Guizar-Sicairos, M. et al. Role of the illumination spatial-frequency spectrum for ptychography. Phys. Rev. B 86, 100103 (2012).
Miao, J. Computational microscopy with coherent diffractive imaging and ptychography. Nature 637, 281–295 (2025).
Kim, C. et al. Three-dimensional imaging of phase ordering in an Fe-Al alloy by Bragg ptychography. Phys. Rev. Lett. 121, 256101 (2018).
Hruszkewycz, S. O. et al. High-resolution three-dimensional structural microscomean absolute errorpy by single-angle Bragg ptychography. Nat. Mater. 16, 244–251 (2017).
Feng, Z.-H., Kittler, J., Awais, M. & Wu, X.-J. Rectified wing loss for efficient and robust facial landmark localisation with convolutional neural networks. Int. J. Comput. Vis. 128, 2126–2145 (2020).
Li, T. et al. Learning neural representations for X-ray ptychography reconstruction with unknown probes. Preprint at https://doi.org/10.48550/arXiv.2509.04402 (2025).
Loshchilov, I. & Hutter, F. Decoupled weight decay regularization. in International Conference on Learning Representations (ICLR, 2019).
Griewank, A. & Walther, A. Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, Second Edition. (Society for Industrial and Applied Mathematics, 2008). https://doi.org/10.1137/1.9780898717761.
Lee, W., Yu, H., Rival, X. & Yang, H. On Correctness of Automatic Differentiation for Non-Differentiable Functions. in Advances in Neural Information Processing Systems (eds Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M. F. & Lin, H.) vol. 33 6719–6730 (Curran Associates, Inc., 2020).
Bolte, J., Boustany, R., Pauwels, E. & Pesquet-Popescu, B. On the complexity of nonsmooth automatic differentiation. in Proc. International Conference on Learning Representations (ICLR, 2023).
Acknowledgements
This work is supported by the U.S. Department of Energy, Office of Science, Advanced Scientific Computing Research and Basic Energy Sciences award X-ray Scientific Center for Optimization, Prediction, and Experimentation (XSCOPE), under Contract No. DE-AC02-06CH11357. This work was also supported by the U.S. Department of Energy, Office of Science, Office of Workforce Development for Teachers and Scientists, Office of Science Graduate Student Research (SCGSR) program. The SCGSR program is administered by the Oak Ridge Institute for Science and Education for the DOE under contract number DE-SC0014664. A.S. acknowledges the support by the U.S. Department of Energy, Office of Science, Office of Basic Energy Sciences (Contract No. DE-SC0019414). M.J.C also acknowledge support from the U.S. Department of Energy, Office of Science, Office of Basic Energy Sciences Data, Artificial Intelligence, and ML at DOE Scientific User Facilities program under Award Number 34532. We gratefully acknowledge the computing resources provided and operated by the Joint Laboratory for System Evaluation (JLSE) at Argonne National Laboratory. Work performed at the Center for Nanoscale Materials and Advanced Photon Source, both U.S. Department of Energy Office of Science User Facilities, was supported by the U.S. DOE, Office of Basic Energy Sciences, under Contract No. DE-AC02-06CH11357.
Author information
Authors and Affiliations
Advanced Photon Source, Argonne National Laboratory, Lemont, IL, USA
Aileen Luo, Ming Du & Mathew J. Cherukara
Department of Materials Science and Engineering, Cornell University, Ithaca, NY, USA
Aileen Luo & Andrej Singer
Center for Nanoscale Materials, Argonne National Laboratory, Lemont, IL, USA
Tao Zhou & Martin V. Holt
Authors
- Aileen Luo
- Tao Zhou
- Ming Du
- Martin V. Holt
- Andrej Singer
- Mathew J. Cherukara
Contributions
A.L. designed the neural network architecture, performed network training and testing, adapted the simulations to experimental conditions, analyzed the data, and expanded the simulations and neural network to additional parameter axes, with advice from M.D., T.Z., A.S., and M.J.C. T.Z. and M.V.H. developed the original simulation and correlation fitting method. A.L., T.Z., A.S., and M.J.C. contributed to the proposal of the initial idea. All authors contributed to the manuscript writing.
Corresponding authors
Correspondence to Aileen Luo, Andrej Singer or Mathew J. Cherukara.
Ethics declarations
Competing interests
The authors declare no competing interests.
Additional information
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Luo, A., Zhou, T., Du, M. et al. DONUT: physics-aware machine learning for real-time X-ray nanodiffraction analysis. npj Comput Mater 11, 380 (2025). https://doi.org/10.1038/s41524-025-01860-7
Received: 18 July 2025
Accepted: 03 November 2025
Published: 16 December 2025
Version of record: 24 December 2025
DOI: https://doi.org/10.1038/s41524-025-01860-7