Energy#

Energy class is used as an interface to everything about the classical energy of the Hamiltonian. It is created from a spin Hamiltonian

>>> import numpy as np
>>> import magnopy
>>> # Hamiltonian for the nearest-neighbor ferromagnet on a cubic lattice
>>> spinham = magnopy.examples.cubic_ferro_nn(S=5/2, J_iso=1, J_21=np.diag([2, -1, -1]))
>>> energy = magnopy.Energy(spinham=spinham)

And then takes a set of spin directions to compute \(E^{(0)}\) (Energy.E_0())

Classical energy#

The classical energy \(E^{(0)}\) is computed for a given set of spin directions

# In meV by default
>>> energy.E_0(spin_directions = [[0, 0, 1]])
-25.0
>>> energy.E_0(spin_directions = [[0, 1, 0]])
-25.0
>>> energy.E_0(spin_directions = [[1, 0, 0]])
-6.25

Optimal spin directions#

The optimal spin directions (at least a local minima) can be found by numerical minimization

>>> optimal_directions = energy.optimize(initial_guess = [[0.5, 0.3, 0.1]])