Skip to content

Commit 331569b

Browse files
committed
Change TimeZeeman to use helper.init_vector
1 parent e8cb4df commit 331569b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

fidimag/micro/zeeman.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,22 @@ class TimeZeeman(Zeeman):
115115

116116
"""
117117
The time dependent external field, also can vary with space
118+
119+
The function time_fun must be a function which takes two arguments:
120+
121+
def time_fun(pos, t):
122+
x, y, z = pos
123+
# compute Bx, By, Bz as a function of x y, z and t.
124+
Bx = ...
125+
By = ...
126+
Bz = ...
127+
return (Bx, By, Bz)
128+
129+
118130
"""
119131

120132
def __init__(self, H0, time_fun, name='TimeZeeman'):
133+
121134
self.H0 = H0
122135
self.time_fun = time_fun
123136
self.name = name
@@ -128,5 +141,8 @@ def setup(self, mesh, spin, Ms):
128141
self.H_init = self.field.copy()
129142

130143
def compute_field(self, t=0, spin=None):
131-
self.field[:] = self.H_init[:] * self.time_fun(t)
144+
self.field[:] = helper.init_vector(self.time_fun,
145+
self.mesh,
146+
False,
147+
t)
132148
return self.field

0 commit comments

Comments
 (0)