Micromagnetic standard problem 4

Author: Marijan Beg, Marc-Antonio Bisotti

Date: 18 Mar 2016

This notebook can be downloaded from the github repository, found here.

[1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

Problem specification

The simulated sample is a thin film cuboid with dimensions: - length \(L = 500 \,\text{nm}\), - width \(d = 125 \,\text{nm}\), and - thickness \(t = 3 \,\text{nm}\).

[2]:
from fidimag.common import CuboidMesh
mesh = CuboidMesh(nx=160, ny=40, nz=1, dx=3.125, dy=3.125, dz=3, unit_length=1e-9)

The material parameters (similar to permalloy) are:

  • exchange energy constant \(A = 1.3 \times 10^{-11} \,\text{J/m}\),
  • magnetisation saturation \(M_\text{s} = 8 \times 10^{5} \,\text{A/m}\).

Magnetisation dynamics is governed by the Landau-Lifshitz-Gilbert equation

\[\frac{d\mathbf{m}}{dt} = -\gamma_{0}(\mathbf{m} \times \mathbf{H}_\text{eff}) + \alpha\left(\mathbf{m} \times \frac{d\mathbf{m}}{dt}\right)\]

where \(\gamma_{0} = 2.211 \times 10^{5} \,\text{m}\,\text{A}^{-1}\,\text{s}^{-1}\) is the gyromagnetic ratio and \(\alpha=0.02\) is the Gilbert damping.

[3]:
A = 13e-12
Ms = 8.0e5
alpha = 0.02
gamma = 2.211e5

In the standard problem 4, the system is firstly relaxed at zero external magnetic field and then, stating from the obtained equlibrium configuration, the magnetisation dynamics is simulated for each of two different external magnetic fields:

  1. \(\mathbf{H}_{1} = (-24.6, 4.3, 0.0) \,\text{mT}\)
  2. \(\mathbf{H}_{2} = (-35.5, -6.3, 0.0) \,\text{mT}\)

The micromagnetic standard problem 4 specification can be also found in Ref. 1.

Simulation

Getting the Initial Magnetisation

The simulation object is created and parameters set.

[4]:
from fidimag.micro import Sim, UniformExchange, Demag, Zeeman, TimeZeeman

sim = Sim(mesh)  # create simulation object

sim.driver.set_tols(rtol=1e-10, atol=1e-10)
sim.Ms = Ms
sim.driver.alpha = 0.5  # large value since the magnetisation dynamics is not important in the relexation stage
sim.driver.gamma = gamma
sim.driver.do_precession = False  # speeds up the simulation


# Starting magnetisation.
sim.set_m((1, 0.25, 0.1))
sim.add(UniformExchange(A=A))
sim.add(Demag())

We have ignored the decaying external field. Finally, the system can be relaxed and the obtained equilibrium configuration saved, so that it can be used as an initial state for simulating magnetisation dynamics.

[5]:
# PYTEST_VALIDATE_IGNORE_OUTPUT
sim.driver.relax(dt=1e-13, stopping_dmdt=0.01, max_steps=5000, save_m_steps=None, save_vtk_steps=None);
np.save("m0.npy", sim.spin)  # save equilibrium configuration
step=1, time=1e-13, max_dmdt=517 ode_step=0
step=2, time=2e-13, max_dmdt=510 ode_step=1.8e-14
step=3, time=3e-13, max_dmdt=502 ode_step=4.38e-14
step=4, time=4e-13, max_dmdt=495 ode_step=4.38e-14
step=5, time=5e-13, max_dmdt=489 ode_step=7.03e-14
step=6, time=6e-13, max_dmdt=482 ode_step=7.03e-14
step=7, time=7e-13, max_dmdt=476 ode_step=7.03e-14
step=8, time=8e-13, max_dmdt=470 ode_step=7.03e-14
step=9, time=9e-13, max_dmdt=464 ode_step=7.03e-14
step=10, time=1e-12, max_dmdt=459 ode_step=7.03e-14
step=11, time=1.14e-12, max_dmdt=453 ode_step=1.43e-13
step=12, time=1.29e-12, max_dmdt=445 ode_step=1.43e-13
step=13, time=1.43e-12, max_dmdt=439 ode_step=1.43e-13
step=14, time=1.57e-12, max_dmdt=433 ode_step=1.43e-13
step=15, time=1.72e-12, max_dmdt=428 ode_step=1.43e-13
step=16, time=1.86e-12, max_dmdt=422 ode_step=1.43e-13
step=17, time=2e-12, max_dmdt=417 ode_step=1.43e-13
step=18, time=2.15e-12, max_dmdt=412 ode_step=1.43e-13
step=19, time=2.29e-12, max_dmdt=407 ode_step=1.43e-13
step=20, time=2.51e-12, max_dmdt=401 ode_step=2.15e-13
step=21, time=2.72e-12, max_dmdt=394 ode_step=2.15e-13
step=22, time=2.94e-12, max_dmdt=387 ode_step=2.15e-13
step=23, time=3.15e-12, max_dmdt=381 ode_step=2.15e-13
step=24, time=3.37e-12, max_dmdt=375 ode_step=2.15e-13
step=25, time=3.58e-12, max_dmdt=369 ode_step=2.15e-13
step=26, time=3.8e-12, max_dmdt=364 ode_step=2.15e-13
step=27, time=4.01e-12, max_dmdt=358 ode_step=2.15e-13
step=28, time=4.23e-12, max_dmdt=353 ode_step=2.15e-13
step=29, time=4.44e-12, max_dmdt=348 ode_step=2.15e-13
step=30, time=4.66e-12, max_dmdt=343 ode_step=2.15e-13
step=31, time=4.87e-12, max_dmdt=338 ode_step=2.15e-13
step=32, time=5.09e-12, max_dmdt=333 ode_step=2.15e-13
step=33, time=5.3e-12, max_dmdt=328 ode_step=2.15e-13
step=34, time=5.52e-12, max_dmdt=324 ode_step=2.15e-13
step=35, time=5.73e-12, max_dmdt=320 ode_step=2.15e-13
step=36, time=5.95e-12, max_dmdt=315 ode_step=2.15e-13
step=37, time=6.16e-12, max_dmdt=311 ode_step=2.15e-13
step=38, time=6.38e-12, max_dmdt=307 ode_step=2.15e-13
step=39, time=6.59e-12, max_dmdt=303 ode_step=2.15e-13
step=40, time=6.81e-12, max_dmdt=299 ode_step=2.15e-13
step=41, time=7.02e-12, max_dmdt=295 ode_step=2.15e-13
step=42, time=7.24e-12, max_dmdt=291 ode_step=2.15e-13
step=43, time=7.45e-12, max_dmdt=288 ode_step=2.15e-13
step=44, time=7.78e-12, max_dmdt=283 ode_step=3.29e-13
step=45, time=8.11e-12, max_dmdt=278 ode_step=3.29e-13
step=46, time=8.44e-12, max_dmdt=273 ode_step=3.29e-13
step=47, time=8.77e-12, max_dmdt=268 ode_step=3.29e-13
step=48, time=9.09e-12, max_dmdt=263 ode_step=3.29e-13
step=49, time=9.42e-12, max_dmdt=258 ode_step=3.29e-13
step=50, time=9.75e-12, max_dmdt=254 ode_step=3.29e-13
step=51, time=1.01e-11, max_dmdt=249 ode_step=3.29e-13
step=52, time=1.04e-11, max_dmdt=245 ode_step=3.29e-13
step=53, time=1.07e-11, max_dmdt=240 ode_step=3.29e-13
step=54, time=1.11e-11, max_dmdt=236 ode_step=3.29e-13
step=55, time=1.14e-11, max_dmdt=232 ode_step=3.29e-13
step=56, time=1.17e-11, max_dmdt=229 ode_step=3.29e-13
step=57, time=1.21e-11, max_dmdt=225 ode_step=3.29e-13
step=58, time=1.24e-11, max_dmdt=221 ode_step=3.29e-13
step=59, time=1.27e-11, max_dmdt=218 ode_step=3.29e-13
step=60, time=1.3e-11, max_dmdt=214 ode_step=3.29e-13
step=61, time=1.34e-11, max_dmdt=211 ode_step=3.29e-13
step=62, time=1.37e-11, max_dmdt=208 ode_step=3.29e-13
step=63, time=1.4e-11, max_dmdt=204 ode_step=3.29e-13
step=64, time=1.45e-11, max_dmdt=201 ode_step=4.94e-13
step=65, time=1.5e-11, max_dmdt=196 ode_step=4.94e-13
step=66, time=1.55e-11, max_dmdt=192 ode_step=4.94e-13
step=67, time=1.6e-11, max_dmdt=188 ode_step=4.94e-13
step=68, time=1.65e-11, max_dmdt=184 ode_step=4.94e-13
step=69, time=1.7e-11, max_dmdt=180 ode_step=4.94e-13
step=70, time=1.75e-11, max_dmdt=177 ode_step=4.94e-13
step=71, time=1.8e-11, max_dmdt=173 ode_step=4.94e-13
step=72, time=1.85e-11, max_dmdt=170 ode_step=4.94e-13
step=73, time=1.9e-11, max_dmdt=167 ode_step=4.94e-13
step=74, time=1.95e-11, max_dmdt=164 ode_step=4.94e-13
step=75, time=2e-11, max_dmdt=161 ode_step=4.94e-13
step=76, time=2.04e-11, max_dmdt=159 ode_step=4.94e-13
step=77, time=2.09e-11, max_dmdt=156 ode_step=4.94e-13
step=78, time=2.17e-11, max_dmdt=153 ode_step=7.48e-13
step=79, time=2.24e-11, max_dmdt=150 ode_step=7.48e-13
step=80, time=2.32e-11, max_dmdt=147 ode_step=7.48e-13
step=81, time=2.39e-11, max_dmdt=144 ode_step=7.48e-13
step=82, time=2.47e-11, max_dmdt=141 ode_step=7.48e-13
step=83, time=2.54e-11, max_dmdt=138 ode_step=7.48e-13
step=84, time=2.62e-11, max_dmdt=136 ode_step=7.48e-13
step=85, time=2.69e-11, max_dmdt=134 ode_step=7.48e-13
step=86, time=2.77e-11, max_dmdt=131 ode_step=7.48e-13
step=87, time=2.84e-11, max_dmdt=129 ode_step=7.48e-13
step=88, time=2.92e-11, max_dmdt=127 ode_step=7.48e-13
step=89, time=2.99e-11, max_dmdt=125 ode_step=7.48e-13
step=90, time=3.07e-11, max_dmdt=124 ode_step=7.48e-13
step=91, time=3.14e-11, max_dmdt=122 ode_step=7.48e-13
step=92, time=3.22e-11, max_dmdt=120 ode_step=7.48e-13
step=93, time=3.29e-11, max_dmdt=119 ode_step=7.48e-13
step=94, time=3.37e-11, max_dmdt=118 ode_step=7.48e-13
step=95, time=3.44e-11, max_dmdt=116 ode_step=7.48e-13
step=96, time=3.52e-11, max_dmdt=115 ode_step=7.48e-13
step=97, time=3.59e-11, max_dmdt=114 ode_step=7.48e-13
step=98, time=3.67e-11, max_dmdt=113 ode_step=7.48e-13
step=99, time=3.74e-11, max_dmdt=112 ode_step=7.48e-13
step=100, time=3.82e-11, max_dmdt=111 ode_step=7.48e-13
step=101, time=3.89e-11, max_dmdt=110 ode_step=7.48e-13
step=102, time=3.97e-11, max_dmdt=109 ode_step=7.48e-13
step=103, time=4.04e-11, max_dmdt=108 ode_step=7.48e-13
step=104, time=4.12e-11, max_dmdt=107 ode_step=7.48e-13
step=105, time=4.19e-11, max_dmdt=107 ode_step=7.48e-13
step=106, time=4.26e-11, max_dmdt=106 ode_step=7.48e-13
step=107, time=4.34e-11, max_dmdt=105 ode_step=7.48e-13
step=108, time=4.41e-11, max_dmdt=104 ode_step=7.48e-13
step=109, time=4.49e-11, max_dmdt=104 ode_step=7.48e-13
step=110, time=4.56e-11, max_dmdt=103 ode_step=7.48e-13
step=111, time=4.64e-11, max_dmdt=102 ode_step=7.48e-13
step=112, time=4.71e-11, max_dmdt=102 ode_step=7.48e-13
step=113, time=4.79e-11, max_dmdt=101 ode_step=7.48e-13
step=114, time=4.86e-11, max_dmdt=101 ode_step=7.48e-13
step=115, time=4.94e-11, max_dmdt=100 ode_step=7.48e-13
step=116, time=5.01e-11, max_dmdt=99.6 ode_step=7.48e-13
step=117, time=5.09e-11, max_dmdt=99.1 ode_step=7.48e-13
step=118, time=5.16e-11, max_dmdt=98.6 ode_step=7.48e-13
step=119, time=5.24e-11, max_dmdt=98.2 ode_step=7.48e-13
step=120, time=5.31e-11, max_dmdt=97.7 ode_step=7.48e-13
step=121, time=5.39e-11, max_dmdt=97.2 ode_step=7.48e-13
step=122, time=5.46e-11, max_dmdt=96.8 ode_step=7.48e-13
step=123, time=5.54e-11, max_dmdt=96.3 ode_step=7.48e-13
step=124, time=5.61e-11, max_dmdt=95.9 ode_step=7.48e-13
step=125, time=5.69e-11, max_dmdt=95.5 ode_step=7.48e-13
step=126, time=5.8e-11, max_dmdt=95 ode_step=1.14e-12
step=127, time=5.91e-11, max_dmdt=94.4 ode_step=1.14e-12
step=128, time=6.03e-11, max_dmdt=93.8 ode_step=1.14e-12
step=129, time=6.14e-11, max_dmdt=93.2 ode_step=1.14e-12
step=130, time=6.26e-11, max_dmdt=92.7 ode_step=1.14e-12
step=131, time=6.37e-11, max_dmdt=92.2 ode_step=1.14e-12
step=132, time=6.48e-11, max_dmdt=91.6 ode_step=1.14e-12
step=133, time=6.6e-11, max_dmdt=91.1 ode_step=1.14e-12
step=134, time=6.71e-11, max_dmdt=90.6 ode_step=1.14e-12
step=135, time=6.82e-11, max_dmdt=90.1 ode_step=1.14e-12
step=136, time=6.94e-11, max_dmdt=89.6 ode_step=1.14e-12
step=137, time=7.05e-11, max_dmdt=89.2 ode_step=1.14e-12
step=138, time=7.17e-11, max_dmdt=88.7 ode_step=1.14e-12
step=139, time=7.28e-11, max_dmdt=88.2 ode_step=1.14e-12
step=140, time=7.39e-11, max_dmdt=87.8 ode_step=1.14e-12
step=141, time=7.51e-11, max_dmdt=87.3 ode_step=1.14e-12
step=142, time=7.62e-11, max_dmdt=86.9 ode_step=1.14e-12
step=143, time=7.74e-11, max_dmdt=86.4 ode_step=1.14e-12
step=144, time=7.85e-11, max_dmdt=86 ode_step=1.14e-12
step=145, time=7.96e-11, max_dmdt=85.6 ode_step=1.14e-12
step=146, time=8.08e-11, max_dmdt=85.2 ode_step=1.14e-12
step=147, time=8.19e-11, max_dmdt=84.8 ode_step=1.14e-12
step=148, time=8.3e-11, max_dmdt=84.4 ode_step=1.14e-12
step=149, time=8.42e-11, max_dmdt=84 ode_step=1.14e-12
step=150, time=8.53e-11, max_dmdt=83.5 ode_step=1.14e-12
step=151, time=8.65e-11, max_dmdt=83.1 ode_step=1.14e-12
step=152, time=8.76e-11, max_dmdt=82.7 ode_step=1.14e-12
step=153, time=8.87e-11, max_dmdt=82.3 ode_step=1.14e-12
step=154, time=8.99e-11, max_dmdt=82 ode_step=1.14e-12
step=155, time=9.1e-11, max_dmdt=81.6 ode_step=1.14e-12
step=156, time=9.21e-11, max_dmdt=81.2 ode_step=1.14e-12
step=157, time=9.33e-11, max_dmdt=80.8 ode_step=1.14e-12
step=158, time=9.44e-11, max_dmdt=80.4 ode_step=1.14e-12
step=159, time=9.56e-11, max_dmdt=80 ode_step=1.14e-12
step=160, time=9.67e-11, max_dmdt=79.6 ode_step=1.14e-12
step=161, time=9.78e-11, max_dmdt=79.3 ode_step=1.14e-12
step=162, time=9.9e-11, max_dmdt=78.9 ode_step=1.14e-12
step=163, time=1.01e-10, max_dmdt=78.4 ode_step=1.75e-12
step=164, time=1.02e-10, max_dmdt=77.8 ode_step=1.75e-12
step=165, time=1.04e-10, max_dmdt=77.3 ode_step=1.75e-12
step=166, time=1.06e-10, max_dmdt=76.7 ode_step=1.75e-12
step=167, time=1.08e-10, max_dmdt=76.1 ode_step=1.75e-12
step=168, time=1.09e-10, max_dmdt=75.6 ode_step=1.75e-12
step=169, time=1.11e-10, max_dmdt=75 ode_step=1.75e-12
step=170, time=1.13e-10, max_dmdt=74.5 ode_step=1.75e-12
step=171, time=1.15e-10, max_dmdt=74 ode_step=1.75e-12
step=172, time=1.16e-10, max_dmdt=73.4 ode_step=1.75e-12
step=173, time=1.18e-10, max_dmdt=72.9 ode_step=1.75e-12
step=174, time=1.2e-10, max_dmdt=72.4 ode_step=1.75e-12
step=175, time=1.22e-10, max_dmdt=71.8 ode_step=1.75e-12
step=176, time=1.23e-10, max_dmdt=71.3 ode_step=1.75e-12
step=177, time=1.25e-10, max_dmdt=70.8 ode_step=1.75e-12
step=178, time=1.27e-10, max_dmdt=70.3 ode_step=1.75e-12
step=179, time=1.29e-10, max_dmdt=69.8 ode_step=1.75e-12
step=180, time=1.3e-10, max_dmdt=69.3 ode_step=1.75e-12
step=181, time=1.32e-10, max_dmdt=68.8 ode_step=1.75e-12
step=182, time=1.34e-10, max_dmdt=68.3 ode_step=1.75e-12
step=183, time=1.36e-10, max_dmdt=67.8 ode_step=1.75e-12
step=184, time=1.37e-10, max_dmdt=67.3 ode_step=1.75e-12
step=185, time=1.39e-10, max_dmdt=66.8 ode_step=1.75e-12
step=186, time=1.41e-10, max_dmdt=66.3 ode_step=1.75e-12
step=187, time=1.43e-10, max_dmdt=65.8 ode_step=1.75e-12
step=188, time=1.44e-10, max_dmdt=65.3 ode_step=1.75e-12
step=189, time=1.46e-10, max_dmdt=64.8 ode_step=1.75e-12
step=190, time=1.48e-10, max_dmdt=64.4 ode_step=1.75e-12
step=191, time=1.5e-10, max_dmdt=63.9 ode_step=1.75e-12
step=192, time=1.52e-10, max_dmdt=63.3 ode_step=2.69e-12
step=193, time=1.55e-10, max_dmdt=62.6 ode_step=2.69e-12
step=194, time=1.58e-10, max_dmdt=61.9 ode_step=2.69e-12
step=195, time=1.6e-10, max_dmdt=61.2 ode_step=2.69e-12
step=196, time=1.63e-10, max_dmdt=60.5 ode_step=2.69e-12
step=197, time=1.66e-10, max_dmdt=59.8 ode_step=2.69e-12
step=198, time=1.69e-10, max_dmdt=59.1 ode_step=2.69e-12
step=199, time=1.71e-10, max_dmdt=58.4 ode_step=2.69e-12
step=200, time=1.74e-10, max_dmdt=57.8 ode_step=2.69e-12
step=201, time=1.77e-10, max_dmdt=57.1 ode_step=2.69e-12
step=202, time=1.79e-10, max_dmdt=56.5 ode_step=2.69e-12
step=203, time=1.83e-10, max_dmdt=55.7 ode_step=4.09e-12
step=204, time=1.87e-10, max_dmdt=54.7 ode_step=4.09e-12
step=205, time=1.92e-10, max_dmdt=53.8 ode_step=4.09e-12
step=206, time=1.96e-10, max_dmdt=52.8 ode_step=4.09e-12
step=207, time=2e-10, max_dmdt=51.9 ode_step=4.09e-12
step=208, time=2.04e-10, max_dmdt=51 ode_step=4.09e-12
step=209, time=2.08e-10, max_dmdt=50.2 ode_step=4.09e-12
step=210, time=2.12e-10, max_dmdt=49.3 ode_step=4.09e-12
step=211, time=2.16e-10, max_dmdt=48.5 ode_step=4.09e-12
step=212, time=2.2e-10, max_dmdt=47.6 ode_step=4.09e-12
step=213, time=2.24e-10, max_dmdt=46.8 ode_step=4.09e-12
step=214, time=2.28e-10, max_dmdt=46 ode_step=4.09e-12
step=215, time=2.32e-10, max_dmdt=45.3 ode_step=4.09e-12
step=216, time=2.37e-10, max_dmdt=44.5 ode_step=4.09e-12
step=217, time=2.41e-10, max_dmdt=43.7 ode_step=4.09e-12
step=218, time=2.45e-10, max_dmdt=43 ode_step=4.09e-12
step=219, time=2.49e-10, max_dmdt=42.3 ode_step=4.09e-12
step=220, time=2.53e-10, max_dmdt=41.6 ode_step=4.09e-12
step=221, time=2.57e-10, max_dmdt=40.9 ode_step=4.09e-12
step=222, time=2.61e-10, max_dmdt=40.2 ode_step=4.09e-12
step=223, time=2.65e-10, max_dmdt=39.5 ode_step=4.09e-12
step=224, time=2.69e-10, max_dmdt=38.9 ode_step=4.09e-12
step=225, time=2.73e-10, max_dmdt=38.2 ode_step=4.09e-12
step=226, time=2.77e-10, max_dmdt=37.6 ode_step=4.09e-12
step=227, time=2.81e-10, max_dmdt=37 ode_step=4.09e-12
step=228, time=2.86e-10, max_dmdt=36.4 ode_step=4.09e-12
step=229, time=2.9e-10, max_dmdt=35.8 ode_step=4.09e-12
step=230, time=2.94e-10, max_dmdt=35.2 ode_step=4.09e-12
step=231, time=3e-10, max_dmdt=34.5 ode_step=6.13e-12
step=232, time=3.06e-10, max_dmdt=33.6 ode_step=6.13e-12
step=233, time=3.12e-10, max_dmdt=32.8 ode_step=6.13e-12
step=234, time=3.18e-10, max_dmdt=32.1 ode_step=6.13e-12
step=235, time=3.24e-10, max_dmdt=31.3 ode_step=6.13e-12
step=236, time=3.31e-10, max_dmdt=30.6 ode_step=6.13e-12
step=237, time=3.37e-10, max_dmdt=29.9 ode_step=6.13e-12
step=238, time=3.43e-10, max_dmdt=29.3 ode_step=6.13e-12
step=239, time=3.49e-10, max_dmdt=28.6 ode_step=6.13e-12
step=240, time=3.55e-10, max_dmdt=28 ode_step=6.13e-12
step=241, time=3.61e-10, max_dmdt=27.4 ode_step=6.13e-12
step=242, time=3.67e-10, max_dmdt=27 ode_step=6.13e-12
step=243, time=3.73e-10, max_dmdt=26.6 ode_step=6.13e-12
step=244, time=3.8e-10, max_dmdt=26.2 ode_step=6.13e-12
step=245, time=3.86e-10, max_dmdt=25.8 ode_step=6.13e-12
step=246, time=3.92e-10, max_dmdt=25.4 ode_step=6.13e-12
step=247, time=3.98e-10, max_dmdt=25.1 ode_step=6.13e-12
step=248, time=4.04e-10, max_dmdt=24.7 ode_step=6.13e-12
step=249, time=4.1e-10, max_dmdt=24.3 ode_step=6.13e-12
step=250, time=4.16e-10, max_dmdt=24 ode_step=6.13e-12
step=251, time=4.22e-10, max_dmdt=23.6 ode_step=6.13e-12
step=252, time=4.29e-10, max_dmdt=23.3 ode_step=6.13e-12
step=253, time=4.35e-10, max_dmdt=22.9 ode_step=6.13e-12
step=254, time=4.41e-10, max_dmdt=22.6 ode_step=6.13e-12
step=255, time=4.51e-10, max_dmdt=22.2 ode_step=9.71e-12
step=256, time=4.6e-10, max_dmdt=21.7 ode_step=9.71e-12
step=257, time=4.7e-10, max_dmdt=21.2 ode_step=9.71e-12
step=258, time=4.8e-10, max_dmdt=20.7 ode_step=9.71e-12
step=259, time=4.89e-10, max_dmdt=20.2 ode_step=9.71e-12
step=260, time=4.99e-10, max_dmdt=19.7 ode_step=9.71e-12
step=261, time=5.09e-10, max_dmdt=19.4 ode_step=9.71e-12
step=262, time=5.19e-10, max_dmdt=19.2 ode_step=9.71e-12
step=263, time=5.28e-10, max_dmdt=19 ode_step=9.71e-12
step=264, time=5.38e-10, max_dmdt=18.8 ode_step=9.71e-12
step=265, time=5.48e-10, max_dmdt=18.7 ode_step=9.71e-12
step=266, time=5.57e-10, max_dmdt=18.5 ode_step=9.71e-12
step=267, time=5.67e-10, max_dmdt=18.3 ode_step=9.71e-12
step=268, time=5.77e-10, max_dmdt=18.1 ode_step=9.71e-12
step=269, time=5.87e-10, max_dmdt=18 ode_step=9.71e-12
step=270, time=5.96e-10, max_dmdt=17.8 ode_step=9.71e-12
step=271, time=6.06e-10, max_dmdt=17.6 ode_step=9.71e-12
step=272, time=6.16e-10, max_dmdt=17.4 ode_step=9.71e-12
step=273, time=6.25e-10, max_dmdt=17.2 ode_step=9.71e-12
step=274, time=6.35e-10, max_dmdt=17.1 ode_step=9.71e-12
step=275, time=6.45e-10, max_dmdt=16.9 ode_step=9.71e-12
step=276, time=6.54e-10, max_dmdt=16.7 ode_step=9.71e-12
step=277, time=6.64e-10, max_dmdt=16.5 ode_step=9.71e-12
step=278, time=6.74e-10, max_dmdt=16.3 ode_step=9.71e-12
step=279, time=6.84e-10, max_dmdt=16.1 ode_step=9.71e-12
step=280, time=6.93e-10, max_dmdt=15.9 ode_step=9.71e-12
step=281, time=7.03e-10, max_dmdt=15.7 ode_step=9.71e-12
step=282, time=7.13e-10, max_dmdt=15.5 ode_step=9.71e-12
step=283, time=7.22e-10, max_dmdt=15.3 ode_step=9.71e-12
step=284, time=7.32e-10, max_dmdt=15.1 ode_step=9.71e-12
step=285, time=7.42e-10, max_dmdt=14.9 ode_step=9.71e-12
step=286, time=7.52e-10, max_dmdt=14.7 ode_step=9.71e-12
step=287, time=7.61e-10, max_dmdt=14.5 ode_step=9.71e-12
step=288, time=7.71e-10, max_dmdt=14.3 ode_step=9.71e-12
step=289, time=7.81e-10, max_dmdt=14.2 ode_step=9.71e-12
step=290, time=7.9e-10, max_dmdt=14 ode_step=9.71e-12
step=291, time=8.06e-10, max_dmdt=13.7 ode_step=1.53e-11
step=292, time=8.21e-10, max_dmdt=13.4 ode_step=1.53e-11
step=293, time=8.36e-10, max_dmdt=13.1 ode_step=1.53e-11
step=294, time=8.52e-10, max_dmdt=12.8 ode_step=1.53e-11
step=295, time=8.67e-10, max_dmdt=12.5 ode_step=1.53e-11
step=296, time=8.82e-10, max_dmdt=12.2 ode_step=1.53e-11
step=297, time=8.97e-10, max_dmdt=11.9 ode_step=1.53e-11
step=298, time=9.13e-10, max_dmdt=11.6 ode_step=1.53e-11
step=299, time=9.28e-10, max_dmdt=11.3 ode_step=1.53e-11
step=300, time=9.43e-10, max_dmdt=11.1 ode_step=1.53e-11
step=301, time=9.59e-10, max_dmdt=10.8 ode_step=1.53e-11
step=302, time=9.74e-10, max_dmdt=10.5 ode_step=1.53e-11
step=303, time=9.89e-10, max_dmdt=10.2 ode_step=1.53e-11
step=304, time=1e-09, max_dmdt=9.99 ode_step=1.53e-11
step=305, time=1.02e-09, max_dmdt=9.73 ode_step=1.53e-11
step=306, time=1.04e-09, max_dmdt=9.48 ode_step=1.53e-11
step=307, time=1.05e-09, max_dmdt=9.24 ode_step=1.53e-11
step=308, time=1.07e-09, max_dmdt=9 ode_step=1.53e-11
step=309, time=1.08e-09, max_dmdt=8.76 ode_step=1.53e-11
step=310, time=1.1e-09, max_dmdt=8.54 ode_step=1.53e-11
step=311, time=1.11e-09, max_dmdt=8.32 ode_step=1.53e-11
step=312, time=1.13e-09, max_dmdt=8.1 ode_step=1.53e-11
step=313, time=1.14e-09, max_dmdt=7.89 ode_step=1.53e-11
step=314, time=1.16e-09, max_dmdt=7.68 ode_step=1.53e-11
step=315, time=1.17e-09, max_dmdt=7.48 ode_step=1.53e-11
step=316, time=1.19e-09, max_dmdt=7.28 ode_step=1.53e-11
step=317, time=1.2e-09, max_dmdt=7.09 ode_step=1.53e-11
step=318, time=1.22e-09, max_dmdt=6.91 ode_step=1.53e-11
step=319, time=1.23e-09, max_dmdt=6.72 ode_step=1.53e-11
step=320, time=1.25e-09, max_dmdt=6.54 ode_step=1.53e-11
step=321, time=1.26e-09, max_dmdt=6.37 ode_step=1.53e-11
step=322, time=1.28e-09, max_dmdt=6.2 ode_step=1.53e-11
step=323, time=1.3e-09, max_dmdt=6.04 ode_step=1.53e-11
step=324, time=1.31e-09, max_dmdt=5.88 ode_step=1.53e-11
step=325, time=1.33e-09, max_dmdt=5.72 ode_step=1.53e-11
step=326, time=1.34e-09, max_dmdt=5.57 ode_step=1.53e-11
step=327, time=1.36e-09, max_dmdt=5.42 ode_step=1.53e-11
step=328, time=1.37e-09, max_dmdt=5.28 ode_step=1.53e-11
step=329, time=1.39e-09, max_dmdt=5.14 ode_step=1.53e-11
step=330, time=1.4e-09, max_dmdt=5 ode_step=1.53e-11
step=331, time=1.43e-09, max_dmdt=4.84 ode_step=2.31e-11
step=332, time=1.45e-09, max_dmdt=4.64 ode_step=2.31e-11
step=333, time=1.47e-09, max_dmdt=4.46 ode_step=2.31e-11
step=334, time=1.49e-09, max_dmdt=4.28 ode_step=2.31e-11
step=335, time=1.52e-09, max_dmdt=4.11 ode_step=2.31e-11
step=336, time=1.54e-09, max_dmdt=3.95 ode_step=2.31e-11
step=337, time=1.56e-09, max_dmdt=3.79 ode_step=2.31e-11
step=338, time=1.59e-09, max_dmdt=3.65 ode_step=2.31e-11
step=339, time=1.61e-09, max_dmdt=3.5 ode_step=2.31e-11
step=340, time=1.63e-09, max_dmdt=3.37 ode_step=2.31e-11
step=341, time=1.66e-09, max_dmdt=3.24 ode_step=2.31e-11
step=342, time=1.68e-09, max_dmdt=3.11 ode_step=2.31e-11
step=343, time=1.7e-09, max_dmdt=2.99 ode_step=2.31e-11
step=344, time=1.73e-09, max_dmdt=2.87 ode_step=2.31e-11
step=345, time=1.75e-09, max_dmdt=2.76 ode_step=2.31e-11
step=346, time=1.77e-09, max_dmdt=2.66 ode_step=2.31e-11
step=347, time=1.8e-09, max_dmdt=2.55 ode_step=2.31e-11
step=348, time=1.82e-09, max_dmdt=2.46 ode_step=2.31e-11
step=349, time=1.84e-09, max_dmdt=2.36 ode_step=2.31e-11
step=350, time=1.86e-09, max_dmdt=2.27 ode_step=2.31e-11
step=351, time=1.89e-09, max_dmdt=2.19 ode_step=2.31e-11
step=352, time=1.91e-09, max_dmdt=2.1 ode_step=2.31e-11
step=353, time=1.93e-09, max_dmdt=2.02 ode_step=2.31e-11
step=354, time=1.96e-09, max_dmdt=1.95 ode_step=2.31e-11
step=355, time=1.98e-09, max_dmdt=1.87 ode_step=2.31e-11
step=356, time=2e-09, max_dmdt=1.8 ode_step=2.31e-11
step=357, time=2.03e-09, max_dmdt=1.74 ode_step=2.31e-11
step=358, time=2.05e-09, max_dmdt=1.67 ode_step=2.31e-11
step=359, time=2.07e-09, max_dmdt=1.61 ode_step=2.31e-11
step=360, time=2.1e-09, max_dmdt=1.55 ode_step=2.31e-11
step=361, time=2.12e-09, max_dmdt=1.49 ode_step=2.31e-11
step=362, time=2.14e-09, max_dmdt=1.44 ode_step=2.31e-11
step=363, time=2.16e-09, max_dmdt=1.38 ode_step=2.31e-11
step=364, time=2.19e-09, max_dmdt=1.33 ode_step=2.31e-11
step=365, time=2.21e-09, max_dmdt=1.28 ode_step=2.31e-11
step=366, time=2.23e-09, max_dmdt=1.23 ode_step=2.31e-11
step=367, time=2.26e-09, max_dmdt=1.19 ode_step=2.31e-11
step=368, time=2.28e-09, max_dmdt=1.15 ode_step=2.31e-11
step=369, time=2.3e-09, max_dmdt=1.1 ode_step=2.31e-11
step=370, time=2.33e-09, max_dmdt=1.06 ode_step=2.31e-11
step=371, time=2.35e-09, max_dmdt=1.02 ode_step=2.31e-11
step=372, time=2.37e-09, max_dmdt=0.988 ode_step=2.31e-11
step=373, time=2.4e-09, max_dmdt=0.952 ode_step=2.31e-11
step=374, time=2.43e-09, max_dmdt=0.909 ode_step=3.51e-11
step=375, time=2.47e-09, max_dmdt=0.859 ode_step=3.51e-11
step=376, time=2.5e-09, max_dmdt=0.812 ode_step=3.51e-11
step=377, time=2.54e-09, max_dmdt=0.768 ode_step=3.51e-11
step=378, time=2.57e-09, max_dmdt=0.727 ode_step=3.51e-11
step=379, time=2.61e-09, max_dmdt=0.688 ode_step=3.51e-11
step=380, time=2.64e-09, max_dmdt=0.651 ode_step=3.51e-11
step=381, time=2.68e-09, max_dmdt=0.616 ode_step=3.51e-11
step=382, time=2.71e-09, max_dmdt=0.583 ode_step=3.51e-11
step=383, time=2.75e-09, max_dmdt=0.552 ode_step=3.51e-11
step=384, time=2.78e-09, max_dmdt=0.522 ode_step=3.51e-11
step=385, time=2.82e-09, max_dmdt=0.494 ode_step=3.51e-11
step=386, time=2.85e-09, max_dmdt=0.468 ode_step=3.51e-11
step=387, time=2.89e-09, max_dmdt=0.443 ode_step=3.51e-11
step=388, time=2.92e-09, max_dmdt=0.42 ode_step=3.51e-11
step=389, time=2.96e-09, max_dmdt=0.397 ode_step=3.51e-11
step=390, time=2.99e-09, max_dmdt=0.376 ode_step=3.51e-11
step=391, time=3.03e-09, max_dmdt=0.357 ode_step=3.51e-11
step=392, time=3.06e-09, max_dmdt=0.338 ode_step=3.51e-11
step=393, time=3.1e-09, max_dmdt=0.32 ode_step=3.51e-11
step=394, time=3.13e-09, max_dmdt=0.303 ode_step=3.51e-11
step=395, time=3.17e-09, max_dmdt=0.287 ode_step=3.51e-11
step=396, time=3.2e-09, max_dmdt=0.272 ode_step=3.51e-11
step=397, time=3.24e-09, max_dmdt=0.258 ode_step=3.51e-11
step=398, time=3.27e-09, max_dmdt=0.245 ode_step=3.51e-11
step=399, time=3.31e-09, max_dmdt=0.232 ode_step=3.51e-11
step=400, time=3.34e-09, max_dmdt=0.22 ode_step=3.51e-11
step=401, time=3.38e-09, max_dmdt=0.208 ode_step=3.51e-11
step=402, time=3.42e-09, max_dmdt=0.197 ode_step=3.51e-11
step=403, time=3.45e-09, max_dmdt=0.187 ode_step=3.51e-11
step=404, time=3.49e-09, max_dmdt=0.177 ode_step=3.51e-11
step=405, time=3.52e-09, max_dmdt=0.168 ode_step=3.51e-11
step=406, time=3.56e-09, max_dmdt=0.159 ode_step=3.51e-11
step=407, time=3.59e-09, max_dmdt=0.151 ode_step=3.51e-11
step=408, time=3.63e-09, max_dmdt=0.143 ode_step=3.51e-11
step=409, time=3.66e-09, max_dmdt=0.136 ode_step=3.51e-11
step=410, time=3.7e-09, max_dmdt=0.129 ode_step=3.51e-11
step=411, time=3.76e-09, max_dmdt=0.12 ode_step=5.91e-11
step=412, time=3.81e-09, max_dmdt=0.11 ode_step=5.91e-11
step=413, time=3.87e-09, max_dmdt=0.101 ode_step=5.91e-11
step=414, time=3.93e-09, max_dmdt=0.092 ode_step=5.91e-11
step=415, time=3.99e-09, max_dmdt=0.0841 ode_step=5.91e-11
step=416, time=4.05e-09, max_dmdt=0.077 ode_step=5.91e-11
step=417, time=4.11e-09, max_dmdt=0.0705 ode_step=5.91e-11
step=418, time=4.17e-09, max_dmdt=0.0645 ode_step=5.91e-11
step=419, time=4.23e-09, max_dmdt=0.059 ode_step=5.91e-11
step=420, time=4.29e-09, max_dmdt=0.054 ode_step=5.91e-11
step=421, time=4.35e-09, max_dmdt=0.0494 ode_step=5.91e-11
step=422, time=4.41e-09, max_dmdt=0.0453 ode_step=5.91e-11
step=423, time=4.47e-09, max_dmdt=0.0414 ode_step=5.91e-11
step=424, time=4.52e-09, max_dmdt=0.0379 ode_step=5.91e-11
step=425, time=4.58e-09, max_dmdt=0.0347 ode_step=5.91e-11
step=426, time=4.64e-09, max_dmdt=0.0318 ode_step=5.91e-11
step=427, time=4.7e-09, max_dmdt=0.0291 ode_step=5.91e-11
step=428, time=4.76e-09, max_dmdt=0.0267 ode_step=5.91e-11
step=429, time=4.82e-09, max_dmdt=0.0244 ode_step=5.91e-11
step=430, time=4.88e-09, max_dmdt=0.0224 ode_step=5.91e-11
step=431, time=4.94e-09, max_dmdt=0.0205 ode_step=5.91e-11
step=432, time=5e-09, max_dmdt=0.0187 ode_step=5.91e-11
step=433, time=5.09e-09, max_dmdt=0.0168 ode_step=8.9e-11
step=434, time=5.18e-09, max_dmdt=0.0147 ode_step=8.9e-11
step=435, time=5.26e-09, max_dmdt=0.0129 ode_step=8.9e-11
step=436, time=5.35e-09, max_dmdt=0.0113 ode_step=8.9e-11
step=437, time=5.44e-09, max_dmdt=0.0099 ode_step=8.9e-11

We not plot the magnetisation configuration,

[6]:
# PYTEST_VALIDATE_IGNORE_OUTPUT
m = sim.spin
m.shape = (-1,3)
mx = m[:,0]
my = m[:,1]
mx.shape = (40, 160)
my.shape = (40, 160)
fig = plt.figure(figsize=(15,5))
plt.axes().set_aspect('equal')
plt.quiver(mx[1::4,1::4], my[::4,::4], my[::4,::4], pivot='mid', alpha=0.9, scale=45, cmap=plt.get_cmap('jet'), edgecolors='None' )
plt.xlim([-0.5,39.5])
plt.xticks([])
plt.yticks([])
plt.show()
print(np.average(m[:,:], axis=0))
../_images/ipynb_standard_problem_4_15_0.png
[  9.66821767e-01   1.25543432e-01   3.11232500e-18]

With the obtained relaxed magnetisation, the magnetisation evolution can be simulated for the two different external magnetic fields using the following function:

[7]:
def field_simulation(H, name):
    print(name)
    sim = Sim(mesh, name)
    sim.driver.alpha = alpha
    sim.driver.gamma = gamma
    sim.Ms = Ms
    sim.add(UniformExchange(A=A))
    sim.add(Demag())
    sim.add(Zeeman(H))
    sim.set_m(np.load('m0.npy'))  # load the equilibrium magnetisation from the previous step

    timesteps = np.linspace(0, 0.2e-9, 21)
    for i, t in enumerate(timesteps):
        sim.driver.run_until(t)
        if i % 10 == 0:
            print("\tsimulated {} s".format(t))

Using the created field_simulation function, we obtain the average magnetisation components time evolutions. Note that we only run the simulation for a short time, a full version of this standard problem 4 can be found in folder examples/micromagnetic/std4.

[8]:
# PYTEST_VALIDATE_IGNORE_OUTPUT
mu0 = 4 * np.pi * 1e-7  # magnetic constant (H/m)
mT = 1e-3 / mu0  # millitesla

field_simulation([-24.6 * mT,  4.3 * mT, 0], "field_1")
#field_simulation([-35.5 * mT, -6.3 * mT, 0], "field_2")
field_1
        simulated 0.0 s
        simulated 1e-10 s
        simulated 2e-10 s

We could have saved the magnetisation dynamics in python objects on the fly. Instead, we chose to make use of fidimag’s automatic saving capabilities and will now read our simulation results back in.

[9]:
# PYTEST_VALIDATE_IGNORE_OUTPUT
import matplotlib.pyplot as plt
%matplotlib inline
from fidimag.common.fileio import DataReader

def do_plot(data_name):
    dynamics = DataReader(data_name)
    # we could load the data with np.loadtxt, but using the DataReader gives
    # us the possibility to use the column headers to access our data
    fig = plt.figure(figsize=(8, 6))
    axes = fig.add_subplot(111)
    axes.plot(dynamics["time"] * 1e9, dynamics["m_x"], "b-", label="m_x")
    axes.plot(dynamics["time"] * 1e9, dynamics["m_y"], "r--", label="m_y")
    axes.plot(dynamics["time"] * 1e9, dynamics["m_z"], "g--", label="m_z")
    axes.set_xlabel("time (ns)")
    axes.set_xlim((0, 0.25))
    axes.set_ylabel("unit magnetisation (1)")
    axes.set_ylim((-1.05, 1))
    axes.legend()
    plt.show()

do_plot('field_1.txt')
../_images/ipynb_standard_problem_4_21_0.png

References

[1] muMAG Micromagnetics Website. URL: http://www.ctcms.nist.gov/~rdm/mumag.org.html (Date of access: 26/02/2016)