Acta Polytechnica CTU Proceedings doi:10.14311/APP.2018.17.0020 Acta Polytechnica CTU Proceedings 17:20–23, 2018 © Czech Technical University in Prague, 2018 available online at http://ojs.cvut.cz/ojs/index.php/app FITEXC – DIFFRACTION PROFILE FITTING PROGRAM RUN IN MS EXCEL Petr Vertata, b, ∗, Jan Drahokoupila, c a Department of Solid State Engineering, FNSPE CTU in Prague, Trojanova 13, 120 00, Prague 2, Czech Republic b Department of Magnetic Measurements and Materials, Institute of Physics AS CR, Na Slovance 2, 182 21, Prague 8, Czech Republic c Department of Material Analysis, Institute of Physics AS CR, Na Slovance 2, 182 21, Prague 8, Czech Republic ∗ corresponding author: vertat@fzu.cz Abstract. We present our custom made diffraction fitting program FitExc for the basic treatment of the 1D diffraction profiles, in particular, the Intensity(2θ) of X-ray, synchrotron or neutron diffraction measurements. In the current state, the program allows for simultaneous fitting of up to three profiles in one data set and is intended to be used mainly for precise lattice parameters determination or fitting of overlapped peaks. The entire program is built in the common MS Excel environment, it does not require any installation and is free to use. Keywords: X–ray diffraction, diffraction profile fitting, MS Excel. 1. Introduction X-ray crystallography is a powerful tool with many applications: it is often used to determine the lattice parameters, the complete structure of solids, to examine the phase composition, residual stresses or texture. For multiple applications the precise examination of measured 1D Intensity(2θ) diffraction profiles represents a crucial part of data processing. There are various programs for detailed diffraction profile fitting available. Many of them offer complex solutions implementing the Rietveld refinement process [1] (such as X’Pert Highscore Plus [2], TOPAS [3] or FullProf [4]). On the other hand, there are many applications, where quick and precise fitting of few diffraction peaks and their closest neighbourhood is sufficient. Even in this field, a few programs are used, such as Fityk [5]. Unfortunately, the majority of the programs for X-ray diffraction (XRD) data analysis does not, to our knowledge and experience, allow the user to fully control or customize all the aspects of the fitting in an easily accessible way, nor are they user- friendly or quick enough for easier applications and batch processing. Although the simple fitting of a few diffraction maxima might also be done manually (for example using the Origin software [6]), the approach is often clumsy and require wider knowledge of such environment. We developed a simple user-friendly diffraction profile fitting program FitExc that does not suffer from mentioned disadvantages, yet provides precise results for basic applications. The program, first introduced in [7], is based on the Microsoft Excel environment, which is immediately available on the majority of computers today. Excel’s interface together with Visual Basic for Applications-based macros create a lightweight but powerful tool for the diffraction peak fitting. Another advantage is the immediate possibility to implement user’s own scripts for various kinds of analyses such as macroscopic residual stress determination or the analysis of the crystallite size and strain using the Williamson-Hall plot. 2. Program interface and fitting functions In the attempt to make FitExc as user-friendly as possible, the clickable interface with buttons, drop-down lists and check-boxes was created over the hidden worksheets used for the calculations. Actions are macro-powered and the overall approach is straightforward. First, user is asked to select the file to be loaded. PANalytical .xrdml files are supported as well as standard .xy, .xye or .txt files (multiple columns in the ordinary textfile). Next, the fitting function and the radiation spectrum can be specified. Standard Cauchy, Gauss, Pearson VII and pseudo-Voigt functions are implemented, as well as their split variants for dealing with possible asymmetry. As for the radiation, user may choose from different X-ray tube presets or define his own spectrum containing up to 7 components with desired wavelength, relative intensity and width (Figure 1) [8]. Therefore, the program might be used not only for XRD, but also for neutron or synchrotron diffraction data fitting. On the main fitting page, where the measured data and fitted function are plotted (Figure 2), the entire data processing is controlled. In the current state, up to three profiles might be fitted for one loaded dataset, in the future, the ability to use more than three profiles is to be added. Each of the profiles is defined by 20 http://dx.doi.org/10.14311/APP.2018.17.0020 http://ojs.cvut.cz/ojs/index.php/app vol. 17/2018 FitExc – Diffraction profile fitting program run in MS Excel Figure 1. Program interface: Initial settings worksheet shown after the data file is chosen. Here the basic settings can be specified, such as the spectrum of the radiation, function for fitting or initialisation of the new peak parameters. function formula (f(2θ)) Cauchy A1/(1 + A3(2θ − A2)2) Gauss A1exp(−A3(2θ − A2)2) Pearson VII A1/(1 + A3(2θ − A2)2)A4 pseudo-Voigt A4 Gauss + (1 − A4) Cauchy Table 1. Implemented fitting functions with following parameters: intensity at maximum A1, angular position of the maximum A2 , the relative width A3 and the shape parameter A4 [9]. four parameters A1−4, where A1 is the intensity at maximum, A2 the 2θ position of the maximum, A3 is the relative width parameter and A4 is the shape parameter. The simple formulas for such defined functions are denoted in Table 1 [9]. In the case of asymmetric profiles, instead of one A3 and A4 parameter, two sets of parameters (A31, A41 and A32, A42) are used – one pair for the left and one pair for the right side of the peak. For background fitting, the constant, linear and quadratic forms were implemented so far. The program also calculates the integral intensity of the fitted reflections using analytical formulas where possible and numerical approach for the Pearson VII based functions. The loaded 2θ might be restricted if needed. As one of the advantages, the user is immediately able to fix some parameters that will not be changed during fitting. This makes the program very effective for fitting of complex patterns and multiple overlapped peaks. Fitting algorithm is based on general reduced gradient non-linear least squares method. It is implemented using the Solver (solver.xlam) add-in and the standard worksheet environment of MS Excel run in the background. To evaluate the goodness of the fit the standard discrepancy factors RP , RW P , Rexp and χ2 are calculated and their values might be compared with those before fit. 3. Additional functionality For processing of multiple data, our program allows loading of multiple files. These are then fitted automatically one after another. In case that .xrdml file containing multiple scans is loaded, the batch feature is enabled automatically providing the tool to fit the datasets sequentially. This feature has already been used for determination of the temperature development of selected lattice parameters of magnetic shape memory (MSM) alloys [10]. As our program enables determination of very small changes of the lattice parameters, their temperature evolution is clearly observable even in narrow temperature intervals (Figure 3). Fitting algorithm is stable enough even for fitting of multiple peaks with great intensity differences 21 Petr Vertat, Jan Drahokoupil Acta Polytechnica CTU Proceedings Figure 2. Program interface: The main worksheet for data fitting. User is able to start the fitting, preset or check the fitted parameters, fix them if needed and to see the measured and fitted data including the difference curve. Figure 3. Application example: precisely determined lattice parameters a and b of Ni–Mn–Ga MSM alloy and their evolution while heating. The sudden change denotes the structural transformation [10]. (so far even with two orders difference the results were reliable). To review a situation, the user may immediately choose between the linear and logarithmic scale of the main graph by clicking a single button. Once the good fit is obtained, all the results including the basic settings might be stored in the easily accessible results worksheet. The procedure for easy recovery of the parameters of the fit to the fitting worksheet is also implemented. 4. Conclusions We developed a new simple diffraction profile fitting program FitExc. This lightweight and user-friendly program can be run on any PC with MS Excel (2003 or later) installed. It is intended mainly for the precise fitting of the single reflections (especially their 2θ positions) based on selected or user-defined spectra of the radiation source and for fitting of overlapped peaks. This allows the precise determination of the lattice parameters, observation of their evolution or study of the residual stresses. The program is free to use. To get your own copy, please visit http://people.fjfi.cvut.cz/vertapet/. Acknowledgements This work was supported by the Grant Agency of the Czech Technical University in Prague, grant No. SGS16/245/OHK4/3T/14, and Czech Science Foundation, grants No. 16-00043S and 17-00062S. Authors would like to thank O. Heczko for useful remarks and motivation - the tremendous amount of tasks requiring the development of our program :-) . References [1] H.M. Rietveld: A profile refinement method for nuclear and magnetic structures. J. Appl. Cryst. 2 65–71, 1969. doi: 10.1107/S0021889869006558 [2] T. Degen, M. Sadki, E. Bron, U. Koenig, G. Nenert: The HighScore suite. Powder Diffraction 29 (Supplement S2):S13–S18, 2014. doi: 10.1017/S0885715614000840 [3] DIFFRAC.SUITE TOPAS (Bruker, Karlsruhe, Germany), https://www.bruker.com/products/x-ray- diffraction-and-elemental-analysis/x-ray- diffraction/xrd-software/topas.html 22 vol. 17/2018 FitExc – Diffraction profile fitting program run in MS Excel [4] J. Rodriguez–Carjaval: Recent advances in magnetic structure determination by neutron powder diffraction. Physica B 192 (1–2):55–69, 1993. doi: 10.1016/0921-4526(93)90108-I [5] M. Wojdyr: Fityk: a general-purpose peak fitting program. J. Appl. Cryst. 43 1126–1128, 2010. doi: 10.1107/S0021889810030499 [6] Origin (OriginLab, Northampton, MA). [7] P. Vertat: Diffraction profile fitting in MS Excel. 5. studentska vedecka konference fyziky pevnych latek, Nove Hrady, Ceske vysoke uceni technicke v Praze, 2015. [8] V. K. Pecharsky, P .Y. Zavalij: Fundamentals of Powder Diffraction and Structural Characterization of Materials, Kluwer Academic Publishers: Boston/Dordrecht/London , 2nd ed., p. 115, 2009. [9] R. Kuzel: Informace v praskovem difraktogramu a jeho zpracovani. Materials Structure 10 (1a) 18–19, 2003. [10] L. Straka, J. Drahokoupil, P. Vertat, J. Kopecek, M. Zeleny, H. Seiner, O. Heczko: Orthorhombic intermediate phase originating from {110} nanotwinning in Ni 50.0 Mn 28.7 Ga 21.3 modulated martensite. Acta Mater. 132 335–344, 2017. doi: 10.1016/j.actamat.2017.04.048 23 Acta Polytechnica CTU Proceedings 17:20–23, 2018 1 Introduction 2 Program interface and fitting functions 3 Additional functionality 4 Conclusions Acknowledgements References