Last active
May 29, 2020 15:59
-
-
Save agagniere/1e88b3fd14dd3b938bf606880290f1c9 to your computer and use it in GitHub Desktop.
Generate the electronic configuration of neutral atoms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Possible names of this ordering rule : | |
# * Madelung rule (after Erwin Madelung) | |
# * Janet rule (after Charles Janet) | |
# * Klechkowsky rule (after Vsevolod Klechkovsky) | |
# * aufbau approximation | |
# * Uncle Wiggly path or | |
# * diagonal rule | |
def aufbau(): | |
i = 0 | |
while True: | |
subshell = i // 2 | |
shell = i - subshell | |
while (subshell >= 0): | |
yield (subshell,shell) | |
subshell -= 1 | |
shell += 1 | |
i += 1 | |
# Returns the size of the subshell of index i | |
# It is the sequence 2, 6, 10, 14, ... | |
subshell_size = lambda i: 4 * i + 2 | |
# Returns the theorical electronic configuration of the neutral atom | |
# with _atomic_number_ protons in its neucleus | |
def electronic_configuration(atomic_number): | |
result = [] | |
electrons = atomic_number | |
for subshell, shell in aufbau(): | |
current = min(electrons, subshell_size(subshell)) | |
while len(result) <= shell: | |
result += [list()] | |
result[shell] += [current] | |
electrons -= current | |
if not electrons: | |
break | |
return result | |
for n in range(1, 119): | |
print("{:3}: {}".format(n, electronic_configuration(n))) |
by replacing the break
with
offset = (0 if len(result[shell]) == 1 else 34 - 2 * len(result[shell]) ** 2)
return (offset + current, len(result))
one can have the position (starting from (1,1)
to (32,7)
) of the element on the Mendeliev table
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output: