diff --git a/dpdata/vasp/outcar.py b/dpdata/vasp/outcar.py index a99332603..f35b54b23 100644 --- a/dpdata/vasp/outcar.py +++ b/dpdata/vasp/outcar.py @@ -1,10 +1,12 @@ import numpy as np +import re def system_info (lines, type_idx_zero = False) : atom_names = [] atom_numbs = None nelm = None - for ii in lines: + for ii in lines: + ii_word_list=ii.split() if 'TITEL' in ii : # get atom names from POTCAR info, tested only for PAW_PBE ... _ii=ii.split()[3] @@ -13,9 +15,11 @@ def system_info (lines, type_idx_zero = False) : atom_names.append(_ii.split('_')[0]) else: atom_names.append(_ii) - elif 'NELM' in ii and nelm == None: - # will read only first nelm - nelm = int(ii.split()[2].rstrip(";")) + #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) + if m: + nelm = int(m.group(1)) elif 'ions per type' in ii : atom_numbs_ = [int(s) for s in ii.split()[4:]] if atom_numbs is None :