Materials

Module materials defines atomic and material properties related to x-ray scattering, diffraction and propagation: reflectivity, transmittivity, refractive index, absorption coefficient etc.

read_atomic_data

Reads atomic data from AtomicData.dat file adopted from XOP [XOP].

Element

Interface to scattering factors f0, f1 and f2 of a chemical element.

Material

Interface to reflectivity, transmittivity, refractive index and absorption coefficient of a material specified by its chemical formula and density.

Multilayer

Interface to reflectivity and transmittivity of a multilayer.

Coated

Derivative class from Mutilayer with a single reflective layer on top of a substrate.

Crystal

The base class for crystals; the descendants define a method get_structure_factor().

CrystalFcc

FCC crystal.

CrystalDiamond

Diamond-like crystal.

CrystalSi

Si crystal with d-spacing as a function of temperature.

CrystalFromCell

Crystal from cell parameters and atomic positions.

Powder

Crystal with randomly distributed atomic plane orientations.

MonoCrystal

Calculates single crystal diffraction (so far cubic symettries only).

TXMMaterial

Indexed-volume transmission sample material from HDF5 file.

xrt.backends.raycing.materials.read_atomic_data(elem)

Reads atomic data from AtomicData.dat file adopted from XOP [XOP]. It has the following data: 0 AtomicRadius[Å] CovalentRadius[Å] AtomicMass BoilingPoint[K] MeltingPoint[K] Density[g/ccm] AtomicVolume CoherentScatteringLength[1E-12cm] IncoherentX-section[barn] Absorption@1.8Å[barn] DebyeTemperature[K] ThermalConductivity[W/cmK]

In read_atomic_data() only the mass is inquired. The user may extend the method to get the other values by simply adding the corresponding array elements to the returned value.

class xrt.backends.raycing.materials.Element

Interface to scattering factors f0, f1 and f2 of a chemical element. It can also report other atomic data listed in AtomicData.dat file adopted from XOP [XOP].

__init__(elem=None, table='Chantler')
elem: str or int

The element can be specified by its name (case sensitive) or its ordinal number.

table: str

This parameter is explained in the description of Material.

get_f0(qOver4pi=0)

Calculates f0 for the given qOver4pi.

get_f1f2(E)

Calculates (interpolates) f1 and f2 for the given array E.

read_f0_Kissel()

Reads f0 scattering factors from the tabulation of XOP [XOP]. These were calculated by [Kissel] and then parameterized as [Waasmaier]:

\[f_0\left(\frac{q}{4\pi}\right) = c + \sum_{i=1}^5{a_i\exp\left(-b_i \left(q/(4\pi)\right)^2\right)}\]

where \(q/(4\pi) = \sin{\theta} / \lambda\) and \(a_i\), \(b_i\) and \(c\) are the coefficients tabulated in the file f0_xop.dat.

[Kissel]

L. Kissel, Radiation physics and chemistry 59 (2000) 185-200, http://www-phys.llnl.gov/Research/scattering/RTAB.html

[Waasmaier]

D. Waasmaier & A. Kirfel, Acta Cryst. A51 (1995) 416-413

read_f1f2_vs_E(table)

Reads f1 and f2 scattering factors from the given table at the instantiation time.

class xrt.backends.raycing.materials.Material

Interface to reflectivity, transmittivity, refractive index and absorption coefficient of a material specified by its chemical formula and density. See also predefined materials in modules compounds and elemental.

__init__(elements=None, quantities=None, kind='auto', rho=0, t=None, table='Chantler total', efficiency=None, efficiencyFile=None, name='', refractiveIndex=None, **kwargs)
elements: str or sequence of str

Contains all the constituent elements (symbols)

quantities: None or sequence of floats of length of elements

Coefficients in the chemical formula. If None, the coefficients are all equal to 1.

kind: str

One of ‘mirror’, ‘thin mirror’, ‘plate’, ‘lens’, ‘grating’, ‘FZP’. If ‘auto’, the optical element will decide which material kind to use via its method assign_auto_material_kind().

rho: float

Density in g/cm³.

t: float or None

Thickness in mm. Required for ‘thin mirror’; also used by finite-thickness materials such as crystals where supported.

table: str

At the time of instantiation the tabulated scattering factors of each element are read and then interpolated at the requested q value and energy. table can be ‘Henke’ (10 eV < E < 30 keV) [Henke], ‘Chantler’ (11 eV < E < 405 keV) [Chantler] or ‘BrCo’ (30 eV < E < 509 keV) [BrCo].

The tables of f2 factors consider only photoelectric cross-sections. The tabulation by Chantler can optionally have total absorption cross-sections. This option is enabled by table = ‘Chantler total’.

[Henke]

http://henke.lbl.gov/optical_constants/asf.html B.L. Henke, E.M. Gullikson, and J.C. Davis, X-ray interactions: photoabsorption, scattering, transmission, and reflection at E=50-30000 eV, Z=1-92, Atomic Data and Nuclear Data Tables 54 (no.2) (1993) 181-342.

