xoppylib.crystals package
Submodules
xoppylib.crystals.bragg_preprocessor_file_io module
I/O utilities for Bragg crystal preprocessor files (read/write version 1 and 2).
xoppylib.crystals.create_bragg_preprocessor_file_v1 module
Create Bragg preprocessor files version 1 using dabax or xraylib.
- xoppylib.crystals.create_bragg_preprocessor_file_v1.create_bragg_preprocessor_file_v1(interactive=True, DESCRIPTOR='Si', H_MILLER_INDEX=1, K_MILLER_INDEX=1, L_MILLER_INDEX=1, TEMPERATURE_FACTOR=1.0, E_MIN=5000.0, E_MAX=15000.0, E_STEP=100.0, SHADOW_FILE='bragg.dat', material_constants_library=None)[source]
SHADOW preprocessor for crystals - python+xraylib version
xoppylib.crystals.create_bragg_preprocessor_file_v2 module
Create Bragg preprocessor files version 2 using dabax or xraylib.
- xoppylib.crystals.create_bragg_preprocessor_file_v2.create_bragg_preprocessor_file_v2(interactive=True, DESCRIPTOR='Si', H_MILLER_INDEX=1, K_MILLER_INDEX=1, L_MILLER_INDEX=1, TEMPERATURE_FACTOR=1.0, E_MIN=5000.0, E_MAX=15000.0, E_STEP=100.0, SHADOW_FILE='bragg.dat', material_constants_library=None)[source]
SHADOW preprocessor for crystals - python+xraylib version
xoppylib.crystals.mare_calc module
MARE crystal diffraction calculations (structure factors, rocking curves).
- xoppylib.crystals.mare_calc.mare_calc(descriptor, H, K, L, HMAX, KMAX, LMAX, FHEDGE, DISPLAY, lambda1, deltalambda, PHI, DELTAPHI, material_constants_library, verbose=0)[source]
Calculates:
Spaghetti plots (lambda versis Psi for multiple crystal reflection)
The Umweganregung peak location plot (the diffracted wavelength lambda vs. Psi) for a given primary reflection,i.e., an horizontal cut of the spaghetti plot.
The Glitches spectrum (the negative intensity for versus the wavelength) or a vertical cut of the spaghetti plot.
- Psi is the azimutal angle of totation, i.e., the totation around
the H vector (main reflection)
In other words, if a crystal is set with a particular Bragg angle to match a given reflection (inputs: H,K,L) at a given wavelength (input: WaveLength), many other (secondary) reflections are excited when the crystal is rotated around the azimutal angle Psi, without changing the Bragg angle.
The plot (WaveLength,Psi) of the possible reflections is calculated and contains all possible reflection curves up to a maximum reflection (input: H Max, K Max, L Max).
Umweg plot: The intersection of these curves with an horizontal line at the wavelength of the primary reflection (input: WaveLength) gives the position of the peaks in the unweg plot. The width of each peak depends on the pendent of the curve at the intersection. For that, the Psi1 and Psi2 intersection angles with a band of width (input: DeltaWaveLength) are calculated. With this width and the intensity of the diffraction line, it is possible to compute a Gaussian that “roughly” describe the peak.
Glitches plot: The intersection of these curves with a vertical line at a given Psi gives the position of the peaks in the glitches plot. The width of each peak is the difference between the wavelength values for Psi+/-DeltaPsi With this width and the intensity of the diffraction line, it is possible to compute a Gaussian that “roughly” describe the peak.
- Parameters:
descriptor – a valid crystal name for xraylib
H – the miller index H
K – the miller index K
L – the miller index L
HMAX – the maximum miller index H
KMAX – the maximum miller index K
LMAX – the maximum miller index L
FHEDGE – below this edge (structure factor value) the reflections are discarded
DISPLAY – 0: Create spaghetti plot script 0: Create spaghetti+Umweg plot scripts 0: Create spaghetti+Glitches plot scripts 0: Create spaghetti+Umweg+Glitches plot scripts
lambda1 – wavelength in Angstroms for Umweg plot
deltalambda – delta wavelength in Angstroms for Umweg plot
PHI – phi angle in deg for the Glitches plot
DELTAPHI – delta phi angle in deg for the Glitches plot
verbose – set to 1 for a more verbose output
- Returns:
xoppylib.crystals.tools module
Crystal diffraction tools: Bragg metric tensor, structure factors, and related utilities.
- xoppylib.crystals.tools.TemperFactor(sinTheta_lambda, anisos, Miller={'h': 1, 'k': 1, 'l': 1}, cell={'a': 23.44, 'b': 23.44, 'c': 23.44}, n=1936)[source]
Calculation isotropic & anisotropic temerature factors.
- Parameters:
sinTheta_lambda (float) – Sin(theta)/lambda, lambda in units of Angstrom.
anisos (numpy array) – array of dictionary containing anisotropic coefficients.
Miller (dict) – The miller indices, example: {‘h’:1,’k’:1,’l’:1}.
cell (dict) – The cell a,b,c parameters, example: {‘a’:23.44,’b’:23.44,’c’:23.44}
n (int, optional) – number of atomic sites.
- Returns:
output results in a 2-elements list: [[sotropic],[anisotropic]].
- Return type:
list
- xoppylib.crystals.tools.bragg_calc(descriptor='Si', hh=1, kk=1, ll=1, temper=1.0, emin=5000.0, emax=15000.0, estep=100.0, fileout=None, material_constants_library=None, verbose=False)[source]
OBSOLETE…. USE bragg_calc2() INSTEAD! Preprocessor for Structure Factor (FH) calculations. It calculates the basic ingredients of FH.
- Parameters:
descriptor (str, optional) – crystal name (as in xraylib)
hh (int, optional) – miller index H
kk (int, optional) – miller index K
ll (int, optional) – miller index L
temper (float, optional) – temperature factor (scalar <=1.0 )
emin (float, optional) – photon energy minimum in eV
emax (float, optional) – photon energy maximum in eV
estep (float, optional) – photon energy step in eV
fileout (None or str, optional) – name for the output file (default=None, no output file)
material_constants_library (xraylib or instance of DabaxXraylib, optional) – The pointer to the material library to be used to retrieve scattering data.
- Return type:
dict
- xoppylib.crystals.tools.bragg_calc2(descriptor='YB66', hh=1, kk=1, ll=1, temper=1.0, emin=5000.0, emax=15000.0, estep=100.0, ANISO_SEL=0, fileout=None, do_not_prototype=0, material_constants_library=None, verbose=False)[source]
Preprocessor for Structure Factor (FH) calculations. It calculates the basic ingredients of FH.
- Parameters:
descriptor (str, optional) – crystal name (as in xraylib)
hh (int, optional) – miller index H
kk (int, optional) – miller index K
ll (int, optional) – miller index L
temper (float, optional) – temperature factor (scalar <=1.0 )
emin (float, optional) – photon energy minimum in eV
emax (float, optional) – photon energy maximum in eV
estep (float, optional) – photon energy step in eV
ANISO_SEL (int, optional) – 0: Do not use anisotropy. 1: Use anisotropy.
fileout (None or str, optional) – name for the output file (default=None, no output file)
do_not_prototype (int, optional) – for computing the structure factor, 0=sum over site groups (recommended), 1=sum over each individual sites
verbose (int, optional) – Set to 1 for verbose output.
material_constants_library (xraylib or instance of DabaxXraylib, optional) – The pointer to the material library to be used to retrieve scattering data.
- Returns:
a dictionary with all ingredients of the structure factor.
- Return type:
dict
- xoppylib.crystals.tools.bragg_metrictensor(a, b, c, a1, a2, a3, RETURN_REAL_SPACE=0, RETURN_VOLUME=0, HKL=None)[source]
Returns the metric tensor in the reciprocal space.
- Parameters:
a (float) – unit cell a
b (float) – unit cell b
c (float) – unit cell c
a1 (float) – unit cell alpha [in deg]
a2 (float) – unit cell beta [in deg]
a3 (float) – unit cell gamma [in deg]
RETURN_REAL_SPACE (int, optional) – set to 1 for returning metric tensor in real space.
RETURN_VOLUME (int, optional) – set to 1 to return the unit cell volume in Angstroms^3.
HKL (None, or list) – if !=None, returns the d-spacing for the corresponding [H,K,L] reflection.
- Returns:
then retuns the metric tensor in reciprocal space.
- Return type:
The returned value depends on the keywords used. If RETURN_REAL_SPACE=0, RETURN_VOLUME=0, and HKL=None
- xoppylib.crystals.tools.calc_temperature_factor(temperature, crystal='Si', debyeTemperature=644.92, millerIndex=[1, 1, 1], atomicMass=28.09, dSpacing=3.135416288633058, material_constants_library=None)[source]
Calculates the (Debye) temperature factor for single crystals. See [1]_, [2]_.
- Parameters:
temperature (float) – Crystal temperature in Kelvin (positive number).
crystal (str, optional) – Crystal descriptor (e.g. Si, Ge, …).
debyeTemperature (float, optional) – Debye temperature of the crystal material in Kelvin.
millerIndex (list or numpy array, optional) – Miller indexes of the crystal orientation. For use with xraylib only.
atomicMass (float, optional) – Atomic mass of the crystal element (amu unit). if atomicMass == 0, get from xraylib.
dSpacing (float, optional) – dSpacing in Angstroms, given the crystal and millerIndex . if dSpacing == 0, get from xraylib.
material_constants_library (xraylib or instance of DabaxXraylib, optional) – The pointer to the material library to be used to retrieve scattering data.
- Returns:
The temperature factor.
- Return type:
float
References
- xoppylib.crystals.tools.crystal_fh(input_dictionary, phot_in, theta=None, forceratio=0)[source]
Calculates the crystal structure factors.
- Parameters:
input_dictionary (dict) – as resulting from bragg_calc()
phot_in (float, numpy array) – The photon energy in eV
theta (None or float or numpy array.) – The incident angle (half of scattering angle) in rad. If None, it uses the Bragg angle.
forceratio (int, optional) – 0: calculates ratio = numpy.sin(itheta[i]) / (toangstroms / phot) 1: calculates ratio = 1 / (2 * dspacing * 1e8)
- Returns:
a dictionary with structure factor.
- Return type:
dict
- xoppylib.crystals.tools.lorentz(theta_bragg_deg, return_what=0)[source]
This function returns the Lorentz factor, polarization factor (unpolarized beam), geometric factor, or a combination of them.
- Parameters:
theta_bragg_deg (float) – Bragg angle in degrees.
return_what – 0: (default) PolFac*lorentzFac 1: PolFac 2: lorentzFac 3: geomFac
int – 0: (default) PolFac*lorentzFac 1: PolFac 2: lorentzFac 3: geomFac
- Return type:
float
- xoppylib.crystals.tools.mare_calc(descriptor, H, K, L, HMAX, KMAX, LMAX, FHEDGE, DISPLAY, lambda1, deltalambda, PHI, DELTAPHI, material_constants_library=None, verbose=0)[source]
Calculates:
Spaghetti plots (lambda versis Psi for multiple crystal reflection)
The Umweganregung peak location plot (the diffracted wavelength lambda vs. Psi) for a given primary reflection,i.e., an horizontal cut of the spaghetti plot.
The Glitches spectrum (the negative intensity for versus the wavelength) or a vertical cut of the spaghetti plot.
- Psi is the azimutal angle of totation, i.e., the totation around
the H vector (main reflection)
In other words, if a crystal is set with a particular Bragg angle to match a given reflection (inputs: H,K,L) at a given wavelength (input: WaveLength), many other (secondary) reflections are excited when the crystal is rotated around the azimutal angle Psi, without changing the Bragg angle.
The plot (WaveLength,Psi) of the possible reflections is calculated and contains all possible reflection curves up to a maximum reflection (input: H Max, K Max, L Max).
Umweg plot:
The intersection of these curves with an horizontal line at the wavelength of the primary reflection (input: WaveLength) gives the position of the peaks in the unweg plot. The width of each peak depends on the pendent of the curve at the intersection. For that, the Psi1 and Psi2 intersection angles with a band of width (input: DeltaWaveLength) are calculated. With this width and the intensity of the diffraction line, it is possible to compute a Gaussian that “roughly” describe the peak.
Glitches plot:
The intersection of these curves with a vertical line at a given Psi gives the position of the peaks in the glitches plot. The width of each peak is the difference between the wavelength values for Psi+/-DeltaPsi With this width and the intensity of the diffraction line, it is possible to compute a Gaussian that “roughly” describe the peak.
- Parameters:
descriptor (str) – a valid crystal name for xraylib.
H (int) – the miller index H.
K (int) – the miller index K.
L (int) – the miller index L.
HMAX (int) – the maximum miller index H.
KMAX (int) – the maximum miller index K.
LMAX (int) – the maximum miller index L.
FHEDGE (float) – below this edge (structure factor value) the reflections are discarded.
DISPLAY (int) – 0: Create spaghetti plot script 1: Create spaghetti+Umweg plot scripts 2: Create spaghetti+Glitches plot scripts 3: Create spaghetti+Umweg+Glitches plot scripts
lambda1 (float) – wavelength in Angstroms for Umweg plot.
deltalambda (float) – delta wavelength in Angstroms for Umweg plot.
PHI (float) – phi angle in deg for the Glitches plot.
DELTAPHI (float) – delta phi angle in deg for the Glitches plot.
material_constants_library (xraylib or instance of DabaxXraylib, optional) – The pointer to the material library to be used to retrieve scattering data.
verbose (int, optional) – set to 1 for a more verbose output
- Returns:
A script to create the plots.
- Return type:
str
- xoppylib.crystals.tools.run_diff_pat(bragg_dict, preprocessor_file='xcrystal.bra', descriptor='Si', MOSAIC=0, GEOMETRY=0, SCAN=2, UNIT=1, SCANFROM=-100, SCANTO=100, SCANPOINTS=200, ENERGY=8000.0, ASYMMETRY_ANGLE=0.0, THICKNESS=0.7, MOSAIC_FWHM=0.1, RSAG=125.0, RMER=1290.0, ANISOTROPY=0, POISSON=0.22, CUT='2 -1 -1 ; 1 1 1 ; 0 0 0', FILECOMPLIANCE='mycompliance.dat', MILLER_INDEX_H=1, MILLER_INDEX_K=1, MILLER_INDEX_L=1)[source]