magnopy.Energy#
- class magnopy.Energy(spinham)[source]#
Classical energy of the spin Hamiltonian.
This class is optimized for calculation of the energy for any spin directions for the given Hamiltonian.
Important
If the spin Hamiltonian is modified, then a new instance of the energy class should be created.
- Parameters:
- spinham
SpinHamiltonian Spin Hamiltonian for the calculation of energy.
- spinham
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,
energycan be used to compute classical energy of the Hamiltonian, its gradient, torque or search for the local minima.>>> sd1 = [[1, 0, 0]] >>> sd2 = [[0, 1, 0]] >>> sd3 = [[0, 0, 1]] >>> # Default units are meV >>> energy(sd1), energy(sd2), energy(sd3) (-4.5, -4.5, -6.75) >>> # You can request other units >>> print(f"{energy(sd1, units='Joule'):.4e}") -7.2098e-22
Methods
E_0(spin_directions[, units, _normalize])Computes classical energy of the spin Hamiltonian.
E_corr(spin_directions[, units, _normalize])Computes quantum correction to the classical energy of the spin Hamiltonian.
gradient(spin_directions[, units, ...])Computes first derivatives of energy (\(E^{(0)}\)) with respect to the components of the spin directional vectors.
optimize([initial_guess, energy_tolerance, ...])Optimizes classical energy by varying the directions of spins in the unit cell.
torque(spin_directions[, units, _normalize, ...])Computes torque on each spin.