radis.lbl.base module

Summary

A class to aggregate methods to calculate spectroscopic parameter and populations (and unload factory.py)

BaseFactory is inherited by BroadenFactory eventually

Routine Listing

PUBLIC METHODS

PRIVATE METHODS - CALCULATE SPECTROSCOPIC PARAMETERS (everything that doesnt depend on populations / temperatures) (computation: work & update with ‘df0’ and called before eq_spectrum() )

PRIVATE METHODS - APPLY ENVIRONMENT PARAMETERS (all functions that depends upon T or P) (calculates populations, linestrength & radiance, lineshift) (computation: work on df1, called by or after eq_spectrum() )

Most methods are written in inherited class with the following inheritance scheme:

DatabankLoader > BaseFactory > BroadenFactory > BandFactory > SpectrumFactory

Inheritance diagram of radis.lbl.factory.SpectrumFactory

class BaseFactory[source]

Bases: radis.lbl.loader.DatabankLoader

assert_no_nan(df, column)[source]

Assert there are no nan in the column.

Crash with a nice explanation if one is found

calc_einstein_coefficients()[source]

Calculate \(A_{ul}\), \(B_{lu}\), \(B_{ul}\) Einstein coefficients from weighted transition moments squared \(R_s^2\).

Returns

None

Return type

self.df0 is updated directly with new columns Aul, Blu, Bul

Notes

Einstein A coefficient already in database under df0.A Difference between df0.A and df0.Aul < 0.5%

References

Einstein induced absorption coefficient (in \(cm^3/J/s^2\))

\[B_{lu}=10^{-36}\cdot\frac{8{\pi}^3}{3h^2} R_s^2 \cdot 10^{-7}\]

Einstein induced emission coefficient (in \(cm^3/J/s^2\))

\[B_{ul}=10^{-36}\cdot\frac{8{\pi}^3}{3h^2} \frac{gl}{gu} R_s^2 \cdot 10^{-7}\]

Einstein spontaneous emission coefficient (in \(s^{-1}\))

\[A_{ul}=10^{-36}\cdot\frac{\frac{64{\pi}^4}{3h} {\nu}^3 gl}{gu} R_s^2\]

See (Eqs.(A7), (A8), (A9) in [Rothman-1998])

calc_lineshift()[source]

Calculate lineshift due to pressure.

Returns

None

Return type

self.df1 is updated directly with new column shiftwav

References

Shifted line center based on pressure shift coefficient \(lambda_{shift}\) and pressure \(P\).

\[\omega_{shift}=\omega_0+\lambda_{shift} P\]

See Eq.(A13) in [Rothman-1998]

calc_linestrength_eq(Tgas)[source]

Calculate linestrength at temperature Tgas correcting the database linestrength tabulated at temperature \(T_{ref}\).

Parameters

Tgas (float (K)) – gas temperature

Returns

None

Return type

self.df1 is updated directly with new column S

References

\[S(T) = S_0 \frac{Q_{ref}}{Q_{gas}} \operatorname{exp}\left(-E_l \left(\frac{1}{T_{gas}}-\frac{1}{T_{ref}}\right)\right) \frac{1-\operatorname{exp}\left(\frac{-\omega_0}{Tgas}\right)}{1-\operatorname{exp}\left(\frac{-\omega_0}{T_{ref}}\right)}\]

See Eq.(A11) in [Rothman-1998]

Notes

Internals:

(some more informations about what this function does)

Starts with df1 which is still a copy of df0 loaded by load_databank() Updates linestrength in df1. Cutoff criteria is applied afterwards.

calc_populations_eq(Tgas)[source]

Calculate upper state population for all active transitions in equilibrium case (only used in total power calculation)

Parameters

Tgas (float (K)) – temperature

Returns

nu is stored in self.df1

Return type

None

Notes

Isotopes: these populations are not corrected for the isotopic abundance, i.e, abundance has to be accounted for if used for emission density calculations (based on Einstein A coefficient), but not for linestrengths (that include the abundance dependency already)

References

Population of upper state follows a Boltzmann distribution:

\[n_u = g_u \frac{\operatorname{exp}\left(\frac{-E_u}{T_{gas}}\right)}{Q_{gas}}\]

See also

calc_populations_noneq(), _calc_populations_noneq_multiTvib(), at()

calc_populations_noneq(Tvib, Trot, vib_distribution='boltzmann', rot_distribution='boltzmann', overpopulation=None)[source]

Calculate upper and lower state population for all active transitions, as well as all levels (through at_noneq())

Parameters
  • Tvib, Trot (float (K)) – temperatures

  • vib_distribution ('boltzmann', 'treanor') – vibrational level distribution

  • rot_distribution ('boltzmann') – rotational level distribution

  • overpopulation (dict, or None) – dictionary of overpopulation factors for vibrational levels

Returns

None

Return type

nu, nl, nu_vib, nl_vib are stored in self.df1

Notes

Isotopic abundance:

Note that these populations are not corrected for the isotopic abundance, i.e, abundance has to be accounted for if used for emission density calculations (based on Einstein A coefficient), but not for linestrengths (that include the abundance dependency already)

All populations:

This method calculates populations of emitting and absorbing levels. Populations of all levels (even the one not active on the spectral range considered) are calculated during the Partition function calculation. See: at_noneq()

References

Boltzmann vibrational distributions

\[n_{vib}=\frac{g_{vib}}{Q_{vib}} \operatorname{exp}\left(\frac{-E_{vib}}{T_{vib}}\right)\]

or Treanor vibrational distributions

\[n_{vib}=\frac{g_{vib}}{Qvib} \operatorname{exp}\left(-\left(\frac{E_{vib,harm}}{T_{vib}}+\frac{E_{vib,anharm}}{T_{rot}}\right)\right)\]

Overpopulation of vibrational levels

\[n_{vib}=\alpha n_{vib}\]

Boltzmann rotational distributions

\[n_{rot}=\frac{g_{rot}}{Q_{rot}} \operatorname{exp}\left(\frac{-E_{rot}}{T_{rot}}\right)\]

Final rovibrational population of one level

\[n=n_{vib} n_{rot} \frac{Q_{rot} Q_{vib}}{Q}\]

See also

calc_populations_eq(), _calc_populations_noneq_multiTvib(), at_noneq()

calc_weighted_trans_moment()[source]

Calculate weighted transition-moment squared \(R_s^2\) (in Debye^2)

Returns

self.df0 is updated directly with new column Rs2 . R is in Debye^2 (1e-36 ergs.cm3)

Return type

None

References

Weighted transition-moment squared \(R_s^2\) from linestrength \(S_0\) at temperature \(T_ref\), derived from Eq.(A5) in [Rothman-1998]

cond_units = {'Tgas': 'K', 'Tref': 'K', 'Trot': 'K', 'Tvib': 'K', 'broadening_max_width': 'cm-1', 'calculation_time': 's', 'cutoff': 'cm-1/(#.cm-2)', 'path_length': 'cm', 'pressure_mbar': 'mbar', 'wavelength_max': 'nm', 'wavelength_min': 'nm', 'wavenum_max': 'cm-1', 'wavenum_max_calc': 'cm-1', 'wavenum_min': 'cm-1', 'wavenum_min_calc': 'cm-1', 'wstep': 'cm-1'}[source]
get_abundance(molecule, isotope)[source]

Returns abundance of molecule > isotope.

get_energy_levels(molecule, isotope, state, conditions=None)[source]

Return energy levels database for given molecule > isotope > state (look up Factory.parsum_calc[molecule][iso][state])

Parameters
  • molecule (str) – molecule name

  • isotope (int) – isotope identifier

  • state (str:) – electronic state

  • conditions (str, or None) – if not None, add conditions on which energies to retrieve, e.g:

    >>> 'j==0' or 'v1==0'
    

    Conditions are applied using Dataframe.query() method. In that case, get_energy_levels() returns a copy. Default None

Returns

energies – a view of the energies stored in the Partition Function calculator for isotope iso. If conditions are applied, we get a copy

Return type

pandas Dataframe

get_lines()[source]

Return lines if self.misc.export_lines is True, else get None.

get_populations(levels='vib')[source]

For all molecules / isotopes / electronic states, lookup energy levels as calculated in partition function calculators, and (if calculated) populations, and returns as a dictionary.

Parameters

levels ('vib', 'rovib', list of these, or None) – what levels to get. Note that 'rovib' can yield large Spectrum objects.

Returns

pops

Structure:

{molecule: {isotope: {electronic_state: {'vib': pandas Dataframe,    # (copy of) vib levels
                                         'rovib': pandas Dataframe,  # (copy of) rovib levels
                                         'Ia': float    # isotopic abundance
                                         }}}}

Return type

dict

plot_hist(dataframe='df0', what='int')[source]

Plot distribution (to help determine a cutoff criteria)

Parameters
  • dataframe (‘df0’, ‘df1’) – which dataframe to plot (df0 is the loaded one, df1 the scaled one)

  • what (str) – which feature to plot. Default 'S' (scaled linestrength). Could also be 'int' (reference linestrength intensity), 'A' (Einstein coefficient)

plot_linestrength_hist()[source]

Plot linestrength distribution (to help determine a cutoff criteria)

plot_populations(what='vib', isotope=None, nfig=None)[source]

Plot populations currently calculated in factory.

Plot populations of all levels that participate in the partition function. Output is different from the Spectrum plot_populations() method, where only the levels that directly contribute to the spectrum are shown

Note: only valid after calculating non_eq spectrum as it uses the partition function calculator object

Parameters
  • what (‘vib’, ‘rovib’) – what levels to plot

  • isotope (int, or None) – which isotope to plot. If None and if there are more than one isotope, raises an error.

Other Parameters

nfig (int, or str) – on which Figure to plot. Default None

print_conditions(preprend=None)[source]

Prints all physical / computational parameters. These are also stored in each result Spectrum.

Parameters

preprend (str) – just to text to display before printing conditions

units = {'abscoeff': 'cm-1', 'abscoeff_continuum': 'cm-1', 'absorbance': '', 'emisscoeff': 'mW/cm3/sr/nm', 'emisscoeff_continuum': 'mW/cm3/sr/nm', 'emissivity': '', 'emissivity_noslit': '', 'radiance': 'mW/cm2/sr/nm', 'radiance_noslit': 'mW/cm2/sr/nm', 'transmittance': '', 'transmittance_noslit': ''}[source]
get_waverange(wmin=None, wmax=None, wunit=<radis.misc.utils.Default object>, wavenum_min=None, wavenum_max=None, wavelength_min=None, wavelength_max=None, medium='air')[source]

Returns wavenumber based on whatever input was given: either ν_min, ν_max directly, or λ_min, λ_max in the given propagation medium.

Parameters
  • medium ('air', 'vacuum') – propagation medium

  • wmin, wmax (float, or Quantity or None) – hybrid parameters that can serve as both wavenumbers or wavelength depending on the unit accompanying them. If unitless, wunit is assumed as the accompanying unit.

  • wunit (string) – The unit accompanying wmin and wmax. Cannot be passed without passing values for wmin and wmax. Default: cm-1

  • wavenum_min, wavenum_max (float, or Quantity or None) – wavenumbers

  • wavelength_min, wavelength_max (float, or Quantity or None) – wavelengths in given medium

Returns

wavenum_min, wavenum_max, – wavenumbers

Return type

float