# Formalism¶

RADEX is a non-LTE radiative transfer solver that calculates the intensities of molecular lines assuming an homogeneous medium with a simple geometry. For a full description of the code, please see their release paper. The RADEX code has been modified to meet modern Fortran specifications but is otherwise unchanged in SpectralRadex.

## Spectral Modelling¶

In order to calculate the emission from a molecular transition as a function of frequency, we need the excitation temperature and the optical depth as a function of velocity. This allows us to calculate the brightness temperature as a function of velocity:

$T_B = [J_{\nu}(T_{ex})-J_{\nu}(T_{BG})](1-\exp(-\tau_v))$

Where $$T_{ex}$$ is the excitation temperature and $$T_{BG}$$ is the background temperature, likely 2.73 K. In LTE, the optical depth at line centre can be calculated from the column density and Boltzmann distribution whilst the excitation temperature is assumed to be the LTE temperature. We can then calculate $$\tau_v$$ assuming a gaussian line profile:

$\tau_v = \tau_0 e^{\left(-4ln(2)\frac{(v-v_0)^2}{\Delta v^2}\right)}$

However, using RADEX, we can do better than to assume LTE. For a given set of physical parameters RADEX will provide the optical depth at line centre for every transition and the excitation temperature that gives the correct brightness temperature at line centre.

Thus, rather than using our gas kinetic temperature and an LTE derived $$\tau_0$$, we can take the values for each line from an appropriate RADEX output. In the high density limit, this tends to the LTE solution but at lower densities it can deviate significantly.

In SpectralRadex, we do this for each transition in a collisional datafile between a minimum and maximum frequency set by the user. $$T_B$$ is calculated as a function of frequency for each line and then combined to give the overall spectrum of the molecule.

Finally, we need to consider what to do with overlapping lines. We follow Hsieh et al 2015 and use an opacity weighted radiation temperature:

$T_B = \left(\frac{\Sigma_i J{\nu}(T^i_{ex})\tau^i_v}{\Sigma_i \tau^i_v}-J_{\nu}(T_{BG})\right)(1-\exp(-\tau_v))$

We can multiply $$T_B$$ by the filling factor to get the main beam temperature.