/
doc.txt
105 lines (73 loc) · 3.33 KB
/
doc.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
.. _Example: Uniaxial anisotropy:
Example: Uniaxial anisotropy
----------------------------
In this example we would like to simulate the development of a Bloch type
domain wall on a thin cobalt bar of dimension 504 x 1 x 1 nm
(:download:`bar.nmesh.h5 </example_uniaxial_anis/bar.nmesh.h5>`) due to uniaxial
anisotropy.
.. _Uniaxial anisotropy simulation script:
Uniaxial anisotropy simulation script
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. include:: bar.py
:literal:
We shall now discuss the :download:`bar.py </example_uniaxial_anis/bar.py>` script
step-by-step:
In this particular example we are solely interested in energy terms resulting
from exchange interaction and anisotropy. Hence we disable the demagnetisation
field as follows::
sim = nmag.Simulation(do_demag=False)
We then create the material ``Co`` used for the bar, cobalt in this case, which exhibits :ref:`uniaxial_anisotropy` in z direction with phenomenological anisotropy constant
``K1 = SI(520e3, "J/m^3")``::
Co = nmag.MagMaterial(name="Co",
Ms=SI(1400e3, "A/m"),
exchange_coupling=SI(30e-12, "J/m"),
anisotropy=nmag.uniaxial_anisotropy(axis=[0, 0, 1], K1=SI(520e3, "J/m^3")))
After loading the mesh, we set the initial magnetisation direction such that
it rotates from +z to -z while staying in the plane normal to x direction
(hence suggesting the development of a Bloch type domain wall)::
def sample_m0((x, y, z)):
# relative_position goes linearly from -1 to +1 in region B
relative_position = -2*(x - offset)/length + 1
mz = min(1.0, max(-1.0, relative_position))
return [0, math.sqrt(1 - mz*mz), mz]
We further pin the magnetisation at the very left (x < offset = 2 nm)
and right (x > offset + length = 502 nm) of the bar
(note that the pinning function may also just return a python truth
value rather than the number 0.0 or 1.0)::
def sample_pinning((x, y, z)):
return x >= offset and x <= offset + length
sim.set_pinning(sample_pinning)
Finally, we relax the system to find the equilibrium magnetisation
configuration, which is saved to the file ``bar_mag_x.dat`` in a format
understandable by `Gnuplot`_.
.. _Visualization:
Visualization
~~~~~~~~~~~~~
We can then use the following `Gnuplot`_ script to visualize
the equilibrium magnetisation:
.. include:: bar_mag_x.gnu
:literal:
The resulting plot clearly shows that a Bloch type domain wall has developed:
.. image:: /example_uniaxial_anis/bar_mag_x.png
:align: center
:width: 800
:height: 600
The figure shows also that the Bloch domain wall is well localized at the center
of the bar, in the region where x goes from 200 to 300 nm.
.. _Comparison:
Comparison
~~~~~~~~~~
After simulating the same scenario with
OOMMF (see :download:`oommf/bar.mif </example_uniaxial_anis/oommf/bar.mif>`),
we can compare results using another `Gnuplot`_ script:
.. include:: bar_mag_x_compared.gnu
:literal:
which generates the following plot showing good agreement of both systems:
.. image:: /example_uniaxial_anis/bar_mag_x_compared.png
:align: center
:width: 800
:height: 600
The plot shows also the known analytical solution::
Mz(x) = Ms * cos(pi/2 + atan(sinh((x - x_wall)/sqrt(A/K1))))
The plot shows only a restricted region located at the center of the bar,
thus allowing an easier comparison between the three sets of data.