exojax.opacity.lpf packageο
Submodulesο
exojax.opacity.lpf.api moduleο
API for Line Profile Function (LPF) opacity calculations.
This module provides the OpaDirect class for direct line-by-line opacity calculations using the LPF method.
- class exojax.opacity.lpf.api.OpaDirect(mdb, nu_grid: ndarray, wavelength_order: Literal['ascending', 'descending'] = 'descending')ο
Bases:
OpaCalc
Opacity Calculator Class for Direct Line-by-Line calculations (LPF).
This class performs direct line-by-line opacity calculations without approximations, providing the most accurate results at the cost of computational efficiency.
- methodο
Always βlpfβ for this calculator
- mdbο
Molecular database instance
- wavelength_orderο
Order of wavelength grid
- opainfoο
Opacity information from initialization
- apply_params() None ο
Apply database parameters and initialize opacity info.
- xsmatrix(Tarr: Union[ndarray, Array], Parr: Union[ndarray, Array]) Array ο
Compute cross section matrix for temperature and pressure arrays.
Note
Self-pressure (Pself) is currently set to zero for HITEMP/HITRAN.
- Parameters:
Tarr β Temperature array in K
Parr β Pressure array in bar
- Returns:
Cross section matrix with shape (Nlayer, N_wavenumber) in cmΒ²
- Raises:
ValueError β If database type is not supported
- xsvector(T: float, P: float, Pself: float = 0.0) Array ο
Compute cross section vector for given temperature and pressure.
- Parameters:
T β Temperature in Kelvin
P β Pressure in bar
Pself β Self-pressure for HITEMP/HITRAN in bar
- Returns:
Cross section vector in cmΒ²
- Raises:
ValueError β If database type is not supported
exojax.opacity.lpf.lpf moduleο
Line Profile Functions method for opacity calculation.
- exojax.opacity.lpf.lpf.exomol(mdb, Tarr, Parr, molmass)ο
Computes molecular line information required for MODIT using Exomol mdb.
- Parameters:
mdb β mdb instance
Tarr β Temperature array
Parr β Pressure array
molmass β molecular mass
- Returns:
line intensity matrix, gammaL matrix, sigmaD matrix
- exojax.opacity.lpf.lpf.hjert_jvp(primals, tangents)ο
- exojax.opacity.lpf.lpf.ljert(x, a)ο
ljert function, consisting of a combination of imwofz and imag(asymptiotic wofz).
- Parameters:
x β
a β
- Returns:
L(x,a) or Imag(wofz(x+ia))
Note
ljert provides a L(x,a) function. This function accepts a scalar value as an input. Use jax.vmap to use a vector as an input.
- exojax.opacity.lpf.lpf.vald(adb, Tarr, PH, PHe, PHH)ο
Computes VALD line information required for LPF using VALD atomic database (adb)
- Parameters:
adb β adb instance made by the AdbVald class in moldb.py
Tarr β Temperature array
PH β Partial pressure array of neutral hydrogen (H)
PHe β Partial pressure array of neutral helium (He)
PHH β Partial pressure array of molecular hydrogen (H2)
- Returns:
line intensity matrix gammaLM: gammaL matrix sigmaDM: sigmaD matrix
- Return type:
SijM
- exojax.opacity.lpf.lpf.vald_each(Tarr, PH, PHe, PHH, qt_284_T, QTmask, QTref_284, logsij0, nu_lines, ielem, iion, dev_nu_lines, elower, eupper, atomicmass, ionE, gamRad, gamSta, vdWdamp, Tref)ο
Compute VALD line information required for LPF for separated each species
- Parameters:
Tarr β temperature array [N_layer]
PH β partial pressure array of neutral hydrogen (H) [N_layer]
PHe β partial pressure array of neutral helium (He) [N_layer]
PHH β partial pressure array of molecular hydrogen (H2) [N_layer]
qt_284_T β partition function at the temperature T Q(T), for 284 species
QTmask β array of index of Q(Tref) grid (gQT) for each line
QTref_284 β partition function at the reference temperature Q(Tref), for 284 species
logsij0 β log line strength at T=Tref
nu_lines β line center (cm-1) in np.array (float64)
ielem β atomic number (e.g., Fe=26)
iion β ionized level (e.g., neutral=1, singly ionized=2, etc.)
dev_nu_lines β line center (cm-1) in device (float32)
elower β the lower state energy (cm-1)
eupper β the upper state energy (cm-1)
atomicmass β atomic mass (amu)
ionE β ionization potential (eV)
gamRad β log of gamma of radiation damping (s-1)
gamSta β log of gamma of Stark damping (s-1)
vdWdamp β log of (van der Waals damping constant / neutral hydrogen number) (s-1)
- Returns:
line intensity matrix [N_layer x N_line] gammaLM: gammaL matrix [N_layer x N_line] sigmaDM: sigmaD matrix [N_layer x N_line]
- Return type:
SijM
- exojax.opacity.lpf.lpf.voigt(nuvector, sigmaD, gammaL)ο
Custom JVP version of Voigt profile using Voigt-Hjerting function.
- Parameters:
nu β wavenumber array
sigmaD β sigma parameter in Doppler profile
gammaL β broadening coefficient in Lorentz profile
- Returns:
Voigt profile
- Return type:
v
- exojax.opacity.lpf.lpf.voigtone(nu, sigmaD, gammaL)ο
Custom JVP version of (non-vmapped) Voigt function using Voigt-Hjerting function.
- Parameters:
nu β wavenumber
sigmaD β sigma parameter in Doppler profile
gammaL β broadening coefficient in Lorentz profile
- Returns:
Voigt funtion
- Return type:
v
- exojax.opacity.lpf.lpf.vvoigt(numatrix, sigmaD, gammaL)ο
Custom JVP version of vmaped voigt profile.
- Parameters:
numatrix β wavenumber matrix in R^(Nline x Nwav)
sigmaD β doppler sigma vector in R^Nline
gammaL β gamma factor vector in R^Nline
- Returns:
Voigt profile vector in R^Nwav
- exojax.opacity.lpf.lpf.xsmatrix(numatrix, sigmaDM, gammaLM, SijM)ο
Custom JVP version of cross section matrix.
- Parameters:
numatrix β wavenumber matrix in R^(Nline x Nwav)
sigmaDM β doppler sigma matrix in R^(Nlayer x Nline)
gammaLM β gamma factor matrix in R^(Nlayer x Nline)
SijM β line strength matrix in R^(Nlayer x Nline)
- Returns:
cross section matrix in R^(Nlayer x Nwav)
- exojax.opacity.lpf.lpf.xsvector(numatrix, sigmaD, gammaL, Sij)ο
Custom JVP version of cross section vector.
- Parameters:
numatrix β wavenumber matrix in R^(Nline x Nwav)
sigmaD β doppler sigma vector in R^Nline
gammaL β gamma factor vector in R^Nline
Sij β line strength vector in R^Nline
- Returns:
cross section vector in R^Nwav
exojax.opacity.lpf.make_numatrix moduleο
- exojax.opacity.lpf.make_numatrix.add_nu(dd, fnu, fhatnu, Nz)ο
re-adding an interger part w/JIT.
- Parameters:
dd β difference matrix
fnu β integer part of wavenumber
fhatnu β residual wavenumber
Nz β boost factor
- Returns:
an integer part readded value
- exojax.opacity.lpf.make_numatrix.divwavnum(nu, Nz=1)ο
separate an integer part from a residual.
- Parameters:
nu β wavenumber array
Nz β boost factor (default=1)
- Returns:
integer part of wavenumber, residual wavenumber, boost factor
- exojax.opacity.lpf.make_numatrix.make_numatrix0(nu, hatnu, warning=True)ο
Generate numatrix0.
Note
Use float64 as inputs.
- Parameters:
nu β wavenumber matrix (Nnu,)
hatnu β line center wavenumber vector (Nline,), where Nm is the number of lines
warning β True=warning on for nu.dtype=float32
- Returns:
numatrix (Nline,Nnu)
- exojax.opacity.lpf.make_numatrix.make_numatrix0_subtract(nu, hatnu, Nz=1, warning=True)ο
Generate numatrix0 using gpu.
Note
This function computes a wavenumber matrix using XLA. Because XLA does not support float64, a direct computation sometimes results in large uncertainity. For instace, letβs assume nu=2000.0396123 cm-1 and hatnu=2000.0396122 cm-1. If applying float32, we get np.float32(2000.0396123)-np.float32(2000.0396122) = 0.0. But, after subtracting 2000 from both nu and hatnu, we get np.float32(0.0396123)-np.float32(0.0396122)=1.0058284e-07. make_numatrix0 does such computation. Nz=1 means we subtract a integer part (i.e. 2000), Nz=10 means we subtract 2000.0, and Nz=10 means we subtract 2000.00.
- Parameters:
nu β wavenumber matrix (Nnu,)
hatnu β line center wavenumber vector (Nline,), where Nm is the number of lines
Nz β boost factor (default=1)
warning β True=warning on for nu.dtype=float32
- Returns:
wavenumber matrix w/ no shift
- Return type:
numatrix0
- exojax.opacity.lpf.make_numatrix.subtract_nu(dnu, dhatnu)ο
compute nu - hatnu by subtracting an integer part w/JIT
- Parameters:
dnu β residual wavenumber array
dhatnu β residual line center array
- Returns:
difference matrix