## Introduction

X-ray and extreme ultraviolet (XUV) free-electron lasers (FELs)1,2,3,4,5 enable investigation of X-ray induced demagnetization within magnetic materials on femtosecond timescales. FELs generate intense, coherent pulses of femtosecond duration and tunable wavelength, which can rapidly induce strong electronic excitation in solid materials. Historically, since its discovery in 19966, ultrafast demagnetization on sub-picosecond timescales was studied mostly with lasers working in the infrared wavelength regime7,8,9,10. X-ray FELs provide not only an opportunity to probe magnetic properties of solids on femtosecond timescales and at nanometer length scales but they also enable to study ultrafast demagnetization induced by photons of much higher energies than those accessible with optical lasers11,12,13,14,15,16. This is possible with resonant X-ray magnetic scattering17,18,19. The energy of photons in the FEL beam is then tuned to an absorption edge of a ferromagnetic element. Transient magnetic properties of the system can be followed, taking advantage of X-ray magnetic circular dichroism (XMCD) effect, for example, by performing a resonant magnetic small-angle X-ray scattering (mSAXS) measurement20,21. In particular, for samples characterized by a strong perpendicular magnetic anisotropy, the latter scheme gives access to X-ray induced ultrafast changes within magnetic domains22,23. Let us emphasize that in such experiments11,12,13 the X-ray pulse serves both as a pump and as a probe, exciting the material and simultaneously probing the excited state with magnetic scattering.

The mSAXS measurement principle is the following (see, e.g., ref. 20). The resonant coherent elastic scattering amplitude for a magnetic ion includes a contribution from charge and magnetic scattering17,18. For an X-ray beam (i) arriving perpendicularly to the surface of a magnetic sample (with magnetization vectors also perpendicular to the surface), and (ii) scattered into a ring of a radius reflecting the spatial correlation of magnetic domains (typically on 100 nm length scales, i.e., large in comparison with charge heterogeneity, ~10 nm), the overall scattering amplitude reduces to the magnetic contribution only17,20. In the electric dipole approximation, it reads:

$${F}^{{{{\rm{magn}}}}}=-{{{\rm{i}}}}\cdot \left({{{\bf{e}}}}\times {{{{\bf{e}}}}}^{\prime}\right)\cdot {{{\bf{m}}}}\,\,{F}^{{{{\rm{m1}}}}}.$$
(1)

The vectors e and $${{{{\bf{e}}}}}^{\prime}$$ are polarization vectors of the incoming and scattered radiation, m is the unit vector of the magnetization. The complex dipole-transition matrix element, Fm1, describes the resonant magnetic scattering strength19. It depends, among others, on the difference between the incoming photon energy and the resonant energy, and on the actual material magnetization, M.

As the resonant magnetic scattering strength, Fm1, is proportional to the magnetization of the sample11,13, any changes of the magnetization within magnetic domains will be reflected by the change of the scattering signal. This, in particular, implies that any demagnetization of the sample will cause a decrease of the magnetic signal.

Let us emphasize that the modeling tool able to follow transient changes of magnetization has to take into account radiation damage processes in the sample induced by X-ray irradiation. The damage processes have, in general, two components: (i) electronic damage due to X-ray induced excitation and collisional relaxation of electrons, and (ii) structural damage resulting in atomic displacements. In this work, we report on a nanoscopic modeling tool, XSPIN, exploring only electronic damage. This restricts the applicability of our model to X-ray fluences below the structural damage threshold. However, this is the fluence regime of the strongest interest and applicational potential, as the demagnetization is then a reversible process and, after a certain time, the material recovers its equilibrium magnetization. If the structural damage fluence threshold is exceeded, the changes in the material become irreversible, and its magnetic properties can be ultimately lost13,16,20.

With the XSPIN tool, we analyze the results of a recent experiment11 on resonant magnetic scattering with ultrashort XUV pulses (tuned to the M-edge of cobalt) from Co/Pt multilayer system with perpendicular magnetic anisotropy24. The experiment was performed at the FERMI FEL facility. In particular, we demonstrate that the processes of electronic excitation, relaxation and transport induced by XUV radiation predominantly affect the behavior of the transient magnetization and hence the scattered magnetic signal.

## Results

### Modeling of X-ray induced processes in solid materials

The hybrid code XTANT25,26 (discussed in detail in the ”Methods” section) was the base for the code XSPIN, which we have constructed and use in this study to follow X-ray induced magnetic transitions in solid materials.

The XTANT code includes all predominant processes occurring in a solid material as a result of X-ray irradiation. It is a hybrid simulation approach combining various modeling techniques. It enables a treatment of large samples and highly excited electronic states (up to keV energy) which is not yet feasible with fully ab initio approaches such as, e.g., those presented in27,28. The XSPIN code is an extension of XTANT, which treats spin degrees of freedom in electronic subsystem. The following paragraphs summarize the modeling framework of XSPIN.

