Derived fields and values

In this tutorial, we show how derived fields and values can be computed afetr the micromagnetic system is defined.

Simulation

First of all, as usual, we import oommfc and discretisedfield.

In [1]:
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}\).

In [2]:
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
../_images/ipynb_derived_fields_3_0.png

Now we define the system object and its Hamiltonian.

In [3]:
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.

In [4]:
Ms = 8e5
system.m = df.Field(mesh, value=(0,0,1), norm=Ms)

Effective field

Total effective field is:

In [5]:
system.hamiltonian.effective_field.plot_plane("x")
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.5s]
../_images/ipynb_derived_fields_9_1.png

Whereas, the individual exchange effective field is:

In [6]:
Hex_eff = system.hamiltonian.exchange.effective_field
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.5s]

Because we initialised the system with the uniform state, we expect this effective field to be zero.

In [7]:
Hex_eff.average
Out[7]:
(0.0, 0.0, 0.0)

Relax the system

In [8]:
md = oc.MinDriver()
md.drive(system)
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.8s]

Compute the energy (and demonstrate that the energy decreased) and plot its magnetisation:

In [9]:
E = system.hamiltonian.energy
print("The system's energy is {} J.".format(E))

system.m.plot_plane("x")
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.5s]
The system's energy is 5.352855331445327e-20 J.
../_images/ipynb_derived_fields_17_1.png

Computing energies of individual term

For instance, the exchange energy is:

In [10]:
system.hamiltonian.exchange.energy
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.5s]
Out[10]:
1.1217019043857784e-21

We can also chack the sum of all individual energy terms and check if it the same as the total energy.

In [11]:
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))
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.5s]
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.5s]
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.5s]
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.6s]
The sum of energy terms is 5.352855331445327e-20 J.
2017/9/25 14:32: Calling OOMMF (system/system.mif) ... [0.5s]
The system's energy is 5.352855331445327e-20 J.