librad: C++ Radiative Transfer Library
librad is a C++ library that calculates a variety of functions used in Chandrasekhar’s radiative transfer theory1 including the \(X\), \(Y\), and \(H\) functions. These functions can be used to calculate diffuse reflection, transmission and absorption coefficients for strongly scattering materials, even for strongly anisotropic cases. The code contains no external dependencies and uses only the C++ standard library. The code is available on my Github account here.
librad implements several components including:
- a variety of numeric integration/quadrature routines
- Several explicit Runge-Kutta ODE solvers
- iterative solutions to \(H\), \(X\), and \(Y\)
- approximate analytic solutions to \(H\) 4
- reflectance, transmittance, and absorbance calculations for a planar layer
Some solutions for isotropic scattering are presented in the following figures.
librad evaluates the \(X\) and \(Y\) functions iteratively through the following integro-differential equations
\[\begin{aligned} \frac{\partial Y}{\partial\tau} + \frac{Y}{\mu} = X \overset{1}{\underset{0}{\int}} \frac{du}{u} \; \Phi(u) Y \\ \frac{\partial X}{\partial \tau} = Y \overset{1}{\underset{0}{\int}} \frac{du}{u} \; \Phi(u) Y \end{aligned}\]subject to the initial condition
\[X(\tau=0,\mu) = Y(\tau=0,\mu) = 1.\]for \(\mu > 0\). The \(H\) function for the isotropic scattering case is evaluated using a closed form integral representation5 that requires only a single numeric integral:
\[\ln H = -\frac{\mu}{\pi} \overset{\frac{\pi}{2}}{\underset{0}{\int}} \frac{\ln (1 - \alpha x \cot x)}{\cos^2 x + \mu^2 \sin^2 x} dx\]for the isotropic scattering case where \(\alpha\) is the albedo.
-
Chandrasekhar, Subrahmanyan. Radiative transfer. Dover publications, 1960. ↩
-
Bogaert, Ignace. “Iteration-free computation of Gauss–Legendre quadrature nodes and weights.” SIAM Journal on Scientific Computing 36.3 (2014): A1008-A1026. ↩
-
Bogaert, Ignace. “Fast Gauss-Legendre Quadrature Rules”, http://sourceforge.net/projects/fastgausslegendrequadrature. ↩
-
Davidović, Dragomir M., Jovan Vukanić, and Dušan Arsenović. “Two new analytic approximations of the Chandrasekhar’s H function for isotropic scattering.” Icarus 194.1 (2008): 389-397. ↩
-
Kawabata, Kiyoshi, and Sanjay S. Limaye. “Rational approximation formula for Chandrasekhar’s H-function for isotropic scattering.” Astrophysics and Space Science 332.2 (2011): 365-371. ↩