research papers\(\def\hfill{\hskip 5em}\def\hfil{\hskip 3em}\def\eqno#1{\hfil {#1}}\)

Journal logoJOURNAL OF
SYNCHROTRON
RADIATION
ISSN: 1600-5775

Formulation of perfect-crystal diffraction from Takagi–Taupin equations: numerical implementation in the crystalpy library

crossmark logo

aEuropean Synchrotron Radiation Facility, 71 Avenue des Martyrs, F-38000 Grenoble, France
*Correspondence e-mail: [email protected], [email protected]

Edited by H. Tolentino, Brazilian Synchrotron Light Laboratory, Brazil (Received 21 June 2024; accepted 20 September 2024; online 29 October 2024)

The Takagi–Taupin equations are solved in their simplest form (zero deformation) to obtain the Bragg-diffracted and transmitted complex amplitudes. The case of plane-parallel crystal plates is discussed using a matrix model. The equations are implemented in an open-source Python library crystalpy adapted for numerical applications such as crystal reflectivity calculations and ray tracing.

1. Introduction

Almost every synchrotron radiation beamline operating with hard X-rays makes use of perfect crystals. Most beamlines use a double-crystal monochromator with flat crystals. Multiple reflections are used for high resolution (Ishikawa et al., 2005[Ishikawa, T., Tamasaku, K. & Yabashi, M. (2005). Nucl. Instrum. Methods Phys. Res. A, 547, 42-49.]; Shvyd'ko, 2004[Shvyd'ko, Y. (2004). X-ray optics: high-energy-resolution applications, Vol. 98 of Springer Series in Optical Sciences. Springer Science & Business Media.]). Curved crystals are used in reflection [polychromators for dispersive X-ray absorption spectroscopy (Tolentino et al., 1988[Tolentino, H., Dartyge, E., Fontaine, A. & Tourillon, G. (1988). J. Appl. Cryst. 21, 15-22.])] or in transmission [single- (Suortti et al., 1993[Suortti, P., Thomlinson, W., Chapman, D., Gmür, N., Siddons, D. & Schulze, C. (1993). Nucl. Instrum. Methods Phys. Res. A, 336, 304-309.]) or double-crystal Laue monochromators (Ren et al., 1999[Ren, B., Dilmanian, F., Chapman, L., Ivanov, I., Wu, X., Zhong, Z. & Huang, X. (1999). Nucl. Instrum. Methods Phys. Res. A, 428, 528-550.])]. Plane crystals plates are used to change the polarization state of X-rays (Bouchenoire et al., 2003[Bouchenoire, L., Brown, S. D., Thompson, P., Duffy, J. A., Taylor, J. W. & Cooper, M. J. (2003). J. Synchrotron Rad. 10, 172-176.]; Detlefs et al., 2012[Detlefs, C., Sanchez del Rio, M. & Mazzoli, C. (2012). Eur. Phys. J. Spec. Top. 208, 359-371.]). In addition, crystal analyzers are used in most spectroscopy beamlines [see, for example, Rovezzi et al. (2017[Rovezzi, M., Lapras, C., Manceau, A., Glatzel, P. & Verbeni, R. (2017). Rev. Sci. Instrum. 88, 013108.])].

Beamline simulation tools used for the design, optimization and commissioning of synchrotron instrumentation implement in software the equations to calculate the reflectivity of perfect crystals. The theory of diffraction [see Authier (2003[Authier, A. (2003). Dynamical Theory of X-ray Diffraction. Oxford University Press.]) for a complete reference] is the basis of all numeric implementations.

There are many simulation tools implementing the equations of the dynamical theory in different forms. This variate scenario is even more complex if we consider that the calculation of the crystal structure factor, which is an essential ingredient for calculating diffracted amplitudes and intensities, is obtained from tabulated scattering functions of multiple origins. A wide collection of software methods and tools can be found even in a single application, such as the OASYS suite (Rebuffi & Sanchez del Rio, 2017[Rebuffi, L. & Sanchez del Rio, M. (2017). Proc. SPIE, 10388, 103880S.]), which provides multiple solutions for calculating diffraction profiles of crystals [e.g. INPRO (https://github.com/oasys-kit/xoppy_external_codes/tree/master/src/INPRO), CRYSTAL (Sanchez del Rio et al., 2015[Sanchez del Rio, M., Perez-Bocanegra, N., Shi, X., Honkimäki, V. & Zhang, L. (2015). J. Appl. Cryst. 48, 477-491.]), X-RAY Server (Stepanov, 2004[Stepanov, S. A. (2004). Proc. SPIE, 5536, 16-26.])], as well as beamline simulation tools [based on the ray-tracing code SHADOW (Sanchez del Rio et al., 2011[Sanchez del Rio, M., Canestrari, N., Jiang, F. & Cerrina, F. (2011). J. Synchrotron Rad. 18, 708-716.])] and physical wave-optics simulations with SRW (Chubar & Elleaume, 1998[Chubar, O. & Elleaume, P. (1998). Proceedings of the 6th European Particle Accelerator Conference (EPAC1998), pp. 1177-1179. THP01G.]; Sutter et al., 2014[Sutter, J. P., Chubar, O. & Suvorov, A. (2014). Proc. SPIE, 9209, 92090L.]). Most ray-tracing codes used for synchrotron applications incorporate models for crystal diffraction, like SHADOW (Sanchez del Rio et al., 2011[Sanchez del Rio, M., Canestrari, N., Jiang, F. & Cerrina, F. (2011). J. Synchrotron Rad. 18, 708-716.]), RAY (Schäfers, 2008[Schäfers, F. (2008). The BESSY Raytrace Program RAY, pp. 9-41. Berlin, Heidelberg: Springer.]; Baumgärtel et al., 2019[Baumgärtel, P., Grundmann, P., Zeschke, T., Erko, A., Viefhaus, J., Schäfers, F. & Schirmacher, H. (2019). AIP Conf. Proc. 2054, 060034.]), XRT (Chernikov & Klementiev, 2017[Chernikov, R. & Klementiev, K. (2017). Proc. SPIE, 10388, 1038806.]; Klementiev & Chernikov, 2023[Klementiev, K. & Chernikov, R. (2023). Synchrotron Radiat. News, 36(5), 23-27.]). This scenario has inherited decades of advancements and has witnessed the evolution of several generations of synchrotron radiation sources. Our research aims to tackle this challenge by consolidating the resources for crystal diffraction calculations. We have two primary objectives: deducing the equations governing crystal reflectivity from first principles and integrating them into a thoroughly documented open-source software library.

The Takagi–Taupin equations are a powerful tool in Bragg diffraction by deformed crystals for diverse forms of the incident monochromatic wave. They are applied here to the simple particular case of plane parallel crystals and plane incident waves. We derive results found in the conventional dynamical theory described in textbooks (Zachariasen, 1994[Zachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.]; Pinsker, 1978[Pinsker, Z. G. (1978). Dynamical Scattering of X-rays in Crystals. Springer-Verlag.]; Authier, 2003[Authier, A. (2003). Dynamical Theory of X-ray Diffraction. Oxford University Press.]). Therefore, there are no new physical results in the present paper. However, the method presented here is mathematically well defined and simple. It is general in the sense that it deals directly with absorbing crystals. We believe that it represents a valuable and useful shortcut to the conventional method.

In Section 2[link] we derive the Takagi–Taupin (TT) equations (Takagi, 1962[Takagi, S. (1962). Acta Cryst. 15, 1311-1312.]; Taupin, 1964[Taupin, D. (1964). Bull. Soc. Fr. Miner. Crystallogr. 87, 469-511.]; Taupin, 1967[Taupin, D. (1967). Acta Cryst. 23, 25-35.]). In Section 3[link] we solve the TT equations for a plane undeformed-crystal. Given known complex amplitudes at the entrance surface, the complex amplitudes along the incident and diffracted directions at the back surface are calculated via a transfer matrix (Section 3.2[link]). For the Laue case, the transfer matrix is directly used to compute the diffracted and forward-diffracted (or transmitted) complex amplitudes (Section 3.4[link]). For the Bragg case (Section 3.5[link]) the transfer matrix is used to obtain the scattering matrix, which gives the diffracted and transmitted complex amplitudes. Section 4[link] is dedicated to the software implementation of the library crystalpy. A final summary and conclusions are in Section 5[link].

2. Takagi–Taupin equations

The scalar time-independent X-ray wave equation in a perfect crystal is the Helmholtz equation,

Mathematical equation

where Mathematical equation is the wavefunction, k = 2π/λ, with λ the wavelength, Mathematical equation is the electric susceptibility [refractive index n = (1 + χ)1/2] that can be expanded in a Fourier series,

Mathematical equation

where the sum goes over all reciprocal lattice vectors h with (hkl) Miller indices. The spacing of the (hkl) reflection is dhkl = 2π/h, where h = Mathematical equation.

Let us consider an incident plane wave Mathematical equation in vacuum. Its wavevector Mathematical equation, with modulus k = Mathematical equation, is close to the Bragg condition for the diffraction vector h. In the `two-beams case' of Bragg diffraction, considered in this paper, we define Mathematical equation Mathematical equation Mathematical equation, of modulus kh = Mathematical equation. In general, the direction of Mathematical equation does not correspond to the Bragg-diffracted wavevector in vacuum, and kh is slightly different from k. The deviation from the exact Bragg position is expressed by the parameter α (Mathematical equation), defined as

Mathematical equation

The wavefield Mathematical equation in the crystal is set empirically as the sum of `two modulated plane waves',

Mathematical equation

in which the amplitudes Mathematical equation are considered as `slowly varying functions', thus neglecting their second-order derivatives in Mathematical equation,

Mathematical equation

thus giving

Mathematical equation

In the product Mathematical equation, using the equations (2)[link] and (4)[link], we write separately the terms containing either Mathematical equation or Mathematical equation, and do not consider the other terms,

Mathematical equation

Inserting equations (5)[link] and (6)[link] into (1)[link], we obtain the TT equations,

Mathematical equation

We can use the oblique coordinates (s0, sh) in the diffraction plane (the plane containing Mathematical equation and h, as well as Mathematical equation), with origin O on the crystal surface and unit vectors Mathematical equation and Mathematical equation along Mathematical equation and Mathematical equation, respectively. A generic spatial position Mathematical equation = (s0,sh,st) should include a third coordinate st along an axis Mathematical equation non-coplanar with Mathematical equation and Mathematical equation. We can choose Mathematical equation to lie on the crystal entrance surface and be perpendicular to the intersection line of the diffraction plane and the crystal surface. The chosen direction of Mathematical equation implies Mathematical equation = 0. The equation of the crystal surface is γ0s0 + γhsh = 0, with Mathematical equation = Mathematical equation Mathematical equation Mathematical equation the director cosines with respect to n, the unit inward normal vector to the entrance plane surface.

The relation ds0 = Mathematical equation = Mathematical equation implies Mathematical equation = 1 and Mathematical equation = 0. Similarly, Mathematical equation = 1 and Mathematical equation = 0. Therefore,

Mathematical equation

Using the approximation1

Mathematical equation

we obtain from equation (7)[link],

Mathematical equation

where we used the notation

Mathematical equation

Our formulation is written for the case of σ-polarization. For the case of π-polarization, it is sufficient to replace χh and χh with Cχh and Cχh with C = Mathematical equation. An equivalent form of the TT equations (10)[link] is obtained in Appendix A[link], using oblique axes along the directions of the geometrical Bragg law, and applying a crystal rotation.

3. Solutions of TT equations for a plane wave incident on a crystal with plane entrance surface

It is interesting to consider first the effects of refraction and absorption without Bragg diffraction. Setting uh = 0 in equations (10a)[link], we obtain the following equation for the refracted amplitude,

Mathematical equation

Its solution satisfying the boundary conditions Mathematical equation = 1 for γ0s0 + γhsh = 0 (equation of the crystal surface) is Mathematical equation = Mathematical equation = exp(iu0s) where

Mathematical equation

We now consider the solutions of the equations (10)[link] depending on the single variable2 s, which means ∂D0/∂s0 = Mathematical equation and ∂Dh/∂sh = Mathematical equation. The equations (10)[link] become

Mathematical equation

It is convenient to use the functions B0,h(s) by setting

Mathematical equation

with

Mathematical equation

Equations (14)[link] become

Mathematical equation

They have special solutions of the form3 B0(s) = exp(ias) and Bh(s) = Mathematical equation, which, introduced in equation (17)[link], give ξ = buh/(a − ω) = (a + ω)/uh and

Mathematical equation

The general solution of equation (17)[link] is

Mathematical equation

From the case s = 0, we obtain

Mathematical equation

Consequently

Mathematical equation

Mathematical equation

or, in terms of D0,h(s) [equation (15)[link]] in a more compact form,

Mathematical equation

Mathematical equation

3.1. Expressions of α, ω and Mathematical equation as functions of the angles

Note that h = Mathematical equation, θB being the geometrical Bragg angle, and Mathematical equation = Mathematical equation, with θ the glancing angle of Mathematical equation on the reflecting planes. From equation (3)[link] we obtain

Mathematical equation

Our definition of α [equation (3)[link]] was made in such a way that α increases when θ increases.4 The approximated value of α is not valid far from the Bragg position or when θB approaches π/2 (normal incidence); therefore equation (3)[link] is used in the crystalpy software.

α′ [equation (11)[link]] and ω [equation (16)[link]] are

Mathematical equation

Mathematical equation

The `corrected Bragg angle' θc, that differs from θB because of the effect of refraction, is obtained as the θ value such that Mathematical equation = 0, or

Mathematical equation

which, under the usual conditions [Mathematical equationMathematical equation], reduces to

Mathematical equation

From equations (24)[link] and (25)[link], the value of ω has a simple expression as a function of θc and θ,

Mathematical equation

Note that, in our representation [using waves of the form Mathematical equation], we have Mathematical equation ≥ 0. Equations (21)[link] are expressed in terms of a, but they depend only on a2. Using equation (27)[link] in equation (18)[link] we obtain

Mathematical equation

Mathematical equation

Note that a can be expressed in terms of a2 as

Mathematical equation

3.2. The transfer matrix of a parallel crystal slab

The front and back surfaces of a crystal parallel slab correspond to s = 0 and s = tc/γ0 = T, respectively, with tc the `usual' thickness of the crystal. We can express the fields at the back surface (D0(T), Dh(T)) in terms of those at the front surface (D0(0), Dh(0)) in matrix form,

Mathematical equation

According to equation (21)[link], the elements of the `transfer matrix' M are

Mathematical equation

Mathematical equation

Mathematical equation

Mathematical equation

The determinant of the matrix M is Mathematical equation = Mathematical equation. Its modulus |det(M)| ≤ 1. It is 1 for a non-absorbing crystal (u0 and ω are real). This is in agreement with the expected energy conservation. It can be verified that M(T1 + T2) = M(T2)M(T1) and M(−T) = [M(T)]−1. Last, but not least, equation (30)[link] is valid for both Bragg and Laue cases (with adequate values of b, a and ω).

3.3. The transfer matrix for the case of a `thick crystal'

Equations (21)[link] and (31)[link] are expressed in terms of a, but they depend only on a2. It is possible to write them as

Mathematical equation

where the two terms are interchanged when a is changed in −a. They correspond to the two roots of a2. They also correspond to the two branches of the dispersion surface [see, for example, Authier (2003[Authier, A. (2003). Dynamical Theory of X-ray Diffraction. Oxford University Press.])]. The real part of the argument of the exponential factors, Mathematical equation, is related to the absorption. When Mathematical equation, the absorption is less than Mathematical equation for the first term, and more than that for the second one. Similarly, for Mathematical equation the two matrices present opposite behaviour. If Mathematical equation is large (for example Mathematical equation), we can keep only the largest term in equation (32)[link],

Mathematical equation

A beam, that would be absorbed without Bragg diffraction if Mathematical equation >> 1 may partially go through the `thick crystal' in the condition of Bragg diffraction. Equation (33)[link] is a clear expression of the Borrmann effect.

3.4. Reflection and transmission amplitudes in the Laue case

In this case, b > 0. The boundary conditions are (D0(0), Dh(0)) = (1, 0). The reflection and transmission amplitudes, rL = Dh(T) and tL = D0(T), respectively, are directly written from the matrix equation (30)[link],

Mathematical equation

Mathematical equation

The reflecting power is Mathematical equation = Mathematical equation, where P = |b|−1 is the ratio of the cross sections of the reflected and incident beams (Zachariasen, 1994[Zachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.]). Its plot Mathematical equation as a function of the angle of incidence is the diffraction profile, often referred to as the rocking curve. Mathematical equation and Mathematical equation = Mathematical equation are hereafter called reflectance and transmittance, respectively. An example is shown in Fig. 1[link].

[Figure 1]
Figure 1
Calculated reflectance (a) and transmittance (b) for a 10 µm-thick Laue Si 111 crystal at 8 keV, with 65° of asymmetric angle. The Bragg angle is θB = 14.31°.

It is also interesting to consider the case of incidence along the direction of Mathematical equation (diffraction vector Mathematical equation), for which (D0(0), Dh(0)) = (0, 1). It is directly seen from equation (30)[link] that the transmission and reflection amplitudes are Mathematical equation = Dh(T) = m22 and Mathematical equation = D0(T) = m12 (note that the reflection power factor is P = |b| in this case). These results can be written as

Mathematical equation

This means that, for the Laue case, the matrix M can be considered not only as the `transfer-matrix' of the crystal slab but also as the `scattering-matrix' (S-matrix) which relates the vacuum waves leaving the crystal to the vacuum waves entering it, in analogy with the S-matrix used in general scattering theory.

The exponential factor in equation (34)[link] gives a damping factor, which is {using u0 + ω = [(b + 1)u0 + bα′]/2 from equation (16)[link], and noting that α′ is real}

Mathematical equation

The Pendellösung effect is due to the oscillations of Mathematical equation = Mathematical equation. The Pendellösung distance (depending on θ) along s0 is thus equal to Mathematical equation = Mathematical equation, where w = (λ/π)ω. At θ = θc, Mathematical equation = Mathematical equation. In the symmetric Laue case (b = 1) we obtain the well known formula of the Pendellösung distance along the direction normal to the crystal surface [see, for example, equation (3.48) of Pinsker (1978[Pinsker, Z. G. (1978). Dynamical Scattering of X-rays in Crystals. Springer-Verlag.])],

Mathematical equation

3.5. Reflection and transmission amplitudes in the Bragg case – the S-matrix

In this case, b < 0. We set D0(0) = 1 and Dh(T) = 0 (which means no beam entering the crystal slab on the back surface). The reflection and transmission amplitudes are rB = Dh(0) and tB = D0(T), respectively. Equation (30)[link] is

Mathematical equation

from which we obtain

Mathematical equation

Mathematical equation

These solutions, as well as those for Laue in equations (34[link]), can also be obtained by direct integration of the TT equations (17)[link] using Laplace transforms (see Appendix B[link]). Similarly, in the case of incidence on the crystal back side along the direction Mathematical equation (diffraction vector Mathematical equation), we set Dh(T) = 1, D0(T) = Mathematical equation, D0(0) = 0 and Dh(0) = Mathematical equation. Therefore, equation (30)[link] gives

Mathematical equation

from which we obtain

Mathematical equation

Mathematical equation

Consequently, the S-matrix for the Bragg case, defined as

Mathematical equation

is

Mathematical equation

The diffraction profile (reflectance) is Mathematical equation = Mathematical equation, with P = 1/|b|, and the transmittance is Mathematical equation = Mathematical equation. An example is shown in Fig. 2[link].

[Figure 2]
Figure 2
Calculated reflectance (a) and transmittance (b) of a symmetrical Bragg Si 111 crystal with 10 µm thickness at 8 keV.

The field inside the crystal, i.e. D0(s) and Dh(s), can be calculated using equation (19)[link], with D0(0) = 1 and Dh(0) = rB from equation (39a)[link] we obtain

Mathematical equation

Mathematical equation

An example of simulation of the field inside the crystal using equation (44)[link] is shown in Fig. 3[link]. For the Laue case, also shown in this figure, we observe that the field at coordinate s is simply calculated by the equations (34)[link] replacing T by s.

[Figure 3]
Figure 3
Calculations for a symmetric Si 111 at 8 keV with thickness tc = 50 µm. The graphs show the electric field intensity inside the crystal as a function of the deviation angle θθB and penetration ratio −s/T (equivalent to a depth ratio − t/tc), for (a) Bragg |Dh|2, (b) Bragg |D0|2, (c) Laue |Dh|2, (d) Laue |D0|2.

Fig. 3[link](b) shows that the penetration of the incident wave inside the crystal is small in a limited interval around θc. In Fig. 4[link] we fitted the intensity profile of |D0(s)|2 versus depth for each value of θθB. The fact that for a thick crystal in Bragg geometry |D0(s)|2 has significant values only in the vicinity of the crystal surface, in the central region, can be explained from equation (44)[link]. The moduli of the functions Mathematical equation and Mathematical equation are approximately proportional to Mathematical equation if the argument of this exponential function is sufficiently large. Consequently, |D0(s)|2 is nearly proportional to Mathematical equation. Writing Mathematical equation = Mathematical equation, with Mathematical equation = Mathematical equation the extinction length (measured along the s0 axis), we obtain for the Bragg symmetric (b = −1) case,

Mathematical equation

[Figure 4]
Figure 4
Fit of |D0|2 versus t of Fig. 3[link](b) with a function Mathematical equation to obtain the extinction depth text. This result is compared with the calculated value from equation (45)[link] that gives Mathematical equation = Mathematical equation = Mathematical equation.
3.5.1. Reflection amplitude for a thick absorbing crystal in the Bragg case

In the case of thick (or semi-infinite) Bragg crystal, the reflection amplitude, given by equation (39)[link], takes the form [using M from equation (33)[link]]

Mathematical equation

Both equations are equivalent assuming that the sign in a = ±(a2)1/2 is correctly selected. The condition on Mathematical equation in equation (46)[link] is in accordance with the physical condition that |rB| goes to zero when Mathematical equation is large. The condition Mathematical equation [Mathematical equation] is equivalent5 to Mathematical equation = Mathematical equation [Mathematical equation = Mathematical equation] for large values of Mathematical equation.

Equation (46)[link] is a useful result, as most crystal monochromators used in synchrotron radiation are thick crystals in Bragg (reflection) mode.

3.5.2. Reflection amplitude for non-absorbing crystals in the Bragg case

In this case Mathematical equation = u*h; ω [see equation (16)[link]] and a2 = Mathematical equation are real. We can distinguish two cases.

If a2 ≤ 0, or Mathematical equation Mathematical equation Mathematical equation, then a = Mathematical equation; therefore, according to equation (46)[link],

Mathematical equation

If a2 > 0, or Mathematical equation > Mathematical equation,

Mathematical equation

Equation (48)[link] represents the tails of the reflection profile. As discussed previously, the sign selection is such that |rB| tends to zero for large values of |ω|. Equation (47)[link] corresponds to the zone of total reflection. The reflectance is

Mathematical equation

with y = Mathematical equation

3.6. Calculation of reflection and transmission amplitudes using the transfer matrix

The matrix method permits the complex reflection and transmission amplitudes of a crystal made by layers of different crystals (or the same crystal with different orientations) to be obtained. For that, (i) construct the transfer matrix of the total crystal by multiplication6 of the transfer matrices of the different layers [each one calculated using equation (31)[link]]; (ii) if the geometry is Laue, obtain reflection and transmission amplitudes using the coefficients m21 and m11, respectively, of this matrix [equation (34)[link]]; otherwise (Bragg geometry), compute the scattering matrix using equation (43)[link] and the reflection and transmission amplitudes are given in the matrix terms s21 and s11 [equation (39)[link]], respectively.

A first example shows how simple is the application of this recipe of multiplication of transfer matrices to obtain the reflectance of a simple two-layer crystal. Consider a bilayer of two identical crystal layers of thickness T and transfer matrix M for each one. Using matrix analysis, the transfer matrix of the bilayer is [M(T)]2 = M(2T) from which it is easy to compute the reflectivity in Bragg geometry [equation (39)[link]]. Otherwise, if this result would be obtained via the reflectivities (r and Mathematical equation) and transmittivities (t and Mathematical equation) of the single layer (S-matrix), the reflectivity of the bilayer results from an infinite series as shown in Fig. 5[link].

[Figure 5]
Figure 5
Example of calculation of the reflection amplitude r2 of a Si 111 crystal of 2 µm thickness from the amplitudes of the half-layer (1 µm). The reflectivity of the bilayer r2 can be obtained as an infinite sum r2 = Mathematical equation + Mathematical equation + Mathematical equation + … = Mathematical equation = Mathematical equation. Calculations done with crystalpy for a photon energy of 8 keV.

A second example is the Bragg reflection of a crystal layer on a thick substrate. The transfer matrix is calculated as

Mathematical equation

with Mthick the transfer matrix of the substrate and M the transfer matrix of the thin layer. We are interested in the Bragg reflectivity or

Mathematical equation

This can be expressed as a function of the substrate reflectivity Mathematical equation = Mathematical equation giving

Mathematical equation

The method of transfer matrix multiplication can also be used for analysing distorted and bent crystals and will be explored in a future work.

3.7. The direction of the diffracted wave in vacuum

In some applications, as in ray tracing, it is essential to know the diffracted wavevector Mathematical equation that exits from the crystal. As mentioned before, the choice of Mathematical equation in equation (4)[link] is somewhat arbitrary. In our choice, Mathematical equation corresponds exactly to the wavevector of the incident plane wave. The vector Mathematical equation (see Section 2[link]), defined as Mathematical equation = Mathematical equation, does not correspond in general to the wavevector of the outgoing ray or wave outside the crystal. Mathematical equation has the form

Mathematical equation

with n the unit vector along the inward normal to the crystal exit surface. The (real) coefficient β is obtained by writing that the modulus of Mathematical equation is equal to k,

Mathematical equation

Note that Mathematical equation = Mathematical equation and Mathematical equation = Mathematical equation, from which we obtain the equation

Mathematical equation

Its solutions are

Mathematical equation

where the ± sign is chosen in such a way that β = 0 when α = 0 (i.e. positive for γh > 0 and negative for γh < 0).

4. The crystalpy library

Crystalpy is a Python library that performs calculations on diffraction from perfect crystals using the formalism introduced in the previous chapters.

The motivation of crystalpy was to create a modern, extensible, well documented and friendly library to overcome the difficulties of integrating ancient software tools based on the dynamical diffraction theory. It is specifically designed for two objectives: support for new versions of the crystal diffraction codes delivered in platforms like OASYS (Rebuffi & Sanchez del Rio, 2017[Rebuffi, L. & Sanchez del Rio, M. (2017). Proc. SPIE, 10388, 103880S.]), and to provide a core for ray-tracing simulations with crystals. The crystalpy library is written in the Python language and uses standard libraries (NumPy and SciPy). It makes use of vector calculus and stack operations to accelerate the calculations. Therefore, it is adapted for being used in ray-tracing tools, such as the future SHADOW (Sanchez del Rio et al., 2011[Sanchez del Rio, M., Canestrari, N., Jiang, F. & Cerrina, F. (2011). J. Synchrotron Rad. 18, 708-716.]) versions.

To simulate a diffraction experiment using a perfect crystal, crystalpy offers functions that implement the theory described previously. Two input objects must be prepared: (i) the incident wave(s) or photon ray(s), and (ii) the information on the crystal (diffraction setup). The objects representing these two entities are described here.

The Photon class is a minimum class for a photon, containing the energy (in eV) and a unit direction vector, implemented in the Vector class. It deals with the storage and operations (addition, scalar product, cross product, normalization, rotation around an axis, etc.) of a 3D vector. A superclass of Photon is ComplexAmplitudePhoton, that contains the scalar complex amplitude for σ and π polarizations). These classes ( Vector, Photon and ComplexAmplitudePhoton) can hold stacks (the internal storage is done with arrays to speed-up vector operations). The ComplexAmplitudePhoton class has a corresponding ComplexAmplitudePhotonBunch superclass, decorated with methods to deal with multiple waves or beams (bunches or sets of photons).

The information on the crystal itself (e.g. particular crystal material and crystal structure), its preparation (crystal cut) and related physical parameters (like the structure factor) are managed by the DiffractionSetup classes. crystalpy allows multiple options to retrieve the crystal structure and the scattering functions needed to calculate the structure factors. The DiffractionSetupAbstract class defines the methods to access the basic information of the crystal (defined as a string, e.g. `Si') such as angleBragg, dSpacing and unitCellVolume, and to compute the structure factors: F0, FH, FH_ bar. These parameters can be obtained from several libraries external to crystalpy. We implemented three options: (i) DiffractionSetupXraylib using the Mathematical equation library (Schoonjans et al., 2011[Schoonjans, T., Brunetti, A., Golosio, B., Sanchez del Rio, M., Solé, V. A., Ferrero, C. & Vincze, L. (2011). At. Spectrosc. 66, 776-784.]), (ii) DiffractionSetupDabax that uses the dabax library (Sanchez del Rio, 2021[Sanchez del Rio, M. (2021). DABAX Python library, https://github.com/oasys-kit/dabax.]), and (iii) using an ad hoc generated data file. This modular structure permits disconnecting the calculation part from the access to optical and physical constants. Indeed, when using ad hoc data files we do not have to import Mathematical equation or dabax packages. We implemented this for the crystal material files of the SHADOW (Sanchez del Rio et al., 2011[Sanchez del Rio, M., Canestrari, N., Jiang, F. & Cerrina, F. (2011). J. Synchrotron Rad. 18, 708-716.]) code in the traditional version ( DiffractionSetupShadowPreprocessorV1), and in a version supporting d-spacing crystals ( DiffractionSetupShadowPreprocessorV2). The DiffractionSetup classes handle the information about the crystal setup and collect all the parameters needed to fully define the physical system we are modelling: geometry_ type (among BraggDiffraction, BraggTransmission, LaueDiffraction and LaueTransmission), crystal_ name (a string, e.g. Si, Ge), thickness (crystal thickness in SI units [m]), miller _ h, miller _ k, miller_  l (the Miller indices) and asymmetry _ angle [angle in degrees between the crystal surface and the planes hkl as definedby Sanchez del Rio et al. (2015[Sanchez del Rio, M., Perez-Bocanegra, N., Shi, X., Honkimäki, V. & Zhang, L. (2015). J. Appl. Cryst. 48, 477-491.])].

The determination of crystal structure factors (necessary to compute χh, χh and thus uh and uh) is not trivial, and requires the list of the crystallographic parameters (basically the cell parameters and a list of the atoms of the unit cell, with their occupation and coordinates). Both Mathematical equation and Mathematical equation libraries use similar methods that are detailed by Yu et al. (2022[Yu, X. J., Chi, X., Smulders, T., Wee, A. T. S., Rusydi, A., Sanchez del Rio, M. & Breese, M. B. H. (2022). J. Synchrotron Rad. 29, 1157-1166.]). This implementation allows any possible crystal structure. Complex crystals such as alpha-quartz (Sutter et al., 2022[Sutter, J. P., Pittard, J., Filik, J. & Baron, A. Q. R. (2022). J. Appl. Cryst. 55, 1011-1028.]; Sutter et al., 2023[Sutter, J. P., Pittard, J., Filik, J. & Baron, A. Q. R. (2023). Proc. SPIE, 12697, 126970A.]), or YB66 (Yu et al., 2022[Yu, X. J., Chi, X., Smulders, T., Wee, A. T. S., Rusydi, A., Sanchez del Rio, M. & Breese, M. B. H. (2022). J. Synchrotron Rad. 29, 1157-1166.]) are considered. However, some particularities regarding chirality, strong anisotropy or temperature dependence may not be included accurately and are sometimes modelled by phenomenological parameters.

To perform the main calculations (reflectivities, transfer matrices, diffracted photons, etc.) several methods in the Diffraction class are used, getting the crystal setup and the photon bunch as inputs. For the moment, only flat perfect crystals are coded (in the PerfectCrystalDiffraction class) which directly implements the formulation and theory in Section 3[link]. For completeness, crystalpy also includes the equations of Zachariasen (Zachariasen, 1994[Zachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.]) and can be used instead of the formalism described in this paper. Typical angle or photon scans, as shown in Fig. 2[link], are calculated defining a  ComplexAmplitudePhoton entity for each point, grouping them in a ComplexAmplitudePhotonBunch and then calculating the diffraction by the crystal using calculateDiffractedComplexAmplitudes.

A user-friendly application has been written in the OASYS environment to compute diffraction profiles using crystalpy (Fig. 6[link]). The applications automatically generates a script that can be used for further batch calculations.

[Figure 6]
Figure 6
Interactive application for computing the perfect crystal diffraction profiles using crystalpy and available in OASYS.

In the ray-tracing SHADOW4, all calculations related to crystal optics are delegated to crystalpy. Ray-tracing permits simulations of beamline optics including a realistic description of the source. It also allows the simulation of curved crystals, under the assumption that the local reflectivity of the curved crystal is the same as for the flat crystal. This assumption is not always granted and has to be verified before performing ray-tracing simulations including curved crystals.

5. Summary and conclusions

We have presented a theoretical and numerical description of dynamical diffraction in perfect crystals. In the first part of this paper we presented a new perspective of the well known dynamical theory of diffraction applied to undeformed perfect crystals. We deduced the equations of diffraction amplitudes (as well as intensity reflectance and transmittance) starting from basic principles via the solution of the Takagi–Taupin equations. We calculated the transfer matrix, useful to compute the diffraction of stacked crystal layers, and also the scattering matrix, of interest for the Bragg case. For completeness, our results are compared with those presented in the well known textbook by Zachariasen (1994[Zachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.]) (see Appendix C[link]). In the second part we presented crystalpy, a software library completely written in Python that implements the theory previously discussed. This open source tool can be used to predict the diffraction properties of any crystal structure, like Si, Ge or diamond typically used in synchrotron beamlines, but also for any other crystal provided its crystalline structure is known. This library is intended to replace multiple scattered pieces of software in packages like OASYS (Rebuffi & Sanchez del Rio, 2017[Rebuffi, L. & Sanchez del Rio, M. (2017). Proc. SPIE, 10388, 103880S.]) and is designed to be the kernel of the crystal calculations in version 4 of the SHADOW (Sanchez del Rio et al., 2011[Sanchez del Rio, M., Canestrari, N., Jiang, F. & Cerrina, F. (2011). J. Synchrotron Rad. 18, 708-716.]) ray-tracing code. The crystalpy library and its documentation are available from https://github.com/oasys-kit/crystalpy.

APPENDIX A

Derivation of the TT equations for a rotating perfect crystal

In the `rotating crystal mode', the crystal is rotated around an axis perpendicular to the `diffraction plane' which contains the diffraction vector h and the wavevector Mathematical equation of the fixed incident plane-wave in vacuum. The crystal rotation from the exact geometrical Bragg position may be viewed as a special kind of crystal deformation. We propose to use the Takagi–Taupin approach for the deformed crystal to derive the basic results of the dynamic theory for perfect crystal diffraction. The X-ray wavefield inside the crystal is set as

Mathematical equation

Mathematical equation is the position of the diffraction vector when the crystal is in the exact Bragg condition for the fixed incident wavevector Mathematical equation. The vector Mathematical equation = Mathematical equation + Mathematical equation is therefore such that Mathematical equation = Mathematical equation = k = Mathematical equation. The Fourier coefficients χh of the perfect crystal susceptibility are replaced by the function Mathematical equation, in which Mathematical equation = Mathematical equation, with Mathematical equation the displacement field of the deformed crystal. In such conditions, the following form of the TT equations,

Mathematical equation

Mathematical equation

is obtained by inserting equation (53)[link] into (1)[link], with the following approximations: the second-order derivatives of A0,h, supposed to be slowly varying amplitudes, are neglected and only the terms containing Mathematical equation in the product χΨ are considered. Introducing oblique coordinates (s0, sh) in the diffraction plane, along the directions of Mathematical equation and Mathematical equation, so that Mathematical equation = Mathematical equation and Mathematical equation = Mathematical equation, the TT equations are

Mathematical equation

Mathematical equation

Performing the transformation A0 = D0 and Mathematical equation = Dh, we obtain

Mathematical equation

Mathematical equation

This is identical to equation (10)[link] considering that Mathematical equation = Mathematical equation, for which a demonstration follows.

A1. Demonstration of α = (2/k)(∂ϕ/∂sh)

Let Mathematical equation be unit vectors along the fixed directions of Mathematical equation and Mathematical equation; the crystal rotation transforms Mathematical equation into Mathematical equation. A position vector Mathematical equation is transformed into Mathematical equation. The displacement field is Mathematical equation = Mathematical equation + Mathematical equation; Mathematical equation = Mathematical equation. Hence

Mathematical equation

We note that

Mathematical equation

and therefore

Mathematical equation

APPENDIX B

Solutions of TT equations (17)[link] using the Laplace transform

B1. Laue solution based on Laplace transform

Let us denote Mathematical equation the Laplace transform of a function F(s)

Mathematical equation

Applying the Laplace transform to equations (17)[link] we get

Mathematical equation

The solutions are

Mathematical equation

with, as previously defined, a2 = ω2 + buhuh, a = (ω2 + buhuh)1/2, hence one retrieves the same results of equations (34)[link] using the fact that (p2 + a2)−1 and p(p2 + a2)−1 are the Laplace transforms of sin(as)/a and cos(as), respectively.

B2. Bragg solution based on Laplace transform

By Laplace transform of equation (17)[link], and calling r′ = Bh(0), we obtain

Mathematical equation

or

Mathematical equation

with (the same as before) a2 = ω2 + buhuh. Hence,

Mathematical equation

Mathematical equation

r and then the reflected and transmitted amplitudes are obtained using the condition Dh(T) = Bh(T) = 0. With some calculation, we obtain the results of equations (39)[link].

APPENDIX C

Equivalence of amplitudes in equation (39)[link] and (34)[link] with Zachariasen's formulation

The diffracted and transmitted intensities (not the amplitudes) are derived in the book of Zachariasen (Zachariasen, 1994[Zachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.]) (first edition published in 1944). It is shown hereafter that the amplitudes can be easily derived from Zachariasen's formalism. For that purpose, we use Zachariasen's notation and equations.

In the Laue case, using equations [3.127] and [3.128] of Zachariasen (1994[Zachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.]), we obtain

Mathematical equation

Mathematical equation

Similarly, in the Bragg case, using Zachariasen's equations [3.127] and [3.135], we obtain7

Mathematical equation

Mathematical equation

The symbols c and x are

Mathematical equation

γ0h) is the direction cosine of the incident (diffracted) wave and the other quantities are defined as

Mathematical equation

Mathematical equation

Mathematical equation

Mathematical equation

with X = (q + z2)1/2, q = Mathematical equation, ΨH is the Fourier component of the electrical susceptibility Ψ0 and b = γ0h is the asymmetry factor.

It is easy to see that Mathematical equation = Mathematical equation, x1x2 = Mathematical equation. Introducing the variables c = Mathematical equation and m = −2πk0Xt/(2γ0), we have

Mathematical equation

and

Mathematical equation

Replacing in equation (56)[link] the terms obtained here we finally get

Mathematical equation

For the Bragg case, we pre-calculate

Mathematical equation

that we introduced in equation (56)[link] and we finally get

Mathematical equation

Considering the equivalence of notations between this work and Zachariasen' book (see Table 1[link]), we can verify that equations (55)[link] are identical to (34)[link] and, similarly, equations (56)[link] are identical to (39)[link].

Table 1
Correspondences of notation in this work and Zachariasen (1994[Zachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.])

Zachariasen This work
Mathematical equation Mathematical equation
k0 = 1/λ k = 2π/λ
αZ α
Ψ0 χ0
ΨH χh
z −(λ/π)ω
X (λ/π)a
t0 tc = T/γ0
m aT
c Mathematical equation

Footnotes

1If the approximation in equation (9)[link] were not used, the coefficients of D0,h in (10b)[link] should be multiplied by (1 − α)−1/2 ≃ 1 + α/2 +…; since χ0, χh and α are much smaller than 1, we neglect the high-order terms.

2For any point Mathematical equation = (s0,sh,st), s is the path length inside the crystal along Mathematical equation: the ray through r enters the crystal at the point of coordinates (s0, sh, st) such that γ0s0 + γhsh = 0, so that s = s0s0 = s0 + sh/b.

3These solutions are the Ewald wavefields discussed in detail by Authier (2003[Authier, A. (2003). Dynamical Theory of X-ray Diffraction. Oxford University Press.]) using the dispersion surface.

4Our α has the opposite sign to the α defined in equation [3.114b] of Zachariasen (1994[Zachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.]).

5To see this, suppose Mathematical equation > 0; this implies [equation (27)[link]] Mathematical equation < 0 (note that b < 0 for the Bragg case) and [equation (28a)[link]] Mathematical equation > 0, therefore [equation (29)[link]] Mathematical equation > 0 if Mathematical equation > 0. Similarly, supposing Mathematical equation < 0, we obtain Mathematical equation > 0 and Mathematical equation < 0, therefore Mathematical equation < 0 if Mathematical equation > 0.

6The multiplication should be done from bottom to top, i.e. M = MnMn−1M2M1.

7Note that in equation (56b)[link] we write (c2c1) rather than (c1c2) in Zachariasen's equation [3.137]. This does not affect the result shown by Zachariasen as the amplitudes are squared to give intensities. However, for calculating the amplitudes, the correct sign (as shown here) is important.

Acknowledgements

We recognize the work of Edoardo Cappelli and Mark Glass who developed the first version of crystalpy implementing the theory in Zachariasen (1994[Zachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.]). We acknowledge Ali Khounsary and Yujia Ding (CSRII, Illinois Institute of Technology, Chicago, IL 60616, USA) for helpful discussions on stacked crystals.

References

First citationAuthier, A. (2003). Dynamical Theory of X-ray Diffraction. Oxford University Press.  Google Scholar
First citationBaumgärtel, P., Grundmann, P., Zeschke, T., Erko, A., Viefhaus, J., Schäfers, F. & Schirmacher, H. (2019). AIP Conf. Proc. 2054, 060034.  Google Scholar
First citationBouchenoire, L., Brown, S. D., Thompson, P., Duffy, J. A., Taylor, J. W. & Cooper, M. J. (2003). J. Synchrotron Rad. 10, 172–176.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationChernikov, R. & Klementiev, K. (2017). Proc. SPIE, 10388, 1038806.  Google Scholar
First citationChubar, O. & Elleaume, P. (1998). Proceedings of the 6th European Particle Accelerator Conference (EPAC1998), pp. 1177–1179. THP01G.  Google Scholar
First citationDetlefs, C., Sanchez del Rio, M. & Mazzoli, C. (2012). Eur. Phys. J. Spec. Top. 208, 359–371.  Web of Science CrossRef CAS Google Scholar
First citationIshikawa, T., Tamasaku, K. & Yabashi, M. (2005). Nucl. Instrum. Methods Phys. Res. A, 547, 42–49.  Web of Science CrossRef CAS Google Scholar
First citationKlementiev, K. & Chernikov, R. (2023). Synchrotron Radiat. News, 36(5), 23–27.  CrossRef Google Scholar
First citationPinsker, Z. G. (1978). Dynamical Scattering of X-rays in Crystals. Springer-Verlag.  Google Scholar
First citationRebuffi, L. & Sanchez del Rio, M. (2017). Proc. SPIE, 10388, 103880S.  Google Scholar
First citationRen, B., Dilmanian, F., Chapman, L., Ivanov, I., Wu, X., Zhong, Z. & Huang, X. (1999). Nucl. Instrum. Methods Phys. Res. A, 428, 528–550.  Web of Science CrossRef CAS Google Scholar
First citationRovezzi, M., Lapras, C., Manceau, A., Glatzel, P. & Verbeni, R. (2017). Rev. Sci. Instrum. 88, 013108.  Web of Science CrossRef PubMed Google Scholar
First citationSanchez del Rio, M. (2021). DABAX Python library, https://github.com/oasys-kit/dabaxGoogle Scholar
First citationSanchez del Rio, M., Canestrari, N., Jiang, F. & Cerrina, F. (2011). J. Synchrotron Rad. 18, 708–716.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationSanchez del Rio, M., Perez-Bocanegra, N., Shi, X., Honkimäki, V. & Zhang, L. (2015). J. Appl. Cryst. 48, 477–491.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationSchäfers, F. (2008). The BESSY Raytrace Program RAY, pp. 9–41. Berlin, Heidelberg: Springer.  Google Scholar
First citationSchoonjans, T., Brunetti, A., Golosio, B., Sanchez del Rio, M., Solé, V. A., Ferrero, C. & Vincze, L. (2011). At. Spectrosc. 66, 776–784.  Web of Science CrossRef CAS Google Scholar
First citationShvyd'ko, Y. (2004). X-ray optics: high-energy-resolution applications, Vol. 98 of Springer Series in Optical Sciences. Springer Science & Business Media.  Google Scholar
First citationStepanov, S. A. (2004). Proc. SPIE, 5536, 16–26.  CrossRef Google Scholar
First citationSuortti, P., Thomlinson, W., Chapman, D., Gmür, N., Siddons, D. & Schulze, C. (1993). Nucl. Instrum. Methods Phys. Res. A, 336, 304–309.  CrossRef Web of Science Google Scholar
First citationSutter, J. P., Chubar, O. & Suvorov, A. (2014). Proc. SPIE, 9209, 92090L.  Google Scholar
First citationSutter, J. P., Pittard, J., Filik, J. & Baron, A. Q. R. (2022). J. Appl. Cryst. 55, 1011–1028.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationSutter, J. P., Pittard, J., Filik, J. & Baron, A. Q. R. (2023). Proc. SPIE, 12697, 126970A.  Google Scholar
First citationTakagi, S. (1962). Acta Cryst. 15, 1311–1312.  CrossRef CAS IUCr Journals Web of Science Google Scholar
First citationTaupin, D. (1964). Bull. Soc. Fr. Miner. Crystallogr. 87, 469–511.  CAS Google Scholar
First citationTaupin, D. (1967). Acta Cryst. 23, 25–35.  CrossRef CAS IUCr Journals Web of Science Google Scholar
First citationTolentino, H., Dartyge, E., Fontaine, A. & Tourillon, G. (1988). J. Appl. Cryst. 21, 15–22.  CrossRef CAS Web of Science IUCr Journals Google Scholar
First citationYu, X. J., Chi, X., Smulders, T., Wee, A. T. S., Rusydi, A., Sanchez del Rio, M. & Breese, M. B. H. (2022). J. Synchrotron Rad. 29, 1157–1166.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationZachariasen, W. H. (1994). Theory of X-ray Diffraction in Crystals. Dover Publications.  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 logoJOURNAL OF
SYNCHROTRON
RADIATION
ISSN: 1600-5775
Follow J. Synchrotron Rad.
Sign up for e-alerts
Follow J. Synchrotron Rad. on Twitter
Follow us on facebook
Sign up for RSS feeds