From 0f34461b611b8111d281b3054cedd5d2bcce9d8b Mon Sep 17 00:00:00 2001 From: jiyuang Date: Thu, 28 Dec 2023 15:46:32 +0800 Subject: [PATCH] fix bug for lower version --- phonopy/interface/abacus.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/phonopy/interface/abacus.py b/phonopy/interface/abacus.py index 78e5c1f24..7d1822f49 100644 --- a/phonopy/interface/abacus.py +++ b/phonopy/interface/abacus.py @@ -313,23 +313,13 @@ 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)) - _match_pattern = ( - r"^(\s*)([A-Za-z]*[0-9]+)((\s*[-]?[0-9]+\.[0-9]+){3})(.*)$" - ) - _match = re.match(_match_pattern, line) - while not _match: - line = file.readline() - _match = re.match(_match_pattern, line) - iatom = 0 - while _match: - 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) + 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)) if force is None: raise ValueError("Force data not found.")