abtem.slicing#
Module for slicing atoms for the multislice algorithm.
Module Contents#
Classes#
Base class for sliced atoms used for grouping each atom in an ASE atoms object into a collection of slices along the z-direction. |
|
Sliced atoms assigning each atom to a specific slice index. |
|
Sliced atoms assigning each atom to multiple slices. |
Functions#
Find grid points such that the sampling grid is commensurate with the atom positions in x and y, closest to a target sampling. |
|
Find slice thicknesses commensurate with the crystal planes, closest to a target thickness. |
|
Calculates slice thicknesses to match the spacing between the crystal planes of a given collection of atoms. |
|
Check if the value is a number, including a NumPy array with a single element, an integer, or a float. |
|
The entrance and exit thicknesses of each slice [Å]. |
API#
- class abtem.slicing.BaseSlicedAtoms(...)[source]#
Bases:
abtem.core.utils.EqualityMixinBase class for sliced atoms used for grouping each atom in an ASE atoms object into a collection of slices along the z-direction.
- Parameters:
atoms (Atoms) – The atoms to be sliced. Must have an orthgonal cell.
slice_thickness (float or sequence of float, optional) – Thickness of the potential slices in the propagation direction in [Å] (default is 0.5 Å). If given as a float, the number of slices is calculated by dividing the slice thickness into the z-height of supercell. The slice thickness may be given as a sequence of values for each slice, in which case an error will be thrown if the sum of slice thicknesses is not equal to the height of the atoms.
Initialization
- property atoms: ase.Atoms#
The Atoms before slicing.
- generate_atoms_in_slices(...)[source]#
Generate atoms in slices.
- Parameters:
- Yields:
atoms (Atoms) – The atoms in each slice.
- class abtem.slicing.SliceIndexedAtoms(...)[source]#
Bases:
abtem.slicing.BaseSlicedAtomsSliced atoms assigning each atom to a specific slice index.
- Parameters:
atoms (Atoms) – The atoms to be sliced. Must have an orthgonal cell.
slice_thickness (float or sequence of float, optional) – Thickness of the potential slices in the propagation direction in [Å] (default is 0.5 Å). If given as a float, the number of slices is calculated by dividing the slice thickness into the z-height of supercell. The slice thickness may be given as a sequence of values for each slice, in which case an error will be thrown if the sum of slice thicknesses is not equal to the height of the atoms.
Initialization
- class abtem.slicing.SlicedAtoms(...)[source]#
Bases:
abtem.slicing.BaseSlicedAtomsSliced atoms assigning each atom to multiple slices.
- Parameters:
atoms (Atoms) – The atoms to be sliced. Must have an orthgonal cell.
slice_thickness (float or sequence of float, optional) – Thickness of the potential slices in the propagation direction in [Å] (default is 0.5 Å). If given as a float, the number of slices is calculated by dividing the slice thickness into the z-height of supercell. The slice thickness may be given as a sequence of values for each slice, in which case an error will be thrown if the sum of slice thicknesses is not equal to the height of the atoms.
xy_padding (float, optional) – Padding of the atoms in x and y included in each of the slices [Å].
z_padding (float, optional) – Padding of the atoms along z in each slice included in the slices [Å].
Initialization
- abtem.slicing.commensurate_gpts(...) tuple[int, int][source]#
Find grid points such that the sampling grid is commensurate with the atom positions in x and y, closest to a target sampling.
For each axis the function identifies the unique atom planes and computes the GCD of the spacings between them. This gives the primitive lattice spacing and therefore the required grid period p (= number of grid points per unit cell of the primitive lattice). The result is invariant under rigid translations of the structure: a crystal that has been centered or otherwise shifted within the cell always yields the same p as the unshifted version.
When round_to_fast_fft is enabled the number of grid points additionally factorizes completely into the primes 2, 3, 5 and 7 whenever that is compatible with commensurability, so FFTs run on fast radix kernels instead of the slow, memory-hungry Bluestein fallback. The multiple of p nearest the target sampling is kept when it is already such a length, and otherwise the next one up – so enabling this never coarsens the grid. If p itself contains a prime factor larger than 7 no multiple of it can be fast, and commensurability takes precedence.
Structures whose internal parameters are irrational (rutile, brookite) have no commensurate grid at all. For those, round_to_fast_fft additionally selects among fast sizes within a few percent of the target the one whose grid the atom planes come closest to sitting on, subject to keeping the grid a multiple of the plane set’s translational period – without which symmetry-equivalent atoms in different unit cells would discretise differently. This is the only case in which the returned grid is not the one closest to target_sampling.
- Parameters:
positions (ndarray) – Atom positions with shape (N, 3) or (N, 2).
target_sampling (float) – Target grid sampling [Å].
tolerance (float) – Tolerance for identifying distinct atom planes [Å].
round_to_fast_fft (bool) – If True (default), prefer grids that are also fast FFT sizes (all prime factors in {2, 3, 5, 7}). The realized sampling is then never coarser than commensurability alone would give, and at most a few percent finer. Setting this to False reproduces the plain commensurate grid exactly, including for the incommensurate structures above, which then simply take the target size.
- Returns:
Number of grid points in x and y.
- Return type:
- abtem.slicing.commensurate_slice_thickness(...) tuple[float, ...][source]#
Find slice thicknesses commensurate with the crystal planes, closest to a target thickness.
Unique z-positions (within tolerance) define candidate slice boundaries between 0 and the cell height. Adjacent plane-level slices are merged so that each resulting slice thickness is as close as possible to target_thickness while keeping boundaries aligned with atomic planes.
- abtem.slicing.crystal_slice_thicknesses(...) ndarray[source]#
Calculates slice thicknesses to match the spacing between the crystal planes of a given collection of atoms.
- Parameters:
atoms (Atoms) – The atoms to be sliced. Must have an orthogonal cell.
tolerance (float, optional) – The tolerance between atomic positions in the z-direction