Skip to content

Commit 8327973

Browse files
chain/nebm: removed driver from sim object
1 parent e983a1f commit 8327973

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

fidimag/common/chain_method_base.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ def __init__(self, sim,
199199
self.n_dofs_image_material = np.sum(self._material)
200200

201201
# VTK saver for the magnetisation/spin field --------------------------
202-
self.VTK = VTK(self.mesh,
203-
directory='vtks'.format(self.name),
204-
filename='image'
205-
)
202+
self.VTK = VTK(self.mesh, directory='vtks', filename='image')
206203

207204
# Functions to convert the energy band coordinates to Cartesian
208205
# coordinates when saving VTK and NPY files We assume Cartesian
@@ -303,6 +300,9 @@ def __init__(self, sim,
303300

304301
self.G_log = []
305302

303+
# Make sure the sim object does not have a driver: (see sim_base.py -> set_m)
304+
sim.driver = None
305+
306306
# TODO: Move this property to the NEBM classes because they are only
307307
# relevant to the NEBM and not the string method
308308
@property
@@ -403,21 +403,17 @@ def save_npys(self, coordinates_function=None):
403403
np.save(name, self.band[i])
404404
self.band.shape = (-1)
405405

406-
def initialise_integrator(self,
407-
integrator='sundials',
408-
rtol=1e-6, atol=1e-6):
406+
def initialise_integrator(self, integrator='sundials', rtol=1e-6, atol=1e-6):
409407
self.t = 0
410408
self.iterations = 0
411409
self.ode_count = 1
412410

413411
if integrator == 'sundials':
414412
if not self.openmp:
415-
self.integrator = cvode.CvodeSolver(self.band,
416-
self.Sundials_RHS)
413+
self.integrator = cvode.CvodeSolver(self.band, self.Sundials_RHS)
417414
self.integrator.set_options(rtol, atol)
418415
else:
419-
self.integrator = cvode.CvodeSolver_OpenMP(self.band,
420-
self.Sundials_RHS)
416+
self.integrator = cvode.CvodeSolver_OpenMP(self.band, self.Sundials_RHS)
421417
self.integrator.set_options(rtol, atol)
422418
# elif integrator == 'scipy':
423419
# self.integrator = ScipyIntegrator(self.band, self.step_RHS)
@@ -440,8 +436,7 @@ def initialise_integrator(self,
440436
# In Verlet algorithm we only use the total force G and not YxYxG:
441437
self._llg_evolve = False
442438
else:
443-
raise Exception('No valid integrator specified. Available: '
444-
'"sundials", "scipy"')
439+
raise Exception('No valid integrator specified. Available: "sundials", "scipy"')
445440

446441
def create_tablewriter(self):
447442
entities_energy = {
@@ -763,11 +758,15 @@ def compute_polynomial_factors(self, compute_fields=True):
763758
self.compute_tangents(self.band)
764759
self.compute_distances()
765760

761+
self.gradientE.shape = (self.n_images, -1)
762+
self.tangents.shape = (self.n_images, -1)
763+
766764
deltas = np.zeros(self.n_images)
767765
for i in range(self.n_images):
768-
deltas[i] = np.dot(self.scale * (self.gradientE).reshape(self.n_images, -1)[i],
769-
self.tangents.reshape(self.n_images, -1)[i]
770-
)
766+
deltas[i] = np.dot(self.scale * self.gradientE[i], self.tangents[i])
767+
768+
self.gradientE.shape = (-1)
769+
self.tangents.shape = (-1)
771770

772771
ds = self.path_distances
773772
E = self.energies

fidimag/common/nebm_geodesic.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
class NEBM_Geodesic(ChainMethodBase):
19-
"""
19+
r"""
2020
ARGUMENTS -----------------------------------------------------------------
2121
2222
sim :: An instance of a micromagnetic or an atomistic
@@ -276,10 +276,8 @@ def compute_effective_field_and_energy(self, y):
276276
# Only update the extreme images
277277
for i in range(1, len(y) - 1):
278278

279-
# self.sim.set_m(y[i]) # -> memory leak
279+
# self.sim.set_m(y[i]) # -> memory leak if sim has a driver
280280
self.sim.spin[:] = y[i]
281-
# elif self.coordinates == 'Cartesian':
282-
# self.sim.set_m(self.band[i])
283281

284282
self.sim.compute_effective_field(t=0)
285283

0 commit comments

Comments
 (0)