@@ -184,12 +184,12 @@ def __init__(self, sim,
184184
185185 def initialise_energies (self ):
186186 # Energy of the images
187- self .band = self . band . reshape (self .n_images , - 1 )
187+ self .band . shape = (self .n_images , - 1 )
188188 for i in range (self .n_images ):
189189 self .sim .set_m (self .band [i ])
190190 self .sim .compute_effective_field (t = 0 )
191191 self .energies [i ] = self .sim .compute_energy ()
192- self .band = self . band . reshape (- 1 )
192+ self .band . shape = (- 1 )
193193
194194 def generate_initial_band (self , method = 'linear' ):
195195 """
@@ -199,7 +199,7 @@ def generate_initial_band(self, method='linear'):
199199
200200 # Every row will be an image of the band, i.e. the i-th row is
201201 # the i-t image
202- self .band = self . band . reshape (self .n_images , - 1 )
202+ self .band . shape = (self .n_images , - 1 )
203203
204204 # Indexes indicating the image number (position of the images) in the
205205 # band, for the specified initial images
@@ -255,7 +255,7 @@ def generate_initial_band(self, method='linear'):
255255 i_initial_images [i + 1 ]] = interpolation
256256
257257 # expand the energy band array
258- self .band = self . band . reshape (- 1 )
258+ self .band . shape = (- 1 )
259259
260260 def compute_effective_field_and_energy (self , y ):
261261 """
@@ -270,14 +270,14 @@ def compute_effective_field_and_energy(self, y):
270270
271271 """
272272
273- self .gradientE = self .gradientE .reshape (self .n_images , - 1 )
274-
275- y = y .reshape (self .n_images , - 1 )
273+ self .gradientE .shape = (self .n_images , - 1 )
274+ y .shape = (self .n_images , - 1 )
276275
277276 # Only update the extreme images
278277 for i in range (1 , len (y ) - 1 ):
279278
280- self .sim .set_m (y [i ])
279+ # self.sim.set_m(y[i]) # -> memory leak
280+ self .sim .spin [:] = y [i ]
281281 # elif self.coordinates == 'Cartesian':
282282 # self.sim.set_m(self.band[i])
283283
@@ -287,8 +287,8 @@ def compute_effective_field_and_energy(self, y):
287287
288288 self .energies [i ] = self .sim .compute_energy ()
289289
290- y = y . reshape (- 1 )
291- self .gradientE = self . gradientE . reshape (- 1 )
290+ y . shape = (- 1 )
291+ self .gradientE . shape = (- 1 )
292292
293293 def compute_tangents (self , y ):
294294 nebm_clib .compute_tangents (self .tangents , y , self .energies ,
0 commit comments