From 34bc2b6225ce134219b1579b4da7bbab49046ed6 Mon Sep 17 00:00:00 2001 From: "Oleg E. Peil" Date: Fri, 4 Dec 2015 12:08:33 +0100 Subject: [PATCH] Modified LOCPROJ parser to conform to new format The format of LOCPROJ has been modified again (in VASP 5.4.2 build from Dec 02, 2015). Now, there is an additional line before each projector block providing the spin, k-, and band indices, as well as eigenvalues and Fermi weights. --- python/converters/plovasp/vaspio.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/converters/plovasp/vaspio.py b/python/converters/plovasp/vaspio.py index a578e65e..eb58e261 100644 --- a/python/converters/plovasp/vaspio.py +++ b/python/converters/plovasp/vaspio.py @@ -195,6 +195,7 @@ class Plocar: # Read the first line of LOCPROJ to get the dimensions with open(locproj_filename, 'rt') as f: line = f.readline() + line = line.split("#")[0] nspin, nk, nband, nproj = map(int, line.split()) plo = np.zeros((nproj, nspin, nk, nband), dtype=np.complex128) @@ -224,15 +225,18 @@ class Plocar: assert ip == nproj, "Number of projectors in the header is wrong in LOCPROJ" +# TODO: one can read eigenvalues and Fermi weights from lines starting with "orbital" +# at the moment we ignore them + patt = re.compile("^orbital") for ispin in xrange(nspin): for ik in xrange(nk): for ib in xrange(nband): for ip in xrange(nproj): line = "" - while not line: + while not line or not re.match(patt, line) is None: line = f.readline().strip() sline = line.split() - ctmp = complex(float(sline[4]), float(sline[5])) + ctmp = complex(float(sline[1]), float(sline[2])) plo[ip, ispin, ik, ib] = ctmp print "Read parameters:"