WorksPhysics and Astronomy
diffpy.morph: Python tools for model independent comparisons between sets of 1D functions
Abstract
diffpymorph addresses a need to gain scientific insights from 1D scientific spectra in model independent ways. A powerful approach for this is to take differences between pairs of spectra and look for meaningful changes that might indicate underlying chemical, structural, or other modifications. The challenge is that the difference curve may contain uninteresting differences such as experimental inconsistencies and benign physical changes such as the effects of thermal expansion. diffpymorph allows researchers to apply simple transformations, or "morphs", to one of the datasets to remove the unwanted differences revealing, when they are present, non-trivial differences. diffpymorph is an open-source Python package available on the Python Package Index and conda-forge. Here, we describe its functionality and apply it to solve a range of experimental challenges on diffraction and PDF data from x-rays and neutrons, though we note that it may be applied to any 1D function in principle.
Introduction
Neutron and X-ray powder diffraction (NXPD) and atomic pair distribution function (PDF) analysis are powerful tools for probing the local and average structure of materials1,2. They can provide many insights; for example, one can compare NXPD patterns and PDFs of samples measured at different temperatures to search for structural changes[3]. This may be done in a model independent way by comparing two patterns and looking for meaningful changes, for example, by plotting the difference curve between the patterns or computing similarity metrics such as the profile-weighted agreement factor (, 1,2) or the Pearson correlation coefficient (PCC[4]). This task is made more difficult in the presence of less interesting effects such as expansion/contraction due to temperature changes, thermal smearing due to increased thermal motion, and certain experimental artifacts.
These are effects that may not represent “interesting” structural changes, but can produce large contributions to the residual curves and s, hiding more scientifically interesting structural changes. A challenge is to remove the uninteresting changes to reveal scientifically interesting ones when they are present.
Here we present the Python program DIFFPY.MORPH that provides a solution to this problem by first applying simple transformations, or “morphs”, to spectra to partially or fully account for these non-interesting effects, allowing any interesting changes that can’t be removed by the morph to become apparent.
We note that this approach is completely general and may be applied beyond diffraction and atomic pair distribution function2 data to any kinds of 1D spectra. The approach is fast and model independent and is a powerful tool for interrogating data in real-time as it is being collected. Here we describe the approach and test it on a number of different real-world examples from our own studies. We show how it can be used to reveal when a structural phase transition occurs, and when it does not, in temperature series PDF data. We then present an example where a thermodynamic parameter , the (linear) thermal expansion coefficient, is extracted directly from temperature-dependent data without modeling, and in contrast, where the temperature of a sample can be extracted given a known , again in a model independent way. We present an example where experimental inconsistencies could be removed between datasets allowing them to be compared despite the inconsistencies. Finally, we also present some more advanced use-cases, where we use DIFFPY.MORPH to find optimal parameters in a data reduction workflow by morphing a low high-throughput data to a reference high target dataset.
DIFFPY.MORPH is easy to use and flexible. It is open source (BSD license)[5] and available on PyPi[6] and conda-forge[7]. It has a command-line interface and API allowing it to be integrated into users’ Python scripts. The program can read most column-style data files (e.g. ‘.xy’, ‘.dat’, ‘.chi’, ‘.gr’), with and without header information. It also automatically handles comparison of two functions plotted on different grids by using linear interpolation.
Though this software was originally designed in the context of PDFs, DIFFPY.MORPH and its morphs can be easily applied to any general function. For example, a neutron scattering experimentalist could subtract the hydrogen contribution to a density of states (DOS) by morphing a known hydrogen DOS to their measured DOS and taking the difference curve, or a computer vision scientist comparing two pictures taken at different brightnesses can give the (flattened) 2D images to DIFFPY.MORPH to correct for intensity differences.
Motivating Examples
Here, we introduce some examples that motivated our development of DIFFPY.MORPH but which also illustrate how it may be applied in different situations.
Identifying a Structural Phase Transition
Identifying whether or not a phase transition has occurred by using morphs
Fig. 1(a-c) shows pairs of PDFs that were collected at 10 K (blue) and 300 K (red) with the difference curve plotted below. We would like to answer the questions: (1) “Do any of these show a structural phase transition in this range?” and (2) “If so, which?”. We might be able to do this by comparing the two PDFs and considering various difference measures. A large difference measure should indicate that there may be a phase transition, and a smaller measure that there is not. We see the largest difference measures for (b) () then (a) (), with the smallest for (c) (), which might suggest that it is more likely to find a structural phase transition in (a) and (b). However, this is a wide temperature range, and there are significant thermal effects. Fig. 1(d-f) show
the corresponding pairs of PDFs after applying “stretching”, “scaling”, and “smearing” morphs, described further below, to the lower-temperature data. In this case, the difference measures become very small for (d) and (e) but remain somewhat large with significant unresolved signal in the green difference curve for (f).
The sample in (c,f) is an IrTe compound, and in (a,d) and (b,e), the Iridium is substituted with Rhodium and Platinum respectively. Single crystals of IrTe where grown with a self-flux method[8], while Rhodium-substituted[9, 10] and Platinum-substituted[9, 10] polycrystals were synthesized using a solid-state reaction method.
After morphing, it is clear that pure IrTe has a phase transition in this temperature range, but substituting Pt, even at the five percent level, suppresses the phase transition. This was not apparent in the unmorphed data but is confirmed by structural modeling in the original study[12].
Similar problems arise when comparing 1D diffraction intensities, , prior to computing a PDF. Fig. 2(a-c) shows the same analysis as carried out on Fig. 1 but this time on the data instead of the PDF.
As before, prior to morphing, it is much less clear from the difference curve which of these cases have structural phase transitions and which do not, but this is very apparent after morphing.
Figure 2. s of IrTe samples with various forms of substitution measured at 10 K (blue) and 300 K (red). The difference curves (green) are plotted below. All values are computed on the grid with spacing . (a) Rhodium-substituted IrRhTe. (b) Platinum-substituted IrPtTe. (c) Pure IrTe. The s plotted in (a-c) were used to generate the PDFs in Figure 1(a-Figure 1c). Plots (d), (e), and (f) have the same high-temperature as (a), (b), and (c) respectively, but a stretch and scale morph has been applied to the low-temperature to best fit the high-temperature target .
We now investigate in more detail how these morphing transformations actually affected the data. In Figure 3(a) we compare PDFs from IrRhTe at 250 K (blue) and 300 K (red). The agreement factor , and there are some ripples in the green difference curve plotted below. By close inspection, we can observe that the peaks in the warmer sample are broader and shifted to higher-. This is most evident in the region , plotted on an expanded scale in Figure 3(d). More evidence of peak shifting across the entire -grid is provided in Supplemental Material, Figure S1.
Figure 3. Morphed PDFs of IrRhTe samples measured at 250 K (blue) plotted against unmorphed PDFs measured at 300 K (red). The difference curves (green) are plotted below. All values are computed on the grid with spacing . (a) No morph is applied. (b) A stretch and scale morph is applied to the lower-temperature PDF. (c) A stretch, scale, and smear morph is applied to the lower-temperature PDF. Plots (d), (e), and (f) are the same as (a), (b), and (c) respectively zoomed into the region .
Figure S1. The difference curve (red) between the PDFs of IrRhTe measured at 250 K minus the PDF measured at 300 K is plotted against the derivative (blue) of the 250 K PDF. The derivative has been rescaled by the grid spacing . The two curves are visually correlated, especially at high-.
The peak shifts could come from thermal expansion and the peak broadening from increased thermal motion. DIFFPY.MORPH allows us to investigate whether a uniform “stretch” of the lattice of the lower-temperature sample can account for the peak shifts across the whole range of the PDF without having to know and model the structure of the material.
To accomplish this DIFFPY.MORPH first interpolates the lower-temperature PDF onto a slightly stretched -grid . This we call the stretch morph with a stretch parameter . Then, DIFFPY.MORPH multiplies the PDF by a constant scale factor . This is the “scale” morph with scale factor . The result of applying these two transformations is shown in Figure 3(b). The is significantly reduced, as are ripples in the difference curve.
From a practical perspective, it is tedious to find the exact stretch and scale morphs to best explain the difference, so we wrap the transformation in a least-squares regression method to find the and values that minimize the between the PDF of the low-temperature signal after morphing (which we denote the “morphed” signal ) and the untouched high-temperature PDF (the “target” signal ).
Although is reduced by almost a factor of two by the stretch and scale morphs, differences remain. We would like to see the extent to which they can be removed by a uniform broadening, or smearing, of the radial distribution function (RDF) of the lower-temperature sample. We accomplish this by computing the RDF from the morphed PDF, convolving the RDF with a normalized Gaussian function with variance , and convert the smeared RDF back to a PDF. We then vary the of that convolution function until we get the best agreement between the morphed PDF and the target PDF. This is the “smear” morph with smearing parameter . The result of turning on the smear morph transformation on top of the stretch and scale morphs is shown in Figure 3(c). This results in a further reduction in of 31% and an almost flat difference curve. For more details on how the morphs are implemented, see § 2.
In the absence of a structural phase transition, the one place in the difference curve where significant fluctuations remain after morphing is in the vicinity of the first peak at Å. This is evident in the difference curve in Figure 1(d,Figure 1e) and Figure 3(c). This phenomenon is well-known and is due to changes in the correlated atomic motion[13]. This could be removed with a smear-morph applied over just the range of the PDF incorporating this first peak. It would allow the temperature dependence of the broadening of the first peak to be extracted separately from the higher- peaks and extract information about the degree of motional correlations, though we don’t do that here. It also shows how careful morphing can remove some features and not others, revealing key insights.
Figure 1. PDFs of IrTe samples with various forms of substitution measured at 10 K (blue) and 300 K (red). The difference curves (green) are plotted below. All values are computed on the grid with spacing . (a) Samples are Rhodium-substituted IrRhTe. (b) Platinum-substituted IrPtTe. (c) Pure IrTe. Plots (d), (e), and (f) have the same high-temperature PDF as (a), (b), and (c) respectively, but a “stretching”, “scaling”, and “smearing” morph has been applied to the low-temperature PDF to best fit the high-temperature target PDF.
Finding the temperature of a phase transition by analyzing multiple morphs
We have seen how DIFFPY.MORPH is helpful in identifying whether or not a phase transition has occurred, but it can also help identify the temperature range in which the transition occurs.
On a dataset of IrTe PDFs measured from 10 K to 300 K, we have used DIFFPY.MORPH’s capability to create multiple morphs (stretch, scale, smear) of the lowest-temperature PDF with each higher-temperature PDF in the set as a target. In Figure 4(a), we plot the resulting (post-morph) s. The s vary slowly over the entire temperature range until 263 K where there is a rapid change in slope up till 283 K, where it again slows down. The same can be seen in the PCC curve shown in red. A phase transition (from low-temperature triclinic to high-temperature trigonal) has been observed near 280 K[14]. The DIFFPY.MORPH analysis shows the onset of this phase transition on cooling beginning at around 283 K with the distortion growing smoothly on cooling until around 263 K but using a completely model-independent analysis and a simple command in a terminal.
Figure 4. (a) (blue) and Pearson correlation coefficient (red) computed between a morphed and target PDF from IrTe PDFs measured at temperatures ranging from 9 K to 297 K. (b) The stretch parameter found in each morph indicating thermal expansion. This parameter sharply drops above 263 K. The drop indicates contraction at the phase transition. Dashed lines are linear fits to the low and high temperature regions.
Comparison of diffpy.morph with model refinement techniques
This method of identifying phase transition temperatures using DIFFPY.MORPH produces results that agree with structural model fitting techniques such as PDFGUI15. There is a known structural change in SrFeAs between 192 K and 198 K[3]. PDFs of SrFeAs measured from 150 K to 246 K were sourced from data published alongside the textbook “Atomic Pair Distribution Function Analysis: A Primer”[3, 16]. In Figure 5(a), we have plotted the and PCC values resulting from morphing the PDF of SrFeAs measured at 150 K to PDFs of the same sample measured at the various higher temperatures. We observe a steep descent in the and ascent in the PCC within the temperature range of the phase transition. We have also used DIFFPY.MORPH to plot the stretch parameter used in the morphs across temperature in Figure 5(b). While this parameter increases linearly from 156 K to 192 K and from 198 K to 245 K, indicating some isotropic expansion in those ranges, from 192 K to 198 K, the stretch parameter does not change, further confirming that some more interesting structural change is occurring at those temperatures. Structural modeling refinement done by PDFGUI15 shows that the tetragonal model only fits well past 198 K, indicating some structural phase change occurs past this temperature. This result was obtained in a model-independent DIFFPY.MORPH analysis.
Figure 5. (a) (blue) and PCC (red) after morphing the PDF from SrFeAs measured at K on to the PDF measured at target at temperatures up to 246 K. (b) The stretch parameter obtained from each morph. The dashed and dotted lines show best-fit linear curves in the temperature ranges 156 K to 192 K and 198 K to 246 K, respectively. The slope gives the thermal expansion coefficient in the respective temperature ranges. (c) The obtained by fitting a tetragonal (blue) and orthorhombic (red) structure to each PDF on the -range [0.5 Å, 100 Å]. The black vertical dashed line is a guide to the eye at the first measured point above the structural phase transition.
Extracting Material Properties using Morph Comparisons
Thermal expansion and Debye temperature using stretch morph on temperature dependent x-ray data
Using a series of PDFs measured at different temperatures, one can estimate the linear thermal expansion coefficient of a material using the stretch morph. For nearly harmonic materials, one can further compute the Debye temperature by looking at the derivative of the stretch parameter with respect to temperature.
In Figure 4(b) the value of the stretch morph parameter computed on the grid is plotted against temperature for the IrTe sample whose x-ray PDF was measured vs. temperature. We see this grow smoothly, albeit noisily. By finding the gradient of we can extract the thermal expansion coefficient as we discuss below.
The stretch parameter obtained from morphing between a temperature and is an average isotropic strain of the material induced by the change in temperature (shown in Supplemental Material, Section S B). We can compute a linear thermal expansion coefficient using
where the approximation holds for . Each was computed from discrete temperature data using finite differences of . From Figure 4(b), we compute an average thermal expansion coefficient of K for the triclinic phase of IrTe (in range K, 263 K) and K for the trigonal phase (in range K, 297 K). Note that the stretch yields an average linear expansion coefficient that more accurately
reflects the actual expansion the more isotropic the material and if the material expansion is highly anisotropic, the stretch morph will not remove the effects of the thermal expansion.
We can also get a sense of the anharmonicity of the material by examining the thermal expansion coefficient as a function of temperature. This can be modeled by the temperature derivative of the stretch parameter
per Eq. (2). In Figure 6, we plot the thermal expansion coefficient, extracted from the morphed data (using central differences to compute the derivative of ), over a large temperature range for, (a), Pt-substituted and, (b), pure IrTe. We then fit the data to the curve for the (linear) thermal expansion , using a quasiharmonic model given by,
Figure 6. Plots of thermal expansion coefficients (extracted using the approximation in Eq. (3)) at various temperatures. The samples involved are (a) IrPtTe and (b) IrTe. Data is fitted to Eq. 4 with parameters , , and (see text). The fits have values of (a) 0.7937 and (b) 0.4143.
with fitting parameters , , and (Debye temperature). The expression is obtained from the Grüneisen equation of state[17, 18], where the forms of the isochoric heat capacity (numerator) and adiabatic bulk modulus (denominator) come from the Debye model[19], and Anderson approximation[18, 20], respectively. For this model to work, we must assume a constant heat-capacity ratio [18, 19] to ensure that the isothermal and adiabatic bulk moduli are proportional, assume the change in volume is small, and assume a constant Grüneisen parameter [17, 18, 20]. Anharmonic (non-harmonic and non-quasi-harmonic) materials are likely to violate these conditions. We see that while the Platinum-substituted sample has a nice agreement and sensible Debye temperature of 233 K [9, 11], the opposite is true for the pure sample with an anomalous upturn in at high- (Figure 6(b)) and an abnormally low Debye temperature 39 K, suggesting significant anharmonicity. The anharmonicity of pure IrTe has been explored previously using Raman spectrometry [21].
Using diffpy.morph for in situ sample thermometry
The converse of finding the thermal expansion coefficient from temperature series data is using a known thermal expansion coefficient to estimate sample temperature in a model independent way.
There are few available techniques for precisely measuring the temperature of diffraction experiment samples heated to high temperatures. One such technique is pyrometry, but thermal gradients caused by uneven heating of the material and ablation in the scattering region can greatly limit the accuracy of the measurement [22, 23]. Further, pyrometry measures only the surface temperature, which makes it unreliable for transmission geometry scattering experiments.
This motivates the development and use of alternative methods for obtaining the bulk average temperature of a sample under in situ conditions. In Section II A 2, we demonstrated how diffpy.morph can be used to identify whether a phase transition has occurred between two PDFs. This can be matched with a known phase transition temperature to identify the temperatures of these PDFs (this works also for s). On the other hand, if a sample does not undergo a phase transition, the following example shows how one can use the known thermal expansion coefficient of the sample material to obtain the average temperatures of the sample at the moment the s and PDFs were acquired [24].
A commercially-obtained sample of yttria-stabilized zirconia (YSZ) was laser heated from room temperature with laser powers ranging from 0 W to 50 W. At each power level, a neutron powder diffraction was measured, and the corresponding PDF, , computed. In Figure 7(a), we show the functions computed from laser-heated YSZ samples at powers 30 W and 50 W. The difference curve shows a significant signal, due to thermal expansion from the additional 20 W of power. Similarly, the difference curve between the corresponding PDFs (shown in Figure 7(c)) also shows a significant signal. However, in (b) and (d), after applying a stretch and scale (as well as a smear morph for the PDF data) on the 30 W data with the 50 W data as a target, the majority of the differences are removed. The yttria content of the YSZ samples used was estimated to be 5.32 mol% using calculated lattice parameters [25], and with a corresponding thermal expansion coefficient of 1/K. This thermal expansion coefficient is in agreement with existing literature [22, 26, 27]. With this thermal expansion, we can use the stretch morph to estimate the temperature of the laser-heated YSZ samples
Figure 7. s ((a) and (b)), and PDFs ((c) and (d)) of YSZ samples heated with a 30 W (plotted in blue) and 50 W (plotted in red) laser. Difference curves are plotted offset below in green. No morphs are applied in (a) and (c). stretch and scale morphs are applied to the lower-power (blue) signal in (a) to obtain the blue in (b). stretch, scale, and smear morphs are applied to the lower-power signal in (c) to obtain the blue PDF in (d). The is computed from the entire , or , range plotted.
directly.
For small , we assume . Rearranging Eq. (2), we get
where is the PDF stretch parameter. Using the stretch parameter and , we can obtain between the room temperature (298 K) sample and each laser-powered sample. The actual temperature is then
The strain, equivalent to (see Supplemental Material Section S B), and the corresponding estimated temperatures (right axis label) are plotted in Figure 8.
Figure 8. Strains computed by morphing 0 W YSZ PDF data (blue) and data (red) to higher-power YSZ data. The corresponding temperature is given by the right axis.
We also carried out the same analysis directly on the data rather than the PDF. (A similar approach has been used to determine sample temperatures on x-ray data [24].) In this case the stretch parameters, , correspond to a strain of
(see Supplemental Material, Section S C) and thus a temperature change of
The strains and corresponding temperatures extracted from the morphs correspond to the red curve in Figure 8. These are in excellent agreement with each other. The largest discrepancy between the two curves is a difference of at 38 W.
This example not only shows how temperatures can be estimated using DIFFPY.MORPH, but its applicability to not just x-ray diffraction signals, but also neutron data.
Nanoparticle shape information from shape morphs
The shape and size of a nanoparticle can greatly affect its (electronic, optical, etc.) properties.28,29 If one has PDF measurements of a bulk and a nanoparticle of the same material, it is possible to use a nanoparticle “shape” morph to determine the morphological parameters without a structural model. By way of example, we show how it is possible to determine the radius of a spherical nanoparticle using a shape morph.
This morph can be very useful if you have a PDF calculated from a bulk model but your data is from a nanocrystalline sample. DIFFPY.MORPH will then multiply the bulk PDF by the chosen nanoparticle characteristic function2,30, , automatically adjusting the parameters of the model to find the best agreement to the nanoparticle PDF.
If a good fit is obtained, the model choice and refined shape parameters can be considered useful, though other models should be tested to search for alternative possible candidates30–33. Significant difference curve signals or indicate large deviations from the desired shape and new shape models may be tried.
This approach has previously been used to estimate diameters of spherical CdSe nanoparticles consistent with those obtained from transmission electron microscopy, ultraviolet-visible spectroscopy, and photoluminescence measurements34.
Here, we have used this approach to estimate the size of PbS nanocrystals with thiostannate () ligands. These nanocrystals are known to be faceted35, but for small diameters, are approximately round. In Figure 9(a), we show the PDF measured from the PbS nanocrystal (blue) against a PDF computed from the bulk structure of PbS36
Figure 9. (a) Measured PbS nanocrystal PDF (blue) plotted against a computed PDF of the bulk PbS (red). (b) The red curve is now the bulk PbS PDF after applying the spherical nanoparticle shape morph. (c) The red curve is a PDF of a spherical PbS nanocrystal computed from the structural model using PDFgui. A difference curve (green) is vertically offset below each plot.
(red). We see clear reduction in the signal of the measured data (blue curve) as we go to higher , indicating that our measured material is definitely nanocrystalline. We then apply the nanoparticle shape morph onto the computed bulk PDF. The resulting morphed PDF is shown in red in Figure 9(b). The radius obtained from the morph was 24.51 Å. For comparison, we used PDFGUI15 to compute a spherical PbS nanocrystal PDF from a structure36 to best fit our measured PDF. The resulting refinement resulted in a nanocrystal diameter of 47.2 Å (radius of 23.86 Å) (red curve in Figure 9(c)). The refinement done by DIFFPY.MORPH (order of seconds) is much faster than the lengthy and human intensive structural refinement done by PDFGUI, with a small relative difference of 1.3% between the two calculated radii.
The DIFFPY.MORPH-computed and PDFGUI-computed PDFs (red curves in (b) and (c), respectively) also show good agreement up to Å. Above this, the DIFFPY.MORPH-computed PDF flat-lines, while the PDFGUI-computed PDF has small sinusoidal oscillations that account for termination ripples2. This example showcases how DIFFPY.MORPH can quickly compute nanoparticle and nanocrystal PDFs from bulk PDFs and obtain morphological parameters.
At the time of writing, DIFFPY.MORPH only includes morphing transformations to account for the effects of a spherical and spheroidal nanoparticle shape on its measured PDF. If the desired shape morph is not implemented, please consider requesting it with an issue at the DIFFPY.MORPH GitHub website[37] or by posting a request at the diffpy-users Google group (https://groups.google.com/g/diffpy-users). If you are able to implement the morph yourself, please consider posting a pull request at the DIFFPY.MORPH repository on GitHub.
High-Throughput Experiment Use Cases
DIFFPY.MORPH has been utilized in high throughput experimental settings, such as synchrotron beam-times, for a variety of use-cases. These include to expose sources of experimental error (e.g. incorrect sample-to-detector distance or misaligned beam center), to identify and remove unwanted signals such as laser induced heating, and to identify optimal processing parameters to compute reliable PDFs from measured data.
A major advantage of using DIFFPY.MORPH in a high-throughput data setting is its speed and ease of use. Rather than performing a lengthy structural refinement, one can obtain morphing parameters in seconds.
Addressing experimental setup challenges
When integrating a 2D diffraction image to obtain a 1D scattering function , we require various experimental geometric parameters such as the sample-to-detector distance, location on the detector of the beam-center, tilt angles of the detector away from orthogonality, and wavelength of the incident beam. These are normally handled by carefully performing calibration measurements. In practice, small deviations between calibration and sample datasets can arise due to a multitude of factors such as minor sample or detector repositioning, motor drift, thermal expansion or contraction of experimental components, and other instrumental or environmental effects. In such cases, DIFFPY.MORPH can be used to apply small corrective adjustments to the calibration parameters.
We prepared a sample of PbS nanocrystals with thiostannate () ligands dissolved in an amide solution. The synthesis of the nanocrystals and ligands follows previous published procedures[38]. A 2D diffraction pattern pattern was obtained from this sample at an XFEL beamline (measured to Å). In Figure 10(a), we showcase two s computed from this 2D diffraction pattern, but where the integration was carried out using different values for the sample-to-detector distances and beam centers. The numbers used were rough initial guesses from the geometry as an initial calibration was not available. This is compared to
Figure 10. s computed from the same diffraction image using the uncalibrated (blue) and calibrated (red) parameters are plotted in (a). In (b) stretch, scale, and shift morphs are applied to the uncalibrated data to maximize agreement with the calibrated data on . For (c), the same morphs are used, but instead maximizing agreement on the region encompassing the first three peaks (). We include a difference curve (green) below each plot.
the final calibrated data (red curve in Figure 10(a)). Specifically, the uncalibrated sample-detector distance value used was mm with the calibrated distance found to be mm. Additionally, the beam center used for the uncalibrated curve is offset mm both horizontally and vertically from that found from the calibrated curve. We can see a significant mismatch between the two curves, but by using the stretch and scale morphs along with a “shift ” morph, in (b), we can obtain very good agreement Figure 10(b). Here, the shift morph shifts the function to the right by adding a shift constant to the -array to account for the zero-offset. This helps to account for the misaligned detector center. Such a morph allows us to make on-the-fly corrections for variability in sample calibration from data-set to data-set. However, it is also possible to invert the morph parameters to find spectrum-dependent corrections to the calibration values.
For the correction to the detector distance, we take advantage of the approximation that at small ,
where is the stretch parameter as usual (proof in Supplemental Material, Section S F). To see how well this approximation worked we applied the morphs to maximize agreement in only the lower- region (the first three peaks) in Figure 10(c). The stretch parameter obtained in (c) was , which gives a correction to the sample-detector distance that is away from the actual value of .
DIFFPY.MORPH includes a “squeeze” morphing transformation as well as the stretch and shift that we already introduced. The squeeze morph applies a higher-order polynomial to the -array (see § 2 § 2.0.1.7). In Figure 11(a), we applied a squeeze using a fifth-order polynomial on the uncalibrated (blue) to attempt to match the properly calibrated (red). The use of a fifth order polynomial in our squeeze morph is motivated in the Supplemental Material, Section S F. We can see by comparing Figure 10(b,Figure 10c) and Figure 11(a) that this quintic polynomial correction can, at the same time, account for the low- (near the 1.85 Å and 2.13 Å Bragg peaks) and high- Å regions. The resulting PDFs are brought well into alignment (Figure 11(b)). As such, while the researcher’s team is working to identify the new alignment parameters to recompute the correctly, the researcher can still analyze this new data, draw conclusions, and inform the next steps of the experiment using the DIFFPY.MORPH analysis.
Figure 11. (a) s computed from the uncalibrated but morphed data (blue) and calibrated (red) alignment parameters. (b) The PDFs computed from the two s in (a). Difference curves (green) are vertically offset below.
As we discuss in the next section, in principle, for those using a Python program for integration of 2D detector images, such as pyFAI[39], DIFFPY.MORPH can also help obtain the optimal alignment parameters directly through the “funcxy” morph.
Obtaining data reduction parameters for an optimal PDF
So far we have used DIFFPY.MORPH to carry out rather simple morphing transformations such as stretch, shift and scale morphs. Complexity increases with squeeze that allows for non-linear stretches of the data. However, in principle the morphing approach can be used for arbitrary transformations to the - and -arrays.
Here we describe an example where we want to estimate the parameters used in processing raw 1D diffraction datasets all the way to a PDF. This processing is done using the PDFGETX3 software package[40] which takes a number of parameters such as how much to scale a background signal, the range of data to use in the Fourier transform, and rpoly which controls the flexibility of a polynomial correction done in the process.
In this example, we have an measured from PbS nanoparticles and a thiostannate salt dissolved in an amide solution (the same sample as Section II C 1). Our goal is
to get a good PDF of the PbS after subtracting the correctly scaled signal from the solvent. The issue is illustrated in Figure 12(a) where the raw signal from the sample (blue curve), scaled background (red curve) and background subtracted signal (green curve) are shown. After running this through PDFGETX3 we obtain the shown in Figure 12(b). This has the wrong shape because the background has been under-subtracted and rpoly has not been optimized.
Figure 12. (a) and (d), the 1D scattering intensities of PbS nanoparticles dissolved in amide solution (blue), the raw signal from the empty solvent (red) and (green) the sample signal with the background subtracted. (b) and (e) show the resulting functions obtained by running the green data-set from the panel above through PDFgetX3 and the blue curves in (c) and (f) the resulting PDFs. Parameters and were used to obtain the curves in (b) and (c) and and for the curves in (e) and (f). The latter numbers were obtained by diffpy.morph. In (c) and (f) the red curve shows the PDF calculated from a bulk PbS structure model36. The green curve is the difference plotted offset below.
A more ideal background subtraction and is shown in Figure 12(d) and (e), respectively. This was done using the funcxy morph in DIFFPY.MORPH and using a PDF calculated from a structural model of PbS as the target to morph on to (red curves in Figure 12(c) and (f)).
PDFGETX3 does the PDF conversion by calling PDFGetter() functor (which behaves like a function). This takes in the input data and a set of parameters such as background scales, rpoly and so on and returns out the calculated and . Here we used PDFGetter() as the user-supplied morphing function in the funcxy morph in DIFFPY.MORPH, allowing it to vary the background scale and rpoly parameters with a target function that was a PDF calculated from a structural model for PbS.
This shows how an arbitrarily complicated function can be used for the morphing transformation (here the input and outputs were actually functions in different spaces, reciprocal and real, respectively, and the function involves a polynomial fit and subtraction). Although the morphing function being applied was complicated, the morph itself was not, in the spirit of the morphing philosophy, with only two well-controlled parameters being refined in such a way that real structural signal could not be lost.
The approach was very fast and allowed thousands of datasets to be rapidly processed each with its own optimized PDF transformation parameters.
The refinement process to obtain optimal PDF calculation parameters is particularly helpful for low data, especially for parameters like [40]. A scientist familiar with the PDF method may be able to estimate a good by seeing how it affects the overall shape of the function[40]. However, it is not always possible to measure over a wide enough -range to make good estimations[41, 42] as we encountered recently when probing the ultra-fast dynamics of a system at a recent x-ray free electron laser (XFEL) experiment.
This approach may also be valuable for lab-based sources that may also have low accessible .
(NSWS) samples were synthesized following previously published procedures[43]. In Figure 13(a), we plot s of the NSWS samples measured at at Eu-XFEL[44] using the LPD detector at the FXE beamline[45] (plotted in blue) and measured at the National Synchrotron Light Source II on beamline 28-ID-2 (plotted in red). The XFEL measurements can be done at much higher time resolution compared to the synchrotron, at the cost of a lower . In (b), we have obtained for the synchrotron data (red) by manually tuning the rpoly parameter until the large- behavior of becomes oscillations about zero. The largest ( Å) for the XFEL data is too small to carry out the same analysis, making it difficult to tune rpoly that way. Instead, to obtain the blue curve in Figure 13(b), we again wanted to use PDFGetter() from PDFgetX3 in the funcxy morph, but this time give it as a target function the from the synchrotron experiment. In this case, as well as applying the PDFGetter() corrections, it was necessary to apply a polynomial squeeze morph due to calibration challenges (see Section II C 1); these were applied together by defining a new Python function that wrapped PDFGetter(). Examples of how to do this can be found in the DIFFPY.MORPH documentation. The resulting PDF, plotted in (c), obtained from the morph-obtained XFEL is consistent with that obtained from the synchrotron , albeit with slightly broader peaks due to the lower .
Figure 13. (a) The 1D scattering intensities of NSWS measured at the XFEL over a narrow range (blue) and at the synchrotron over a wide range (red). (b) The obtained from the XFEL using PDFgetX3 and morphing (blue), and the target synchrotron (red). (c) The PDFs obtained by the morphed XFEL (blue) and target synchrotron (red).
These examples show how morphing provides a way for researchers to rapidly obtain PDFs that are as optimal as possible and process their data in a consistent manner.
Morphing transformations
In this section we define the current set of morphs available in DIFFPY.MORPH and develop some theory behind some of the most widely used morph transformations.
In the general setup of morphing, there is a “target” signal and a “morphed” signal. The target signal is unchanged, while the morphs are applied to the morphed signal.
The objective of the morphing process is to minimize the residual between the two signals by applying a series of simple “morphing” transformations. This is like fitting, but it is model independent and it is designed simply to mimic physical effects, such as uniform lattice expansion or changes in thermal vibration, though it could be anything.
The signals could be any 1D functions or spectral signals such as a diffraction patterns, atomic pair distribution functions, but could also be Raman, NMR, or something else.
For simplicity we develop the theory with the spectra being PDFs with the understanding that the morphs can be applied to other signals. Throughout this section, the unmorphed object PDF will be denoted , and the same PDF after morphing will be denoted as , where denotes the set of morphing parameters.
Scaling morph
Scaling morphs correct the intensity of the morphed PDF by a constant . Scaling simply captures the fact that a measured signal might be on a different scale due to differences in the incident flux during measurements, instruments used, uncertainties in the data reduction process, or any factor that serves to change the scale of a signal. The scale morph can be expressed simply as
where is the scale factor.
Stretching morph
Stretching morphs stretch the PDF linearly along the independent variable axis. Stretching simulates the effect of a uniform lattice expansion of the structure when is positive, while simulates a uniform lattice contraction.
The morph is done by linearly interpolating the grid on to a new stretched -grid, . We chose linear interpolation as most PDF data are stored on dense grids, so errors introduced are small and computational speed is a premium.
In detail, given a stretch factor , the stretched distance, is given by
The resulting stretch morph is therefore given by
A real uniform lattice expansion with thermal strain will also rescale the PDF on the -axis by a factor (see Supplemental Material, Section S B). Therefore, we recommend using a scale morph any time a stretch morph is used to account for intensity changes due to isotropic expansion in the physical system.
Smearing morph (general)
Smearing morphs apply a Gaussian broadening factor to broaden a signal. For example, this will mimic different levels of thermal motion in PDF data (Section III 4). To accomplish this we carry out a convolution of the signal with a Gaussian function whose width can be varied.
The Gaussian broadening factor has the form
where is the smear factor, and is the center of the -grid. The choice of is arbitrary, but centering the convolution Gaussian in the middle of the -grid minimizes edge effects in the numerics of the resulting convolution.
The smear morph then convolves the morphed signal with the broadening function according to
This serves to broaden all peaks in ; specifically, the variance of each Gaussian peak is increased by after convolution. The shifts the smeared curve to ensure its centroid matches that of , and the normalization factor ensures the two curves have the same integrated magnitudes. Proof that this operation indeed broadens the peaks of by while maintaining the centers and integrated magnitudes of each peak can be found in Supplemental Material, Section S D.
Note that , so a smear parameter of is equivalent to a smear parameter of .
Smearing morph (PDF-specific)
The smear morph described above can be used to smear any signal. When that signal is a measured function, it is preferred to convert to the radial distribution function (RDF{sup}2`) before applying the smear. As such, DIFFPY.MORPH contains a modified version of the smear morph, called smear-pdf. This is because atomic motion acts to broaden peaks in the RDF, , and not the PDF .
The differences are small and an approximately correct result can be obtained by smearing directly. However, for more accurate results when dealing with PDFs, a user may use the smear-pdf morph instead of the smear morph. At the command line, this is done by using the --smear-pdf option instead of the --smear option. When using DIFFPY.MORPH in a Python script, you would use the smear-pdf parameter instead of smear. If both smear-pdf and smear options are used, the program ignores the smear input and applies the smear-pdf morph only.
For bulk materials, the RDF is related to the PDF by30
where is the atomic density of the material, and may be referred to as the “baseline slope”. When smear-pdf is used, the input functions are assumed to be PDFs. The program will first convert it to an RDF, , using either a user-given baseline slope or a best-fit slope (if the user is unable to provide one). The smear morph then applies a Gaussian broadening factor to . The morphed is then converted back to a PDF which is then returned as the morphed PDF.
Shifting Morph
Shifting morphs shift the signal horizontally or vertically. They may be needed to account for constant backgrounds or calibration errors such as a shifted zero-point in a diffraction pattern. Shifting is also useful for data visualization techniques (e.g. waterfall plotting).
Given a user-specified horizontal shift parameter and vertical shift parameter , the shift morph is expressed simply as
Nanoparticle shape morph in the PDF
PDFs measured from a nanoparticle and bulk sample of the same material can look quite different as the particle’s shape plays a role in shaping the pair distribution function. One can approximate the PDF of a nanoparticle from the PDF of a bulk of the same material by the simple relation30
The shape and inverse shape morphs in DIFFPY.MORPH were designed to compare bulk and nanoparticle PDFs using the nanoparticle characteristic function, . This characteristic function depends on and on some parameters .
The shape morphs take input and simply multiply them by the characteristic function, ,
The inverse shape morphs take input and divide the characteristic function,
Currently, DIFFPY.MORPH has nanoparticle characteristic functions for spheres[46] and spheroids[47]. The spherical nanoparticle characteristic function, , refines the radius, , of the nanoparticle. The spheroidal nanoparticle characteristic function, , refines the equatorial and polar radii, and , respectively.
General ordinate morph
In addition to the morphs introduced above, which are designed to account for specific physical effects, funcy provides a flexible interface for applying user-defined transformations to the -axis data, enabling comparison of signals influenced by experiment- or system-specific distortions. The definition of the funcy morph is,
where is a user-supplied function in the form of a Python function, and represents its parameter dictionary. The user simply defines a Python function that takes the signal and arrays (or equivalently, any and arrays) and a dictionary of parameters then returns the morphed and arrays. This function is passed to the funcy interface along with the morphed and target functions and the parameters are refined to get a good agreement.
General grid (abscissa) morphs
Similarly it is possible to apply user-defined morphs that transform the -axis of the function, generalizing the stretch morph. Below, we describe two morphs: squeeze and funcx. For reasons discussed at the end of this (sub)section, squeeze should be used when the expected change in the x-axis grid is small, while funcx could be used otherwise.
squeeze applies a polynomial transformation to the -axis, where the user can control the order of the polynomial. This offers a flexible approach for correcting non-linear distortions in signals. A zero’th order polynomial is actually the shift morph and a first-order polynomial recovers the behavior of shift and stretch morphs applied together. But the squeeze interface generalizes this to higher orders.
These morphs have been found useful to account for geometric artifacts introduced by 2D detectors, such as module tilts, curved detection planes, or angle-dependent offsets, as well as structural effects intrinsic to the sample. Its use was introduced in Section II C 1.
The transformation is defined as
where are the polynomial coefficients. The desired order, , of the polynomial to use is a user defined input. This is applied as
resulting in a modified coordinate grid with the morphed signal evaluated as
Given a morph and target function, DIFFPY.MORPH will find the best set of to apply in order to match the target.
To compare to previously-described morphs, if all except , squeeze is equivalent to the horizontal shift morph with (Section III 5), and if instead all except , squeeze is equivalent to a stretch morph with (Section III 2).
The current implementation of the squeeze morph takes the original function as a two-column array , where the notation indicates the quantity is an array. Then, squeeze computes using (23) to get . Finally, squeeze reinterpolates back onto the original grid and returns the squeezed function interpolated on to the original grid, i.e., . The reinterpolation is done for consistency and further processing. This is computed using a cubic spline interpolation. Extrapolation is allowed outside the original domain where needed (and the user will be notified if and where the extrapolation occurs). Care should be taken by the user if the morph results in a large extrapolation.
The squeeze morph will warn the user if the polynomial squeeze results in a modified grid, , that is not monotonically increasing. Non-monotonicity of poses a problem in our procedure above, as may no longer be a single-valued function. This means there is no longer a unique way to interpolate onto the grid . We resolve this by modifying to be a single-valued function by first identifying all duplicated grid points in the array ; i.e. for . We then set
giving a single unique value for each grid point where it may be multi-valued. This procedure can result in a that looks vastly different than if the function is not smooth or if the length of the non-monotonic intervals is large, but seems to work well for small extrapolations that are the most common.
In general, we advise users to avoid a non-monotonic squeeze. We have found success by (1) reducing the order of the polynomial and (2) first performing safe morphs like shift and stretch to get estimates of and , and giving those to squeeze as the initial parameter values.
While squeeze can only apply polynomials to the grid, the funcx, in analogy with funcy, morph allows arbitrary functions. The morphed signal is similarly given by (23), though the new grid is now given by
Here, is a user-provided Python function, and is a dictionary of function parameters to refine over. The function should take in both and (equivalently, and ) and return the morphed grid based on the parameters .
The implementation of the funcx morph is slightly different than that of squeeze. After taking in , we simply return . By design, no interpolation on to the original grid is done in this case. This choice allows arbitrary changes in the independent array, permitting, for example, functions that transform into different spaces, such as the PDFGetter() transform described in Section II C 2.
The advantage to funcx is apparent when the morph and target function grids are extremely different as squeeze could result in strange and uncontrolled behavior. However, this means the grid of the morphed function is constantly changing. This makes computing the residual between the morph and target functions difficult, and the calculation of the difference curve can involve varying amounts of interpolation error each iteration of the refinement. As such, we still recommend the squeeze morph for small changes to the grid as it operates on a single unchanging grid.
General function morph
While a user can use the funcx and funcy morphs together to change both the grid and data simultaneously, we have defined a funcxy morph for convenience. This morph is designed to be compatible with PDF calculators such as the PDFGetter() function in PDFGETX^340, so one can refine the PDF calculation from a measured intensity function. This was described in Section II C 2.
For this morph, the user supplies a single function f
that takes in the arrays and as well as a dictionary of parameters . The function must return two quantities: (a) the desired morph on the grid and, (b) on the function values . In Python, this can be done as a tuple or as two comma-separated quantities .
The funcxy morph is then described by
where
One can see the obvious parallels to Eqs. (20),(25).
Chaining together multiple morphs
All morphs (scale, stretch, smear, smear-pdf, shape, squeeze, funcx, funcy, funcxy, etc.) can be chained together with other morphs to incorporate multiple corrections. To do so, a user simply has to enable the morphs they want chained.
There are some limits to this and the user should use good sense. In some cases the code will prevent clashes, for example, only one of the smear and smear-pdf morphs can be used. If the user enables both on accident only the more specific smear-pdf morph will be done. Also, since a polynomial squeeze morph of order zero or higher includes the horizontal shift morph, the horizontal shift morph will be disabled when the squeeze morph is enabled (the vertical shift morph is not affected). For the same reason, if the polynomial squeeze is of order one or higher, the stretch is disabled.
Users enable morphs by specifying them and initializing the parameter values. Additionally, there are convenience commands to fix and free previously specified morphs. Detailed usage can be found in the documentation of the software.
When multiple morphs are specified they are applied a pre-defined order. Since we found the optimizer to perform better by applying more complex morphs first, the default order in which enabled morphs are applied is (at the time or writing): funcxy, funcx, funcy, squeeze, scale, stretch, smear or smear-pdf, shift (horizontal and vertical are refined simultaneously), then shape. This order may change in the future.
Regression targets
For all morphs, the morphing process uses least squares regression to minimize the difference between the morphed and target signals by varying morphing parameters where is used as the objective function.
If the morph and target functions are not on the same grid, the two functions are first interpolated (using linear interpolation) onto a common grid before computing . The interval of this common grid is the intersection of the two original grid intervals (i.e. if the morphed grid is on the interval and the target grid is on the interval , then the new grid interval is ). If the spacing (the distance between consecutive grid points) between the two grids is different, then the common grid uses the larger of the two spacings. If a grid has uneven spacing (the distance between consecutive grid points vary), then its spacing is defined as the average distance between consecutive grid points.
diffpy.morph Software
DIFFPY.MORPH is an open-source Python software package that runs on Windows, MacOS, and Linux operating systems as part of the DIFFPY project[48]. It can be installed from conda-forge[7] using conda (recommended) or from PyPI[6] using pip. The source code is available on GitHub at https://github.com/diffpy/diffpy.morph.
The DIFFPY.MORPH program can be used both using a command line interface (e.g. a bash terminal) or in Python scripts directly.
The program takes in two input files: the file containing the function to be morphed and the file containing the target function. Readable files contain the data as a multi-column table, where one column contains the -array and another column has the function values. This uses the loadData() method in DIFFPY.UTILS[49]. By default when loadData() encounters two columns it assumes the first column is the - and the second column is the -array but this behavior can be overridden. loadData() will skip over header information or can be used to read and return header information.
The user also provides a set of morphs to apply (e.g. scale, stretch, and smear). The program then carries out the morphs described above, returning the optimized morphing parameters. It contains capabilities to plot the morphed function and the reference function with a difference function below, similar to figures in this paper. If requested, the program also returns the morphed function interpolated to the grid of the reference function.
The package also has an API allowing morphs to be called from within Python scripts.
Tutorials for the software and additional code documentation are available in the DIFFPY.MORPH documentation at https://diffpy.org/diffpy.morph/.
Conclusion
We demonstrate morphing as a model-independent tool for comparing 1D spectral data with worked examples that show how useful information may be extracted from diffraction and PDF data. As DIFFPY.MORPH uses no model/structural refinement, it is fast, making it ideal for on-the-fly analysis in high-throughput data settings such as a synchrotron experiment.
While initially developed for x-ray PDFs, our examples show that the technique also works for 1D diffraction patterns and neutron diffraction data. Since DIFFPY.MORPH is model-independent, it can be used on other 1D functions (e.g. density of states, Raman spectra, flattened image data), though it has not been extensively tested beyond powder diffraction patterns and PDFs.
Acknowledgements
Algorithm and software development, paper writing, as well as Billinge-group involvement in the experiments and analysis, was supported by U.S. Department of Energy, Office of Science, Office of Basic Energy Sciences (DOE-BES) under contract No. DE-SC0024141. Initial development (supporting PJ and CF) of DIFFPY.MORPH was done under the Distributed Analysis of Neutron Scattering Data (DANSE) project funded by the US National Science Foundation (NSF) under DMR-0520547. Further developments by CHL were supported by the Next Generation Synthesis Center (GENESIS), an Energy Frontier Research Center funded by the U.S. Department of Energy, Office of Science, Basic Energy Sciences under Award Number DE-SC0019212.
X-ray PDF measurements of the Iridium Telluride samples were conducted on beamline 28-ID-2 of the National Synchrotron Light Source II, a U.S. Department of Energy (DOE) Office of Science User Facility operated for the DOE Office of Science by Brookhaven National Laboratory under Contract No. DE-SC0012704. This contract also supported CP’s synthesis of the IrTe and IrRhTe samples. Crystal growth of the IrPtTe samples by HDZ was supported by the National Science Foundation Grant No. DMR-2003117. ESB acknowledges funding provided by the Institute of Physics Belgrade, through the grant by the Ministry of Science, Technological Development and Innovation of the Republic of Serbia.
X-ray PDF measurements of the PbS nanocrystals were taken at the SACLA beamline 2 at SPring-8 facility in Hyogo, Japan. NSG acknowledges support for the data acquisition by US-DOE-BES Contract No. DE-SC0019375 and a David and Lucile Packard Foundation Fellowship for Science and Engineering. VRKW’s involvement in the experiment was supported by NSF Graduate Research Fellowship No. DGE1106400. AJ and DVT acknowledge support from the U.S. Department of Energy, Office of Science, Basic Energy Sciences, Materials Sciences and Engineering Division, under grant DE-SC0025256. AJ was also partially supported by the Kwanjeong Educational Foundation. We would like to thank Yuya Kubota and Jungmin Kang, Tadashi Togashi, Taito Osaka, and Kensuke Tono for help with the data acquisition.
The NSWS experiments were carried out at the European XFEL in Schenefeld, Germany at beamline FXE under proposal #8015. The authors would like to thank Paul Evans, Peter Zalden, and Christopher Milne for their help with these experiments, and Sanjit Ghose for help with collecting synchrotron data on these samples at beamline 28-ID-2 at NSLS-II (funding noted above). LN would like to thank the Natural Sciences and Engineering Research Council of Canada (NSERC) for funding through a platform Discovery Grant and a Canada Research Chair.
The Neutron PDF measurements of YSZ used resources at beamline BL-1B (NOMAD) at the Spallation Neutron Source, a DOE Office User Facility operated by the Oak Ridge National Laboratory. Special thanks is given to the SNS staff, Joerg Neuefeind, Jue Liu, Emily Van Aucken, and Dante Quirin for aid in data collection and reduction as well as experiment design and planning. Thanks is also given to Margarita Petrova from the Page group for aiding in data collection, sample preparation, and data reduction.
Supplemental Material
Peak shifting in absence of a phase transition
In Section II A1, we showed two PDFs of IrRhTe measured at 250 K and 300 K and claimed the peaks of the higher-temperature PDF are shifted (to the right) of the lower-temperature PDF peaks.
If this is the dominant change, the difference between a function and a slightly right-shifted function should be correlated with the derivative since
to first order in .
Therefore, if our claim that the peaks of the 300 K PDF are shifted from the peaks of the 250 K PDF is valid, we expect to see correlation between and . In Figure S1, we have plotted (in red) and (in blue), where is the grid spacing for . The gradient was computed using forward differences and rescaled by for comparison. The two curves are visually correlated in the high- region supporting the hypothesis that the difference curve originates from a shift of the signal to higher-.
In Figure 4 we showed what plots of , PCC, and , the stretch parameter, look like in the case where a sample is going through a phase transition. In that case, the sample was IrTe. Here we show the same plots for cases where no phase transformation is occurring. Figure S2 shows the case for IrRhTe and S3 the case for IrPtTe. In both plots, we see a smooth change in the stretch parameter, indicating no structural change. This is supported by (a) of these figures, where the and PCC for each morph is plotted, also as functions of temperature. They too smoothly vary as a function of temperature, with the rising and PCC falling.
Figure S2. (a) (blue) and PCC (red) from morphing the 9 K PDF onto PDFs at each temperature point for IrRhTe measured with x-rays at temperatures ranging from 9 K to 299 K. (b) The resulting stretch parameter used in each morph. The curves are all relatively smooth when compared to Figure 4, indicating no interesting structural change occurs across this temperature range.
Because there is no structural phase transition IrRhTe and IrPtTe from 10 K to 300 K, we expect a majority of the difference curve signal between PDFs of these samples measured at these temperatures to be from heating effects. These can be corrected for and removed by DIFFPY.MORPH, as shown in Figure 1.
Figure S3. (a) (blue) and PCC (red) from morphing the 10 K PDF onto PDFs at each temperature point for IrPtTe measured with x-rays at temperatures ranging from 10 K to 295 K. (b) The resulting stretch parameter used in each morph. Like in Figure S2, we see no interesting structural change in this temperature range.
Derivation of the effects on the PDF of a uniform lattice expansion
To begin, we define the radial distribution function (RDF). For atom , its partial radial distribution is defined such that gives the number of atoms that are a distance between and away from . The definition of excludes self-counting, so .
The total RDF, , is the stoichiometric average of the partial RDFs of each atom in the material, or
Thus, gives the number of atomic pairs (per atom) with a separation distance between and .
The RDF is related to the PDF by 30
where is the atomic number density, and is the nanoparticle characteristic function (defined in Supplemental Material, Section S E).
When a material expands isotropically with strain , all distances between pairs of atoms increase by a factor of (compression occurs for ). Thus, the number of atomic pairs with separation distances between and before expansion occurs equals the number of atomic pairs with separation distances between and after. The total number of atoms in the material is unchanged by the expansion. Defining to be the RDF pre-expansion and to be that post-expansion,
Applying a change of variables to the left hand side of (32) gives
Since the relations in (32) and (33) hold for all ,
for all .
The corresponding pre-expansion PDF is
and the post-expansion PDF is
The , are the pre-expansion atomic density and nanoparticle form function, and , the same quantities post-expansion. Due to the expansion, the volume of the material increases by , while the total number of atoms remains constant, so
The post-expansion nanoparticle characteristic function scales as
(See Supplemental Material, Section S E for proof.)
Finally, we conclude that the PDF after expansion is
Therefore, applying a stretch parameter and a scale parameter to models isotropic expansion with strain .
It is important to note that an isotropic expansion (with strain ) generally denotes that time-averaged atomic distances are multiplied by a factor . These time-averaged atomic distances generally correspond to peaks in the PDF. Therefore, we can still conclude from our derivation of Eq. (41) that peaks in are located at the same -positions as peaks in .
We note that this treatment strictly holds only for a uniform expansion. This is unlikely to be a good approximation for structures with highly anisotropic structures or when there exist hierarchical bonding strengths; for example, molecular solids where a large lattice expansion will not be reflected in large changes in intra-molecular PDF.
It is not necessarily the case, however, that the relation Eq. (41) holds for all parts of the PDF. Since atoms are not stationary, the RDF is a time-dependent function . Thus, so too is the PDF . The PDF we obtain from a material experimentally can be thought of as the time-averaged PDF of that material over the data collection period. The conditions causing a uniform lattice expansion (e.g. increasing temperature) can also change how atomic positions are distributed over time and affect the PDF in a manner distinct from Eq. (41). Other morphs are required to account for these changes. (For example, in Section S D, we show how the smearing morph is used to correct for one such effect.)
With these caveats said, in our experience, the stretch morph can still be a useful approximate first step even when the conditions discussed above are not perfectly met.
Uniform Lattice Expansion Effects on Reciprocal Space Functions
We showed above how a uniform lattice expansion with strain stretches the grid of the PDF by a factor . Below we show that the same expansion instead stretches the reciprocal space (-space) function grid by a factor .
In particular, we derive the relations Eqs. (45), (48), (86), and (84) in order to show that isotropic expansion of a material by strain stretches the grid of the reciprocal space functions , , and by .
While the change in , , and 1D neutron scattering intensities due to lattice expansion can be fully explained by the aforementioned grid stretch, this is not strictly the case for the 1D x-ray and electron scattering intensities. However, we have observed that in practice, for small , it is still a very accurate approximation with little error. This error, we will show, grows linearly with .
Effect on scattering intensities,
In a system with atoms, the full 1D coherent scattering intensity function (of an isotropic sample) is given by
where is the distance between atoms and . Removing the self-scattering gives the 1D discrete scattering intensity
In the case of neutron scattering, the denote the coherent neutron scattering lengths that are independent of . Therefore, upon an isotropic expansion with strain , the interatomic distances become . The coherent scattering intensity post--strain is then
Thus, if a stretch morph is applied on to match as target, the stretch parameter will be
The same relation holds for the discrete scattering intensity:
In the case of x-ray (and electron) scattering, we replace the in Eq. (42) with -dependent atomic form factor functions . Here, the scattering intensity function
Uniform Lattice Expansion Effects on Reciprocal Space Functions
post-expansion is given by
In General
Our simple stretch no longer works as the are unchanged by the isotropic expansion.
In practice, this error has very little effect on our morphing results. We will showcase this on a set of simulated data and then on real experimental data.
For the simulated data, we consider an Ir–Te bond of length Å1. Its contribution to the x-ray scattering intensity is
To simulate how a strain acts on the , we can apply a stretch morph with stretch parameter . The stretch morph simulated contribution from this bond is
However, in reality, an strain on a material will produce a scattering intensity following (given by Eq. (49)), with the contribution by the Ir–Te bond as
We will show, however, that the stretch morph still well-approximates the actual effects of straining (i.e. ).
We can compute and by approximating Gaussians,
with coefficients , , for Ir and Te taken from the literature2.
In Figure S4, we compute and plot (in red) for . We have morphed to match using the morphing parameters in Table S1. The of the morph is extremely small at . The scale parameter and stretch parameter , meaning the parameter we extract from morphing s will accurately model the strain according to Eq. (47).
Figure S4. (a) (blue) and (red) computed for . A scale and stretch morph has been applied to . The difference curve (green) is scaled . (b) The same plot as (a), but for . All values are computed on the grid with grid spacing .
| Ir–Te | Ir–Te | Ir–Ir | Ir–Ir | Te–Te | Te–Te | |
| 0.01 | 0.001 | 0.01 | 0.001 | 0.01 | 0.001 | |
| 3.34 | 0.385 | 2.64 | 0.319 | 3.94 | 0.443 | |
| 1.80 | 0.0613 | 1.52 | 0.0367 | 2.14 | 0.0932 | |
| 9.36 | 1.07 | 9.04 | 1.04 | 9.84 | 1.11 |
Table S1. Test of the effects of the dependence of the x-ray form factor on the accuracy of the DIFFPY.MORPH parameters, (stretch) and (scale). If the approximation is good we expect to be close to unity and to be close to . We also expect to be small. These conditions are satisfied for reasonable strains of 0.01 and 0.001. We also find that the error scales with .
Changing to ( is reduced by an order of magnitude), we see in Figure S4 the is also reduced by about
an order of magnitude. We also see in Table S1 the new and are both an order of magnitude closer to zero compared to the case, indicating that we can even more accurately extract the strain from the stretch parameter.
Repeating these calculations for a simulated Ir–Ir and Te–Te bond (both with length 3 Å) in Table S1, we see again that the stretch morphed contribution still accurately models the actual contribution , with extremely small discrepancies and .
We also observe the same trend as Figure S4 where , , and for are an order of magnitude smaller compared to the parameters when . This is not a coincidence, as we will show in Section S C 2. Finally, we will demonstrate on real experimental data that the errors from applying Eqs. (45),(48) are small, and that they are still good models for x-ray data. In Section S B, we showed that a strain corresponds to a stretch parameter for a morph between PDFs. If Eqs. (45),(48) apply, the stretch parameter between corresponding s will follow
We measured s of samples of IrRhTe and IrPtTe in the temperature range K to K. From each , a PDF was computed. To obtain the PDF stretch parameters , we morphed low-temperature (9 K for the Rh-substituted sample and 10 K for the Pt-substituted sample) PDFs against higher-temperature (up to 295 K for the Rh-substituted sample and 299 K for the Pt-substituted sample). We performed the same process on the 1D diffraction patterns extracted at the same temperatures to obtain . In Figure S5, we plot vs. for the two samples. The slopes of the plots above are within 1.14% from the value of 1 predicted by Eq. (57). As such, we can use Eqs. (45),(48) to model the effect of a strain on the s, showing diffpy.morph can be used just as effectively on data as PDF data.
Figure S5. The stretches, , and reciprocal of the stretches, , for the IrRhTe sample (blue) and the IrPtTe sample (red). The correlation coefficients are 0.99980 for IrRhTe and 0.99993 for IrPtTe.
Analytically bounding the error
In Table S1, it can be seen that the error (the s) from applying Eq. (45) seems to decrease linearly with . This can be shown analytically. We start by quantifying the error at each as
We will show for x-ray scattering (within a -range of Å Å),
for some constant independent of . In words, we will show that the error is (approximately) linearly upper-bounded by the magnitude of the strain.
By applying Eqs. (42),(56), we see that the error in Eq. (58) is
where
For , , with maximum attained at
For , , with minimum attained at . For both cases,
where this approximation holds for small . For , the approximation holds up to a relative error of 0.5%. Then, as , we can very loosely upper-bound the error
As such, we have demonstrated our desired relation Eq. (59).
A similar derivation can be done to show the error from applying Eq. (48),
is also (approximately) linear in .
Effect on scattering structure functions S(Q) and F(Q)
In the process of computing the PDF from , we compute two intermediate reciprocal-space functions and . We show below how these functions are defined and how an isotropic expansion with strain also stretches their grid by . The equations below use the -independent coherent neutron scattering length , but all derivations follow equivalently if one chooses to use the -dependent form factors instead.
The total scattering structure function, , is the discrete scattering intensity normalized by the average scattering factor30:
For a finite number of scatterers, , are finite and the scattering intensities are non-zero, ensuring is finite as long as the denominator of Eq. (72) is non-zero. We will assume this is the case, as only very rare combinations of materials will cause the scattering length products to perfectly cancel.
The reduced total scattering structure function is then obtained from through
Since and thus is finite, .
We finally obtain the PDF through the relation30
To be pedantic, since we include the small angle scattering -values in the integral above, the result obtained is actually
where is the radial distribution function explored in Section S B. Our derivations below will use the more commonly used (albeit inaccurate) expression Eq. (74), but all results follow equivalently by substituting Eq. (74) with Eq. (75) and Eq. (76) with Eq. (34).
Now, let us consider a PDF of a material and PDF of the same material having undergone uniform expansion with strain .
Let be the functions used in the computation of and used in computing . To avoid dealing with -dependent form factors, we will work backward to obtain expressions for the functions post-uniform-expansion in terms of their original counterparts.
Combining Eq. (74) and Eq. (76) gives
where we have applied a change of variables on the last step. From Eq. (74),
and subtracting Eq. (78) gives
Since and ,
so by the inverse sine Fourier transform of an odd function[52],
Therefore
Then, from Eq. (73),
This means for all ,
For continuous , , this means as well (and thus Eq. (86) also holds at ).
Modeling Thermal Smearing on the PDF
Peaks in the radial distribution function (see Supplemental Material, Section S B for definition) obtained from measured PDFs have approximately Gaussian shapes due to Debye-Waller effects. The variance of each peak is given by the atomic displacement parameters (ADP) of the atoms contributing to . The ADP can depend on dynamic (temperature-dependent) and static factors[53]. Models, such as the Debye model, generally separate the two. Per this model, the mean square ADP, denoted , is given by
where increases with temperature. Specifically, the Debye model treats the temperature-dependent component as[53]
where is the mass of the atom , is the Debye temperature of the (crystal) material, is Planck’s constant, and is Boltzmann’s constant. Since
is a strictly increasing function of for , increasing causes to increase by some positive quantity . Increases in the ADP translate to broadening of each Gaussian peak in the RDF.
Motivated by the Debye model, the smear morph broadens all Gaussian peaks in a radial distribution function by an increased variance of . As , only thermal broadening due to increases in temperature can be captured, so it recommended to use DIFFPY.MORPH to morph a lower-temperature sample to match a target higher-temperature sample.
It is of note that the Debye model indicates that the temperature-dependent component of the ADP depends on the mass of the atom (see Eq. (88)). As such, increasing temperature will broaden each peak in the RDF differently. DIFFPY.MORPH only captures the “average” broadening, but still works well to reduce features in the difference due to thermal broadening. A user can also tell DIFFPY.MORPH to evaluate the smearing on an interval capturing a single peak of interest.
The exact operation done by DIFFPY.MORPH is given in Eq. (14). Below, we prove that this broadens all peaks in by an additional variance .
Assume our radial distribution function can be decomposed into a sum of Gaussians
Nanoparticle Characteristic Function
where each is the amplitude multiplied to a normalized Gaussian following
with mean and variance . Convolving the Gaussian broadening factor from Eq. (13) with a single Gaussian gives
where we have defined
Some rearrangement lets us evaluate the integral
As the convolution operator is linear, convolving from Eq. (90) with gives
Therefore,
which is , but with each Gaussian peak broadened by an additional variance .
Nanoparticle Characteristic Function
The shape of a nanoparticle plays a role in shaping the PDF through the nanoparticle characteristic function (see Eq. (17)). In this section, we detail how the form factor is computed and prove the equality in Eq. (39).
To begin, define the shape function , which takes value 1 for within the nanoparticle and 0 for outside. The unaveraged particle form factor is the autocorrelation of this shape function averaged over the nanoparticle volume , computed as30
We refer to the angle-averaged version of this quantity, denoted , as the nanoparticle characteristic function, which is given by30
There is an important relationship between the nanoparticle characteristic function of a material before and after uniform expansion, used in Supplemental Material, Section S B. Given a material has undergone isotropic lattice expansion with thermal strain , the new form factor is a stretched version of the pre-expansion form factor: . To show this, we first note that expansion maps points in the original material to . Thus, the shape function post-expansion is related to that pre-expansion by
The volume of the nanoparticle is increased by a scale factor due to expansion. Following Eq. (103), the post-expansion nanoparticle characteristic function follows
where
is defined to condense the following equations. Applying a change of variables gives:
Finally, taking the angle-averaged integrals from Eq. (104) gives the desired relation in Eq. (39).
A theoretical motivation for the polynomial grid morph
A common setup for a diffraction experiment uses a flat detector and a (x-ray/neutron/electron) source beam perpendicular to the detector. Scattered rays travel off the sample to the detector some distance away. Let’s say that we measured a sample-to-detector distance of distinct from the actual detector distance . We will show that when the relative error is small (), this results in a polynomial change to the grid of the measured 1D scattering intensity . This motivates the morphs in Section III 8.
For elastic scattering in the setup above, a point on the detector that is a distance from the detector center corresponds to a of1,2
but our computed using the incorrect is
There is no simple polynomial relation between and .
However, letting
be small (), we can Taylor approximate to first order
Then, by using
and some trigonometric identities (further below in this section), this simplifies to a polynomial action on per
For , the relative error of the approximation is for small , and this error decays to 0 for larger . For , in Eq. (116) is a monotonically increasing function of on the observable range .
If we assume , we can further approximate
This shows that the stretch morph can account for this misalignment in low using stretch parameter .
Here at the end, we detail the full derivation of the polynomial approximation in Eq. (116) from the Taylor approximation. For convenience, define
We start by using the double angle formula on Eq. (115) to get
where we have used
Then, we use the half angle formula on Eq. (114) to get
where we have used
Plugging in Eq. (120) into Eq. (123) and simplifying gives
We can now use Eqs. (120),(125) to obtain a polynomial relation
Applying this to Eq. (114) gives the desired Eq. (116).
References
References
- [3]Billinge, S. J. L., & Jensen, K. M. Ø. (2024). Atomic Pair Distribution Function Analysis - A Primer. In International Union of Crystallography Texts on Crystallography.
- [4]4 K. Pearson and F. Galton, Proceedings of the Royal Society of London 58, 240 (1895).
- [5]California, R. of . the U. of . (1988). The 3-clause bsd license.
- [6]Yang, A., Farrow, C. L., Liu, C.-H., Kitsu, L., & Billinge, S. J. L. (2025). diffpy.morph (pypi package). <a href="https://doi.org/https://pypi.org/project/diffpy.morph" rel="noopener noreferrer" target="_blank">https://doi.org/https://pypi.org/project/diffpy.morph</a>
- [7]community, . conda .-. forge . (2025). diffpy.morph (conda-forge package). <a href="https://doi.org/https://anaconda.org/channels/conda-forge/packages/diffpy.morph/overview" rel="noopener noreferrer" target="_blank">https://doi.org/https://anaconda.org/channels/conda-forge/packages/diffpy.morph/overview</a>
- [8]8 N. Lazarević, E. S. Božin, M. Šćepanović, M. Opačić, H. Lei, C. Petrović, and Z. V. Popović, Phys. Rev. B 89, 224301 (2014).
- [9]9 Y. Liu, H. Lei, K. Wang, M. Abeykoon, J. B. Warren, E. Bozin, and C. Petrovic, Phys. Rev. B 98, 094519 (2018).
- [10]10 J. J. Yang, Y. J. Choi, Y. S. Oh, A. Hogan, Y. Horibe, K. Kim, B. I. Min, and S.-W. Cheong, Phys. Rev. Lett. 108, 116402 (2012).
- [11]11 S. Pyon, K. Kudo, and M. Nohara, Journal of the Physical Society of Japan 81, 053701 (2012).
- [12]12 R. Yu, S. Banerjee, H. C. Lei, R. Sinclair, M. Abeykoon, H. D. Zhou, C. Petrovic, Z. Guguchia, and E. S. Bozin, Phys. Rev. B 97, 174515 (2018).
- [13]13 I.-K. Jeong, R. H. Heffner, M. J. Graf, and S. J. L. Billinge, Phys. Rev. B 67, 104301 (2003).
- [14]14 R. Yu, S. Banerjee, H. Lei, M. Abeykoon, C. Petrovic, Z. Guguchia, and E. S. Bozin, Phys. Rev. B 98, 134506 (2018).
- [16]Frandsen, B., Yang, L., & Billinge, S. J. L. (2023). pfdttp_data. <a href="https://doi.org/https://github.com/Billingegroup/pfdttp-data" rel="noopener noreferrer" target="_blank">https://doi.org/https://github.com/Billingegroup/pfdttp-data</a>
- [17]17 E. Grünheisen, Annalen der Physik 344, 257 (1912).
- [18]18 Y. Chang, Journal of Physics and Chemistry of Solids 28, 697 (1967).
- [19]Schroeder, D. (2021). An Introduction to Thermal Physics.
- [20]20 O. L. Anderson, Phys. Rev. 144, 553 (1966).
- [21]21 N. Lazarević, E. S. Božin, M. Šćepanović, M. Opačić, H. Lei, C. Petrović, and Z. V. Popović, Phys. Rev. B 89, 224301 (2014).
- [22]22 S. V. Ushakov, A. Navrotsky, R. J. K. Weber, and J. C. Neufeld, Journal of the American Ceramic Society 98, 3381 (2015).
- [23]23 P. Aldebert, Revue de Physique Appliquée 19, 649 (1984).
- [24]24 M. I. Ahmad, D. G. Van Campen, J. D. Fields, J. Yu, V. L. Pool, P. A. Prilla, D. S. Ginley, M. F. A. M. Van Hest, and M. F. Toney, Review of Scientific Instruments 86, 013902 (2015).
- [25]25 Witz, Grégoire and Shklover, Valery and Steurer, Walter and Bachegoda, Sharath and Bossmann, Hans-Peter, Journal of the American Ceramic Society 90, 2935 (2007).
- [26]26 H. Hayashi, T. Saitou, N. Maruyama, H. Inaba, K. Kawamura, and M. Mori, Solid State Ionics 176, 613 (2005).
- [27]27 J. A. Krogstad, Y. Gao, J. Bai, J. Wang, D. M. Lipkin, and C. G. Levi, Journal of the American Ceramic Society 98, 247 (2015).
- [37]Yang, A., Farrow, C. L., Liu, C.-H., Kitsu, L., & Billinge, S. J. L. (2025). diffpy.morph. <a href="https://doi.org/https://github.com/diffpy/diffpy.morph" rel="noopener noreferrer" target="_blank">https://doi.org/https://github.com/diffpy/diffpy.morph</a>
- [38]A. Jeong, J. Portner, C. P. N. Tanner, O. J. C., C. Zhou, Z. Mi, Y. A. Tazoui, B. Lee, V. R. K. Wall, N. S. Ginsberg, and D. V. Talapin, ACS Nano 18, 33864 (2024).
- [39]J. Kieffer, J. Orlans, N. Coquelle, S. Debionne, S. Basu, A. Homs, G. Santoni, and D. De Sanctis, Journal of Applied Crystallography 58, 138 (2025).
- [40]P. Juhas, T. Davis, C. L. Farrow, and S. J. L. Billinge, J Appl Crystallogr 46, 560 (2013), arXiv:1211.7126 [cond-mat].DOI
- [41]F. Bertolotti and I. Robinson, “Scientific opportunities with very hard xfel radiation,” XFEL.EU WR-2024-002 (2024).DOI
- [42]A. F. Sapnik, P. A. Chater, D. S. Keeble, J. S. O. Evans, F. Bertolotti, A. Guagliardi, L. J. Støckler, E. A. Harbourne, A. B. Borup, R. S. Silberg, A. Descamps, C. Prescher, B. D. Klee, A. Phelipeau, I. Ullah, K. G. Medina, T. A. Bird, V. Kaznelson, W. Lynn, A. L. Goodwin, B. B. Iversen, C. Crepisson, E. S. Bozin, K. M. Ø. Jensen, E. E. McBride, R. B. Neder, I. Robinson, J. S. Wark, M. Andrzejewski, U. Boesenberg, E. Brambrink, C. Camarda, V. Cerantola, S. Goede, H. H¨oppner, O. S. Humphries, Z. Konopkova, N. Kujala, T. Michelat, M. Nakatsutsumi, A. Pelka, T. R. Preston, L. Randolph, M. Roeper, A. Schmidt, C. Strohm, M. Tang, P. Talkovski, U. Zastrau, K. Appel, and D. A. Keen, IUCrJ 12, 531 (2025).
- [43]T. Fuchs, S. P. Culver, P. Till, and W. G. Zeier, ACS Energy Letters 5, 146 (2020).
- [44]W. Decking, in Brilliant Light in Life and Material Sciences, edited by V. Tsakanov and H. Wiedemann (Springer Netherlands, Dordrecht, 2007) pp. 21–30.
- [45]A. Galler, W. Gawelda, M. Biednov, C. Bomer, A. Britz, S. Brockhauser, T.-K. Choi, M. Diez, P. Frankenberger, M. French, D. Gör ries, M. Hart, S. Hauf, D. Khakhulin, M. Knoll, T. Korsch, T. Kubicek, K. Kuster, P. Lang, F. Alves Lima, F. Otte, S. Schulz, P. Zalden, and C. Bressler, Journal of Synchrotron Radiation 26, 1432 (2019).
- [46]K. Kodama, S. Iikubo, T. Taguchi, and S.-i. Shamoto, Acta Crystallographica Section A 62, 444 (2006).
- [47]M. Lei, A. M. R. de Graff, M. F. Thorpe, S. A. Wells, and A. Sartbaeva, Phys. Rev. B 80, 024118 (2009).
- [48]team, D. (2025). DiffPy - atomic structure analysis in python. <a href="https://doi.org/https://www.diffpy.org/" rel="noopener noreferrer" target="_blank">https://doi.org/https://www.diffpy.org/</a>
- [49]Juhás, P., Farrow, C. L., Yang, K. R., Yang, A., Knox, K. R., & Billinge, S. J. L. (2025). diffpy.utils. <a href="https://doi.org/https://github.com/diffpy/diffpy.utils" rel="noopener noreferrer" target="_blank">https://doi.org/https://github.com/diffpy/diffpy.utils</a>
- [52]Boas, M. L. (2006). Mathematical methods in the physical sciences.
- [53]R. E. Diennbier and S. J. L. Billinge, International Tables for Crystallography H, 2 (2018).

















