1212
1313
1414TODO:
15- -overload objects to give if empty behavior
15+ -add square bracket functionality NIST
16+ - __bool__ behavior for configurations, terms, energies, etc
1617 -include L-S coupling
1718 -include functions/methods without L-S coupling assumption
1819 -use subshellConfiguration() in electronConfiguration()
@@ -210,7 +211,6 @@ def __init__(self, principalNum, aziNum, electronsNum):
210211 f"which is more than maximum, { maxElectrons } ." )
211212 # assign electrons
212213 self .electrons = electronsNum
213-
214214 def n (self ):
215215 """
216216 return principal quantum number.
@@ -228,7 +228,6 @@ def elec(self):
228228 return number of electrons in subshell.
229229 """
230230 return self .electrons
231-
232231 def __str__ (self ):
233232 """
234233 Displays subshell configuration in standard spectroscopic notation.
@@ -241,7 +240,18 @@ def __str__(self):
241240 # concatenating
242241 subshellSym = principalSym + aziSym + electronsSym
243242 return subshellSym
244-
243+ def __eq__ (self , other ):
244+ """
245+ Test if 2 subshell configurations are identical.
246+ """
247+ # check if other is a SubshellConfigration() object
248+ if not isinstance (other , SubshellConfiguration ):
249+ raise ValueError (f"{ other } is not a SubshellConfiguration()." )
250+ principalEq = self .n () == other .n ()
251+ aziEq = self .l () == other .l ()
252+ electronsEq = self .elec () == other .elec ()
253+ totalEq = principalEq and aziEq and electronsEq
254+ return totalEq
245255 def existsSubshell (self , principal = np .nan , aziNum = np .nan ):
246256 """
247257 Checks if azimuthal quantum number (subshell) exists within the
@@ -258,14 +268,14 @@ def existsSubshell(self, principal=np.nan, aziNum=np.nan):
258268 f"for principal quantum number { principal } ." )
259269 return
260270
261- def subshellElectrons (self , aziNum = np . nan ):
271+ def subshellElectrons (self , aziNum = None ):
262272 """
263273 Given azimuthal quantum number, return maximum number of electrons
264274 in the subshell.
265275 Symbol for azimuthal quantum number is lowercase, cursive L.
266276 """
267277 # if parameters aren't passed then use parameters given in object
268- if np . isnan ( aziNum ) :
278+ if aziNum == None :
269279 aziNum = self .aziNum
270280 return 2 * (2 * aziNum + 1 )
271281 def str2obj (configStr ):
@@ -307,21 +317,52 @@ def __init__(self, subshells):
307317 SubshellConfiguration() objects. It is assumed that
308318 any subshells which are not given are empty.
309319 """
310- # check that list has at least 1 element, if not
311- # create an empty configuration object representing a fully
312- # ionized particle
313- if not subshells :
314- # empty configuration
320+ # test that subshells is a list or numpy array
321+
322+ # convert subshells into a numpy array if it is a list
323+
315324
316325 # test that all objects in list are SubshellConfiguration()
317326 # objects
318327
319328 # test that there are no conflicting subshells, i.e., same
320329 # principal and azimuthal quantum numbers
321330
322-
331+ # drop any empty subshells from the list
332+
333+ # organize the list of subshells according to principal
334+ # quantum number and azimuthal number
335+ subshellsOrdered =
336+
337+ # if an empty list is passed then an empty configuration object
338+ # is created. This represents a fully ionized particle
339+ self .subshells = subshellsOrdered
340+ def __eq__ (self , other ):
341+ """
342+ Check if 2 electron configurations are equal. This is done
343+ by checking if lists of subshells are equal.
344+ """
345+ # test if argument is an ElectronConfiguration()
346+ if not isinstance (other , ElectronConfiguration ):
347+ raise ValueError (f"{ other } is not an ElectronConfiguration()." )
348+ # test equivalence of subshells
349+ eq = (other .subshells == self .subshells ).all ()
350+ return eq
351+ def __bool__ (self ):
352+ """
353+ Method for determining if class value is True or False.
354+ ElectronConfigration() is False when it is empty, and True when
355+ there is at least one subshell.
356+ """
357+ # since subshells is a list which describes the configuration, when
358+ # the list is empty then the configuration is False.
359+ return bool (self .subshells )
323360 def __str__ (self ):
324361 """
362+ An electron configuration consists of an ordered list of subshell
363+ configurations.
364+ !!!May also include quantities in square brackets, but still
365+ need to figure out what those mean!!!
325366 """
326367 def str2obj (self ):
327368 """
@@ -348,6 +389,7 @@ def empty():
348389 particle.
349390 """
350391 return ElectronConfiguration ([])
392+
351393
352394
353395#%% term symbol description
0 commit comments