QijingZheng / VaspBandUnfolding

A collection of python scripts that deal with VASP outpts, e.g. WAVECAR, POTCAR etc.
198 stars 89 forks source link

Deal with situation: no space between signed numbers in PROCAR #6

Open niasw opened 4 years ago

niasw commented 4 years ago

Dear Dr. Zheng,

I want to report an issue about procar.py, and along with a solution for it.

I noticed that when PROCAR is generated, there will be no space between signed numbers sometimes. Since the infomation is extracted by relative column numbers from the end, the procar.py will raise exception in these situations:

ValueError: could not convert string to float: ':'

For example, when PROCAR says

 k-point   19 :    0.50000000-0.00000000 0.00000000     weight = 0.00231481

the line in line 150 in procar.py will return

[':','0.50000000-0.00000000',‘0.00000000’]

instead of

['0.50000000','-0.00000000',‘0.00000000’]

and therefore, procar.py will exec float(':') and thus will raise that ValueError.

To fix this issue, I suggest to fill this space before parsing PROCAR data. In detail, add these

for row in range(0,len(inp)):
           inp[row] = re.sub(r'(?P<num1>[0-9]+)(?P<num2>[\+\-][0-9]+)','\g<num1> \g<num2>',inp[row])

at line 142 in procar.py. And the issue will be no more.

Best Regards, Sun Sibai IOPCAS L02