materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.47k stars 847 forks source link

Species.full_electronic_structure is incorrect #3849

Open rkingsbury opened 3 months ago

rkingsbury commented 3 months ago

Python version

Python 3.10.6

Pymatgen version

2024.5.1

Operating system version

Ubuntu (Windows WSL2)

Current behavior

Species.full_electronic_structure and electronic_structure do not properly account for the number of electrons when an oxidation state other than zero is assigned, for example, Fe(0) and Fe(+3) should not have the same electronic configuration:

>>> Species('Fe',0).full_electronic_structure
[(1, 's', 2),
 (2, 's', 2),
 (2, 'p', 6),
 (3, 's', 2),
 (3, 'p', 6),
 (3, 'd', 6),
 (4, 's', 2)]
>>> Species('Fe',0).electronic_structure
'[Ar].3d6.4s2'

>>> Species('Fe',3).full_electronic_structure
[(1, 's', 2),
 (2, 's', 2),
 (2, 'p', 6),
 (3, 's', 2),
 (3, 'p', 6),
 (3, 'd', 6),
 (4, 's', 2)]
>>> Species('Fe',3).electronic_structure
'[Ar].3d6.4s2'

Expected Behavior

Assigning a nonzero oxidation state to a Species should modify its electronic configuration, e.g.

>>> Species('Fe',3).electronic_structure
'[Ar].3d5'

The same goes for valence:

>>> Species('Fe',0).valence
(2, 6)
>>> Species('Fe',3).valence
(2, 6)

Minimal example

No response

Relevant files to reproduce this bug

No response

shyuep commented 3 months ago

I would add a NotImplemented for Specie unitl someone wants to take a crack at implementing this for Species. It is non-trivial since there are some special rules for removing electrons, especially things related to d10 configs.

rkingsbury commented 3 months ago

Thanks for the quick action @shyuep . I'll see about following up on this. It appears all the electronic structure info is encoded in the .json file, so this is just a matter of re-ordering some of the strings in that file to follow the proper energy ordering.

(The ordering issue in #3850 , that is)