Skip to content

Commit ec7985b

Browse files
fix cp2k 2023 output (#533)
fix #508, #507 --------- Signed-off-by: link89 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 002e073 commit ec7985b

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

dpdata/cp2k/output.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -409,24 +409,18 @@ def get_frames(fname):
409409
cell.append(ii.split()[4:7])
410410
if "Atomic kind:" in ii:
411411
atom_symbol_list.append(ii.split()[3])
412-
if "Atom Kind Element" in ii:
412+
413+
# beginning of coords block
414+
if "Atom Kind Element" in ii or "Atom Kind Element" in ii:
413415
coord_flag = True
414-
coord_idx = idx
416+
# parse coords lines
417+
elif coord_flag:
418+
if ii == "\n":
419+
coord_flag = len(coord) == 0 # skip empty line at the beginning
420+
else:
421+
coord.append(ii.split()[4:7])
422+
atom_symbol_idx_list.append(ii.split()[1])
415423

416-
# get the coord block info
417-
if coord_flag:
418-
if idx == coord_idx + 1:
419-
if ii == "\n":
420-
pass
421-
else:
422-
coord.append(ii.split()[4:7])
423-
atom_symbol_idx_list.append(ii.split()[1])
424-
if idx > coord_idx + 1:
425-
if ii == "\n":
426-
coord_flag = False
427-
else:
428-
coord.append(ii.split()[4:7])
429-
atom_symbol_idx_list.append(ii.split()[1])
430424
if "ENERGY|" in ii:
431425
energy = ii.split()[8]
432426
if " Atom Kind " in ii:

0 commit comments

Comments
 (0)