[Chantler]

http://physics.nist.gov/PhysRefData/FFast/Text/cover.html http://physics.nist.gov/PhysRefData/FFast/html/form.html C. T. Chantler, Theoretical Form Factor, Attenuation, and Scattering Tabulation for Z = 1 - 92 from E = 1 - 10 eV to E = 0.4 - 1.0 MeV, J. Phys. Chem. Ref. Data 24 (1995) 71-643.

[BrCo]

http://www.bmsc.washington.edu/scatter/periodic-table.html ftp://ftpa.aps.anl.gov/pub/cross-section_codes/ S. Brennan and P.L. Cowan, A suite of programs for calculating x-ray absorption, reflection and diffraction performance for a variety of materials at arbitrary wavelengths, Rev. Sci. Instrum. 63 (1992) 850-853.

efficiency: sequence of pairs [order, value]

Can be given for kind = ‘grating’ and kind = ‘FZP’. It must correspond to the field order of the OE. It can be given as a constant per diffraction order or as an energy dependence, also per diffraction order. It is a sequence of pairs [order, value], where value is either the efficiency itself or an index in the data file given by efficiencyFile. The data file can either be (1) a pickle file with energy and efficiency arrays as two first dump elements and efficiency shape as (len(energy), orders) or (2) a column file with energy in the leftmost column and the order efficiencies in the next columns. The value is a corresponding array index (zero-based) or a column number (also zero-based, the 0th column is energy). An example of the efficiency calculation can be found in \examples\withRaycing\11_Wave\waveGrating.py.

efficiencyFile: str or None

See the definition of efficiency.

name: str

Material name. Not used by xrt. Can be used by the user for annotations of graphs or other output purposes. If empty, the name is constructed from the elements and the quantities.

refractiveIndex: float or complex or numpy array or str

Material refractive index is calculated from the tabulated scattering factors by get_refractive_index(). If the target energy range is not covered by the tables of scattering factors (e.g. at IR or visible energies), refractive index can be externally defined by refractiveIndex as: a) float or complex value, for a constant, energy-independent refractive index. b) a 3-column numpy array containing Energy in eV, real and imaginary parts of the complex refractive index c) filename for an *.xls or CSV table containig same columns as a numpy array in b).

get_absorption_coefficient(E)

Calculates the linear absorption coefficient from the imaginary part of refractive index. E can be an array. The result is in cm-1.

\[\mu = 2 \Im(n) k.\]
get_amplitude(E, beamInDotNormal, fromVacuum=True)

Calculates amplitude of reflectivity (for ‘mirror’ and ‘thin mirror’) or transmittivity (for ‘plate’ and ‘lens’) [wikiFresnelEq], [Als-Nielsen]. E is energy, beamInDotNormal is cosine of the angle between the incoming beam and the normal (\(\theta_1\) below), both can be scalars or arrays. The interface of the material is assumed to be with vacuum; the direction is given by boolean fromVacuum. Returns a tuple of the amplitudes of s and p polarizations and the absorption coefficient in cm-1.

\[\begin{split}r_s^{\rm mirror} &= \frac{n_1\cos{\theta_1} - n_2\cos{\theta_2}} {n_1\cos{\theta_1} + n_2\cos{\theta_2}}\\ r_p^{\rm mirror} &= \frac{n_2\cos{\theta_1} - n_1\cos{\theta_2}} {n_2\cos{\theta_1} + n_1\cos{\theta_2}}\\ r_{s,p}^{\rm thin\ mirror} &= r_{s,p}^{\rm mirror}\frac{1 - p^2} {1 - (r_{s,p}^{\rm mirror})^2p^2},\end{split}\]

where the phase factor \(p^2 = \exp(2iEtn_2\cos{\theta_2}/c\hbar)\).

\[\begin{split}t_s^{\rm plate,\ lens} &= 2\frac{n_1\cos{\theta_1}} {n_1\cos{\theta_1} + n_2\cos{\theta_2}}t_f\\ t_p^{\rm plate,\ lens} &= 2\frac{n_1\cos{\theta_1}} {n_2\cos{\theta_1} + n_1\cos{\theta_2}}t_f\\\end{split}\]

where \(t_f = \sqrt{\frac{\Re(n_2n_1)\cos{\theta_2}} {cos{\theta_1}}}/|n_1|\).

[Als-Nielsen] (1,2)

Jens Als-Nielsen, Des McMorrow, Elements of Modern X-ray Physics, John Wiley and Sons, 2001.

get_refractive_index(E)

Calculates refractive index at given E. E can be an array.

\[n = 1 - \frac{r_0\lambda^2 N_A \rho}{2\pi M}\sum_i{x_i f_i(0)}\]

where \(r_0\) is the classical electron radius, \(\lambda\) is the wavelength, \(N_A\) is Avogadro’s number, \(\rho\) is the material density, M is molar mass, \(x_i\) are atomic concentrations (coefficients in the chemical formula) and \(f_i(0)\) are the complex atomic scattering factor for the forward scattering.

