abtem.bloch.dynamical#
Module Contents#
Classes#
The BlochWaves class represents a set of Bloch waves. It may be used to calculate the dynamical diffraction patterns. |
|
The StructureFactors class calculates the structure factors for a given set of atoms and parametrization. |
|
The StructureFactorArray class represents structure factors as an ArrayObject. |
Functions#
Check if the string s only contains characters from allowed_chars. |
|
Calculate the M matrix for a given set of reciprocal space vectors. |
|
Calculate the dynamical scattering given a structure matrix. |
|
Calculate the scattering factors for a given set of atoms and parametrization. |
|
Calculate the scattering matrix for a given set of reciprocal space vectors. |
|
Calculate the structure factors for a given set of atoms and parametrization. |
|
Calculate the structure matrix for a given set of reciprocal space vectors. |
|
Calculate the matrix exponential of a given array. |
|
Calculate a plane wave basis for a given set of reciprocal space vectors at a set of real space positions. |
|
Convert 1D structure factors to 3D structure factors. |
|
Calculate the potential from the structure factors. |
|
Check if the provided g_max is valid. If g_max is None, it is set to half the g_max of the structure factor. |
|
Data#
API#
- abtem.bloch.dynamical.AllowedRotations#
None
- class abtem.bloch.dynamical.BaseStructureFactor(...)[source]#
Initialization
- abstract property cell: ase.cell.Cell#
The unit cell.
- abstract get_projected_potential(...) PotentialArray[source]#
Calculate the projected potential from the structure factors.
- class abtem.bloch.dynamical.BlochWaves(...)[source]#
The BlochWaves class represents a set of Bloch waves. It may be used to calculate the dynamical diffraction patterns.
- Parameters:
structure_factor (StructureFactor) – The structure factor.
energy (float or list of float) – Electron energy [eV]. A single float runs a standard single-energy calculation. A list or array of floats runs the calculation at each energy, using a union of the allowed reciprocal-space vectors across all energies; beams that are inactive at a given energy are set to zero. The output gains a leading
EnergyAxisdimension.sg_max (float) – The maximum excitation error [1/Å].
g_max (float) – The maximum scattering vector length [1/Å].
orientation_matrix (ndarray) – An optional orientation matrix given as a (3, 3) array. If provided, the unit cell is rotated. Instead of providing an orientation matrix, the .rotate method can be used.
centering ({'auto', 'P', 'I', 'A', 'B', 'C', 'F'}) – Lattice centering.
device ({'cpu', 'gpu'}) – Device to use for calculations. Can be ‘cpu’ or ‘gpu’.
use_wave_eq (bool) – If True, the Bloch wave equation derived from the wave equation is used. Otherwise standard Bloch wave is used.
Initialization
- calculate_diffraction_patterns(...) IndexedDiffractionPatterns[source]#
Calculate the dynamical diffraction patterns for a given set of thicknesses.
- Parameters:
thicknesses (float or sequence of floats) – The thicknesses of the sample [Å].
return_complex (bool) – If True, the complex diffraction patterns are returned. If False, the intensity is returned. Default is False.
lazy (bool) – If True, the calculation is done lazily using dask. If False, the calculation is done eagerly.
- Returns:
The dynamical diffraction patterns.
- Return type:
- calculate_exit_waves(...) Waves[source]#
Calculate the exit waves for a given set of thicknesses.
- Parameters:
thicknesses (float or sequence of floats) – The thicknesses of the sample [Å].
gpts (tuple of ints) – The grid points of the exit waves.
extent (tuple of floats) – The extent of the exit waves [Å].
normalization ({'values', 'amplitude'}) – The normalization of the exit waves. If ‘values’, the exit waves are
lazy (bool) – If True, the calculation is done lazily using dask. If False, the calculation is done eagerly.
- Returns:
The exit waves.
- Return type:
- calculate_scattering_matrix(...) ndarray[source]#
Calculate the scattering matrix for a given thickness.
- calculate_structure_matrix(...) ndarray[source]#
Calculate the structure matrix.
- Parameters:
lazy (bool) – If True, the calculation is done lazily using dask. If False, the calculation is done eagerly.
- property cell: ase.cell.Cell#
- get_kinematical_diffraction_pattern(...) IndexedDiffractionPatterns[source]#
Calculate the kinematical diffraction pattern.
- Parameters:
excitation_error_sigma (float) – The standard deviation of the excitation errors used for weigting the structure factor intensities [1/Å].
- Returns:
The kinematical diffraction pattern.
- Return type:
- rotate(...) BlochWaves | BlochwaveEnsemble[source]#
Rotate the unit cell by a given set of Euler angles.
- Parameters:
- Returns:
BlochWaves – The rotated Bloch waves.
BlochWavesEnsemble – The rotated Bloch waves ensemble.
- property structure_factor: BaseStructureFactor#
- class abtem.bloch.dynamical.BlochwaveEnsemble(...)[source]#
Bases:
abtem.core.ensemble.Ensemble,abtem.core.utils.CopyMixinInitialization
- calculate_diffraction_patterns(...) IndexedDiffractionPatterns[source]#
Calculate the dynamical diffraction patterns of the ensemble for a given set of thicknesses.
- Parameters:
thicknesses (float or sequence of floats) – The thicknesses of the sample [Å].
return_complex (bool) – If True, the complex diffraction patterns are returned. If False, the intensity is returned. Default is False.
lazy (bool) – If True, the calculation is done lazily using dask. If False, the calculation is done eagerly.
pbar (bool) – If True, a progress bar is shown. Default is None, which means the value is taken from the configuration.
- Returns:
The diffraction patterns.
- Return type:
- calculate_exit_waves(...) Waves[source]#
Calculate the exit waves for the ensemble for a given set of thicknesses.
- Parameters:
thicknesses (float or sequence of floats) – The thicknesses of the sample [Å].
gpts (tuple of ints, optional) – The grid points of the exit waves.
extent (tuple of floats, optional) – The extent of the exit waves [Å].
normalization ({'values', 'amplitude'}) – The normalization of the exit waves.
g_max (float, optional) – Maximum scattering vector length for the plane wave expansion [1/Å].
lazy (bool) – If True, the calculation is done lazily using dask. If False, the calculation is done eagerly.
pbar (bool, optional) – If True, a progress bar is shown. Default is None, which means the value is taken from the configuration.
- Returns:
The exit waves.
- Return type:
- property ensemble_axes_metadata: list[AxisMetadata]#
- get_ensemble_hkl_mask() ndarray[source]#
Get the mask selecting all the reciprocal space vectors included in the ensemble.
- Returns:
The mask selecting the reciprocal space vectors.
- Return type:
- get_orientation_matrices() ndarray[source]#
Get the orientation matrices for the ensemble.
- Returns:
The orientation matrices. The shape is the ensemble shape + (3, 3).
- Return type:
- property rotations: tuple[BaseDistribution | Number, ...]#
- property structure_factor: BaseStructureFactor#
- class abtem.bloch.dynamical.StructureFactor(...)[source]#
Bases:
abtem.bloch.dynamical.BaseStructureFactor,abtem.core.utils.CopyMixinThe StructureFactors class calculates the structure factors for a given set of atoms and parametrization.
- Parameters:
atoms (Atoms) – Atoms object.
g_max (float) – Maximum scattering vector length [1/Å].
parametrization (str) – Parametrization for the scattering factors.
thermal_sigma (float or dict) – Standard deviation of the atomic displacements for the Debye-Waller factor [Å].
occupancy (float) – The occupancy of the atoms.
cutoff ({'taper', 'hard'}) – Cutoff function for the scattering factors. ‘taper’ is a smooth cutoff, ‘hard’ is a hard cutoff.
device ({'cpu', 'gpu'}) – Device to use for calculations. Can be ‘cpu’ or ‘gpu’.
centering ({'auto', 'P', 'I', 'A', 'B', 'C', 'F'}) – Lattice centering.
Initialization
- property atoms: ase.Atoms#
- build(...) StructureFactorArray[source]#
Calculate the structure factors to obtain a StructureFactorArray object.
- Parameters:
lazy (bool) – If True, the calculation is done lazily using dask. If False, the calculation is done eagerly.
- Returns:
The structure factors.
- Return type:
- calculate_scattering_factors() ndarray[source]#
Calculate the scattering factors for each atomic species in the structure.
- property cell: ase.cell.Cell#
- get_projected_potential(...) PotentialArray[source]#
Calculate the projected potential from the structure factors.
- Parameters:
slice_thickness (float or sequence of floats) – The thickness of the slices.
sampling (float or tuple of floats) – The sampling of the projected potential [Å].
gpts (int or tuple of ints) – The grid points of the projected potential.
lazy (bool) – If True, the calculation is done lazily using dask. If False, the calculation is done eagerly.
- Returns:
The projected potential.
- Return type:
- property parametrization: Parametrization#
- class abtem.bloch.dynamical.StructureFactorArray(...)[source]#
Bases:
abtem.array.ArrayObject,abtem.bloch.dynamical.BaseStructureFactorThe StructureFactorArray class represents structure factors as an ArrayObject.
- Parameters:
array (ndarray) – The structure factors as a 1D array.
hkl (ndarray) – The reciprocal space vectors as Miller indices as a (N, 3) array. N must be the same as the length of the structure factor.
cell (Cell) – The unit cell.
g_max (float) – Maximum scattering vector length [1/Å].
ensemble_axes_metadata (list of AxisMetadata) – Metadata for the ensemble axes.
metadata (dict) – Metadata for the ArrayObject.
Initialization
- property cell: ase.cell.Cell#
- abstract classmethod from_array_and_metadata(...) StructureFactorArray[source]#
- get_potential_3d() ndarray[source]#
Calculate the 3D potential from the structure factors.
- Returns:
The 3D potential.
- Return type:
- get_projected_potential(...) PotentialArray[source]#
Calculate the projected potential from the structure factors.
- Parameters:
slice_thickness (float or sequence of floats) – The thickness of the slices.
sampling (float or tuple of floats) – The sampling of the projected potential [Å].
gpts (int or tuple of ints) – The grid points of the projected potential.
lazy (bool) –
- If True, the calculation is done lazily using dask. If False, the
calculation is done eagerly.
- Returns:
The projected potential.
- Return type:
- property gpts: tuple[int, int, int]#
Number of reciprocal space grid points for 3D structure factors.
- abtem.bloch.dynamical.allowed_chars(...) bool[source]#
Check if the string s only contains characters from allowed_chars.
- abtem.bloch.dynamical.calculate_M_matrix(...) ndarray[source]#
Calculate the M matrix for a given set of reciprocal space vectors.
- abtem.bloch.dynamical.calculate_dynamical_scattering(...) ndarray[source]#
Calculate the dynamical scattering given a structure matrix.
- Parameters:
structure_matrix (ndarray) – The structure matrix as a (N, N) array.
hkl (ndarray) – The reciprocal space vectors as Miller indices. Given as a (N, 3) array.
cell (Cell) – The unit cell.
energy (float) – The energy of the electrons [eV].
thicknesses (sequence of floats) – The thicknesses of the sample [Å].
- Returns:
The dynamical scattering as a complex array with shape (len(thicknesses), len(hkl)).
- Return type:
- abtem.bloch.dynamical.calculate_scattering_factors(...) ndarray[source]#
Calculate the scattering factors for a given set of atoms and parametrization.
- Parameters:
g_vec (ndarray) – Scattering vectors [1/Å]. Either Cartesian vectors with shape (N_g, 3), or plain magnitudes with shape (N_g,). Anisotropic Debye-Waller factors require shape (N_g, 3); passing magnitudes with anisotropic sigmas raises an error.
atoms (Atoms) – Atoms object.
g_max (float) – Maximum scattering vector length [1/Å]. The scattering factors are set to zero for g > g_max.
parametrization ({'lobato', 'kirkland', 'peng'}) – Parametrization for the scattering factors.
thermal_sigma (dict) – Standard deviation of the atomic displacements for the Debye-Waller factor [Å]. For anisotropic displacements, provide three values per atom or element (σx, σy, σz).
cutoff ({'taper', 'hard'}) – Cutoff function for the scattering factors. ‘taper’ is a smooth cutoff, ‘hard’ is a hard cutoff.
- abtem.bloch.dynamical.calculate_scattering_matrix(...) ndarray[source]#
Calculate the scattering matrix for a given set of reciprocal space vectors.
- Parameters:
A (ndarray) – The structure matrix. The last two dimensions must be square.
hkl (ndarray) – The reciprocal space vectors as Miller indices. Given as a (N, 3) array.
cell (Cell) – The unit cell.
z (float) – The thickness of the sample [Å].
energy (float) – The energy of the electrons [eV].
method ({'expm', 'decomposition'}) –
- The method to use for calculating the scattering matrix.
expm:Use a matrix exponential.
decomposition:Use a Hermitian matrix eigendecomposition.
- Returns:
The scattering matrix.
- Return type:
- abtem.bloch.dynamical.calculate_structure_factors(...) ndarray[source]#
Calculate the structure factors for a given set of atoms and parametrization.
- Parameters:
hkl (ndarray) – The reciprocal space vectors as Miller indices. Given as a (N, 3) array.
atoms (Atoms) – The Atoms object.
parametrization ({'lobato', 'kirkland', 'peng'}) – Parametrization for the scattering factors.
g_max (float) – Maximum scattering vector length [1/Å]. The scattering factors are set to zero for g > g_max.
thermal_sigma (float) – Standard deviation of the atomic displacements for the Debye-Waller factor [Å].
cutoff ({'taper', 'hard'}) – Cutoff function for the scattering factors. ‘taper’ is a smooth cutoff, ‘hard’ is a hard cutoff.
device ({'cpu', 'gpu'}) – Device to use for calculations. Can be ‘cpu’ or ‘gpu’.
- Returns:
The structure factors.
- Return type:
- abtem.bloch.dynamical.calculate_structure_matrix(...) ndarray[source]#
Calculate the structure matrix for a given set of reciprocal space vectors.
- Parameters:
structure_factor (ndarray) – The structure factors as a 1D array.
hkl (ndarray) – The reciprocal space vectors as Miller indices corresponding to the structure factors. Given as a (N, 3) array.
hkl_selected (ndarray) – The reciprocal space vectors as Miller indices for which the structure matrix is calculated. Given as a (N, 3) array.
cell (Cell) – The unit cell.
energy (float) – The energy of the electrons [eV].
gpts (tuple of ints) – The number of grid points in the 3D structure factor.
use_wave_eq (bool) – If True, the Bloch wave equation derived from the wave equation is used. Otherwise standard Bloch wave is used.
- Returns:
The structure matrix.
- Return type:
- abtem.bloch.dynamical.equal_slice_thicknesses(...) tuple[tuple[float, ...], tuple[int, ...]][source]#
- abtem.bloch.dynamical.expm(...) ndarray[source]#
Calculate the matrix exponential of a given array.
This is a device agnostic version of the scipy.linalg.expm function.
- abtem.bloch.dynamical.is_base_distribution_tuple(...) TypeGuard[tuple[BaseDistribution, ...]][source]#
- abtem.bloch.dynamical.is_valid_rotations(...) TypeGuard[tuple[abtem.bloch.dynamical.AllowedRotations, ...]][source]#
- abtem.bloch.dynamical.plane_wave_basis(...) ndarray[source]#
Calculate a plane wave basis for a given set of reciprocal space vectors at a set of real space positions.
- Parameters:
- Returns:
The plane wave basis at the given positions.
- Return type:
- abtem.bloch.dynamical.structure_factor_1d_to_3d(...) ndarray[source]#
Convert 1D structure factors to 3D structure factors.
- Parameters:
- Returns:
The 3D structure factors.
- Return type:
- abtem.bloch.dynamical.structure_factor_to_potential(...) ndarray[source]#
Calculate the potential from the structure factors.
- Parameters:
- Returns:
The potential.
- Return type:
- abtem.bloch.dynamical.validate_g_max(...) float[source]#
Check if the provided g_max is valid. If g_max is None, it is set to half the g_max of the structure factor.
- Parameters:
g_max (float) – The maximum scattering vector length [1/Å].
structure_factor (BaseStructureFactor) – The structure factor.
- Returns:
The validated g_max.
- Return type: