Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
niasw opened this issue Sep 26, 2019 · 0 comments
Open

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

niasw opened this issue Sep 26, 2019 · 0 comments

Comments

@niasw
Copy link

niasw commented Sep 26, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant