# Neural network determination of crystallite size and microstrain from X-ray powder diffraction data

Arthur Souesme, René Guinebretière, O Castelnau, Alexandre Boulle

<figure><img src="image_1.png" /></figure>

To cite this version:

Arthur Souesme, René Guinebretière, O Castelnau, Alexandre Boulle. Neural network determination of crystallite size and microstrain from X-ray powder diffraction data. 2025. hal-05393627

HAL Id: hal-05393627

https://hal.science/hal-05393627v1

Preprint submitted on 2 Dec 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.
Neural network determination of crystallite size and microstrain
from X-ray powder diffraction data

A. Souesme<sup>a</sup>, R. Guinebretière<sup>a</sup>, O. Castelnau<sup>b</sup>, A. Boulle<sup>a</sup>

<sup>a</sup> Institut de Recherche sur les Céramiques, CNRS UMR7315, Université de Limoges, Limoges, France.

<sup>b</sup> Procédés et Ingénierie en Mécanique et Matériaux, CNRS UMR 8006, École Nationale Supérieure des Arts et Métiers, Paris, France.

**Abstract** The present work sets out the development of a convolutional neural network (CNN) dedicated to the determination of crystallite size and microstrain in polycrystalline materials, from powder X-ray diffraction (XRD) data. The CNN was trained using synthetic data generated with a dedicated code based on the GSAS-II software. We employ the example of monoclinic ZrO₂ to critically examine the theoretical performances of the CNN. The accuracy of the predictions was systematically investigated within a crystallite size range of 5 – 1000 nm and a microstrain range of 0.05-2%. In this context, the role of the resolution of the diffractometer and the XRD peak profile shape is discussed in details. For instance, on a low-resolution laboratory diffractometer it is possible to determine the crystallite size within a 5–100 nm with 99.7% accuracy in the absence of microstrain, and 97.3% accuracy when microstrains are present. Higher accuracies are obtained with a high-resolution diffractometer and over an extended range of size and microstrain. The potential of the CNN is demonstrated by the analysis of the crystallite size and microstrains in MgAl₂O₄ formed by a solid-state reaction between MgO and Al₂O₃ using *in situ* XRD at 1200 °C at the BM01 beamline at the ESRF. The CNN can determine the crystallite size and microstrain in 0.004 s per diagram, with values in remarkable agreement with those obtained by a conventional Rietveld refinement. We further demonstrate that the same training dataset can be used for other regression problems, for instance phase fraction quantification, with no additional computational cost and only minor modifications to the network architecture. This work paves the way for real-time data analysis at synchrotron facilities.

**Keywords:** Neural networks, X-ray diffraction, crystallite size, microstrain, microstructure
# 1. Introduction

In the seminal article published in 1918, Scherrer (1918) derived the equation, that now bears his name, establishing that the width of the X-ray diffraction (XRD) peaks is inversely proportional to the average size of crystalline domains. This work laid the foundations for all subsequent studies aiming at characterizing the microstructure of materials by means of powder XRD; an approach also known as line profile analysis. A significant advancement was achieved by Stokes and Wilson (Stokes & Wilson, 1944) who demonstrated that heterogeneous strains, also referred to as microstrain, also contribute to peak broadening, though with a different angular dependence. This differential angular dependence was exploited by Hall and Williamson (Hall, 1949; Williamson & Hall, 1953) to separate the effects of size and microstrain broadening. This fundamental property underlies the implementation of microstructural analysis in most, if not all, Rietveld (1969) refinement programs. Despite some important underpinning assumptions, which will be briefly discussed in the next section, and despite the existence of more rigorous approaches to modelling XRD patterns (Scardi & Leoni, 2002), Rietveld refinement (RR) remains the de facto standard for line profile analysis using powder XRD.

The development of fourth-generation synchrotron radiation (SR) sources and X-ray free electron lasers, coupled with the development of fast, large-area X-ray detectors, creates a wealth of opportunities for *in situ* and *operando* characterisations of dynamic processes in materials (phase transitions, thermal expansions, strains, fatigue and local compositional fluctuations), under different external stimuli (temperature, pressure, mechanical loading, electric or magnetic fields, etc.). These dynamic experiments generate very large datasets, up to several TB per day per beamline (Wang *et al.*, 2016), at rates that far exceed the capacity of researchers to process them manually. For example, an experienced scientist can perform a RR in a few minutes. But even in such a favourable case, handling several hundreds or thousands of XRD patterns restricts the timely interpretation of data. Furthermore, this precludes the possibility of real-time data analysis, which would be highly desirable, particularly in the context of *in situ* and *operando* measurements, where adaptive decision-making during experiments is essential.

