From 2e0a182ee81eb751bd4989062aed800b3fc2dfe6 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Sun, 21 Jan 2024 15:43:40 +0800 Subject: [PATCH 1/2] print detailed information on outcar reading failure --- dpdata/vasp/outcar.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dpdata/vasp/outcar.py b/dpdata/vasp/outcar.py index e8280d056..9dc551655 100644 --- a/dpdata/vasp/outcar.py +++ b/dpdata/vasp/outcar.py @@ -142,7 +142,12 @@ def analyze_block(lines, ntot, nelm, ml=False): is_converge = False elif energy_token[ml_index] in ii: energy = float(ii.split()[energy_index[ml_index]]) - assert (force is not None) and len(coord) > 0 and len(cell) > 0 + if len(force) == 0: + raise ValueError("cannot find forces in OUTCAR block") + if len(coord) == 0: + raise ValueError("cannot find coordinates in OUTCAR block") + if len(cell) == 0: + raise ValueError("cannot find cell in OUTCAR block") return coord, cell, energy, force, virial, is_converge elif cell_token[ml_index] in ii: for dd in range(3): From ad228d186c3a23d6d82e76b820aa418c6746362e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 21 Jan 2024 07:45:59 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpdata/vasp/outcar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dpdata/vasp/outcar.py b/dpdata/vasp/outcar.py index 9dc551655..0eddac91a 100644 --- a/dpdata/vasp/outcar.py +++ b/dpdata/vasp/outcar.py @@ -143,11 +143,11 @@ def analyze_block(lines, ntot, nelm, ml=False): elif energy_token[ml_index] in ii: energy = float(ii.split()[energy_index[ml_index]]) if len(force) == 0: - raise ValueError("cannot find forces in OUTCAR block") + raise ValueError("cannot find forces in OUTCAR block") if len(coord) == 0: - raise ValueError("cannot find coordinates in OUTCAR block") + raise ValueError("cannot find coordinates in OUTCAR block") if len(cell) == 0: - raise ValueError("cannot find cell in OUTCAR block") + raise ValueError("cannot find cell in OUTCAR block") return coord, cell, energy, force, virial, is_converge elif cell_token[ml_index] in ii: for dd in range(3):