abtem.potentials.charge_density#

Module for describing the nuclear and electronic charge density used as the electrostatic potential in multislice simulations.

Module Contents#

Classes#

ChargeDensityPotential

The charge density potential is used to calculate the electrostatic potential from a set of core charges defined by an ASE Atoms object and corresponding electron charge density defined by a NumPy array.

Functions#

add_point_charges_fourier

Add the nuclear point charges in Reciprocal space.

curl_fourier

Calculate the curl of a vector field in 3D using Fourier-space differentiation.

integrate_gradient_fourier

Integrate an array representation of a gradient in 3D using Fourier-space integration.

API#

class abtem.potentials.charge_density.ChargeDensityPotential(...)[source]#

Bases: abtem.potentials.iam._PotentialBuilder

The charge density potential is used to calculate the electrostatic potential from a set of core charges defined by an ASE Atoms object and corresponding electron charge density defined by a NumPy array.

Parameters:
  • atoms (Atoms or FrozenPhonons) – Atomic configuration(s) used in the independent atom model for calculating the electrostatic potential(s).

  • charge_density (ndarray) – Charge density as a 3D NumPy array [electrons / Å^3].

  • gpts (one or two int, optional) – Number of grid points in x and y describing each slice of the potential calculated by specifying either sampling or gpts.

  • sampling (one or two float, optional) – Sampling of the potential in x and y [1 / Å] calculated by specifying either sampling or gpts.

  • slice_thickness (float or sequence of float, optional) – Thickness of the potential slices [Å] (default is 0.5 Å). If given as a float, the number of slices are calculated by dividing the slice thickness into the z-height of the cell. 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.

  • 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.

  • plane (str or two tuples of three float, optional) – The plane relative to the provided atoms mapped to the xy plane of the potential, i.e. the propagation direction will be perpendicular to the provided plane. If str, must be a concatenation of two of ‘x’, ‘y’ and ‘z’; the default value ‘xy’ indicates that potential slices are cuts parallel to the ‘xy’-plane. The plane may also be specified with two arbitrary 3D vectors, which are mapped to the x and y directions of the potential, respectively. The length of the vectors has no influence. If the vectors are not perpendicular, the second vector is rotated in the plane to become perpendicular to the first. A value of ((1., 0., 0.), (0., 1., 0.)) is equivalent to ‘xy’.

  • origin (three float, optional) – The origin relative to the provided atoms mapped to the origin of the potential. This is equivalent to translating the atoms. The default is (0., 0., 0.).

  • box (three float, optional) – The extent of the potential in x, y and z. If not given this is determined from the atoms. If the box size does not match an integer number of the atoms’ cell, an affine transformation may be necessary to preserve periodicity, determined by the periodic keyword.

  • periodic (bool, True) – If a transformation of the atomic structure is required, periodic determines how the atomic structure is transformed. If True, the periodicity of the atoms is preserved, which may require applying a small affine transformation to the atoms. If False, the transformed potential is effectively cut out of a larger repeated potential, which may not preserve periodicity.

  • repetitions (three int, optional) – Repeats the atoms and the charge density by integer amounts in the x, y and z directions. The default is (1, 1, 1).

  • device (str, optional) – The device used for calculating the potential. The default is determined by the user configuration file.

Initialization

property charge_density#
property ensemble_axes_metadata#
property ensemble_shape: Tuple[int, ...]#
property frozen_phonons#
generate_slices(...)[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.

Returns:

slices – Generator for the array of slices.

Return type:

generator of ndarray

property is_lazy#
property num_configurations#
property num_frozen_phonons#
property repetitions#
abtem.potentials.charge_density.add_point_charges_fourier(...) ndarray[source]#

Add the nuclear point charges in Reciprocal space.

Parameters:
  • array (ndarray) – Array representing 3D charge density to which the point charges are added.

  • atoms (ase.Atoms) – Atoms from which the nuclear charges with magnitudes and positions are determined.

  • broadening (float) – Gaussian broadening of the point charges (default is 0.05).

Returns:

density – 3D charge density with added nuclear charges in reciprocal space.

Return type:

ndarray

abtem.potentials.charge_density.curl_fourier(...) ndarray[source]#

Calculate the curl of a vector field in 3D using Fourier-space differentiation.

Parameters:
  • vector_field (ndarray) – Array representing a vector field of dimension 3.

  • cell (ase.cell.Cell) – ASE Cell object defining the region of space where the vector field is defined.

Returns:

curl – Array representing the curl of the vector field.

Return type:

ndarray

abtem.potentials.charge_density.integrate_gradient_fourier(...) ndarray[source]#

Integrate an array representation of a gradient in 3D using Fourier-space integration.

Parameters:
  • array (ndarray) – Array representing a gradient of dimension 3.

  • cell (ase.cell.Cell) – ASE Cell object defining the region of space where the gradient is integrated.

  • in_space (str) – Space in which the gradient is defined (either “real” or “fourier”).

  • out_space (str) – Space in which the integrated gradient is defined (“real” or “fourier”).

Returns:

integrated – Integrated gradient.

Return type:

ndarray