Skip to content

Commit

Permalink
fix bug for v3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
1041176461 committed Dec 28, 2023
1 parent 0f34461 commit 5e2fba8
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions phonopy/interface/abacus.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,23 @@ def read_abacus_output(filename):
natom = int(re.search("[0-9]+", line).group())
if re.search(r"TOTAL-FORCE \(eV/Angstrom\)", line):
force = np.zeros((natom, 3))
ver_diff = file.readline()
if "---" not in ver_diff:
for i in range(3):
file.readline()
for i in range(natom):
_, fx, fy, fz = file.readline().split()
force[i] = (float(fx), float(fy), float(fz))
_match_pattern = r"^(\s*)([A-Za-z]*[0-9]+)((\s*[+-]?[0-9]+\
\.[0-9]+(e[+-][0-9]{2})?){3})(.*)$"
_match = re.match(_match_pattern, line)
while not _match:
line = file.readline()
_match = re.match(_match_pattern, line)
iatom = 0
while _match:
print(_match.group(3).split())
fx, fy, fz = (_match.group(3).split()[i].strip() for i in range(3))
force[iatom] = (float(fx), float(fy), float(fz))
iatom += 1
if iatom == natom:
break
else:
line = file.readline()
_match = re.match(_match_pattern, line)

if force is None:
raise ValueError("Force data not found.")
Expand Down

0 comments on commit 5e2fba8

Please sign in to comment.