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

noncollinear attribute of Outcar class has wrong value for VASP calculations with LNONCOLLINEAR=.TRUE. #4031

Closed
KylinGuo opened this issue Sep 3, 2024 · 5 comments · Fixed by #4034
Labels
bug needs repro Bug report that needs a reproduction

Comments

@KylinGuo
Copy link

KylinGuo commented Sep 3, 2024

Python version

Python 3.11.0

Pymatgen version

2024.7.18

Operating system version

Ubuntu 22.04 LTS

Current behavior

I expect that outcar.noncollinear is True for noncollinear calculations. But I got False.

Expected Behavior

I expect that outcar.noncollinear is True for noncollinear calculations.

Minimal example

from pymatgen.io.vasp.outputs import Outcar
outcar = Outcar(filename='OUTCAR')
print(outcar.noncollinear)  # 'True' for LNONCOLLINEAR=.TRUE.


### Relevant files to reproduce this bug

_No response_
@KylinGuo KylinGuo added the bug label Sep 3, 2024
@janosh
Copy link
Member

janosh commented Sep 3, 2024

could you share the OUTCAR file so we can repro?

@janosh janosh added the needs repro Bug report that needs a reproduction label Sep 3, 2024
@KylinGuo
Copy link
Author

KylinGuo commented Sep 3, 2024

```python
print(outcar.noncollinear)  # 'True' for LNONCOLLINEAR=.TRUE.

Yes. Please check the attached file (Please remove the suffix .txt).
OUTCAR.txt

@DanielYang59
Copy link
Contributor

DanielYang59 commented Sep 3, 2024

Thanks. I was able to reproduce this with the OUTCAR attached. Looks like the pattern match failed:

# Check if calculation is non-collinear
self.noncollinear = False
self.read_pattern({"noncollinear": "LNONCOLLINEAR = T"})
if self.data.get("noncollinear", []):
self.noncollinear = False

I haven't looked through this part of source code before, wondering why was this re pattern compiled like this (number of spaces hard coded?

@KylinGuo
Copy link
Author

KylinGuo commented Sep 3, 2024

Thanks. I was able to reproduce this with the OUTCAR attached. Looks like the pattern match failed:

# Check if calculation is non-collinear
self.noncollinear = False
self.read_pattern({"noncollinear": "LNONCOLLINEAR = T"})
if self.data.get("noncollinear", []):
self.noncollinear = False

I haven't looked through this part of source code before, wondering why was this re pattern compiled like this (number of spaces hard coded?

Though the number of white spaces are hard-coded, this should work. The problem lies at line 2118. Here is the correct code.

        self.read_pattern({"noncollinear": r"LNONCOLLINEAR\s*=\s*T"})
        if self.data.get("noncollinear", []):
            self.noncollinear = True  # !!!

@DanielYang59
Copy link
Contributor

Yep the logic should be reversed. would fix this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs repro Bug report that needs a reproduction
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants