#import "importer/main.typ": *
#import "helpers.typ": *
#import "@preview/physica:0.9.5": *

= Overview of the #beorn framework <procedure>

This section describes the model describing the sources of radiation that drive reionization. We explain how #beorn implements this model to generate 3D maps of the IGM during the epoch of reionization. The code of #beorn as well as usage instructions are publicly available under #link("https://github.com/cosmic-reionization/BEoRN", "https://github.com/cosmic-reionization/BEoRN")#footnote[
  For an explicit overview of the changes referenced here, please refer to #link("https://github.com/moll-re/BEoRN")
].


== The halo mass model of reionization <hmreio>

The central action
// don't like that word
performed by #beorn is the parametrization of sources of radiation through the properties of their host dark matter halos. This approach is based on the model presented by @schneider2023cosmologicalforecast21cmpower and gives a description
// bad word
of the $21 "cm"$ signal through the treatment of flux profiles around sources. Using these profiles and allowing them to overlap allows for efficient computations of the ionization state of the IGM without the need for detailed radiative transfer simulations.

The model describes the emission of ionizing radiation by galaxies. It assumes that the sources are hosted by dark matter halos and expresses the star formation and radiation properties as a function of the halo mass $M_"h"$ and mass accretion rate $dot(M_"h")$. The modelling
// maybe treatment
of the halo mass evolution is discussed in section @halo_mass_history, the model itself simply considers an arbitrary but known halo mass accretion history $M_"h" (z)$.

The emission of radiation revolves around the star formation rate $dot(M)_star$ which is simply assumed to be proportional to the halo mass accretion rate via
$
  dot(M)_star = f_star (M_"h") dot dot(M_"h")
$ <eq:star_formation_rate>
where the star formation efficiency $f_star$ introduces a mass dependence that enables the suppression of star formation in low mass halos and the implementation of a cooling limit.
Motivated by abundance matching @schneider2023cosmologicalforecast21cmpower use the double power law
$
  f_star (M_"h") = f_(star,0) dot (2 (Omega_b / Omega_m)) / ((M_"h"/M_"p")^(gamma_1) + (M_"h"/M_"p")^(gamma_2)) dot S(M_"h")
$ <eq:star_formation_efficiency>
where $M_"p"$ is the pivot mass where the efficiency peaks, $gamma_1$ and $gamma_2$ are the low and high mass slopes and $f_(star,0)$ is the normalization chosen at approximately $0.1$. An additional suppression factor $S(M_"h")$ is introduced to account for reduced star formation in low mass halos, its effect is discussed by @Schaeffer_2023.



=== Expression of the profiles
Deriving from the star formation rate the halo model predicts the production and distribution of photons in 3 distinct energy bands:
Lyman-alpha photons, ionizing UV photons, and X-ray photons. Each of these bands has a different effect on the IGM and is treated separately.
// Not really sure that's true

Lyman-alpha photons induce a coupling between the spin temperature and the kinetic temperature of the gas. This effect, known as the Wouthuysen-Field effect
// TODO - check
#cite(<Wouthuysen>, form: "normal")
#cite(<Field>, form: "normal")
causes absorption of $21 "cm"$ photons before reionization. This is reflected in the absorption expected in the global signal before reionization.
$
  rho_alpha (r bar M, z) = (1 + z)^2 / (4 pi r^2) dot sum_(n=2)^(n_m)f_n dot epsilon_alpha (nu prime) dot f_star dot dot(M)(z prime bar M, z)
$



The temperature around the sources is described
// bad word
by the cooling temperature of the adiabatically expanding universe and the heating due to X-ray photons emitted by the newly formed stars. The temperature profile follows

$
  3/2 dot derivative(rho_h (r bar M, z), z) = (3 rho_h (r bar M, z)) / (1 + z) - (rho_"xray" (r bar M, z)) /(k_B (1 + z) H(z))
$
which is based on ????



Ionizing photons, i.e. photons with energies above $13.6 "eV"$ experience a large optical depth which justifies the expression


$
  derivative(V, t) = dot(N)_"ion"(t) / overline(n)_H^0 - alpha_B dot C / a^3 dot overline(n)_H^0 dot V
$

$
x_("HII")(r bar M, z) = theta_"H" (R_b (M, z) - r) = theta_"H" (root(3, 3/ (4pi) V(M,z)) - r)
$

// introduced inaccuracies
// e.g. bursty star formation as presented by Romain Teyssier

=== Expression of the reionization signal

The observable signal of the $21 "cm"$ line is expressed as the differential brightness temperature $d T_"b"$ which describes the contrast of the foreground with the CMB background.
// might want to rephrase that
Following e.g. @Pritchard2012 an expression for $d T_"b"$ is given by
$
  d T_"b"(bold(x), z) tilde.eq T_0 (z) dot x_"HI" (bold(x), z)  dot (1 + delta_b (bold(x), z)) dot (x_alpha (bold(x), z)) / (1 + x_alpha (bold(x), z) ) dot ((1 - T_"CMB" (z)) / (T_"gas" (bold(x), z)))
$
where the background radiation originates from the CMB.


== Simulation steps
The simulation procedure revolves around the implementation of the spherical radiation profiles around halos. We give a brief overview of the main steps here. For a more detailed description of the implementation we refer to @Schaeffer_2023. We discuss our improvements and changes to the original implementation in section @implementation.

=== Halo catalog - n body simulations
As a prerequisite, the generation of map data requires a spatial distribution of dark matter halos as well as the underlying density field. Each snapshot can be used to generate a map at the corresponding redshift. #beorn has been successfully validated against mock maps generated by 21cmFAST
// TODO cite
and produced results by using the #pkdgrav #cite(<potter2016pkdgrav3trillionparticlecosmological>, form: "normal") simulation suite.

=== Computation of radiation profiles
In accordance with the astrophysical parameters set by the user, radiation profiles are computed to be applied onto halos in a subsequent step. We deliberately separate the computation of the profiles from their application onto halos for a more efficient processing. The range of halo masses and redshifts covered by this precomputation is largely determined by the underlying halo catalog since it provides upper bounds on the halo masses
#footnote[
  The minimum halo mass that needs to be considered is already constrained by the atomic cooling limit. Depending on the mass resolution of the simulation it might not even be reached.
]).

=== Painting with the binned approach
The last step consists of applying the ionization and temperature distributions defined by the profiles onto a 3D grid. This is done by iterating over the halos in the catalog and using their corresponding profile. For a given profile a 3D kernel is generated and applied onto the grid via convolution. We refer to this procedure as "painting" since the addition of the contributions of each halo allows us to sequentially build up the final map.

The usage of precomputed profiles is crucial to the efficiency of the simulation but it introduces a discretization in halo mass since each halo is assigned the profile of the closest mass bin. The effect of this simplification has been shown to converge for a sufficient number of mass bins by @Schaeffer_2023.


=== Derivation of global quantities
The global signal as well as the power spectrum are derived from the map data and compared to other models or observations. Being derived from a full 3D nbody simulation means that the results are sensitive to the underlying cosmology and the detailed profile modelling means that the results are sensitive to the underlying astrophysical model.
