Tutorial 3 - Dynamics

The dynamics of magnetisation field $\mathbf{m}$ is governed by the Landau-Lifshitz-Gilbert (LLG) equation

$$\frac{d\mathbf{m}}{dt} = \underbrace{-\gamma_{0}(\mathbf{m} \times \mathbf{H}_\text{eff})}_\text{precession} + \underbrace{\alpha\left(\mathbf{m} \times \frac{d\mathbf{m}}{dt}\right)}_\text{damping},$$

where $\gamma_{0}$ is the gyromagnetic ratio, $\alpha$ is the Gilbert damping, and $\mathbf{H}_\text{eff}$ is the effective field. It consists of two terms: precession and damping. In this exercise, we will explore some basic properties of this equation to understand how to define it in simulations.

We will study the simplest "zero-dimensional" case - macrospin. In the first step, after we import necessary modules (oommfc and discretisedfield), we create the mesh which consists of a single finite difference cell.


In [1]:
import oommfc as oc
import discretisedfield as df
%matplotlib inline

# Define macro spin mesh (i.e. one discretisation cell).
p1 = (0, 0, 0)  # first point of the mesh domain (m)
p2 = (1e-9, 1e-9, 1e-9)  # second point of the mesh domain (m)
cell = (1e-9, 1e-9, 1e-9)  # discretisation cell size (m)
mesh = oc.Mesh(p1=p1, p2=p2, cell=cell)

Now, we can create a micromagnetic system object.


In [2]:
system = oc.System(name="macrospin")

Let us assume we have a simple Hamiltonian which consists of only Zeeman energy term

$$\mathcal{H} = -\mu_{0}M_\text{s}\mathbf{m}\cdot\mathbf{H},$$

where $M_\text{s}$ is the saturation magnetisation, $\mu_{0}$ is the magnetic constant, and $\mathbf{H}$ is the external magnetic field. For more information on defining micromagnetic Hamiltonians, please refer to the Hamiltonian tutorial. We apply the external magnetic field with magnitude $H = 2 \times 10^{6} \,\text{A}\,\text{m}^{-1}$ in the positive $z$ direction.


In [3]:
H = (0, 0, 2e6)  # external magnetic field (A/m)
system.hamiltonian = oc.Zeeman(H=H)

In the next step we can define the system's dynamics. Let us assume we have $\gamma_{0} = 2.211 \times 10^{5} \,\text{m}\,\text{A}^{-1}\,\text{s}^{-1}$ and $\alpha=0.1$.


In [4]:
gamma = 2.211e5  # gyromagnetic ratio (m/As)
alpha = 0.1  # Gilbert damping

system.dynamics = oc.Precession(gamma=gamma) + oc.Damping(alpha=alpha)

To check what is our dynamics equation:


In [5]:
system.dynamics


Out[5]:
$\frac{\partial \mathbf{m}}{\partial t}=-\gamma \mathbf{m} \times \mathbf{H}_\text{eff}+\alpha \mathbf{m} \times\frac{\partial \mathbf{m}}{\partial t}$

Before we start running time evolution simulations, we need to initialise the magnetisation. In this case, our magnetisation is pointing in the positive $x$ direction with $M_\text{s} = 8 \times 10^{6} \,\text{A}\,\text{m}^{-1}$. The magnetisation is defined using Field class from the discretisedfield package we imported earlier.


In [6]:
initial_m = (1, 0, 0)  # vector in x direction
Ms = 8e6  # magnetisation saturation (A/m)

system.m = df.Field(mesh, value=initial_m, norm=Ms)

Now, we can run the time evolution using TimeDriver for $t=0.1 \,\text{ns}$ and save the magnetisation configuration in $n=200$ steps.


In [7]:
td = oc.TimeDriver()

td.drive(system, t=0.1e-9, n=200)


2017/4/4 23:11: Calling OOMMF (macrospin/macrospin.mif) ... [1.8s]

