abtem.magnetism.gpaw#

Module Contents#

Classes#

GPAW

GPAWMagneticField

GPAWMagneticFields

Bundles the electrostatic potential, magnetic vector potential and (optionally) magnetic field built from the same GPAW calculator(s) by gpaw_magnetic_fields.

GPAWVectorPotential

SpinDensityMagneticField

Functions#

calculate_constant_magnetic_field

calculate_magnetic_vector_potential

get_magnetic_field_from_gpaw

get_vector_potential_from_gpaw

gpaw_magnetic_fields

Build the electrostatic potential, magnetic vector potential and (optionally) magnetic field from the same GPAW calculator(s) in one call.

rotate_vector_field

Rotate a 3D vector field defined on a grid using Euler angles.

API#

class abtem.magnetism.gpaw.GPAW[source]#

Bases: typing.Protocol

property atoms: ase.Atoms#
get_number_of_grid_points() ndarray[source]#
class abtem.magnetism.gpaw.GPAWMagneticField(...)[source]#

Bases: abtem.magnetism.gpaw._GPAWMagnetics, abtem.magnetism.iam.BaseMagneticField

Initialization

class abtem.magnetism.gpaw.GPAWMagneticFields[source]#

Bundles the electrostatic potential, magnetic vector potential and (optionally) magnetic field built from the same GPAW calculator(s) by gpaw_magnetic_fields.

potential may carry a frozen-phonon ensemble axis (or, after tiling, come from a CrystalPotential build); vector_potential and magnetic_field are always for a single, rigid configuration – see _check_unsupported_ensemble_params. Use .tile() to bring the magnetic components up to a repeated crystal’s size, and .combined_potential() to fold the vector potential into an electrostatic potential via adjust_coulomb_potential.

combined_potential(...) PotentialArray[source]#

Combine an electrostatic potential with vector_potential via VectorPotentialArray.adjust_coulomb_potential.

Parameters:
  • energy (float) – Electron energy [eV].

  • potential (PotentialArray, optional) – The electrostatic potential to combine with vector_potential. Defaults to self.potential; pass a separately tiled/ensembled potential (e.g. a CrystalPotential build) after calling .tile() for the frozen-phonon workflow.

Return type:

PotentialArray

magnetic_field: Optional[MagneticFieldArray]#

None

potential: PotentialArray#

None

show(...)[source]#

Show side-by-side projections of the electrostatic potential and the x and z components of the vector potential – and, if built, the magnetic field. Az/Bz are the components that matter for combined_potential; Ax/Bx are shown alongside for a sanity check that the in-plane and z-swapped components look sensible relative to each other.

Parameters:
  • tile (two int, optional) – Tile the projected images before plotting, e.g. to preview the periodicity of a repeated unit cell.

  • figsize (two int, optional) – Figure size passed to matplotlib.pyplot.figure.

Returns:

fig

Return type:

matplotlib.figure.Figure

tile(...) GPAWMagneticFields[source]#

Tile vector_potential (and magnetic_field, if present) to match a separately tiled/repeated electrostatic potential, e.g. built via abtem.CrystalPotential.

potential is left untouched here – tile or rebuild it separately (e.g. CrystalPotential(electrostatic_ensemble, repetitions=…)) before calling combined_potential.

vector_potential: VectorPotentialArray#

None

class abtem.magnetism.gpaw.GPAWVectorPotential(...)[source]#

Bases: abtem.magnetism.gpaw._GPAWMagnetics, abtem.magnetism.iam.BaseVectorPotential

Initialization

class abtem.magnetism.gpaw.SpinDensityMagneticField(...)[source]#

Initialization

abtem.magnetism.gpaw.calculate_constant_magnetic_field()[source]#
abtem.magnetism.gpaw.calculate_magnetic_vector_potential(...)[source]#
abtem.magnetism.gpaw.get_magnetic_field_from_gpaw(...)[source]#
abtem.magnetism.gpaw.get_vector_potential_from_gpaw(...)[source]#
abtem.magnetism.gpaw.gpaw_magnetic_fields(...) GPAWMagneticFields[source]#

Build the electrostatic potential, magnetic vector potential and (optionally) magnetic field from the same GPAW calculator(s) in one call.

frozen_phonons (an ensemble of atomic-displacement configurations) is only supported for the electrostatic potential – the magnetic components come from a single, rigid ab initio calculation and cannot vary per configuration. Tile the returned object with .tile() to match a separately built, possibly-ensembled electrostatic potential (e.g. from abtem.CrystalPotential), then combine with .combined_potential().

Parameters:
  • calculators ((list of) gpaw.calculator.GPAW or (list of) str) – One or more converged GPAW calculators (or paths to .gpw files). Forwarded to GPAWPotential. If a list (a frozen-phonon ensemble), magnetic_calculator must be given explicitly, since GPAWVectorPotential/GPAWMagneticField only support a single calculator.

  • gpts (one or two int, optional) – Forwarded to all built components. See GPAWPotential.

  • sampling (one or two float, optional) – Forwarded to all built components. See GPAWPotential.

  • slice_thickness (float or sequence of float, optional) – Forwarded to all built components. See GPAWPotential.

  • exit_planes (int or tuple of int, optional) – Forwarded to all built components. See GPAWPotential.

  • plane (str or two tuples of three float, optional) – Forwarded to all built components. See GPAWPotential.

  • origin (three float, optional) – Forwarded to all built components. See GPAWPotential.

  • box (three float, optional) – Forwarded to all built components. See GPAWPotential.

  • periodic (bool) – Forwarded to all built components. See GPAWPotential.

  • device (str, optional) – Forwarded to all built components. See GPAWPotential.

  • frozen_phonons (BaseFrozenPhonons, optional) – Forwarded to GPAWPotential only.

  • rotate_field (tuple of three float, "auto", or None) – Forwarded to GPAWVectorPotential/GPAWMagneticField. Defaults to “auto”: automatically swap the larger-magnitude in-plane component into z (see _auto_rotation_matrix_for_vector_field).

  • include_magnetic_field (bool) – If True, also build the magnetic field B (not used by combined_potential, only for inspection/visualization). Roughly doubles the GPAW-side cost of the magnetic part, so it is off by default.

  • magnetic_calculator (gpaw.calculator.GPAW, optional) – The single calculator representing the (rigid) magnetic contribution. Defaults to calculators when that is a single calculator; required when calculators is a list.

  • lazy (bool, optional) – Passed to the electrostatic potential’s .build(). The magnetic components are always built eagerly, since GPAWVectorPotential/GPAWMagneticField do not support lazy building.

  • potential_kwargs (dict, optional) – Extra keyword arguments forwarded only to GPAWPotential, or only to GPAWVectorPotential/GPAWMagneticField, respectively (e.g. their differing gridrefinement defaults).

  • field_kwargs (dict, optional) – Extra keyword arguments forwarded only to GPAWPotential, or only to GPAWVectorPotential/GPAWMagneticField, respectively (e.g. their differing gridrefinement defaults).

Return type:

GPAWMagneticFields

abtem.magnetism.gpaw.rotate_vector_field(...) ndarray[source]#

Rotate a 3D vector field defined on a grid using Euler angles.

Parameters:
  • vector_field (ndarray) – 3xNxMxK array representing the 3D vector field.

  • euler_angles (tuple) – Euler angles (xyz) for the rotation.

Returns:

rotated_field – Rotated 3D vector field.

Return type:

ndarray