First, we assume that the incoming X-ray pulses are not intense enough to cause any atomic displacements in a magnetic material during the exposure. We neglect also eventual shifts of electronic levels due to high electron temperature. As the nuclei positions are fixed, we can use an ab initio density of states (DOS) obtained for the material in equilibrium. For XSPIN simulations, it was calculated with the VASP (Vienna Ab initio Simulation Package) code which enables such high-precision DFT calculations for various materials29,30,31,32.

Second, in XSPIN we imply spin non-degeneracy to all electrons. Thus, each electron has its own spin, with two states: spin-up and spin-down. We exclude any spin precession, as it is negligible on the subpicosecond ( ~100 fs) timescales considered here. Consequently, the magnetic domains are static, and demagnetization only affects the magnitude of the magnetization in each individual domain. The spin-up and spin-down valence electrons are initially distributed in the 3d band according to the total magnetic momentum of the material under thermal equilibrium. This scheme is similar to that used in the Stoner-Wolfarth model, describing a single magnetic domain33,34.

Third, the code treats with different simulation techniques non-thermalized high-energy fraction (HEF) of electrons and thermally equilibrated low-energy fraction (LEF) of electrons, the latter involving electrons with energies below some specified energy cutoff (here, 15 eV). The photoinduced and the subsequent electronic collisional processes involving the electrons within HEF are simulated with the classical Monte Carlo scheme adopted from the XTANT code25,26,35. Figure 1 shows schematically the electronic processes considered, i.e., photoionization, impact ionization, and Auger decay. After an X-ray pulse starts to interact with a solid material, electrons from spin-up and spin-down subsystems are released due to the photoabsorption process. The excitation probabilities take into account the actual electronic occupations in the respective bands. If the photon energy is sufficient to trigger an electronic excitation from a core-shell, a spin-up or spin-down electron can be excited from the shell. After the photoabsorption, the energetic photoelectron joins the non-thermalized high-energy electron fraction, preserving its spin state. During the sequence of the following impact ionization events, the electron continuously loses its energy and may ultimately fall into the spin-up or the spin-down subsystem of the thermalized low-energy electron fraction – depending on its spin state. The HEF electrons may excite further electrons, with the same or an opposite spin. The probability of such excitation depends on the actual occupations of the spin-up and spin-down electron levels in the LEF and in the core shells.

Core holes relax via Auger decay. A band electron with the same spin fills the hole, while the Auger electron is chosen randomly, according to the actual distribution of spin-up and spin-down electrons. The cross sections for photoionizations are taken from the EPDL database36 and for impact and Auger ionizations from the EADL database37. The core ionizaton potentials are taken from the X-ray Data Booklet38.

All low energy electrons from the LEF, both within spin-up and spin-down subsystems, are assumed to stay in a common local thermal equlibrium. Therefore, at each time step all the electrons are instantly thermalized to follow a Fermi-Dirac distribution. Note that the intraband collisions leading to the thermalization in the entire low-energy electronic subsystem must then also include spin-flip collisions. In other words, the spin redistribution in our model occurs through thermal collisions. Let us emphasize that XSPIN does not trace the overall angular momentum of the system.

At each time step, the actual number of electrons and the actual electron energy stored in both spin-up and spin-down subsystems of the electronic LEF ($${N}_{{{{\rm{e}}}}}^{{{{\rm{low}}}}}$$ and $${E}_{{{{\rm{e}}}}}^{{{{\rm{low}}}}}$$ respectively) are followed. Knowing them, a common temperature, Te, and a common chemical potential of electrons, μ, can be calculated by solving the equations:

$$\begin{array}{l}{N}_{{{{\rm{e}}}}}^{{{{\rm{low}}}}}=\mathop{\sum}\limits_{\sigma }\mathop{\sum }\limits_{{E}_{\min ,\sigma }}^{{E}_{\max ,\sigma }}{\{1+\exp [({E}_{i,\sigma }-\mu )/({k}_{{{{\rm{B}}}}}{T}_{{{{\rm{e}}}}})]\}}^{-1},\\ {E}_{{{{\rm{e}}}}}^{{{{\rm{low}}}}}=\mathop{\sum}\limits_{\sigma }\mathop{\sum }\limits_{{E}_{\min ,\sigma }}^{{E}_{\max ,\sigma }}{E}_{i,\sigma }{\{1+\exp [({E}_{i,\sigma }-\mu )/({k}_{{{{\rm{B}}}}}{T}_{{{{\rm{e}}}}})]\}}^{-1},\end{array}$$
(2)

