@@ -238,46 +238,55 @@ def get_frames (fname) :
238
238
content = fp .read ()
239
239
count = content .count ('SCF run converged' )
240
240
if count == 0 :
241
- return [], [], [], [], [], [], [], []
241
+ return [], [], [], [], [], [], [], None
242
242
243
+ # search duplicated header
243
244
fp .seek (0 )
245
+ header_idx = []
244
246
for idx , ii in enumerate (fp ) :
245
- if ('CELL| Vector' in ii ) and (cell_count < 3 ) :
246
- cell .append (ii .split ()[4 :7 ])
247
- cell_count += 1
248
- if 'Atom Kind Element' in ii :
249
- coord_flag = True
250
- coord_idx = idx
251
- coord_count += 1
252
- # get the coord block info
253
- if coord_flag and (coord_count == 1 ):
254
- if (idx > coord_idx + 1 ) :
255
- if (ii == '\n ' ) :
256
- coord_flag = False
257
- else :
258
- coord .append (ii .split ()[4 :7 ])
259
- atom_symbol_list .append (ii .split ()[2 ])
260
- if 'ENERGY|' in ii :
261
- energy = (ii .split ()[8 ])
262
- if ' Atom Kind ' in ii :
263
- force_flag = True
264
- force_idx = idx
265
- if force_flag :
266
- if (idx > force_idx ) :
267
- if 'SUM OF ATOMIC FORCES' in ii :
268
- force_flag = False
269
- else :
270
- force .append (ii .split ()[3 :6 ])
271
- # add reading stress tensor
272
- if 'STRESS TENSOR [GPa' in ii :
273
- stress_flag = True
274
- stress_idx = idx
275
- if stress_flag :
276
- if (idx > stress_idx + 2 ):
277
- if (ii == '\n ' ) :
278
- stress_flag = False
279
- else :
280
- stress .append (ii .split ()[1 :4 ])
247
+ if 'Multiplication driver' in ii :
248
+ header_idx .append (idx )
249
+
250
+ # parse from last header
251
+ fp .seek (0 )
252
+ for idx , ii in enumerate (fp ) :
253
+ if idx > header_idx [- 1 ] :
254
+ if 'CELL| Vector' in ii :
255
+ cell .append (ii .split ()[4 :7 ])
256
+
257
+ if 'Atom Kind Element' in ii :
258
+ coord_flag = True
259
+ coord_idx = idx
260
+
261
+ # get the coord block info
262
+ if coord_flag :
263
+ if (idx > coord_idx + 1 ) :
264
+ if (ii == '\n ' ) :
265
+ coord_flag = False
266
+ else :
267
+ coord .append (ii .split ()[4 :7 ])
268
+ atom_symbol_list .append (ii .split ()[2 ])
269
+ if 'ENERGY|' in ii :
270
+ energy = (ii .split ()[8 ])
271
+ if ' Atom Kind ' in ii :
272
+ force_flag = True
273
+ force_idx = idx
274
+ if force_flag :
275
+ if (idx > force_idx ) :
276
+ if 'SUM OF ATOMIC FORCES' in ii :
277
+ force_flag = False
278
+ else :
279
+ force .append (ii .split ()[3 :6 ])
280
+ # add reading stress tensor
281
+ if 'STRESS TENSOR [GPa' in ii :
282
+ stress_flag = True
283
+ stress_idx = idx
284
+ if stress_flag :
285
+ if (idx > stress_idx + 2 ):
286
+ if (ii == '\n ' ) :
287
+ stress_flag = False
288
+ else :
289
+ stress .append (ii .split ()[1 :4 ])
281
290
282
291
283
292
fp .close ()
0 commit comments