radis.lbl.broadening module¶
Summary¶
A class to handle all broadening related functions (and unload factory.py)
BroadenFactory is inherited by SpectrumFactory eventually
Routine Listing¶
Most methods are written in inherited class with the following inheritance scheme:
DatabankLoader
> BaseFactory
>
BroadenFactory
> BandFactory
>
SpectrumFactory
PUBLIC FUNCTIONS - BROADENING
PRIVATE METHODS - BROADENING (all computational-heavy functions: calculates all lines broadening, convolve them, apply them on all calculated range)
radis.lbl.broadening.whiting()
radis.lbl.broadening._whiting_jit()
: precompiled versionradis.lbl.broadening.BroadenFactory._calc_broadening_HWHM()
radis.lbl.broadening.BroadenFactory._add_voigt_broadening_HWHM()
radis.lbl.broadening.BroadenFactory._voigt_broadening()
radis.lbl.broadening.BroadenFactory._calc_lineshape()
radis.lbl.broadening.BroadenFactory._calc_lineshape_DLM()
radis.lbl.broadening.BroadenFactory._apply_lineshape()
radis.lbl.broadening.BroadenFactory._apply_lineshape_DLM()
radis.lbl.broadening.BroadenFactory._calc_broadening()
radis.lbl.broadening.BroadenFactory._calc_broadening_noneq()
radis.lbl.broadening.BroadenFactory._find_weak_lines()
radis.lbl.broadening.BroadenFactory.calculate_pseudo_continuum()
radis.lbl.broadening.BroadenFactory._add_pseudo_continuum()
Notes
Formula in docstrings generated with py2tex()
from pytexit import py2tex
py2tex('...')
- class BroadenFactory[source]¶
Bases:
radis.lbl.base.BaseFactory
A class that holds all broadening methods.
Eventually inherited by
SpectrumFactory
See also
- calculate_pseudo_continuum(noneq=False)[source]¶
Find weak lines, add them in pseudo-continuum (note that pseudo- continuum by RADIS definition is actually more a sum of low-resolution lines)
- Parameters
noneq (bool) – if
True
, also returns the emisscoeff pseudo continuum (for noneq cases). DefaultFalse
- Returns
k_continuum (numpy array (1/(#.cm-2))) – abscoeff semi-continuum on wavenumber space
j_continuum (numpy array) – only returned if
noneq=True
: emisscoeff semi-continuum on wavenumber spaceAlso – self.df1 is updated, lines are removed local variables self._Nlines_in_continuum and self._Nlines_calculated are created
Notes
continuum can be exported in Spectrum is using the
self.export_continuum
boolean. This is not available as a User input but can be edited manually in the Factory.The Weak line characterization [1]_ is only based on abscoeff. For strong nonequilibrium cases there may be lines consired as weak in terms of absorption but not weaks in emission, or the other way around. It should be negligible, though, so a dual conditioning (looking at both abscoeff and emisscoeff) was not implemented. See
radis.lbl.broadening._find_weak_lines()
if you want to change that- 1
RADIS User Guide, RADIS Paper
- plot_broadening(i=0, pressure_atm=None, mole_fraction=None, Tgas=None)[source]¶
just for testing. Recalculate and plot broadening for line of index i.
- Parameters
i (int) – line index
pressure_atm (atm) – if None, defaults to model pressure
mole_fraction ([0-1]) – if None, defaults to model mole fraction
Tgas (K) – if None, defaults to model translational temperature
Examples
- ::
sf=SpectrumFactory(…) sf.eq_spectrum(…) sf.plot_broadening(i=500) # plot line number 500
- doppler_broadening_HWHM(wav, molar_mass, Tgas)[source]¶
Computes Gaussian (Doppler) broadening HWHM over all lines with [1]_, [2]_
\[\frac{w}{c} \sqrt{\frac{2N_a k_b T_{gas} \ln 2}{M}}\]with
k
andc
in CGS- Parameters
wav (array like (nm / cm-1)) – transition waverange [length N = number of lines]
molar_mass (array like (g/mol)) – molar mass for isotope of given transition, in
g/mol
[length N]Tgas (float (K)) – (translational) gas temperature
- Returns
array – gaussian HWHM for all lines
- Return type
(nm / cm-1) [shape N]
References
\[f_{G} = \frac{1}{\alpha} \sqrt{\frac{\ln 2}{\pi}} exp\left(- \ln 2 \left(\frac{w - w_0}{\alpha}\right)^2 \right)\]with α the full-width half maximum (HWHM) calculated in
cm-1
,nm
orHz
:- 1
- HITRAN.org
Eqn. (5) [in cm-1].
c
in CGS, HWHM alpha innm
, M ing/mol
:
\[\alpha w_G= \frac{w}{c_{CGS}} \sqrt{\frac{2N_a k_b T \ln 2}{M}}\]- 2
- Laux et al, 2003, “Optical diagnostics of atmospheric pressure air plasmas”
Eqn. (6) [in nm]. FWHM Delta in
nm
, M ing/mol
:
\[\alpha \lambda_G=3.58\times 10^{-07} \lambda \sqrt{\frac{T}{M}}\]- 3
Wikipedia [in Hz]
\[\alpha f_G=\frac{1}{2} \sqrt{\frac{8 k T \ln 2}{m c^2}} f_0\]
Here we work in
cm-1
with the CGS nomenclature (molar mass M ing/mol
)Notes
equation generated from the Python formula with
py2tex()
See also
- gaussian_FT(w_centered, hwhm)[source]¶
Fourier Transform of a Gaussian lineshape.
\[\operatorname{exp}\left(\frac{-\left({\left(2\pi w_{centered} hwhm\right)}^2\right)}{4\ln2}\right)\]- Parameters
w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)
hwhm (array [shape N = number of lines]) – Half-width at half-maximum (HWHM) of Gaussian
- Returns
- Return type
array
See also
- gaussian_lineshape(w_centered, hwhm)[source]¶
Computes Doppler (Gaussian) lineshape over all lines with [1]_, [2]_
\[\frac{1}{\alpha_g} \sqrt{\frac{\ln 2}{\pi}} \operatorname{exp}\left(-\ln 2 {\left(\frac{w_{centered}}{\alpha_g}\right)}^2\right)\]with \(\alpha_g\) half-width at half maximum (HWHM)
- Parameters
w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0, size W = broadening width size)
hwhm (array [shape N = number of lines]) – Half-width at half-maximum (HWHM) of Gaussian
Tgas (K) – (translational) gas temperature
- Returns
array – line profile
- Return type
[shape N x W]
References
- 1
Wikipedia (in \(cm^{-1}\))
- 2
Laux et al, 2003, “Optical diagnostics of atmospheric pressure air plasmas” (in nm)
Both give the same results.
Notes
formula generated from the Python equation with
py2tex()
- lorentzian_FT(w_centered, gamma_lb)[source]¶
Fourier Transform of a Lorentzian lineshape.
\[\operatorname{exp}\left(-2\pi w_{centered} \gamma_{lb}\right)\]- Parameters
w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)
gamma_lb (array (cm-1) [length N]) – half-width half maximum coefficient (HWHM) for pressure broadening calculation
- Returns
- Return type
array
See also
- lorentzian_lineshape(w_centered, gamma_lb)[source]¶
Computes collisional broadening over all lines [1]_
\[\frac{1}{\pi} \frac{\gamma_{lb}}{\gamma_{lb}^2+w_{centered}^2}\]- Parameters
w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)
gamma_lb (array (cm-1) [length N]) – half-width half maximum coefficient (HWHM) for pressure broadening calculation
- Returns
array – line profile
- Return type
[shape N x W]
References
Notes
formula generated from the Python equation with
py2tex()
- olivero_1977(wg, wl)[source]¶
Calculate approximate Voigt FWHM with [Olivero-1977].
also in NEQAIR 96 manual Eqn. (D2) Note that formula is given in wavelength (nm) [doesnt change anything] and uses full width half maximum (FWHM) of Gaussian and Lorentzian profiles.
For use with the Whiting formula of
voigt_lineshape()
.- Parameters
wg (numpy array) – Gaussian profile FWHM
wl (numpy array) – Lorentzian profile FWHM
- Returns
gamma_voigt – Voigt FWHM
- Return type
numpy array
References
[Olivero-1977] uses FWHM.
\[ \begin{align}\begin{aligned}s_d=\frac{w_l-w_g}{w_l+w_g}\\w_v=\left(1-0.18121\left(1-{s_d}^2\right)-\left(0.023665\operatorname{exp}\left(0.6s_d\right)+0.00418\operatorname{exp}\left(-1.9s_d\right)\right) sin\left(\pi s_d\right)\right) \left(w_l+w_g\right)\end{aligned}\end{align} \]See also
- pressure_broadening_HWHM(airbrd, selbrd, Tdpair, Tdpsel, pressure_atm, mole_fraction, Tgas, Tref)[source]¶
Calculates collisional broadening HWHM over all lines by scaling tabulated HWHM for new pressure and mole fractions conditions [1]_
Note that collisional broadening is computed with a different coefficient for air broadening and self broadening. In the case of non-air mixtures, then the results should be used with caution, or better, the air broadening coefficient be replaced with the gas broadening coefficient
- Parameters
airbrd (array like [length N]) – half-width half max coefficient (HWHM ) for collisional broadening with air
selbrd (array like [length N]) – half-width half max coefficient (HWHM ) for resonant (self) broadening with air
Tdpair (array like [length N]) – temperature dependance coefficient for collisional broadening with air
Tdpsel (array like [length N]) – temperature dependance coefficient for resonant (self) broadening
pressure_atm (float [atm]) – pressure in atmosphere (warning, not bar!)
mole_fraction (float [0-1]) – mole fraction
Tgas (float [K]) – (translational) gas temperature
Tref (float [K]) – reference temperature at which tabulated HWHM pressure broadening coefficients were tabulated
- Returns
lineshape – Lorentzian half-width at half-maximum (FWHM) for each line profile
- Return type
pandas Series [shape N x W]
References
See also
- project_lines_on_grid(df, wavenumber, wstep)[source]¶
Quickly sums all lines on wavespace grid as rectangles of HWHM corresponding to
hwhm_voigt
and a spectral absorption coefficient value so that linestrength is conserved.i.e. profiles are approximated as a rectangle of width \(\alpha \cdot FWHM_{Voigt}\), and with the same linestrength.
- Parameters
df (pandas Dataframe) – Contains
shiftwav
(wavenumbers) andS
(linestrengths) andhwhm_voigt
(Voigt HWHM) sizeN
(number of lines)wavenumber (np.array) – spectral grid. Size
W
. Expected to be regularwstep (float (cm-1)) – wavenumber step
- Returns
k_rough_spectrum (np.array) – spectral absorption coefficient for the waverange
wavenumber
, calculated by assuming a rectangular profile for each line. SizeW
S_density_on_grid – average spectral linestrength intensity of each line (abscoeff ~k), assuming rectangular profile. size
N
line2grid_projection – closest index of the center of each line in
df
on the spectral gridwavenumber
. SizeN
- project_lines_on_grid_noneq(df, wavenumber, wstep)[source]¶
Quickly sums all lines on wavespace grid as rectangles of HWHM corresponding to
hwhm_voigt
and a spectral absorption coefficient value so that linestrength is conserved.i.e. profiles are approximated as a rectangle of width \(\alpha \cdot FWHM_{Voigt}\), and with the same linestrength.
- Parameters
df (pandas Dataframe) – Contains
shiftwav
(wavenumbers) andS
(linestrengths) andhwhm_voigt
(Voigt HWHM) sizeN
(number of lines)wavenumber (np.array) – spectral grid. Size
W
. Expected to be regularwstep (float (cm-1)) – wavenumber step
quantity (‘S’ or ‘Ei’) – use ‘S’ for Linestrength, ‘Ei’ for emission integral. Default ‘S’
- Returns
k_rough_spectrum (np.array) – spectral absorption coefficient for the waverange
wavenumber
, calculated by assuming a rectangular profile for each line. SizeW
j_rough_spectrum (np.array) – spectral emission coefficient for the waverange
wavenumber
, calculated by assuming a rectangular profile for each line. SizeW
S_density_on_grid – average spectral linestrength intensity of each line (abscoeff ~k), assuming rectangular profile. size
N
Ei_density_on_grid – average spectral emission intensity of each line (emisscoeff ~j), assuming rectangular profile. size
N
line2grid_projection – closest index of the center of each line in
df
on the spectral gridwavenumber
. SizeN
Notes
Similar to
project_lines_on_grid()
except that we also calculate the approximate emission intensity (noneq > it cannot be recomputed from the linestrength).
- voigt_FT(w_lineshape_ft, hwhmG, hwhmL)[source]¶
Fourier Transform of a Voigt lineshape
- Parameters
w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)
hwhmG (array [shape N = number of lines]) – Half-width at half-maximum (HWHM) of Gaussian
hwhmL (array (cm-1) [length N]) – Half-width at half-maximum (HWHM) of Lorentzian
See also
- voigt_broadening_HWHM(airbrd, selbrd, Tdpair, Tdpsel, wav, molar_mass, pressure_atm, mole_fraction, Tgas, Tref)[source]¶
Calculate Voigt profile half-width at half-maximum (HWHM) from the Gaussian and Collisional broadening with the empirical formula of [Olivero-1977]
Gaussian broadening is calculated with [2]_, Collisional broadening with [3]_
Exact for a pure Gaussian and pure Lorentzian
- Parameters
Line parameters [length N]
airbrd (np.array [length N] (cm-1/atm)) – air broadening half-width half maximum (HWHM)
selbrd (np.array [length N] (cm-1/atm)) – self broadening half-width half maximum (HWHM)
Tdpair (np.array [length N]) – temperature dependance of collisional broadening by air
Tdpsel (np.array [length N]) – temperature dependance of collisional self-broadening
wav (np.array [length N] (cm-1)) – transition wavenumber
molar_mass (np.array [length N] (g/mol)) – molar mass for isotope of given transition
Environment parameters
pressure_atm (float [atm]) – pressure
mole_fraction (float [0-1]) – mole fraction
Tgas (K) – (translational) gas temperature
Tref (K) – reference temperature at which tabulated HWHM pressure broadening coefficients were tabulated
- Returns
gamma_voigt, gamma_lb, gamma_db – Voigt, Lorentz, and Gaussian HWHM
- Return type
numpy array
References
Notes: [Olivero-1977] uses FWHM.
- Olivero-1977(1,2,3,4,5)
Olivero 1977 “Empirical fits to the Voigt line width: A brief review” Also found in NEQAIR96 Manual.
- 2
Wikipedia (in cm-1)
- 3
Eq. (A.12) in [Rothman-1998]
- voigt_lineshape(w_centered, hwhm_lorentz, hwhm_voigt, jit=True)[source]¶
Calculates Voigt lineshape using the approximation of the Voigt profile of [NEQAIR-1996], [Whiting-1968] that maintains a good accuracy in the far wings. Exact for a pure Gaussian and pure Lorentzian.
- Parameters
w_centered (2D array [one per line: shape W x N]) – waverange (nm / cm-1) (centered on 0)
hwhm_lorentz (array (cm-1) [length N]) – half-width half maximum coefficient (HWHM) for Lorentzian broadening
hwhm_voigt (array (cm-1) [length N]) – half-width half maximum coefficient (HWHM) for Voigt broadening, calculated by
voigt_broadening_HWHM()
- Other Parameters
jit (boolean) – if
True
, use just in time compiler. Usually faster when > 10k lines. DefaultTrue
.- Returns
lineshape – line profile
- Return type
pandas Series [shape N x W]
References
See also
- whiting1968(w_centered, wl, wv)[source]¶
A pseudo-voigt analytical approximation.
\[\Phi(w)=\left(1-\frac{w_l}{w_v}\right) \operatorname{exp}\left(-2.772{\left(\frac{w}{w_v}\right)}^{2.25}\right)+\frac{1\frac{w_l}{w_v}}{1+4{\left(\frac{w}{w_v}\right)}^{2.25}}+0.016\left(1-\frac{w_l}{w_v}\right) \frac{w_l}{w_v} \left(\operatorname{exp}\left(-0.4w_{wv,225}\right)-\frac{10}{10+{\left(\frac{w}{w_v}\right)}^{2.25}}\right)\]- Parameters
w_centered (2D array) – broadening spectral range for all lines
wl (array) – Lorentzian FWHM
wv (array) – Voigt FWHM
References
Used in the expression of [Olivero-1977]
Notes
Performances:
using @jit yield a performance increase from 8.9s down to 5.1s on a 50k lines, 250k wavegrid case (performances.py)
See also