From c3963480c3c2ea336d715fdb391c5e5970ca7f4a Mon Sep 17 00:00:00 2001 From: Holger Badorreck Date: Thu, 30 Mar 2023 11:17:00 +0200 Subject: [PATCH 1/3] fix #359: read atom names from POTCAR if not present in OUTCAR --- dpdata/vasp/outcar.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dpdata/vasp/outcar.py b/dpdata/vasp/outcar.py index e8280d05..ec9e9ed3 100644 --- a/dpdata/vasp/outcar.py +++ b/dpdata/vasp/outcar.py @@ -18,6 +18,14 @@ def system_info(lines, type_idx_zero=False): atom_names.append(_ii.split("_")[0]) else: atom_names.append(_ii) + elif 'POTCAR' in ii: + # get atom names from POTCAR info, tested only for PAW_PBE ... + _ii=ii.split()[2] + if '_' in _ii: + # for case like : POTCAR: PAW_PBE Ti_sv 26Sep2005 + atom_names.append(_ii.split('_')[0]) + else: + atom_names.append(_ii) # a stricker check for "NELM"; compatible with distingct formats in different versions(6 and older, newers_expect-to-work) of vasp elif nelm is None: m = re.search(r"NELM\s*=\s*(\d+)", ii) From 29ea10b7e2ca3fff399896aef9fc13fafe54ffc2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 30 Mar 2023 09:20:14 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpdata/vasp/outcar.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dpdata/vasp/outcar.py b/dpdata/vasp/outcar.py index ec9e9ed3..f0ccabeb 100644 --- a/dpdata/vasp/outcar.py +++ b/dpdata/vasp/outcar.py @@ -18,12 +18,12 @@ def system_info(lines, type_idx_zero=False): atom_names.append(_ii.split("_")[0]) else: atom_names.append(_ii) - elif 'POTCAR' in ii: + elif "POTCAR" in ii: # get atom names from POTCAR info, tested only for PAW_PBE ... - _ii=ii.split()[2] - if '_' in _ii: + _ii = ii.split()[2] + if "_" in _ii: # for case like : POTCAR: PAW_PBE Ti_sv 26Sep2005 - atom_names.append(_ii.split('_')[0]) + atom_names.append(_ii.split("_")[0]) else: atom_names.append(_ii) # a stricker check for "NELM"; compatible with distingct formats in different versions(6 and older, newers_expect-to-work) of vasp From 457e48140638aee892e1d98dfb2acb1972286b88 Mon Sep 17 00:00:00 2001 From: Holger Badorreck Date: Fri, 31 Mar 2023 12:26:34 +0200 Subject: [PATCH 3/3] don't allow duplicate atom names --- dpdata/vasp/outcar.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/dpdata/vasp/outcar.py b/dpdata/vasp/outcar.py index ec9e9ed3..a16f885c 100644 --- a/dpdata/vasp/outcar.py +++ b/dpdata/vasp/outcar.py @@ -12,20 +12,16 @@ def system_info(lines, type_idx_zero=False): ii_word_list = ii.split() if "TITEL" in ii: # get atom names from POTCAR info, tested only for PAW_PBE ... - _ii = ii.split()[3] - if "_" in _ii: - # for case like : TITEL = PAW_PBE Sn_d 06Sep2000 - atom_names.append(_ii.split("_")[0]) - else: - atom_names.append(_ii) - elif 'POTCAR' in ii: + # for case like : TITEL = PAW_PBE Sn_d 06Sep2000 + atom_name = ii.split()[3].split("_")[0] + if atom_name not in atom_names: + atom_names.append(atom_name) + elif "POTCAR" in ii: # get atom names from POTCAR info, tested only for PAW_PBE ... - _ii=ii.split()[2] - if '_' in _ii: - # for case like : POTCAR: PAW_PBE Ti_sv 26Sep2005 - atom_names.append(_ii.split('_')[0]) - else: - atom_names.append(_ii) + # for case like : POTCAR: PAW_PBE Ti_sv 26Sep2005 + atom_name = ii.split()[2].split("_")[0] + if atom_name not in atom_names: + atom_names.append(atom_name) # a stricker check for "NELM"; compatible with distingct formats in different versions(6 and older, newers_expect-to-work) of vasp elif nelm is None: m = re.search(r"NELM\s*=\s*(\d+)", ii)