-
Notifications
You must be signed in to change notification settings - Fork 876
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
[Breaking] Fix valence electron configuration parsing for PotcarSingle.electron_configuration
#4278
base: master
Are you sure you want to change the base?
[Breaking] Fix valence electron configuration parsing for PotcarSingle.electron_configuration
#4278
Conversation
5efb71d
to
c735cca
Compare
bdea380
to
cd92872
Compare
PotcarSingle.electron_configuration
PotcarSingle.electron_configuration
I have a feeling that we might need to rewrite the For example for the pymatgen/tests/io/vasp/test_inputs.py Line 1386 in 5b997f7
Can you please give me some advice on this? @rkingsbury Thanks in advance |
@DanielYang59 I also defines a cutoff for an occupied orbital which might help for non-integer cases |
Hi @JaGeo good day and thanks for the comment
Beautiful! Looks like the
I guess no code is perfectly written without repeated refactor? :) Line 18 in 5b997f7
|
@DanielYang59 yes, it would be great if you take over and make this code a method for the potcar. Then, I can adapt the developer code. |
Great! I guess we could either:
Which do you suggest? I might personally prefer the former now that its already giving the wrong results so I would consider this a fix?
I'm not really aware of non-integer occupancies from POTCARs, can you perhaps point me to some such POTCARs such that I could put more thinking on them? |
@DanielYang59 i also think it should be the former as it currently is implemented wrong in my opinion. Li, Be, maybe? Some have 0.01 occupancy, I think. If you have some potcars available, you can use the dev script to spot them. |
Cool I would just replace for now but should be easy to switch anytime
Thanks I would have a look, I thought it's H.* (H.25, H.35, ...) |
PotcarSingle.electron_configuration
PotcarSingle.electron_configuration
PotcarSingle.electron_configuration
PotcarSingle.electron_configuration
f4fe1c1
to
3804849
Compare
tests/io/vasp/test_inputs.py
Outdated
# Test occupancy cut-off (Be: 2s1.99 2p0.01) | ||
assert_config_equal( | ||
PotcarSingle.from_file(f"{FAKE_POTCAR_DIR}/POT_GGA_PAW_PBE_54/POTCAR.Be.gz").get_electron_configuration( | ||
occu_cutoff=0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to rethink about this cutoff.
For the Be electron configuration, it's:
1 0 0.50 xxx 2.0000
2 0 0.50 xxx 1.9900
2 1 0.50 xxx 0.0100
3 2 1.50 xxx 0.0000
If we choose cutoff as > 0.01, the 1s orbital would also be counted as valence (as 1.99 < ZVAL).
Perhaps use a "tolerance" instead? which serves two purposes:
- Below the tolerance, an orbital would be considered empty (ignored)
- If already accumulated number of electrons is close to ZVAL by "tolerance", stop counting electrons from deeper shells? (i.e. the 2s orbital of 1.99 electrons is close enough to ZVAL as 2 defined under tolerance of 0.1, stop going further and not counting 1s orbital in?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could round to the next integer using this cutoff to get the energy config and if not possible raise an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But happy to hear other opinions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could round to the next integer using this cutoff to get the energy config and if not possible raise an error
If sounds pretty similar to above "tolerance" method if I understand correctly? I.e. when current number of electrons is "close enough" to ZVAL (closeness defined by tolerance), stop searching further.
In this case, if we apply tolerance = 0.1
, 2p orbital (0.01 electrons) would be ignored, first counted orbital would be 2s (1.99 electrons), and as it's close enough to ZVAL=2, search would stop and 1s wouldn't be counted.
Am I understanding this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly.
The Lobster basis function search is slightly different. As I just need the orbitals that might be relevant for a projection from the plane waves. Here, we look for the exact valence electrons (and only integer numbers might be allowed).
@shyuep @mkhorton any opinions here as this would be a breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great thanks for confirming. I would implement the change and everyone please feel free to comment (certainly there would be edge cases that I'm not aware of), also ping @esoteric-ephemera maybe
# Fully expand core-electron configuration (replace noble gas notation string) | ||
if isinstance(data[0], str): | ||
sym: str = data[0].replace("[", "").replace("]", "") | ||
data = list(Element(sym).full_electronic_structure) + data[1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks to me like this is the only substantive change to core.periodic_table.py
, which I support. Can you please make sure to mirror these changes in Species.electronic_structure
as well? Unfortunately the method doesn't inherit; it had to be re-implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this! Sure I would port changes to Species.electronic_structure
.
This change was made to make mypy
happy otherwise it would report: tuple
don't have replace
method (as members of data
could be either tuple or str):
pymatgen/src/pymatgen/core/periodic_table.py
Lines 477 to 478 in 5b997f7
if data[0][0] == "[": | |
sym = data[0].replace("[", "").replace("]", "") |
@DanielYang59 thanks for flagging. I'm not qualified to comment on the best way to connect this to I made one comment above to please mirror changes here in |
Summary
PotcarSingle.electron_configuration
, to fix Possibly incorrect electron_configuration returned by vasp.inputs.PotcarSingle #4269Element
/Species
: orderfull_electron_structure
by energy #3944