HyRec

A code for primordial hydrogen and helium recombination
including radiative transfer


by Yacine Ali-Haïmoud and Chris Hirata



New: HyRec is now incorporated into the Boltzmann code CLASS (by Julien Lesgourgues).
You can also call HyRec from CAMB (by Antony Lewis and Anthony Challinor)

This code includes the following physics:

Helium recombination:

  • Hydrogen continuum opacity in the HeI 21Po--11S line
  • He I] 23Po--11S intercombination line
  • Feedback between these lines

Hydrogen recombination:

  • Exact effective multi-level atom calculation
  • A simultaneous solution of radiative transfer, accounting for:
  • Feedback between Lyman lines
  • Two-photon transitions (emission, absorption, Raman scattering) from 2s and higher levels
  • Frequency diffusion in Lyman-α
  • This code does not include collisional transitions (yet)
We estimate the errors of the code to be at the level of a few times 10-3 during helium recombination and a few times 10-4 during hydrogen recombination.
The code computes a full recombination history in ~2 seconds on a standard laptop.

Download the code (written in C) here (Version: October 2012)

New in this version: wrapper functions to call HyRec from CAMB (courtesy of Antony Lewis; put HyRec in the same folder as CAMB and simply compile CAMB using make RECOMBINATION=hyrec). Otherwise identical to May 2012 version: the Lyman-lines distortion is more accurately evaluated and can be easily extracted. The values of the fine-structure constant and electron mass at recombination can be provided as inputs (more details in the readme file and the technical explanatory supplement).

The previous versions are still available here (May 2012), here (January 2011) and here (November 2010). Warning: the November 2010 version is numerically unstable for some cosmologies. This was fixed in the following release.

Please yourself on the mailing list so we can keep you informed with updates and bug fixes.

The code is provided "as is" and there is no guarantee regarding its accuracy.

Quick start:

  • Compile the source code. For example, if your C compiler is gcc, enter the following at the command line:
    gcc -lm -O3 hyrec.c hydrogen.c helium.c hyrectools.c history.c -o hyrec
  • To compute a recombination history, now type:
    ./hyrec
  • Enter the desired cosmological parameters when prompted.
  • Three columns will be printed to the screen: redshift z, free electron fraction xe(z), and ratio of matter to radiation temperatures Tm/Tr(z).

You can find more details on in the readme file.


When using the code, please refer to:

Y. Ali-Haïmoud & C. M. Hirata, Phys. Rev. D 83, 043513 (2011) [arXiv:1011.3758]

This work also relies heavily on the following papers:

  • Y. Ali-Haïmoud & C. M. Hirata, Phys. Rev. D 82, 063521 (2010) [arXiv:1006.1355]
  • C. M. Hirata, Phys. Rev. D 78, 023001 (2008) [arXiv:0803.0808]
  • E. R. Switzer & C. M. Hirata, Phys. Rev. D 77, 083006 (2008) [arXiv:0702143]

You may also refer to:



For questions or issues, please email yacine[at]jhu[dot]edu

This material is based upon work supported by the National Science Foundation (NSF) under Grants No. AST-0807337 and AST-0807444. Any opinions, findings and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the NSF.

Last revised: October 5th, 2012