Skip to content

Commit ab61da1

Browse files
Kai Luo (罗凯)pre-commit-ci[bot]
andauthored
Latest support for abacus scf output (#875)
Abacus updates its output format, so these keywords were not right. I have updated them to support both eariler ones and latest one by removing the unit part. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved robustness when reading ABACUS simulation outputs by accepting more variations of energy, force, and stress headers. * More permissive header matching reduces failures from minor log-format differences. * Preserves existing convergence and extraction behavior while improving tolerance for alternate log phrasing. * Reduces missed or incomplete parses, increasing reliability across ABACUS log variants. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ebb20ad commit ab61da1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

dpdata/abacus/scf.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ def get_path_out(fname, inlines):
4545
def get_energy(outlines):
4646
Etot = None
4747
for line in reversed(outlines):
48-
if "final etot is" in line:
48+
if "final etot is" in line: # for LTS
49+
Etot = float(line.split()[-2]) # in eV
50+
return Etot, True
51+
elif "TOTAL ENERGY" in line: # for develop
4952
Etot = float(line.split()[-2]) # in eV
5053
return Etot, True
5154
elif "convergence has NOT been achieved!" in line:
@@ -59,7 +62,8 @@ def get_energy(outlines):
5962
def collect_force(outlines):
6063
force = []
6164
for i, line in enumerate(outlines):
62-
if "TOTAL-FORCE (eV/Angstrom)" in line:
65+
# if "TOTAL-FORCE (eV/Angstrom)" in line:
66+
if "TOTAL-FORCE" in line:
6367
value_pattern = re.compile(
6468
r"^\s*[A-Z][a-z]?[1-9][0-9]*\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$"
6569
)
@@ -95,7 +99,8 @@ def get_force(outlines, natoms):
9599
def collect_stress(outlines):
96100
stress = []
97101
for i, line in enumerate(outlines):
98-
if "TOTAL-STRESS (KBAR)" in line:
102+
# if "TOTAL-STRESS (KBAR)" in line:
103+
if "TOTAL-STRESS" in line:
99104
value_pattern = re.compile(
100105
r"^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$"
101106
)

0 commit comments

Comments
 (0)