@@ -150,7 +150,12 @@ class FSIntegrator(BaseIntegrator):
150
150
"""A step integrator considering the action of the band
151
151
"""
152
152
def __init__ (self , band , forces , action , rhs_fun , n_images , n_dofs_image ,
153
- max_steps = 1000 ):
153
+ max_steps = 1000 ,
154
+ maxCreep = 5 , eta_scale = 1.0 , stopping_dE = 1e-6 , dEta = 2 ,
155
+ etaMin = 0.001 ,
156
+ # perturbSeed=42, perturbFactor=0.1,
157
+ nTrail = 10 , resetMax = 20 , mXgradE_tol = 0.1
158
+ ):
154
159
super (FSIntegrator , self ).__init__ (band , rhs_fun )
155
160
156
161
self .i_step = 0
@@ -161,10 +166,59 @@ def __init__(self, band, forces, action, rhs_fun, n_images, n_dofs_image,
161
166
self .forces = forces
162
167
self .max_steps = max_steps
163
168
169
+ self .y_last = np .zeros_like (self .y ) # y -> band
170
+ self .step = 0
171
+ self .nTrail = nTrail
172
+
164
173
def run_until (self , t ):
165
174
pass
166
175
167
176
def run_for (self , n_steps ):
177
+
178
+ nStart = 0
179
+ exitFlag = False
180
+ totalRestart = True
181
+ resetCount = 0
182
+ creepCount = 0
183
+ self .trailE = np .zeros (nTrail )
184
+ trailPool = cycle (range (nTrail )) # cycle through 0,1,...,(nTrail-1),0,1,...
185
+ eta = 1.0
186
+
187
+ while not exitFlag :
188
+
189
+ if totalRestart :
190
+ if self .step > 0 :
191
+ print ('Restarting' )
192
+ self .y [:] = self .y_last
193
+
194
+ # Compute from self.band. Do not update the step at this stage:
195
+ # This step updates the forces in the G array of the nebm module,
196
+ # using the current band state self.y
197
+ self .rhs (t , self .y )
198
+
199
+
200
+ # self.step += 1
201
+ self .gradE_last [:] = - self .field # Scale field??
202
+ self .gradE_last [~ _material ] = 0.0
203
+ self .gradE [:] = self .gradE_last
204
+ self .totalE_last = self .totalE
205
+ self .trailE [nStart ] = self .totalE
206
+ nStart = next (trailPool )
207
+ eta = 1.0
208
+ totalRestart = False
209
+
210
+ creepCount = 0
211
+
212
+ # Creep stage: minimise with a fixed eta
213
+ while creepCount < maxCreep :
214
+ # Update spin. Avoid pinned or zero-Ms sites
215
+ self .y [:] = self .y_last - eta * eta_scale * self .forces_images
216
+
217
+
218
+
219
+
220
+
221
+
168
222
# while abs(self.i_step - steps) > EPSILON:
169
223
st = 1
170
224
while st < n_steps :
0 commit comments