File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -291,11 +291,15 @@ def next_force():
291291 # Now read data
292292 F = []
293293 line = self .readline ()
294+ if 'siesta:' in line :
295+ # This is the final summary, we don't need to read it as it does not contain new information
296+ # and also it make break things since max forces are not written there
297+ return None
294298
295299 # First, we encounter the atomic forces
296300 while '---' not in line :
297301 line = line .split ()
298- if not total or max :
302+ if not ( total or max ) :
299303 F .append ([float (x ) for x in line [- 3 :]])
300304 line = self .readline ()
301305 if line == '' :
@@ -328,8 +332,8 @@ def return_forces(Fs):
328332 if max and total :
329333 return (Fs [..., :- 1 ], Fs [..., - 1 ])
330334 elif max and not all :
331- # This will return a float (or actually a numpy.dtype)
332- return Fs [0 ]
335+ # This will return a float
336+ return np . atleast_1d ( Fs ) [0 ]
333337 return Fs
334338
335339 if all or last :
@@ -342,11 +346,8 @@ def return_forces(Fs):
342346 Fs .append (F )
343347
344348 if last :
345- return return_forces (Fs [- 2 ])
346- # F[-2] is really the same as F[-1], the last forces are stated twice
347- # However, the maxForce is not stated in the final summary, that's why we use F[-2]
348- if self .job_completed :
349- return return_forces (Fs [:- 1 ])
349+ return return_forces (Fs [- 1 ])
350+
350351 return return_forces (Fs )
351352
352353 return return_forces (next_force ())
You can’t perform that action at this time.
0 commit comments