classes¶
Module containing the core classes of the GainCalculator project. End user should not be concerned about this. A convention is used that principal quantum number is denoted n and orbital quantum number is denoted l, keep this in mind.
-
class
Atom(symbol, config_groups, data_folder)[source] This class represents a specific atom with given configuration. Initialize it like this:
Atom( symbol="Fe", config_groups=ConfigGroups( base="1*2 2*8", max_n=4 ), data_folder = "./data", log = lambda: current, total: print "{}% done".format(current / total * 100) )
Parameters: - symbol (str) – A symbol of the element, eg. “Ge” for germanium
- config_groups (ConfigGroups) – Instance of class ConfigGroups representing possible shell configurations.
For more info see
ConfigGroups. - data_folder (str) – Folder where the atomic data are stored, if it doesnt exist, it will be created
-
get_combined_populations(energy_level, temperatures, electron_densities, population_total=1.0, log=None)[source] Convenience wrapper around get_populations with combine parameter set to itertools.product. Thus it performs the calculation over all possible combinations of temperature and density.
Parameters: - energy_level (EnergyLevel) – the energy level instance
- temperatures (ndarray) – temperature in eV (could be iterable)
- electron_densities (ndarray) – electron density in cm^-3 (could be iterable)
- population_total (float) – 1 by default
- log (func) – Function that get called each time an iteration is made. The passed arguments are current index
of the iteration and total length of the iteration. The function is None by default, meaning none is called. :return: numpy structured array with named fields population, electron_density and temperature**
-
get_populations(energy_level, temperatures, electron_densities, combine, population_total=1.0, log=None)[source] Get electron population on single energy level at given temperature and electron density given by arrays/lists. The calculation will be done over the list of tuples generated by applying combine on temperatures and electron_densities. The calculation is done for all energy levels in given atom. Population total is the sum of populations of all energy levels. By default this is 1 and the function returns relative populations. Eg. 0.1 means 10% of all electrons are at energy_level. Example usage:
atom = Atom( symbol="Fe", config_groups=ConfigGroups( base="1*2 2*8", max_n=4 ) ) result = atom.get_population( energy_level=EnergyLevel(config="1s+2(0)0 2s+2(0)0 2p-2(0)0 2p+3(3)3 3s+1(1)4"), temperatures=[900.0, 1000.0] # eV electron_densities=[1e20, 1e21] # cm^-3 combine=itertools.product ) result["population"] # this is an array of populations, len(result["population"]) == 4 # True
Parameters: - energy_level (EnergyLevel) – the energy level instance
- temperatures (ndarray) – temperature in eV (could be iterable)
- electron_densities (ndarray) – electron density in cm^-3 (could be iterable)
- combine (function) – Function taking two lists and returning a single list of tuples
- population_total (float) – 1 by default
- log (func) – Function that get called each time an iteration is made. The passed arguments are current index
of the iteration and total length of the iteration. The function is None by default, meaning none is called. :return: numpy structured array with named fields population, electron_density and temperature
-
class
ConfigGroups(base, max_n)[source] This class represents a set of all possible shell configurations up to max_n concerning only the number of electrons in each shell given by principal quantum number n. There is no end user use of this class aside from providing its instance as a param to other classes. Initialize it like this:
ConfigGroups( base="1*2 2*8", max_n=4 )
Parameters: - base (str) – The base configuration from which all config groups are generated. Notation “1*2 2*8” means there are 2 electron in shell with \(n=1\) and 8 electrons in shell with \(n=2\). Notation with asterisks and spaces must be used at all times.
- max_n (int) –
Maximal principal quantum number \(n\) up to which ConfigGroups are represented:
ConfigGroups(base=1*2 2*8, max_n=4)
represents:
["1*2 2*8", "1*2 2*7 3*1", "1*2 2*7 4*1"]
-
get_max_n()[source]
-
get_names()[source]
-
class
EnergyLevel(config)[source] This class represents a single energy level. Initialize it like this:
EnergyLevel(config="1s+2(0)0 2s+2(0)0 2p-2(0)0 2p+3(3)3 3s+1(1)4")
Parameters: config (str) – A sequence of terms separated by space each representing single shell in jj coupling notation. A shell 5p+3(1)2 has principal quantum number \(n=5\), orbital quantum number \(l = p\). There are three electrons in this shell. The number in brackets is 2 times the total angular momentum \(2J\). Here \(2J\) is 1 hence \(J\) is \(\frac{1}{2}\). The last number is 2 times total angular momentum when taking into account all previous shells here it is 2 meaning total angular momentum of the whole configuration up to this shell is 1. Variables: degeneracy (int) – A number representing the degeneracy of the level. It is usually denoted \(g\). -
get_fac_repr()[source] Returns a string of terms separated by dot. The terms are string representations of LevelTerm. Only terms with shells that are not full are listed :return:
-
get_latex_repr()[source] Generates and returns the latex representation of the energy level as a string. It has the following format: [1s+]^2_0(0) [2s+]^1_1(1), last two numbers are (in order) two times total angular momentum of the shell and two times total angular momentum of the whole system up to this shell. :return str: latex representation of the energy level
-
-
class
LevelTerm(shell, j2)[source] Simple comparable data class representing a term of form 2p+(1)1 where the last number is 2*J (J = total angular momentum over all shells). The rest of the shell notation is documented elsewhere.
Variables: - shell – shell object instance
- j2 – double the value of total angular momentum
-
class
Shell(n, l, spin_direction, double_angular_momentum, electron_count)[source] Class representing a single shell of form 3d+4(2), where 3 is the principal quantum number d is the orbital quantum number (2) + represents spin direction (up), 4 is electron count and 2 is double the value of angular momentum of the shell.
Variables: - n – Starting from 1
- l – Given by value, use Shell.orbital_numbers for convenience
- spin_direction – expects “+” or “-” representing spin up and down
- double_angular_momentum – 2*J value (of shell only) e.g. two electrons up give 2*J=2
- electron_count – number of electrons in the shell
- orbital_numbers – mapping of orbital letters to numbers
- orbital_letters – inverse mapping to orbital numbers
- spin_direction_sign – mapping from “-” to -1 and “+” to 1
-
static
create_from_string(shell_repr)[source] Factory method to deconstruct a string of form 3d+4(2) and create a Shell instance based on it :param shell_repr: string to deconstruct :return: instance of Shell
-
get_latex_repr()[source] Method to generate shell representation in latex format :return: Representation of Shell analogous to “[2p+]^4_0”
-
is_full()[source] Returns true if there is maximum number of electrons in the shell :return:
-
orbital_letters= {0: 's', 1: 'p', 2: 'd', 3: 'f', 4: 'g', 5: 'h', 6: 'i'}
-
orbital_numbers= {'d': 2, 'f': 3, 'g': 4, 'h': 5, 'i': 6, 'p': 1, 's': 0}
-
spin_direction_sign= {'+': 1, '-': -1}
-
class
Transition(atom, lower, upper)[source] This class represents a transition between upper and lower energy levels. Initialize it like this:
atom = Atom( symbol="Fe", config_groups=ConfigGroups( base="1*2 2*8", max_n=4 ) ) Transition( atom=atom, lower=core.EnergyLevel("1s+2(0)0 2s+2(0)0 2p-1(1)1 2p+4(1)1 3s+1(1)2"), upper=core.EnergyLevel("1s+2(0)0 2s+2(0)0 2p-1(1)1 2p+4(6)1 3p+1(3)4") )
Parameters: - atom (Atom) – The atom instance in which te transition occurs
- lower (EnergyLevel) – The lower energy level
- upper (EnergyLevel) – The upper energy level
Variables: weighted_oscillator_strength (float) – The weighted oscillator strength of the transition \(gf\).
-
get_populations(temperatures, electron_densities, population_total=1.0)[source] Simple convenience wrapper around
EnergyLevel.get_population()to get both lower and upper energy levels populations.Parameters: - temperatures (ndarray) – temperature in eV
- electron_densities (ndarray) – electron density in cm^-3
- population_total (float) – 1 by default
Returns: a dict with two keys: {upper: …, lower: …} - the values are numpy structured arrays with fields temperature, electron_density and population
-
get_population_wrapper(inputs)[source]
-
init(logging_handler=<logging.FileHandler object>)[source] Must be called anytime you want to use gain_calculator, preferably in main calling script