Skip to content

Commit e07131a

Browse files
author
Weiwei Wang
committed
add atomistic version of stt
1 parent d3d5682 commit e07131a

File tree

5 files changed

+100
-6
lines changed

5 files changed

+100
-6
lines changed

fidimag/atomistic/llg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ def set_mu_s(self, value):
156156
# Set the neighbour index to -1 for sites with mu_s = 0
157157
self.mesh.neighbours[self.mesh.neighbours == i] = -1
158158

159+
self.mu_s_const = np.max(self._mu_s)
160+
159161
mu_s = property(get_mu_s, set_mu_s)
160162

161163
def add(self, interaction, save_field=False):

fidimag/atomistic/llg_stt.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
from __future__ import division
2+
3+
import fidimag.extensions.clib as clib
4+
import numpy as np
5+
6+
from .llg import LLG
7+
import fidimag.common.helper as helper
8+
import fidimag.common.constant as const
9+
10+
11+
class LLG_STT(LLG):
12+
13+
def __init__(self, mesh, name='unnamed'):
14+
"""Simulation object.
15+
16+
*Arguments*
17+
18+
name : the Simulation name (used for writing data files, for examples)
19+
20+
"""
21+
super(LLG_STT, self).__init__(mesh, name=name)
22+
23+
self.field_stt = np.zeros(3 * self.n)
24+
25+
self._jx = np.zeros(self.n, dtype=np.float)
26+
self._jy = np.zeros(self.n, dtype=np.float)
27+
28+
self.p = 0.5
29+
self.beta = 0
30+
self.update_j_fun = None
31+
32+
# FIXME: change the u0 to spatial
33+
self.u0 = const.g_e * const.mu_B / (2 * const.c_e)
34+
35+
def get_jx(self):
36+
return self._jx
37+
38+
def set_jx(self, value):
39+
self._jx[:] = helper.init_scalar(value, self.mesh)
40+
41+
jx = property(get_jx, set_jx)
42+
43+
def get_jy(self):
44+
return self._jy
45+
46+
def set_jy(self, value):
47+
self._jy[:] = helper.init_scalar(value, self.mesh)
48+
49+
jy = property(get_jy, set_jy)
50+
51+
def sundials_rhs(self, t, y, ydot):
52+
53+
self.t = t
54+
55+
# already synchronized when call this funciton
56+
# self.spin[:]=y[:]
57+
58+
self.compute_effective_field(t)
59+
60+
if self.update_j_fun is not None:
61+
clib.compute_stt_field(self.spin,
62+
self.field_stt,
63+
self._jx * self.update_j_fun(t),
64+
self._jy * self.update_j_fun(t),
65+
self.mesh.dx * self.mesh.unit_length,
66+
self.mesh.dy * self.mesh.unit_length,
67+
self.mesh.neighbours,
68+
self.n
69+
)
70+
else:
71+
clib.compute_stt_field(self.spin,
72+
self.field_stt,
73+
self._jx,
74+
self._jy,
75+
self.mesh.dx * self.mesh.unit_length,
76+
self.mesh.dy * self.mesh.unit_length,
77+
self.mesh.neighbours,
78+
self.n
79+
)
80+
81+
clib.compute_llg_stt_rhs(ydot,
82+
self.spin,
83+
self.field,
84+
self.field_stt,
85+
self.alpha,
86+
self.beta,
87+
self.u0 * self.p / self.Ms_const,
88+
self.gamma,
89+
self.n)

fidimag/atomistic/llg_stt_slonczewski_type.py renamed to fidimag/atomistic/llg_stt_cpp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import fidimag.common.helper as helper
1010

1111

12-
class LLG_STT_Slonczewski(LLG):
12+
class LLG_STT_CPP(LLG):
1313

1414
def __init__(self, mesh, name='unnamed'):
1515
"""Simulation object.
@@ -19,7 +19,7 @@ def __init__(self, mesh, name='unnamed'):
1919
name : the Simulation name (used for writing data files, for examples)
2020
2121
"""
22-
super(LLG_STT_Slonczewski, self).__init__(mesh, name=name)
22+
super(LLG_STT_CPP, self).__init__(mesh, name=name)
2323

2424
self._p = np.zeros(3 * self.n, dtype=np.float)
2525
self._a_J = np.zeros(self.n, dtype=np.float)

fidimag/atomistic/sim.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from .llg import LLG
22
from .sllg import SLLG
3-
from .llg_stt_slonczewski_type import LLG_STT_Slonczewski
3+
from .llg_stt import LLG_STT
4+
from .llg_stt_cpp import LLG_STT_CPP
45

56

67
KNOWN_DRIVERS = {'llg': LLG,
78
'sllg': SLLG,
8-
'slonczewski': LLG_STT_Slonczewski
9+
'llg_stt': SLLG_STT,
10+
'llg_stt_cpp': LLG_STT_CPP
911
}
1012

1113

fidimag/micro/llg_stt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def __init__(self, mesh, name='unnamed'):
3030
self.update_j_fun = None
3131

3232
# FIXME: change the u0 to spatial
33-
self.u0 = const.g_e * const.mu_B / (2 * const.c_e)
33+
v = self.mesh.dx* self.mesh.dy * self.mesh.dz * (self.mesh.unit_length**3)
34+
self.u0 = const.g_e * const.mu_B / (2 * const.c_e) * v
3435

3536
def get_jx(self):
3637
return self._jx
@@ -84,6 +85,6 @@ def sundials_rhs(self, t, y, ydot):
8485
self.field_stt,
8586
self.alpha,
8687
self.beta,
87-
self.u0 * self.p / self.Ms_const,
88+
self.u0 * self.p / self.mu_s_constant,
8889
self.gamma,
8990
self.n)

0 commit comments

Comments
 (0)