Skip to content

Commit

Permalink
Fix bug in atomic configuration state
Browse files Browse the repository at this point in the history
  • Loading branch information
xnx committed Nov 2, 2022
1 parent a18081d commit a358627
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -8,7 +8,7 @@

setup(
name="pyvalem",
version="2.5.11",
version="2.5.12",
description="A package for managing simple chemical species and states",
long_description=long_description,
long_description_content_type="text/x-rst",
Expand Down
2 changes: 1 addition & 1 deletion src/pyvalem/states/atomic_configuration.py
Expand Up @@ -327,7 +327,7 @@ def _expand_noble_gas_config(self, config):

def _contract_to_noble_gas_config(self, state_str):
"""Replace explicit atomic orbital sequence with noble gas notation."""
for noble_gas in noble_gases[::-3]:
for noble_gas in noble_gases[:1:-1]:
config = noble_gas_configs[noble_gas]
if config in state_str:
state_str = state_str.replace(config, f"[{noble_gas}]")
Expand Down
11 changes: 8 additions & 3 deletions tests/test_atomic_configurations.py
Expand Up @@ -69,9 +69,14 @@ def test_atomic_configuration_equality(self):
self.assertEqual(c5.state_str, "[Ne].3s")
self.assertEqual(c5.html, "[Ne]3s")

c5 = AtomicConfiguration("1s2.2s2.2p6")
self.assertEqual(repr(c5), "1s2.2s2.2p6")
self.assertEqual(c5.state_str, "1s2.2s2.2p6")
c6 = AtomicConfiguration("1s2.2s2.2p6")
self.assertEqual(repr(c6), "1s2.2s2.2p6")
self.assertEqual(c6.state_str, "1s2.2s2.2p6")

c7 = AtomicConfiguration("1s2.2s2.2p6.3s2.3p6.3d10.4s2.4p6.4d10.5s2.5p6.5d1")
self.assertEqual(repr(c7), "1s2.2s2.2p6.3s2.3p6.3d10.4s2.4p6.4d10.5s2.5p6.5d")
self.assertEqual(c7.state_str, "[Xe].5d1")
self.assertEqual(c7.html, "[Xe]5d")

def test_excited_atomic_configuration(self):
c1 = AtomicConfiguration("5g1")
Expand Down

0 comments on commit a358627

Please sign in to comment.