From 972c7f1d5928fa7fe764bb5c10d64b856f9366af Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Fri, 24 Nov 2017 01:23:36 -0700 Subject: [PATCH 01/11] Added subshell class which describes electrons contained in an atomic subshell. --- SpectroscoPy/atomic/electronConfiguration.py | 300 +++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 SpectroscoPy/atomic/electronConfiguration.py diff --git a/SpectroscoPy/atomic/electronConfiguration.py b/SpectroscoPy/atomic/electronConfiguration.py new file mode 100644 index 0000000..465cd77 --- /dev/null +++ b/SpectroscoPy/atomic/electronConfiguration.py @@ -0,0 +1,300 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Sat Nov 11 02:49:32 2017 + +Class for describing electron configuration for an ion. This will be +used with the term symbol to give a full description of the +energy state of an ion. Two such energy states then define a transition. +There will be a converter function which converts between this class +object description and spectroscopic notation as found in databases +such as NIST. + + +TODO: + -include L-S coupling + +@author: Pawel M. Kozlowski +""" + +# importing python packages +import numpy as np +import pandas as pd +# importing custom packages + +# defining superscript numbers +superNums = str.maketrans("0123456789", "⁰¹²³⁴⁵⁶⁷⁸⁹") +# defining subscript numbers +subNums = str.maketrans("0123456789", "₀₁₂₃₄₅₆₇₈₉") + +# ion (element and ionization stage) +# this defines the total number of electrons + + +# maximum electrons in a shell +def shellElectrons(n): + """ + Given principal quantum number, n, return maximum number of electrons + contained in shell n. + """ + return 2*n**2 + + +# magnetic quantum number (defines specific orbital within subshell) +""" +ml range from -l to +l by integer steps +""" + +# spin projection quantum number (describes spin of electron in given orbital) +""" +ms range from -s to +s by integer steps +for an electron this mean -1/2 or +1/2, therefore only 2 electrons per +orbital due to Pauli exclusion principle +""" + + +# multiplicity (singlet, doublet, triplet, etc) +""" +multiplicity = 2(S+1) +where S = total spin angular momentum, determined by the total spin of +unpaired electrons. Electrons which are already paired in an orbital are +of opposite spin and therefore cancel out. +multiplicity = 1 singlet +multiplicity = 2 doublet +multiplicity = 3 triplet +multiplicity = 4 quartet +multiplicity = 5 quintet + +The number of levels is further determined by the azimuthal quantum number +as well. When S <= L the multiplicity equals the number of spin orientations, +but when S > L there are only 2L+1 orientations of total angular momentum +possible (where total angular momentum is J = L + S). + +example: + S = 3/2 (3 unpaired electrons) + 2S +1 = 4 (quartet) + For an S state, L = 0 + S can range from -S to + S in integer steps, but L is fixed, and J must + be positive. So only possible value of J is J = 0 + 3/2, and there is + only one level even though multiplicity is 4. + +Note that electrons will first fill empty orbitals, so it should be easy to +calculate the number of unpaired electrons, and therefore the multiplicity. + + +One way to get multiplicity is to take total # of possible electrons in +a subshell and divide it by 2 (which then equals 2l+1). +With nElec being the total number of electrons in a subshell... +if nElec <= 2l+1: + # no electrons are paired + S = nElec * 1/2 +elif nElec > 2l+1: + # some electrons will be paired, but how many? + paired = nElec - 2l+1 + # S is then nElec, less the paired electrons, times 1/2 + S = (nElec - 2*paired) * 1/2 + # reducing, which is just the maximum electrons in the subshell, less + # the total number of present electrons. This works because the empty + # spots tell us there are unpaird electrons, since over half the + # subshell is filled! + S = (2(2l+1) - nElec) * 1/2 +""" + + +# fine structure splitting is due to spin-orbit coupling of electron + +# hyperfine structure splitting (would need to include magnetic dipole +# moment of the nucleus) + + +#%% +# term, level, state, parity + +# x-ray spectroscopic notation for principal quantum numbers (shells) +xrayNotation = ['K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z', + ] +principals = np.arange(0,len(xrayNotation)) + 1 +# constructing dataframe for converting x-ray notation symbols to +# principal quantum numbers +xrayShellsDf = pd.DataFrame(data=principals, index=xrayNotation, columns=['n']) +# example looking up number using symbol, in this case looking up +# shell 'M' +print(xrayShellsDf['n']['M']) + + + + + +symbols = ['s', + 'p', + 'd', + 'f', + 'g', + 'h', + 'i', + 'k', + 'l', + 'm', + 'n', + 'o', + 'q', + 'r', + 't', + 'u', + 'v', + 'w', + 'x', + 'y', + 'z', + ] +azis = np.arange(0,len(symbols)) + +# constructing dataframe for converting spdf symbols to azimuthal quantum +# number and back again +subshellsDf = pd.DataFrame(data=azis, index=symbols, columns=['l']) +subshellsDf['sym'] = symbols + +# example looking up number using symbol, in this case looking up +# subshell 'f' +print(subshellsDf['l']['f']) +# example looking up symbol using number, in this case looking up +# symbol for subshell l=3 +print(subshellsDf['sym'][3]) + +#%% subshell configurations + +class SubshellConfiguration(): + """ + Object for describing atomic subshells containing electrons. + """ + def __init__(self, principalNum, aziNum, electronsNum): + """ + Populating a specific subshell, described by principal quantum + number and azimuthal quantum number, with electronsNum number of + electrons. + This will check whether the number of electrons is allowed. + """ + # check that given numbers are within allowable range (positive) + if not principalNum >= 1: + raise ValueError("Principal quantum number must be n >= 1.") + if not aziNum >= 0: + raise ValueError("Azimuthal quantum number must be l >= 0.") + # assigning principal and azimuthal quantum numbers to object + self.principal = principalNum + self.aziNum = aziNum + # check if azimuthal quantum number exists for principal quantum number + self.existsSubshell() + # check if number of electrons is allowed + maxElectrons = self.subshellElectrons() + if electronsNum > maxElectrons: + raise ValueError(f"Given number of electrons is {electronsNum}, " + f"which is more than maximum, {maxElectrons}.") + # assign electrons + self.electrons = electronsNum + def n(self): + """ + return principal quantum number. + """ + return self.principal + def l(self): + """ + return azimuthal quantum number. + """ + return self.aziNum + def elec(self): + """ + return number of electrons in subshell. + """ + return self.electrons + def __str__(self): + """ + Displays subshell configuration in standard spectroscopic notation. + """ + # convert principal and azimuthal quantum numbers into symbols + principalSym = str(self.principal) + aziSym = subshellsDf['sym'][self.aziNum] + # convert number of electrons to superscript + electronsSym = (str(self.electrons)).translate(superNums) + # concatenating + subshellSym = principalSym + aziSym + electronsSym + return subshellSym + def existsSubshell(self, principal=np.nan, aziNum=np.nan): + """ + Checks if azimuthal quantum number (subshell) exists within the + principal quantum number. + """ + # if arguments aren't passed then use parameters given in object + if np.isnan(principal): + principal = self.principal + if np.isnan(aziNum): + aziNum = self.aziNum + # azimuthal number must be 0 <= l <= n-1 + if not aziNum <= (principal - 1): + raise ValueError(f"Azimuthal number {aziNum} does not exist " + f"for principal quantum number {principal}.") + return + def subshellElectrons(self, aziNum=np.nan): + """ + Given azimuthal quantum number, return maximum number of electrons + in the subshell. + Symbol for azimuthal quantum number is lowercase, cursive L. + """ + # if parameters aren't passed then use parameters given in object + if np.isnan(aziNum): + aziNum = self.aziNum + return 2 * (2 * aziNum + 1) + +# testing subshell class +testSubshell = SubshellConfiguration(principalNum=2, + aziNum=1, + electronsNum=5) +print(testSubshell) + +#%% full electron configurations + +class ElectronConfiguration(): + """ + Object for describing the electron configuration of an atom/ion. + """ + + def __init__(self): + """ + """ + def display(self): + """ + """ + + +#%% term symbol description + + +#%% full energy level description, this includes an electron configuration +# and a term symbol + +class EnergyLevel(): + """ + """ + def __init__(self, electronConfiguration, termSymbol): + """ + """ + def null(): + """ + """ + def display(self): + """ + """ \ No newline at end of file From 074af5b47086c80d8f3af3cff9ce822ab18093dd Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Wed, 6 Dec 2017 15:31:53 -0700 Subject: [PATCH 02/11] Ignoring spyder project directory in .gitignore. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 20bdbba..4f44ff0 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ distribute-*.tar.gz # Linux directory files *.directory + +# spyder project directory +.spyproject From a6c50e97c90008c8ceadf9498a8899b805cfbc3f Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Sat, 16 Dec 2017 01:54:46 -0700 Subject: [PATCH 03/11] Initial class description for atomic subshells, plus some notation. Subshells will then be built into full electron configurations. Full electron configurations will then be joined with term symbol to describe energy level. Two energy levels will then describe a transition. Should then generate a way of handling sets of these transition objects for the purposes of simulations. --- SpectroscoPy/atomic/electronConfiguration.py | 32 +++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/SpectroscoPy/atomic/electronConfiguration.py b/SpectroscoPy/atomic/electronConfiguration.py index 465cd77..91aba77 100644 --- a/SpectroscoPy/atomic/electronConfiguration.py +++ b/SpectroscoPy/atomic/electronConfiguration.py @@ -264,9 +264,34 @@ def subshellElectrons(self, aziNum=np.nan): aziNum=1, electronsNum=5) print(testSubshell) + + +#%% term symbol + +class TermSymbol(): + """ + """ + def __init__(self): + """ + """ + def __str__(self): + """ + """ + # spin state (e.g. doublet, triplet). This becomes the superscript + + # azimuthal quantum number, L. This becomes the letter symbol + + # total angular momentum quantum number, J. This becomes the + # subscript. + #%% full electron configurations +# One way to describe the electron configuration is as a collection of +# subshell configurations. Undefined subshells are considered empty. +# Could add function to subshell configuration to define and populate +# the object by using spectroscopic notation. + class ElectronConfiguration(): """ Object for describing the electron configuration of an atom/ion. @@ -275,7 +300,7 @@ class ElectronConfiguration(): def __init__(self): """ """ - def display(self): + def __str__(self): """ """ @@ -292,9 +317,6 @@ class EnergyLevel(): def __init__(self, electronConfiguration, termSymbol): """ """ - def null(): - """ - """ - def display(self): + def __str__(self): """ """ \ No newline at end of file From 6a36d38cdce4b79aeda124778ab2fd6de584d82c Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Sat, 16 Dec 2017 01:58:53 -0700 Subject: [PATCH 04/11] pep8 fixes. --- SpectroscoPy/atomic/electronConfiguration.py | 35 +++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/SpectroscoPy/atomic/electronConfiguration.py b/SpectroscoPy/atomic/electronConfiguration.py index 91aba77..e334269 100644 --- a/SpectroscoPy/atomic/electronConfiguration.py +++ b/SpectroscoPy/atomic/electronConfiguration.py @@ -37,7 +37,7 @@ def shellElectrons(n): Given principal quantum number, n, return maximum number of electrons contained in shell n. """ - return 2*n**2 + return 2 * n**2 # magnetic quantum number (defines specific orbital within subshell) @@ -103,7 +103,7 @@ def shellElectrons(n): # fine structure splitting is due to spin-orbit coupling of electron -# hyperfine structure splitting (would need to include magnetic dipole +# hyperfine structure splitting (would need to include magnetic dipole # moment of the nucleus) @@ -128,7 +128,7 @@ def shellElectrons(n): 'Y', 'Z', ] -principals = np.arange(0,len(xrayNotation)) + 1 +principals = np.arange(0, len(xrayNotation)) + 1 # constructing dataframe for converting x-ray notation symbols to # principal quantum numbers xrayShellsDf = pd.DataFrame(data=principals, index=xrayNotation, columns=['n']) @@ -137,9 +137,6 @@ def shellElectrons(n): print(xrayShellsDf['n']['M']) - - - symbols = ['s', 'p', 'd', @@ -162,7 +159,7 @@ def shellElectrons(n): 'y', 'z', ] -azis = np.arange(0,len(symbols)) +azis = np.arange(0, len(symbols)) # constructing dataframe for converting spdf symbols to azimuthal quantum # number and back again @@ -178,10 +175,12 @@ def shellElectrons(n): #%% subshell configurations + class SubshellConfiguration(): """ Object for describing atomic subshells containing electrons. """ + def __init__(self, principalNum, aziNum, electronsNum): """ Populating a specific subshell, described by principal quantum @@ -206,21 +205,25 @@ def __init__(self, principalNum, aziNum, electronsNum): f"which is more than maximum, {maxElectrons}.") # assign electrons self.electrons = electronsNum + def n(self): """ return principal quantum number. """ return self.principal + def l(self): """ return azimuthal quantum number. """ return self.aziNum + def elec(self): """ return number of electrons in subshell. """ return self.electrons + def __str__(self): """ Displays subshell configuration in standard spectroscopic notation. @@ -233,6 +236,7 @@ def __str__(self): # concatenating subshellSym = principalSym + aziSym + electronsSym return subshellSym + def existsSubshell(self, principal=np.nan, aziNum=np.nan): """ Checks if azimuthal quantum number (subshell) exists within the @@ -248,6 +252,7 @@ def existsSubshell(self, principal=np.nan, aziNum=np.nan): raise ValueError(f"Azimuthal number {aziNum} does not exist " f"for principal quantum number {principal}.") return + def subshellElectrons(self, aziNum=np.nan): """ Given azimuthal quantum number, return maximum number of electrons @@ -259,6 +264,7 @@ def subshellElectrons(self, aziNum=np.nan): aziNum = self.aziNum return 2 * (2 * aziNum + 1) + # testing subshell class testSubshell = SubshellConfiguration(principalNum=2, aziNum=1, @@ -271,19 +277,21 @@ def subshellElectrons(self, aziNum=np.nan): class TermSymbol(): """ """ + def __init__(self): """ """ + def __str__(self): """ """ # spin state (e.g. doublet, triplet). This becomes the superscript - + # azimuthal quantum number, L. This becomes the letter symbol - + # total angular momentum quantum number, J. This becomes the # subscript. - + #%% full electron configurations @@ -296,10 +304,11 @@ class ElectronConfiguration(): """ Object for describing the electron configuration of an atom/ion. """ - + def __init__(self): """ """ + def __str__(self): """ """ @@ -314,9 +323,11 @@ def __str__(self): class EnergyLevel(): """ """ + def __init__(self, electronConfiguration, termSymbol): """ """ + def __str__(self): """ - """ \ No newline at end of file + """ From 5988247571a4175c444f19a91d34c6d30b1ea327 Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Sat, 16 Dec 2017 02:07:38 -0700 Subject: [PATCH 05/11] Added pandas dependency (hopefully). --- requirements/base.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/base.txt b/requirements/base.txt index fdbe13c..97fe8eb 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,3 +1,4 @@ numpy (>= 1.13) scipy (>= 0.19) astropy (>= 2.0) +pandas (>=0.20.3) From 7ba4d84f6b0d4a966d84217257deddcdd21de2dc Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Wed, 20 Dec 2017 15:44:31 +0100 Subject: [PATCH 06/11] Added small comments what s, p, d, f mean. Added file for testing electronConfiguration.py --- SpectroscoPy/atomic/electronConfiguration.py | 8 ++++---- .../atomic/tests/test_electronConfiguration.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 SpectroscoPy/atomic/tests/test_electronConfiguration.py diff --git a/SpectroscoPy/atomic/electronConfiguration.py b/SpectroscoPy/atomic/electronConfiguration.py index e334269..2bb1e78 100644 --- a/SpectroscoPy/atomic/electronConfiguration.py +++ b/SpectroscoPy/atomic/electronConfiguration.py @@ -137,10 +137,10 @@ def shellElectrons(n): print(xrayShellsDf['n']['M']) -symbols = ['s', - 'p', - 'd', - 'f', +symbols = ['s', # sharp + 'p', # principal + 'd', # diffuse + 'f', # fundamental/fine 'g', 'h', 'i', diff --git a/SpectroscoPy/atomic/tests/test_electronConfiguration.py b/SpectroscoPy/atomic/tests/test_electronConfiguration.py new file mode 100644 index 0000000..d54d029 --- /dev/null +++ b/SpectroscoPy/atomic/tests/test_electronConfiguration.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Wed Dec 20 15:41:47 2017 + +@author: Pawel M. Kozlowski +""" + +import pytest +import numpy as np \ No newline at end of file From 04ea7ee998cd8b096636166c690e33a3863f954e Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Wed, 20 Dec 2017 16:21:07 +0100 Subject: [PATCH 07/11] Added simple methods for EnergyLevel(), __str__(), configuration(), and term(). --- SpectroscoPy/atomic/electronConfiguration.py | 62 +++++++++++++------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/SpectroscoPy/atomic/electronConfiguration.py b/SpectroscoPy/atomic/electronConfiguration.py index 2bb1e78..43c2933 100644 --- a/SpectroscoPy/atomic/electronConfiguration.py +++ b/SpectroscoPy/atomic/electronConfiguration.py @@ -13,6 +13,12 @@ TODO: -include L-S coupling + -include functions/methods without L-S coupling assumption + -use subshellConfiguration() in electronConfiguration() + -use electronConfiguration() and termSymbol() for energyLevel() + -use 2 energyLevel() objects for transition() object + -Create system for managing/saving/converting list of transition() objs + -add tests for allowed/forbidden transitions @author: Pawel M. Kozlowski """ @@ -174,8 +180,6 @@ def shellElectrons(n): print(subshellsDf['sym'][3]) #%% subshell configurations - - class SubshellConfiguration(): """ Object for describing atomic subshells containing electrons. @@ -272,10 +276,16 @@ def subshellElectrons(self, aziNum=np.nan): print(testSubshell) -#%% term symbol +#%% full electron configurations -class TermSymbol(): +# One way to describe the electron configuration is as a collection of +# subshell configurations. Undefined subshells are considered empty. +# Could add function to subshell configuration to define and populate +# the object by using spectroscopic notation. + +class ElectronConfiguration(): """ + Object for describing the electron configuration of an atom/ion. """ def __init__(self): @@ -285,24 +295,12 @@ def __init__(self): def __str__(self): """ """ - # spin state (e.g. doublet, triplet). This becomes the superscript - # azimuthal quantum number, L. This becomes the letter symbol - - # total angular momentum quantum number, J. This becomes the - # subscript. - - -#%% full electron configurations -# One way to describe the electron configuration is as a collection of -# subshell configurations. Undefined subshells are considered empty. -# Could add function to subshell configuration to define and populate -# the object by using spectroscopic notation. +#%% term symbol description -class ElectronConfiguration(): +class TermSymbol(): """ - Object for describing the electron configuration of an atom/ion. """ def __init__(self): @@ -312,9 +310,12 @@ def __init__(self): def __str__(self): """ """ + # spin state (e.g. doublet, triplet). This becomes the superscript + # azimuthal quantum number, L. This becomes the letter symbol -#%% term symbol description + # total angular momentum quantum number, J. This becomes the + # subscript. #%% full energy level description, this includes an electron configuration @@ -323,11 +324,32 @@ def __str__(self): class EnergyLevel(): """ """ - def __init__(self, electronConfiguration, termSymbol): """ """ + # initialize electron configuration + self.electronConfiguration = electronConfiguration + # initialize term symbol + self.termSymbol = termSymbol def __str__(self): """ + String representation of enery level. This is just the string + representations of the electron configuration and term symbol. + """ + # fetching electron configuration and term symbol strings. + configStr = self.electronConfiguration.__str__() + termStr = self.termSymbol.__str__() + # concatenating + energyStr = configStr + ' ' + termStr + return energyStr + def configuration(self): + """ + Returns full electron configuration. + """ + return self.electronConfiguration + def term(self): + """ + Returns term symbol. """ + return self.termSymbol From c7ce036d9d993e2b077d585421aff5ac8d0abc08 Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Wed, 20 Dec 2017 16:50:13 +0100 Subject: [PATCH 08/11] Started adding empty object initialization. --- SpectroscoPy/atomic/electronConfiguration.py | 55 +++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/SpectroscoPy/atomic/electronConfiguration.py b/SpectroscoPy/atomic/electronConfiguration.py index 43c2933..1b65846 100644 --- a/SpectroscoPy/atomic/electronConfiguration.py +++ b/SpectroscoPy/atomic/electronConfiguration.py @@ -12,6 +12,7 @@ TODO: + -overload objects to give if empty behavior -include L-S coupling -include functions/methods without L-S coupling assumption -use subshellConfiguration() in electronConfiguration() @@ -267,6 +268,18 @@ def subshellElectrons(self, aziNum=np.nan): if np.isnan(aziNum): aziNum = self.aziNum return 2 * (2 * aziNum + 1) + def str2obj(configStr): + """ + Method for generating a subshell configuration from spectroscopic + notation string. + """ + # split string into components + + # test that string is valid + + # generate subshell configuration object + subshellConfig = + return subshellConfig # testing subshell class @@ -288,13 +301,53 @@ class ElectronConfiguration(): Object for describing the electron configuration of an atom/ion. """ - def __init__(self): + def __init__(self, subshells): """ + Initializes electron configuration using a list of + SubshellConfiguration() objects. It is assumed that + any subshells which are not given are empty. """ + # check that list has at least 1 element, if not + # create an empty configuration object representing a fully + # ionized particle + if not subshells: + # empty configuration + + # test that all objects in list are SubshellConfiguration() + # objects + + # test that there are no conflicting subshells, i.e., same + # principal and azimuthal quantum numbers + def __str__(self): """ """ + def str2obj(self): + """ + Initialize an electron configuration using spectroscopic notation + string. + """ + # break string into substrings, with each one representing + # a subshell configuration. + + # test that string is valid + + # combine subshell configurations to form full electron configuration. + + return configObj + def subshell(self, principalNum, aziNum): + """ + Return SubhshellConfiguration() object for a particular subshell + corresponding to principal and azimuthal quantum numbers. + """ + return + def empty(): + """ + Generate an empty configuration representing a fully ionized + particle. + """ + return ElectronConfiguration([]) #%% term symbol description From 2d7a4dde79387e43e2b0bab978743e46b71ce7b0 Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Thu, 21 Dec 2017 15:01:39 +0100 Subject: [PATCH 09/11] Added empty ElectronConfiguration() and __bool__ method. --- SpectroscoPy/atomic/electronConfiguration.py | 66 ++++++++++++++++---- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/SpectroscoPy/atomic/electronConfiguration.py b/SpectroscoPy/atomic/electronConfiguration.py index 1b65846..faf8630 100644 --- a/SpectroscoPy/atomic/electronConfiguration.py +++ b/SpectroscoPy/atomic/electronConfiguration.py @@ -12,7 +12,8 @@ TODO: - -overload objects to give if empty behavior + -add square bracket functionality NIST + - __bool__ behavior for configurations, terms, energies, etc -include L-S coupling -include functions/methods without L-S coupling assumption -use subshellConfiguration() in electronConfiguration() @@ -210,7 +211,6 @@ def __init__(self, principalNum, aziNum, electronsNum): f"which is more than maximum, {maxElectrons}.") # assign electrons self.electrons = electronsNum - def n(self): """ return principal quantum number. @@ -228,7 +228,6 @@ def elec(self): return number of electrons in subshell. """ return self.electrons - def __str__(self): """ Displays subshell configuration in standard spectroscopic notation. @@ -241,7 +240,18 @@ def __str__(self): # concatenating subshellSym = principalSym + aziSym + electronsSym return subshellSym - + def __eq__(self, other): + """ + Test if 2 subshell configurations are identical. + """ + # check if other is a SubshellConfigration() object + if not isinstance(other, SubshellConfiguration): + raise ValueError(f"{other} is not a SubshellConfiguration().") + principalEq = self.n() == other.n() + aziEq = self.l() == other.l() + electronsEq = self.elec() == other.elec() + totalEq = principalEq and aziEq and electronsEq + return totalEq def existsSubshell(self, principal=np.nan, aziNum=np.nan): """ Checks if azimuthal quantum number (subshell) exists within the @@ -258,14 +268,14 @@ def existsSubshell(self, principal=np.nan, aziNum=np.nan): f"for principal quantum number {principal}.") return - def subshellElectrons(self, aziNum=np.nan): + def subshellElectrons(self, aziNum=None): """ Given azimuthal quantum number, return maximum number of electrons in the subshell. Symbol for azimuthal quantum number is lowercase, cursive L. """ # if parameters aren't passed then use parameters given in object - if np.isnan(aziNum): + if aziNum == None: aziNum = self.aziNum return 2 * (2 * aziNum + 1) def str2obj(configStr): @@ -307,11 +317,10 @@ def __init__(self, subshells): SubshellConfiguration() objects. It is assumed that any subshells which are not given are empty. """ - # check that list has at least 1 element, if not - # create an empty configuration object representing a fully - # ionized particle - if not subshells: - # empty configuration + # test that subshells is a list or numpy array + + # convert subshells into a numpy array if it is a list + # test that all objects in list are SubshellConfiguration() # objects @@ -319,9 +328,41 @@ def __init__(self, subshells): # test that there are no conflicting subshells, i.e., same # principal and azimuthal quantum numbers - + # drop any empty subshells from the list + + # organize the list of subshells according to principal + # quantum number and azimuthal number + subshellsOrdered = + + # if an empty list is passed then an empty configuration object + # is created. This represents a fully ionized particle + self.subshells = subshellsOrdered + def __eq__(self, other): + """ + Check if 2 electron configurations are equal. This is done + by checking if lists of subshells are equal. + """ + # test if argument is an ElectronConfiguration() + if not isinstance(other, ElectronConfiguration): + raise ValueError(f"{other} is not an ElectronConfiguration().") + # test equivalence of subshells + eq = (other.subshells == self.subshells).all() + return eq + def __bool__(self): + """ + Method for determining if class value is True or False. + ElectronConfigration() is False when it is empty, and True when + there is at least one subshell. + """ + # since subshells is a list which describes the configuration, when + # the list is empty then the configuration is False. + return bool(self.subshells) def __str__(self): """ + An electron configuration consists of an ordered list of subshell + configurations. + !!!May also include quantities in square brackets, but still + need to figure out what those mean!!! """ def str2obj(self): """ @@ -348,6 +389,7 @@ def empty(): particle. """ return ElectronConfiguration([]) + #%% term symbol description From 5615029e9450a19cc529ab8f1e839161f61f20ae Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Mon, 30 Apr 2018 15:20:59 -0600 Subject: [PATCH 10/11] misc changes (don't remember). --- SpectroscoPy/atomic/electronConfiguration.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/SpectroscoPy/atomic/electronConfiguration.py b/SpectroscoPy/atomic/electronConfiguration.py index faf8630..9488921 100644 --- a/SpectroscoPy/atomic/electronConfiguration.py +++ b/SpectroscoPy/atomic/electronConfiguration.py @@ -16,11 +16,12 @@ - __bool__ behavior for configurations, terms, energies, etc -include L-S coupling -include functions/methods without L-S coupling assumption + -include jj coupling scheme methods -use subshellConfiguration() in electronConfiguration() -use electronConfiguration() and termSymbol() for energyLevel() -use 2 energyLevel() objects for transition() object -Create system for managing/saving/converting list of transition() objs - -add tests for allowed/forbidden transitions + -add "selection rules" tests for allowed/forbidden transitions @author: Pawel M. Kozlowski """ @@ -389,6 +390,21 @@ def empty(): particle. """ return ElectronConfiguration([]) + def unpaired(self): + """ + Returns the number of unpaired electrons. + """ + def multiplicity(self): + """ + Spin multiplicity, calculated based on the number of unpaired + electrons. + """ + def multiplet(self): + """ + Returns whether the configuration is in a singlet, doublet, triplet, + etc. state based on the multiplicty and limitations on the number + of spin orientations, when S <= L. + """ From 55a3ff184b3d5e05b4bb4ff9bdbb1d4aa72555f7 Mon Sep 17 00:00:00 2001 From: Pawel Marek Kozlowski Date: Thu, 10 May 2018 22:10:12 -0600 Subject: [PATCH 11/11] Moving electron configuration class stuff to SpectroscoPyx directory from SpectroscoPy due to package name change. --- {SpectroscoPy => SpectroscoPyx}/atomic/electronConfiguration.py | 0 .../atomic/tests/test_electronConfiguration.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {SpectroscoPy => SpectroscoPyx}/atomic/electronConfiguration.py (100%) rename {SpectroscoPy => SpectroscoPyx}/atomic/tests/test_electronConfiguration.py (100%) diff --git a/SpectroscoPy/atomic/electronConfiguration.py b/SpectroscoPyx/atomic/electronConfiguration.py similarity index 100% rename from SpectroscoPy/atomic/electronConfiguration.py rename to SpectroscoPyx/atomic/electronConfiguration.py diff --git a/SpectroscoPy/atomic/tests/test_electronConfiguration.py b/SpectroscoPyx/atomic/tests/test_electronConfiguration.py similarity index 100% rename from SpectroscoPy/atomic/tests/test_electronConfiguration.py rename to SpectroscoPyx/atomic/tests/test_electronConfiguration.py