class xrt.backends.raycing.materials.TXMMaterial

Indexed-volume transmission sample material from HDF5 file.

The HDF5 file must use the following layout:

/indexGrid       integer dataset, shape (nz, ny, nx)
/limits/x        [xmin, xmax] in mm
/limits/y        [ymin, ymax] in mm
/limits/z        [zmin, zmax] in mm

The grid axis order is always (z, y, x). Each value stored in /indexGrid is an integer key in materialsIndex. The number of voxels along each axis is taken from the shape of /indexGrid.

The optional /indexGrid attribute backgroundIndex identifies the material used when spatial coordinates are not supplied. It defaults to 0. If the optional axisOrder attribute is present, it must be "zyx".

An instance with an empty fileName or materialsIndex is a transparent vacuum placeholder. This allows GUI editors to create and configure the material incrementally. A failed reload of a non-empty configuration is recorded in loadError and leaves the last successfully loaded volume active.

For example, a compatible file can be created with:

with h5py.File("sample.h5", "w") as h5:
    grid = h5.create_dataset(
        "indexGrid", data=indexGrid, dtype="u1")
    grid.attrs["axisOrder"] = "zyx"
    grid.attrs["backgroundIndex"] = 0

    limits = h5.create_group("limits")
    limits.create_dataset("x", data=[-0.025, 0.025])
    limits.create_dataset("y", data=[-0.025, 0.025])
    limits.create_dataset("z", data=[0.0, 0.050])
__init__(fileName=None, materialsIndex=None, name='', **kwargs)
fileName: str

Path to the indexed-volume HDF5 file.

materialsIndex: dict or sequence

Maps the integer values stored in /indexGrid to material instances or material names. A sequence is interpreted as a zero-based mapping. For example:

materialsIndex = {
    0: water,
    1: rocksalt,
    2: air,
}
name: str

User-specified name.

get_absorption_coefficient(E, x=None, y=None, z=None)

Calculates the linear absorption coefficient from the imaginary part of refractive index. E can be an array. The result is in cm-1.

\[\mu = 2 \Im(n) k.\]
get_refractive_index(E, x=None, y=None, z=None)

Calculates refractive index at given E. E can be an array.

\[n = 1 - \frac{r_0\lambda^2 N_A \rho}{2\pi M}\sum_i{x_i f_i(0)}\]

where \(r_0\) is the classical electron radius, \(\lambda\) is the wavelength, \(N_A\) is Avogadro’s number, \(\rho\) is the material density, M is molar mass, \(x_i\) are atomic concentrations (coefficients in the chemical formula) and \(f_i(0)\) are the complex atomic scattering factor for the forward scattering.

class xrt.backends.raycing.materials.Multilayer

Interface to reflectivity and transmittivity of a multilayer. The multilayer may have variable thicknesses of the two alternating layers as functions of local x and y and/or as a function of the layer number.

__init__(tLayer=None, tThickness=0.0, bLayer=None, bThickness=0.0, nPairs=0, substrate=None, tThicknessLow=0.0, bThicknessLow=0.0, idThickness=0.0, power=2.0, substRoughness=0.0, substThickness=inf, name='', geom='reflected', **kwargs)
tLayer, bLayer, substrate: instance of Material

The top layer material, the bottom layer material and the substrate material.

tThickness and bThickness: float in Å

The thicknesses of the layers. If the multilayer is depth graded, tThickness and bThickness are at the top and tThicknessLow and bThicknessLow are at the substrate. If you need laterally graded thicknesses, modify get_t_thickness and/or get_b_thickness in a subclass.

power: float

Defines the exponent of the layer thickness power law, if the multilayer is depth graded:

\[d_n = A / (B + n)^{power}.\]
tThicknessLow and bThicknessLow: float

Are ignored (left as zeros) if not depth graded.

nPairs: int

The number of layer pairs.

idThickness: float in Å

RMS thickness \(\\sigma_{j,j-1}\) of the interdiffusion/roughness interface.

substThickness: float in Å

Is only relevant in transmission if substrate is present.

geom: str

Either ‘transmitted’ or ‘reflected’.

get_amplitude(E, beamInDotNormal, x=None, y=None, ucl=None)

Calculates amplitude of reflectivity [Als-Nielsen]. E is energy, beamInDotNormal is cosine of the angle between the incoming beam and the normal (\(\theta_0\) below), both can be scalars or arrays. The top interface of the multilayer is assumed to be with vacuum. Returns a tuple of the amplitudes of s and p polarizations.

The calculation starts from the bottommost layer (with index \(N\)). The reflectivity from its top into the adjacent layer (\(N-1\)) is:

\[R_N = \frac{r_{N-1, N} + r_{N, N+1} p_N^2} {1 + r_{N-1, N} r_{N, N+1} p_N^2},\]

where the capital \(R\) denotes the net reflectivity of the layer and the small letters \(r\) denote the interface reflectivity (Fresnel equations):

\[r_{j, j+1} = \frac{Q_j - Q_{j+1}}{Q_j + Q_{j+1}},\]

here \(N+1\) refers to the substrate material and

\[Q_j = \sqrt{Q^2 - 8k^2\delta_j + i8k^2\beta_j}, \quad Q = 2k\sin{\theta_0}\]

and \(\delta_j\) and \(\beta_j\) are parts of the refractive index \(n_j = 1 - \delta_j + i\beta_j\). The phase factor \(p_j^2\) is \(\exp(i\Delta_j Q_j)\), \(\Delta_j\) being the layer thickness. The calculation proceeds recursively upwards by layers as

\[R_j = \frac{r_{j-1, j} + R_{j+1} p_j^2} {1 + r_{j-1, j} R_{j+1} p_j^2},\]

until \(R_1\) is reached, where the 0th layer is vacuum and \(Q_0 = Q\).

If the interdiffusion thickness is not zero, the reflectivity at each interface is attenuated by a factor of \(exp(-2k_{j,z}k_{j-1,z}\sigma^{2}_{j,j-1})\), where \(k_{j,z}\) is longitudinal component of the wave vector in j-th layer [Nevot-Croce].

The above formulas refer to s polarization. The p part differs at the interface:

\[r^p_{j, j+1} = \frac{Q_j\frac{n_{j+1}}{n_j} - Q_{j+1}\frac{n_{j}}{n_{j+1}}}{Q_j\frac{n_{j+1}}{n_j} + Q_{j+1}\frac{n_{j}}{n_{j+1}}}\]

and thus the p polarization part requires a separate recursive chain.

In transmission, the recursion is the following (we could not find any relevant paper or book, this is our own simple derivation):

\[T_{N+1} = \frac{t_{N, N+1}t_{N+1, N+2}p_{N+1}} {1 + r_{N, N+1} r_{N+1, N+2} p_N^2}, \quad T_j = \frac{T_{j+1}t_{j-1, j}p_j}{1 + r_{j-1, j} R_{j+1} p_j^2},\]

where the layer \(N+2\) is vacuum and the interface transmittivities for the two polarizations are equal to:

\[t^s_{j, j+1} = \frac{2Q_j}{Q_j + Q_{j+1}}, \quad t^p_{j, j+1} = \frac{2Q_j\frac{n_{j+1}}{n_j}} {Q_j\frac{n_{j+1}}{n_j} + Q_{j+1}\frac{n_{j}}{n_{j+1}}}\]
[Nevot-Croce]

L. Nevot and P. Croce, Rev. Phys. Appl. 15, (1980) 761

get_b_thickness(x, y, iPair)

The bottom (the lower in the period pair) layer thickness in Å as a function of local coordinates x and y and the index (zero at vacuum) of the period pair.

For parametric surfaces, the x and y local coordinates are assumed to be s and phi of the parametric representation.

get_dtheta_symmetric_Bragg(E, order=1)

The angle correction for the symmetric Bragg case:

\[\delta\theta = \theta_B - \arcsin(\sqrt{m^2\lambda^2 + 8 d^2 \overline\delta} / 2d),\]

where \(\overline\delta\) is the period-averaged real part of the refractive index.

get_t_thickness(x, y, iPair)

The top (the upper in the period pair) layer thickness in Å as a function of local coordinates x and y and the index (zero at vacuum) of the period pair.

For parametric surfaces, the x and y local coordinates are assumed to be s and phi of the parametric representation.

class xrt.backends.raycing.materials.Coated

Derivative class from Mutilayer with a single reflective layer on top of a substrate.

__init__(*args, **kwargs)
coating, substrate: instance of Material

Material of the mirror coating layer, and the substrate material.

cThickness: float

The thicknesses of mirror coating in Å.

surfaceRoughness: float

RMS rougness of the mirror surface in Å.

substRoughness: float

RMS rougness of the mirror substrate in Å.

class xrt.backends.raycing.materials.Crystal(Material)

The base class for crystals; the descendants define a method get_structure_factor(). Crystal gives reflectivity and transmittivity of a crystal in Bragg and Laue cases.

__init__(hkl=[1, 1, 1], d=0, V=None, elements='Si', quantities=None, rho=0, t=None, factDW=1.0, geom='Bragg reflected', table='Chantler total', name='', volumetricDiffraction=False, useTT=False, nu=None, mosaicity=0, **kwargs)
hkl: sequence

hkl indices.

d: float

Interatomic spacing in Å.

V: float

Unit cell volume in ų. If not given, is calculated from d assuming a cubic symmetry.

t: float or None

Crystal thickness in mm. Infinite if None. Finite values are used by Bragg, Laue, TT and volumetric diffraction where applicable.

factDW: float

Debye-Waller factor applied to the structure factor.

geom: str

The 1st word is either ‘Bragg’ or ‘Laue’, the 2nd word is either ‘transmitted’ or ‘reflected’ or ‘Fresnel’ (the optical element must then provide local_g method that gives the grating vector).