similarly as it was done in the code XTANT, therein with spin degeneracy25. The energy Ei,σ is the energy of the i-th level for spin σ = , ; $${E}_{\min ,\sigma }$$ and $${E}_{\max ,\sigma }$$ are the minimal and maximal (cut off) electronic energies in the band σ respectively, and kB is the Boltzmann constant. The energy levels in the low-energy electron fraction are determined from the total spin-polarized density of states Dσ(ϵ) for fcc Co, calculated with the code VASP. The energy Ei,σ of i-th level for spin-σ electrons is then calculated from the equation: $$i=\int\nolimits_{-\infty }^{{E}_{i,\sigma }}d\epsilon \,{D}_{\sigma }(\epsilon )$$. Also, the number of energy levels is determined by this equation. For example, for 64 atoms the number of electron levels between the bottom of d-band and the cut-off energy of 15 eV is 481 for spin-up electrons, and 474 for spin-down electrons. Below we list further features of the XSPIN model.

1. (1)

We assume that the photons scattered due to the resonant magnetic scattering process do not induce further magnetic scattering. This assumption is justified by the very small cross section for the resonant magnetic scattering in comparison to the photoabsorption cross section39.

2. (2)

We also assume that the X-ray fluences applied do not cause a significant structural damage to the material during or shortly after the XUV pulse, i.e., on ~100 fs timescales. We give the justification below. A rigorous definition of structural damage threshold is difficult at the 100 fs timescale considered. The usual measure for a damage threshold in a metal is the threshold dose for its thermal melting. This dose for cobalt is estimated as 0.54 eV/atom. However, the thermal melting would require picosecond(s) to be completed. This time is needed for a transfer of a sufficient amount of energy from the electronic system to the lattice. At 100 fs timescale, we can only use this threshold dose as an indicator when structural modifications can start to play some role.

Therefore, in our model, we can assume that the atomic positions are fixed, i.e., the atoms do not change their positions during the simulations. This is because the timescale of atomic displacements during the structural transformation is then longer than the femtosecond pulse duration, see, e.g.,40,41,42.We also neglect eventual shifts of electronic levels due to high electron temperature. These both assumptions guarantee a reasonable modeling accuracy even for the doses a few times higher than 0.54 eV/atom, on 100 fs timescales. However, at higher absorbed X-ray doses or if the model should be applied at picosecond timescales (e.g., in order to follow the recovery of the magnetization), the possible atomic relocations should be taken into account. Such an extension of XSPIN is possible but it would require a significant modification of the anyway complex code, with much effort to be invested. Still, we plan this effort in future.

3. (3)

We assume that all band electrons (both from the spin-up and from the spin-down fractions) undergo instantaneous thermalization at each time step. The intraband collisions, which lead to the electron thermalization, also include spin-flip collisional processes between spin-up and spin-down electrons (cf.43). In such a way, the spin-flip processes are implicitly included in our model. Electron–ion coupling is neglected here, due to ultrashort timescales considered.

Note that the assumption of the instantaneous electron thermalization limits the applicability of the XSPIN to model X-ray irradiation with X-ray pulses of duration longer than the timescale of electronic thermalization. We have performed dedicated simulations with the XCASCADE(3D) code44 to investigate the timescale of electron cascading process in Co and Pt, which is comparable to the timescale of electron thermalization. The calculations show that a photon of energy ~61.1 eV (as used in the experiment) creates on average 3.81 electrons in Co and 5.22 electrons in Pt within 0.2–0.4 fs, both through the excitations from valence band and from the uppermost core levels. This indicates that the XSPIN model should not be applied for subfemtosecond X-ray pulses.

4. (4)

Interactions between magnetic domains in (X, Y) plane are not included, consistently with the Stoner-Wolfarth model framework of a single magnetic domain33,34, used here. Results from a simplistic model with periodic domains (not shown) indicate that the details on domain structure in (X, Y) plane should not significantly affect our results on 100 fs timescales.

5. (5)

X-ray pulses from FERMI facility have a high degree of coherence, as documented in ref. 5. Therefore, the total signal scattered from the multilayer sample is calculated as a coherent superposition of the contributions from individual layers.

6. (6)

For the XSPIN analysis, we used average fluence values estimated by the experiment11. They were estimated, knowing the beam energy focused into a FWHM focal spot. We assumed that the spatial profile of X-ray pulse in our simulations was flat-top, with an average fluence. No volume integration of the signal in the (X, Y) plane was performed. For a meaningful volume integration, we would need much more precise information on the spatial pulse profile than provided by the experiment, in particular, the information on the pulse wings shape.

7. (7)

