Note
Go to the end to download the full example code.
Classical Energy¶
Tutorial tasks
Compute classical energy of one of the Hamiltonians from the previous tasks.
Change the convention of the spin Hamiltonian and re-compute the energy. Does it change?
Use the set of Hamiltonians from Arithmetic operations. Optimize the spin direction for the full Hamiltonian. Use them to compute energy contributions of every term.
(extra) Create a Hamiltonian of the ferromagnet with an easy magnetic axis. Find out numerically the value of the magnetic field that is applied perpendicular to the easy axis, which fully orients the spins along the magnetic field.
Classical energy of the spin Hamiltonian is implemented in a separate class.
import magnopy
spinham = magnopy.examples.cubic_ferro_nn(S=1, J_21=(-1, 0, 1))
energy = magnopy.Energy(spinham=spinham)
This object can be used to simply compute the energy for some set of spin directions
print(energy(spin_directions=[[1, 0, 0]]))
print(energy(spin_directions=[[0, 1, 0]]))
print(energy(spin_directions=[[0, 0, 1]]))
-4.0
-3.0
-2.0
or to optimize spin directions within unit cell and get the configuration of some local minima
optimized_sd = energy.optimize()
─────┬─────────────┬─────────────┬─────────────
step │ E_0 │ delta E_0 │ max torque
─────┴─────────────┴─────────────┴─────────────
1 -3.8144091 0.5227305 0.7795155
2 -3.9177110 0.1033019 0.6757774
3 -3.9701722 0.0524612 0.3862030
4 -3.9996792 0.0295069 0.0361254
5 -3.9998632 0.0001840 0.0281246
6 -3.9999656 0.0001025 0.0117617
7 -3.9999929 0.0000273 0.0069941
8 -3.9999954 0.0000024 0.0046177
9 -3.9999977 0.0000023 0.0042198
10 -3.9999992 0.0000015 0.0019175
11 -3.9999996 0.0000005 0.0016791
12 -4.0000000 0.0000003 0.0003172
13 -4.0000000 0.0000000 0.0002358
14 -4.0000000 0.0000000 0.0000697
15 -4.0000000 0.0000000 0.0000598
16 -4.0000000 0.0000000 0.0000160
17 -4.0000000 0.0000000 0.0000126
18 -4.0000000 0.0000000 0.0000033
───────────────────────────────────────────────
see magnopy.Energy for more details.
print(optimized_sd)
print(energy(optimized_sd))
[[ 1.00000000e+00 -1.43745602e-06 -4.01553907e-07]]
-3.9999999999976126
Total running time of the script: (0 minutes 0.038 seconds)