MagneticAnisotropyEnergy

class MagneticAnisotropyEnergy(configuration, filename, object_id, theta_angles=None, phi_angles=None, kpoints=None, projections=None, energy_minimum=None, energy_maximum=None, bands_per_electron=None, initial_spin=None, initial_state=None, store_k_point_resolved_data=None, log_filename_prefix=None, number_of_processes_per_task=None)

Constructor for the MagneticAnisotropyEnergy object.

Parameters:
  • configuration (BulkConfiguration | MoleculeConfiguration) – The configuration with an attached calculator for which to calculate the projected density of states. The configuration must have an LCAOCalculator attached with a pseudopotential that supports Spin-Orbit coupling.

  • filename (str) – The full or relative filename path the Study object should be saved to. See nlsave().

  • object_id (str) – The name of the study that the Study object should be saved to within the file. This needs to be a unique name in this file. See nlsave().

  • theta_angles (PhysicalQuantity of type angle.`) – A list of theta angles specifying the spin rotation for the magnetic anisotropy calculations.
    Default: [0.0, 90.0]*Degrees

  • phi_angles – A list of phi angles specifying the spin rotation for the magnetic anisotropy calculations.
    Default: 0.0*Degrees

  • kpoints (sequence (size 3) of int | MonkhorstPackGrid | KpointDensity | RegularKpointGrid) – The k-points for which to calculate the projected density of states.
    Default: The Monkhorst-Pack grid used for the self-consistent calculation.

  • projections (list of Projection | Projection | ProjectionGenerator) – The projections used for the calculating the weights.
    Default: ProjectOnSites.

  • energy_minimum (PhysicalQuantity of type energy.) – The smallest energy to consider, relative to the Fermi energy.
    Default: -1000*eV

  • energy_maximum (PhysicalQuantity of type energy.) – The highest energy to consider, relative to the Fermi energy.
    Default: 1.0*eV

  • bands_per_electron (float) – The number of bands per electron to include in the projection calculations. The number must be 1.0 or larger.
    Default: 1.1

  • initial_spin – The initial spins for the polarized configuration.
    Default: Maximum spin polarization.

  • initial_state (BulkConfiguration | MoleculeConfiguration | None) – The initial state object to be used for the polarized configuration. The initial_state must have a calculator with either polarized or unpolarized exchange-correlation.
    Default: No initial state.

  • store_k_point_resolved_data (bool) – Whether or not the energies and projections should be stored k-point resolved.
    Default: False for LCAOCalculator, True for PlaneWaveCalculator.

  • log_filename_prefix (str | LogToStdOut) – Filename prefix for the logging output of magnetic anisotropy energy calculations. If LogToStdOut, all logging will instead be sent to standard output.
    Default: 'magneticanisotropyenergy_'

  • number_of_processes_per_task (int | ProcessesPerNode | AllProcesses) – The number of processes that will be used to execute each task. If this value is greater than or equal to the total number of available processes, each single task will be executed collaboratively over all processes. Otherwise, a delegator-worker scheme is used; in this case, one process will be set aside as the delegator, and the remaining ones will be grouped into workers and execute tasks concurrently.
    Default: AllProcesses, all available processes execute each task collaboratively.

addAngles(theta_angles=None, phi_angles=None)

Add a list of theta- and/or phi angles to the MagneticAnisotropyEnergy study. These will be calculated the next time the object is updated.

Parameters:
  • theta_angles (PhysicalQuantity of type angle) – A list with theta angles specifying the spin rotation for the magnetic anisotropy calculations.

  • phi_angles – A list with phi angles specifying the spin rotation for the magnetic anisotropy calculations.

addProjections(projections=None)

Add a list of projection or a projection generator to the MagneticAnisotropyEnergy study. These will be calculated the next time the object is updated.

Parameters:

projections (list of Projection | Projection | ProjectionGenerator) – The projections used for the calculating the weights.

bandEnergies(theta, phi)

Method to get the calculated band energies for each projection, band and k-point. This method only returns data when store_k_point_resolved_data=True, which is not default for LCAOCalculator. When store_k_point_resolved_data=False the method will return None.

Parameters:
  • theta (PhysicalQuantity of type angle.) – The theta angle to get the results for.

  • phi (PhysicalQuantity of type angle.) – The phi angle to get the results for.

Returns:

The band energies for the updated spin orbit configuration for specified theta and phi angles. The energies array has dimension (number_number_of_kpoints, number_of_bands).

Return type:

PhysicalQuantity of type energy

bandEnergyVsAngles()

Calculates the summed band energies for all the angles.

Returns:

The total magnetic anisotropy energy as function of theta and phi angles. The shape of the array is (n-theta, n-phi), where n-theta is the number of theta angles and n-phi is the number of phi angles.

Return type:

PhysicalQuantity of type energy.

bandsPerElectron()
Returns:

The number of bands per electron to include in the projection calculations.

Return type:

float

calculatedPhiAngles()

Retrieve the list of calculated phi angles.

Returns:

The list of calculated phi angles.

Return type:

PhysicalQuantity of type angle.

calculatedThetaAngles()

Retrieve the list of calculated theta angles.

Returns:

The list of calculated theta angles.

Return type:

PhysicalQuantity of type angle.

calculator()
Returns:

The calculator attached to the configuration.

Return type:

LCAOCalculator

dependentStudies()
Returns:

The list of dependent studies.

Return type:

list of Study

energyMaximum()
Returns:

The highest energy to consider, relative to the Fermi energy.

Return type:

PhysicalQuantity of type energy.

energyMinimum()
Returns:

The smallest energy to consider, relative to the Fermi energy.

Return type:

PhysicalQuantity of type energy.

filename()
Returns:

The filename where the study object is stored.

Return type:

str

initialSpin()
Returns:

The initial spin used for the polarized calculation.

Return type:

InitialSpin

initialState()
Returns:

The initial state used for the polarized calculation.

Return type:

BulkConfiguration | None

kpoints()
Returns:

The k-point sampling used for calculating the magnetic anisotropy energy.

Return type:

MonkhorstPackGrid | RegularKpointGrid

logFilenamePrefix()
Returns:

The filename prefix for the logging output of the study.

Return type:

str | LogToStdOut

magneticAnisotropyEnergy(theta_0=None, phi_0=None, theta_1=None, phi_1=None, energy_minimum=None, energy_maximum=None)

The magnetic anisotropy energy is defined as MAE = E(theta_1, phi_1) - E(theta_0, phi_0).

Parameters:
  • theta_0 (PhysicalQuantity of type angle.) – One of the theta angles to check.
    Default: The first theta angle.

  • theta_1 (PhysicalQuantity of type angle.) – One of the theta angles to check.
    Default: The last theta angle.

  • phi_0 (PhysicalQuantity of type angle.) – One of the phi angles to check.
    Default: The first phi angle.

  • phi_1 (PhysicalQuantity of type angle.) – One of the phi angles to check.
    Default: The last phi angle.

  • energy_minimum (PhysicalQuantity of type energy.) – The smallest energy to consider, relative to the Fermi energy.

  • energy_maximum (PhysicalQuantity of type energy.) – The highest energy to consider, relative to the Fermi energy.

Returns:

The total MAE.

Return type:

PhysicalQuantity of type energy.

nlprint(stream=None)

Print a string containing an ASCII table useful for plotting the Study object.

Parameters:

stream (python stream) – The stream the table should be written to.
Default: NLPrintLogger()

numberOfProcessesPerTask()
Returns:

The number of processes to be used to execute each task. If None, all available processes execute each task collaboratively.

Return type:

int | None | ProcessesPerNode

numberOfProcessesPerTaskResolved()
Returns:

The number of processes to be used to execute each task. Default values are resolved based on the current execution settings.

Return type:

int

objectId()
Returns:

The name of the study object in the file.

Return type:

str

phiAngles()
Returns:

The phi angles used for the calculated magnetic anisotropy energy.

Return type:

PhysicalQuantity of type angle.

projectionWeights(theta, phi)

Method to get the calculated projection weights for each projection, band and k-point. This method only returns data when store_k_point_resolved_data=True, which is not default for LCAOCalculator. When store_k_point_resolved_data=False the method will return None.

Parameters:
  • theta (PhysicalQuantity of type angle.) – The theta angle to get the results for.

  • phi (PhysicalQuantity of type angle.) – The phi angle to get the results for.

Returns:

Retrieve the projection weights for the updated spin orbit configuration for specified theta and phi angles. The weights array has dimensions (number_of_projections, number_number_of_kpoints, number_of_bands).

Return type:

PhysicalQuantity of type energy

projections()
Returns:

The projections used for the calculated magnetic anisotropy energy.

Return type:

list of Projection | Projection

saveToFileAfterUpdate()
Returns:

Whether the study is automatically saved after it is updated.

Return type:

bool

siteAndOrbitalProjectedMAE(theta_0=None, theta_1=None, phi_0=None, phi_1=None, axis='z')

Function for getting the site and shell projected magnetic anisotropy. The magnetic anisotropy energy is defined as MAE = E(theta_1, phi_1) - E(theta_0, phi_0). The site- and orbital-projected energies are plotted along the specified axis.

Parameters:
  • theta_0 (PhysicalQuantity of type angle.) – One of the theta angles at which to evaluate the energies.
    Default: The smallest calculated theta angle.

  • theta_1 (PhysicalQuantity of type angle.) – One of the theta angles at which to evaluate the energies.
    Default: The largest calculated theta angle.

  • phi_0 (PhysicalQuantity of type angle.) – One of the phi angles at which to evaluate the energies.
    Default: The smallest calculated phi angle.

  • phi_1 (PhysicalQuantity of type angle.) – One of the phi angles at which to evaluate the energies.
    Default: The largest calculated phi angle.

  • axis (str.) – The axis to plot the site projections along. This should either be ‘x’, ‘y’, or ‘z’.

Returns:

Two dicts with coordinates and site- and orbital-resolved MAE. The first dict contains for each element the coordinates for atoms of this type. The second dict contains for each element a list of arrays with dimension (number of atoms, 2*l + 1) for each index l in the list.

Return type:

dict, dict.

siteAndShellProjectedMAE(theta_0=None, theta_1=None, phi_0=None, phi_1=None, axis='z')

Function for getting the site and shell projected magnetic anisotropy. The magnetic anisotropy energy is defined as MAE = E(theta_1, phi_1) - E(theta_0, phi_0). The site- and shell-projected energies are plotted along the specified axis.

Parameters:
  • theta_0 (PhysicalQuantity of type angle.) – One of the theta angles at which to evaluate the energies.
    Default: The smallest calculated theta angle.

  • theta_1 (PhysicalQuantity of type angle.) – One of the theta angles at which to evaluate the energies.
    Default: The largest calculated theta angle.

  • phi_0 (PhysicalQuantity of type angle.) – One of the phi angles at which to evaluate the energies.
    Default: The smallest calculated phi angle.

  • phi_1 (PhysicalQuantity of type angle.) – One of the phi angles at which to evaluate the energies.
    Default: The largest calculated phi angle.

  • axis (str.) – The axis to plot the site projections along. This should either be ‘x’, ‘y’, or ‘z’.

Returns:

Two dicts with coordinates and site- and shell-resolved MAE. The first dict contains for each element the coordinates for atoms of this type. The second dict contains for each element an array with dimension (number of atoms, number of shells).

Return type:

dict, dict.

siteProjectedMAE(theta_0=None, theta_1=None, phi_0=None, phi_1=None, axis='z')

Function for getting the site projected magnetic anisotropy. The magnetic anisotropy energy is defined as MAE = E(theta_1, phi_1) - E(theta_0, phi_0).

Parameters:
  • theta_0 (PhysicalQuantity of type angle.) – One of the theta angles at which to evaluate the energies.
    Default: The smallest calculated theta angle.

  • theta_1 (PhysicalQuantity of type angle.) – One of the theta angles at which to evaluate the energies.
    Default: The largest calculated theta angle.

  • phi_0 (PhysicalQuantity of type angle.) – One of the phi angles at which to evaluate the energies.
    Default: The smallest calculated phi angle.

  • phi_1 (PhysicalQuantity of type angle.) – One of the phi angles at which to evaluate the energies.
    Default: The largest calculated phi angle.

  • axis (str.) – The axis to plot the site projections along. This should either be ‘x’, ‘y’, or ‘z’.

Returns:

x- and y-data as coordinates and energies. If no site projections are present the return will be None, None

Return type:

PhysicalQuantity of type length, PhysicalQuantity of type energy.

storeKPointResolvedData()
Returns:

Boolean controlling if energies and projections should be stored k-point resolved.

Return type:

bool

thetaAngles()
Returns:

The theta angles used for the calculated magnetic anisotropy energy.

Return type:

PhysicalQuantity of type angle.

uniqueString()

Return a unique string representing the state of the object.

update()

Run the calculations for the study object.

updatedPolarizedConfiguration()

Retrieve the updated polarized configuration

Returns:

The optimized device configuration. If not available, returns None.

Return type:

DeviceConfiguration | None

updatedSpinOrbitConfiguration(theta, phi)

Retrieve the updated spin orbit configuration for specified theta and phi angles.

Returns:

The optimized device configuration. If not available, returns None.

Return type:

DeviceConfiguration | None

Notes

Note

Study objects behave differently from analysis objects. See the Study object overview for more details.

The MagneticAnisotropyEnergy object can be used to perform a detailed study of the magnetic anisotropy energy, which is defined as the energy difference between two spin orientations:

\[MAE = E(\theta_1, \phi_1) - E(\theta_0, \phi_0),\]

where the spin orientation is described by the two spherical angles \(\theta\) and \(\phi\).

Force theorem

In the MagneticAnisotropyEnergy study object we calculate the MAE using the force theorem, which allows you to evaluate the energy difference using non-self consistent band energies [1]:

\[MAE = \sum_i f_i(\theta_1, \phi_1) \epsilon_i(\theta_1, \phi_1) - \sum_i f_i(\theta_0, \phi_0) \epsilon_i(\theta_0, \phi_0),\]

where \(f_i(\theta, \phi)\) is the occupation factor for band i (including both band and k-point index) with the spin orientation \((\theta, \phi)\) and \(\epsilon_i(\theta, \phi)\) is the corresponding band energy.

The work implemented in the study object is the following

  1. Perform a self-consistent polarized calculation.

  2. For each spin orientation:

  1. Make a non-self consistent spin-orbit calculation using the polarized electron density and effective potential, rotated in the desired direction.

  2. Using this configuration calculate and sum the band energies according to the formula above.

  3. For each band energy (band index and k-point) we potentially also calculate the projection weight using the specified projection scheme. This step allows for a detailed site- and/or orbital compositional analysis.

The use of the force theorem (FT) has been validated in several papers, e.g. [2], [3] against self-consistent calculations of total energies. Using the FT has several advantages over the self-consistent approach:

  • It is significantly faster since the self-consistent solution of the spin-orbit calculation is computationally significantly more demanding than the polarized one.

  • Often it is harder to achieve good convergence for a spin-orbit calculation than for a polarized one.

  • Using the FT approach allows for projection analysis since each band energy has an associated eigenvector that can be projected onto atomic sites or individual orbitals (see below). The projection analysis is often helpful in understanding the physics behind the calculated MAE. An example could be the difference between surface/interface atoms and bulk atoms in the contribution to the MAE in a metallic slab [4].

Note

The calculator must contain a basis/pseudopotential that supports spin-orbit calculations.

Usage Example

This example script shows how to perform a magnetic anisotropy energy calculation of CoPt in the \(L0_1\) phase

# -*- coding: utf-8 -*-
setVerbosity(MinimalLog)

# -------------------------------------------------------------
# Bulk Configuration
# -------------------------------------------------------------

# Set up lattice
lattice = SimpleTetragonal(3.81*Angstrom, 3.68846*Angstrom)

# Define elements
elements = [Cobalt, Platinum, Platinum, Cobalt]

# Define coordinates
fractional_coordinates = [[ 0.            ,  0.            ,  0.            ],
                          [ 0.            ,  0.5           ,  0.5           ],
                          [ 0.5           ,  0.            ,  0.5           ],
                          [ 0.5           ,  0.5           ,  0.            ]]

# Set up configuration
bulk_configuration = BulkConfiguration(
    bravais_lattice=lattice,
    elements=elements,
    fractional_coordinates=fractional_coordinates
    )

# -------------------------------------------------------------
# Calculator
# -------------------------------------------------------------
#----------------------------------------
# Basis Set
#----------------------------------------
basis_set = [
    BasisGGAPseudoDojoSO.Cobalt_Medium,
    BasisGGAPseudoDojoSO.Platinum_Medium,
    ]

#----------------------------------------
# Exchange-Correlation
#----------------------------------------
exchange_correlation = SOGGA.PBE

k_point_sampling = MonkhorstPackGrid(
    na=25,
    nb=25,
    nc=25,
    force_timereversal=False,
    )
numerical_accuracy_parameters = NumericalAccuracyParameters(
    density_mesh_cutoff=155.0*Hartree,
    k_point_sampling=k_point_sampling,
    occupation_method=ColdSmearing(0.05*eV),
    )

calculator = LCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    numerical_accuracy_parameters=numerical_accuracy_parameters,
    )

bulk_configuration.setCalculator(calculator)
nlprint(bulk_configuration)
nlsave('CoPt_MAE.hdf5', bulk_configuration)

# -------------------------------------------------------------
# Magnetic Anisotropy Energy
# -------------------------------------------------------------
# Kpoint sampling
kpoint_grid = MonkhorstPackGrid(
    na=35,
    nb=35,
    nc=35,
    )

# File name.
filename = 'CoPt_MAE.hdf5'

magnetic_anisotropy_energy = MagneticAnisotropyEnergy(
    configuration=bulk_configuration,
    filename=filename,
    object_id='magnetic_anisotropy_energy',
    theta_angles=numpy.linspace(0, 90, 2)*Degrees,
    phi_angles=numpy.linspace(0, 0, 1)*Degrees,
    kpoints=kpoint_grid,
    projections=NoProjection,
    energy_minimum=-1000*eV,
    energy_maximum=1*eV,
    bands_per_electron=1.1,
    log_filename_prefix='magnetic_anisotropy_energy_',
    number_of_processes_per_task=None,
)

magnetic_anisotropy_energy.update()

magnetic_anisotropy_energy.py

Note

In order to get accurate results, a high k-point sampling is needed on the calculator and an even higher sampling on the MagneticAnisotropyEnergy study object. Convergence with respect to k-point sampling should be carefully checked.

Results

The total MAE can be obtained from the method magneticAnisotropyEnergy which returns the total MAE for specified angles and projections. By default:

mae = magnetic_anisotropy_energy.magneticAnisotropyEnergy()

will return the MAE calculated from the first and last angle pairs defined in the construction of the study object.

It is further possible the access the summed band energies (i.e. not band energy difference) from the method summedBandEnergies.

In order to inspect the dependence on the angles it is possible, using the method projectedBandEnergyVsAngles, to obtain the projected band energies for all the considered angles.

Adding angles

After having updated a MagneticAnisotropyEnergy study object, it is possible perform additional calculations for different angles using the addAngles method:

magnetic_anisotropy_energy.addAngles(phi_angles=[22.5, 45.0]*Degrees)
magnetic_anisotropy_energy.update()

By doing so one avoids to redo the self-consistent polarized calculation since this is already stored on the study.

Adding projections

After having updated a MagneticAnisotropyEnergy study object, it is also possible perform additional calculations for different projections using the addProjections method:

magnetic_anisotropy_energy.addProjections(ProjectOnShellsBySite)
magnetic_anisotropy_energy.update()

for projecting on individual shells \(s, p, d,\) etc. on each atom, or:

magnetic_anisotropy_energy.addProjections(ProjectOnOrbitalsBySite)
magnetic_anisotropy_energy.update()

for projecting on each orbital \(s, p_x, p_y, p_z,\) etc. on each atom.

Calculating without projections

If one is only interested in the total MAE and not concerned about the atom or orbital projections it is possible, and often significantly faster, to set the projections to NoProjections like:

projections=NoProjection