Element
/Species
: order full_electron_structure
by energy
#3944
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This is a follow up to #3902 to address an inconsistent behavior I encountered. The major change in this PR is that
full_electronic_structure
is now always returned as a sorted list according to the Madelung rule, so that the final element is always the valence shell. Prior to this PR, this was sometimes but not always the case, as I elaborate below.Major changes:
Element
andSpecies.full_electronic_structure
are now sorted by increasing energy level according to the Madelung rulevalence
andfull_electronic_structure
both work as expectedn_electrons
property toSpecies
andElement
Background
As we discussed in #3902,
electronic_structure
should not be sorted by energy level, because this is how NIST and many other sources report it (e.g., forCe(0)
we have'[Xe].4f1.5d1.6s2'
).full_electronic_structure
parseselectronic_structure
into a list but did not make any attempt to sort it. In theory, given the above convention, one might expect this to mean thatfull_electronic_structure
always gives orbitals in order of increasing quantum numbers (e.g. 1s, 2s ... 3d, 4s, 4p, 4d, 4f, 5s...), but that was not always the case. For example, it worked forFe(0)
which gavebut for
Ce(0)
we getUltimately, this is caused by the fact that when
electronic_structure
is written in shorthand (for example, Ce is[Xe].4f1.5d1.6s2
),full_electronic_structure
just takes that structure of the atom ([Xe]
) and appends the new orbitals to it. This can result in unpredictable ordering of the orbitals as shown above.valence
DOES make an attempt to sort the orbitals, but because of the issues raised above, it will fail to find the correct valence for someSpecies
.The changes in this PR remedy all of the above problems and ensure that
full_electronic_structure
has a consistent meaning for allElement
andSpecies
.