magnopy.Energy.E_0#

method

Energy.E_0(spin_directions, units='meV', _normalize=True) float[source]#

Computes classical energy of the spin Hamiltonian.

Parameters:
spin_directions(M, 3) array-like

Directions of spin vectors. Only directions of vectors are used, modulus is ignored. M is the amount of magnetic atoms in the Hamiltonian. The order of spin directions is the same as the order of magnetic atoms in spinham.magnetic_atoms.spins.

unitsstr, default "meV"

Units of energy. See Units of energy for the full list of supported units.

Added in version 0.3.0.

_normalizebool, default True

Whether to normalize the spin_directions or use the provided vectors as is. This parameter is technical and we do not recommend to use it at all.

Returns:
E_0float

Classic energy of state with spin_directions. Return in the units of units.

Examples

First, one need to create some spin Hamiltonian

>>> import numpy as np
>>> import magnopy
>>> cell = np.eye(3)
>>> atoms = dict(
...     names=["Fe"], spins=[1.5], g_factors=[2], positions=[[0, 0, 0]]
... )
>>> convention = magnopy.Convention(
...     multiple_counting=True, spin_normalized=False, c21=1, c22=-1
... )
>>> spinham = magnopy.SpinHamiltonian(
...     cell=cell, atoms=atoms, convention=convention
... )

Then, add some parameters to the Hamiltonian

>>> spinham.add_21(alpha=0, parameter=np.diag([0, 0, -1]))
>>> spinham.add_22(
...     alpha=0,
...     beta=0,
...     nu=(1, 0, 0),
...     parameter=magnopy.converter22.from_iso(iso=1),
... )

Now everything is ready to create an instance of the Energy class

>>> energy = magnopy.Energy(spinham)

Finally, energy an be used to compute classical energy of the Hamiltonian for arbitrary spin configuration.

>>> sd1 = [[1, 0, 0]]
>>> sd2 = [[0, 1, 0]]
>>> sd3 = [[0, 0, 1]]
>>> # Default units are meV
>>> energy.E_0(sd1), energy.E_0(sd2), energy.E_0(sd3)
(-4.5, -4.5, -6.75)
>>> # The command above is equivalent to
>>> energy(sd1), energy(sd2), energy(sd3)
(-4.5, -4.5, -6.75)