PlaneWave#

class abtem.waves.PlaneWave(extent=None, gpts=None, sampling=None, energy=None, normalize=False, tilt=(0.0, 0.0), device=None)[source]#

Bases: WavesBuilder

Represents electron probe wave functions for simulating experiments with a plane- wave probe, such as HRTEM and SAED.

Parameters:
  • extent (two float, optional) – Lateral extent of the wave function [Å].

  • gpts (two int, optional) – Number of grid points describing the wave function.

  • sampling (two float, optional) – Lateral sampling of the wave functions [Å]. If ‘gpts’ is also given, will be ignored.

  • energy (float, optional) – Electron energy [eV]. If not provided, inferred from the wave functions.

  • normalize (bool, optional) – If true, normalizes the wave function such that its reciprocal space intensity sums to one. If false, the wave function takes a value of one everywhere.

  • tilt (two float, optional) – Small-angle beam tilt [mrad] (default is (0., 0.)). Implemented by shifting the wave functions at every slice.

  • device (str, optional) – The wave functions are stored on this device (‘cpu’ or ‘gpu’). The default is determined by the user configuration.

__init__(extent=None, gpts=None, sampling=None, energy=None, normalize=False, tilt=(0.0, 0.0), device=None)[source]#

Methods

__init__([extent, gpts, sampling, energy, ...])

apply_transform(transform[, max_batch, lazy])

build([lazy, max_batch])

Build plane-wave wave functions.

check_can_build()

Check whether the wave functions can be built.

copy()

Make a copy.

ensemble_blocks([chunks])

Split the ensemble into an array of smaller ensembles.

generate_blocks([chunks])

Generate chunks of the ensemble.

match_grid(other[, check_match])

Match the grid to another object with a Grid.

multislice(potential[, detectors, ...])

Run the multislice algorithm, after building the plane-wave wave function as needed.

Attributes

accelerator

Accelerator object describing the acceleration energy.

angular_sampling

Reciprocal-space sampling in units of scattering angles [mrad].

antialias_cutoff_gpts

The number of grid points along the x and y direction in the simulation grid at the antialiasing cutoff scattering angle.

antialias_valid_gpts

The number of grid points along the x and y direction in the simulation grid for the largest rectangle that fits within antialiasing cutoff scattering angle.

axes_metadata

List of AxisMetadata.

base_axes_metadata

List of AxisMetadata for the base axes in real space.

base_shape

Shape of the base axes of the waves.

cutoff_angles

Scattering angles at the antialias cutoff [mrad].

cutoff_frequencies

Spatial frequencies at the antialias cutoff [1/Å].

device

The device where the waves are created.

dtype

The datatype of waves.

energy

Electron acceleration energy in electron volts.

ensemble_axes_metadata

List of AxisMetadata of the ensemble axes.

ensemble_shape

Shape of the ensemble axes of the waves.

extent

Extent of grid for each dimension in Ångstrom.

full_cutoff_angles

Scattering angles corresponding to the full wave function size [mrad].

gpts

Number of grid points for each dimension.

grid

Simulation grid.

metadata

Metadata stored as a dictionary.

normalize

True if the created waves are normalized in reciprocal space.

reciprocal_space_axes_metadata

List of AxisMetadata for base axes in reciprocal space.

reciprocal_space_sampling

Reciprocal-space sampling in reciprocal Ångstrom.

rectangle_cutoff_angles

Scattering angles corresponding to the sides of the largest rectangle within the antialias cutoff [mrad].

sampling

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

shape

Shape of the waves.

tilt

The small-angle tilt of applied to the Fresnel propagator [mrad].

wavelength

Relativistic wavelength in Ångstrom.

property accelerator: Accelerator#

Accelerator object describing the acceleration energy.

property angular_sampling: tuple[float, float]#

Reciprocal-space sampling in units of scattering angles [mrad].

property antialias_cutoff_gpts: tuple[int, int]#

The number of grid points along the x and y direction in the simulation grid at the antialiasing cutoff scattering angle.

property antialias_valid_gpts: tuple[int, int]#

The number of grid points along the x and y direction in the simulation grid for the largest rectangle that fits within antialiasing cutoff scattering angle.

property axes_metadata: AxesMetadataList#

List of AxisMetadata.

property base_axes_metadata: list[AxisMetadata]#

List of AxisMetadata for the base axes in real space.

property base_shape: tuple[int, int]#

Shape of the base axes of the waves.

build(lazy=None, max_batch='auto')[source]#

Build plane-wave wave functions.

Parameters:
  • lazy (bool, optional) – If True, create the wave functions lazily, otherwise, calculate instantly. If not given, defaults to the setting in the user configuration file.

  • max_batch (int or str, optional) – The number of wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is automatically chosen based on the abtem user configuration settings “dask.chunk-size” and “dask.chunk-size-gpu”.

Returns:

plane_waves – The wave functions.

Return type:

Waves

check_can_build()#

Check whether the wave functions can be built.

copy()#

Make a copy.

Return type:

Self

property cutoff_angles: tuple[float, float]#

Scattering angles at the antialias cutoff [mrad].

property cutoff_frequencies: tuple[float, float]#

Spatial frequencies at the antialias cutoff [1/Å].

property device: str#

The device where the waves are created.

property dtype: dtype#

The datatype of waves.

property energy: float | None#

Electron acceleration energy in electron volts.

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#

Shape of the ensemble axes of the waves.

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

Extent of grid for each dimension in Ångstrom.

property full_cutoff_angles: tuple[float, float]#

Scattering angles corresponding to the full wave function size [mrad].

generate_blocks(chunks=1)#

Generate chunks of the ensemble.

Parameters:

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

Return type:

Generator[tuple[tuple[int, ...], tuple[slice, ...], ndarray], None, None]

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

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 metadata#

Metadata stored as a dictionary.

multislice(potential, detectors=None, max_batch='auto', lazy=None)[source]#

Run the multislice algorithm, after building the plane-wave wave function as needed. The grid of the wave functions will be set to the grid of the potential.

Parameters:
  • potential (BasePotential, Atoms) – The potential through which to propagate the wave function. Optionally atoms can be directly given.

  • detectors (Detector, list of detectors, optional) – A detector or a list of detectors defining how the wave functions should be converted to measurements after running the multislice algorithm.

  • max_batch (int, optional) – The number of wave functions in each chunk of the Dask array. If ‘auto’ (default), the batch size is automatically chosen based on the abtem user configuration settings “dask.chunk-size” and “dask.chunk-size-gpu”.

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

Return type:

Union[BaseMeasurements, Waves, list[Union[BaseMeasurements, Waves]]]

Returns:

  • measurements (BaseMeasurements or ComputableList of BaseMeasurement) – The detected measurement (if detector(s) given).

  • exit_waves (Waves) – Wave functions at the exit plane(s) of the potential (if no detector(s) given).

property normalize#

True if the created waves are normalized in reciprocal space.

property reciprocal_space_axes_metadata: list[AxisMetadata]#

List of AxisMetadata for base axes in reciprocal space.

property reciprocal_space_sampling: tuple[float, float]#

Reciprocal-space sampling in reciprocal Ångstrom.

property rectangle_cutoff_angles: tuple[float, float]#

Scattering angles corresponding to the sides of the largest rectangle within the antialias cutoff [mrad].

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

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

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

Shape of the waves.

property tilt#

The small-angle tilt of applied to the Fresnel propagator [mrad].

property wavelength: float#

Relativistic wavelength in Ångstrom.