Skip to content

Commit 61126fe

Browse files
authored
[Fix] Include #TOTAL ENERGY# check in get_energy function of abacus/[md,relax].py (#950)
Fix #949. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved energy extraction from ABACUS MD logs to recognize additional energy markers, ensuring energy values are captured reliably across varied log formats and maintaining correct alignment with structure snapshots. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Levi Zhou <31941107+ZhouXY-PKU@users.noreply.github.com>
1 parent d68b700 commit 61126fe

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

dpdata/abacus/md.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def get_energy(outlines, ndump, dump_freq):
135135
energy = []
136136
nenergy = 0
137137
for line_idx, line in enumerate(outlines):
138-
if "final etot is" in line:
138+
if "final etot is" in line or "#TOTAL ENERGY#" in line:
139139
if nenergy % dump_freq == 0:
140140
energy.append(float(line.split()[-2]))
141141
nenergy += 1

dpdata/abacus/relax.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_coords_from_log(loglines, natoms):
9494
list(map(lambda x: float(x) * a0, loglines[i + k].split()[0:3]))
9595
)
9696

97-
elif line[1:14] == "final etot is":
97+
elif line[1:14] == "final etot is" or "#TOTAL ENERGY#" in line:
9898
# add the energy for previous structures whose SCF is not converged
9999
while len(energy) < len(coords) - 1:
100100
energy.append(np.nan)

0 commit comments

Comments
 (0)