hotcross.cu
Documentation for the functions that dictate the hot cross section when evaluating inverse compton scattering.
Functions
Functions
-
__host__ void init_hotcross(void)
Initializes the Compton cross-section lookup table.
This function prepares a 2D lookup table for the total Compton cross-section as a function of dimensionless photon frequency \( w \) and electron temperature \( \Theta_e \).
Routine:
Attempts to open the file specified by
HOTCROSS.If the file is found, it loads the precomputed values into memory.
If the file is missing, it triggers a numerical calculation of the table using
total_compton_cross_num().
Note
The table is stored in \( \log_{10}-\log_{10} \) space.
- Returns:
void
-
__device__ double total_compton_cross_lkup(double w, double thetae, const double *d_table_ptr)
Computes the total Compton cross-section via lookup table and approximations.
This function selects the optimal physical regime to calculate the cross-section based on photon frequency \( w \) and electron temperature \( \Theta_e \).
Routine:
Thomson: If \( w \Theta_e < 10^{-6} \), returns the Thomson cross-section.
Klein-Nishina: If below table temperature limits, uses analytical expressions.
Interpolation: If in-bounds, performs bilinear interpolation in \( \log_{10}-\log_{10} \) space.
Fallback: If out-of-bounds, triggers a direct numerical calculation.
- Parameters:
w – Dimensionless photon frequency.
thetae – Dimensionless electron temperature.
d_table_ptr – Restrict-qualified pointer to the device lookup table.
- Returns:
The calculated Compton cross-section.
-
__host__ __device__ double total_compton_cross_num(double w, double thetae)
Performs numerical integration of the total Compton cross-section.
This function evaluates the cross-section by integrating over the electron Lorentz factor \( \gamma_e \) and collision angle \( \mu_e \). It utilizes a double loop to sum the contributions of the electron distribution function and includes analytical shortcuts for the Thomson and Klein-Nishina limits in low-temperature regimes.
- Parameters:
w – Dimensionless photon frequency.
thetae – Dimensionless electron temperature.
- Returns:
The numerically integrated cross-section normalized by \( \sigma_T \).
-
__host__ __device__ double dNdgammae(double thetae, double gammae)
Calculates the normalized Maxwell-Jüttner electron distribution function.
Returns the number of electrons per unit Lorentz factor \( \gamma_e \), normalized per unit proper electron number density. The implementation uses the modified Bessel function \( K_2(1/\Theta_e) \sim \Theta_{\rm e}^2\) approximation to ensure numerical stability in both relativistic and non-relativistic regimes.
- Parameters:
thetae – Dimensionless electron temperature \( \Theta_e = k_B T_e / m_e c^2 \).
gammae – Electron Lorentz factor \( \gamma_e \).
- Returns:
The value of \( dN/d\gamma_e \).
-
__host__ __device__ double boostcross(double w, double mue, double gammae)
Computes the Doppler-boosted Compton cross-section in the lab frame.
Transforms the lab-frame photon frequency \( w \) into the electron rest frame to evaluate the Klein-Nishina cross-section. The result is weighted by the relative interaction rate \( (1 - \mu_e \beta) \) to account for the beaming and relative velocity of the collision.
- Parameters:
w – Dimensionless photon frequency in the lab frame.
mue – Cosine of the angle between photon and electron velocity.
gammae – Electron Lorentz factor \( \gamma_e \).
- Returns:
The effective boosted cross-section.
-
__host__ __device__ double hc_klein_nishina(double we)
Evaluates the normalized Klein-Nishina cross-section \( \sigma_{KN} / \sigma_T \).
Computes the total cross-section for a photon with dimensionless energy \( w \) in the electron rest frame. For \( w < 10^{-3} \), it uses the expansion \( 1 - 2w \). Otherwise, it calculates:
\[ \sigma = \frac{3}{4} \left[ \frac{2}{w^2} + \left( \frac{1}{2w} - \frac{1+w}{w^3} \right) \ln(1+2w) + \frac{1+w}{(1+2w)^2} \right] \]- Parameters:
we – Dimensionless photon frequency in the electron rest frame.
- Returns:
The total cross-section normalized by the Thomson cross-section.
-
__host__ __device__ double bessi0(double xbess)
Modified Bessel function of the first kind, order zero: \( I_0(x) \).
Uses polynomial approximations and asymptotic expansions for numerical stability.
See also
- Parameters:
xbess – The input value \( x \).
- Returns:
The value of \( I_0(x) \).
-
__host__ __device__ double bessi1(double xbess)
Modified Bessel function of the first kind, order one: \( I_1(x) \).
Implemented using polynomial fits for small \( x \) and asymptotic forms for large \( x \).
See also
- Parameters:
xbess – The input value \( x \).
- Returns:
The value of \( I_1(x) \).
-
__host__ __device__ double bessk0(double xbess)
Modified Bessel function of the second kind, order zero: \( K_0(x) \). Evaluated via log-polynomial approximations for \( x \le 2 \) and exponential-asymptotic forms for \( x > 2 \).
See also
- Parameters:
xbess – The input value \( x \).
- Returns:
The value of \( K_0(x) \).
-
__host__ __device__ double bessk1(double xbess)
Modified Bessel function of the second kind, order one: \( K_1(x) \). Employs rational approximations and asymptotic expansions to maintain precision across scales.
See also
- Parameters:
xbess – The input value \( x \).
- Returns:
The value of \( K_1(x) \).
-
__host__ __device__ double bessk2(double xbess)
Modified Bessel function of the second kind, order two: \( K_2(x) \).
Computed using the recurrence relation: \( K_{n+1}(x) = K_{n-1}(x) + \frac{2n}{x}K_n(x) \), starting from the values of \( K_0 \) and \( K_1 \).
See also
- Parameters:
xbess – The input value \( x \).
- Returns:
The value of \( K_2(x) \).