CrystalPotential#

class abtem.potentials.iam.CrystalPotential(potential_unit, repetitions, num_frozen_phonons=None, exit_planes=None, seeds=None)[source]#

Bases: _PotentialBuilder

The crystal potential may be used to represent a potential consisting of a repeating unit. This may allow calculations to be performed with lower computational cost by calculating the potential unit once and repeating it.

If the repeating unit is a potential with frozen phonons it is treated as an ensemble from which each repeating unit along the z-direction is randomly drawn. If num_frozen_phonons an ensemble of crystal potentials are created each with a random seed for choosing potential units.

Parameters:
  • potential_unit (BasePotential) – The potential unit to assemble the crystal potential from.

  • repetitions (three int) – The repetitions of the potential in x, y and z.

  • num_frozen_phonons (int, optional) – Number of frozen phonon configurations assembled from the potential units.

  • exit_planes (int or tuple of int, optional) – The exit_planes argument can be used to calculate thickness series. Providing exit_planes as a tuple of int indicates that the tuple contains the slice indices after which an exit plane is desired, and hence during a multislice simulation a measurement is created. If exit_planes is an integer a measurement will be collected every exit_planes number of slices.

  • seeds (int or sequence of int) – Seed for the random number generator (RNG), or one seed for each RNG in the frozen phonon ensemble.

__init__(potential_unit, repetitions, num_frozen_phonons=None, exit_planes=None, seeds=None)[source]#

Methods

__init__(potential_unit, repetitions[, ...])

build([first_slice, last_slice, max_batch, lazy])

Build the potential.

copy()

Make a copy.

ensemble_blocks([chunks])

Split the ensemble into an array of smaller ensembles.

generate_blocks([chunks])

Generate chunks of the ensemble.

generate_slices([first_slice, last_slice, ...])

Generate the slices for the potential.

match_grid(other[, check_match])

Match the grid to another object with a Grid.

project()

Sum of the potential slices as an image.

select_block(index, chunks)

Select a block from the ensemble.

show([project])

Show the potential projection.

to_images()

Converts the potential to an ensemble of images.

Attributes

axes_metadata

List of AxisMetadata.

base_axes_metadata

List of AxisMetadata for the base axes.

base_shape

Shape of the base axes of the potential.

box

The extent of the potential in x, y and z.

device

The device where the potential is created.

ensemble_axes_metadata

List of AxisMetadata of the ensemble axes.

ensemble_shape

Shape of the ensemble axes.

exit_planes

The "exit planes" of the potential.

exit_thicknesses

The "exit thicknesses" of the potential.

extent

Extent of grid for each dimension in Ångstrom.

gpts

Number of grid points for each dimension.

grid

Simulation grid.

num_configurations

Number of frozen phonons in the ensemble of potentials.

num_exit_planes

Number of exit planes.

num_slices

Number of projected potential slices.

origin

The origin relative to the provided atoms mapped to the origin of the potential.

periodic

Specifies whether the potential is periodic.

plane

The plane relative to the atoms mapped to xy plane of the potential, i.e. the plane is perpendicular to the propagation direction.

potential_unit

reciprocal_space_sampling

Reciprocal-space sampling in reciprocal Ångstrom.

repetitions

sampling

Grid sampling for each dimension in Ångstrom per grid point.

seeds

shape

Shape of the ensemble.

slice_limits

The entrance and exit thicknesses of each slice [Å].

slice_thickness

Slice thicknesses for each slice.

thickness

Thickness of the potential [Å].

property axes_metadata: AxesMetadataList#

List of AxisMetadata.

property base_axes_metadata#

List of AxisMetadata for the base axes.

property base_shape#

Shape of the base axes of the potential.

property box: tuple[float, float, float]#

The extent of the potential in x, y and z.

build(first_slice=0, last_slice=None, max_batch=1, lazy=None)#

Build the potential.

Parameters:
  • first_slice (int, optional) – Index of the first slice of the generated potential.

  • last_slice (int, optional) – Index of the last slice of the generated potential

  • max_batch (int or str, optional) – Maximum number of slices to calculate in task. Default is 1.

  • lazy (bool, optional) – If True, create the wave functions lazily, otherwise, calculate instantly. If None, this defaults to the value set in the configuration file.

Returns:

potential_array – The built potential as an array.

Return type:

PotentialArray

copy()#

Make a copy.

property device: str#

The device where the potential is created.

property ensemble_axes_metadata: list[AxisMetadata]#

List of AxisMetadata of the ensemble axes.

ensemble_blocks(chunks=None)#

Split the ensemble into an array of smaller ensembles.

Parameters:

chunks (iterable of tuples) – Block sizes along each dimension.

Return type:

Array

property ensemble_shape: tuple[int, ...]#

Shape of the ensemble axes.

property exit_planes: tuple[int]#

The “exit planes” of the potential. The indices of slices where a measurement is returned.

property exit_thicknesses: tuple[float]#

The “exit thicknesses” of the potential. The thicknesses in the potential where a measurement is returned.

property extent: tuple[float] | tuple[float, float] | tuple[float, ...]#

Extent of grid for each dimension in Ångstrom.

generate_blocks(chunks=1)#

Generate chunks of the ensemble.

Parameters:

chunks (iterable of tuples) – Block sizes along each dimension.

generate_slices(first_slice=0, last_slice=None, return_depth=False)[source]#

Generate the slices for the potential.

Parameters:
  • first_slice (int, optional) – Index of the first slice of the generated potential.

  • last_slice (int, optional) – Index of the last slice of the generated potential.

  • return_depth (bool) – If True, return the depth of each generated slice.

Yields:

slices (generator of np.ndarray) – Generator for the array of slices.

property gpts: tuple[int] | tuple[int, int] | tuple[int, ...]#

Number of grid points for each dimension.

property grid: Grid#

Simulation grid.

match_grid(other, check_match=False)#

Match the grid to another object with a Grid.

property num_configurations#

Number of frozen phonons in the ensemble of potentials.

property num_exit_planes: int#

Number of exit planes.

property num_slices: int#

Number of projected potential slices.

property origin: tuple[float, float, float]#

The origin relative to the provided atoms mapped to the origin of the potential.

property periodic: bool#

Specifies whether the potential is periodic.

property plane: str#

The plane relative to the atoms mapped to xy plane of the potential, i.e. the plane is perpendicular to the propagation direction.

project()#

Sum of the potential slices as an image.

Returns:

projected – The projected potential.

Return type:

Images

property reciprocal_space_sampling: tuple[float] | tuple[float, float] | tuple[float, ...]#

Reciprocal-space sampling in reciprocal Ångstrom.

property sampling: tuple[float] | tuple[float, float] | tuple[float, ...]#

Grid sampling for each dimension in Ångstrom per grid point.

select_block(index, chunks)#

Select a block from the ensemble.

Parameters:
  • index (tuple of ints) – Index of selected block.

  • chunks (iterable of tuples) – Block sizes along each dimension.

property shape#

Shape of the ensemble.

show(project=True, **kwargs)#

Show the potential projection. This requires building all potential slices.

Parameters:
  • project (bool, optional) – Show the projected potential (True, default) or show all potential slices. It is recommended to index a subset of the potential slices when this keyword set to False.

  • kwargs – Additional keyword arguments for the show method of Images.

property slice_limits: list[tuple[float, float]]#

The entrance and exit thicknesses of each slice [Å].

property slice_thickness: tuple[float, ...]#

Slice thicknesses for each slice.

property thickness: float#

Thickness of the potential [Å].

to_images()#

Converts the potential to an ensemble of images.

Returns:

image_ensemble – The potential slices as images.

Return type:

Images