abtem.multislice#
Module for running the multislice algorithm.
Module Contents#
Classes#
Multislice algorithm computed fast in Fourier space. |
|
The Fresnel propagator is used for propagating wave functions using the near-field approximation (Fresnel diffraction). |
|
Transformation applying the multislice algorithm to wave functions, producing new wave functions or measurements. |
|
Multislice algorithm computed in real-space. |
Functions#
Allocate a measurement matching the given wave functions and detector. |
|
Allocate the multislice measurements that would be produced by detecting the given set of wave functions with the given set of detectors. |
|
Calculate one step of the multislice algorithm for the given batch of wave functions through a given potential slice. |
|
Generator that yields (current, next) items from an iterable. The last item is yielded as (last, None). |
|
Calculate the full multislice algorithm for the given batch of wave functions through a given potential, detecting at each of the exit planes specified in the potential. |
|
Calculate the full multislice algorithm for the given batch of wave functions through a given potential, detecting at each of the exit planes specified in the potential. |
API#
- class abtem.multislice.FourierMultislice[source]#
Multislice algorithm computed fast in Fourier space.
- Parameters:
order (int, optional) – Propagator order, one of 1, 2, or ‘exact’ (default ‘exact’)
expansion_scope (str) – Specified for compatibility. Must be “propagator” (default “propagator”)
conjugate (bool, optional) – If True, use the conjugate of the transmission function (default is False)
transpose (bool, optional) – If True, reverse the order of propagation and transmission (default is False)
- class abtem.multislice.FresnelPropagator[source]#
The Fresnel propagator is used for propagating wave functions using the near-field approximation (Fresnel diffraction).
Initialization
- get_array(...) ndarray[source]#
Get the Fresnel propagator as an array for the given wave functions and thickness.
- class abtem.multislice.MultisliceTransform(...)[source]#
Bases:
abtem.transform.WavesTransform[abtem.measurements.BaseMeasurements]Transformation applying the multislice algorithm to wave functions, producing new wave functions or measurements.
- Parameters:
potential (BasePotential) – A potential as
BasePotentialobject.detectors ((list of) BaseDetector, optional) – A detector or a list of detectors defining how the wave functions should be converted to measurements after running the multislice algorithm.
multislice_func (callable, optional) – The multislice function defining the multislice algorithm used (default is
multislice_and_detect()).**multislice_func_kwargs – Additional keyword arguments passed to the multislice function.
Initialization
- apply(...) Waves | BaseMeasurements | list[Waves | BaseMeasurements][source]#
Run the multislice algorithm on the given wave functions. An output is returned for each detector.
- Parameters:
- Returns:
waves – The wave functions after running the multislice algorithm.
- Return type:
tuple of Waves and BaseMeasurements
- property detectors: list[BaseDetector]#
List of detectors defining how the wave functions should be converted to measurements.
- property ensemble_axes_metadata#
- property ensemble_shape#
- property potential: BasePotential#
Electrostatic potential for each multislice slice.
- class abtem.multislice.RealSpaceMultislice[source]#
Multislice algorithm computed in real-space.
- Parameters:
order (int, optional) – Propagator and/or transmission operator order (default 1)
expansion_scope (str) – If “propagator” (default) only the propagator operator is expanded to order If “full” both the propagator and transmission operators are expanded to order
derivative_accuracy (int, optional) – Finite-difference accuracy for Laplace operator (default 6)
max_terms (int, optional) – Max terms in exponent Taylor series expansion (default 80)
- abtem.multislice.allocate_measurement(...) BaseMeasurements | Waves[source]#
Allocate a measurement matching the given wave functions and detector.
- Parameters:
waves (BaseWaves) – The wave functions to derive the allocated measurement from.
detector (BaseDetector) – The detector to derive the allocated measurement from.
extra_ensemble_axes_shape (tuple of int, optional) – The shape of additional ensemble axes not in the waves.
extra_ensemble_axes_metadata (list of AxisMetadata) – The axes metadata of additional ensemble axes not in the waves.
- Returns:
allocated_measurement – The allocated measurement
- Return type:
- abtem.multislice.allocate_multislice_measurements(...) list[BaseMeasurements | Waves][source]#
Allocate the multislice measurements that would be produced by detecting the given set of wave functions with the given set of detectors.
- Parameters:
waves (Waves) – The waves to derive the allocated measurement from.
detectors (list of BaseDetector) – The detectors to derive the allocated measurement from.
extra_ensemble_axes_shape (tuple of int, optional) – The shape of additional ensemble axes not in the waves.
extra_ensemble_axes_metadata (list of AxisMetadata) – The axes metadata of additional ensemble axes not in the waves.
- Returns:
allocated_measurements – List of allocated to measurements.
- Return type:
- abtem.multislice.conventional_multislice_step(...) Waves[source]#
Calculate one step of the multislice algorithm for the given batch of wave functions through a given potential slice.
- Parameters:
waves (Waves) – A batch of wave functions as a
Wavesobject.potential_slice (PotentialArray or TransmissionFunction) – A potential slice as a
PotentialArrayorTransmissionFunction.propagator (FresnelPropagator, optional) – A Fresnel propagator type matching the wave functions. The main reason for using this argument is to reuse a previously calculated propagator. If not provided a new propagator is created.
antialias_aperture (AntialiasAperture, optional) – An antialias aperture type matching the wave functions. The main reason for using this argument is to reuse a previously calculated antialias aperture. If not provided a new antialias aperture is created.
conjugate (bool, optional) – If True, use the conjugate of the transmission function (default is False).
transpose (bool, optional) – If True, reverse the order of propagation and transmission (default is False).
- Returns:
forward_stepped_waves – Wave functions propagated and transmitted through the potential slice.
- Return type:
- abtem.multislice.is_waves_base_measurements_or_list(...) TypeGuard[Waves | BaseMeasurements | list[Waves | BaseMeasurements]][source]#
- abtem.multislice.lookahead(...)[source]#
Generator that yields (current, next) items from an iterable. The last item is yielded as (last, None).
- abtem.multislice.multislice_and_detect(...) BaseMeasurements | Waves | list[BaseMeasurements | Waves][source]#
Calculate the full multislice algorithm for the given batch of wave functions through a given potential, detecting at each of the exit planes specified in the potential.
The potential is consumed in chunks of contiguous slices. For an unbuilt
Potential, each chunk is eagerly computed into memory, the wave functions are propagated through those slices, and the chunk is discarded before the next one is built. This keeps peak memory bounded — previously,build()placed the entire slice dimension into a single dask chunk, so the full potential had to fit in memory (or VRAM) at once.On GPU, where dask uses a synchronous scheduler and the full dask chunk is materialized at once, this chunking is critical for simulations whose potential exceeds available VRAM.
When the potential is already a pre-built
PotentialArray(eager or dask-backed), the chunks are views into the existing array and the memory savings only apply if an unbuiltPotentialis passed instead.- Parameters:
waves (Waves) – A batch of wave functions as a
Wavesobject.potential (BasePotential) – A potential as
BasePotentialobject. Pass an unbuiltPotentialto benefit from memory-bounded slice chunking. A pre-builtPotentialArrayis also supported but its full data is already in memory, so chunking only controls iteration grouping.detectors ((list of) BaseDetector, optional) – A detector or a list of detectors defining how the wave functions should be converted to measurements after running the multislice algorithm.
algorithm (FourierMultislice or RealSpaceMultislice, optional) – Algorithm used for multislice operator (default is FourierMultislice()).
return_backscattered (bool, optional) – If algorithm.expansion_scope=”full” and return_backscatter is True, then the backscattered components are also returned. Requires potential exit_planes.
pbar (bool, optional) – If True, display a progress bar.
potential_chunk_size (int or str, optional) – Number of potential slices to eagerly build and hold in memory at once during propagation.
"auto"(default) selects based on the configured memory budget (dask.chunk-size/dask.chunk-size-gpu). Can also be set globally via thepotential.slice-chunk-sizeconfiguration key.
- abtem.multislice.transition_potential_multislice_and_detect(...) list[BaseMeasurements | Waves] | BaseMeasurements | Waves[source]#
Calculate the full multislice algorithm for the given batch of wave functions through a given potential, detecting at each of the exit planes specified in the potential.
- Parameters:
waves (Waves) – A batch of wave functions as a
Wavesobject.potential (BasePotential) – A potential as
BasePotentialobject.detectors ((list of) BaseDetector, optional) – A detector or a list of detectors defining how the wave functions should be converted to measurements after running the multislice algorithm.
algorithm (FourierMultislice or RealSpaceMultislice, optional) – Algorithm used for multislice operator (default is FourierMultislice())
- Returns:
measurements – Exit waves or detected measurements or lists of measurements.
- Return type:
Wavesor tuple ofBaseMeasurements