Skip to content

ThomasGesseyJones/CosmicRayHeatingFor21cm

Repository files navigation

Cosmic Ray Heating For 21cm Simulations

Overview

Repository

Cosmic Ray Heating For 21cm Simulations

Author

Thomas Gessey-Jones

Homepage

https://github.com/ThomasGesseyJones/CosmicRayHeatingFor21cm

Paper

https://ui.adsabs.harvard.edu/abs/2023MNRAS.526.4262G

This repository contains the code used to produce the cosmic ray heating window functions and heating coefficients for the paper Signatures of Cosmic Ray Heating in 21-cm Observables.

The code was developed to be integrated into the semi-numerical 21-cm signal simulation code described in Visbal et al. (2012), Fialkov et al. (2014), and Reis et al. (2020) (for access to this simulation code please contact Anastasia Fialkov at anastasia.fialkov@gmail.com). However, this cosmic ray heating code can operate standalone, and so could be used to integrate cosmic ray heating into any grid-based semi-numerical 21-cm simulation code. Hence, it is made available here for the community to use.

Code Structure

The code is split into four files:

  • cosmic_ray_general.py which contains the general functions used to calculate the heating window functions and heating coefficients. Most of these functions are either approximate analytic solutions to the cosmic ray energy equation (paper equation 25) or the comoving path length equation (paper equation 26).
  • cosmic_ray_coeffs.py which contains the functions used to calculate the heating coefficients that describe the rate of cosmic ray heating by a source. These coefficients are calculated on an adaptive redshift grid which will refine to ensure that the heating coefficients are calculated to a specified accuracy.
  • cosmic_ray_window.py which contains the functions used to calculate the heating window functions that describe the distribution of cosmic ray heating around a point source. Near the point source these window functions are calculated on a higher resolution grid, that is then convolved with the possible point source positions to produce the heating window functions at the desired resolution.
  • generate_cosmic_ray.py acts as the main interface to the code, taking command line arguments to specify the cosmic ray spectrum to use and the type of window functions to produce. It is described in more detail below.

The code is intended to be used through the command line interface of generate_cosmic_ray.py which takes the following arguments:

  • path_to_storage: a string. The path of folder where window functions and coefficients are to be stored
  • window_function_type: a string. ID of the type of window function to be generated. Options are 'global', 'locally_confined' and 'free_streaming'. Note for 'global' and 'locally_confined' the window functions are trivial and so are not stored (coefficients are still stored).
  • alpha: a float. Exponent of cosmic ray power-law spectrum (see paper equation 22)
  • ke_min: a float. Minimum energy of cosmic ray power-law spectrum in MeV (see paper equation 22)
  • ke_max: a float. Maximum energy of cosmic ray power-law spectrum in MeV (see paper equation 22)

Other aspects of the code can be changed by editing the constants at the top of the code. For example, the number of pixels in the semi-numerical signal simulation cube or the pixels side length can be changed by editing the constants at the top of generate_cosmic_ray.py.

The code is parallelised using joblib and so can be run on multiple cores for faster execution. The number of jobs is currently 35 so no benefit will be seen from running on more than 35 cores. This value is set by the number of emission redshifts coefficients/window functions are calculated at.

Definitions

The heating coefficients are defined as the normalized rate of cosmic ray energy deposition into the IGM (not heating) at z due to a source at z:

$$C(z, z') = \int_{0}^{\infty} dT \left(\left.\frac{dE}{dz}\right|_{E\&I}(T) \frac{dN_{E}(T'[z', z, T])}{dT} \frac{dT'}{dT} \right)$$

where T is the kinetic energy of cosmic ray protons at z, T is the kinetic energy the cosmic ray proton would have needed to have had at z to have a kinetic energy of T at z, $\frac{dN_{E}(T'[z', z, T])}{dT}$ is the cosmic ray emission spectrum at z (normalized to one unit of energy emission) and, $\left.\frac{dE}{dz}\right|_{E\&I}(T)$ is the energy deposition rate per redshift of a cosmic ray proton of kinetic energy T at z (see paper equation 4). $\frac{dT'}{dT}$ is a Jacobian factor which transforms from the cosmic ray energy at z to the cosmic ray energy at z.

The heating window functions W(x⃗, z, z′) are simply the distribution this energy deposition rate around a point source at z. Hence, they vary with cosmic ray propagation mode (see paper section 3.3.2). The heating window functions are therefore probability distributions and so are normalized to one.

Combining these we find the cosmic ray energy deposition rate into the IGM (not heating rate) is given by:

$$\left.\frac{dU}{dV dz}\right|_{cr}{(\vec{x}) = \eta_{cr} \int C(z, z') (W(\vec{x}, z, z') \ast SFRD_{cr}(\vec{x}, z') )dz'}$$

where ηcr is the efficiency of cosmic ray emission and SFRDcr is the star formation (redshift) rate density of cosmic ray emitting sources (see paper section 3.3.1). This can then be converted to a heating rate by multiplying by the local heating efficiency (see paper section 3.3.3) and the local heat capacity of the IGM.

Licence and Citation

The software is available on the MIT licence.

If you use the code for academic purposes we request that you cite the following paper.

@ARTICLE{2023MNRAS.526.4262G,
       author = {{Gessey-Jones}, T. and {Fialkov}, A. and {de Lera Acedo}, E. and {Handley}, W.~J. and {Barkana}, R.},
        title = "{Signatures of cosmic ray heating in 21-cm observables}",
      journal = {\mnras},
     keywords = {cosmic rays, dark ages, reionization, first stars, early Universe, cosmology: theory},
         year = 2023,
        month = dec,
       volume = {526},
       number = {3},
        pages = {4262-4284},
          doi = {10.1093/mnras/stad3014},
archivePrefix = {arXiv},
       eprint = {2304.07201},
       adsurl = {https://ui.adsabs.harvard.edu/abs/2023MNRAS.526.4262G},
      adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

Requirements

The code requires the following packages to run:

and was developed using python 3.8. It has not been tested on other versions of python.

Questions

If you have any questions about the code please contact Thomas Gessey-Jones at tg400@cam.ac.uk. Or alternatively open an issue on the github page.