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

Possibly incorrect electron_configuration returned by vasp.inputs.PotcarSingle #4269

Open
pranabdas opened this issue Jan 27, 2025 · 1 comment · May be fixed by #4278
Open

Possibly incorrect electron_configuration returned by vasp.inputs.PotcarSingle #4269

pranabdas opened this issue Jan 27, 2025 · 1 comment · May be fixed by #4278
Labels

Comments

@pranabdas
Copy link

Python version

3.10.16

Pymatgen version

2025.1.24

Operating system version

No response

Current behavior

It seems pymatgen returns incorrect valence configuration while parsing VASP POTCAR. Consider following code, where the POTCAR file corresponds to Hg (VASP-5.4, GGA, PBE, PAW, default):

from pymatgen.io.vasp.inputs import PotcarSingle

with open("POTCAR", "r", encoding="utf-8") as file:
    data = file.read()

print(PotcarSingle(data).electron_configuration)

It prints:

[(5, 'd', 10), (4, 'f', 14)]

Expected Behavior

Previously, I tested pymatgen==2023.8.10, it used to return:

[(6, 's', 2), (5, 'd', 10)]

The second line (valence) in POTCAR file is:

12.0000000000000 

Also, there is this line:

   POMASS =  XXX.XXX; ZVAL   =   12.000    mass and valenz

So, I suppose the previous behavior (i.e, [(6, 's', 2), (5, 'd', 10)], 12 valence electrons) was correct.

Atomic configuration block:

   Atomic configuration
   15 entries
     n  l   j            E        occ.
     1  0  0.50         XXX      2.0000
...
     4  3  3.50         XXX     14.0000
     5  0  0.50         XXX      2.0000
     5  1  1.50         XXX      6.0000
     5  2  2.50         XXX     10.0000
     6  0  0.50         XXX      2.0000
     6  1  1.50         XXX      0.0000

Minimal example

We can create a temporary directory and create virtualenv for testing:

mkdir test
cd test
python -m venv .venv
source .venv/bin/activate
pip install pymatgen

Then please use POTCAR of Hg and run the above python code.

To test older version of pymatgen, do the same instead install:

pip install pymatgen==2023.8.10 numpy==1.*

Relevant files to reproduce this bug

Sorry, but you need access to VASP POTCAR files, which cannot be shared due to copyright issues.

@DanielYang59
Copy link
Contributor

DanielYang59 commented Feb 1, 2025

Hi thanks for reporting this and looks like a bug to me, and I could recreate this issue :)

from pymatgen.core import Element


ele_hg = Element.from_Z(80)

print(ele_hg.full_electronic_structure)
# [(1, 's', 2), (2, 's', 2), (2, 'p', 6), (3, 's', 2), (3, 'p', 6), (4, 's', 2), (3, 'd', 10), (4, 'p', 6), (5, 's', 2), (4, 'd', 10), (5, 'p', 6), (6, 's', 2), (4, 'f', 14), (5, 'd', 10)]

_madelung = [
(1, "s"),
(2, "s"),
(2, "p"),
(3, "s"),
(3, "p"),
(4, "s"),
(3, "d"),
(4, "p"),
(5, "s"),
(4, "d"),
(5, "p"),
(6, "s"),
(4, "f"),
(5, "d"),
(6, "p"),
(7, "s"),
(5, "f"),
(6, "d"),
(7, "p"),
]


I guess it's related to the change in #3944 and we would need to fix how the valence shell is determined

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