table: str

This parameter is explained in the description of the parent class Material.

volumetricDiffraction: bool

By default the diffracted ray originates in the point of incidence on the surface of the crystal in both Bragg and Laue case. When volumetricDiffraction is enabled, the point of diffraction is generated randomly along the transmitted beam path, effectively broadening the meridional beam profile in plain Laue crystal. If the crystal is bent, local deformation of the diffracting plane is taken into account, creating the polychromatic focusing effect.

useTT: bool

Specifies whether the reflectivity is calculated by analytical formula (useTT is False) or by solution of the Takagi-Taupin equations (when useTT is True). The latter case is based on PyTTE code [PyTTE1] [PyTTE2] that was adapted to running the calculations on GPUs.

[PyTTE2]

A.-P. Honkanen, S. Huotari, IUCrJ 8 (2021) 102-115. doi:10.1107/S2052252520014165

Warning

You need a good graphics card to run these calculations! The corresponding optical element, that utilizes the present crystal material class, must specify targetOpenCL (typically, ‘auto’) and precisionOpenCL (in Bragg cases ‘float32’ is typically sufficient and ‘float64’ is typically needed in Laue cases).

nu: float

Poisson’s ratio. Can be used for calculation of reflectivity in bent isotropic crystals with [PyTTE1]. Not required for plain crystals or for crystals with predefined compliance matrix, see crystals. If provided, overrides existing compliance matrix.

mosaicity: float, radians

The sigma of the normal distribution of the crystallite normals.

xrt follows the concept of mosaic crystals from [SanchezDelRioMosaic]. This concept has three main parts: (i) a random distribution of the crystallite normals results in a distribution in the reflected directions, (ii) the secondary extinction results in a mean free path distribution of the new ray origins and (iii) the reflectivity is calculated following the work [BaconLowde].

In the above stage (ii), the impact points are sampled according to the secondary extinction distribution. For a thin crystal (when t is specified) those rays that go over the crystal thickness retain the original incoming direction and their x, y, z coordinates (the ray heads) are put on the back crystal surface. These rays are also attenuated by the mosaic crystal. Note again that the impact points do not lie on the front crystal surface, so to plot them in a 2D XY plot becomes useless. You can still plot them as YZ or XZ to study the secondary extinction depth. The remaining rays (those sampled within the crystal depth) get reflected and also attenuated depending on the penetration depth.

Note

The amplitude calculation in the mosaic case is implemented only in the reflection geometry. The transmitted beam can still be studied by ray-tracing as we split the beam in our modeling of secondary extinction, see the previous paragraph.

Note

The mosaicity is assumed large compared with the Darwin width. Therefore, there is no continuous transition mosaic-to-perfect crystal at a continuously reduced mosaicity parameter.

See the tests here.

[SanchezDelRioMosaic]

M. Sánchez del Río et al., Rev. Sci. Instrum. 63 (1992) 932.

[BaconLowde]

G. E. Bacon and R. D. Lowde, Acta Crystallogr. 1, (1948) 303.

get_Darwin_width(E, b=1.0, polarization='s')

Calculates the Darwin width as

\[2\delta = |C|\sqrt{\chi_h\chi_{\overline{h}} / b}/\sin{2\theta}\]
get_amplitude(E, beamInDotNormal, beamOutDotNormal=None, beamInDotHNormal=None, xd=None, yd=None)

Calculates complex amplitude reflectivity and transmittivity for s- and p-polarizations (\(\gamma = s, p\)) in Bragg and Laue cases for the crystal of thickness L, based upon Belyakov & Dmitrienko [BD]:

\[\begin{split}R_{\gamma}^{\rm Bragg} &= \chi_{\vec{H}}C_{\gamma}\left(\alpha + i\Delta_{\gamma}\cot{l_{\gamma}}\right)^{-1}|b|^{-\frac{1}{2}}\\ T_{\gamma}^{\rm Bragg} &= \left(\cos{l{_\gamma}} - i\alpha\Delta {_\gamma}^{-1}\sin{l_{\gamma}}\right)^{-1} \exp{\left(i\vec{\kappa}_0^2 L (\chi_0 - \alpha b) (2\vec{\kappa}_0\vec{s})^{-1}\right)}\\ R_{\gamma}^{\rm Laue} &= \chi_{\vec{H}}C_{\gamma} \Delta_{\gamma}^{-1}\sin{l_{\gamma}}\exp{\left(i\vec{\kappa}_0^2 L (\chi_0 - \alpha b) (2\vec{\kappa}_0\vec{s})^{-1}\right)} |b|^{-\frac{1}{2}}\\ T_{\gamma}^{\rm Laue} &= \left(\cos{l_{\gamma}} + i\alpha \Delta_{\gamma}^{-1}\sin{l_{\gamma}}\right) \exp{\left(i\vec{\kappa}_0^2 L (\chi_0 - \alpha b) (2\vec{\kappa}_0\vec{s})^{-1}\right)}\end{split}\]

where

\[\begin{split}\alpha &= \frac{\vec{H}^2 + 2\vec{\kappa}_0\vec{H}} {2\vec{\kappa}_0^2}+\frac{\chi_0(1-b)}{2b}\\ \Delta_{\gamma} &= \left(\alpha^2 +\frac{C_{\gamma}^2\chi_{\vec{H}} \chi_{\overline{\vec{H}}}}{b}\right)^{\frac{1}{2}}\\ l_{\gamma} &= \frac{\Delta_{\gamma}\vec{\kappa}_0^2L} {2\vec{\kappa}_{\vec{H}}\vec{s}}\\ b &= \frac{\vec{\kappa}_0\vec{s}}{\vec{\kappa}_{\vec{H}}\vec{s}}\\ C_s &= 1, \quad C_p = \cos{2\theta_B}\end{split}\]

In the case of thick crystal in Bragg geometry:

\[R_{\gamma}^{\rm Bragg} = \frac{\chi_{\vec{H}} C_{\gamma}} {\alpha\pm\Delta_{\gamma}}|b|^{-\frac{1}{2}}\]

with the sign in the denominator that gives the smaller modulus of \(R_\gamma\).

\(\chi_{\vec{H}}\) is the Fourier harmonic of the x-ray susceptibility, and \(\vec{H}\) is the reciprocal lattice vector of the crystal. \(\vec{\kappa}_0\) and \(\vec{\kappa}_{\vec{H}}\) are the wave vectors of the direct and diffracted waves. \(\chi_{\vec{H}}\) is calculated as:

\[\chi_{\vec{H}} = - \frac{r_0\lambda^2}{\pi V}F_{\vec{H}},\]

where \(r_e = e^2 / mc^2\) is the classical radius of the electron, \(\lambda\) is the wavelength, V is the volume of the unit cell.

Notice \(|b|^{-\frac{1}{2}}\) added to the formulas of Belyakov & Dmitrienko in the cases of Bragg and Laue reflections. This is needed because ray tracing deals not with wave fields but with rays and therefore not with intensities (i.e. per cross-section) but with flux.

[BD]

V. A. Belyakov and V. E. Dmitrienko, Polarization phenomena in x-ray optics, Uspekhi Fiz. Nauk. 158 (1989) 679–721, Sov. Phys. Usp. 32 (1989) 697–719.

