import oommfc as oc
import discretisedfield as df
We define the cube mesh with edge length $10 \,\text{nm}$ and cell discretisation edge $1 \,\text{nm}$.
mesh = oc.Mesh(p1=(0, 0, 0), p2=(10e-9, 10e-9, 10e-9), cell=(1e-9, 1e-9, 1e-9))
# Plot the mesh.
%matplotlib inline
mesh
Now we define the system object and its Hamiltonian.
system = oc.System(name="system")
A = 1e-11
H = (0.1/oc.mu0, 0, 0)
K1 = 1e3
u = (1, 1, 1)
system.hamiltonian = oc.Exchange(A) + \
oc.Demag() + \
oc.Zeeman(H) + \
oc.UniaxialAnisotropy(K1=K1, u=u)
We will now intialise the system in $(0, 0, 1)$ direction and relax the magnetisation.
Ms = 8e5
system.m = df.Field(mesh, value=(0,0,1), norm=Ms)
Total effective field is:
system.hamiltonian.effective_field.plot_plane("x")
2018/3/26 16:32: Calling OOMMF (system/system.mif) ... [0.7s]
Whereas, the individual exchange effective field is:
Hex_eff = system.hamiltonian.exchange.effective_field
2018/3/26 16:32: Calling OOMMF (system/system.mif) ... [0.7s]
Because we initialised the system with the uniform state, we expect this effective field to be zero.
Hex_eff.average
(0.0, 0.0, 0.0)
md = oc.MinDriver()
md.drive(system)
2018/3/26 16:32: Calling OOMMF (system/system.mif) ... [1.0s]
Compute the energy (and demonstrate that the energy decreased) and plot its magnetisation:
E = system.hamiltonian.energy
print("The system's energy is {} J.".format(E))
system.m.plot_plane("x")
2018/3/26 16:32: Calling OOMMF (system/system.mif) ... [0.7s] The system's energy is 5.352855331445172e-20 J.
For instance, the exchange energy is:
system.hamiltonian.exchange.energy
2018/3/26 16:32: Calling OOMMF (system/system.mif) ... [0.7s]
1.1217019053781098e-21
We can also chack the sum of all individual energy terms and check if it the same as the total energy.
total_energy = 0
for term in system.hamiltonian.terms:
total_energy += term.energy
print("The sum of energy terms is {} J.".format(total_energy))
print("The system's energy is {} J.".format(system.hamiltonian.energy))
2018/3/26 16:32: Calling OOMMF (system/system.mif) ... [0.7s] 2018/3/26 16:32: Calling OOMMF (system/system.mif) ... [0.7s] 2018/3/26 16:32: Calling OOMMF (system/system.mif) ... [0.7s] 2018/3/26 16:32: Calling OOMMF (system/system.mif) ... [0.7s] The sum of energy terms is 5.352855331445171e-20 J. 2018/3/26 16:33: Calling OOMMF (system/system.mif) ... [0.7s] The system's energy is 5.352855331445172e-20 J.