We included the effect of interlayer electron transport in our predictions. The significant role of electron transport in demagnetization processes was indicated in earlier works on diffusive spin currents, e.g.,9,45,46. In the 100 fs time regime, considered in this work (with the XUV pulse of duration 70 fs, acting both as a pump and as a probe), only the start phase of the spin currents, i.e., the ballistic transport regime, can be treated. Treatment of long-range electron transport is not necessary because such transport does not have enough time to develop. We then only focus on fast collisional processes influencing the electron distribution within the magnetically sensitive regime of the 3d band. X-ray photoabsorption processes cause the emission of electrons, both through direct photoionization as well as through the 3p Auger processes. These ballistic electrons can excite further electrons in collisional processes. The resulting electron cascades then spread in the material. In our multilayer sample, the cascade electrons can also enter the neighboring layers. As mentioned in (3), dedicated simulations with the XCASCADE(3D) code44 predicted that a photon of energy ~61.1 eV (used in the experiment) created on average 3.81 electrons in Co and 5.22 electrons in Pt within 0.2–0.4 fs, i.e., almost instantaneously, both through the excitations from valence band and from the uppermost core levels. The averaging has been performed over 30000 Monte-Carlo cascade realizations. The electron ranges47, i.e., the maximal distances traveled by electrons released in a single photoabsorption event until their energy decreased below ionization threshold, were 1.49 nm and 10.51 nm for Co and Pt respectively. This clearly indicates that interlayer electron transport cannot be neglected in our multilayer sample, where layer thicknesses are only: dCo = 0.8 nm and dPt = 1.4 nm. After the electron cascading stops, modifications within the magnetically sensitive regime of 3d band through collisional ionization processes stop as well. Low energy electrons propagate further through the material in a diffusive transport. As the energy of these electrons is located within the magnetically sensitive regime of 3d band, their diffusive transport throughout the sample, followed by interactions with local 3d electrons, can further modify magnetic properties of the system. However, it occurs on much longer timescales, as indicated by earlier works on diffusive spin currents, e.g.,9,45,46.

The interlayer electron transport was modeled in the following way in the XSPIN code. First, the number of additional electrons in each Co layer which arrived from other layers was estimated, knowing the distribution of the absorbed photons and the electron range in Co and Pt materials. Repeated calculations were then performed with XSPIN, assuming a higher (effective) X-ray pulse fluence, such that would lead to the production of the increased number of electrons (including additional electrons originating from interlayer transport). The XSPIN results on the resonant magnetic scattering signal from a multilayer system tested in the experiment11, shown later in the paper, were calculated, taking the interlayer electron transport into account.

8. (8)

XSPIN simulations were performed for the supercell containing 64 Co atoms. As we consider fluences low enough not to cause atomic relocations, such number of atoms is sufficient to get a statistically reliable results. This expectation was confirmed by the preceding convergence tests of our results in respect to the size of the supercell (not shown).

9. (9)

Accuracy of DOS calculations performed for Co/Pt multilayer system: In Fig. 2a and b, the comparison is shown between: (i) the density of states calculated for a 4-atomic-layer Co structure and the density of states calculated for bulk Co, and (ii) between the partial density of states extracted for Co atoms from the Co-Pt multilayer structure (4 atomic layers of Co followed by 6 atomic layers of Pt) and the density of states calculated for bulk Co atoms. The presented results clearly indicate that there are no significant differences between the calculated density of states in all considered cases. In particular, the overlap between Co and Pt electronic orbitals is of minor importance. Moreover, the densities of state for the 4-atom Co layer in the vacuum and for the bulk Co system look similar. Thus, the usage of the density of states obtained for bulk Co for the parametrization of low-energy electronic levels in our code XSPIN seems well justified.

Now we will describe in detail how magnetic signal from X-ray irradiated Co layer is constructed in XSPIN. X-ray magnetic dichroism arises from a directional spin alignment and the spin-orbit coupling, and results in different X-ray absorption of left and right circularly polarized light at the absorption edges of ferromagnetic materials48. The absorption spectra reflect the actual positions of electronic energy levels and the actual occupations of the resonant electronic states. Let us consider a magnetic scattering signal from an X-ray irradiated Co layer. Incoming X-ray photons of energy ωγ can then excite electrons from the 3p band to the 3d band (Fig. 3). The region in the 3d band to which the electrons can be excited from the 3p band extends from ω0 − Δ to ω0 + Δ, where ω0 is the difference between the photon energy and the position of M-edge:

$$\hslash {\omega }_{0}=\hslash {\omega }_{\gamma }-{E}_{{{{\rm{edge}}}}},$$
(3)

with Eedge = 60 eV for M-edge of Co. Here, 2  Δ is the 3p band width, which determines the number of states probed in the 3d band. The magnetization is proportional to the disparity between electronic populations at the resonant states in spin-up and spin-down subsystems:

$$M\propto \mathop{\sum }\limits_{\hslash {\omega }_{0}-{{\Delta }}}^{\hslash {\omega }_{0}+{{\Delta }}}[{N}_{\uparrow }^{{{{\rm{hole}}}}}({E}_{i,\uparrow })-{N}_{\downarrow }^{{{{\rm{hole}}}}}({E}_{i,\downarrow })],$$
(4)