xd and yd are local coordinates of the corresponding optical element. If they are not None and crystal’s get_d method exists, the d spacing is given by the get_d method, otherwise it equals to self.d. In a parametric representation, xd and yd are the same parametric coordinates used in local_r and local_n` methods of the corresponding optical element.

get_amplitude_pytte(E, beamInDotNormal, beamOutDotNormal=None, beamInDotHNormal=None, xd=None, yd=None, alphaAsym=None, inPlaneRotation=None, Ry=None, Rx=None, ucl=None, tolerance=1e-06, maxSteps=10000000.0, autoLimits=True, signal=None)

Calculates complex amplitude reflectivity for s- and p-polarizations (\(\gamma = s, p\)) in Bragg and Laue cases, based on modified PyTTE code

alphaAsymm: float

Angle of asymmetry in radians.

inPlaneRotation: float

Counterclockwise-positive rotation of the crystal directions around the normal vector of (hkl) in radians. (see pyTTE.TTcrystal). In-plane rotation definition as vector is not supported in xrt currently.

Ry: float

Meridional radius of curvature in mm. Positive for concave bend.

Rx: float

Sagittal radius of curvature in mm. Positive for concave bend.

ucl:

instance of XRT_CL class, defines the OpenCL device and precision of calculation. Calculations should run fine in single precision, float32. See XRT_CL.

tolerance: float

Precision tolerance for RK adaptive step algorithm.

maxSteps: int

Emergency exit to avoid kernel freezing if the step gets too small.

autoLimits: bool

If True, the algorithm will try to automatically determine the angular range where reflectivity will be calculated by numeric integration. Useful for ray-tracing applications where angle of incidence can be too far from Bragg condition, and integration might take unnesessarily long time.

get_dtheta(E, alpha=None)

The angle correction for the general asymmetric case:

\[\begin{split}\delta\theta = \frac{\mp \gamma_0 \pm \sqrt{\gamma_0^2 \mp (\gamma_0 - \gamma_h) \sqrt{1 - \gamma_0^2} \chi_0 / \sin{2\theta_B}}}{\sqrt{1 - \gamma_0^2}}\\\end{split}\]

where \(\gamma_0 = \sin(\theta_B + \alpha)\), \(\gamma_h = \mp \sin(\theta_B - \alpha)\) and the upper sign is for Bragg and the lower sign is for Laue geometry.

Taken from [Authier] Eq. (8.3). See the comparison between the two expressions (get_dtheta() and get_dtheta_regular()) in Fig. 8.3.

[Authier]

A. Authier, Dynamical theory of X-ray diffraction, Oxford University Press, 2001.

get_dtheta_regular(E, alpha=None)

The angle correction for the general asymmetric case in its simpler version:

\[\begin{split}\delta\theta = (1 - b)/2 \cdot \chi_0 / \sin{2\theta_B}\\ |b| = \sin(\theta_B + \alpha) / \sin(\theta_B - \alpha)\end{split}\]

For the symmetric Bragg b = -1 and for the symmetric Laue b = +1.

get_dtheta_symmetric_Bragg(E)

The angle correction for the symmetric Bragg case:

\[\delta\theta = \chi_0 / \sin{2\theta_B}\]
get_refractive_correction(E, beamInDotNormal=None, alpha=None)

The difference in the glancing angle of incidence for incident and exit waves, Eqs. (2.152) and (2.112) in [Shvydko_XRO]:

\[\theta_c - \theta'_c = \frac{w_H^{(s)}}{2} \left(b - \frac{1}{b} \right) \tan{\theta_c}\]

Note

Not valid close to backscattering.

[Shvydko_XRO]

Yu. Shvyd’ko, X-Ray Optics High-Energy-Resolution Applications, Springer-Verlag Berlin Heidelberg, 2004.

class xrt.backends.raycing.materials.CrystalFcc(Crystal)

FCC crystal. Defines the structure factor as:

\[\begin{split}F_{hkl}^{fcc} = f \times \left\{ \begin{array}{rl} 4 &\mbox{if $h,k,l$ are all even or all odd} \\ 0 &\mbox{ otherwise} \end{array} \right.\end{split}\]
class xrt.backends.raycing.materials.CrystalDiamond(CrystalFcc)

Diamond-like crystal. Defines the structure factor as:

\[F_{hkl}^{\rm diamond} = F_{hkl}^{fcc}\left(1 + e^{i\frac{\pi}{2} (h + k + l)}\right).\]
class xrt.backends.raycing.materials.CrystalSi(CrystalDiamond)

Si crystal with d-spacing as a function of temperature.

__init__(*args, **kwargs)
tK: float

Temperature in Kelvin.

hkl: sequence

hkl indices.

dl_l(t=None)

Calculates the crystal elongation at temperature t. Uses the parameterization from [Swenson]. Less than 1% error; the reference temperature is 19.9C; data is in units of unitless; t must be in degrees Kelvin.

[Swenson]

C.A. Swenson, J. Phys. Chem. Ref. Data 12 (1983) 179

get_Bragg_offset(E, Eref)

Calculates the Bragg angle offset due to a mechanical (mounting) misalignment.

E is the calculated energy of a spectrum feature, typically the edge position.

Eref is the tabulated position of the same feature.

get_a()

Gives the lattice parameter.

class xrt.backends.raycing.materials.CrystalFromCell(Crystal)

Crystal from cell parameters and atomic positions. The crystal data can be found e.g. in Crystals.dat of XOP [XOP] or xraylib. See also predefined crystals in module crystals.

Examples:
>>> xtalQu = rm.CrystalFromCell(
>>>     'alphaQuartz', (1, 0, 2), a=4.91304, c=5.40463, gamma=120,
>>>     atoms=[14]*3 + [8]*6,
>>>     atomsXYZ=[[0.4697, 0., 0.],
>>>               [-0.4697, -0.4697, 1./3],
>>>               [0., 0.4697, 2./3],
>>>               [0.4125, 0.2662, 0.1188],
>>>               [-0.1463, -0.4125, 0.4521],
>>>               [-0.2662, 0.1463, -0.2145],
>>>               [0.1463, -0.2662, -0.1188],
>>>               [-0.4125, -0.1463, 0.2145],
>>>               [0.2662, 0.4125, 0.5479]])
>>>
>>> xtalGr = rm.CrystalFromCell(
>>>     'graphite', (0, 0, 2), a=2.456, c=6.696, gamma=120,
>>>     atoms=[6]*4, atomsXYZ=[[0., 0., 0.], [0., 0., 0.5],
>>>                            [1./3, 2./3, 0.], [2./3, 1./3, 0.5]])
>>>
>>> xtalBe = rm.CrystalFromCell(
>>>     'Be', (0, 0, 2), a=2.287, c=3.583, gamma=120,
>>>     atoms=[4]*2, atomsXYZ=[[1./3, 2./3, 0.25], [2./3, 1./3, 0.75]])
__init__(name='', hkl=[1, 1, 1], a=5.43071, b=None, c=None, alpha=90, beta=90, gamma=90, atoms=[14, 14, 14, 14, 14, 14, 14, 14], atomsXYZ=[[0.0, 0.0, 0.0], [0.0, 0.5, 0.5], [0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.25, 0.25, 0.25], [0.25, 0.75, 0.75], [0.75, 0.25, 0.75], [0.75, 0.75, 0.25]], atomsFraction=None, tK=0, t=None, factDW=1.0, geom='Bragg reflected', table='Chantler total', volumetricDiffraction=False, useTT=False, nu=0, mosaicity=0, **kwargs)
name: str

Crystal name.

hkl: sequence

hkl indices.

a, b, c: float

Cell parameters in Å. a must be given. b, c, if not given, are equlized to a.

alpha, beta, gamma: float

Cell angles in degrees. If not given, are equal to 90.

atoms: list of str or list of int

List of atoms in the cell given by element Z’s or element names.

atomsXYZ: list of 3-sequences

List of atomic coordinates in cell units.

Note

atoms and atomsXYZ must contain all the atoms, not only the unique ones for a given symmetry group (we do not consider symmetry here). For example, the unit cell of magnetite (Fe3O4) has 3 unique atomic positions and 56 in total; here, all 56 are needed.

atomsFraction: a list of float or None

Atomic fractions. If None, all values are 1.

class xrt.backends.raycing.materials.Powder(CrystalFromCell)

Crystal with randomly distributed atomic plane orientations. Serves as a model to polycrystalline powders. The distribution is uniform in the spherical coordinates, so that the angles of longitudinal and transverse deflection (θ and χ) are both functions of uniformly sampled over [0, 1) variables μ and ν: θ = arccos(μ), χ = 2πν.

The class parameter hkl defines the highest reflex, so that reflectivities are calculated for all possible combinations of indices [mnp], where 0 ≤ m ≤ h, 0 ≤ n ≤ k, 0 ≤ p ≤ l, excluding [000]. One reflection is randomly selected for each incident ray, with probability proportional to abs(r_s)**2 + abs(r_p)**2 over the candidate reflections. The selected reflection retains its complex s- and p-polarized amplitudes.

Warning

Heavy computational load. NumPy CPU and OpenCL backends are available; OpenCL is recommended for large beams and reflection ranges.

__init__(*args, **kwargs)
chi: 2-list of floats [min, max]

Limits of the χ angle distribution. Zero and π/2 angles correspond to the positive directions of x and z axes.

class xrt.backends.raycing.materials.CrystalHarmonics(CrystalFromCell)

A derivative class from CrystalFromCell, used to calculate multiple orders of the given reflex in one run: n*[hkl], where 1 ≤ n ≤ Nmax i.e. [111], [222], [333] or [220], [440], [660]. One harmonic is selected for each incident ray by maximizing abs(r_s) + abs(r_p). The selected harmonic retains its complex s- and p-polarized amplitudes. Use this class to estimate the efficiency of higher harmonic rejection schemes.

Warning

NumPy CPU and OpenCL backends are available. OpenCL highly recommended, NumPy backend is substantially slower on large beams or many harmonics.

__init__(*args, **kwargs)
Nmax: int

Specifies the highest order of reflection to be calculated.

class xrt.backends.raycing.materials.MonoCrystal(CrystalFromCell)

Calculates single crystal diffraction (so far cubic symettries only). Similar to the parent class, parameter hkl defines the cut orientation, whereas Nmax stands for the highest index to consider, i.e. for every ray the code would calculate the range of reflexes from [-Nmax, -Nmax, -Nmax] to [Nmax, Nmax, Nmax], excluding [000]. One reflection is randomly selected for each incident ray, with probability proportional to abs(r_s)**2 + abs(r_p)**2 over the candidate reflections. The selected reflection retains its complex s- and p-polarized amplitudes. The search uses two passes for cumulative selection; the second pass selects one reflection per ray.

Warning

Heavy computational load. NumPy CPU and OpenCL backends are available; OpenCL is recommended for large beams and reflection ranges.

__init__(*args, **kwargs)
Nmax: int

Specifies the highest order of reflection to be calculated.

Predefined Materials

The module crystals contains predefined classes for most commonly used crystals. Lattice parameters, atomic positions and references have been semi-automatically parsed from XOP/DABAX [XOP] Crystals.dat. To use a crystal in a script simply import the module and instantiate its class:

import xrt.backends.raycing.materials.crystals as xcryst
myInSbXtal = xcryst.InSb(hkl=(3, 1, 1))  # default hkl=(1, 1, 1)

The crystals inherit from Crystal and can use its methods to calculate diffraction amplitudes, the Darwin width, extinction depth etc.

The following crystal classes are defined in this module (sorted by cell volume in ų), marked in bold are those with available elastic constants:

Be (16.23), Graphite (34.98), Titanium (35.32), Diamond (45.38), Iron (46.31), Copper (47.24), Platinum (60.43), LiF (65.27), Aluminum (66.41), Gold (67.83), LaB6 (71.61), LaB6NIST (71.83), SiC (82.2), AlphaQuartz (113), Si (160.2), GaP (161.9), NaCl (179.4), GaAs (180.7), Ge (181.1), InP (202.1), CsF (216.9), InAs (219.9), GaSb (226.5), KCl (249.2), Sapphire (254.7), AlphaAlumina (254.8), InSb (271.9), LiNbO3 (318.2), PET (324.8), CsCl (345.9), Beryl (657.3), TlAP (855.9), KAP (858.9), RbAP (862.9), KTP (871.3), Muscovite (934.2)