research papers
Fine-tuning ab initio XANES spectra calculations using the Bayesian optimization algorithm
aInstitute of Catalysis Research and Technology, Karlsruhe Institute of Technology, Hermann-von-Helmholtz-Platz1, D-76344 Eggenstein-Leopoldshafen, Germany, and bInstitute for Chemical Technology and Polymer Chemistry, Karlsruhe Institute of Technology, Engesserstraße 20, D-76131 Karlsruhe, Germany
*Correspondence e-mail: [email protected], [email protected]
Theoretical modeling of X-ray absorption near-edge structure (XANES) spectra is often performed to interpret experimental spectra and to relate spectral features to the atomic and electronic structure of materials. The sensitivity of the XANES spectra to coordination environment, oxidation state and structural disorder is explored using FEFF and FDMNES simulation codes. With a suitable configuration of these instruments, one can also explore the quantitative characteristics of the studied materials, such as lattice constant, nanoparticle geometry, coordination numbers and longer-range ordering. However, fine-tuning the input parameters is often resource-consuming and non-intuitive. We test the application of the Bayesian optimization (BO) algorithm in finding the most optimal simulation parameters for the theoretical XANES spectra and compare the results using different spectrum similarity metrics. The BO method outperforms the random search technique by a factor of three in speed and shows that the correlation-based metrics provide better shape-level agreement than those defined as normalized distance.
Keywords: XANES; Bayesian optimization; XANES simulation; ab initio calculations; spectra simulations.
1. Introduction
Due to high structural sensitivity at the atomic scale, X-ray absorption spectroscopy (XAS) is widely used for probing local coordination environments, oxidation states and electronic structure in materials ranging from catalysts and battery materials to complex biological systems. X-ray absorption near-edge structure (XANES) is mainly sensitive to the oxidation state and coordination environment, and extended X-ray fine structure (EXAFS) spectroscopy is used primarily to determine coordination numbers, distances and types of the nearest neighbors to the absorbing atom. This is one of the characterization techniques that does not require any local or long-range ordering and can be used on a wide range of substances. Hence, it has become the characterization tool of choice in not only materials research and catalysis but also for molecular species and amorphous materials.
Identification of the species in question mostly relies on analyzing the XANES part of the spectrum. An extensive overview of XAFS analysis tools is given by Bordiga et al. (2013
). In the context of analyzing experimental data, one can name four basic methods (Martini et al., 2020
):
(i) Fingerprinting approach, where the features of the experimental spectrum are compared with features in the reference spectra (e.g. obtained from spectral libraries or theoretically calculated).
(ii) Gradient descent approach, which uses a series of steps to minimize the difference between experimental and theoretical spectra quantified by some objective function. This method is used in such codes as GNXAS (Di Cicco & Filipponi, 2009
; Filipponi et al., 1995
; Filipponi & Di Cicco 1995
), Viper (Klementev, 2001
), MXAN (Benfatto et al., 2021
; Benfatto et al., 2001
) and IFEFFIT (Ravel & Newville, 2005
).
(iii) Indirect approach for modeling the difference between experimental and theoretical spectra with a multidimensional polynomial function, with the minimal discrepancy being found using interpolation techniques. Such a method was applied in the program FitIt (Smolentsev & Soldatov, 2007
) and its successor pyFitIt (Martini et al., 2020
).
(iv) Direct approach, which solves the inverse problem of parameterizing structural parameters to fit the XANES spectrum descriptors. This method embraces a variety of machine-learning-based methods, largely neural networks, which are used to build a black-box correspondence between the XAS spectrum and the system structure (Timoshenko & Frenkel, 2019
; Torrisi et al., 2020
).
The X-ray absorption spectrum simulation plays an important role in the XAS data analysis, helping in qualitative and quantitative interpretation of the measurements. In the context of characterization of heterogeneous (photo-/electro-)catalysts, we are often interested in analyzing solid transition metal nanoparticles (NPs). While spectra of monometallic NPs can often be fitted using library reference spectra of corresponding metal foils or model well defined samples, the situation becomes more complicated for samples containing several metals capable of forming alloys, small particles and/or intermetallic compounds, for which experimentally obtained reference spectra often do not exist and need to be calculated. While the phenomena and the related processes are generally understood, the efforts to provide a precise simulation of EXAFS and especially XANES spectra are still ongoing. There are several simulation codes aimed at the calculation of XANES spectra and their parameters. The FEFF package (Rehr et al., 2010
; Kas et al., 2021
) uses real-space Green's function and multiple scattering for the calculation of excitation spectra and electronic structure. Another tool, FDMNES, can solve the Schrödinger equation using full-potential finite-difference to evaluate near-edge structure (Bunău & Joly, 2009
). The codes OCEAN (Vinson et al., 2011
) and exciting (Gulans et al., 2014
) implement first-principles calculations based on both ground-state density functional theory (DFT) and the Bethe–Salpeter equation. In addition to this, ORCA (Neese et al., 2020
) has attracted a lot of attention as a general-purpose package with a special focus on transition metals and spectroscopy, featuring DFT, wavefunction-based correlation, semi-empirical and force-field methods.
FEFF and FDMNES are the tools that are commonly used for XAS spectrum simulation due to their ease of use, computational speed and out-of-the-box results quality. Our work is therefore focused on these two codes.
FEFF is a widely used ab initio simulation package for XAS, capable of calculating both XANES and EXAFS spectra based on real-space multiple scattering theory. It models the propagation of the photoelectron excited from a core level in the potential created by the surrounding atomic environment, using Green's function method and self-consistent potentials. FEFF supports a wide range of features, including polarization effects, Debye–Waller factors for thermal disorder and many-body corrections for inelastic losses and core-hole effects. Its cluster-based approach makes it particularly well suited for systems with local disorder, surfaces and finite-size effects.
FDMNES is another ab initio simulation package designed to calculate XANES and EXAFS (with the help of the FDMX extension). It solves the Schrödinger or Dirac equation for a photoelectron in a full-potential framework using either a finite difference method or multiple scattering formalism. FDMNES supports both spherical and non-spherical potentials, allowing accurate treatment of low-symmetry environments, anisotropic systems and complex electronic structures. The code accounts for core-hole effects, spin–orbit coupling and electric quadrupole transitions, making it particularly powerful for simulating detailed near-edge features and dichroism.
The XAS simulation codes employ a range of physical models to represent how the X-rays interact with the matter and how this interaction is influenced by the electronic and atomic structure around the absorbing atom. The main physical phenomena described by these models include the photoelectric effect, multiple scattering of the photoelectron, unoccupied density of states and core-hole effects. Not all of these models are first-principle ones and many require being configured with tunable, often empirically found, parameters. Being used by non-experts in the underlying implementation, the XAS simulation codes are often considered as black-box software with configurations made by intuition or at random. On the other hand, the definitions of the best fit to the experimental measurements are often vague and ambiguous, which makes it hard to identify which parameter set brings a better prediction of the experimental spectrum of a given species.
In the case of complex system optimizations that include resource-intensive calculations and where the explicit dependence on the optimized parameters is not known, there are a handful of methods to determine the best modeling parameters. The most often used are the grid search, random search and Bayesian optimization (BO). The grid search is the most ineffective one, since all possible parameter combinations are trialed to cover the whole domain of possible values, and then the best combination is selected. Random search consists of randomly selecting parameter combinations until there is no improvement for a predefined number of trials. This method is known to outperform grid search in the case of large dimensionality of parameter space (Bergstra & Bengio, 2012
). The BO algorithm (Brochu et al., 2010
) is known to beat these two in the majority of cases by utilizing knowledge about previous trials in order to select the parameter set for the next ones. This method is currently a standard go-to in the contemporary hyperparameter tuning tasks, whether machine learning modeling, physical system optimizations or computer simulations are considered.
The Bayesian techniques were previously used for XAS analysis in different directions. Iwamitsu et al. (2020
) used a Bayesian spectroscopy technique to decompose pre-edge peaks from the XANES region of the α-Fe2O3 Fe K spectrum and a similar technique was used (Kashiwamura et al., 2022
) for XANES spectrum deconvolution into the sum of multiple basis functions. The method of two coupled BOs, named adversarial Bayesian optimization (ABO), which comprises an automated parameter fitting to obtain the atomic Hamiltonian and at the same time perform efficient sampling-based active learning, was tested for NiO by Zhang et al. (2023
). Although not directly related to optimization, Haddad et al. (2024
) used Bayes' theorem to estimate the structural parameter correlations in the EXAFS analysis and demonstrate its application by building structural models of CdS magic-size clusters using EXAFS data. Finally, the BO method was applied in the grazing exit X-ray absorption near-edge structure (GE-XANES) experiments to maximize the efficiency of the energy scanning and significantly reduce the measurement time (Cakir et al., 2024
).
In this work, we apply the BO algorithm to fine tune the XAS simulation data from FEFF and FDMNES. We test an approach similar to the gradient descent, but without relying on differentiability. We consider the deviation of the modeled spectra from the measured ones as a black-box objective function, with hyperparameters defined by the simulation package control cards. Crucially, this study includes an evaluation of several spectrum similarity metrics when applied to matching the experimental spectra of several transition metals commonly explored in relation to catalysis and energy storage applications.
2. Methods
2.1. Optimized parameters
Table 1
provides a list of FEFF (v10.0.0) package input parameters that influence the XANES/EXAFS spectrum simulation. For our study, we chose to optimize the prediction of the XANES spectrum. The same method in principle can be applied to the EXAFS spectra too, given that the corresponding parameters are included and the control cards are adjusted (Rehr et al., 2020
).
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A similar list of configuration parameters for the FDMNES/FDM (v2025_07_11) package is provided in Table 2
.
|
||||||||||||||||||||||||||||||||||||||||||||
2.2. Objective functions for BO
The method of BO relies on prior knowledge about the objective function and its properties, such as smoothness. It therefore operates in the functional space by employing the Bayes' theorem, which helps to direct the sampling, and to manage the trade-off between exploration and exploitation of the search space. If xi is the ith sample and f(xi) is the value of the loss function at xi, then the accumulated observations are =
. As we accumulate the observations, the prior distribution is combined with the likelihood function
. Under the assumption that the objective function is smooth and noise-free, the components are combined to obtain the posterior distribution
The objective function is thus interpreted as a surrogate function formally described as a posterior mean function of a Gaussian process. The next sampling location xt+1 is determined using the acquisition function which provides a `hint' where the resulting observation will have either the highest probability of improvement, or Bayesian expected losses, or satisfy another criterion built into the acquisition function definition.
When performing parameter optimization, the definition of the spectrum similarity metric in the loss function is important. Since the experimentally measured XAS spectra are unitless, and the theoretical predictions may have arbitrary spectrum normalization, the most relevant metrics are deemed those that are less sensitive to the magnitude and more sensitive to the distribution of shape and peak positions. One can consider the following metrics (with details given in Appendix A
) to quantify how well the simulated spectra fit to the experimental data: L2 normalized distance, R factor, cosine similarity, Pearson correlation coefficient, Spearman rank correlation score. These metrics display different sensitivities to shape and absolute discrepancy. The L2 normalization distance is constructed as the quadratic norm of the difference between two unit vectors along the direction of intensity vectors (i.e. vectors with coordinates being the intensity values of the spectra, assuming the energy values are the same). The R factor is a ratio of the difference between theoretical and experimental intensity vectors and the experimental one, and cosine similarity is a cosine angle between the theoretical and experimental intensity vectors. Correlation coefficients capture the mutual trends in the spectral shape. To distinguish between normalization of XAS spectra, which involves background subtraction, pre-edge and post-edge fitting, etc. and normalization used in metric computation, we will refer to the former as edge-step normalization and to the latter as vector normalization.
2.3. Experimental spectra
The K-edge transmission spectra of reference Ni, Fe and Pd metal foils used in this study are listed in Table 3
and their XANES regions are presented in Fig. 1
.
|
|
Figure 1
XANES region of the experimentally measured at the (a) Ni K-, (b) Fe K- and (c) Pd K-edge XAS that were used for the analysis |
These measurements come from different facilities: 13-ID-C,D (APS, 2025b
) and 13-BM-D (APS, 2025a
) beamlines of the Advanced Photon Source (APS), BioXAS spectroscopy beamline 07ID-2 (CLS, 2025
) of the Canadian Light Source (CLS) and P65 beamline of the PETRA III synchrotron (Welter et al., 2019
). The datasets in the XDI format (Ravel & Newville, 2016
) are publicly available in the following databases: X-ray Absorption Data Library (XASLIB, 2002
), CLS XAS Database (Spasyuk, 2025
) and RefXAS (Paripsa et al., 2024
) and their corresponding sample ids are shown in Table 3
. P65 samples were recorded by the authors using reference foils available at the beamline. These spectra were preprocessed using standard energy alignment and edge-step normalization procedures in the Larch (Newville, 2013
) package and in-house-developed Python scripts (XASProc, 2025
). The preprocessing parameters for each metal are shown in Table 4
.
|
||||||||||||||||||||||
There are slight differences visible for Fe and Pd spectra, possibly related to the different foil quality (suspected for the case of Fe foils), energy resolution (suspected for the case of Pd foils) and the preprocessing of the respective spectra. Different facilities and beamlines have different beam parameters, such as flux, energy resolution, fraction of higher-order harmonics in the beam and others, as well as different detection modes and systems, which influence the resulting spectral features (Chantler et al., 2018
), and thus may impede the optimization convergence or lead to different optimal parameters of the simulation.
2.4. Optimizing the spectra simulation
The optimization flow was implemented in a Python program BO-XAS (BO-XAS, 2025
). The code is interfaced with Optuna (Akiba et al., 2019
) and uses the ASE (Hjorth Larsen et al., 2017
; Bahn & Jacobsen, 2002
) ecosystem to simulate the crystal structure. The program needs a local FEFF or FDMNES installation, experimental spectra as XDI files and a configuration file. The optimization steps and visualization were run using Jupyter notebooks (Kluyver et al., 2016
). In the optimization process, the headers of the input files for the FEFF or FDMNES simulation packages were created from predefined templates with parameters substituted for every iteration. With simulation time strongly dependent on the parameter values (essentially for the radii) the maximum values were limited, as shown in Table 5
. The convergence of the self-consistent field (SCF) is a vital prerequisite for adequate XAS spectrum simulation in FEFF and FDMNES. Therefore, lower limits were also set on the corresponding radii RSCF and Rself, justified in Appendix B
. The parameter Vr0 in the EXCHANGE card, adjusting the exchange correlation potential which adds a constant shift to the Fermi level, gives a linear shift of the resulting spectrum along the energy axis. This parameter is typically used to account for the energy offset relative to the experimental measurement. In the case of algorithmic optimization, the energy calibration part can be moved into the objective function, casting out one whole dimension. The imaginary part of the potential Vi0 influences the broadening and is kept to account for the instrument-related effects in the spectra.
|
||||||||||||||||||||||||||||||||||||||||||
In order to produce the simulated spectra for particular species, both FEFF and FDMNES also require the atomic structure to be defined in their input files. In this work, we used the ASE library (Hjorth Larsen et al., 2017
) to build the monometallic crystal structures of the samples described above. For Ni and Pd samples, we used face-centered structures with lattice constants of 3.524 Å and 3.890 Å, respectively, and, for Fe samples, we used a body-centered structure with a lattice constant of 2.866 Å (CRC Handbook, 2004
). The cubic bulk cell was generated for every element and then either converted to a crystal description for FDMNES or used to produce explicit cluster geometry for FEFF.
One of the popular open-source libraries that implements the BO algorithm is the Optuna library (Akiba et al., 2019
), which was used in the current study. Optuna is an open-source Python framework that provides a flexible interface to define arbitrary objective functions, supports efficient sampling strategies such as tree-structured Parzen estimator (Bergstra et al., 2011
) and Covariance Matrix Adaptation Evolution Strategy (CMA-ES) (Hansen & Ostermeier, 2001
), and includes pruning mechanisms for early stopping of unpromising trials. The algorithm was configured to perform a series of objective function evaluations varying the input parameters and to stop after reaching a limit of non-improving trials. The stability tests show that ten trials for this limit are enough to reach the objective minimum when fitting the experimental XANES spectrum with FEFF or FDMNES.
3. Results
For every experimental spectrum, we performed an optimization procedure with both FEFF and FDMNES packages using objective functions based on different metrics: L2 normalized distance, cosine similarity, Pearson correlation coefficient, and Spearman rank correlation score. The cumulative results of optimized simulations for various metrics can be seen in Table 6
for the FEFF package and in Table 7
for the Ni APS sample simulated with FDMNES. To compare the metrics' performance on a common basis, we provide the R factors for FEFF results in Table 8
. The values were calculated between experimental spectra and theoretical spectra, integral-scaled to the experimental one. Fig. 2
shows the FEFF spectra optimized with different metrics against the experimental one, with the relative difference in the lower panel. The simulated spectra were energy-aligned and have their intensities integral-normalized. Due to limited computational resources, a similar comparison for the FDMNES-optimized simulation is shown in Fig. 3
for the Ni APS spectrum only.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
|
Figure 2
Results of approximating experimental spectra of different metals with their respective simulations using the FEFF package. The upper section shows the edge-normalized experimental μexp and simulated μth XANES spectra, the lower section shows the relative difference between the simulated spectrum and experimental one Δ = (μth − μexp)/μexp × 100%. Vertical dashed lines denote the fitted energy range. The color legend for simulated spectra in the first plot applies to all other plots. |
|
Figure 3
Results of approximating the experimental Ni APS spectrum using the FDMNES package. The upper section shows the edge-normalized experimental μE and simulated μT XANES spectra; the lower section shows the relative difference between the simulated spectrum and the experimental one, Δ = (μT − μE)/μE × 100%. Vertical dashed lines denote the fitted energy range. |
As noted in Section 2.4
, within the objective function, a secondary objective minimization procedure was applied to perform the energy alignment. In all cases, the main objective function was used as the minimization loss, except for Spearman rank correlation, which, due to its definition, is not sensitive to energy misalignment. In this case, we used L2 normalization distance as a secondary objective.
Despite the metrics chosen for this study being insensitive to the intensity of the spectral features, the objective functions were found to be non-convex, and the optimization results were not reproducible, even with secondary minimization based on the linear energy shift. A variation of the lattice constant was also tested to compensate for the energy scaling (Escaling) effect, but it did not result in any meaningful improvement. Therefore, we had to include Escaling in addition to the linear energy correction. While such a correction is acknowledged as lacking physical grounds, it can be shown that it compensates for some of the systematic discrepancies of the model, helps to get the overall spectrum shape closer to the experimental and consistently reduces the residual, indicating it captures a systematic rather thana random discrepancy.
Table 9
shows L2 normalized distance and Spearman correlation metric values calculated for the simulated foil spectra optimized using baseline Hedin–Lundqvist (HL) and many-pole self-energy (MPSE) models with Escaling enabled and disabled. The L2 metric is less uniform than the Spearman correlation because it is more weighted toward the edge-region intensity. The Spearman correlation shows that the spectrum shape modeling is improved when either Escaling or a many-pole model is used. The plots in Fig. 4
also demonstrate this. The post-edge area has a smoother ratio of simulated spectrum to the experimental one if either Escaling or the many-pole model is enabled, with the highest visual similarity achieved when both are enabled.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Figure 4
Effect of Escaling and many-pole approximation on the FEFF simulation spectra with BO optimization using the L2 normalized distance objective function. The color legend in the top view applies to the two other views. |
This observation lies in agreement with the FEFF documentation (Kas et al., 2021
), which recommends enabling the MPSE option for MPSE approximation `if peaks are slightly beyond the edge need to move to slightly higher energies and require more broadening', which essentially happens when one applies the Escaling. This scaling thus compensates for the insufficient precision of the HL model, which can be improved with the many-pole approximation for two of the three considered foils (Ni, Pd). Numerically, it is reflected by the fact that switching from HL to the many-pole model changes the required Escaling coefficient from 0.960 to 0.975 for Ni APS, from 0.930 to 0.914 for Fe APS and from 0.930 to 0.950 for Pd BIOXAS sample. The more feature-rich absorption edge potentially causes the issue with the iron spectrum.
To test the optimization convergence, we performed several runs with identical inputs but different initial random seeds. For example, fitting the Ni APS sample against L2 normalized distance metric gives good convergence of the resulting R factor Rf = 0.0304 ± 0.0004 with parameters Vi0 = 0.90 ± 0.04 and RFMS = 7.7 ± 0.1, and lower sensitivity for RSCF = 6.7 ± 0.6. Fig. 5
provides a set of contour plots showing a similar loss function landscape for (Vi0, RFMS) coordinates that were obtained in independent optimization runs.
|
Figure 5
Objective function landscape plots calculated by the BO algorithm for the FEFF simulation parameters Vi0 versus RFMS for nine independent Ni APS sample fits with L2 normalized distance used as a metric. The stars denote the best parameter values found during the optimization. |
For this particular case of the Ni APS sample simulated with L2 normalized distance optimization, an example of contour plots for the complete set of parameters that were explored can be seen in Fig. 6
. These figures show the 2D projection landscape of the objective function on the selected dimensions, with the Z-axis corresponding to the L2 normalized distance metric. From such a distribution, one can examine the convexity of the objective function relative to (Vi0, RSCF) and (Vi0, RFMS) parameter pairs. In the (RFMS, RSCF) projection, the objective function may have several local minima, which agrees with the observed low sensitivity to the RSCF parameter (Fig. 8).
|
Figure 6
Objective function landscape plots for the BO algorithm for the Ni APS sample fitted with L2 normalized distance. The stars denote the best parameter values found during the optimization. |
From the quantitative comparison of optimized results between FEFF and FDMNES for the Ni APS sample one can see that, for all metrics, FEFF provides better agreement than FDMNES. However, looking at the graphical spectra representation, one can see that the main contribution to the FDMNES discrepancy comes from an inaccurate description of resonant enhancement due to p–d states hybridization (mid-edge peak at 8335 keV), while the area after the white line shows better matching than FEFF.
It is interesting to see how the BO algorithm performs in comparison with the random search method. In this test, we compare the average number of trials that both algorithms require to converge to the same optimum, given the same non-improvement tolerance of ten runs and the same parameter space. This quantity is calculated for BO repeated runs directly: the 〈L2〉 = 0.0310 ± 0.0004 minimum value of the L2 objective function is reached on average in 17 runs for the FEFF code when simulating the Ni APS sample. For the random sampling, we deduce this quantity from computing the probability p of reaching the 95% confidence interval of the same optimum. Over the series of 1000 simulations with randomized parameter values within the parameter set, 25 outcomes have reached this limit, which gives p = 0.025. According to the Bernoulli distribution, the expected number of trials before success is 1/p = 40. Adding the non-improvement tolerance of ten trials, we obtain that in this particular example the BO reaches the optimum on average about three times faster than the random sampling. Fig. 7
demonstrates how BO is more efficient in converging to the optimum value relative to the random search algorithm.
|
|
Figure 7
Comparison of random search (left) and BO (right) algorithm trials (black dots) while converging to the optimum (red star) plotted for Ni APS sample fitted with L2 normalized distance. |
4. Discussion
The sensitivity of optimization to the simulation parameters can be characterized by the so-called parameter importance. In the case of the BO algorithm implemented in the Optuna library, they are defined by how much each parameter contributed to the variation in the objective value after the optimization procedure (Hutter et al., 2014
). Fig. 8
shows the parameter importance values calculated for the Ni APS sample when using different objective functions. We see that the sensitivity to the Vi0 parameter prevails in the fitting procedure for most of the objective functions, but particularly for cosine similarity RSCF and RFMS also become significant.
|
Figure 8
Optimization parameter sensitivity (importance) calculated for Ni APS sample and different metrics. |
It is important to note that these quantities do not necessarily reflect the parameter relevance, and one should not rely on their values to decide whether to include or discard the parameters from the optimization procedure. The objective function landscape serves better for this purpose. We also find it valuable to check the parameter correlations because they have a direct impact on the reproducibility of the results. Fig. 9
shows the heatmap of correlation coefficients for the Ni APS sample fitted with FEFF simulation using the L2 metric. One can see that the correlation values between Vi0, RSCF and RFMS parameters are below ∼0.2, which can be considered as negligible.
|
Figure 9
Correlations between optimization parameters for the Ni APS sample fitted with the L2 metric. |
As expected the BO algorithm, when applied for fitting of experimental XANES spectra, is more resource-effective as compared with explicit grid-search or random search approaches. Both FEFF and FDMNES calculations can be time-consuming, and reducing the number of iterations required for the optimization procedure is always beneficial. The definition of agreement to the experimental spectra is, however, ambiguous, and the final result is heavily dependent on the chosen metric. The commonly used R factor and L2 normalized distance can give a closer quantitative match, but the correlation-based metrics seem to provide better shape-wise agreement, which complies with the fingerprinting logic. One should also note that the spectrum similarity objective function is non-convex by default, and one may need to apply energy transformation for the simulated spectra of some materials. The linear energy transformation applied in this work helps to achieve robustness of the optimization while preserving the spectral features.
Note that there are alternative methods to improve the theoretical description of experimental spectra: apart from full-scale DFT calculations, one can improve FEFF results by enabling the MPSE model (Kas et al., 2007
) and provide an accurate calculation of the corresponding loss function. While deepening the domain knowledge is always beneficial, many aspects of theory may still be hidden from ordinary users as they will treat the simulation frameworks as a black box. The BO method can thus be used to partially compensate for such shortcomings. In addition, the XANES BO may be efficiently applied to the structural and/or chemical composition analysis, and, presumably, the structural disorder analysis (Li et al., 2021
).
Unlike other applications of Bayesian approaches to XAS analysis, which primarily help to decompose and interpret the spectra, our approach is targeted at obtaining the best possible results when using ab initio calculations that are based on prior knowledge of the material structure.
While the current state of the XANES simulation brings it extremely close to the experiment, its application to numerical analysis is still limited. The ab initio codes are mostly used for qualitative assessment of trends and tendencies that can be observed due to structural or chemical changes. Having a method for more precise configuration of FEFF or FDMNES should make numerical analysis more feasible by allowing a direct matching between data and simulation.
5. Conclusion
Using the BO algorithm based on L2 normalized distance, cosine similarity, Pearson correlation coefficient, Spearman rank correlation score objective functions we performed optimization of input parameters for theoretical XANES calculations by FEFF and FDMNES in order to achieve the best match between calculated and experimental reference spectra. The imaginary optical potential correction and full multiple scattering radius parameters were found to have the strongest influence on the spectra, with the most optimal values being different for every material. For example, for Ni K-edge transmission spectrum the optimal FEFF parameters are Vi0 = 0.95, RFMS = 7.9 and RSCF = 7.6 when using L2 normalized distance and Vi0 = 1.5, RFMS = 6 and RSCF = 7.5 when using Spearman correlation. This is another valuable finding: different objective functions give different optima. One may choose the correlation-based metrics if they want more uniform shape agreement (see, for example, the relative difference plots in Fig. 2
). We observe that applying the BO procedure gains a significant time reduction relative to the random search optimization. The resulting optimal parameter sets are intended to be used for modeling spectra of transition metal species often predicted theoretically (such as bi-, tri-metallic compounds, high entropy alloys, etc.), but which are difficult to obtain experimentally as reliable, well defined reference samples.
Given the promising results of tuning the XANES simulations using the BO algorithm, we can further extend its application to actual catalysis phenomena and energy storage research. This includes local atomic structure, surface versus bulk contributions and structural heterogeneity and disorder under realistic operation conditions. The most interesting application of the present work would be tests of the quantitative interpretation of XANES spectra—a field where the simulation-based methods are currently limited in terms of precision.
APPENDIX A
Similarity metrics for spectrum comparison
To quantify the agreement between experimental and theoretical spectra in the procedure of optimizing theoretical parameters in FEFF and FDMNES packages, we employed several metrics which capture various aspects of spectral similarity. Let the intensities of the experimental (exp) and theoretical (th) spectra, evaluated on the same energy grid of length N, be denoted as Iexp = (Iexp, 1, …, Iexp, N) and Ith = (Ith, 1, …, Ith, N).
A1. L2 normalized distance
The L2 normalized distance quantifies the shape dissimilarity between two spectra after each is vector-normalized to unit Euclidean norm. It is defined as
This metric is sensitive to differences in spectral shape, while being invariant to absolute scaling.
A2. R factor
The R factor is commonly used in EXAFS analysis and measures the relative deviation between the spectra,
It captures the pointwise agreement in intensities, vector-normalized to the total signal of the experimental spectrum.
A3. Cosine similarity
Cosine similarity measures the cosine of the angle between two vectors in high-dimensional space,
It is a shape-based metric, insensitive to offset and absolute scaling.
A4. Pearson correlation coefficient
Pearson correlation coefficient quantifies the linear correlation between two spectra,
where and
denote the mean intensity of each spectrum. This metric reflects how linearly the intensities vary with each other, overall shape similarity and amplitude accuracy.
A5. Spearman rank correlation
Spearman rank correlation coefficient assesses the degree to which the relationship between spectra is monotonic. It is computed as
where di = rank(Iexp, i) − rank(Ith, i) is the difference between the ranks of the intensities. This metric is robust to nonlinear intensity transformations and emphasizes the ordinal agreement of spectral features. It is thus more focused on the order in which the spectrum features appear along the energy axis (e.g. peak positions, pre- and post-edge).
APPENDIX B
SCF convergence
In order to validate the SCF convergence in XAS simulation, the manuals recommend observing the convergence of the Fermi level energy. The general recommendation (Moreno et al., 2007
) is to observe the stability between iterations within one run and to pick RSCF values from the plateau region. Fig. 10
shows an example of the SCF convergence test for Ni, Fe and Pd monometallic crystal simulations studied in this work. It is visible that, for Ni and Fe, the approximate stability is reached for RSCF > 6.5, corresponding to cluster size >100 atoms. For Pd, the limits are even higher, and start from RSCF > 9 (150 atoms), which makes iterative calculations very expensive.
|
Figure 10
SCF radius convergence test with FEFF calculations for Ni, Fe and Pd foils. The convergence values start for clusters around above 100 atoms. |
Acknowledgements
We acknowledge support by the state of Baden-Württemberg through bwHPC and the German Research Foundation (DFG) through grant no INST 40/575-1 FUGG (JUSTUS 2 cluster). We are also thankful to Alexey Boubnov for fruitful discussions on the simulation details and to the authors and maintainers of the XASLIB, Canadian Light Source XAS and RefXAS databases for providing free access to the XAS spectra that were used in this work. Open access funding enabled and organized by Projekt DEAL.
Conflict of interest
There are no conflicts to declare.
Data availability
The data and the computer programs supporting the reported results can be shared upon a reasonable request.
Funding information
We thank the Helmholtz Association (HGF) for funding within the framework of the ROCK-IT project and the MTET program.
References
Akiba, T., Sano, S., Yanase, T., Ohta, T. & Koyama, M. (2019). Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 4–8 August 2019, Anchorage, AK, USA.
Google Scholar
APS (2025a). 13 BM-D beamline: Tomography, diamond anvil cell, and large-volume press capabilities. GSECARS at University of Chicago – APS Beamline Overview. Accessed: 2025–09-09. https://gsecars.uchicago.edu/gsecars-facility/sector-13-beamlines/13-bmd/.
Google Scholar
APS (2025b). 13 ID-C beamline: General-purpose diffractometer and grazing incidence spectroscopies. GSECARS at UChicago – Advanced Photon Source beamline overview. Accessed: 2025–09-09. https://gsecars.uchicago.edu/gsecars-facility/sector-13-beamlines/13-idc/.
Google Scholar
Bahn, S. R. & Jacobsen, K. W. (2002). Comput. Sci. Eng. 4, 56–66.
Web of Science
CrossRef
CAS
Google Scholar
Benfatto, M., Congiu-Castellano, A., Daniele, A. & Della Longa, S. (2001). J. Synchrotron Rad. 8, 267–269.
Web of Science
CrossRef
CAS
IUCr Journals
Google Scholar
Benfatto, M., Della Longa, S., Pace, E., Chillemi, G., Padrin, C., Natoli, C. R. & Sanna, N. (2021). Comput. Phys. Commun. 265, 107992.
Web of Science
CrossRef
Google Scholar
Bergstra, J., Bardenet, R., Bengio, Y. & Kégl, B. (2011). In Advances in Neural Information Processing Systems edited by J. Shawe-Taylor, R. Zemel, P. Bartlett, F. Pereira & K. Weinberger, Vol. 24. Curran Associates, Inc. (https://proceedings.neurips.cc/paper_files/paper/2011/file/86e8f7ab32cfd12577bc2619bc635690-Paper.pdf)
Google Scholar
Bergstra, J. & Bengio, Y. (2012). J. Mach. Learn. Res. 13, 281–305.
Google Scholar
Bordiga, S., Groppo, E., Agostini, G., van Bokhoven, J. A. & Lamberti, C. (2013). Chem. Rev. 113, 1736–1850.
Web of Science
CrossRef
CAS
PubMed
Google Scholar
BO-XAS (2025). BO-XAS: Bayesian optimization for x-ray absorption spectra, https://github.com/ITCP-AKG/boxas.
Google Scholar
Brochu, E., Cora, V. M. & de Freitas, N. (2010). arXiv:1012.2599.
Google Scholar
Bunău, O. & Joly, Y. (2009). J. Phys. Condens. Matter 21, 345501.
Web of Science
PubMed
Google Scholar
Cakir, C. T., Bogoclu, C., Emmerling, F., Streli, C., Guilherme Buzanich, A. & Radtke, M. (2024). Mach. Learn. Sci. Technol. 5, 025037.
CrossRef
Google Scholar
Chantler, C. T., Bunker, B. A., Abe, H., Kimura, M., Newville, M. & Welter, E. (2018). J. Synchrotron Rad. 25, 935–943.
Web of Science
CrossRef
CAS
IUCr Journals
Google Scholar
CLS (2025). Bioxas-spectroscopy beamline (07id-2): High-sensitivity x-ray absorption spectroscopy for biological and environmental samples. Canadian Light Source, Saskatchewan, Canada – Beamline Overview. Accessed: 2025–09-09. (https://www.lightsource.ca/facilities/beamlines/cls/beamlines/bioxas-spectroscopy.php).
Google Scholar
CRC Handbook (2004). CRC Handbook of Chemistry and Physics, 85th ed. Boca Raton: CRC Press.
Google Scholar
Di Cicco, A. & Filipponi, A. (2009). J. Phys. Conf. Ser. 190, 011001.
Google Scholar
Filipponi, A. & Di Cicco, A. (1995). Phys. Rev. B, 52, 15135–15149.
CrossRef
CAS
Web of Science
Google Scholar
Filipponi, A., Di Cicco, A. & Natoli, C. R. (1995). Phys. Rev. B, 52, 15122–15134.
CrossRef
CAS
Web of Science
Google Scholar
Gulans, A., Kontur, S., Meisenbichler, C., Nabok, D., Pavone, P., Rigamonti, S., Sagmeister, S., Werner, U. & Draxl, C. (2014). J. Phys. Condens. Matter 26, 363202.
CrossRef
PubMed
Google Scholar
Haddad, L., Gianolio, D., Dunstan, D. J., Liu, Y., Rankine, C. & Sapelkin, A. (2024). Nanoscale 16, 5768–5775.
CrossRef
PubMed
Google Scholar
Hansen, N. & Ostermeier, A. (2001). Evol. Comput. 9, 159–195.
Web of Science
CrossRef
PubMed
CAS
Google Scholar
Hjorth Larsen, A., Jørgen Mortensen, J., Blomqvist, J., Castelli, I. E., Christensen, R., Dułak, M., Friis, J., Groves, M. N., Hammer, B., Hargus, C., Hermes, E. D., Jennings, P. C., Bjerre Jensen, P., Kermode, J., Kitchin, J. R., Leonhard Kolsbjerg, E., Kubal, J., Kaasbjerg, K., Lysgaard, S., Bergmann Maronsson, J., Maxson, T., Olsen, T., Pastewka, L., Peterson, A., Rostgaard, C., Schiøtz, J., Schütt, O., Strange, M., Thygesen, K. S., Vegge, T., Vilhelmsen, L., Walter, M., Zeng, Z. & Jacobsen, K. W. (2017). J. Phys. Condens. Matter 29, 273002.
Web of Science
CrossRef
PubMed
Google Scholar
Hutter, F., Hoos, H. & Leyton-Brown, K. (2014). In Proceedings of the 31st International Conference on Machine Learning, edited by E. P. Xing & T. Jebara, Vol. 32 of Proceedings of Machine Learning Research, pp. 754–762. Beijing, China. (https://proceedings.mlr.press/v32/hutter14.html).
Google Scholar
Iwamitsu, K., Yokota, T., Murata, K., Kamezaki, M., Mizumaki, M., Uruga, T. & Akai, I. (2020). Phys. Status Solidi B 257, 2000107.
CrossRef
Google Scholar
Kas, J. J., Sorini, A. P., Prange, M. P., Cambell, L. W., Soininen, J. A. & Rehr, J. J. (2007). Phys. Rev. B 76, 195116.
CrossRef
Google Scholar
Kas, J. J., Vila, F. D., Pemmaraju, C. D., Tan, T. S. & Rehr, J. J. (2021). J. Synchrotron Rad. 28, 1801–1810.
Web of Science
CrossRef
CAS
IUCr Journals
Google Scholar
Kashiwamura, S., Katakami, S., Yamagami, R., Iwamitsu, K., Kumazoe, H., Nagata, K., Okajima, T., Akai, I. & Okada, M. (2022). J. Phys. Soc. Jpn 91, 074009.
CrossRef
Google Scholar
Klementev, K. V. (2001). J. Phys. D Appl. Phys. 34, 2241–2247.
CrossRef
Google Scholar
Kluyver, T., Ragan-Kelley, B., Pérez, F., Granger, B. E., Bussonnier, M., Frederic, J., Kelley, K., Hamrick, J. B., Grout, J., Corlay, S., Ivanov, P., Avila, D., Abdalla, S. & Willing, C. (2016). Positioning and Power in Academic Publishing: Players, Agents and Agendas, pp. 87–90. IOS Press.
Google Scholar
Li, J., Li, Y., Routh, P. K., Makagon, E., Lubomirsky, I. & Frenkel, A. I. (2021). J. Synchrotron Rad. 28, 1511–1517.
Web of Science
CrossRef
CAS
IUCr Journals
Google Scholar
Martini, A., Guda, S., Guda, A., Smolentsev, G., Algasov, A., Usoltsev, O., Soldatov, M., Bugaev, A., Rusalev, Y., Lamberti, C. & Soldatov, A. (2020). Comput. Phys. Commun. 250, 107064.
CrossRef
Google Scholar
Moreno, M., Jorissen, K. & Rehr, J. (2007). Micron 38, 1–11.
CrossRef
PubMed
Google Scholar
Neese, F., Wennmohs, F., Becker, U. & Riplinger, C. (2020). J. Chem. Phys. 152, 224108.
Web of Science
CrossRef
PubMed
Google Scholar
Newville, M. (2001). Ni foil room temperature, https://xaslib.xrayabsorption.org/spectrum/147/.
Google Scholar
Newville, M. (2002). Fe foil room temperature, https://xaslib.xrayabsorption.org/spectrum/111/.
Google Scholar
Newville, M. (2013). J. Phys. Conf. Ser. 430, 012007.
CrossRef
Google Scholar
Paripsa, S., Gaur, A., Förste, F., Doronkin, D. E., Malzer, W., Schlesiger, C., Kanngießer, B., Welter, E., Grunwaldt, J.-D. & Lützenkirchen-Hecht, D. (2024). J. Synchrotron Rad. 31, 1105–1117.
Web of Science
CrossRef
CAS
IUCr Journals
Google Scholar
Ravel, B. & Newville, M. (2005). J. Synchrotron Rad. 12, 537–541.
Web of Science
CrossRef
CAS
IUCr Journals
Google Scholar
Ravel, B. & Newville, M. (2016). J. Phys. Conf. Ser. 712, 012148.
CrossRef
PubMed
Google Scholar
Rehr, J. J., Kas, J. J., Jorissen, K., Ankudinov, A. & Ravel, B. (2020). FEFF10 Users Guide, Version 10.0.0, https://github.com/times-software/feff10/releases/download/v10.0.0/feff10_users_guide.pdf.
Google Scholar
Rehr, J. J., Kas, J. J., Vila, F. D., Prange, M. P. & Jorissen, K. (2010). Phys. Chem. Chem. Phys. 12, 5503–5513.
Web of Science
CrossRef
CAS
PubMed
Google Scholar
Selinsek, M., Deschner, B. J., Doronkin, D. E., Sheppard, T. L., Grunwaldt, J.-D. & Dittmeyer, R. (2018). ACS Catal. 8, 2546–2557.
CrossRef
Google Scholar
Smolentsev, G. & Soldatov, A. (2007). Comput. Mater. Sci. 39, 569–574.
CrossRef
Google Scholar
Spasyuk, D. (2025). Xasdb – design and implementation of an open-access spectral database, https://arxiv.org/abs/2509.13566.
Google Scholar
Spasyuk, D., Mikhchian, M., Blanchard, P., Vu, M., Reid, J., Bergen, E., Chen, N., Desmau, M., Chernikov, R., Pan, Y., Lin, J. & Grosvenor, A. (2025). Canadian light source xas database data, https://doi.org/10.20383/103.01329.
Google Scholar
Timoshenko, J. & Frenkel, A. I. (2019). ACS Catal. 9, 10192–10211.
Web of Science
CrossRef
CAS
Google Scholar
Torrisi, S., Carbone, M., Rohr, B., Montoya, J. H., Ha, Y., Yano, J., Suram, S. & Hung, L. (2020). ChemRxiv, doi:10.26434/chemrxiv.11873691.v1.
Google Scholar
Vajglová, Z., Gauli, B., Mäki-Arvela, P., Kumar, N., Eränen, K., Wärnå, J., Lassfolk, R., Simakova, I. L., Prosvirin, I. P., Peurla, M., Lindén, J. K. M., Huhtinen, H., Paturi, P., Doronkin, D. E. & Murzin, D. Y. (2023). ACS Appl. Nano Mater. 6, 10064–10077.
Google Scholar
Vinson, J., Rehr, J. J., Kas, J. J. & Shirley, E. L. (2011). Phys. Rev. B 83, 115106.
CrossRef
Google Scholar
Welter, E., Chernikov, R., Herrmann, M. & Nemausat, R. (2019). AIP Conf. Proc. 2054, 040002.
Google Scholar
XASLIB (2002). IXAS – X-ray absorption data library, https://xaslib.xrayabsorption.org.
Google Scholar
XASProc (2025). Xasproc: A basic preprocessing library for xas spectra (xasproc), https://github.com/ITCP-AKG/xasproc.
Google Scholar
Zhang, Y., Xie, R., Long, T., Günzing, D., Wende, H., Ollefs, K. J. & Zhang, H. (2023). npj Comput. Mater. 9, 46.
CrossRef
Google Scholar
This is an open-access article distributed under the terms of the Creative Commons Attribution (CC-BY) Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original authors and source are cited.

journal menu
access



