radis.levels.partfunc module

Partition function calculators and tabulators.

Notes

Partition function calculators and tabulators

Calculators all derive from the same RovibPartitionFunction object, and require a list of energies

Tabulators are more specific, and require a list of precalculated partition functions at different temperature. PartFuncTIPS uses the HITRAN hapi.py [1] module to interpolate Q for HITRAN species

Routine Listing

Partition functions:

Which inherit from:

Which inherit from:

See also

-

class:PartFuncCO2_CDSDcalc

-

class:PartFuncCO2_CDSDtab

References


class PartFuncExoMol(name, T_range, Q_range)[source]

Bases: RovibParFuncTabulator

Return partition function using interpolation of tabulated values.

Parameters:
  • name (str) – exomol isotope full name

  • T_range, Q_range (array) – initial references values to be tabulated.

Examples

One can use fetch_exomol() which has the option to return a PartFuncExoMol object

from radis.io.exomol import fetch_exomol
from radis.api.exomolapi import get_exomol_database_list

print(get_exomol_database_list("SiO", "28Si-16O"))  # 'EBJT" is one database
_, _, Z_exomol = fetch_exomol("SiO", "EBJT", return_local_path=True, return_partition_function=True)

# Get temperature at 2000 K
print(Z_exomol.at(2000))

See also

fetch_exomol()

PartFuncHAPI[source]

alias of PartFuncTIPS

class PartFuncTIPS(M, I, path=None, verbose=True)[source]

Bases: RovibParFuncTabulator

Return partition function using interpolation of tabulated values using the TIPS program [TIPS-2020]

Parameters:
  • M (int) – molecule id

  • I (int) – isotope identifier

  • path (str) – path to hapi.py. If None, the hapi package from PyPI is used.

Examples

from radis.levels.partfunc import PartFuncTIPS
from radis.db.classes import get_molecule_identifier

M = get_molecule_identifier('N2O')
iso=1

Q = PartFuncTIPS(M, iso)
print(Q.at(T=1500))

See online examples for more.

Partition Functions from TIPS

Partition Functions from TIPS

Scale Linestrengths of carbon-monoxide

Scale Linestrengths of carbon-monoxide

Fit Multiple Voigt Lineshapes

Fit Multiple Voigt Lineshapes

References

Partition function are retrieved from [TIPS-2020] through [HAPI] (Hitran Python Interface) using partitionSum(M,I,T)

import_from_file(path)[source]

Import hapi.py from a given file (in case user wants to specify a different HAPI version than the one embedded in RADIS)

class PartFunc_Dunham(electronic_state, vmax=None, vmax_morse=None, Jmax=None, spectroscopic_constants='default', use_cached=True, verbose=True, calc_Evib_per_mode=True, calc_Evib_harmonic_anharmonic=True, group_energy_modes_in_2T_model={'CO2': (['Evib1', 'Evib2', 'Evib3'], ['Erot'])}, mode='full summation')[source]

Bases: RovibParFuncCalculator

Calculate partition functions from spectroscopic constants, if molecule data is available in RADIS. If using the default spectroscopic constants, make sure you know what reference data is being used in RADIS! Energies are calculated with the Erovib() method of Molecules

Parameters:
  • electronic_state (ElectronicState) – an ElectronicState object, which is defined in RADIS molecule database and contains spectroscopic data

  • vmax (int, or None) – maximum vibrational quantum to calculate with Dunham expansion. If None, the molecule one is taken. If None still, all levels are calculated up to the molecule dissociation energy

  • vmax_morse (int, or None) – maximum vibrational quantum to calculate with Morse potential. If None, the molecule one is taken. Use 0 or -1 not to calculate with Morse potential

  • Jmax (int, or None) – maximum rotational quantum. If None, the molecule one is taken. If None, all levels are calculated up to the molecule dissociation energy

Other Parameters:
  • use_cached (True, False, or 'regen', 'force') – if True, use (and generate if doesnt exist) a .h5 file. If 'regen', regenerate cache file. If 'force', raise an error if file doesnt exist. Default True

  • calc_Evib_per_mode (boolean) – if True, calculate energies of each vibration mode (so far only implemented for CO2 with Evib1, Evib2, Evib3 but shall be generalized to all molecules)

  • calc_Evib_harmonic_anharmonic (boolean) – if True, calculate and store separately harmonic and anharmonic parts of the vibrational energy. This is needed to calculate Treanor distributions ( ~ Evib_harmonic / Tvib - Evib_anharmonic / Trot )

  • group_energy_modes_in_2T_model (dict) – (experimental in neq 0.9.21) for polyatomic molecules (> 1 vibration mode), how to regroup energy modes when working with 2T models. For instance, for CO2, (Evib, Erot) could as well as defined with:

    ['Evib1', 'Evib2', 'Evib3'],['Erot']
    or
    ['Evib3'],['Evib1', 'Evib2', 'Erot']
    

    depending on which levels are supposed to interact the most

  • mode (‘full summation’, ‘tabulation’) – calculation mode. 'tabulation' is much faster but not all possible distributions are implemented. Default 'full-summation'

Examples

Calculate partition function of CO using default spectroscopic constants:

from radis.db.molecules import Molecules
from radis.levels.partfunc import PartFunc_Dunham

isotope = 1
electronic_state = "X"
S = Molecules["CO"][isotope][electronic_state]

# Equilibrium partition functions :
Qf = PartFunc_Dunham(S)
print(Qf.at(T=3000))  # K

# Nonequilibrium partition functions :
print(Qf.at_noneq(Tvib=2000, Trot=1000))  # K

Examples using radis.levels.partfunc.PartFunc_Dunham

Partition Functions from spectroscopic constants

Partition Functions from spectroscopic constants

Partition Functions from TIPS

Partition Functions from TIPS

Notes

Validity:

So far, RADIS energy levels are only calculated from Dunham’s expansion. Above a certain vibrational level a Morse Potential may be used. See how the molecule is defined in molecules

build_energy_levels_class1()[source]

in the case where only Ediss is given. Deal with vmax, Jmax later.

Applies to molecules in HITRAN_CLASS1

Returns:

but the Pandas DataFrame self.df is updated with parameters:

  • g : degeneracy

  • E : energy level

  • Evib : vibrational energy

  • Erot : rotational energy

  • viblvl : vibrational level name

Return type:

None

build_energy_levels_class5(calc_Evib_per_mode=True, calc_Evib_harmonic_anharmonic=False, group_energy_modes_in_2T_model=(['Evib1', 'Evib2', 'Evib2'], ['Erot']))[source]

in the case where only Ediss is given. Deal with vmax, Jmax later.

HITRAN_CLASS5 = [‘CO2’] # Linear triatomic with large Fermi resonance

Parameters:

calc_Evib_per_mode (boolean) – if True, calculates Evib1, Evib2, Evib3

Other Parameters:
  • calc_Evib_harmonic_anharmonic (boolean) – if True, calculates Evib_h and Evib_a, harmonic and non harmonic components, to be used in Treanor distributions

  • group_energy_modes_in_2T_model (dict) – (experimental in neq 0.9.21) for polyatomic molecules (> 1 vibration mode), how to regroup energy modes when working with 2T models. For instance, for CO2, (Evib, Erot) could as well as defined with:

    ['Evib1', 'Evib2', 'Evib3'],['Erot']
    

    or:

    ['Evib3'],['Evib1', 'Evib2', 'Erot']
    

    depending on which levels are supposed to interact the most

Returns:

but the Pandas DataFrame self.df is updated with parameters:

  • g : degeneracy

  • E : energy level

  • Evib : vibrational energy

  • Erot : rotational energy

  • viblvl : vibrational level name

Return type:

None

gi(ElecState)[source]

Get state independent rotational degeneracy. Typically depends on the isotope.

See also

gi()

gs(ElecState)[source]

Get state specific rotational degeneracy.

Parameters:

ElecState – an ElectronicState, that contains molecule id and isotope number

See also

gs()

class RovibParFuncCalculator(electronic_state, mode='full summation', verbose=False)[source]

Bases: RovibPartitionFunction

Parameters:

electronic_state (ElectronicState) – an ElectronicState object, which is defined in RADIS molecule database and contains spectroscopic data. Energies are calculated with the Erovib() method.

Other Parameters:

mode (‘full summation’, ‘tabulation’) – calculation mode. 'tabulation' is much faster but not all possible distributions are implemented. Default 'full-summation'

N_bins_scaling[source]

func int, int -> int Reduce number of Bins in each dimension ; in high dimensional spaces. This is justified by accuracy tests in radis.test.levels.test_partfunc.test_tabulated_partition_functions()

at(T, update_populations=False)[source]

Get partition function at temperature T under equilibrium conditions.

Parameters:

T (float) – equilibrium temperature

Other Parameters:

update_populations (boolean) – if True, store calculated populations in energy level list Default False

Returns:

Q – partition function calculated at temperature T

Return type:

float

Examples

See online examples

See also

at_noneq(), at_noneq_3Tvib()

at_noneq(Tvib, Trot, overpopulation=None, vib_distribution='boltzmann', rot_distribution='boltzmann', returnQvibQrot=False, update_populations=False)[source]

Calculate Partition Function under non equilibrium (Tvib, Trot), with boltzmann/treanor distributions and overpopulations as specified by the user.

Parameters:
  • Tvib, Trot (float) – vibrational & rotational temperatures (K)

  • overpopulation (dict, or None) – dict of overpopulated levels: {'level':over_factor}

  • vib_distribution ('boltzmann', 'treanor') – distribution of vibrational levels

  • rot_distribution ('boltzmann') – distribution of rotational levels

  • returnQvibQrot (boolean) – cf output

Other Parameters:

update_populations (boolean) – if True, store calculated populations in energy level list. Default False

Returns:

  • Q (float) – partition function calculated at non eq temperatures

  • Q, Qvib, dfQrot (float, float, pandas table (if returnQvibQrot)) – total partition function, vibrational partition function, and table of rotational partition functions for each vibrational state (note that all Qrot are not necessarily the same for all vibrational levels)

Examples

See online examples

See also

at(), at_noneq_3Tvib()

at_noneq_3Tvib(Tvib, Trot, overpopulation=None, vib_distribution='boltzmann', rot_distribution='boltzmann', returnQvibQrot=False, update_populations=False)[source]

Calculate Partition Function under non equilibrium ((Tvib1, Tvib2, Tvib3), Trot), with boltzmann/treanor distributions and overpopulations as specified by the user.

Dedicated function for 3 Tvib mode

Parameters:
  • Tvib, Trot ((float, float, float), float) – vibrational & rotational temperatures (K)

  • overpopulation (dict, or None) – dict of overpopulated levels: {'level':over_factor}

  • vib_distribution ('boltzmann', 'treanor')

  • rot_distribution ('boltzmann')

  • returnQvibQrot (boolean) – cf output

  • update_populations (boolean) – if True, saves populations for calculated temperature in PartitionFunction dataframe. Default False

Returns:

  • Q (float) – partition function calculated at non eq temperatures

  • Q, Qvib, dfQrot (float, float, pandas table (if returnQvibQrot)) – total partition function, vibrational partition function, and table of rotational partition functions for each vibrational state (note that all Qrot are not necessarily the same for all vibrational levels)

See also

at(), at_noneq()

reset_populations()[source]

Discard computed populations of all energy levels.

To call on every RovibrationalPartitionFunction object before each new spectrum calculation

class RovibParFuncTabulator[source]

Bases: RovibPartitionFunction

at(T, **kwargs)[source]

Get partition function at temperature T under equilibrium conditions, from tabulated data.

Parameters:

T (float) – equilibrium temperature

Returns:

Q – partition function interpolated at temperature T

Return type:

float

Examples

See online examples

See also

PartFuncTIPS

at_noneq(*args, **kwargs)[source]
class RovibPartitionFunction[source]

Bases: object

General class from which all partition function calculators derive.

Parameters:

electronic_state (ElectronicState) – an ElectronicState object, which is defined in RADIS molecule database and contains spectroscopic data

Notes

Implementation:

one partition function generator (RovibPartitionFunction) is generated per specie per isotope

RovibPartitionFunction may differ in the way they build / fetch their list of states and the associated energies, but the .at(), .at_noneq() calls to calculate the partition function should be shared among all derived classes