where $${N}_{\sigma }^{{{{\rm{hole}}}}}({E}_{i,\sigma })=1-{N}_{{{{\rm{e}}}},\sigma }^{{{{\rm{low}}}}}({E}_{i,\sigma })$$ denotes the number of empty states at Ei,σ level. The coefficient $${N}_{{{{\rm{e}}}},\sigma }^{{{{\rm{low}}}}}({E}_{i,\sigma })=\left\{1+\exp \right.{\{[({E}_{i,\sigma }-\mu )/({k}_{{{{\rm{B}}}}}{T}_{{{{\rm{e}}}}})]\}}^{-1}$$ defines the electronic occupation of the level Ei,σ (assumed to be a Fermi-Dirac occupation at all times).

The XSPIN code calculates transient changes of $${N}_{\sigma }^{{{{\rm{hole}}}}}({E}_{i,\sigma })$$ in response to a specific X-ray pulse for the probed energy levels within the Co 3d band (i.e., within the interval ± Δ around the probed level ω0). The transient magnetization of the system can then be calculated from Eq. (4).

Figure 4 shows an example of a typical shape of the demagnetization curve, M(t)2, normalized to its initial value, M(t = 0)2, obtained for a single Co layer. The temporal shape of the X-ray pulse was Gaussian, with the full width at half maximum (FWHM) of 70 fs. The pulse fluence was 13 mJ/cm2, corresponding to the average absorbed dose in the material of 0.93 eV/atom. The assumed thickness of the Co layer was 0.8 nm, i.e., much less than the photon attenuation length in Co for  ~60 eV photon. This ensured a uniform distribution of absorbed energy within the Co layer. The decrease of the M(t)2 curve follows the increase of the number of excited electrons (i.e., the electrons with energy above the Fermi level) in the sample, also depicted in Fig. 4. When the electron cascading saturates, the value of M(t)2 stabilizes, here within ~70 fs after the pulse maximum.

The transient intensity of the resonant magnetic scattering signal (per unit surface), Imagn(t), (cf.11,20,48) is:

$${I}^{{{{\rm{magn}}}}}(t)\propto I(t)\cdot | {F}^{{{{\rm{magn}}}}}(t){| }^{2}$$
(5)

where I(t) is the incoming X-ray intensity, and Fmagn(t) is the instantaneous amplitude for the resonant magnetic scattering taken from Eq. (1). If we separate out the magnetization from the the dipole-transition matrix element in Fmagn(t) (see, e.g.,48), assuming that energy level shifts and stimulated emission processes are only of minor importance – which is the case here – the magnetic scattering signal can be rewritten as:

$${I}^{{{{\rm{magn}}}}}(t)\propto I(t)| M(t){| }^{2},$$
(6)

where M(t) is the transient magnetization. The time-integrated intensity, Imagn(t), yields the experimental observable, magnetic scattering efficiency, S(F):

$$S(F)=P\cdot \int dt\,I(t)| M(t){| }^{2},$$
(7)

where F = ∫ dtI(t) is the pulse fluence. The proportionality factor, P, in Eq. (7) depends both on the material properties and on the X-ray beam parameters (e.g., polarization)11. However, it does not depend on the X-ray pulse fluence.

The formalism presented above works only for the case when a single XUV pulse serves both as a pump and a probe, and the time-integrated mSAXS signal is recorded. Simulation of measurements with separate pump and probe pulses (e.g.,49) would require a dedicated treatment with a respective modification of the Eq. (7), taking into account the actual time delay between the probing time and the response of the magnetic system to the pump pulse (e.g.,50).

### Magnetic signal recorded in mSAXS experiments

Experiments investigating X-ray induced demagnetization use multilayer systems in order to strengthen the overall magnetic scattering signal (which then becomes a sum of contributions from individual layers), and to tune the magnetic domain size, see, e.g.,23. The multilayer systems are composed of ferromagnetic and paramagnetic materials, e.g., Co/Pt11,20,23 or Co/Pd12,15,16. In multilayer samples of such composition, magnetic maze domains are formed, with magnetization perpendicular to the layer surface and alternating up and down11. In an mSAXS experiment, coherent X rays arrive with normal incidence at the top layer of the multilayer system and propagate through it (Fig. 5a). Two processes can then occur: (i) photoabsorption, and (ii) coherent scattering including resonant magnetic scattering if the radiation is tuned to the absorption edge. Magnetically scattered photons are recorded at the CCD detector. They form a scattering ring which radius reflects the spatial correlation of magnetic domains, being twice the domain size, ζ = 2π/Qm (Fig. 5b), where Qm is the length of the scattering vector Qm, $${Q}_{{{{\rm{m}}}}}=\frac{4{{{\rm{\pi }}}}}{\lambda }\sin \theta$$, with λ being the wavelength of the incoming radiation, and 2 θ being the scattering angle. The total intensity of the ring reflects time-integrated scattering efficiency of magnetic domains9.

Figure 6 shows schematically the multilayer system studied in the experiment by Kobs et al.11 for which we will later present the corresponding XSPIN predictions. The FEL beam was first impinging at normal incidence on the Si3N4 membrane (not shown) and then entered the top platinum layer, Ptin. The spatial correlation, ζ, of the maze domains in the Co layers was of the order of 180 nm (corresponding to the peak scattering vector Qm = 0.036 nm−1), and lead to a pronounced mSAXS signal. The experiment used incoming photons of energy ~61.1 eV. Pulse fluences on the top Pt layer, FPt,in, were between 0.3 and 45 mJ/cm2. The temporal shape of the XUV pulse was Gaussian, with full width at half maximum (FWHM) of 70 fs.

### Theory predictions for mSAXS signal

Our goal is now to validate the XSPIN model predictions. For this purpose, we used the already existing experimental data from the mSAXS experiment11 performed with photon energies tuned to the Co M-edge, which used Co/Pt multilayers.

In order to describe the response of the multilayer system (Fig. 6) to X-ray/XUV irradiation, one has to analyse propagation of the radiation through the system. Let us first note that any reflection on Co or Pt layers can be neglected as the reflectivity coefficients for Co and Pt layers at 61.1 eV photon energy are of the order of ~10−2–10−3. The change of incoming X-ray intensity after passing through a layer of a material can then be expressed as:

$$\frac{dI}{dz}=-{\alpha }_{{{{\rm{phot}}}}}\cdot \,I,$$
(8)

where αphot is the photoabsorption coefficient, equal to the inverse of the photon attenuation length47. The solution of this Beer-Lambert-type equation is well-known (see, e.g.,14,47). According to it, X-ray pulse intensity changes as:

$$I={I}_{0}\cdot {e}^{-{d}_{{{{\rm{Co}}}}}/{\lambda }_{{{{\rm{att,Co}}}}}},$$
(9)

after passing through a Co layer of a thickness dCo, where λatt,Co is the photon attenuation length in cobalt. In our multilayer system (Fig. 6), this implies a recursive relation between the X-ray intensities in two consecutive Co layers: the nth layer and the (n + 1)th layer of the same thickness dCo at a time instant t,

$${I}_{n+1}(t)={I}_{n}(t)\cdot {a}_{{{{\rm{Co}}}}}\cdot {a}_{{{{\rm{Pt}}}}},$$
(10)

where λatt,Pt is the photon attenuation length in platinum, and aCo(Pt) are material attenuation coefficients in Co or Pt, defined as $${a}_{{{{\rm{Co}}}}({{{\rm{Pt}}}})}={e}^{-{d}_{{{{\rm{Co}}}}({{{\rm{Pt}}}})}/{\lambda }_{{{{\rm{att,Co(Pt)}}}}}}$$. For 61.1 eV photons, λatt,Co ~ 9.20 nm and λatt,Pt ~ 9.13 nm respectively. They are ~ 4 times shorter than the overall thickness of the multilayer system (40.8 nm), i.e., the pulse intensity attenuation has to be taken into account. The initial condition for Eq. (10) is: I1(t) = IPt,in(t) aPt,in. Here we neglected any intensity attenuation due to resonant magnetic scattering as the corresponding cross section is much smaller than the photoabsorption cross section39.

The time-integrated scattered signal emitted into the magnetic ring, Qm, is then a coherent sum of contributions from different Co layers within the multilayer system:

$$S({F}_{{{{\rm{Pt,in}}}}};{Q}_{{{{\rm{m}}}}})=P\cdot \,\int \,dt\,{\left|\mathop{\sum }\limits_{n = 1}^{{N}_{{{{\rm{Co}}}}}}\sqrt{{I}_{n}(t)}\cdot M(t)\cdot \sqrt{{a}_{{{{\rm{Pt}}}}}^{{N}_{{{{\rm{Co}}}}}-n}\cdot {a}_{{{{\rm{Co}}}}}^{{N}_{{{{\rm{Co}}}}}-n}\cdot {a}_{{{{\rm{Pt,out}}}}}}\cdot {e}^{-{{{\rm{i}}}}{{{{\rm{Q}}}}}_{{{{\rm{m}}}}}\cdot {{{{\rm{R}}}}}_{n}}\right|}^{2},$$
(11)

where In(t) also contains attenuation coefficients (see Eq. (10)). It can be shown that the overall product of the attenuation coefficients in Eq. (11) is the same for each layer, i.e., the total signal sums the contributions from different layers with the same attenuation weight. Note also that Eq. (11) accounts for the fact that during the passage of 61.1 eV photons through Pt layers only photoabsorption processes and no resonant magnetic scattering occur. To justify the latter assumption, we checked that platinum has absorption edges at 54 eV and 66 eV. However, as Fig. 2b in ref. 21 shows, the contribution of Pt magnetic resonances to the overall resonant magnetic scattering signal from Co and Pt at 61.1 eV is subleading, when compared with the contribution of Co. To illustrate, platinum peak heights at 54 eV and 66 eV are ~0.12 and ~0.15 respectively, and Co peak height is ~0.75 at 61.1 eV, see Fig. 2b in ref. 21. Therefore, in the framework of our model, we neglected Pt contribution to the resonant scattering signal at 61.1 eV.

### Comparison of XSPIN predictions to experimental data

We have calculated the magnetic scattering signal numerically, using XSPIN results for time-dependent magnetization obtained for various (attenuated) X-ray fluences in each Co layer of the multilayer system. Interlayer electron transport was also taken into account (for details, see ”Further features of XSPIN model” section). In what follows, we will use a simplified notation: F ≡ FPt,in and S(F) ≡ S(F, Qm). Figure 7 shows the result on the normalized magnetic scattering signal, defined as: Snorm(F) = S(F) F0/S(F0), for Δ = 1.2 eV. This value of Δ corresponds to the half of the FWHM of the Co M-edge peak (see ref. 21).

Figure 7 shows the experimental data on Snorm(F) for X-ray irradiated multilayer system, retrieved from ref. 11 (blue points), with an exponential fitting function, $${S}_{{{{\rm{norm}}}}}(F)=F\cdot \exp (d+c\cdot F)$$ (orange dashed line), yielding the coefficients, c = −0.035 and d = −0.034 (cf.11). The experimental data are compared to the theoretical prediction for Snorm(F) obtained with the XSPIN model (black solid line). The prediction takes the interlayer electron transport into account. Note that the calculation of Snorm(F) for the theoretical predictions involves the multiplication of the theoretical raw signal S(F) by the factor, F0/S(F0), similarly as it was done for the experimental data in11. Therein, F0 ≈ 0.4 mJ/cm2. The error bars plotted weight the theoretical results with the relative experimental error, calculated for the factor, F0/S(F0), from the experimental data. The calculation used specifically the experimental errorbars for the fluence, F0, and for the normalized scattering efficiency, Ieff (11; Fig. 2 therein). The error bars give an estimate for the uncertainty of the applied signal scaling. Note that the experimental data and theory predictions lay within the errorbars.

In the plot, we also show the Snorm(F) obtained, when assuming a constant magnetization of the sample at all times, i.e., M(t) = M(0). It starts to deviate from the normalized signal including demagnetization already for fluences of a few mJ/cm2, indicating the onset of the demagnetization contribution. This observation is in agreement with the trend seen in the experimental data.

Generally, the limited range of fluences available for the actual experimental points (up to ~40 mJ/cm2) and the large error bars do not allow us to accurately extrapolate the data towards higher fluences. For this purpose, an additional measurement of magnetic signal at higher fluence values would be helpful. However, one can expect that at very higher fluences, when structural damage strongly affects the sample, the magnetic scattering signal should ultimately disappear. Such behavior has been experimentally observed at high X-ray fluences in ref. 13.

In any case, it should be emphasized that the region of interest for potential practical applications of X-ray induced demagnetization lies below the structural damage threshold. In this region, the demagnetization is a reversible process, i.e., the magnetization of the sample, after a certain recovery time needed for excited electrons to relax, recovers its equilibrium value. The material can then be demagnetized with X rays again. With this analysis, we have shown that electronic processes strongly influence magnetic properties of the sample in this regime. In particular, our XSPIN model that treats electronic damage processes was able to describe the actual experimental data11 with a good accuracy. The model can then be applied for predicting responses of various magnetic samples to X-ray pulses. Such study would be a significant step towards understanding and controlling X-ray induced femtosecond demagnetization in magnetic materials.

## Discussion

With the theoretical model, XSPIN, we followed magnetic properties of X-ray irradiated magnetic multilayer system. We have shown that the demagnetization of such system, induced by X-ray pulses of fluences below the structural damage threshold, follows as a result of electronic damage processes. During the electronic relaxation, the occupations of magnetically sensitive levels in ferromagnetic Co transiently change, resulting in the ultrafast decrease of Co magnetization. Within tens of femtoseconds, the magnetization reaches an equilibrium value, which remains stable on hundred femtosecond timescale. When one increases the fluence of X-ray pulse, the magnetization decreases to a lower final value. This is reflected by the decrease of the time-integrated magnetic scattering signal with increasing X-ray fluence. However, the timescale of the magnetization decrease is not affected by a change of pulse fluence.

Further, we have shown that a similar behavior of magnetic scattering efficiency can be observed for experimentally investigated multilayer systems. The electronic damage within the system layers is additionally influenced by pulse intensity attenuation and interlayer electron transport, which our model takes into account. Good agreement of our predictions with the data from the experiment by Kobs et al.11 (within the limits of experimental accuracy) confirms the fidelity of this physical picture. However, for ultimate model validation, it would be necessary to compare the XSPIN predictions on transient XUV induced magnetization to the respective time-resolved XUV experimental data, such as those obtained in6,9 for NIR induced demagnetization. An experiment performed for a single Co layer: (i) with magnetization aligned by an external magnetic field, (ii) then pumped with XUV rays, and (iii) probed with NIR pulses at varying time delays, would enable to collect such time-resolved data on magnetization which could then be compared to the XSPIN predictions. Such comparison would also require a significant extension of the XSPIN code, in order to take into account possible effects of long-range electron transport, as indicated in ref. 9. This would be challenging, in particular, due to the large spatial scales involved in the transport modeling. They would make the simulation computationally expensive.

Up to our knowledge, the XSPIN model is the first model which couples a comprehensive quantitative description of X-ray induced electronic damage processes in solids, checked by earlier comparisons of its predictions with several experimental results on non-magnetic systems, with the description of transient magnetic processes in solids. An earlier theory model14 ascribed the decrease of the magnetic scattering signal (tuned to the Co L3 resonance) to the existence of a stimulated elastic scattering into the forward direction15. This mechanism has not been confirmed by later experiments tuned to the Co M resonance11,12.

Let us emphasize that the current model does not claim an immediate applicability for magnetic samples irradiated with infrared radiation. Different processes, acting on different timescales, can lead to demagnetization. In the X-ray/XUV regime and at 100 fs timescales, the electronic damage seems the fastest process which can drive it. It changes the magnetic state of the sample on a femtosecond timescale before an onset of any other—slower—process which could otherwise demagnetize the material.

The predominant role of electronic damage for X-ray induced demagnetization, confirmed by our theoretical study, opens a promising prospect for ultrafast demagnetization control. We can now predict with XSPIN how to affect the magnitude and timescale of the demagnetization by adjusting X-ray pulse parameters (wavelength, pulse duration, and fluence), as well as by the choice of a magnetic material. Further experimental studies, supported by theory predictions with XSPIN, can then be performed, investigating the possible options for the control of demagnetization. This is a step toward prospective technological applications, e.g., XUV/X-ray light-controlled nanoscopic magnetic switches, operating on femtosecond timescales.

## Methods

### Modeling interaction of X rays with solid materials, using the code XTANT

Modeling radiation damage in nanoscopic samples and solid materials has been performed for several years with various simulation techniques, e.g.,25,51,52,53. One of the tools is the hybrid code XTANT (X-ray-induced Thermal And Nonthermal Transitions)25,26,35,54. Using periodic boundary conditions, the XTANT can simulate evolution of X-ray irradiated bulk materials. The code consists of a few modules dedicated to simulate various processes induced by the incoming X-ray FEL radiation:

1. (a)

The core of the XTANT model is a band structure module (in refs. 25,26,35,54 based on transferable tight binding Hamiltonian, in ref. 55 replaced by the DFTB+ code56), which calculates the transient electronic band structure of thermalized LEF electrons and the atomic potential energy surface. The latter also evolves in time, depending on the positions of atoms in the simulation box, and is used to calculate the actual forces acting on nuclei.

2. (b)

After the forces act on atoms, the atoms move. Their actual positions are propagated in time, using a classical molecular dynamics (MD) scheme. It solves Newton equations for nuclei, with the potential energy surface evaluated from the band structure module.

3. (c)

Electron occupation numbers, distributed on the transient energy levels, are assumed to follow Fermi-Dirac distribution with a transient temperature and chemical potential evolving in time. The electron temperature changes due to the interaction of band electrons with X-rays and high-energy electrons; or due to their non-adiabatic interaction with nuclei (through electron–ion scattering54).

4. (d)

Non-equilibrium fraction of electrons at high energies (HEF) and Auger decays of core holes are treated with a classical event-by-event Monte Carlo (MC) simulation. It stochastically models X-ray induced photoelectron emission from deep shells or from the valence band, the Auger decays, and the scattering of high-energy electrons. In the code, at each time step an intrinsic averaging over 30000 different Monte Carlo realizations of electron (and core hole) trajectories is performed, in order to calculate the average electronic distribution which is then applied at the next time step.

5. (e)

Electron–ion energy exchange is calculated, using a non-adiabatic approach54. This energy is transferred to atoms by the respective velocity scaling at each MD step.

XTANT’s hybrid approach enables computationally inexpensive simulations of relatively large supercells (containing up to 1000 atoms). The code treats all predominant excitation and relaxation processes within an X-ray FEL irradiated sample, including its non-equilibrium evolution stage, thermal and non-thermal processes, and structural transformations57. In particular, all X-ray induced processes exciting electrons are taken into account in the model. Ballistic electrons are considered as high energy electrons. In the bulk material, they propagate with the restriction of periodic boundaries.