How different system parameters vary with time, we can inspect by showing the system's datatable.


In [8]:
system.dt


Out[8]:
E Ecount max_dm/dt dE/dt deltaE FixedZeeman:zeeman:Energy iteration stage_iteration stage mx my mz last_time_step t
0 -4.400762e-22 37.0 25204.415522 -8.798712e-10 -3.269612e-22 -4.400762e-22 6.0 6.0 0.0 0.975901 0.217115 0.021888 3.715017e-13 5.000000e-13
1 -8.797309e-22 44.0 25186.311578 -8.786077e-10 -4.396547e-22 -8.797309e-22 8.0 1.0 1.0 0.904810 0.423562 0.043754 5.000000e-13 1.000000e-12
2 -1.318544e-21 51.0 25156.186455 -8.765071e-10 -4.388134e-22 -1.318544e-21 10.0 1.0 2.0 0.790286 0.609218 0.065579 5.000000e-13 1.500000e-12
3 -1.756100e-21 58.0 25114.112032 -8.735776e-10 -4.375555e-22 -1.756100e-21 12.0 1.0 3.0 0.638055 0.765021 0.087341 5.000000e-13 2.000000e-12
4 -2.191985e-21 65.0 25060.188355 -8.698302e-10 -4.358857e-22 -2.191985e-21 14.0 1.0 4.0 0.455710 0.883427 0.109020 5.000000e-13 2.500000e-12
5 -2.625796e-21 72.0 24994.543058 -8.652792e-10 -4.338104e-22 -2.625796e-21 16.0 1.0 5.0 0.252321 0.958790 0.130596 5.000000e-13 3.000000e-12
6 -3.057133e-21 79.0 24917.330629 -8.599414e-10 -4.313375e-22 -3.057133e-21 18.0 1.0 6.0 0.037964 0.987644 0.152049 5.000000e-13 3.500000e-12
7 -3.485609e-21 86.0 24828.731532 -8.538369e-10 -4.284760e-22 -3.485609e-21 20.0 1.0 7.0 -0.176794 0.968860 0.173360 5.000000e-13 4.000000e-12
8 -3.910846e-21 93.0 24728.951193 -8.469880e-10 -4.252366e-22 -3.910846e-21 22.0 1.0 8.0 -0.381440 0.903698 0.194510 5.000000e-13 4.500000e-12
9 -4.332477e-21 100.0 24618.218851 -8.394196e-10 -4.216312e-22 -4.332477e-21 24.0 1.0 9.0 -0.566044 0.795715 0.215480 5.000000e-13 5.000000e-12
10 -4.750150e-21 107.0 24496.786302 -8.311589e-10 -4.176728e-22 -4.750150e-21 26.0 1.0 10.0 -0.721760 0.650574 0.236253 5.000000e-13 5.500000e-12
11 -5.163525e-21 114.0 24364.926541 -8.222352e-10 -4.133754e-22 -5.163525e-21 28.0 1.0 11.0 -0.841265 0.475731 0.256813 5.000000e-13 6.000000e-12
12 -5.572279e-21 121.0 24222.932304 -8.126794e-10 -4.087542e-22 -5.572279e-21 30.0 1.0 12.0 -0.919113 0.280042 0.277142 5.000000e-13 6.500000e-12
13 -5.976105e-21 128.0 24071.114545 -8.025244e-10 -4.038251e-22 -5.976105e-21 32.0 1.0 13.0 -0.951989 0.073295 0.297227 5.000000e-13 7.000000e-12
14 -6.374709e-21 135.0 23909.800852 -7.918041e-10 -3.986048e-22 -6.374709e-21 34.0 1.0 14.0 -0.938853 -0.134288 0.317052 5.000000e-13 7.500000e-12
15 -6.767820e-21 142.0 23739.333804 -7.805539e-10 -3.931107e-22 -6.767820e-21 36.0 1.0 15.0 -0.880958 -0.332583 0.336604 5.000000e-13 8.000000e-12
16 -7.155181e-21 149.0 23560.069311 -7.688099e-10 -3.873606e-22 -7.155181e-21 38.0 1.0 16.0 -0.781759 -0.512064 0.355869 5.000000e-13 8.500000e-12
17 -7.536553e-21 156.0 23372.374925 -7.566091e-10 -3.813728e-22 -7.536553e-21 40.0 1.0 17.0 -0.646706 -0.664281 0.374837 5.000000e-13 9.000000e-12
18 -7.911719e-21 163.0 23176.628147 -7.439887e-10 -3.751659e-22 -7.911719e-21 42.0 1.0 18.0 -0.482933 -0.782263 0.393497 5.000000e-13 9.500000e-12
19 -8.280478e-21 170.0 22973.214749 -7.309866e-10 -3.687587e-22 -8.280478e-21 44.0 1.0 19.0 -0.298880 -0.860849 0.411837 5.000000e-13 1.000000e-11
20 -8.642648e-21 177.0 22762.527105 -7.176403e-10 -3.621700e-22 -8.642648e-21 46.0 1.0 20.0 -0.103838 -0.896909 0.429850 5.000000e-13 1.050000e-11
21 -8.998067e-21 184.0 22544.962562 -7.039874e-10 -3.554187e-22 -8.998067e-21 48.0 1.0 21.0 0.092526 -0.889471 0.447527 5.000000e-13 1.100000e-11
22 -9.346590e-21 191.0 22320.921854 -6.900652e-10 -3.485234e-22 -9.346590e-21 50.0 1.0 22.0 0.280664 -0.839721 0.464861 5.000000e-13 1.150000e-11
23 -9.688093e-21 198.0 22090.807560 -6.759102e-10 -3.415026e-22 -9.688093e-21 52.0 1.0 23.0 0.451621 -0.750908 0.481846 5.000000e-13 1.200000e-11
24 -1.002247e-20 205.0 21855.022629 -6.615587e-10 -3.343744e-22 -1.002247e-20 54.0 1.0 24.0 0.597469 -0.628134 0.498477 5.000000e-13 1.250000e-11
25 -1.034962e-20 212.0 21613.968974 -6.470456e-10 -3.271568e-22 -1.034962e-20 56.0 1.0 25.0 0.711683 -0.478061 0.514748 5.000000e-13 1.300000e-11
26 -1.066949e-20 219.0 21368.046130 -6.324053e-10 -3.198671e-22 -1.066949e-20 58.0 1.0 26.0 0.789431 -0.308547 0.530657 5.000000e-13 1.350000e-11
27 -1.098201e-20 226.0 21117.650007 -6.176707e-10 -3.125220e-22 -1.098201e-20 60.0 1.0 27.0 0.827782 -0.128225 0.546201 5.000000e-13 1.400000e-11
28 -1.128715e-20 233.0 20863.171708 -6.028739e-10 -3.051379e-22 -1.128715e-20 62.0 1.0 28.0 0.825800 0.053944 0.561377 5.000000e-13 1.450000e-11
29 -1.158488e-20 240.0 20604.996449 -5.880455e-10 -2.977303e-22 -1.158488e-20 64.0 1.0 29.0 0.784547 0.229122 0.576185 5.000000e-13 1.500000e-11
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
170 -2.008367e-20 1227.0 1193.004741 -1.971288e-12 -1.007512e-24 -2.008367e-20 346.0 1.0 170.0 0.045666 -0.012410 0.998880 5.000000e-13 8.550000e-11
171 -2.008463e-20 1234.0 1167.200407 -1.886934e-12 -9.644002e-25 -2.008463e-20 348.0 1.0 171.0 0.046248 -0.002149 0.998928 5.000000e-13 8.600000e-11
172 -2.008556e-20 1241.0 1141.953041 -1.806185e-12 -9.231310e-25 -2.008556e-20 350.0 1.0 172.0 0.044625 0.007774 0.998974 5.000000e-13 8.650000e-11
173 -2.008644e-20 1248.0 1117.250693 -1.728889e-12 -8.836261e-25 -2.008644e-20 352.0 1.0 173.0 0.040966 0.016906 0.999018 5.000000e-13 8.700000e-11
174 -2.008728e-20 1255.0 1093.081670 -1.654897e-12 -8.458102e-25 -2.008728e-20 354.0 1.0 174.0 0.035531 0.024849 0.999060 5.000000e-13 8.750000e-11
175 -2.008809e-20 1262.0 1069.434522 -1.584070e-12 -8.096112e-25 -2.008809e-20 356.0 1.0 175.0 0.028653 0.031281 0.999100 5.000000e-13 8.800000e-11
176 -2.008887e-20 1269.0 1046.298041 -1.516270e-12 -7.749600e-25 -2.008887e-20 358.0 1.0 176.0 0.020718 0.035961 0.999138 5.000000e-13 8.850000e-11
177 -2.008961e-20 1276.0 1023.661257 -1.451371e-12 -7.417906e-25 -2.008961e-20 360.0 1.0 177.0 0.012146 0.038746 0.999175 5.000000e-13 8.900000e-11
178 -2.009032e-20 1283.0 1001.513431 -1.389247e-12 -7.100398e-25 -2.009032e-20 362.0 1.0 178.0 0.003367 0.039583 0.999211 5.000000e-13 8.950000e-11
179 -2.009100e-20 1290.0 979.844052 -1.329780e-12 -6.796470e-25 -2.009100e-20 364.0 1.0 179.0 -0.005195 0.038518 0.999244 5.000000e-13 9.000000e-11
180 -2.009165e-20 1297.0 958.642831 -1.272857e-12 -6.505542e-25 -2.009165e-20 366.0 1.0 180.0 -0.013145 0.035681 0.999277 5.000000e-13 9.050000e-11
181 -2.009227e-20 1304.0 937.899698 -1.218368e-12 -6.227058e-25 -2.009227e-20 368.0 1.0 181.0 -0.020135 0.031283 0.999308 5.000000e-13 9.100000e-11
182 -2.009287e-20 1311.0 917.604797 -1.166211e-12 -5.960487e-25 -2.009287e-20 370.0 1.0 182.0 -0.025875 0.025598 0.999337 5.000000e-13 9.150000e-11
183 -2.009344e-20 1318.0 897.748481 -1.116285e-12 -5.705320e-25 -2.009344e-20 372.0 1.0 183.0 -0.030150 0.018949 0.999366 5.000000e-13 9.200000e-11
184 -2.009399e-20 1325.0 878.321307 -1.068495e-12 -5.461070e-25 -2.009399e-20 374.0 1.0 184.0 -0.032820 0.011690 0.999393 5.000000e-13 9.250000e-11
185 -2.009451e-20 1332.0 859.314035 -1.022750e-12 -5.227271e-25 -2.009451e-20 376.0 1.0 185.0 -0.033827 0.004191 0.999419 5.000000e-13 9.300000e-11
186 -2.009501e-20 1339.0 840.717621 -9.789627e-13 -5.003475e-25 -2.009501e-20 378.0 1.0 186.0 -0.033196 -0.003184 0.999444 5.000000e-13 9.350000e-11
187 -2.009549e-20 1346.0 822.523214 -9.370487e-13 -4.789255e-25 -2.009549e-20 380.0 1.0 187.0 -0.031026 -0.010094 0.999468 5.000000e-13 9.400000e-11
188 -2.009595e-20 1353.0 804.722150 -8.969284e-13 -4.584202e-25 -2.009595e-20 382.0 1.0 188.0 -0.027485 -0.016232 0.999490 5.000000e-13 9.450000e-11
189 -2.009639e-20 1360.0 787.305953 -8.585249e-13 -4.387925e-25 -2.009639e-20 384.0 1.0 189.0 -0.022800 -0.021341 0.999512 5.000000e-13 9.500000e-11
190 -2.009681e-20 1367.0 770.266326 -8.217651e-13 -4.200047e-25 -2.009681e-20 386.0 1.0 190.0 -0.017240 -0.025225 0.999533 5.000000e-13 9.550000e-11
191 -2.009721e-20 1374.0 753.595150 -7.865784e-13 -4.020209e-25 -2.009721e-20 388.0 1.0 191.0 -0.011104 -0.027753 0.999553 5.000000e-13 9.600000e-11
192 -2.009759e-20 1381.0 737.284479 -7.528978e-13 -3.848069e-25 -2.009759e-20 390.0 1.0 192.0 -0.004708 -0.028864 0.999572 5.000000e-13 9.650000e-11
193 -2.009796e-20 1388.0 721.326537 -7.206587e-13 -3.683296e-25 -2.009796e-20 392.0 1.0 193.0 0.001636 -0.028565 0.999591 5.000000e-13 9.700000e-11
194 -2.009831e-20 1395.0 705.713715 -6.897996e-13 -3.525576e-25 -2.009831e-20 394.0 1.0 194.0 0.007632 -0.026932 0.999608 5.000000e-13 9.750000e-11
195 -2.009865e-20 1402.0 690.438568 -6.602614e-13 -3.374608e-25 -2.009865e-20 396.0 1.0 195.0 0.013011 -0.024099 0.999625 5.000000e-13 9.800000e-11
196 -2.009897e-20 1409.0 675.493807 -6.319876e-13 -3.230101e-25 -2.009897e-20 398.0 1.0 196.0 0.017545 -0.020251 0.999641 5.000000e-13 9.850000e-11
197 -2.009928e-20 1416.0 660.872303 -6.049242e-13 -3.091780e-25 -2.009928e-20 400.0 1.0 197.0 0.021059 -0.015612 0.999656 5.000000e-13 9.900000e-11
198 -2.009958e-20 1423.0 646.567078 -5.790193e-13 -2.959381e-25 -2.009958e-20 402.0 1.0 198.0 0.023428 -0.010435 0.999671 5.000000e-13 9.950000e-11
199 -2.009986e-20 1430.0 632.571305 -5.542233e-13 -2.832649e-25 -2.009986e-20 404.0 1.0 199.0 0.024591 -0.004988 0.999685 5.000000e-13 1.000000e-10

200 rows × 14 columns

However, in our case it is much more informative if we plot the time evolution of magnetisation $z$ component $m_{z}(t)$.


In [9]:
system.dt.plot("t", "mz");


Similarly, we can plot all three magnetisation components


In [10]:
system.dt.plot("t", ["mx", "my", "mz"]);


We can see that after some time the macrospin aligns parallel to the external magnetic field in the $z$ direction. We can explore the effect of Gilbert damping $\alpha = 0.2$ on the magnetisation dynamics.


In [11]:
system.dynamics.damping.alpha = 0.2
system.m = df.Field(mesh, value=initial_m, norm=Ms)

td.drive(system, t=0.1e-9, n=200)

system.dt.plot("t", ["mx", "my", "mz"]);


2017/4/4 23:11: Calling OOMMF (macrospin/macrospin.mif) ... [2.3s]

Exercise 1

By looking at the previous example, explore the magnetisation dynamics for $\alpha=0.005$ in the following code cell.


In [ ]:

Exercise 2

Repeat the simulation with $\alpha=0.1$ and H = (0, 0, -2e6).


In [ ]:

Exercise 3 (optional)

Keep using $\alpha=0.1$.

Change the field from H = (0, 0, -2e6) to H = (0, -1.41e6, -1.41e6), and plot $m_x(t)$, $m_y(t)$ and $m_z(t)$ as above. Can you explain the (initially non-intuitive) output?


In [ ]: