C L A S S

the Cosmic Linear Anisotropy Solving System


The purpose of CLASS is to simulate the evolution of linear perturbations in the universe and to compute CMB and large scale structure observables. Its name also comes from the fact that it is written in object-oriented style mimicking the notion of class. Classes are a wonderfull programming feature available e.g. in C++ and python, but these languages are known to be less vectorizable/parallelizable than plain C (or Fortran), and hence potentially slower. For CLASS we choose to use plain C for high performances, while organizing the code in a few modules that reproduce the architecture and philosophy of C++ classes, for optimal readability and modularity.

Download

The use of CLASS is free provided that if you use it in a publication, you will cite at least the paper CLASS II: Approximation schemes (reference below). You are welcome to cite any other CLASS paper if relevant!

There are two ways to download CLASS. The simplest thing is to clik the download button below, to get the code as a single compressed .tar.gz file. But if you are familiar with git repositories, and you wish to do modifications to the code, or develop a new branch of the code, you will prefer to download it from the class_public git repository.

Download version v2.4.3 :
(check that your browser accepts cookies, otherwise you may bounce back to the same page)
Email addres:
Keep me informed about future updates of CLASS


Documentation

After downloading the code, unpack the archive (tar -zxvf class_v*.tar.gz), go to the class directory (cd class_v*/) and compile (make clean; make class). If the first compilation attempt fails, you may need to open the Makefile and adapt the name of the compiler (default: gcc), of the optization flag (default: -O4) and of the OpenMP flag (default: -fopenmp; this flag is facultative, you are free to compile without OpenMP if you don't want parallel execution; note that you need the version 4.2 or higher of gcc to be able to compile with -fopenmp). Several details on the CLASS compilation are given on the installation wiki page (in particular, for compiling on Mac 10.9 Mavericks).

To check that the code runs, type: ./class explanatory.ini The explanatory.ini file is a reference input file, containing and explaning the use of all possible input parameters. We recommend to read it, to keep it unchanged (for future reference), and to create for your own purposes some shorter input files, containing only the input lines which are useful for you. Input files must have a *.ini extension.

If you want to play with the precision/speed of the code, you can use one of the provided precision files (e.g. cl_permille.pre) or modify one of them, and run with two input files (e.g. ./class test.ini cl_permille.pre).

A simplified documentation can be found in the CLASS I: Overview paper. On top of that, if you wish to modify the code, you will find lots of comments directly into the files. Other CLASS papers dedicated to various aspects of the code are listed below. You can also look at slides from CLASS-dedicated courses.

To use CLASS from python, or ipython notebooks, or from the Monte Python parameter extraction code, you need to compile not only the code, but also its python wrapper. This can be done by typing just make instead of make class. More details on the wrapper and its compilation are found on the wiki page.

Since version 2.3, the package includes an improved plotting script called CPU.py (Class Plotting Utility), written by Benjamin Audren and Jesus Torrado. It can plot the Cl's, the P(k) or any other CLASS puput, for one or several models, as well as their ratio or percentage difference. The syntax and list of available options is obtained by typing pyhton CPU.py --help. There is a similar script for MATLAB, written by Thomas Tram. To use it, once in MATLAB, type help plot_CLASS_output.m

If you want to develop the code, we suggest that you download it from the github webpage rather than from class-code.net. Then you will enjoy all the feature of git repositories. You can even develop your own branch and get it merged to the public distribution, following the related instructions.


Papers


Version history

The developement of CLASS benefits from various contributors credited below. In absence of specific credits, developements are written by the main CLASS authors, Julien Lesgourgues and Thomas Tram.

v2.4 (29.09.2014)
  • extended inflation simulator embedded in the primordial module. Option 'inflation_V' (input = V(phi) function in observable range) still exists, but more efficient; two new options 'inflation_H' (input = H(phi) function in observable range) and 'inflation_V_end' (input = V(phi) trusted until the end of inflation, and parameters specifying the amount of inflation between the Hubble crossing for the pivot scale and the end of inflation). See explanatory.ini for details on new input parameters.
  • improved accuracy of Limber approximation in curved space, as explained in Appendix E of JCAP 09 (2014) 032
  • the python code for plotting output files, CPU.py, has been significantly improved (type python CPU.py --help to check options and input format) (credits: Benjamin Audren, Jesus Torrado).
  • the classy wrapper can now output many more quantities than just the CMB Cl's and P(k): density Cl's (this can be used for Euclid forecast with detailled modelling of the power spectrum, credits Benjamin Audren), evolution of background, thermodynamical, perturbation quantities, density and velocity transfer functions.
  • expanded automatic tests, with a detailled explanation in the header of python/test_class.py. It is now easy to combine models, add new scenarios to test, and systematically compare the implementation in synchronous and Newtonian gauge.
  • improvements in the Decay Dark Matter (ddm) sector: choice between more input formats, fixed error in Newtonian gauge.
  • increased precision settings for CMB and P(k) with massive neutrinos or WDM (ncdm) in the Newtonian gauge (thanks to Mathias Garny).
  • various small bug fixes (credits Guido Pettinari) and memory leak fixes.
  • 12.10.2014 (v2.4.1): default parameter values updated close to Planck 2013 best fit
  • 06.01.2015 (v2.4.2): minor improvements, mainly related to the plotting unit CPU.py, to the Makefile and to the use of the functionality k_output_values=... (perturbations are now stored in files for exactly those values, not values close to them)
  • 10.03.2015 (v2.4.3): minor mistakes corrected (lensing potential in curved space, details of nCl and DM annihilation calculation, density-lensing correlations between bins), as well as a long-standing rare bug in the integrator
v2.3 (09.05.2014)
  • implemented a new species: decaying cold dark matter (dcdm) and its relativistic decay product (dr); also, background module improved, now ready for adding easily other cases where one needs to integrate more background quantitites over time than just the scale factor a(tau).
  • implemented a new input parameter: '100*theta_s', the angle of the sound horizon at decoupling (thanks to S. Plaszczynski); also, input module improved, now ready for adding easily several input parameters which require a shooting method (like '100*theta_s' or the decaying dark matter density today 'Omega_dcdmdr', another example not written yet would be 'sigma_8')
  • increased precision settings, consequences mainly for P(k) at large k >> 0.1 h/Mpc (thanks to Chi-Ting Chiang, Mathias Garny, Aurel Schneider)
  • tensor calculation sped up, thanks to independent sampling of wavenumber space for scalars and tensors
  • the 'root' name preceeding all output file names is now set by default to the input file name plus the first available integer number (e.g. output/myname00_ the first time, output/myname01_ in the next run...); also, improved output file headers with automatic column numbering
  • classy wrapper improved (installation compatible with both Python2.6 and 2.7, handles tensor and isocurvature modes, improved automatic testing with nosetests python/test_class.py, changed the function get_current_derived_parameters() to accept as argument a list of names) (credits: Benjamin Audren)
  • new MATLAB plotting routine plot_CLASS_output.m, type help plot_CLASS_output.m in MATLAB for usage
  • the other plotting routine, CPU, is in the process of being rewritten. A new file, CPU.py is using matplotlib, and works exactly like the MATLAB routine - but is so far incomplete (credits: Benjamin Audren)
  • 26.05.2014 (v2.3.2): fixed minor bugs and extended functionalities of CPU.py
v2.2 (28.03.2014)
  • incorporated massless and massive neutrinos (in the language of the code, the ultra-relativistic ur and non-cold dark matter ncdm species) in the calculation of tensor modes (for temperature and polarisation)
  • for speed up, included two approximation schemes for tensors, described in the field tensor method of explanatory.ini. By default, when evolving tensor perturbations, the code will replace massive neutrinos by an appropriate amount of massless ones. This works very well, especially for masses below 0.6eV, and even above. The exact calculation involving the ncdm momentum space can always be restored.
v2.1 (07.03.2014)
  • the ClassGAL features developped in JCAP 1311 (2013) 044 (by E. Di Dio, F. Montanari, J. Lesgourgues and R. Durrer) have been imported into the main distribution of the code. The naive "density Cl's" are replaced by the "number count Cls", calculated if the 'output' entry includes 'nCl'. The user can choose to include all relativistic corrections by passing 'number count contributions = density, rsd, lensing, gr', or only the dominant terms. One can also tune the selection function, linear bias, magnification bias and evolution effects (see the description of the fields 'dNdz_selection', 'bias', 's_bias', 'dNdz_evolution' in explanatory.ini and in the appendix of JCAP 1311 (2013) 044).
  • the non-linear module has been completely re-written. In the main function, the non-linear module is now called before the transfer module, to allow for the calculation of lensing Cl's, density Cl's and lensed CMB Cl's including non-linear corrections. The module features HALOFIT recalibrated by Takahashi et al., extended to massive neutrinos following the same method as in arXiv:1109.4416 (input command 'non linear = halofit' (vredits Simeon Bird). The one-loop and time renormalisation algorithms of previous versions have been dropped temporarily, but new methods are now easier to incorporate, and will be implemented in the future.
  • new features for passing or plotting the primordial power spectrum (credits Jesus Torrado). They are active when the input is set to 'P_k_ini type = external_Pk' (instead of the other options 'analytic_Pk', 'inflation_V', 'two scales'). The user can pass the primordial spectrum as an input file, or even compute it on-the-fly with an external code (in whatever language). The input is then the command line for running that code. This is described briefly in explanatory.ini and extensively in the external_Pk/README.md file delivered with the code. Finally, for whatever way of computing the primordial spectrum, the user can output it in a file with the input command 'write primordial' described in explanatory.ini.
  • implementation of perturbed recombination (credits Luc Voruz), based on arXiv:0707.2727 and astro-ph/0503196. A detailed description of related equations is provided in these notes. Perturbed recombination can be switched on by passing 'perturbed recombination = yes', as explained in explanatory.ini.
  • facility for printing perturbations as a function of time (credits Thomas Tram). In order to physically understand what you are doing, or produce nice plots in a paper, it is useful to output the evolution of each perturbation (of matter components, of the metric, etc.) as a function of time. This feature is now directly accessible from the input file, by passing a list of wavenumbers in the field 'k_output_values' as described in explanatory.ini. Then the corresponding output files will be written.
  • compatible with version 2.0 of Monte Python (credits Benjamin Audren)
  • improved Python wrapper classy.pyx (credits Benjamin Audren), mainly a change of function names and error classes. (For developers: a test suite has been written, in python/test_class.py, which necessitates the python "nose" package. It calls CLASS sequentially on many combinations of models, and is useful to check that CLASS is still working after having made modifications.) For details see the new wiki on the python wrapper and on the python test function.
  • 22.03.2013 (v2.1.2): corrected a few bugs introduced in v2.1.0 (most important related to calculation of baryon drag redshift, credits Francesco Montesano), and updated Halofit with the revision of Takahashi et al. 2012 extended to massive neutrinos (credits Simeon Bird)
v2.0 (01.10.2013)
  • implementation of spatial curvature (credits Thomas Tram). Curvature is set using the 'Omega_k' input parameter (positive for negative curvature, following the usual convention).
  • the perturbation module relies on the optimal Boltzmann hierarchy described in arXiv:1305.3261 [astro-ph.CO].
  • the transfer module has exprienced major changes. For the computation of hyperspherical Bessel functions and transfer functions, some explanations on the methodology, the precision, the comparison with other codes are given in arXiv:1312.2697. In brief, with default precision settings, the scalar temperature Cls are precise at the 0.1% level, and the scalar polarisation Cls at the 0.2% level. The code remains very fast for small curvature, but the running time increases with the absolute value of Omega_k.
  • more accurate for tensor modes, and ready for working with vector modes (they are already implemented in the transfer module).
  • spherical Bessel functions cannot be stored/read from a file anymore, because the gain in time was too marginal. All Bessel functions are now computed on-the-fly by a set of new efficient functions, called directly from the transfer module. Hence, the bessels module and structure have been eliminated.
  • 09.10.2013 (v2.0.2): added the possibility to output the correlation Cls between density and galaxy lensing; computation of hyperspherical bessel functions made faster thanks to a vectorisation scheme; fixed a few bugs; restored the same sign convention for E-modes as CAMB and CMBFAST, while v2.0.1 had the opposite convention, taken from Hu & White.
  • 31.10.2013 (v2.0.3): several little bug fixes, accuracy of ClTphi and ClEphi restored, thanks to S. Plaszczynski and G. Pettinari
  • 09.12.2013 (v2.0.4): wavenumber sampling and few approximations improved, to match arXiv:1312.2697. New input field temperature contributions, allows to compute separately the SW, late and early ISW, Doppler and polarisation contributions.
v1.7 (21.03.2013)
  • version ready for use with Planck. Three precision parameters increased to match Planck sensitivity. With new default settings, Planck chi2 accurate up to approximately 0.5. This has been proved to be sufficient for parameter extraction from Planck data when using MCMC algorithms (checked through intensive testing within Planck collaboration, comparing different codes and various accuracy settings). Still possible to use higher precision settings when needed, e.g. for a very precise minimization of Planck chi2, or to derive frequentist bounds.
  • compatible with version 1.2 of Monte Python (credits Benjamin Audren). This version of the parameter extraction code is interfaced with the Planck and WMAP9 likelihoods, and features fast nuisance parameters (similar to the new CosmoMC implementation but simpler: does the Cholesky parameter rotation, but not the fast-parameter dragging scheme; this is sufficient for a considerable speed up) (credits A. Lewis)
  • implements an alternative parameter set for the primordial spectrum, consisting in amplitudes at two scales instead of one amplitude and one tilt, identical to the parameters in the isocurvature section of the Planck inflation paper. See explanatory.ini for all possibilities.
  • plethora of derived parameters defined in the python wrapper python/classy.pyx, ready to be used in Monte Python: slow-roll parameters, isocurvature fraction defined in different manners, tilt and running computed numerically at the end of the inflationary module.
  • for DM annihilation, new flag to switch on/off the on-the-spot approximation.
  • 28.03.2013: restored computation of lensed BB spectrum, set accidentally to zero in versions 1.6.x and 1.7.0 (but OK in earlier versions; thanks to Giulio Fabbian for pointing it out)
  • 04.04.2013: fixed bug introduced in 1.7.0, leading to segmentation fault in newtonian gauge (thanks to Ivan Duran Sancho for pointing it out)
v1.6 (15.01.2013)
  • computation of full-sky galaxy lensing potential Cl's, useful for cosmic shear experiments (if you add sCl to the field output=...)
  • for both lensing Cl's (sCl) and density Cl's (dCl), source galaxies can be distributed in redshift bins with either gaussian, tophat or dirac-like selection functions (see field selection in explanatory.ini). Also the dCl calculation has been speeded up and redesigned for more accurate results, even when the bins are many, and/or thin, and/or at small redhsift.
  • the python wrapper python/classy.pyx includes more functionalities, useful for running with the updated version 1.1 of Monte Python (credits Benjamin Audren)
  • several bugs fixed (many thanks to Stephane Plaszczynski, Sophie Henrot-Versille, Alberto Vallinotto, Katarina Markovic, Guido Pettinari, Matthieu Roman). The major one affected the CMB lensing potential Cl's, but only occasionally and when running with high precision settings (with a value of the precision parameter perturb_sampling_stepsize smaller than the default one). Another bug could occasionally affect the result of the Halofit routine.
v1.5 (25.10.2012)
  • changed three defaut values of RECFAST parameters to match RECFAST v1.5.2
  • module primordial includes an inflation simulator computing the primordial spectrum fully numerically, for a given expression of the scalar potential valid within the observable inflation range (as in Lesgourgues and Walkenburg (2007)), see explanatory.ini for details on possible input parameters
  • includes several parameters to model CDM annihilation (in the smooth background and in halos), as in Gisen et al. (2012)
  • code can output not only individual density transfer functions, but also individual velocity transfer functions (if you add vTk to the field output=...)
  • python wrapper python/classy.pyx expanded for compatibility with parameter inference code Monte Python v1.0
  • corrected bug that showed up when trying to get finely sampled transfer functions. Sampling can now be arbitrarily fine.
  • internal re-ordering of operations in transfer modules, that speeds up the calculation of matter density Cl's. Also, the user can compute correlation between all shells or only between neighbouring shells.
v1.4 (13.02.2012)
  • recombination can be computed either with RECFAST v1.5, or with the HyRec code by Y. Ali-Haimoud & C. Hirata. Just set the input parameter recombination to either RECFAST or HyRec. HyRec is slower, but more precise and flexible. Both codes agree at the level of precision of Planck and for standard cosmology. The November 2011 version of HyRec is distributed together with v1.4. Class can be compiled without HyRec by leaving HYREC = blank in the Makefile, instead of putting there the path to HyRec (default: compiled with the distributed version, located in class/hyrec/) (credits Y. Ali-Haimoud and C. Hirata)
  • user can choose between the same reionization history as in CAMB (featuring a single step for hydrogen reionization), or a binned reionization history, with arbitrary bin number, position and width (similar to implementation in Lewis, Weller and Battye (2006)). Set input parameter reionization to either reio_camb or reio_bins_tanh, and see explanatory.ini for more details on input parameters (binned_reio_z, binned_reio_z, etc.)
  • user can choose to pass a numerical value for the primordial helium fraction YHe, or let it be fixed as a function of omega_b and N_eff by standard BBN calculations, by setting YHe to BBN (as in Hamann, Lesgourgues and Mangano (2008))
  • includes latest version of HALOFIT, working even in presence of massive neutrinos (from Bird, Viel and Haehnelt (2011)). Set non linear to HALOFIT to get the non-linear P(k) (credits B. Audren and S. Bird)
  • improved newtonian gauge: phi is integrated over time rather than infered from constraint equation; in that way newtonian gauge calculations are more accurate than in v1.3, and remain stable even in presence of isocurvature modes or massive neutrinos (credits Guido W. Pettinari)
  • user can choose to pass some numerical values for the tensor tilt and running (n_t, alpha_t), or let them be fixed by the two self-consistency conditions of single field slow-roll inflation, by setting these entries to scc (see explanatory.ini for details)
  • if output includes dCl, the code will compute the Cl spectra of matter density perturbations in an arbitrary number of redshift bins (defined by gaussian window functions, with arbitrary centers and widths, fixed through input variables selection_mean and selection_width). The output ..._cl.dat file will then contain CMB (if requested) plus density spectra, including all possible cross-correlations. See explanatory.ini for details on input parameters.
  • corrected a few bugs previously affecting temperature/polarization tensor spectra.
  • python wrapper for class, available in the python/ directory (see python/README). Used by the cosmological parameter extraction code that we will release soon (credits K. Benabed and B. Audren)
  • c++ wrapper for class, available in the cpp/ directory (see cpp/README) (credits S. Plaszczynski)
v1.3 (08.11.2011)
  • implementation of the Newtonian / longitudinal gauge equations on top of the synchronous ones. The user can choose the gauge by writing e.g. gauge=newtonian in the input file (by default, set to synchronous gauge). The Newtonian gauge calculations turn out to be essentially as stable, fast and accurate as the synchronous ones for LambdaCDM. Instabilities may occur when ncdm (= non-cold dark matter, e.g. massive neutrinos) and/or isocurvature modes are turned on: in those two cases, the code outputs roughly the right answer (provided that the tol_ncdm precision parameter is decreased by a factor 100), but the convergence of the spectra in the limit of increased precision parameters is not obvious.
  • by default, the component called fluid can have not only an arbitrary sound speed, but also a time-varying equation of state of the form w=w0+wa*(1-a/a0); a couple of bugs in this fluid sector have been fixed.
  • CPU (Class Plotting Utility) upgraded to version 1.3, with an extra option -colnum N useful for plotting polarisation and lensing potential spectra. More details on CPU in the README file.
  • issue of initial conditions in the power spectrum renormalisation module trg.c fixed according to discussion in Audren & Lesgourgues 2011.
v1.2 (13.06.2011)
  • new trg.c module allowing to compute the non-linear density, velocity and cross density-velocity power spectra on mildly non-linear scales, using either the dynamical 1-loop method (fast) or the Time Renormalization Group method (1 hour/number of CPU); see Audren & Lesgourgues 2011. In the input file, you just need to set non linear=one-loop or non linear=trg. So far, this module works only for LambdaCDM with no non-cold relics or dark energy.
  • fast mode for CMB lensed spectra calculation. Speeds up the code significantly. For very accurate calculations, you can still tune the precision parameter accurate_lensing and use the previous method. Credits: Simon Prunet.
  • in input file, user can choose the format of output files: format=class for CLASS format (as in previous versions), format=camb for camb-like format (compatible with Healpix, etc.). Also, all output file headers can be omitted with headers=no.
  • convenient python module named CPU for plotting CLASS output spectra. Can plot one or several spectra, or the relative difference between two spectra (even when they are sampled with different values, as it is usually the case for P(k)'s). Works for C_l^TT and P(k). Detects the type of output file and infers axes and labels. See the various options by typing python CPU --help or python CPU -h. Typical usage: python CPU output/myspectrum.dat for a single spectrum. For using CPU you need to have on your machine a recent version of python and scientific python (scipy), as well as gnuplot.
  • new precision file chi2pl10.pre for even faster (but less accurate) CMB calculation than with default settings.
  • bug in dark energy fluid equations fixed on 16.06.11, thanks to Vid Irsic for pointing it out.
v1.1 (16.05.2011)
  • slightly modified definition of three trigger parameters controlling UFA and RSA approximations (refer to tau instead of tau_h). Changed precision files accordingly.
  • corrected bug previously leading to segmentation fault when computing lensed temperature but not polarisation
v1.0 (16.04.2011)
  • first public version


Support

Please report bugs, ask questions and send comments/suggestions through the GitHub website class_public. Go to that page, click issue and then New issue. Then write your text and press Submit new issue. Your text will automatically be sent by e-mail to the class developpers, and they will answer you as soon as possible.
If your question is related to the MontePython code, you should do the same but on the montepython_public page.
Webmaster Julien Lesgourgues; thanks to Diego Blas for logo and aesthetic supervision; thanks to Wessel Valkenburg and Manuel Malo De Molina Martinez for interactive script.
Last update on the 10.03.2015