In this context, machine learning algorithms, and in particular those based on multilayered artificial neural networks (NNs), i.e. deep learning (DL), have emerged as efficient tools to process large datasets and extract meaningful structural insights in an automated way. The use of NNs to analyse XRD is not a new idea *per se*. The first applications of NNs applied to XRD data can actually be traced back to the mid-1990s and the early 2000s with focus on phase identification (Garcia *et al.*, 1994; Tatlier, 2011; Sozeri *et al.*, 2011; Campi *et al.*, 2013; Woinaroschy *et al.*, 2000), phase quantification (Griffen, 1999; Okumura *et al.*, 2006), lattice parameter determination (Habershon *et al.*, 2004), strain profile determination (Glorieux & Zolotoyabko, 2001; Dilanian *et al.*, 2006) and data classification (Berntson *et al.*, 2003; Becker & Streit, 2014; Wang *et al.*, 2016). The recent proliferation of XRD studies incorporating DL algorithms has been made possible by the advent of
user-friendly Python libraries, namely TensorFlow (https://www.tensorflow.org) and PyTorch (https://pytorch.org/) first released in 2015 and 2017, respectively. Since then, focusing solely on powder XRD, the potential of NNs (mainly convolutional neural networks, CNNs) has been clearly demonstrated for different applications such as:

* crystalline system and space group identification (Park et al., 2017; Ziletti et al., 2018; Garcia-Cardona et al., 2019; Oviedo et al., 2019; Sun et al., 2019; Vecsei et al., 2019; Zaloga et al., 2020; Chakraborty & Sharma, 2022; Lee et al., 2022; Lolla et al., 2022; Corriero et al., 2023; Salgado et al., 2023; Chen et al., 2024; Ozaki et al., 2025; Wang et al., 2025),

* phase identification (Wang et al., 2020; Lee et al., 2020; Schuetzke et al., 2021; Szymanski et al., 2021; Massuyeau et al., 2022; Strohmann et al., 2023; Szymanski et al., 2023, 2024),

* material discovery (Maffettone et al., 2020; Banko et al., 2021; Schuetzke et al., 2023),

* phase quantification (Lee et al., 2021; Dong et al., 2021; Poline et al., 2024; Simonnet et al., 2024; Yue et al., 2024),

* lattice parameter determination (Chitturi et al., 2021; Dong et al., 2021; Gómez-Peralta et al., 2023, 2025),

* and structure determination (Riesel et al., 2024; Guo et al., 2024, 2025; Li et al., 2025).

The first studies addressing the case of crystallite size quantification have been published by Dong et al. (2021) and Allara et al. (2024). While successful and promising, these studies were restricted to a rather narrow range of crystallite sizes (2-50 nm and 2-10 nm, respectively) and the effect of microstrain broadening was not discussed, although microstrains are ubiquitous in materials.

In this work we aim to fill this gap by developing a NN that can determine both the crystallite size and the microstrain, across the widest range that can be detected in a diffraction pattern, when accounting for the limitations associated with the resolution of the diffractometer. To achieve this goal, we trained our NN using synthetic data, which is a common practice in similar published studies. What sets our neural network and data generation procedure apart is their versatility in tackling different types of problems. They have been designed with reusability in mind: it should be fast and reliable to generate a new dataset adapted to a different diffractometer or to different materials, and to train the NN accordingly. Moreover, although our focus is on crystallite size and microstrain, the same dataset can be used for other regression problems, such as lattice parameter determination or phase fraction quantification, with no additional computational cost and only minor modifications to the network architecture, as we will demonstrate below.

The article is organized as follows. The exact meaning of “crystallite size” and “microstrain”, and the associated necessary background, will be recalled in section 2. Details regarding data generation and the NN architecture (and training procedure) will be given in section 2 and 3, respectively. In section 4, we will investigate the theoretical performances of the NN with the example of synthetic diffraction patterns of monoclinic ZrO₂. Finally, in section 5, to demonstrate the capabilities of the NN in real
and complex situations, we will study the high temperature formation of MgAl₂O₄ by solid state reaction between MgO and Al₂O₃. It will be shown that the analysis performed by the NN is almost instantaneous, requiring only ~0.004 seconds for a single XRD pattern to determine the crystallite size, the microstrain as well as the phase fraction. This achievement paves the way for real-time microstructural analysis with XRD.

## 2. Generation of training data

One reason for NNs success in image and data analysis is their ability to interpolate in very high-dimensional spaces. For example, determining the crystallite size and microstrain from an XRD pattern with 10⁴ data points, involves finding a function (the NN) that maps a 10⁴ – dimensional space onto a 2 – dimensional one. The generalisation capabilities of a NN are therefore entirely dependent on the diversity of the data used for training, with more diverse data resulting in more effective generalisation. As the generation of data represents the most time-consuming step of the study, there is a clear interest in generating datasets that can serve multiple purposes. For instance, the same dataset could be used for size and microstrain determination, as well as for the determination of lattice parameters or the quantification of phase fractions. This also implies that the diversity of the training dataset must be achieved under physically realistic conditions, excluding any *a posteriori* alteration of the data like peak removal or addition, arbitrary peak shifting, random intensity modification, etc.

With this in mind, we developed an XRD data generation program based on the crystallography software GSAS II (Toby & Von Dreele, 2013). Using a well-established simulation software has the advantage that data generation is based on complete, optimised and well-tested algorithms. Such an approach has been used in other studies as well, using GSAS II (Garcia-Cardona et al., 2019), TOPAS (Schuetzke et al., 2021; Lolla et al., 2022; Gómez-Peralta et al., 2025) or HighScore (Oviedo et al., 2019).

In Rietveld simulation programs, the effects of crystallite size and microstrain are described via their influence on the XRD peak width and shape. Since the NNs developed in this study are trained using data generated with a Rietveld algorithm, they rely on the same hypothesis. This is the reason why the following section is dedicated to a concise review of the principles underpinning microstructural analysis using the width of XRD peaks. In doing so we will also clearly recall the meaning of the terms “crystallite size” and “microstrain”. For further details the reader can refer to dedicated textbooks (Snyder et al., 2000; Mittemeijer & Scardi, 2011). It is also worth mentioning that we restrict ourselves to approaches based on the analysis of the breadth and shape of the XRD profile, since these are the approaches implemented in most Rietveld refinement programs. Other, equally important approaches, such as those based on a Fourier analysis of the peaks (Bertaut, 1949; Warren & Averbach, 1950) or on the variance of the peaks (Wilson, 1962), will not be discussed.
## 2.1. Background on size and microstrain determination using XRD

### 2.1.1. Size broadening

Scherrer (1918) first established that the width of the XRD peaks is related to the “X-ray crystallite size”, $\tau$, according to (Snyder, 1993)<fnref n="1" />:

$$ \beta_{\tau} = \frac{\lambda}{\tau \cos \theta}, \\ \text{or } \beta_{\tau}^{*} = \frac{1}{\tau} \qquad (1) $$

where $\theta$ is half the scattering angle, $\beta_{\tau}$ is the integral breadth (in radians) of the XRD peak, corrected for the broadening induced by the diffractometer. $\beta_{\tau}^*$ is the integral breadth expressed in reciprocal space (in Å⁻<fnref n="1" />). In its initial formulation, Scherrer used the full-width at half-maximum (FWHM) $\Gamma$ of the peak, which led the equation to include the term $2\sqrt{(\ln 2)/\pi} \approx 0.939$, which correspond to the $\Gamma/\beta$ ratio of a Gaussian function. Note that this factor assumes that the XRD peak profile is Gaussian, which is unlikely to occur in practice. It should also be noted that this factor is not the Scherrer constant, $K$, which was introduced later to convert to a “true” size, defined as the cube root of the crystallite volume (Langford & Wilson, 1978). Despite its name, $K$ is not a constant and it varies between 1 and 1.4 (i.e., a 40% variation) depending on the actual shape of the crystallites and the crystallographic direction. The concept of true size, as defined earlier, is of little practical use; it is usually preferable to use the “volume-weighted average column length” (Krill & Birringer, 1998). Here, the column length, $L$, is the thickness of the crystal measured through a point in the direction parallel to the diffraction vector (Langford & Wilson, 1978), and the average is taken over the crystallite shape and the size distribution. With this definition, the crystallite size is expressed as:

$$ \tau = \frac{\langle L^2 \rangle}{\langle L \rangle} \qquad (2) $$

Interestingly, $\tau$ can be calculated for a variety of crystal shapes and size distributions (Scardi & Leoni, 2001; Croset, 2017). In the case of spheres with diameter $D$, it can be shown that (Krill & Birringer, 1998):

$$ \tau = \frac{3 \langle D^4 \rangle}{4 \langle D^3 \rangle} \qquad (3) $$

where the average is taken over the size distribution. The ratio in equations (2) and (3) reduces to the arithmetic means $\langle L \rangle$ and $\langle D \rangle$, respectively, only if all crystallites have the same shape and size. A graphical representation of the different averages can be found in (Langford et al., 2000). The key conclusion to be drawn is that the crystallite size, as determined by XRD, does not exactly correspond to the actual size of the diffracting crystal, even in the elementary case of spheres. Moreover,

<footnote n="1">¹ We use the notation of Snyder where $\tau$ and $\varepsilon$ designate the crystallite size and the microstrain, respectively.</footnote>
structural defects that reduce the length over which diffraction is coherent (such as stacking faults, dislocation walls, etc.) also affect the measured crystallite size.

### 2.1.2. Microstrain broadening

The term microstrain is employed to denote heterogeneities of the elastic strain $e$; that is, fluctuations of the strain around its mean value. The broadening of the XRD peak, induced by microstrain, $\epsilon$, is written as (Stokes & Wilson, 1944; Snyder, 1993):

$$ \beta_{\epsilon} = \epsilon \cdot \tan \theta, \\ \text{or } \beta_{\epsilon}^{*} = \epsilon \cdot d^{*} \qquad (4) $$

where $\beta_{\epsilon}$ is the integral breadth of the XRD peak, corrected for the broadening induced by the diffractometer, and $d^*$ is the norm of the reciprocal lattice vector. In contrast to $\tau$, which can be interpreted on the basis of geometrical crystallite shapes, $\epsilon$ depends on the atomic displacement field, due to crystalline defects distorting the crystal lattice. Assuming a Gaussian distribution of strain, Stokes & Wilson (1944) demonstrated that $\epsilon$ was connected to the standard deviation of the strain distribution via $\epsilon = \sqrt{2\pi} \langle (e - \langle e \rangle)^2 \rangle^{1/2}$. Besides the fact that a Gaussian distribution is unlikely to occur in practice, as soon as the standard deviation depends on $L$ (as defined in the previous section), $\beta_{\epsilon}$ exhibits a non-linear behaviour with respect to $d^*$ (Van Berkum et al., 1996; Balzar, 1999; Boulle et al., 2005). Moreover, anisotropic peak broadening also occurs due to the presence of extended defects such as dislocations for example (Wilkens, 1970; Ungár & Borbély, 1996). A general treatment of anisotropic strain broadening has been given by Stephens (1999). The principal conclusion to be drawn is that $\epsilon$ offers a limited quantitative insight into the actual defect structure of the material. However, relative variations of $\epsilon$ during any material transformation is relevant, and can hence be regarded as a proxy for the defect density.

### 2.1.3. Size and strain broadening

The simultaneous presence of size and microstrain effects is very common in materials; the corresponding shape of the XRD peaks is the result of the convolution of the different broadening effects (Langford, 1978). Hall and Williamson (Hall, 1949; Williamson & Hall, 1953) assumed that equations (1) and (4) could be linearly added, which implicitly supposes that the peak profiles associated with pure size and pure strain effects have a Lorentzian shape. The different dependence on $d^*$ allowed them to separate the effect of size and microstrain broadening. Instead of a simple Lorentzian or Gaussian profile shape, Langford (Langford, 1978, 1992) suggested to use the convolution of these two functions (i.e., a Voigt (1912) function) and analyse the Lorentzian and Gaussian part separately:
$$ \beta_L^* = \frac{1}{\tau_L} + \epsilon_L \cdot d^*, \qquad (5) $$

$$ \beta_G^{*2} = \frac{1}{\tau_G^2} + \epsilon_G^2 \cdot d^{*2}, $$

where the subscript G and L denote the Gaussian and Lorentzian contributions. These equations constitute the state-of-the-art of line profile analysis using the peak shape and width. They are commonly implemented in RR programs in the form a modified Caglioti polynomial (Caglioti et al., 1958) expressing the Gaussian and Lorentzian FWHMs (Thompson et al., 1987; Balzar et al., 2004):

$$ \Gamma_G^2 = (U + U_\epsilon) \tan^2 \theta + V \tan \theta + W + \frac{P_\tau}{\cos^2 \theta} \qquad (6) $$
$$ \Gamma_L = \frac{(X + X\tau)}{\cos \theta} + (Y + Y_\epsilon) \tan \theta + Z $$

where U, V, W, X, Y and Z are the contributions from the instrument to the peak width. The parameters with subscripts τ and ε are the contributions from crystallite size and microstrain, respectively, with angular dependence as defined in equations (1) and (4). The Voigt function is frequently approximated by a pseudo-Voigt function, i.e., a weighted sum of a Gaussian and a Lorentzian (Wertheim et al., 1974), which is computationally more efficient. As previously stated (Langford, 1992), there is no theoretical basis for using the Voigt (or the pseudo-Voigt) function, nor for using a Gaussian or a Lorentzian. Its widespread use is founded on the empirical observation that it generally correctly fits XRD profiles.

From the above sections, it can be noted that the determination of the crystallite size and microstrain using XRD relies on many assumptions, and it is impossible to say whether these assumptions are justified a priori. Despite this, the Rietveld method has proven immensely successful, especially for obtaining relative information about the evolution of the microstructure due to different sample preparation, varying experimental conditions or the application of external stimuli. Consequently, it is still today the de facto standard for the characterisation of the microstructure of polycrystalline materials by means of line profile analysis of XRD data.

Finally, it is important to note that all the assumptions made above can be overcome by a modelling of the XRD patterns on the basis of physical assumptions (Ungár et al., 1999; Scardi & Leoni, 2002). This approach involves the calculation of the Fourier coefficients of XRD peak profiles based on assumptions concerning the crystallite shape, crystallite size distribution and the nature of the structural defects (primarily dislocations and stacking faults). While this is arguably the most sophisticated approach to modelling XRD patterns, it necessitates a certain degree of a priori knowledge regarding the microstructure of the sample; a prerequisite that is frequently not met in material science studies. Consequently, the present study favours the utilisation of the approach implemented in the Rietveld method. Nevertheless, no fundamental incompatibility exists between
such approaches and the NN algorithm that follows, and this could constitute a potential avenue for
future research.

**2.2. Generation procedure**

NNs can contain several millions of parameters, which must be determined during the so-called
training stage. The training process can be conceptualised as an optimisation problem, wherein the
discrepancy between the output of the NN and a target value is minimised through the utilisation of a
dedicated algorithm (in general based on gradient descent). Given the considerable number of
parameters, a substantial volume of training data is necessary for the training to be effective. As
outlined earlier, this data has to be as diverse as possible, while remaining within physically realistic
bounds. Moreover, the generation of the training data must be as fast as possible, so that dedicated
NNs can be trained on demand for different materials and different XRD instruments.

As previously stated, GSAS II was employed for the generation of the data. GSAS II has a Python
application programming interface (API), a feature that facilitates seamless integration in Python
programs, without having to rely on the graphical interface. Additionally, GSAS II is available as
free/open-source software. This enabled us to make minor adjustments to the source code, in
particular eliminating some read/write operations on the hard drive. This was necessary to avoid race
conditions when running the program in parallel on multiple central processing units (CPUs). The
program, in essence, utilises one (or several) crystallographic information file(s) (CIF) as input, with
the objective of generating a large number of XRD patterns. Each pattern is calculated with a unique
set of parameters, detailed below. The range of values for each parameter is specified in a user-
supplied configuration file. Finally, the program distributes the computation over all available CPU
cores (96 in our case, using an Intel Xeon Gold 6248R processor), and stores all patterns and all
parameters in two distinct 2D arrays. Each array comprises *N* lines, where *N* is the number of patterns
generated.

We will use monoclinic ZrO₂ (space group P2₁/c) as an example material to test the performances of
the NN. Because of the monoclinic symmetry, the XRD patterns exhibit important peak overlap
which is expected to be more challenging for a NN.

The different parameters entering the model are as follows:

* Structural parameters: the lattice parameter and atomic coordinates are allowed to vary within the range of ±0.5% and ±5%, respectively. The thermal parameters (Uiso) are varying between 0 and 0.3. These ranges result from a trial and error to produce sufficient peak shifts and intensity variations.

* Microstructural parameters: the crystallite size is allowed to vary within the range [5 nm - τmax]. The performance of the NN with varying τmax will be the topic of section 4. The microstrain is allowed to vary within the range [εmin - 2%]. The role of εmin will also be discussed below. The shape parameter of the pseudo-Voigt function η (i.e., the relative
fraction of Gaussian and Lorentzian function) is allowed to vary in the [0 – 1] range. No texture is added. The choice of the lower 5 nm limit, and the upper 2% limit are arbitrary. The goal is to demonstrate the potential of the NN for a realistic range of values. The limits can be adapted depending on the needs.

* Instrument parameters: the values of U, V, W, X, Y, Z are kept constant for a given diffractometer and fixed measurement conditions (geometry of the measurement, x-ray wavelength, etc.). They are determined beforehand, using the peak widths of a LaB₆ (NIST 660c) standard reference material. Two type of configurations will be discussed: low and high resolution. The former corresponding to a standard laboratory powder diffractometer, and the latter to a powder diffraction synchrotron beamline (ESRF-BM01).

The values of all varying parameters are randomly sampled within the allowed variation range, using a uniform distribution.

Although the NN is initially trained using synthetic data, the ultimate objective is to work with real data. Therefore, it is hence imperative that the training data is as similar as possible to the actual XRD data. For this purpose, a background modelled using a tenth-order Chebyshev polynomial, is added to the computed data and the signal-to-background ratio is allowed to vary randomly in the [10³ – 10⁶] range. Finally, Poisson noise is added to all computed patterns. Each pattern must contain 10501 points because the NN architecture has been optimized with this, arbitrarily chosen, input size. For example, this corresponds to a 105° 2θ range with a step of 0.01°. The exact angular range is unimportant and depends on the wavelength of the radiation and the desired step size. The step size should be small enough to accurately depict the shape of the XRD peaks, otherwise, the performance of the CNN will deteriorate significantly. The data provided to the CNN are intensity values, stored in a one-dimensional array. An XRD pattern is therefore treated by the CNN as a one-dimensional image, with pixel values corresponding the diffracted intensities, and pixel index representing the diffraction angle.

With our hardware, the generation of 8×10⁴ patterns required 15.6 minutes. The choice of this number of patterns is discussed in section 3.2. The generation time depends on the symmetry of the material in question. Materials with lower symmetry exhibit a larger number of peaks, and as such require a greater amount of computation. For instance, the computation time for the same amount of patterns drops to 4 and 3.6 minutes for tetragonal (P4₂/nmc) and cubic (Fm$\overline{3}$m) zirconia, respectively. Typical computed XRD diagrams, for a laboratory diffractometer in Bragg-Brentano geometry and CuKα₁ wavelength, are displayed in Fig. 1. Each diagram has been generated with a maximum diffracted intensity of 10⁵ and a background level of ~200. The effect of size and strain broadening are clearly visible. Moreover, the higher angular dependence of strain broadening can also be visualized. These two features constitute the information on which the NN will rely on in order to quantify the crystallite size and the amount of microstrain. Before being fed to the NN, the XRD intensities are converted to a logarithmic scale. Section 4 explains the rationale behind the logarithmic conversion.
<figure><img src="image_2.png" /><figcaption>**Figure 1** Examples of computed XRD curves of monoclinic ZrO₂, assuming a sample (a) without size or strain broadening, (b) size broadening only and, (c) size and strain broadening. The intensity is plotted logarithmically and the curves are shifted vertically. For clarity a reduced angular range is displayed. Actual data span a 15-120° range.</figcaption></figure>

# 3. Network architecture and training

## 3.1. Architecture

“Model architecture is more an art than a science” (Chollet, 2018), and it is largely based on empirical knowledge. Nevertheless, there are a few principles of architecture that are common to most CNNs. Typically, a CNN will transform input data through successive convolutional, activation, and pooling layers (noted *l*) to produce high-level “feature maps”, which are then fed into one or more fully connected layers (also referred to as dense layers) for classification or regression.

A convolutional layer<fnref n="2" /> applies a set of learnable filters (kernels) to the input data. The input data has a length $L_{in}$, and depth $N_{in}$. The length corresponds to the number of intensity data points in the input array and the depth correspond to the number of such input arrays. For instance, in the first layers $L_{in} = 10501$ and $N_{in} = 1$. Each filter is small in spatial size (noted *K*) but spans the full depth of the input, and is swept over the input data. Formally, in the case of 1D data, if $a^{l-1}$ is the output of layer *l*-1, and $w_{k,n,m}^l$ are the weights of the *m*th filter, the output of layer *l* is (adapted from Géron (2023)):

$$a_{i,m}^l = \sigma \left( \sum_{n=0}^{N_{in}-1} \sum_{k=0}^{K-1} w_{k,n,m}^l \times a_{s \times i+k, n}^{l-1} + b_m^l \right) \quad (7)$$

A schematic representation of this equation is given in Fig. 2. In Eq. (7) the sums run over the depth of the input, i.e., all input feature maps (*n*), and all components (*k*) of each filter. *m* ranges

<footnote n="2">² Strictly speaking Eq. 7 is a cross-correlation operation, but it is universally referred to as a convolution in the deep-learning community.</footnote>
between 0 and $N_{out}-1$, where $N_{out}$ is the number of filters used. $i$ ranges between 0 and $L_{in}-1$. In the subscript $s \times i + k$, $i$ runs over the index of the input data. $s$ is the stride of the convolution, i.e., the step at which the filter is swept over the input data. A stride larger than 1 allows to downsample the data. $b_m^l$ is the bias of the $m^{th}$ filter in the $l^{th}$ layer. $\sigma$ is the activation function. Here we used the common ReLU function: $ReLU(x) = max(0, x)$.

<figure><img src="image_3.png" /></figure>

**Figure 2** Example of the application of Eq. (7) to compute the third ($i=2$) component of the $m^{th}$ output of a convolutional operation. In this fictitious example the input data size is $L_{in} = 8$, the number of input feature maps is $N_{in} = 4$, and the kernel size is $K = 3$. Only the components needed for the computations are reported in the figure. The full output is computed by swiping the filter across the input index (increasing $l$) and the operation is repeated for all filters $m$. The number of filters determines the depth of the output ($N_{out}$). The depth is represented by the stack of light grey rectangles. This convolutional operation is stacked several times in successive layers $l$. Notice that the number of filters, $N_{out}$, of layer $l$ becomes the number of feature maps, $N_{in}$, of layer $l+1$.

In general, convolutional layers are followed by a pooling layer, which aims to downsample the input data (reduce $L_{in}$) while preserving the depth. The most common is “max pooling” which selects the pixel of maximum intensity in regions given by the pool length $p$, i.e.,

$$a_{i,m}^{l} = \max_{0 \le j < p} (a_{i \times p + j, m}^{l-1}), \quad \text{for } i = 0, 1, \dots, (L_{in}/p) - 1 \qquad (8)$$

Convolutional and pooling operations are typically performed several times in successive layers $l$ to replace pixel-wise information with a set of translationally invariant features that fully characterise the input data.

Finally the feature maps are stacked together and fed into a dense layer of neurons, in which the output of each neuron of the layer $l$ is the weighted sum (plus a bias term) of the output of all neurons of the layer $l-1$. This is written by the well-known equation

$$a_i^l = \sigma \left( \sum_k w_{i,k}^l \times a_k^{l-1} + b_i^l \right) \qquad (9)$$
where $w_{i,k}^l$ and $b_i^l$ are the weights and bias of the $l^{th}$ neuron in the $i^{th}$ layer. $a_i^l$ and $a_k^{l-1}$ are the activation of the $i^{th}$ and $k^{th}$ neurons of current, $l$, and previous, $l-1$, layers, respectively.

In addition to these basic building blocks, other elements can be incorporated into the architecture of a CNN to enable the stacking of more layers and enhance its capacity for learning complex features from input data. For more details see, for instance, Goodfellow *et al.* (2016).

In the present work we started with the CNN developed in our previous work (Boulle & Debelle, 2023) and adapted the architecture to reach optimal performances with powder XRD data. The architecture of the CNN is shown in **Fig. 3**. The methodology used to optimise the architecture is briefly described in Appendix A. The CNN has been implemented using the TensorFlow library (https://www.tensorflow.org) and the computation were performed on a Nvidia RTX A6000 Graphics Processing Unit (GPU). In addition to the increased number of layers, a significant modification brought to our previous architecture is the incorporation of parallel convolution operations, the outputs of which are then added together (**Fig. 3a**). The stack of two convolutions on the right-hand side of **Fig. 3a**, with a filter size of $K = 10$ and a convolution stride of $s = 2$, results in an effective receptive field of 28 pixels<fnref n="3" />. In contrast, the effective receptive field on the left-hand side, with a single convolution with a filter size of $K = 10$ and a stride of $s = 2$, is 20 pixels. Therefore, the convolutions running in parallel are sensitive to features of different sizes. This modification allowed to significantly increase the performance of the CNN when both size and strain broadening are present. It is important to note that these stride and filter size values are optimised for a given input data size (here, 10501). Modifying the input data size implies that the CNN must be re-optimised. The influence of the number of parallel convolution blocks, the size of the fully connected layer, and the filter size on CNN performance is detailed and discussed in Appendix A. The pool size was found to have a rather weak effect and was fixed to $p = 2$. This CNN contains more than $8 \times 10^6$ parameters (weights and biases) to be determined.

<footnote n="3">³ The receptive field quantifies the size (in pixels) of the region of the input data that influences a particular activation in a given layer. It determines how much spatial information a neuron can integrate.</footnote>
<figure><img src="image_4.png" /><figcaption>**Figure 3** Architecture of the CNN. (a) detail of the parallel convolutions block: $N_{out}$, K, s and p are the number of filters, the size of the filter, the stride and the pool size, respectively. (b) the whole network consists in the repetition of six parallel convolution blocks with increasing number of filters. The resulting feature maps are stacked and fed into a dense layer, the output of which are the parameters to be determined (size, strain, phase fraction, etc.).</figcaption></figure>

## 3.2. Training

During the training phase, the weights and biases are adjusted so as to minimise the mean squared error (MSE) between the values (stored in a vector $\hat{y}$) computed by the CNN when fed with an XRD pattern, and the corresponding actual values (the ground truth, y).

$$MSE = \frac{1}{N} \sum_{i} |y_{i} - \hat{y}_{i}|^{2} \qquad (10)$$

where N is the number of patterns in the training dataset.

Training was performed using the mini-batch stochastic gradient descent algorithm with an Adam optimiser and a learning rate of $10^{-4}$ (Chollet, 2018). This last parameter determines how quickly the weights and biases are updated at each step of the gradient descent process. Values in the range $10^{-3} - 10^{-4}$ provided identical results. Two parameters were found to have a significant impact on the training procedure: the size of the dataset (N) and the batch size. The effect of these parameters on the
validation MSE and computation time for 20 independent trainings is shown in **Fig. 4**. The validation
MSE is the MSE computed using XRD data that was not used during training, *i.e.*, the *validation*
dataset. It reflects the NN's generalisation capabilities and is used to optimize the parameters of the
NN. As each training is repeated 20 times, in order to keep the calculation time reasonable, in **Fig. 4**
we consider the case of a NN that only predicts the crystallite size. More complex cases will be
discussed in sections 4 and 5.

<figure><img src="image_5.png" /><figcaption>**Figure 4** Evolution of the validation mean square error (continuous line) and the training time (dashed line) as a function of (a) the size of the dataset and, (b) the batch size. The “violins” of the MSE correspond to the histogram of values observed across 20 different trainings. The central bar is the average. The line connects the best values. A successfully trained NN should be close to the best value.</figcaption></figure>

As can be seen from **Fig. 4a**, increasing the size of the training dataset considerably improves the CNN's generalisation capabilities as attested by the steep decrease of the MSE. For a dataset size greater than ~7.5×10⁴, the MSE decreases at a very slow rate. It is also evident that increasing the dataset size increases computing time. Another key insight from **Fig. 4a** is the dispersion of the MSE across multiple CNN trainings for a given dataset size. This is illustrated by shaded “violins” representing the MSE histogram. This dispersion stems from the fact that each training is initialised
with a different set of random weights and biases. Furthermore, stochasticity is inherent in stochastic gradient descent, where data batches are randomly sampled from the training dataset to compute the gradient (see below). As can be seen, a larger dataset size ensures higher repeatability in training. To strike a balance between speed, accuracy and repeatability, all subsequent trainings, unless stated otherwise, were conducted using a dataset containing 8×10⁴ patterns. This number represents the total number of XRD diagrams generated. 10% were kept for testing and, among the remaining 7.2×10⁴ patterns, 10% were randomly selected during the training for validation (see Appendix A). As will be shown in the next section, the optimal dataset size depends on the complexity of the problem. In particular, predicting both size and strain will require a dataset of ~2×10⁶.

A similar analysis can be performed for the batch size. Rather than computing the gradient of the MSE using the entire dataset, the mini-batch approach uses only a subset of the data. A new batch is used for each parameter update. As mentioned previously, this approach introduces stochasticity during gradient descent, whereby the shape of the MSE hypersurface changes with each parameter update. This reduces the risk of the algorithm becoming trapped in a local minimum. Examining Fig. 4b shows that using a large batch size (e.g. 4096) results in training times of less than 5 minutes because the GPU is used to its full potential. However, the repeatability of the training and the final MSE are mediocre. We prioritised accuracy and repeatability over speed and selected a batch size of 32. Overall, the training time with these conditions is 11 minutes.

## 4. Theoretical performances of the neural network

Let us now focus on the prediction capabilities of the NN. Instead of the MSE, which is a global metric quantifying the learning of the NN, we use the accuracy on the predicted parameters, introduced in our earlier work (Boulle & Debelle, 2023):

$$Acc(\%) = \frac{100}{N} \sum_{i} \delta_{i} \qquad (11)$$

where $\delta_i = 1$ if $err \le err_{max}$, 0 otherwise. It corresponds to the fraction of predictions $\hat{p}$ of a given parameter $p$, that exhibit relative error, $err = |\hat{p} - p|/p$, lower than a given threshold $err_{max}$. For crystallite size and strain we selected a threshold of 10%, i.e., a parameter is correctly predicted if it deviates by less than 10% from the ground truth $p$.

### 4.1. Size or strain only

Before we discuss the complex case of determining both size and microstrain simultaneously, we will briefly address the case of XRD patterns exhibiting solely size or microstrain broadening. This allows us to introduce the concepts used to quantify the performance of the NN. The NN's performance is evaluated using the *test* dataset. This dataset contains data that has not been used for training. Moreover, unlike the validation dataset, the test dataset is not used to optimise the NN architecture or
the learning strategy. Its sole purpose is to quantify the NN's final performance. Finally, we first consider the case of a low resolution laboratory diffractometer.

**Fig. 5a** shows a plot of predicted crystallite size $\hat{\tau}$, vs. the ground truth, for the 8×10³ XRD patterns of the test dataset. In this first case, the training dataset contained XRD patterns generated assuming a crystallite size lying in the 5-100 nm range, i.e., $\tau_{max} = 100$ nm. The vast majority of the predictions lie on the $\tau = \hat{\tau}$ line indicating that most predictions are correct. Using the accuracy metric introduced above, Eq. (11), this corresponds to an accuracy of 99.7%, i.e., 99.7% of the predictions have an error of less than 10%. This excellent performance can be understood from Scherrer's equation, Eq. (1): a smaller crystallite size results in a larger broadening, meaning the NN has a large number of pixels to rely on to determine the crystallite size. This can be further confirmed by increasing the complexity of the problem. **Fig. 5b** shows a plot of predicted crystallite size vs. the ground truth for the same dataset size, but with $\tau_{max} = 1$ µm. It can be observed that the dispersion of the predictions significantly increases, in particular for the largest crystallite sizes. This effect is quantified by an accuracy reduced to 75.3%. It should be noted that **Fig. 5a** can not be obtained by zooming in the 5-100 nm region of **Fig. 5b**. In this region of **Fig. 5b** the corresponding accuracy is 73.8%: including harder to predict values degrades the overall performances of the NN.

<figure><img src="image_6.png" /></figure>

**Figure 5** Plot of predicted crystallite size vs. the ground truth of 8×10³ XRD patterns. The size prediction range is (a): 5-100 nm; (b): 5-1000 nm. The data points are coloured according to their relative error. Deep purple colour indicate relative errors larger than 10%.

In **Fig. 6a**, the evolution of the best accuracy and the dispersion across 20 different trainings is shown as a function of $\tau_{max}$. The progressive degradation of the prediction accuracy with increasing prediction range [5 nm, $\tau_{max}$] is clearly observed (red curve). Furthermore, the reliability of the prediction also decreases, as evidenced by the widening of the dispersion. Nonetheless, the NN still achieves an accuracy of 94.6% over a prediction range of 5-400 nm. As previously discussed, however, the accuracy of the prediction is reduced with larger crystallite sizes. It should be noted that there is a physical limit imposed by the resolution of the diffractometer. As soon as the crystallite size is large enough to induce negligible broadening as compared to the resolution of the diffractometer, no accurate prediction is possible. This is illustrated in **Fig. 7a** which shows computed XRD peaks, corresponding to the 11\bar{1} reflection of ZrO₂, for crystallite sizes ranging from 5 nm to 1 µm. For small
crystallite sizes, the peak is very broad, meaning that the number of pixels in the data containing information about the crystallite size is important. Conversely, for a crystallite size of 1 µm, the width of the XRD peak is very close to the diffractometer's resolution (indicated by the red curve). The only visible difference between the XRD pattern corresponding to the 1 µm crystallite size, and the resolution function is located in the profile tails. It is noteworthy that, despite this subtle difference, the NN is still able to produce correct predictions, albeit with reduced accuracy and reliability.

<figure><img src="image_7.png" /></figure>

**Figure 6** (a): evolution of the prediction accuracy on the crystallite size as a function of the upper bound of the prediction range [5 nm, τmax]. (b): evolution of the prediction accuracy on the microstrain as a function of the lower bound of the prediction range [εmin − 2%]. In both cases the x axis represents the difficulty of the task. The order of εmin is therefore reversed. In both cases the line connects the best accuracy obtained across 20 different trainings and the violins represent the histogram of accuracy values.

<figure><img src="image_8.png" /></figure>

**Figure 7** (a): evolution of computed XRD peaks corresponding to the 111 reflection of ZrO₂, with crystallite size ranging from 5 nm to 1 µm, compared to the resolution function of a typical laboratory diffractometer (red curve). (b) same as (a) but compared to the resolution function of the ESRF-BM01 beamline (orange curve). For illustration purposes, in both cases, the shape parameter of the size-induced broadening has been set to η = 1, and no counting noise has been introduced.
The only way for the NN to overcome this limit is to use data recorded from a diffractometer with a better resolution. **Fig 7b** shows the evolution of computed XRD profiles, for crystallite sizes ranging from 5 nm to 1 µm, compared with the resolution of the BM01 beamline (orange curve). Even for a 1 µm crystallite size, a clear difference is observed between the size-broadened data and the instrumental resolution. This results in better overall performances of the NN with increasing the prediction range, with an accuracy as high as 85.5% for the highest range, 5-1000 nm (**Fig. 6a**, orange curve).

Let us now consider the effect of microstrain. **Fig. 6b** shows the evolution of the prediction accuracy with increasing the prediction range [$\epsilon_{min}$ – 2%]. As might be expected, the behaviour of the NN is very similar to that observed for crystallite size: decreasing the lower bound of the microstrain range in the training data results in a degradation of accuracy and repeatability. This is because low microstrain gives rise to weak broadening (see Eq. 4), making it harder to quantify. A distinctive feature of microstrain predictions is that the overall accuracy is higher than for crystallite size predictions. Even for $\epsilon_{min}$ = 0.05%, i.e., a prediction range of 0.05-2%, the prediction accuracy is 96.5% and 98.1% in the case of the low and high resolution cases, respectively. The most likely reason for this is that microstrain broadening increases faster as a function of $\theta$ (tan $\theta$) than size broadening (1/cos $\theta$): the data provided to the NN contains more pixels with information about microstrain, hence the increased accuracy.

In **Fig. 7a** and **7b** it is important to notice that the intensity is plotted on a logarithmic scale to enhance the visibility of the broadening. This is the reason why the data is converted to a logarithmic scale before being fed to the NN. Furthermore, in machine learning it is of common practice to rescale data to avoid large values biasing the training, and to accelerate convergence. As a matter of fact, using linear intensity values result in a considerable deterioration of the NN's performance.

The most important conclusion of this section is that the data used to train the NN must be carefully adapted to the resolution of the diffractometer. Including large crystallite sizes or very low microstrains in the training data may result in unpredictable errors when analysing data recorded on a low-resolution diffractometer. With a careful training, the prediction accuracies can largely exceed 95%. Finally, it is worth mentioning that the conclusions regarding the NN's performance are valid regardless of the profile shape of the XRD peaks. The training data was generated with a full randomisation of the pseudo-Voigt shape parameters in the [0-1] range, i.e., the profile shapes can exhibit any shape between the Gaussian and Lorentzian limits.

## 4.2. Size and strain

The simultaneous presence of size and microstrain broadening is expected to be more challenging for two reasons:
* size and microstrain broadening affect each other in a similar way to how the diffractometer's resolution does. For example, a high level of microstrain will impede the NN's capability to quantify the crystallite size.

* the NN will have to be able to infer the different pixel index dependence (i.e., the angular dependence) between the broadening due to size and due to microstrain, from the raw intensity vectors.

The performance of the NN in predicting the crystallite size and microstrain is outlined in Fig. 8, where the prediction accuracies on crystallite size and microstrain are given as a function of the prediction ranges of these parameters. Before analysing this data in detail, two important remarks can be made.

Firstly, the NN is indeed capable of differentiating the effects of size and microstrain broadening. To underline the significance of this outcome, it is worth reminding that the NN only relies on intensity values. In contrast to the preceding paragraph, in which the sole contribution to the broadening was size, or microstrain, in conjunction with a *constant* instrumental resolution, the NN is capable of differentiating two distinct, and non-constant, contributions that are combined *via* a convolution operation.

Secondly, in some instances, the prediction accuracy appears to have been significantly degraded, reaching a value as low as 45.9% for the crystallite size. This is a direct consequence of the higher complexity of the problem that the NN has to solve. As will be demonstrated at the conclusion of this section, this issue can be resolved by increasing the size of the training dataset. In the following we shall nonetheless continue to utilise a dataset comprising 8×10⁴ XRD patterns, with the objective of ensuring a reasonable calculation time, since each number presented in Fig. 8 and Fig. 9 is the result of 5 different trainings. Consequently, the subsequent discourse shall centre on the progression of accuracy, as opposed to its absolute value.

Let us consider the accuracy of the predictions, starting with the crystallite size, Fig. 8a. Similarly to Fig. 6, where the accuracy was plotted as a function of $\tau_{max}$ or $\varepsilon_{min}$, Fig 7a shows the evolution of this accuracy as a function of both upper bound of the size prediction range (horizontal axis, $\tau_{max}$) and the lower bound of the microstrain prediction range (vertical axis, $\varepsilon_{min}$). The accuracies reported correspond to the best case obtained throughout 5 different trainings. The highest accuracies are observed in the first column (97.3 – 96%), which correspond to a size range of 5-100 nm. Similarly to what was observed in the previous section, the accuracy decreases when increasing the size of the prediction range, i.e., increasing $\tau_{max}$. For $\tau_{max}$ = 500 nm, the accuracies drop to 53 – 45.9%. The degraded accuracy as compared to section 4.1 is due to the competing effect of size and microstrain broadening. For a given crystallite size range, the accuracy decreases when increasing $\varepsilon_{min}$, i.e., when increasing the presence of large microstrain values. Here also, this is due to the competing effect of size and strain broadening. Nonetheless, it is possible to obtain accuracies as high as 87.9% for a
crystallite size range 5-200 nm with the presence of a large range of microstrain (0.05-2%), even with
the reduced training dataset size we are using in this section.

<figure><img src="image_9.png" /><figcaption>**Figure 8** Evolution of the accuracy of the predictions of (a) the crystallite size and (b) the microstrain, as a function of prediction ranges of each parameter.</figcaption></figure>

A symmetrical situation is obtained for the microstrain, although with overall better accuracies, **Fig. 8b**. When microstrain dominates the broadening (top line of **Fig. 8b**), which correspond to a range of microstrain value of 1-2%, the highest accuracies are obtained: 95.1 to 97.8%. Upon increasing the microstrain range to 0.05-2% (bottom line) the accuracies drop to 80.3 – 88.1%. For a given range of microstrain, the accuracy decreases when increasing the presence of size broadening, *i.e.*, lowering τmax. Nonetheless, assuming the same size range as above (5-200 nm), an accuracy as high as 84.2% can be obtained in the full range of microstrain considered in this work (0.05-2%). Overall, the accuracy on the microstrain is remarkably good, and never falls below 80%, even with the reduced dataset size we are using in this section.

As expected, determining size and microstrain simultaneously is more challenging. However, it is
worth noting that RR faces the same limitations when both effects are present. The main difference is
that, when performing an inference, the NN does not rely on least squares minimisation between a
model and the data; it makes its predictions based solely on the intensity values. Bearing this in mind, it is interesting to investigate how the NN processes data. To this end, we have trained several NNs using XRD patterns with fixed peak shapes. Following the various hypotheses that have been proposed over the last century, we will examine cases where the peak shapes are purely Gaussian or purely Lorentzian, or a mixed situation where size broadening is strictly Lorentzian and strain broadening is strictly Gaussian (De Keijser et al., 1982). The results are shown in Fig. 9.

**Fig. 9a** summarises the situation of **Fig. 8**: it represents the situation in which the XRD profiles are permitted to take on any possible shape between a Lorentzian and a Gaussian, and the numbers correspond to the global accuracy obtained by taking the quadratic average of the size and microstrain accuracies. The best accuracy is 95.5% (top left, maximum microstrain and size broadening), while the worst is 72.7% (bottom right, minimum microstrain and size broadening). A considerable increase in accuracy is achieved when variability in peak shapes is suppressed. For a purely Gaussian function, the accuracies increase to 99.5% and 89.2% (see **Fig. 9b**). For Lorentzian profiles, the accuracy increases further to 99.7% and 96% (**Fig. 9c**). This difference is most likely due to the fact that the XRD peak profile decreases as $exp(-x^2)$ for the Gaussian profile, vs. $x^{-2}$ for the Lorentzian profiles, i.e., the number of pixels carrying information regarding broadening is larger for a Lorentzian function as compared to a Gaussian. In other words, there is more information for the NN to rely on. Finally, in the mixed case (**Fig. 9d**), the accuracy reaches values as high as 99.8% and 96.1%. This indicates that the NN efficiently exploits the difference in intensity (i.e., pixel value) distribution between the Gaussian and Lorentzian shapes to improve its ability to discriminate between size and microstrain broadening. While this analysis is of little practical use because actual XRD profiles are never purely Lorentzian or Gaussian, it allows us to gain insight into the internal functioning of the NN. This is important for guiding the generation of training data, taking into account the diffractometer used to record the data and the expected characteristics of the materials under study.

To conclude this section, we shall return to **Fig. 8**, where disappointing accuracies were obtained for the size predictions, when both size and strain are present. Let us consider the case of the largest possible prediction ranges considered in this figure, namely [5 – 500 nm] and [0.05 – 2%], for the crystallite size and microstrain, respectively. Since two, highly intertwined, parameters are to be determined from the data, it is not surprising that the performances are degraded. A straightforward way to solve this issue is to expose the NN to a higher amount of training data, i.e., increasing the dataset size. **Fig. 10** show the evolution of the accuracy on the size and microstrain predictions as a function of the dataset size, up to $4×10^6$ XRD patterns. As already observed in **Fig. 4** for the MSE, increasing the dataset size results in a continuous improvement of the NN’s performance. However, this comes at a considerable cost in terms of training time. Selecting a dataset size of $2×10^6$ XRD patterns requires 7.5 hours to generate the data and 5.9 hours for the training. While significantly longer than the situation with $8×10^4$ patterns (15.6 minutes for data generation and 11 minutes for the training), this configuration results in a NN that will operate with the best possible performances on the widest possible range of size and microstrain values. With this dataset the accuracy on size and
microstrain are 76.9% and 93.6% (vs. 53% and 88% in Fig. 8). However, if any *a priori* information
is available regarding the microstructure of the samples, as for instance a range of possible crystallite
size obtained by electron microscopy, it can be put to good use to reduce the computing time.

<figure><img src="image_10.png" /></figure>

<figure><img src="image_11.png" /></figure>

<figure><img src="image_12.png" /></figure>

<figure><img src="image_13.png" /><figcaption>**Figure 9** Evolution of the global accuracy of the NN's predictions as a function of the size and microstrain prediction ranges. (a): the profiles are pseudo-Voigt with a random shape parameters. (b): the profiles are purely Gaussian. (c): the profiles are purely Lorentzian. (d): the size broadening is Lorentzian and the microstrain broadening is Gaussian.</figcaption></figure>
<figure><img src="image_14.png" /><figcaption>**Figure 10** Evolution of the accuracy of the size and microstrain predictions and of the computation time, as a function of the size of the training dataset.</figcaption></figure>

**5. Application to the in situ characterization of the formation of MgAl₂O₄**

In order to demonstrate the prediction capabilities of the NN on real experimental data, we investigate the case of the formation of MgAl₂O₄ by solid state reaction between MgO and α-Al₂O₃. XRD measurements were performed in situ at the BM01 beamline at the ESRF, at a wavelength of 0.71724 Å (17.28 keV). The initial powders were placed in a sapphire capillary and heated at 1200 degrees. An XRD pattern was recorded every 5.8 minutes; each pattern requiring 60 seconds counting time. Overall, 126 diagrams were recorded. The objective of the measurement is to quantify the formation and growth kinetic of MgAl₂O₄, which requires the determination of both the crystallite size and the phase fraction as a function of time. In the XRD pattern measured shortly after the specimen heating, the intensity of MgAl₂O₄ is very weak (~ 0.04 and 0.09× lower than MgO or Al₂O₃) which make line profile analysis challenging. A selection of 32 diagrams (every fourth pattern) is shown in **Fig. 11a**.
<figure><img src="image_15.png" /></figure>

**Figure 11** (a) experimental (coloured) and simulated (white) XRD curves as a function of time at 1200°C (time increases upwards). For visibility only 32 curves out of 126 are shown, and we selected a reduced angular region containing the first four visible peaks of MgAl₂O₄ (grey region and indexation). Actual data span a 5.8 – 27° range. The intensity is plotted logarithmically and the curves are shifted vertically for clarity. (b) evolution of the R<sub>wp</sub> factor for the RR (gray) and for the RR with size, strain and weight fractions fixed to the values of the NN (green).

**5.1. Adaptation of the network**

The presence of three different crystalline phases, and the necessity to determine the phase fraction, led us to modify the CNN as follows:

* The training data was generated including the three different phases with random volume fractions. The volume fractions were sampled from a Dirichlet distribution in order to ensure a uniform fraction distribution and that their sum equals unity.

* In addition to the crystallite size and microstrain of MgAl₂O₄, the phase fraction of all phases were included as an output of the NN.

* Because reliable peak intensities are required to quantify the phase fraction, the range of thermal parameter variations have been drastically reduced as compared to section 4, namely [0 – 0.05], and the atomic coordinates were allowed to vary from their nominal values by 0.005 Å. This ensured that a sufficiently large spectrum of possible crystal structures is seen by the NN during the training.

Since the phase we aim to characterize is formed during the experiment, we do not have any *a priori* information regarding the microstructure. The NN is therefore trained with a dataset of 2×10⁶ XRD patterns, as explained in section 4.2.
It turns out that determining the volume fraction is a fairly simple task compared to crystallite size and strain. Assuming, for instance, an absolute error threshold of 3%, the theoretical accuracy is 98.6%. Since the phase fraction are easily learnt by the NN, it does not affect the accuracy of the size and microstrain predictions. This demonstrates that the same NN architecture can be used for different use cases with only minor modifications. In this case, three additional output neurons (one for each phase fraction) have been added to the final layer.

## 5.2. Results

The results of the predictions of the NN regarding the phase fraction, crystallite size and microstrain are depicted in **Fig. 12**, together with the results obtained from a conventional Rietveld analysis. In the RR, for all phases, all structural (lattice parameters, atomic coordinates and thermal parameters) and microstructural parameters (phase fraction, crystallite size and microstrain and their associated peak profile shapes), were allowed to vary. The first remarkable outcome is that the predictions with the NN required 0.52 seconds (0.004 sec / pattern). In contrast, the RR required several hours. In particular, in the last stages of the procedure, where all parameters are refined simultaneously, the profile shape parameters of the size and microstrain broadening often led the fit to diverge and required important manual fine tuning.

First, let us consider the evolution of the phase fraction with increasing heating time (**Fig. 12a**). The RR and the NN provide almost identical results for all phases. The uncertainty in the phase fraction determined by the RR is very low (the error bars are smaller than the symbol). To get a rough estimate of the statistical errors affecting the NN's predictions, we trained five different NNs. The average prediction is the result shown in **Fig. 12**. The confidence bands correspond to the minimum and maximum values of the predictions from the five NNs. In the case of the phase fraction the dispersion is too small to be visible, which demonstrates that the NN can robustly determine the phase fraction.
<figure><img src="image_16.png" /></figure>

<figure><img src="image_17.png" /></figure>

<figure><img src="image_18.png" /></figure>

**Figure 12** (a) evolution as a function of time at 1200°C of the weight fractions of MgO (yellow), α-Al₂O₃ (red) and MgAl₂O₄ (green) obtained by the NN. The values obtained by RR are shown in grey. Evolution of (b) the crystallite size of MgAl₂O₄ and (c) the microstrain of MgAl₂O₄. The grey data correspond to the results obtained by the RR and the shaded area corresponds to ± the estimated standard deviation. The green data are the predictions from the NN and the shaded zone is the spread of the prediction using five independent NNs trained separately.
**Fig. 12b** shows the evolution of the crystallite size. The first striking observation is the substantial uncertainty that affect the value determined by the RR, as demonstrated by the wide error bars. For a given experimental profile shape, different size and microstrain values, each with different associated peak profile shape can provide similar fitting results, hence the large estimated standard deviation resulting from the refinement. Moreover, although a clear trend is observed in the evolution of the crystallite size, the point-to-point evolution is very noisy, especially at the beginning of the measurement. This is the consequence of the low peak intensities of the MgAl₂O₄ peaks and the counting noise. This effect is lowered after ~200 min when the weight phase fraction exceed ~27%. On the contrary, the NN's determination appears to be very smooth and characterized by a smaller prediction errors, as suggested by the narrow prediction spread. The evolution of the crystallite size determined by the NN follows the same trend albeit with slighter larger values, about ~7% higher (i.e., 203 vs. 189 nm) at the end of the measurement. Despite this discrepancy, the confidence band of the NN is completely included within the uncertainty range of the values obtained by the RR. A similar outcome is observed for the microstrain (**Fig. 12c**), with the distinction that the NN prediction slightly underestimates the microstrain as compared to the RR: the NN value is 0.036 percentage points lower at the end of the measurement (0.38% vs. 0.42%). In both cases, it is striking that both RR and the NN provide the same tendency, including local “accidents” in the evolution. Overall, however, the NN provides a smoother estimation.

The slight differences observed between the values obtained from the RR and the NN points to the
very different ways in which the two approaches operate. The RR minimises the least squares error
between the intensity equation and the experimental data. Therefore, the determination of the
crystallite size and microstrain of the MgAl₂O₄ phase is affected by the presence of the intense peaks
of Al₂O₃ and MgO, the background, etc. Conversely, the NN has been trained to detect characteristic
patterns in raw data points and, in doing so, it learned that the peaks belonging to the Al₂O₃ and MgO,
the background, etc., can not be correlated with varying size and microstrain values of MgAl₂O₄.

Out of habit it might be tempting to conclude that the values obtained by RR constitute the ground
truth. However, within statistical error, it is impossible to conclude which determination is correct. To
confirm this statement we conducted a second RR in which the phase fractions, size and microstrain
parameters are fixed to the values determined by the NN. The corresponding calculated curve are
superimposed with the data in **Fig. 11a**. The weighted profile R-factor (R<sub>wp</sub>) for the conventional RR
and the refinement with values fixed to the NN predictions are shown in **Fig. 11b**: no significant
difference can be detected. This last result demonstrates that both determination are statistically
equivalent, which definitely validates the use of the NN to conduct line profile analysis.

**6. Conclusions and outlook**

We have developed a convolutional neural network that can determine both crystallite size and
microstrain from powder X-ray diffraction data. The CNN was trained using synthetic data generated
with a dedicated code based on the GSAS-II software, ensuring that the data remained within
physically sound limits without any subsequent modification. This is essential for adding new
capabilities to the CNN, such as determining phase fractions or lattice parameters. It is not very
meaningful to provide absolute performance metrics because the performance of the CNN depends on
both the resolution of the diffractometer and the microstructure of the sample. Nevertheless, we can
mention that determining a crystallite size within the 5–100 nm range using a laboratory
diffractometer can be achieved with 99.7% accuracy in the absence of microstrain and 97.3%
accuracy when microstrains are present. Determining both size and microstrain on a laboratory
diffractometer in the 5–500 nm and 0.05–2% range can be achieved with 77% and 94% accuracy,
respectively. Higher accuracies or larger ranges are accessible at high-resolution synchrotron
facilities.

We applied the NN to determine the crystallite size and microstrain in MgAl₂O₄ formed by a solid-state reaction between MgO and Al₂O₃ using *in situ* XRD at 1200 °C at the BM01 beamline at the ESRF. We modified the NN to infer the weight fraction of each phase by adding three neurons to the final layer (one for each phase). No modification of the training dataset was required. The NN predicted the weight fraction with remarkable accuracy compared to conventional Rietveld refinement. The major advantage is that analysing 126 patterns took just 0.52 seconds instead of several hours and the crystallite sizes and microstrains predicted by the NN differ by less than 7% compared to Rietveld refinement, with identical statistical agreement factors. This paves the way for real-time data analysis at synchrotron facilities.

Finally, we demonstrated the capabilities of a CNN in fairly simple situation of a sample made of
isotropic crystallites and exhibiting isotropic microstrains. Much more complex situations can be
handled, provided a sufficient amount of training data can be gathered. For example, we trained a NN
to determine the axial and equatorial sizes of uniaxial anisotropic crystals. The performances are
99.5% in the 5-100 nm range, comparable to that of the isotropic model. Future work could involve
training CNNs with realistic defect structures using training data obtained from a physical modelling
of XRD patterns.

Data availability

The Jupyter notebooks the train and test the NN, as well as a NN trained to analyse the spinel data can
be found at https://github.com/aboulle/LPA-NN. The train and test data can be found at the French
research data repository: https://doi.org/10.57745/SVOART

**Acknowledgements** we grateful to region Nouvelle Aquitaine (France) for 50% funding of the PhD of AS (project Deep Matter). This work was also partially supported by the NanOX-ML program funded by the French National Research Agency (ANR) and the Austrian Science Fund (FWF) under grant number ANR-23-CE09-0041. Section 5, devoted to demonstrate the relevance of the NN approach on real data uses the solid-state reaction of spinel as an illustration. The corresponding
experimental data was acquired within the framework of the CESAREF project, supported by the
European Union's Horizon 2020 research and innovation program under the Marie Skłodowska-Curie
grant agreement 101072625. We thank M. Yehualaw Ewnete for preparing the samples and the Elkem
company for providing the raw materials. We acknowledge the ESRF for the provision of the
synchrotron beamtime and we thank C. Fuller and D. Chernyshov from the BM01 beamline for their
support during the XRD measurements.

**Appendix A. Neural network optimisation procedure**

There are no strict rules to optimize the architecture of a NN, and it mainly relies on trial and error. Automated approaches exist but are also time consuming, especially when the NN has a large number of layers and neurons. Here we used the following procedure: starting from our previously architecture (Boulle & Debelle, 2023) we first removed the Batch Normalisation layers which turned out to be useless in the case of powder XRD data. As mentioned earlier, it was discovered that a substantial increase in accuracy (a few percentage points) could be achieved by running convolutions in parallel in each convolutional layer.

A typical training curve is displayed in **Fig. 13a**. It plots the MSE (Eq. 10) as a function of the “epoch”. One epoch correspond to a series of parameter updates (weights and biases) where the whole training data set has been used once. With increasing epoch number the training MSE decreases which indicate that the NN is indeed learning. In addition to the training error, it is also customary to compute the validation error: the MSE obtained from a data set not used in the training, whose evolution can be used to optimize the architecture of the NN so as improve its generalisation capabilities. It is observed that the validation error decreases and saturates around 50 epochs. The value at saturation is used in the subsequent optimisation steps. The green curve is the learning rate, i.e., the magnitude at which the parameters are modified at each step. We used a “reduced learning rate on plateau” procedure, where the learning rate decreases by an order of magnitude when the validation error remains constant for at least 10 epochs.

For each architecture we performed 20 different trainings. In **Fig. 13b-d** we report the best results obtained, as well as the dispersion, in the form of a violin plot that represent the histogram of results. This dispersion, although not frequently discussed, is as important as the best value or the computation time. It reflects the repeatability of the training which is of crucial importance since a different NN has to be trained depending on the diffractometer and the materials under study. The optimisation procedure therefore aims at finding the architecture providing the lowest error, with the smallest dispersion and the smallest possible computing time.

We successively optimised the number of convolutional blocks (**Fig. 13b**), the number of neurons in the dense layer (**Fig. 13c**) and the size of the filters (**Fig. 13d**). The highest repeatability was obtained with 6 convolutional layers (**Fig 13b**). Starting from this geometry, the dense layer size that provided
the lowest MSE was 1000 (Fig. 13c). Finally, a further decrease in error and dispersion was achieved with a filter size of 10 (Fig. 13d). This results in the architecture presented in Fig. 3.

<figure><img src="image_19.png" /></figure>

<figure><img src="image_20.png" /></figure>

<figure><img src="image_21.png" /></figure>

<figure><img src="image_22.png" /><figcaption>**Figure 13** (a) evolution of the training and validation MSE, and of the learning rate during the training. (b) influence of the number of parallel convolution blocks on the validation MSE and training time. (c) influence of the size of the dense layer (number of neurons) on the validation MSE and the training time. (d) influence of the filter size (number of pixels) on the validation MSE and the training time.</figcaption></figure>
References

Allara, L., Bertolotti, F. & Guagliardi, A. (2024). *Npj Comput. Mater.* **10**, 54.

Balzar, D. (1999). Vol. *Defect and Microstructure Analysis by Diffraction*. pp. 94-126. Oxford University Press New York.

Balzar, D., Audebrand, N., Daymond, M. R., Fitch, A., Hewat, A., Langford, I. J., Lebail, A., Louër, D., Masson, O., McCowan, C. N., Popa, N. C., Stephens, P. W. & Toby, B. H. (2004). *J. Appl. Cryst.* **37**, 911.

Banko, L., Maffettone, P. M., Naujoks, D., Olds, D. & Ludwig, A. (2021). *Npj Comput. Mater.* **7**, 104.

Becker, D. & Streit, A. (2014). Vol. 2014 IEEE Fourth International Conference on Big Data and Cloud Computing. pp. 71-76. Sydney, Australia: IEEE.

Berntson, A., Stojanoff, V. & Takai, H. (2003). *J Synchrotron Rad.* **10**, 445-449.

Bertaut, F. (1949). *Comptes Rendus Hebdomadaires Des Séances de l'Académie Des Sciences* **228**, 492-494.

Boulle, A. & Debelle, A. (2023). *Mach. Learn.: Sci. Technol.* **4**, 015002.

Boulle, A., Guinebretière, R. & Dauger, A. (2005). *J. Phys. D: Appl. Phys.* **38**, 3907-3920.

Caglioti, G., Paoletti, A. & Ricci, F. P. (1958). *Nucl. Instr.* **3**, 223-228.

Campi, G., Pezzotti, G., Fratini, M., Ricci, A., Burghammer, M., Cancedda, R., Mastrogiacomo, M., Bukreeva, I. & Cedola, A. (2013). *Appl. Phys. Lett.* **103**, 253703.

Chakraborty, A. & Sharma, R. (2022). *Vis. Comput.* **38**, 1275-1282.

Chen, L., Wang, B., Zhang, W., Zheng, S., Chen, Z., Zhang, M., Dong, C., Pan, F. & Li, S. (2024). *J. Am. Chem. Soc.* **146**, 8098-8109.

Chitturi, S. R., Ratner, D., Walroth, R. C., Thampy, V., Reed, E. J., Dunne, M., Tassone, C. J. & Stone, K. H. (2021). *J. Appl. Cryst.* **54**, 1799-1810.

Chollet, F. (2018). Deep learning with Python: Manning Publications Co.

Corriero, N., Rizzi, R., Settembre, G., Del Buono, N. & Diacono, D. (2023). *J. Appl. Cryst.* **56**, 409-419.

Croset, B. (2017). *J. Appl. Cryst.* **50**, 1245-1255.

De Keijser, Th. H., Langford, J. I., Mittemeijer, E. J. & Vogels, A. B. P. (1982). *J. Appl. Cryst.* **15**, 308-314.

Dilanian, R. A., Nikulin, A. Y., Darahanau, A. V., Hester, J. & Zaumseil, P. (2006). *J. Appl. Phys.* **99**, 113526.

Dong, H., Butler, K. T., Matras, D., Price, S. W. T., Odarchenko, Y., Khatry, R., Thompson, A., Middelkoop, V., Jacques, S. D. M., Beale, A. M. & Vamvakeros, A. (2021). *Npj Comput. Mater.* **7**, 74.

Garcia, A., Sivaprasad, S., Wilder, J. & Mammone, R. J. (1994). Vol. Proceedings of SPIE - The International Society for Optical Engineering. pp. 130-136.
Garcia-Cardona, C., Kannan, R., Johnston, T., Proffen, T., Page, K. & Seal, S. K. (2019). Vol. 2019 IEEE International Conference on Big Data (Big Data). pp. 4490-4497.

Géron, A. (2023). Hands-on machine learning with Scikit-Learn, Keras, and TensorFlow: concepts, tools, and techniques to build intelligent systems Beijing Boston Farnham Sebastopol Tokyo: O'Reilly.

Glorieux, C. & Zolotoyabko, E. (2001). *J. Appl. Cryst.* **34**, 336-342.

Gómez-Peralta, J. I., Bokhimi, X. & Quintana, P. (2023). *J. Phys. Chem. A* **127**, 7655-7664.

Gómez-Peralta, J. I., Bokhimi, X. & Quintana-Owen, P. (2025). *Scripta Mater.* **263**, 116697.

Goodfellow, I., Bengio, Y. & Courville, A. (2016). Deep Learning MIT Press.

Griffen, D. T. (1999). *Clay Miner.* **34**, 117-126.

Guo, G., Goldfeder, J., Lan, L., Ray, A., Yang, A. H., Chen, B., Billinge, S. J. L. & Lipson, H. (2024). *Npj Comput. Mater.* **10**, 209.

Guo, G., Saidi, T. L., Terban, M. W., Valsecchi, M., Billinge, S. J. L. & Lipson, H. (2025). *Nat. Mater.* **24**, 1726-1734.

Habershon, S., Cheung, E. Y., Harris, K. D. M. & Johnston, R. L. (2004). *J. Phys. Chem. A* **108**, 711-716.

Hall, W. H. (1949). *Proc. Phys. Soc. A* **62**, 741-743.

Krill, C. E. & Birringer, R. (1998). *Philos. Mag.* A **77**, 621-640.

Langford, J. I. (1978). *J. Appl. Cryst.* **11**, 10-14.

Langford, J. I. (1992). Vol. 846, *Proceedings of the International Conference Accuracy in Powder Difraction II*. pp. 110-126. NIST, Gaithersburg, MD: NIST Special Publication.

Langford, J. I., Louër, D. & Scardi, P. (2000). *J. Appl. Cryst.* **33**, 964-974.

Langford, J. I. & Wilson, A. J. C. (1978). *J. Appl. Cryst.* **11**, 102-113.

Lee, B. D., Lee, J.-W., Park, W. B., Park, J., Cho, M.-Y., Pal Singh, S., Pyo, M. & Sohn, K.-S. (2022). *Adv. Intell. Syst.* **4**, 2200042.

Lee, J.-W., Park, W. B., Kim, M., Pal Singh, S., Pyo, M. & Sohn, K.-S. (2021). *Inorg. Chem. Front.* **8**, 2492-2504.

Lee, J.-W., Park, W. B., Lee, J. H., Singh, S. P. & Sohn, K.-S. (2020). *Nat. Commun.* **11**, 86.

Li, Q., Jiao, R., Wu, L., Zhu, T., Huang, W., Jin, S., Liu, Y., Weng, H. & Chen, X. (2025). *Nat. Commun.* **16**, 7428.

Lolla, S., Liang, H., Kusne, A. G., Takeuchi, I. & Ratcliff, W. (2022). *J. Appl. Cryst.* **55**, 882-889.

Maffettone, P. M., Banko, L., Cui, P., Lysogorskiy, Y., Little, M. A., Olds, D., Ludwig, A. & Cooper, A. I. (2020). *arXiv:2008.00283 [Cond-Mat].*

Massuyeau, F., Broux, T., Coulet, F., Demessence, A., Mesbah, A. & Gautier, R. (2022). *Adv. Mater.* **34**, 2203879.
Mittemeijer, E. J. & Scardi, P. (2011). Diffraction analysis of the microstructure of materials Berlin: Springer.

Okumura, T., Nakazono, M., Otsuka, M. & Takayama, K. (2006). *Colloids Surf B Biointerfaces* **49**, 153-157.

Oviedo, F., Ren, Z., Sun, S., Settens, C., Liu, Z., Hartono, N. T. P., Ramasamy, S., DeCost, B. L., Tian, S. I. P., Romano, G., Gilad Kusne, A. & Buonassisi, T. (2019). *Npj Comput. Mater.* **5**, 60.

Ozaki, H., Ishida, N. & Kiyobayashi, T. (2025). *J. Appl. Cryst.* **58**, 718-730.

Park, W. B., Chung, J., Jung, J., Sohn, K., Singh, S. P., Pyo, M., Shin, N. & Sohn, K.-S. (2017). *IUCrJ* **4**, 486-494.

Poline, V., Purushottam Raj Purohit, R. R. P., Bordet, P., Blanc, N. & Martinetto, P. (2024). *J. Appl. Cryst.* **57**, 831-841.

Riesel, E. A., Mackey, T., Nilforoshan, H., Xu, M., Badding, C. K., Altman, A. B., Leskovec, J. & Freedman, D. E. (2024). *J. Am. Chem. Soc.* **146**, 30340-30348.

Rietveld, H. M. (1969). *J. Appl. Cryst.* **2**, 65-71.

Salgado, J. E., Lerman, S., Du, Z., Xu, C. & Abdolrahim, N. (2023). *Npj Comput. Mater.* **9**, 214.

Scardi, P. & Leoni, M. (2001). *Acta Cryst.* **A 57**, 604-613.

Scardi, P. & Leoni, M. (2002). *Acta Cryst.* **A 58**, 190.

Scherrer, P. (1918). *Nachr. Ges. Wiss. Göttingen* **2**, 98.

Schuetzke, J., Benedix, A., Mikut, R. & Reischl, M. (2021). *IUCrJ* **8**, 408-420.

Schuetzke, J., Schweidler, S., Muenke, F. R., Orth, A., Khandelwal, A. D., Breitung, B., Aghassi-Hagmann, J. & Reischl, M. (2023). *Adv. Intell. Syst.* 2300501.

Simonnet, T., Grangeon, S., Claret, F., Maubec, N., Fall, M. D., Harba, R. & Galerne, B. (2024). *IUCrJ* **11**, 859-870.

Snyder, R., Fiala, J., Bunge, H. J., Snyder, R., Fiala, J. & Bunge, H. J. (2000). Defect and Microstructure Analysis by Diffraction Oxford, New York: Oxford University Press.

Snyder, R. L. (1993). *The Rietveld Method* **1**, 111-131.

Sozeri, H., Kucuk, I. & Ozkan, H. (2011). *J. Supercond. Nov. Magn.* **24**, 683-687.

Stephens, P. W. (1999). *J. Appl. Cryst.* **32**, 281-289.

Stokes, A. R. & Wilson, A. J. C. (1944). *Proc. Phys. Soc.* **56**, 174-181.

Strohmann, T., Barriobero-Vila, P., Gussone, J., Melching, D., Stark, A., Schell, N. & Requena, G. (2023). *Scripta Mater.* **226**, 115238.

Sun, S., Hartono, N. T. P., Ren, Z. D., Oviedo, F., Buscemi, A. M., Layurova, M., Chen, D. X., Ogunfunmi, T., Thapa, J., Ramasamy, S., Settens, C., DeCost, B. L., Kusne, A. G., Liu, Z., Tian, S. I. P., Peters, I. M., Correa-Baena, J.-P. & Buonassisi, T. (2019). *Joule* **3**, 1437-1451.
Szymanski, N. J., Bartel, C. J., Zeng, Y., Diallo, M., Kim, H. & Ceder, G. (2023). *Npj Comput. Mater.* **9**, 31.

Szymanski, N. J., Bartel, C. J., Zeng, Y., Tu, Q. & Ceder, G. (2021). *Chem. Mater.* **33**, 4204–4215.

Szymanski, N. J., Fu, S., Persson, E. & Ceder, G. (2024). *Npj Comput. Mater.* **10**, 45.

Tatlier, M. (2011). *Neural Comput. Applic.* **20**, 365–371.

Thompson, P., Cox, D. E. & Hastings, J. B. (1987). *J. Appl. Cryst.* **20**, 79–83.

Toby, B. H. & Von Dreele, R. B. (2013). *J. Appl. Cryst.* **46**, 544–549.

Ungár, T. & Borbély, A. (1996). *Appl. Phys. Lett.* **69**, 3173–3175.

Ungár, T., Leoni, M. & Scardi, P. (1999). *J. Appl. Cryst.* **32**, 290–295.

Van Berkum, J. G. M., Delhez, R., De Keijser, Th. H. & Mittemeijer, E. J. (1996). *Acta Cryst.* **A** **52**, 730–747.

Vecsei, P. M., Choo, K., Chang, J. & Neupert, T. (2019). *Phys. Rev. B* **99**, 245120.

Voigt, W. (1912). *Sitzungsberichte Königliche Bayerische Akademie Der Wissenschaften* **42**, 603–620.

Wang, B., Guan, Z., Yao, S., Qin, H., Nguyen, M. H., Yager, K. & Yu, D. (2016). Vol. 2016 New York Scientific Data Summit (NYSDS). pp. 1–5. New York, NY, USA: IEEE.

Wang, H., Xie, Y., Li, D., Deng, H., Zhao, Y., Xin, M. & Lin, J. (2020). *J. Chem. Inf. Model.* **60**, 2004–2011.

Wang, H., Zhong, J., Li, Y., Zhang, J. & Du, R. (2025). *J. Appl. Cryst.* **58**, 711–717.

Warren, B. E. & Averbach, B. L. (1950). *J. Appl. Phys.* **21**, 595–599.

Wertheim, G. K., Butler, M. A., West, K. W. & Buchanan, D. N. E. (1974). *Rev. Sci. Instr.* **45**, 1369–1371.

Wilkens, M. (1970). *Phys. Stat. Sol.* (a) **2**, 359–370.

Williamson, G. K. & Hall, W. H. (1953). *Acta Metall.* **1**, 22–31.

Wilson, A. J. C. (1962). *Nature* **193**, 568–569.

Woinaroschy, A., Isopescu, R. & Filipescu, L. (2000). *Cryst. Res. Technol.* **35**, 969–977.

Yue, W., Mehdi, M. R., Tripathi, P. K., Willard, M. A., Ernst, F. & French, R. H. (2024). *MRS Adv.* **9**, 921–928.

Zaloga, A. N., Stanovov, V. V., Bezrukova, O. E., Dubinin, P. S. & Yakimov, I. S. (2020). *Mater. Today Commun.* **25**, 1016–62.

Ziletti, A., Kumar, D., Scheffler, M. & Ghiringhelli, L. M. (2018). *Nat. Commun.* **9**, 2775.