3535
3636# Load element data (periodic table) from JSON file
3737with open (Path (__file__ ).absolute ().parent / "periodic_table.json" , encoding = "utf-8" ) as ptable_json :
38- _pt_data : dict = json .load (ptable_json )
38+ _PT_DATA : dict = json .load (ptable_json )
3939
40- _pt_row_sizes : tuple [int , ...] = (2 , 8 , 8 , 18 , 18 , 32 , 32 )
40+ _PT_ROW_SIZES : tuple [int , ...] = (2 , 8 , 8 , 18 , 18 , 32 , 32 )
4141
42- _madelung : list [tuple [int , str ]] = [
42+ # Madelung energy ordering rule (lower to higher energy)
43+ _MADELUNG : list [tuple [int , str ]] = [
4344 (1 , "s" ),
4445 (2 , "s" ),
4546 (2 , "p" ),
@@ -137,21 +138,21 @@ def __init__(self, symbol: SpeciesLike) -> None:
137138 Solid State Communications, 1984.
138139 """
139140 self .symbol = str (symbol )
140- data = _pt_data [symbol ]
141+ data = _PT_DATA [symbol ]
141142
142143 # Store key variables for quick access
143144 self .Z = data ["Atomic no" ]
144145
145146 self ._is_named_isotope = data .get ("Is named isotope" , False )
146147 if self ._is_named_isotope :
147- for sym , info in _pt_data .items ():
148+ for sym , info in _PT_DATA .items ():
148149 if info ["Atomic no" ] == self .Z and not info .get ("Is named isotope" , False ):
149150 self .symbol = sym
150151 break
151152 # For specified/named isotopes, treat the same as named element
152153 # (the most common isotope). Then we pad the data block with the
153154 # entries for the named element.
154- data = {** _pt_data [self .symbol ], ** data }
155+ data = {** _PT_DATA [self .symbol ], ** data }
155156
156157 at_r = data .get ("Atomic radius" , "no data" )
157158 if str (at_r ).startswith ("no data" ):
@@ -493,7 +494,7 @@ def parse_orbital(orb_str: str) -> str | tuple[int, str, int]:
493494 data = list (Element (sym ).full_electronic_structure ) + data [1 :]
494495
495496 # Sort the final electronic structure by increasing energy level
496- return sorted (data , key = lambda x : _madelung .index ((x [0 ], x [1 ])))
497+ return sorted (data , key = lambda x : _MADELUNG .index ((x [0 ], x [1 ])))
497498
498499 @property
499500 def n_electrons (self ) -> int :
@@ -610,7 +611,7 @@ def from_Z(Z: int, A: int | None = None) -> Element:
610611 Returns:
611612 Element with atomic number Z.
612613 """
613- for sym , data in _pt_data .items ():
614+ for sym , data in _PT_DATA .items ():
614615 atomic_mass_num = data .get ("Atomic mass no" ) if A else None
615616 if data ["Atomic no" ] == Z and atomic_mass_num == A :
616617 return Element (sym )
@@ -631,7 +632,7 @@ def from_name(name: str) -> Element:
631632 uk_to_us = {"aluminium" : "aluminum" , "caesium" : "cesium" }
632633 name = uk_to_us .get (name .lower (), name )
633634
634- for sym , data in _pt_data .items ():
635+ for sym , data in _PT_DATA .items ():
635636 if data ["Name" ] == name .capitalize ():
636637 return Element (sym )
637638
@@ -658,7 +659,7 @@ def from_row_and_group(row: int, group: int) -> Element:
658659 Note:
659660 The 18 group number system is used, i.e. noble gases are group 18.
660661 """
661- for sym in _pt_data :
662+ for sym in _PT_DATA :
662663 el = Element (sym )
663664 if 57 <= el .Z <= 71 :
664665 el_pseudo_row = 8
@@ -698,7 +699,7 @@ def row(self) -> int:
698699 return 6
699700 if 89 <= z <= 103 :
700701 return 7
701- for idx , size in enumerate (_pt_row_sizes , start = 1 ):
702+ for idx , size in enumerate (_PT_ROW_SIZES , start = 1 ):
702703 total += size
703704 if total >= z :
704705 return idx
@@ -1202,7 +1203,7 @@ def parse_orbital(orb_str):
12021203 sym = data [0 ].replace ("[" , "" ).replace ("]" , "" )
12031204 data = list (Element (sym ).full_electronic_structure ) + data [1 :]
12041205 # sort the final electronic structure by increasing energy level
1205- return sorted (data , key = lambda x : _madelung .index ((x [0 ], x [1 ])))
1206+ return sorted (data , key = lambda x : _MADELUNG .index ((x [0 ], x [1 ])))
12061207
12071208 # NOTE - copied exactly from Element. Refactoring / inheritance may improve
12081209 # robustness
0 commit comments