CAMB Lecture

Download as pdf or txt
Download as pdf or txt
You are on page 1of 46

CAMB/EFTCAMB/CosmoMC

A general note
What will we do?
1. How to use the codes

2. Learn settings and possible customizations

3. A glimpse at their structures


We will not go through all the source code, only things needed for the most common modifications

4. Exercises on use and modifications


Requirements
● gfortran (gcc6) or intel (ifort14+) compiler
● python2.7 or python3.4

How to get these:

● Linux/Mac: sudo apt-get install “package” should do the trick


● Windows:
For windows users, we suggest to use the CosmoBox virtual machine.
Once that is set up you will not need to install much (or anything at all)
Step 0: install the working environment
Go to http://cosmologist.info/CosmoBox/ and follow the instructions to install
Cosmobox Desktop.

As explained you just need to download and install

❏ VirtualBox (https://www.virtualbox.org/wiki/Downloads)
❏ Vagrant (https://www.vagrantup.com/downloads.html)
❏ Or use the DockerToolbox (Mac and windows...I used this)

Create your working directory ( e.g. Corfu2017/) and run

> cd Corfu2017/
> vagrant init cmbant/cosmobox
> vagrant up
Step 0.1: run cosmobox

You can suspend and resume the virtual machine by running

> vagrant suspend


> vagrant resume

Inside cosmobox you can download, compile the code as shown in few slides!
If you need further tools (e.g. plotting tools) you can get them as in any unix system
> sudo apt-get install gnuplot
On the workstations
We add issues in installing all the requirements there

To solve it quickly we installed the CosmoBox also there


From your home folder:
> vagrant resume

You now have an Ubuntu machine within an Ubuntu machine!


CAMB
CAMB
Code for Anisotropies in the Microwave Background

Main authors: Antony Lewis and Anthony Challinor

Documentation: README, CAMB notes and python documentation

Main references:
definitely too many to list, refer to the references section of the README
Outline
1. The black box approach: compiling and running

2. Exercise: how to use CAMB

3. A glimpse at the structure

4. Exercise: modify CAMB

5. Extra exercise (additional transfer function)


The Black Box Approach
What’s CAMB?

Code for Anisotropies in the Microwave Background


Language: fortran + python wrapper

Given a set of cosmological parameters, it solves Boltzmann equations and computes:

● CMB power spectra


● Transfer functions
● Matter power spectrum

Assuming ~ΛCDM (can use w=w(z) dark energy)


Downloading
CAMB is available at camb.info (with an informative readme page) or on github

Get the code with:

> git clone https://github.com/cmbant/CAMB.git

There is also a web interface on the LAMBDA website


Schematic structure Output

params.ini
Input cosmology
Cosmology calculators
And options

calls

calls

inidriver.F90 calls camb.f90 calls cmbmain.f90


Reads ini Module CAMB Module CAMBmain
(main wrapper for (main integration modules,
Runs the code camb routines) computes cls, etc…)
Compiling
Makefile and Makefile_main contain instructions to compile the code.
Generally, they don’t need to be modified.

Some choices can be done at the level of the Makefile:

Switch to equations_ppf.f90 and then


compile:
> make

...fingers crossed!
Cosmology and options: params.ini
Cosmology and general options are passed to CAMB through the params.ini
(or through the python wrapper).

What the code should do and how

Cosmological parameters
(other parameters below)
Output control and accuracy Accuracy options: trade speed for
accurate calculations

Transfer functions output and usage


Run the code
Depending on the choices you made in the params.ini file you will have different
kind of output.

Let’s give it a try...

> ./camb params.ini


The output
Python wrapper
CAMB now has also a python wrapper.
From the pylab folder

> python setup.py install --user

How to use it? Call it in your python scripts


Good extensive demo in the docs

http://camb.readthedocs.io/en/latest/CAMBdemo.html
Exercise:
“fit” the Planck data
Exercise:
Reproduce the Planck best fit!

● Use the marginalized values obtained analyzed temperature (Table 4 - fitst column) and
temperature+lensing (Table 4 second column) from the Planck 2015 parameter paper
to obtain CMB spectra

● Plot temperature and lensing theoretical spectra on top of the data

● use the data available on Google Drive (temperature and lensing data point)
These are taken from the LAMBDA website

Is there a difference between the two cases? Why?


Results
Planck and lensing
There is a difference in lensing amplitude
if you measure it with Planck T,E,B
spectra or with lensing extraction
algorithms

Planck 2015 XIII


CAMB’s structure
CAMB changelog
Schematic structure Output

params.ini
Input cosmology
Cosmology calculators
And options

calls

calls

inidriver.F90 calls camb.f90 calls cmbmain.f90


Reads ini Module CAMB Module CAMBmain
(main wrapper for (main integration modules,
Runs the code camb routines) computes cls, etc…)

To use CAMB in an external code: use CAMB, call CAMB_GetResults (see CosmoMC)
What’s in the files?
Utilities Cosmology Driver and params
● bessels.f90 ● camb.f90 ● inidriver.F90
● inifile.f90 ● cmbmain.f90 ● params.ini
● Matrix_utils.f90 ● cosmorec.f90
● subroutines.f90 ● equations.f90
● utils.F90 ● halofit.f90
● writefits.f90 ● hyrec.f90
● lensing.f90
● modules.f90
● power_tilt.f90
● recfast.f90
● reionization.90
● SeparableBispectrum.f90
A closer look at cosmology
Evolution and transfer : Recombination: CMB lensing:
● equations.f90 ● recfast.f90 ● lensing.f90
● equations_ppf.f90 ● cosmorec.f90
● hyrec.f90

Initial power spectrum: CMB Cls: Non linear P(k):

● power_tilt.f90 ● cmbmain.f90 ● halofit.f90


initial power parameters ● halofit_ppf.90
definition and reading

Modules: Reionization: Bispectrum:


● Modules.f90 ● reionization.f90 ● SeparableBispectrum.f90
variables declaration, background
functions, P(k), output
A “small” subtlety
CAMB stores the evolution in two different places:

1. EV%OutputTransfer
These functions contain the evolution used to compute P(k,z) for the given
choice of species. This is not transformed in spherical harmonics, thus Bessel
functions are not used here.

2. sources(1-3)
These terms are integrated together with the Bessel functions to obtain Cls
Transfer functions and P(k)
Starting from primordial power spectrum, evolved observables are computed in
terms of the transfer functions, e.g.

These are computed in equations and used in various parts of the code
Sources and CMB
To obtain Cls one has to integrate the source terms with the Bessel functions in k
and z (see Ingunn’s lecture). This is done in cmbmain.f90

Source_q are interpolations of the source term computed in equations.f90 multiplied by the bessel functions
Source terms: just to scare you
Background functions
Given the evolution computed in equations.f90 CAMB computes some relevant
functions that are used throughout the code and can be also called by external codes.

In module.f90 you can find for example all the routines computing the P(k).
You can also find several functions computing background quantities, e.g.
Cosmological parameters

CAMB has two different procedures for parameters definitions.


We can broadly divide parameters in two classes:

1. Expansion and density parameters


H_0, baryon, DM and neutrino densities, w, …

2. Initial power parameters


A_s, n_s, ...
Expansion and densities parameters
Defined in modules.f90 Read in inidriver.F90
Initial power parameters
Defined, read (and used) in power_tilt.f90
Exercise:
Features in the primordial power spectrum
Exercise: features in the primordial P(k)
At low multipoles, data seem to prefer a lower power than what we expect
Inflation features?
The low-l problem can be tackled thinking of inflationary features in the primordial
power spectrum, e.g.

Benetti et al. 2012


A phenomenological approach
You want to investigate this issue, but you don’t know much about inflation.

What to do?

1. Work with your inflationary friend


2. Give up and go enjoy the sun on the beach
3. Use a phenomenological parametrization
A phenomenological approach
Try to include a parametrized modification to the primordial power spectrum

Initial P(k) is computed in power_tilt.f90


Include here new parameters and modify P(k)

Include a print to see the new primordial spectrum


Tips
● Modifications need to be done where primordial power spectrum is defined:
power_tilt.f90

● Define the parameters in InitialPowerParams type


● Read them in InitialPower_ReadParams
● Set default value SetDefPowerParams
● Modify the power spectrum in ScalarPower

Basically follow one of the standard initial power parameters, e.g. k_0_scalar

And remember to include the new parameter in params.ini!


Results

Can we fit the low-l tail without spoiling everything else?


Extra exercise: a modified transfer function
Add an extra contribution to CDM transfer function

This is an effect of models such as Unified Dark Matter models, see 1103.0234

Implement equations (8) and (11) in CAMB.


Transfer functions are defined in equations_ppf.f90 (or equations.f90)

Remember to define the new parameter.


Tips
● Define a new subroutine, where the new transfer function is computed

● Call the subroutine in the relevant part of the codes (output and derivs
subroutines in equations_ppf.f90)

● Add the result properly to the transfer functions, i.e. to


EV%OutputTransfer(Transfer_cdm)
EV%OutputTransfer(Transfer_tot)
and to the lensing source term, sources(3)

● Use CAMB’s subroutine for bessel functions


call BJL(order,argument,result)
Results

Camera, Martinelli, Bertacca 2017

You might also like