├── README.md ├── class ├── CPU ├── CPU.py ├── Makefile ├── REFCLASS.pre ├── REFCLASS_tClpCl.pre ├── RealSpaceInterface │ ├── Calc2D │ │ ├── CalculationClass.py │ │ ├── DataGeneration.py │ │ ├── DataPropagation.py │ │ ├── Database.py │ │ ├── TransferFunction.py │ │ ├── __init__.py │ │ └── rFourier.py │ ├── README │ ├── __pycache__ │ │ └── config.cpython-36.pyc │ ├── cache │ │ └── .keep │ ├── colormap_converter.py │ ├── config.py │ ├── requirements.txt │ ├── static │ │ ├── css │ │ │ ├── custom.css │ │ │ └── timeline.css │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── fonts │ │ │ └── open-iconic │ │ │ │ ├── .gitignore │ │ │ │ ├── FONT-LICENSE │ │ │ │ ├── ICON-LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── bower.json │ │ │ │ ├── font │ │ │ │ ├── css │ │ │ │ │ ├── open-iconic-bootstrap.css │ │ │ │ │ ├── open-iconic-bootstrap.less │ │ │ │ │ ├── open-iconic-bootstrap.min.css │ │ │ │ │ ├── open-iconic-bootstrap.scss │ │ │ │ │ ├── open-iconic-bootstrap.styl │ │ │ │ │ ├── open-iconic-foundation.css │ │ │ │ │ ├── open-iconic-foundation.less │ │ │ │ │ ├── open-iconic-foundation.min.css │ │ │ │ │ ├── open-iconic-foundation.scss │ │ │ │ │ ├── open-iconic-foundation.styl │ │ │ │ │ ├── open-iconic.css │ │ │ │ │ ├── open-iconic.less │ │ │ │ │ ├── open-iconic.min.css │ │ │ │ │ ├── open-iconic.scss │ │ │ │ │ └── open-iconic.styl │ │ │ │ └── fonts │ │ │ │ │ ├── open-iconic.eot │ │ │ │ │ ├── open-iconic.otf │ │ │ │ │ ├── open-iconic.svg │ │ │ │ │ ├── open-iconic.ttf │ │ │ │ │ └── open-iconic.woff │ │ │ │ └── package.json │ │ ├── images │ │ │ ├── cmap.png │ │ │ └── colormaps │ │ │ │ ├── Default │ │ │ │ └── default.png │ │ │ │ ├── Diverging │ │ │ │ ├── RdYlBu.png │ │ │ │ ├── Spectral.png │ │ │ │ └── seismic.png │ │ │ │ ├── Miscellaneous │ │ │ │ └── jet.png │ │ │ │ └── Uniform │ │ │ │ ├── inferno.png │ │ │ │ ├── magma.png │ │ │ │ ├── plasma.png │ │ │ │ └── viridis.png │ │ ├── js │ │ │ ├── .Rhistory │ │ │ ├── RSI.js │ │ │ ├── gif.js │ │ │ ├── gif.worker.js │ │ │ ├── gridLayout.js │ │ │ ├── jquery.flot.axislabels.js │ │ │ ├── paramGui.js │ │ │ ├── parameterConfig.js │ │ │ ├── playerPanel.js │ │ │ ├── redshiftModal.js │ │ │ ├── simulation.js │ │ │ ├── simulationList.js │ │ │ └── sockjs.min.js │ │ └── threejs │ │ │ ├── Detector.js │ │ │ ├── controls │ │ │ └── OrbitControls.js │ │ │ └── libs │ │ │ └── stats.min.js │ ├── templates │ │ ├── AlreadySimulatedModal.html │ │ ├── ExceptionModal.html │ │ ├── GifExportModal.html │ │ ├── Header.html │ │ ├── ImageExportModal.html │ │ ├── ProgressModal.html │ │ ├── RSI.html │ │ ├── RedshiftModal.html │ │ ├── SimulationList.html │ │ └── index.html │ └── tornadoserver.py ├── base_2015_plikHM_TT_lowTEB_lensing.ini ├── base_2018_plikHM_TTTEEE_lowl_lowE_lensing.ini ├── bbn │ ├── sBBN.dat │ ├── sBBN_2017.dat │ └── sBBN_2017_marcucci.dat ├── cl_permille.pre ├── cl_ref.pre ├── cpp │ ├── ClassEngine.cc │ ├── ClassEngine.hh │ ├── Engine.cc │ ├── Engine.hh │ ├── README │ └── testKlass.cc ├── doc │ ├── README │ ├── input │ │ ├── chap2.md │ │ ├── chap3.md │ │ ├── doxyconf │ │ ├── doxygen.sty │ │ ├── intro.md │ │ ├── latex │ │ │ ├── class.aux │ │ │ ├── class.log │ │ │ ├── class.pdf │ │ │ ├── class.synctex.gz │ │ │ └── class.tex │ │ ├── make1.sh │ │ ├── make2.sh │ │ └── mod.md │ └── manual │ │ └── CLASS_MANUAL.pdf ├── explanatory-EDE.ini ├── explanatory.ini ├── external_Pk │ ├── Pk_example.dat │ ├── Pk_example_w_tensors.dat │ ├── README.md │ ├── generate_Pk_example.py │ └── generate_Pk_example_w_tensors.py ├── figures-for-paper │ ├── cmb │ │ ├── DellEEandTE.pdf │ │ ├── DellTT.pdf │ │ └── Dellpp.pdf │ ├── mPk │ │ ├── PkDES.pdf │ │ ├── PkDiffOnePlot-ratio.pdf │ │ ├── PkDiff_fEDE.pdf │ │ ├── PkDiff_zc.pdf │ │ ├── Pkh.pdf │ │ ├── growth.pdf │ │ └── s8s.pdf │ ├── priors │ │ ├── data │ │ │ ├── fEDE-shooting-Us.npy │ │ │ ├── fEDE-shooting_Smith.npy │ │ │ ├── fEDE_no_shooting.npy │ │ │ ├── log10f_scf-shooting-Smith.npy │ │ │ ├── log10f_scf-shooting-Us.npy │ │ │ ├── log10m_scf-shooting-Smith.npy │ │ │ ├── log10m_scf-shooting-Us.npy │ │ │ ├── log10z_c-shooting-Smith.npy │ │ │ ├── log10z_c-shooting-Us.npy │ │ │ ├── log10z_c_no_shooting.npy │ │ │ ├── thetai_scf-shooting-Smith.npy │ │ │ ├── thetai_scf-shooting-Us.npy │ │ │ └── thetai_scf_no_shooting.npy │ │ ├── priors-f-m-shooting-Smith.pdf │ │ ├── priors-f-m-shooting-Smith.png │ │ ├── priors-f-m-shooting-Us.pdf │ │ ├── priors-f-m-shooting-Us.png │ │ ├── priors-fEDE-z_c-no-shooting.pdf │ │ └── priors-fEDE-z_c-no-shooting.png │ └── scf │ │ ├── fEDE-example.pdf │ │ └── fEDE_v_z.png ├── hyrec │ ├── Alpha_inf.dat │ ├── Makefile │ ├── R_inf.dat │ ├── helium.c │ ├── helium.h │ ├── history.c │ ├── history.h │ ├── hydrogen.c │ ├── hydrogen.h │ ├── hyrec.c │ ├── hyrec.h │ ├── hyrectools.c │ ├── hyrectools.h │ ├── input.dat │ └── two_photon_tables.dat ├── include │ ├── arrays.h │ ├── background.h │ ├── class.h │ ├── common.h │ ├── dei_rkck.h │ ├── evolver_ndf15.h │ ├── evolver_rkck.h │ ├── growTable.h │ ├── hermite3_interpolation_csource.h │ ├── hermite4_interpolation_csource.h │ ├── hermite6_interpolation_csource.h │ ├── hyperspherical.h │ ├── input.h │ ├── lensing.h │ ├── nonlinear.h │ ├── output.h │ ├── parser.h │ ├── perturbations.h │ ├── precision_macros.h │ ├── precisions.h │ ├── primordial.h │ ├── quadrature.h │ ├── sparse.h │ ├── spectra.h │ ├── svnversion.h │ ├── thermodynamics.h │ ├── transfer.h │ └── trigonometric_integrals.h ├── main │ └── class.c ├── myevolution.dat ├── myselection.dat ├── notebooks-ede │ ├── 1-Introduction.ipynb │ ├── 2-CMB-Comparison.ipynb │ ├── 3-Effective-Priors.ipynb │ ├── 4-Matter-Power-Spectrum.ipynb │ └── 5-DES-EDE_mPk.ipynb ├── output │ └── README ├── pk_ref.pre ├── psd_FD_single.dat ├── python │ ├── .DS_Store │ ├── README │ ├── cclassy.pxd │ ├── classy.pyx │ ├── extract_errors.py │ ├── interface_generator.py │ ├── setup.py │ └── test_class.py ├── scripts │ ├── cl_ST.py │ ├── cltt_terms.py │ ├── distances.py │ ├── many_times.py │ ├── neutrinohierarchy.py │ ├── one_k.py │ ├── one_time.py │ ├── thermo.py │ ├── varying_neff.py │ ├── varying_pann.py │ └── warmup.py ├── source │ ├── background.c │ ├── input.c │ ├── lensing.c │ ├── nonlinear.c │ ├── output.c │ ├── perturbations.c │ ├── primordial.c │ ├── spectra.c │ ├── thermodynamics.c │ └── transfer.c ├── test │ ├── chi2.c │ ├── custom_lensing.c │ ├── test_2D_quadrature.c │ ├── test_background.c │ ├── test_bessel.c │ ├── test_degeneracy.c │ ├── test_hyperspherical.c │ ├── test_loops.c │ ├── test_loops_omp.c │ ├── test_nonlinear.c │ ├── test_optimize.c │ ├── test_optimize_1D.c │ ├── test_pbc.c │ ├── test_perturbations.c │ ├── test_spectra.c │ ├── test_thermodynamics.c │ ├── test_timing.c │ ├── test_transfer.c │ └── test_trg.c └── tools │ ├── arrays.c │ ├── common.c │ ├── dei_rkck.c │ ├── evolver_ndf15.c │ ├── evolver_rkck.c │ ├── growTable.c │ ├── hermite3_interpolation_csource.h │ ├── hermite4_interpolation_csource.h │ ├── hermite6_interpolation_csource.h │ ├── hyperspherical.c │ ├── parser.c │ ├── quadrature.c │ ├── sparse.c │ └── trigonometric_integrals.c └── cobaya └── classy.py /README.md: -------------------------------------------------------------------------------- 1 | [![](https://img.shields.io/badge/arXiv-2003.07355%20-red.svg)](https://arxiv.org/abs/2003.07355) 2 | 3 | ### This version of class_ede is now outdated. The lastest version is available [here](https://github.com/mwt5345/class_ede). 4 | 5 | # CLASS_EDE: CLASS for Early Dark Energy 6 | 7 | A modified version of the publicly available Einstein-Boltzmann code [CLASS](https://github.com/lesgourg/class_public) to implement Early Dark Energy (EDE). CLASS_EDE solves for the evolution of the scalar field perturbations directly using the perturbed Klein-Gordon equation and implements adiabatic initial conditions for the scalar field fluctuations. The code allows one to specify the EDE model parameters in terms of the particle physics parameters *f* and *m* or effective EDE parameters *f_EDE* and *z_c*. 8 | 9 | See [Hill et al.](https://arxiv.org/abs/2003.07355) where CLASS_EDE is implemented to test the validity of the EDE model. 10 | 11 | ![](https://github.com/mwt5345/class_ede/blob/master/class/figures-for-paper/scf/fEDE_v_z.png) 12 | 13 | ## CLASS edited by 14 | - J. Colin Hill; jch2200 at columbia.edu 15 | - Evan McDonough; evan_mcdonough at brown.edu 16 | - Michael W. Toomey; michael_toomey at brown.edu 17 | 18 | ## Files 19 | 20 | All CLASS files in the directory class, the relevant file for the sampler Cobaya is in the directory cobaya. 21 | 22 | ## Installation 23 | 24 | After cloning or downloading the repository, compile CLASS_EDE with make in the [class](https://github.com/mwt5345/class_ede/tree/master/class) directory. 25 | 26 | $ make class 27 | 28 | To utilize Cobaya with CLASS_EDE replace stock classy.py with the modified version [here](https://github.com/mwt5345/class_ede/tree/master/cobaya). 29 | 30 | ## Examples 31 | 32 | ### Python 33 | Jupyter notebooks with worked out examples in Python can be found [here](https://github.com/mwt5345/class_ede/tree/master/class/notebooks-ede). 34 | 35 | ### C 36 | 37 | CLASS_EDE can be run in C just as normal CLASS. See explanatory-EDE.ini for EDE implementation details. 38 | 39 | $ ./class explanatory-EDE.ini 40 | 41 | ## Modifications to CLASS 42 | 43 | Modifications are explained below. All edits are flagged in the code by "EDE-edit". 44 | 45 | (1) Scalar field parameters: 46 | 47 | The syntax for entering scalar field parameters has been changed to the following: the user must input one of {m_scf,log10m_scf,log10z_c} and one of {f_scf,log10f_scf,fEDE}, as well the power law n_scf, the initial field displacement thetai (=\phi_i /f), and an additive constant CC_scf. The units of f_scf and m_scf are eV. Note that fEDE may only be input if log10z_c is also input. 48 | 49 | (2) Background dynamics: 50 | 51 | The scalar field is implemented in background.c in a seemingly trivial way, with the key detail that V(\phi) includes an additive constant. This is used as the "tuning parameter" in all CLASS runs, and the explicit Omega_Lambda is set to 0. 52 | 53 | (3) To run as LCDM: 54 | 55 | Works the same as normal CLASS. Note the CC is now handled by Omega_Lambda! 56 | 57 | (4) Perturbations: 58 | 59 | Adiabatic initial conditions for the scalar field are implemented in perturbations.c . 60 | 61 | (5) fEDE and z_c: 62 | 63 | We have implemented the calculation of f_EDE and z_c into the background module and python wrapper. We have also implemented a the built-in shooting algorithm for fEDE and log10z_c, in input.c, allowing the user to specify {fEDE,log10z_c,thetai} and CLASS will find the corresponding {f_scf,m_scf,thetai}. 64 | 65 | (6) Exit codes: 66 | 67 | Large values of f_{EDE} (>.9) will crash CLASS (often the thermodynamics module). Such large values are not physical. To avoid crashing an MCMC run, an error code has been added to background.c, "fEDE = %e instead of < 0.5" 68 | 69 | (7) fsigma8: 70 | 71 | Defined a function fsigma8 = f(z)*sigma8(z) for use with RSD likelihoods. 72 | 73 | (8) P_k_max_h/Mpc too small: 74 | 75 | CLASS run in c, i.e. with the command ./class xxxx.ini , throws a warning if you try to compute the non-linear P(k) at high-z, requiring too high k values (as set by P_k_max). The python wrapper flags this warning as a CosmoSevereError and will kill the evaluation. This will crash an MCMC sampler like Cobaya; the DES likelihood sets P_k_max=15 (overwriting the user-input value), which is too low for some corners of parameter space in certain models. This problem has been resolved by CosmoSevereError-->CosmoComputationError in classy.pyx, and with an exception added to Cobaya's classy.py . 76 | 77 | 78 | ## Modifications to Cobaya 79 | 80 | One should replace stock classy.py from [Cobaya](https://github.com/CobayaSampler/cobaya) with the modified version [here](https://github.com/mwt5345/class_ede/tree/master/cobaya). 81 | 82 | (1) Error handling: 83 | 84 | Cobaya can bypass a CLASS "CosmoComputationError" by assigning it zero likelihood and then continuing to sample. This has been implemented for extremely large values of fEDE, and for cosmologies where P_k_max_h/Mpc=15 [or the value set in _DES_prototype.py] is not sufficient to compute P(k). 85 | 86 | (2) For RSD: 87 | 88 | Get fsigma8(z) from CLASS 89 | -------------------------------------------------------------------------------- /class/REFCLASS.pre: -------------------------------------------------------------------------------- 1 | # this precision file obtained as follows: 2 | # - computing adiabatic scalar unlensed ClT only (ndf15 integrator with AMD) 3 | # - for each precision parameter varied individually, Deltachi2(Planck) between high-precision limit and selected value = 1.e-3 4 | 5 | a_ini_over_a_today_default = 1.e-14 6 | back_integration_stepsize = 7.e-3 7 | tol_background_integration = 1.e-2 8 | 9 | recfast_z_initial=1.e4 10 | 11 | recfast_Nz0=100000 12 | tol_thermo_integration=1.e-5 13 | 14 | recfast_Heswitch=6 15 | recfast_fudge_He=0.86 16 | 17 | recfast_Hswitch = 1 #_TRUE_ 18 | recfast_fudge_H = 1.14 19 | recfast_delta_fudge_H = -0.035 20 | recfast_AGauss1 = -0.14 21 | recfast_AGauss2 = 0.05 22 | recfast_zGauss1 = 7.28 23 | recfast_zGauss2 = 6.75 24 | recfast_wGauss1 = 0.18 25 | recfast_wGauss2 = 0.33 26 | 27 | recfast_z_He_1 = 8000. 28 | recfast_delta_z_He_1 = 50. 29 | recfast_z_He_2 = 5000. 30 | recfast_delta_z_He_2 = 100. 31 | recfast_z_He_3 = 3500. 32 | recfast_delta_z_He_3 = 50. 33 | recfast_x_He0_trigger = 0.995 34 | recfast_x_He0_trigger2 = 0.995 35 | recfast_x_He0_trigger_delta = 0.01 36 | recfast_x_H0_trigger = 0.995 37 | recfast_x_H0_trigger2 = 0.995 38 | recfast_x_H0_trigger_delta = 0.01 39 | 40 | recfast_H_frac=1.e-3 41 | 42 | reionization_z_start_max = 50. 43 | reionization_sampling=1.e-2 44 | reionization_optical_depth_tol=1.e-2 45 | reionization_exponent=1.5 46 | 47 | reionization_width=0.5 48 | 49 | reionization_start_factor=8. 50 | helium_fullreio_redshift=3.5 51 | helium_fullreio_width=0.5 52 | 53 | thermo_rate_smoothing_radius=50 54 | 55 | gauge=1 #synchronous 56 | 57 | k_scalar_min_eta0=0.002 58 | k_scalar_max_eta0_over_l_max=3. 59 | k_scalar_step_sub=0.015 60 | k_scalar_step_super=0.0001 # was 0.0005 61 | k_scalar_step_transition=0.2 # was 0.2 62 | 63 | #start_small_k_at_eta_g_over_eta_h = 0.006 64 | #start_large_k_at_eta_g_over_eta_k = 1.e-5 65 | #tight_coupling_trigger_eta_g_over_eta_h=0.008 66 | #tight_coupling_trigger_eta_g_over_eta_k=0.05 67 | #start_sources_at_eta_g_over_eta_h = 0.01 68 | start_small_k_at_eta_g_over_eta_h = 0.0004 69 | start_large_k_at_eta_h_over_eta_k = 0.15 70 | tight_coupling_trigger_eta_g_over_eta_h=0.005 71 | tight_coupling_trigger_eta_g_over_eta_k=0.008 72 | start_sources_at_eta_g_over_eta_h = 0.006 73 | tight_coupling_approximation=5 #(int)second_order_CRS; 74 | 75 | l_max_g=25 76 | l_max_pol_g=25 77 | l_max_nur=35 78 | l_max_ncdm1=28 79 | 80 | tol_eta_approx=1.e-5 81 | tol_perturb_integration=1.e-6 82 | perturb_sampling_stepsize=0.01 83 | 84 | free_streaming_approximation = 2 85 | free_streaming_trigger_eta_h_over_eta_k = 120. 86 | free_streaming_trigger_Omega_r = 0.07 87 | 88 | l_logstep=1.026 89 | l_linstep=25 90 | 91 | bessel_x_step=0.005 92 | bessel_j_cut=5.e-10 # WATCH IT! 93 | bessel_delta_x_min =1.e-4 94 | bessel_file_name=bessel_large.dat 95 | 96 | k_per_decade_primordial = 10. 97 | 98 | k_step_trans_scalars=0.002 99 | 100 | transfer_cut=1 #0=none,1=osc,2=cl #segfault with zero, watch it! 101 | transfer_cut_threshold_osc=0.005 # with 0.005, more smooth than when smaller for l>2000 WATCH IT 102 | transfer_cut_threshold_cl=1.e-8 # not robust if tilted or if one Delta_l(k) oscillation tangents zero 103 | 104 | evolver=0 105 | 106 | l_switch_limber = 40. 107 | num_mu_minus_lmax = 1000. 108 | delta_l_max = 1000. -------------------------------------------------------------------------------- /class/REFCLASS_tClpCl.pre: -------------------------------------------------------------------------------- 1 | # this precision file obtained as follows: 2 | # - computing adiabatic scalar unlensed ClT only (ndf15 integrator with AMD) 3 | # - for each precision parameter varied individually, Deltachi2(Planck) between high-precision limit and selected value = 1.e-3 4 | 5 | a_ini_over_a_today_default = 1.e-14 6 | back_integration_stepsize = 7.e-3 7 | tol_background_integration = 1.e-2 8 | 9 | recfast_z_initial=1.e4 10 | 11 | recfast_Nz0=100000 12 | tol_thermo_integration=1.e-5 13 | 14 | recfast_Heswitch=6 15 | recfast_fudge_He=0.86 16 | 17 | recfast_Hswitch = 1 #_TRUE_ 18 | recfast_fudge_H = 1.14 19 | recfast_delta_fudge_H = -0.035 20 | recfast_AGauss1 = -0.14 21 | recfast_AGauss2 = 0.05 22 | recfast_zGauss1 = 7.28 23 | recfast_zGauss2 = 6.75 24 | recfast_wGauss1 = 0.18 25 | recfast_wGauss2 = 0.33 26 | 27 | recfast_z_He_1 = 8000. 28 | recfast_delta_z_He_1 = 50. 29 | recfast_z_He_2 = 5000. 30 | recfast_delta_z_He_2 = 100. 31 | recfast_z_He_3 = 3500. 32 | recfast_delta_z_He_3 = 50. 33 | recfast_x_He0_trigger = 0.995 34 | recfast_x_He0_trigger2 = 0.995 35 | recfast_x_He0_trigger_delta = 0.01 36 | recfast_x_H0_trigger = 0.995 37 | recfast_x_H0_trigger2 = 0.995 38 | recfast_x_H0_trigger_delta = 0.01 39 | 40 | recfast_H_frac=1.e-3 41 | 42 | reionization_z_start_max = 50. 43 | reionization_sampling=1.e-2 44 | reionization_optical_depth_tol=1.e-2 45 | reionization_exponent=1.5 46 | 47 | reionization_width=0.5 48 | 49 | reionization_start_factor=8. 50 | helium_fullreio_redshift=3.5 51 | helium_fullreio_width=0.5 52 | 53 | thermo_rate_smoothing_radius=50 54 | 55 | gauge=1 #synchronous 56 | 57 | k_scalar_min_eta0=0.003 58 | k_scalar_max_eta0_over_l_max=3. 59 | k_scalar_step_sub=0.01 60 | k_scalar_step_super=0.0005 61 | k_scalar_step_transition=0.2 62 | 63 | #start_small_k_at_eta_g_over_eta_h = 0.006 64 | #start_large_k_at_eta_g_over_eta_k = 1.e-5 65 | #tight_coupling_trigger_eta_g_over_eta_h=0.008 66 | #tight_coupling_trigger_eta_g_over_eta_k=0.05 67 | #start_sources_at_eta_g_over_eta_h = 0.01 68 | start_small_k_at_eta_g_over_eta_h = 0.0004 69 | start_large_k_at_eta_h_over_eta_k = 0.15 70 | tight_coupling_trigger_eta_g_over_eta_h=0.005 71 | tight_coupling_trigger_eta_g_over_eta_k=0.008 72 | start_sources_at_eta_g_over_eta_h = 0.006 73 | tight_coupling_approximation=5 #(int)second_order_CRS; 74 | 75 | l_max_g=25 76 | l_max_pol_g=25 77 | l_max_nur=35 78 | l_max_ncdm1=28 79 | 80 | tol_eta_approx=1.e-5 81 | tol_perturb_integration=1.e-6 82 | perturb_sampling_stepsize=0.01 83 | 84 | free_streaming_approximation = 2 85 | free_streaming_trigger_eta_h_over_eta_k = 120. 86 | free_streaming_trigger_Omega_r = 0.07 87 | 88 | l_logstep=1.026 89 | l_linstep=25 90 | 91 | bessel_x_step=0.01 92 | bessel_j_cut=5.e-10 # WATCH IT! 93 | bessel_delta_x_min =1.e-4 94 | bessel_file_name=bessel_large.dat 95 | 96 | k_per_decade_primordial = 10. 97 | 98 | k_step_trans_scalars=0.04 # 0.04 to smooth oscillations at l<200, but 0.2 reasonnable; smaller -> job killed on superb 99 | 100 | transfer_cut=2 #0=none,1=osc,2=cl #segfault with zero, watch it! 101 | transfer_cut_threshold_osc=0.005 # with 0.005, more smooth than when smaller for l>2000 WATCH IT 102 | transfer_cut_threshold_cl=1.e-8 103 | 104 | evolver=0 105 | 106 | l_switch_limber = 10. 107 | num_mu_minus_lmax = 1000. 108 | delta_l_max = 2000. -------------------------------------------------------------------------------- /class/RealSpaceInterface/Calc2D/DataGeneration.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | import numpy as np 4 | import cv2 5 | 6 | from Calc2D.rFourier import realFourier, realInverseFourier 7 | 8 | def GenerateGaussianData(sigma, size, points, A=1): 9 | xr = np.linspace(-size / 2.0, size / 2.0, points) 10 | yr = np.linspace(-size / 2.0, size / 2.0, points) 11 | step = xr[1] - xr[0] 12 | x, y = np.meshgrid( 13 | xr, yr, indexing='ij', sparse=True) # indexing is important 14 | del xr, yr 15 | 16 | #use the more easy formula 17 | Value = A * np.exp(-(x**2 + y**2) / (2 * sigma**2)) 18 | 19 | kx, ky, FValue = realFourier(step, Value) 20 | kxr, kyr = np.meshgrid(kx, ky, indexing='ij', sparse=True) 21 | 22 | k = np.sqrt(kxr**2 + kyr**2) 23 | del kxr, kyr 24 | 25 | kx = (min(kx), max(kx)) #just return the extremal values to save memory 26 | ky = (min(ky), max(ky)) 27 | 28 | ValueE = (Value.min(), Value.max()) 29 | 30 | return ValueE, FValue, k, kx, ky 31 | 32 | def GenerateSIData(A, size, points, limit=None, ns=0.96): 33 | xr = np.linspace(-size / 2.0, size / 2.0, points) 34 | yr = np.linspace(-size / 2.0, size / 2.0, points) 35 | step = xr[1] - xr[0] 36 | 37 | x, y = np.meshgrid( 38 | xr, yr, indexing='ij', sparse=True) # indexing is important 39 | del xr, yr 40 | Value = 0 * x + 0 * y 41 | 42 | kx, ky, FValue = realFourier(step, Value) #FValue==0 43 | 44 | kxr, kyr = np.meshgrid(kx, ky, indexing='ij', sparse=True) 45 | 46 | k = np.sqrt(kxr**2 + kyr**2) 47 | del kxr, kyr 48 | 49 | if limit == None: 50 | 51 | ktilde = k.flatten() 52 | ktilde[np.argmin(k)] = 10**9 #just let the background be arbitrary low 53 | ktilde = ktilde.reshape(k.shape) 54 | 55 | FValue = np.random.normal( 56 | loc=0, 57 | scale=np.sqrt(A / ktilde**( 58 | 2 - (ns - 1) * 2. / 3.)) / np.sqrt(2)) + np.random.normal( 59 | loc=0, 60 | scale=np.sqrt(A / ktilde** 61 | (2 - (ns - 1) * 2. / 3.)) / np.sqrt(2)) * 1j 62 | 63 | elif type(limit) == list or type(limit) == tuple: 64 | 65 | iunder, junder = np.where(k < limit[1]) 66 | 67 | for t in range(len(iunder)): 68 | 69 | if k[iunder[t]][junder[t]] > limit[0] and k[iunder[t]][junder[t]] > 0: 70 | 71 | FValue[iunder[t]][junder[t]] = np.random.normal( 72 | loc=0, 73 | scale=np.sqrt(A / k[iunder[t]][junder[t]]** 74 | (2 - (ns - 1) * 2. / 3.)) / 75 | np.sqrt(2)) + np.random.normal( 76 | loc=0, 77 | scale=np.sqrt(A / k[iunder[t]][junder[t]]** 78 | (2 - 79 | (ns - 1) * 2. / 3.)) / np.sqrt(2)) * 1j 80 | 81 | else: 82 | raise ValueError("limit must be None or tuple or list") 83 | 84 | Value = realInverseFourier(FValue) 85 | 86 | kx = (min(kx), max(kx)) 87 | ky = (min(ky), max(ky)) 88 | 89 | ValueE = (Value.min(), Value.max()) 90 | 91 | return ValueE, FValue, k, kx, ky 92 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/Calc2D/DataPropagation.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | #uses one dimensional interpolation 3 | def PropagateDatawithListOld(k,FValue,zredindex,transferFunctionlist): 4 | return (transferFunctionlist[zredindex](k.ravel()) * FValue.ravel()).reshape(FValue.shape) 5 | 6 | def PropagateDatawithList(k, FValue, zredindex, transferFunctionlist): 7 | result = {} 8 | for field, transfer_function in transferFunctionlist.items(): 9 | result[field] = (transfer_function[zredindex](k.ravel()) * FValue.ravel()).reshape(FValue.shape) 10 | return result 11 | 12 | #module with uses two dimensional interpolation and propagates all data at once (fastest but high memory consumption) 13 | def PropagateAllData(k,FValue,allzred,transferFunction): 14 | 15 | allFValue = np.ones((len(allzred),FValue.shape[0],FValue.shape[1]),dtype=complex) 16 | 17 | for kxindex in range(FValue.shape[0]): 18 | allFValue[:,kxindex,:] = transferFunction(allzred,k[kxindex])*FValue[kxindex] 19 | 20 | 21 | return allFValue 22 | 23 | 24 | #module with uses 2 dimensional interpolation (slowest but can be useful if the set of redshift changes very often) 25 | def PropagateData(k,FValue,zred,transferFunction): 26 | 27 | FValuenew = np.ones(FValue.shape,dtype=complex) 28 | 29 | for kxindex in range(FValue.shape[0]): 30 | allFValue[kxindex,:] = transferFunction(zred,k[kxindex])*FValue[kxindex] 31 | 32 | 33 | return allFValue 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/Calc2D/Database.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | import os 3 | import logging 4 | import uuid 5 | 6 | class Database: 7 | def __init__(self, directory, db_file="database.dat"): 8 | self.directory = directory 9 | self.db_file = db_file 10 | 11 | if not os.path.isdir(directory): 12 | raise ValueError("'{}' is not a directory!".format(directory)) 13 | 14 | self.db_path = os.path.join(directory, db_file) 15 | if not os.path.exists(self.db_path): 16 | logging.info("No database found; Creating one at {}.".format(self.db_path)) 17 | with open(self.db_path, "w") as f: 18 | pickle.dump(dict(), f) 19 | 20 | self.db = self.__read_database() 21 | 22 | def __read_database(self): 23 | with open(self.db_path) as f: 24 | return pickle.load(f) 25 | 26 | def __write_database(self): 27 | with open(self.db_path, "w") as f: 28 | pickle.dump(self.db, f) 29 | 30 | def __create_file(self, data): 31 | filename = str(uuid.uuid4()) 32 | with open(os.path.join(self.directory, filename), "w") as f: 33 | pickle.dump(data, f) 34 | return filename 35 | 36 | def __get_frozen_key(self, key): 37 | return frozenset(key.items()) 38 | 39 | def __getitem__(self, key): 40 | frozen_key = self.__get_frozen_key(key) 41 | if frozen_key in self.db: 42 | filename = self.db[frozen_key] 43 | with open(os.path.join(self.directory, filename)) as f: 44 | return pickle.load(f) 45 | else: 46 | raise KeyError("No data for key: {}".format(key)) 47 | 48 | def __setitem__(self, key, data): 49 | frozen_key = self.__get_frozen_key(key) 50 | self.db[frozen_key] = self.__create_file(data) 51 | self.__write_database() 52 | 53 | def __contains__(self, key): 54 | """ 55 | Return whether `self` contains a record 56 | for the given `key`. 57 | """ 58 | return self.__get_frozen_key(key) in self.db -------------------------------------------------------------------------------- /class/RealSpaceInterface/Calc2D/TransferFunction.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | import pickle 3 | import uuid 4 | import numpy as np 5 | from scipy.interpolate import InterpolatedUnivariateSpline, RectBivariateSpline 6 | import sys 7 | import logging 8 | 9 | from classy import Class 10 | 11 | import Calc2D.Database as Database 12 | import config 13 | 14 | TRANSFER_QUANTITIES = ["d_g", "d_ur", "d_cdm", "d_b", "d_g/4 + psi"] 15 | 16 | def ComputeTransferData(settings, redshift): 17 | database_key = settings.copy() 18 | database_key.update({'redshift': tuple(redshift)}) 19 | 20 | database = Database.Database(config.DATABASE_DIR) 21 | if database_key in database: 22 | return database[database_key], redshift 23 | else: 24 | cosmo = Class() 25 | cosmo.set(settings) 26 | cosmo.compute() 27 | 28 | outputData = [cosmo.get_transfer(z) for z in redshift] 29 | # Calculate d_g/4+psi 30 | for transfer_function_dict in outputData: 31 | transfer_function_dict["d_g/4 + psi"] = transfer_function_dict["d_g"]/4 + transfer_function_dict["psi"] 32 | # Now filter the relevant fields 33 | fields = TRANSFER_QUANTITIES + ["k (h/Mpc)"] 34 | outputData = [{field: outputData[i][field] for field in fields} for i in range(len(redshift))] 35 | 36 | database[database_key] = outputData 37 | return outputData, redshift 38 | 39 | 40 | def ComputeTransferFunctionList(cosmologicalParameters, redshift, kperdecade=200, P_k_max=100): 41 | class_settings = cosmologicalParameters.copy() 42 | class_settings.update({ 43 | "output": "mTk", 44 | "gauge": "newtonian", 45 | "evolver": "1", 46 | "P_k_max_h/Mpc": P_k_max, 47 | "k_per_decade_for_pk": kperdecade, 48 | "z_max_pk": str(max(redshift)), 49 | }) 50 | 51 | data_dict, redshift = ComputeTransferData(class_settings, redshift) 52 | transfer_functions = {field: [] for field in TRANSFER_QUANTITIES} 53 | 54 | 55 | for i in range(len(redshift)): 56 | k_data = data_dict[0]["k (h/Mpc)"] * cosmologicalParameters["h"] #in order to get k [1/Mpc] 57 | k_data_zero = np.concatenate(([0.0], k_data)) 58 | for field in TRANSFER_QUANTITIES: 59 | data = data_dict[i][field] / data_dict[i][field][0] 60 | data_zero = np.concatenate(([1.0], data)) 61 | interpolated_func = InterpolatedUnivariateSpline(k_data_zero, data_zero) 62 | transfer_functions[field].append(interpolated_func) 63 | 64 | return transfer_functions 65 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/Calc2D/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/Calc2D/__init__.py -------------------------------------------------------------------------------- /class/RealSpaceInterface/Calc2D/rFourier.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import numpy.fft as fft 3 | 4 | def realFourier(step, Value): 5 | FValue = np.fft.fftshift( 6 | np.fft.rfft2(Value), axes=(0)) #shifting only the x axes 7 | 8 | kx = np.fft.fftshift(np.fft.fftfreq(Value.shape[0], d=step)) * 2 * np.pi 9 | ky = np.fft.rfftfreq(Value.shape[0], d=step) * 2 * np.pi 10 | 11 | return kx, ky, FValue 12 | 13 | def realInverseFourier(FValue): 14 | return np.fft.irfft2(np.fft.ifftshift( 15 | FValue, axes=(0))) #shifting only on the x axes 16 | 17 | 18 | def realInverseAllFourier(allFValue): 19 | return np.fft.irfftn( 20 | np.fft.ifftshift(allFValue, axes=(1)), 21 | axes=(1, 2)) #shifting only on the x axes 22 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/README: -------------------------------------------------------------------------------- 1 | For installation of python packages, run 2 | 3 | pip install -r requirements.txt 4 | 5 | Launch the application with 6 | 7 | python tornadoserver.py 8 | 9 | Then in any browser open the URL 10 | 11 | http://localhost:7777 12 | 13 | ------------------------------------------------------------ 14 | 15 | Cache files are located in cache/, so to clear the cache, run 16 | 17 | rm cache/* 18 | 19 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/__pycache__/config.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/__pycache__/config.cpython-36.pyc -------------------------------------------------------------------------------- /class/RealSpaceInterface/cache/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/cache/.keep -------------------------------------------------------------------------------- /class/RealSpaceInterface/colormap_converter.py: -------------------------------------------------------------------------------- 1 | import matplotlib.cm as cm 2 | import matplotlib.pyplot as plt 3 | import numpy as np 4 | from PIL import Image 5 | import os 6 | 7 | OUTPUT_DIR = os.path.join("static", "images", "colormaps") 8 | WIDTH = 512 9 | 10 | def create_image(cmap, width): 11 | values = np.linspace(0, 1, width) 12 | colors = cmap(values).reshape((1, width, 4)) 13 | image = Image.fromarray(np.uint8(255 * colors)) 14 | return image 15 | 16 | cmap_names = {} 17 | cmap_names['Uniform'] = [ 18 | 'viridis', 'plasma', 'inferno', 'magma'] 19 | cmap_names['Diverging'] = [ 20 | 'seismic', 'RdYlBu', 'Spectral' 21 | ] 22 | cmap_names['Miscellaneous'] = ['jet'] 23 | 24 | if __name__ == "__main__": 25 | for category in cmap_names: 26 | category_dir = os.path.join(OUTPUT_DIR, category) 27 | if not os.path.exists(category_dir): 28 | os.mkdir(category_dir) 29 | for name in cmap_names[category]: 30 | result = create_image(plt.get_cmap(name), width=WIDTH) 31 | output_path = os.path.join(category_dir, "{}.png".format(name)) 32 | print(output_path) 33 | result.save(output_path) 34 | 35 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/config.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | # Default port number to listen on. Can be overriden by passing a port number 4 | # as the first command line argument, e.g. `python tornadoserver.py 1234` 5 | PORT = 7777 6 | 7 | # Directory to store previously computed transfer functions, spectra etc. in 8 | DATABASE_DIR = "cache" 9 | 10 | # Maximum number of thread pool workers (only required for multi-user usage) 11 | MAX_THREADPOOL_WORKERS = 8 12 | 13 | # Path of colormap directory relative to the static directory from which 14 | # tornado serves static files 15 | COLORMAP_PATH = os.path.join("images", "colormaps") 16 | 17 | # number of sample points for the transfer function that is displayed 18 | # in the client 19 | TRANSFER_FUNCTION_CLIENT_SAMPLES = 400 20 | 21 | # number of sample points for the matter spectrum that is displayed 22 | # in the client per decade 23 | MATTER_SPECTRUM_CLIENT_SAMPLES_PER_DECADE = 40 24 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/requirements.txt: -------------------------------------------------------------------------------- 1 | futures>=3.0.2 2 | numpy>=1.8.2 3 | scipy>=0.14.0 4 | tornado>=4.0.2 5 | opencv-python 6 | # Building the Python bindings of CLASS requires Cython 7 | Cython 8 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/css/custom.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | overflow: hidden; 4 | } 5 | 6 | .activityIndicator-active, .activityIndicator-inactive { 7 | border-radius: 50%; 8 | width: 20px; 9 | height: 20px; 10 | display: inline-block; 11 | vertical-align: sub; 12 | } 13 | 14 | .activityIndicator-active { 15 | border: 3px solid #f3f3f3; 16 | border-top: 3px solid #3498db; 17 | animation: spin 2s linear infinite; 18 | } 19 | 20 | .activityIndicator-inactive { 21 | border: 3px solid #444; 22 | display: none; 23 | } 24 | 25 | @keyframes spin { 26 | 0% { transform: rotate(0deg); } 27 | 100% { transform: rotate(360deg); } 28 | } 29 | 30 | td.color-circle-container { 31 | vertical-align: middle; 32 | } 33 | 34 | .color-circle { 35 | width: 24px; 36 | height: 24px; 37 | border-radius: 50%; 38 | margin: auto; 39 | } 40 | 41 | .popover { 42 | max-width: 100%; 43 | } 44 | 45 | .modal { 46 | overflow-y: scroll; 47 | } 48 | 49 | /* PLOTS */ 50 | 51 | #plotWindowContainer { 52 | position: absolute; 53 | top: 50px; 54 | left: 0px; 55 | overflow: hidden; 56 | } 57 | 58 | #plotWindowWrapper { 59 | min-width: 550px; 60 | border-radius: 3px; 61 | } 62 | 63 | .plotWindowWrapperHidden { 64 | } 65 | 66 | .plotWindowWrapperVisible { 67 | padding-top: 10px; 68 | padding-bottom: 10px; 69 | padding-left: 10px; 70 | padding-right: 10px; 71 | } 72 | 73 | .plotWindowHidden, .plotWindowVisible { 74 | overflow-x: hidden; 75 | background-color: rgba(255, 255, 255, 0.8); 76 | } 77 | 78 | .plotWindowHidden { 79 | display: none; 80 | margin: 0px; 81 | } 82 | 83 | .plotWindowVisible { 84 | display: block; 85 | min-height: 200px; 86 | } 87 | 88 | .plotWindowVisible:not(:last-child) { 89 | margin-bottom: 10px; 90 | } 91 | 92 | #plotWindowToggle { 93 | width: 100%; 94 | } 95 | 96 | /* END PLOTS */ 97 | 98 | #aboutLink { 99 | position: absolute; 100 | padding: 5px; 101 | right: 0; 102 | bottom: 0; 103 | text-align: right; 104 | vertical-align: bottom; 105 | border-top-left-radius: 3px; 106 | } 107 | 108 | #statusBar { 109 | position: absolute; 110 | bottom: 0; 111 | left: 0; 112 | padding: 5px; 113 | border-top-right-radius: 3px; 114 | } 115 | 116 | #statusBar p { 117 | margin: 0; 118 | vertical-align: bottom; 119 | } 120 | 121 | .status-bar-item { 122 | display: inline-block; 123 | } 124 | 125 | /* */ 126 | #simulationTable td { 127 | text-align: center; 128 | vertical-align: middle; 129 | } 130 | 131 | #simulationTable th { 132 | text-align: center; 133 | border: none; 134 | } 135 | 136 | .visible-checkbox { 137 | vertical-align: middle; 138 | } 139 | 140 | /* .cmap-preview, .cmap-preview-button { */ 141 | /* } */ 142 | 143 | .cmap-preview { 144 | width: 64px; 145 | height: inherit; 146 | margin-left: 1em; 147 | } 148 | 149 | /* .cmap-preview-button { */ 150 | /* height: 1em; */ 151 | /* vertical-align: middle; */ 152 | /* } */ 153 | 154 | #colormap-selector-button-placeholder { 155 | width: 64px; 156 | display: inline-block; 157 | } 158 | 159 | .colormap-selector-item { 160 | display: flex; 161 | justify-content: space-between; 162 | } 163 | 164 | .scrollable-menu { 165 | height: auto; 166 | max-height: 200px; 167 | overflow-x: hidden; 168 | } 169 | 170 | 171 | /* FIX DAT.GUI */ 172 | .dg .c input[type=text] { 173 | line-height:normal; 174 | } 175 | 176 | .dg .c div { 177 | box-sizing: content-box; 178 | } 179 | 180 | /* END FIX */ 181 | 182 | 183 | #exceptionModalMessage { 184 | white-space: pre; 185 | } 186 | 187 | .modal-lg { 188 | max-width: 900px; 189 | } 190 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/css/timeline.css: -------------------------------------------------------------------------------- 1 | .player { 2 | width: 25%; 3 | border-radius: 2px; 4 | margin-top: 6px; 5 | } 6 | 7 | .timeline { 8 | height: 12px; 9 | /*background: linear-gradient(to right, red 0%, red 20%, green 20%);*/ 10 | border-radius: 8px; 11 | /* horizontal vertical blur spread color */ 12 | /* box-shadow: inset 2px 2px 20px -5px #333; */ 13 | cursor: pointer; 14 | } 15 | 16 | .scrubber { 17 | width: 18px; 18 | height: 18px; 19 | border-radius: 50%; 20 | float: left; 21 | cursor: pointer; 22 | background: linear-gradient(to bottom, hsl(134, 61%, 45%), hsl(134, 61%, 35%)); 23 | box-shadow: 0px 2px 10px 2px #333; 24 | } 25 | 26 | .scrubber:hover { 27 | background: linear-gradient(to bottom, hsl(134, 61%, 65%), hsl(134, 61%, 55%)); 28 | } 29 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/favicon-16x16.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/favicon-32x32.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "open-iconic", 3 | "description": "An open source icon set in SVG, webfont and raster formats", 4 | "version": "1.1.1", 5 | "license": [ 6 | "MIT", 7 | "OFL-1.1" 8 | ], 9 | "homepage": "https://useiconic.com/open", 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/iconic/open-iconic.git" 13 | }, 14 | "main": [ 15 | "./sprite/open-iconic.min.svg" 16 | ], 17 | "ignore": [ 18 | "*.json", 19 | "*.md" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/fonts/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/fonts/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/fonts/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/fonts/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/fonts/open-iconic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "open-iconic", 3 | "description": "An open source icon set with marks in SVG, sprite, webfont and raster format", 4 | "version": "1.1.1", 5 | "keywords": ["icon", "iconic", "open-iconic", "svg", "sprite", "font", "png", "webp"], 6 | "homepage": "http://useiconic.com/open-iconic/", 7 | "author": { 8 | "name": "Iconic", 9 | "email": "yourfriends@useiconic.com", 10 | "web": "http://useiconic.com/" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/iconic/open-iconic.git" 15 | }, 16 | "contributors": [ 17 | { 18 | "name": "P.J. Onori", 19 | "web": "http://twitter.com/somerandomdude" 20 | }, 21 | { 22 | "name": "Dave Johnson", 23 | "web": "http://twitter.com/protodave" 24 | } 25 | ], 26 | "licenses": [ 27 | { 28 | "type": "MIT License", 29 | "url": "http://opensource.org/licenses/mit-license.html" 30 | }, 31 | { 32 | "type": "SIL OFL 1.1", 33 | "url": "http://scripts.sil.org/OFL" 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/cmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/cmap.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/colormaps/Default/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/colormaps/Default/default.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/colormaps/Diverging/RdYlBu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/colormaps/Diverging/RdYlBu.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/colormaps/Diverging/Spectral.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/colormaps/Diverging/Spectral.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/colormaps/Diverging/seismic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/colormaps/Diverging/seismic.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/colormaps/Miscellaneous/jet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/colormaps/Miscellaneous/jet.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/colormaps/Uniform/inferno.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/colormaps/Uniform/inferno.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/colormaps/Uniform/magma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/colormaps/Uniform/magma.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/colormaps/Uniform/plasma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/colormaps/Uniform/plasma.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/images/colormaps/Uniform/viridis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/images/colormaps/Uniform/viridis.png -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/js/.Rhistory: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/RealSpaceInterface/static/js/.Rhistory -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/js/gridLayout.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class GridLayout 3 | * 4 | * @property {number} count - Maximum number of items in this layout 5 | * @property {number} margin - space between planes 6 | * @property {number} size - size of each plane 7 | */ 8 | function GridLayout(count, size, margin) { 9 | this.count = count; 10 | this.margin = margin; 11 | this.size = size; 12 | 13 | this.recalculate(); 14 | } 15 | 16 | /** 17 | * Recalculate the number of rows of the layout. 18 | * 19 | * Must be called after each change of either columns or count. 20 | */ 21 | GridLayout.prototype.recalculate = function() { 22 | this.columns = Math.ceil(Math.sqrt(this.count)); 23 | this.rows = Math.ceil(this.count / this.columns); 24 | } 25 | 26 | /** 27 | * Get the position of the item defined by index. 28 | */ 29 | GridLayout.prototype.getPosition = function(index) { 30 | if (index >= this.count) { 31 | throw "GridLayout error: index higher than maximum number of items in layout"; 32 | } 33 | 34 | row = Math.floor(index / this.columns); 35 | column = index % this.columns; 36 | 37 | return [row, column]; 38 | } 39 | 40 | /** 41 | * Get the actual position (in correct units of size) of 42 | * the item defined by index. 43 | */ 44 | GridLayout.prototype.getWorldPosition = function(index) { 45 | var pos = this.getPosition(index); 46 | 47 | var row = pos[0]; 48 | var col = pos[1]; 49 | 50 | var x = 0, y = 0; 51 | var dx = Math.floor(this.columns / 2); 52 | var dy = Math.floor(this.rows / 2); 53 | if (this.columns % 2 == 0) 54 | dx -= 1 / 2; 55 | if (this.rows % 2 == 0) 56 | dy -= 1 / 2; 57 | x = (col - dx) * (this.size + this.margin); 58 | y = (row - dy) * (this.size + this.margin); 59 | 60 | return [x, y]; 61 | } 62 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/js/parameterConfig.js: -------------------------------------------------------------------------------- 1 | /* 2 | The parameters the application exposes to the user are configured using this list. 3 | Each parameter is represented by an entry in that list. 4 | An entry is an object containing some required and some optional fields. 5 | 6 | The required fields are: 7 | ------------------------ 8 | - `name`: The `name` property is the one that will be used to pass the 9 | parameter value to CLASS. 10 | 11 | - `displayName`: The `displayName` property will be displayed as the label 12 | of the property in both the control panel (on the left of the 13 | application) and in the simulation list. 14 | HTML is allowed. Subscripts use the tag. 15 | 16 | - `min`: Minimum parameter value. 17 | 18 | - `max`: Maximum parameter value. 19 | 20 | - `default`: Default parameter value. 21 | 22 | The optional fields are: 23 | ------------------------ 24 | - `step`: The increment by which the parameter will be increased using 25 | the sliders in the control panel. Defaults to 0.001. 26 | 27 | - `replaceBy`: It might be necessary to pass parameters to CLASS 28 | which are functions of other parameters, e.g. the user might 29 | set a value of `omega_m` but CLASS requires `omega_cdm` to be 30 | passed. In this case, a function accepting a dictionary of 31 | all the parameters and returning a dictionary containining 32 | the key-value pairs that are supposed to be passed to CLASS 33 | (see example for `omega_m` below). 34 | */ 35 | 36 | /** @global */ 37 | var COSMOLOGICAL_PARAMETER_LIST = [ 38 | { 39 | name: "h", 40 | displayName: "h", 41 | min: 0.0, 42 | max: 2.0, 43 | default: 0.67556, 44 | }, 45 | { 46 | name: "omega_b", 47 | displayName: "ωb", 48 | min: 0.0, 49 | max: 1.0, 50 | default: 0.022, 51 | }, 52 | { 53 | name: "omega_m", 54 | displayName: "ωm", 55 | min: 0.0, 56 | max: 1.0, 57 | default: 0.142, 58 | replaceBy: function(parameters) { 59 | return { 60 | "omega_cdm": parameters.omega_m - parameters.omega_b 61 | }; 62 | }, 63 | }, 64 | { 65 | name: "Omega_k", 66 | displayName: "Ωk", 67 | min: -0.2, 68 | max: 0.2, 69 | default: 0.0, 70 | }, 71 | { 72 | name: "N_ur", 73 | displayName: "Neff", 74 | min: 0.0, 75 | max: 30.0, 76 | default: 3.046 77 | }, 78 | { 79 | name: "w0_fld", 80 | displayName: "w0,fld", 81 | min: -2.0, 82 | max: 0.0, 83 | default: -1.0, 84 | }, 85 | { 86 | name: "wa_fld", 87 | displayName: "wa,fld", 88 | min: -1.0, 89 | max: 1.0, 90 | default: 0.0 91 | }, 92 | ]; 93 | 94 | 95 | /** 96 | * It is possible to pass additional parameters to CLASS using 97 | * the following object. 98 | * 99 | * @global 100 | */ 101 | var ADDITIONAL_CLASS_PARAMETERS = { 102 | "Omega_Lambda": 0, 103 | "YHe": 0.25, 104 | }; 105 | 106 | 107 | /** 108 | * Default redshifts. 109 | * Depending on the value of log, the individual arrays will be created either 110 | * as 111 | *
112 |  * numpy.logspace(from, to, points) (for log = true)
113 |  *  or
114 |  * numpy.linspace(from, to, points) (for  log = false).
115 |  * 
116 | * 117 | * The resulting individual arrays will be concatenated and duplicates removed. 118 | * 119 | * @global 120 | */ 121 | var DEFAULT_REDSHIFTS = [ 122 | { 123 | from: 1000000, 124 | to: 10000, 125 | log: true, 126 | points: 60, 127 | }, 128 | { 129 | from: 10000, 130 | to: 1089, 131 | log: true, 132 | points: 80, 133 | }, 134 | { 135 | from: 1089, 136 | to: 0.01, 137 | log: false, 138 | points: 40, 139 | }, 140 | ]; 141 | 142 | /** 143 | * Default Initial Condition Values. 144 | * 145 | * @global 146 | */ 147 | var DEFAULT_INITIAL = { 148 | scale: 400, 149 | resolution: 200, 150 | sigmaGauss: 10.0, 151 | n_s: 0.96 152 | }; 153 | 154 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/threejs/Detector.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * @author mr.doob / http://mrdoob.com/ 4 | */ 5 | 6 | var Detector = { 7 | 8 | canvas: !! window.CanvasRenderingContext2D, 9 | webgl: ( function () { try { var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); } catch ( e ) { return false; } } )(), 10 | workers: !! window.Worker, 11 | fileapi: window.File && window.FileReader && window.FileList && window.Blob, 12 | 13 | getWebGLErrorMessage: function () { 14 | 15 | var element = document.createElement( 'div' ); 16 | element.id = 'webgl-error-message'; 17 | element.style.fontFamily = 'monospace'; 18 | element.style.fontSize = '13px'; 19 | element.style.fontWeight = 'normal'; 20 | element.style.textAlign = 'center'; 21 | element.style.background = '#fff'; 22 | element.style.color = '#000'; 23 | element.style.padding = '1.5em'; 24 | element.style.width = '400px'; 25 | element.style.margin = '5em auto 0'; 26 | 27 | if ( ! this.webgl ) { 28 | 29 | element.innerHTML = window.WebGLRenderingContext ? [ 30 | 'Your graphics card does not seem to support WebGL.
', 31 | 'Find out how to get it here.' 32 | ].join( '\n' ) : [ 33 | 'Your browser does not seem to support WebGL.
', 34 | 'Find out how to get it here.' 35 | ].join( '\n' ); 36 | 37 | } 38 | 39 | return element; 40 | 41 | }, 42 | 43 | addGetWebGLMessage: function ( parameters ) { 44 | 45 | var parent, id, element; 46 | 47 | parameters = parameters || {}; 48 | 49 | parent = parameters.parent !== undefined ? parameters.parent : document.body; 50 | id = parameters.id !== undefined ? parameters.id : 'oldie'; 51 | 52 | element = Detector.getWebGLErrorMessage(); 53 | element.id = id; 54 | 55 | parent.appendChild( element ); 56 | 57 | } 58 | 59 | }; 60 | 61 | // browserify support 62 | if ( typeof module === 'object' ) { 63 | 64 | module.exports = Detector; 65 | 66 | } 67 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/static/threejs/libs/stats.min.js: -------------------------------------------------------------------------------- 1 | // stats.js - http://github.com/mrdoob/stats.js 2 | var Stats=function(){var l=Date.now(),m=l,g=0,n=Infinity,o=0,h=0,p=Infinity,q=0,r=0,s=0,f=document.createElement("div");f.id="stats";f.addEventListener("mousedown",function(b){b.preventDefault();t(++s%2)},!1);f.style.cssText="width:80px;opacity:0.9;cursor:pointer";var a=document.createElement("div");a.id="fps";a.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002";f.appendChild(a);var i=document.createElement("div");i.id="fpsText";i.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px"; 3 | i.innerHTML="FPS";a.appendChild(i);var c=document.createElement("div");c.id="fpsGraph";c.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff";for(a.appendChild(c);74>c.children.length;){var j=document.createElement("span");j.style.cssText="width:1px;height:30px;float:left;background-color:#113";c.appendChild(j)}var d=document.createElement("div");d.id="ms";d.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none";f.appendChild(d);var k=document.createElement("div"); 4 | k.id="msText";k.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";k.innerHTML="MS";d.appendChild(k);var e=document.createElement("div");e.id="msGraph";e.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0";for(d.appendChild(e);74>e.children.length;)j=document.createElement("span"),j.style.cssText="width:1px;height:30px;float:left;background-color:#131",e.appendChild(j);var t=function(b){s=b;switch(s){case 0:a.style.display= 5 | "block";d.style.display="none";break;case 1:a.style.display="none",d.style.display="block"}};return{REVISION:11,domElement:f,setMode:t,begin:function(){l=Date.now()},end:function(){var b=Date.now();g=b-l;n=Math.min(n,g);o=Math.max(o,g);k.textContent=g+" MS ("+n+"-"+o+")";var a=Math.min(30,30-30*(g/200));e.appendChild(e.firstChild).style.height=a+"px";r++;b>m+1E3&&(h=Math.round(1E3*r/(b-m)),p=Math.min(p,h),q=Math.max(q,h),i.textContent=h+" FPS ("+p+"-"+q+")",a=Math.min(30,30-30*(h/100)),c.appendChild(c.firstChild).style.height= 6 | a+"px",m=b,r=0);return b},update:function(){l=this.end()}}}; 7 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/templates/AlreadySimulatedModal.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/templates/ExceptionModal.html: -------------------------------------------------------------------------------- 1 | 19 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/templates/GifExportModal.html: -------------------------------------------------------------------------------- 1 | 2 | 82 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/templates/ImageExportModal.html: -------------------------------------------------------------------------------- 1 | 2 | 50 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/templates/ProgressModal.html: -------------------------------------------------------------------------------- 1 | 21 | 22 | 29 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/templates/RedshiftModal.html: -------------------------------------------------------------------------------- 1 | 13 | 14 | 37 | 38 | 58 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/templates/SimulationList.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /class/RealSpaceInterface/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | three.js webgl - geometry - dynamic 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Simulation
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /class/base_2015_plikHM_TT_lowTEB_lensing.ini: -------------------------------------------------------------------------------- 1 | # *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* 2 | # * CLASS input parameter file * 3 | # *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* 4 | 5 | # Best fit parameters from Planck 2015 6 | # Case 2.59 of: 7 | # https://wiki.cosmos.esa.int/planckpla2015/images/f/f7/Baseline_params_table_2015_limit68.pdf 8 | # (but with more significant digits, directly from the chains) 9 | 10 | #---------------------------- 11 | #----> background parameters: 12 | #---------------------------- 13 | 14 | H0 = 67.86682 15 | omega_b = 0.02227716 16 | N_ur = 2.03066666667 17 | omega_cdm = 0.1184293 18 | N_ncdm = 1 19 | omega_ncdm = 0.0006451439 20 | 21 | #-------------------------------- 22 | #----> thermodynamics parameters: 23 | #-------------------------------- 24 | 25 | YHe = 0.245352 26 | tau_reio = 0.06664549 27 | 28 | #------------------------------------- 29 | #----> primordial spectrum parameters: 30 | #------------------------------------- 31 | 32 | n_s = 0.9682903 33 | A_s = 2.140509e-09 34 | 35 | #----------------------------- 36 | #----> non linear corrections: 37 | #----------------------------- 38 | 39 | non linear = halofit 40 | 41 | #---------------------------------------- 42 | #----> parameters controlling the output: 43 | #---------------------------------------- 44 | 45 | output = tCl,pCl,lCl,mPk 46 | lensing = yes 47 | 48 | root = output/base_2015_plikHM_TT_lowTEB_lensing_ 49 | 50 | write warnings = yes 51 | write parameters = yes 52 | 53 | input_verbose = 1 54 | background_verbose = 1 55 | thermodynamics_verbose = 1 56 | perturbations_verbose = 1 57 | transfer_verbose = 1 58 | primordial_verbose = 1 59 | spectra_verbose = 1 60 | nonlinear_verbose = 1 61 | lensing_verbose = 1 62 | output_verbose = 1 -------------------------------------------------------------------------------- /class/base_2018_plikHM_TTTEEE_lowl_lowE_lensing.ini: -------------------------------------------------------------------------------- 1 | # *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* 2 | # * CLASS input parameter file * 3 | # *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* 4 | 5 | # Best fit parameters from Planck 2018 6 | # Case 2.17 of: 7 | # https://wiki.cosmos.esa.int/planck-legacy-archive/images/b/be/Baseline_params_table_2018_68pc.pdf 8 | # (but with more significant digits, directly from the chains) 9 | 10 | #---------------------------- 11 | #----> background parameters: 12 | #---------------------------- 13 | 14 | H0 = 67.32117 15 | omega_b = 0.02238280 16 | N_ur = 2.03066666667 17 | omega_cdm = 0.1201075 18 | N_ncdm = 1 19 | omega_ncdm = 0.0006451439 20 | 21 | #-------------------------------- 22 | #----> thermodynamics parameters: 23 | #-------------------------------- 24 | 25 | YHe = 0.2454006 26 | tau_reio = 0.05430842 27 | 28 | #------------------------------------- 29 | #----> primordial spectrum parameters: 30 | #------------------------------------- 31 | 32 | n_s = 0.9660499 33 | A_s = 2.100549e-09 34 | 35 | #----------------------------- 36 | #----> non linear corrections: 37 | #----------------------------- 38 | 39 | non linear = halofit 40 | 41 | #---------------------------------------- 42 | #----> parameters controlling the output: 43 | #---------------------------------------- 44 | 45 | output = tCl,pCl,lCl,mPk 46 | lensing = yes 47 | 48 | root = output/base_2018_plikHM_TTTEEE_lowl_lowE_lensing_ 49 | 50 | write warnings = yes 51 | write parameters = yes 52 | 53 | input_verbose = 1 54 | background_verbose = 1 55 | thermodynamics_verbose = 1 56 | perturbations_verbose = 1 57 | transfer_verbose = 1 58 | primordial_verbose = 1 59 | spectra_verbose = 1 60 | nonlinear_verbose = 1 61 | lensing_verbose = 1 62 | output_verbose = 1 -------------------------------------------------------------------------------- /class/cl_permille.pre: -------------------------------------------------------------------------------- 1 | # precision file to be passed as input in order to achieve at least percent precision on scalar Cls 2 | hyper_flat_approximation_nu = 7000. 3 | transfer_neglect_delta_k_S_t0 = 0.17 4 | transfer_neglect_delta_k_S_t1 = 0.05 5 | transfer_neglect_delta_k_S_t2 = 0.17 6 | transfer_neglect_delta_k_S_e = 0.13 7 | delta_l_max=1000 8 | -------------------------------------------------------------------------------- /class/cl_ref.pre: -------------------------------------------------------------------------------- 1 | # this file achieves maximum precision for the CMB: each ClTT and ClEE, lensed and unlensed, are stable at the 0.01% level 2 | 3 | tol_ncdm_bg = 1.e-10 4 | 5 | recfast_Nz0=100000 6 | tol_thermo_integration=1.e-5 7 | 8 | recfast_x_He0_trigger_delta = 0.01 9 | recfast_x_H0_trigger_delta = 0.01 10 | 11 | evolver=0 12 | 13 | k_min_tau0=0.002 14 | k_max_tau0_over_l_max=3. 15 | k_step_sub=0.015 16 | k_step_super=0.0001 17 | k_step_super_reduction=0.1 18 | 19 | start_small_k_at_tau_c_over_tau_h = 0.0004 20 | start_large_k_at_tau_h_over_tau_k = 0.05 21 | tight_coupling_trigger_tau_c_over_tau_h=0.005 22 | tight_coupling_trigger_tau_c_over_tau_k=0.008 23 | start_sources_at_tau_c_over_tau_h = 0.006 24 | 25 | l_max_g=50 26 | l_max_pol_g=25 27 | l_max_ur=50 28 | l_max_ncdm=50 29 | 30 | tol_perturb_integration=1.e-6 31 | perturb_sampling_stepsize=0.01 32 | 33 | radiation_streaming_approximation = 2 34 | radiation_streaming_trigger_tau_over_tau_k = 240. 35 | radiation_streaming_trigger_tau_c_over_tau = 100. 36 | 37 | ur_fluid_approximation = 2 38 | ur_fluid_trigger_tau_over_tau_k = 50. 39 | 40 | ncdm_fluid_approximation = 3 41 | ncdm_fluid_trigger_tau_over_tau_k = 51. 42 | 43 | tol_ncdm_synchronous = 1.e-10 44 | tol_ncdm_newtonian = 1.e-10 45 | 46 | l_logstep=1.026 47 | l_linstep=25 48 | 49 | hyper_sampling_flat = 12. 50 | hyper_sampling_curved_low_nu = 10. 51 | hyper_sampling_curved_high_nu = 10. 52 | hyper_nu_sampling_step = 10. 53 | hyper_phi_min_abs = 1.e-10 54 | hyper_x_tol = 1.e-4 55 | hyper_flat_approximation_nu = 1.e6 56 | 57 | q_linstep=0.20 58 | q_logstep_spline= 20. 59 | q_logstep_trapzd = 0.5 60 | q_numstep_transition = 250 61 | 62 | transfer_neglect_delta_k_S_t0 = 100. 63 | transfer_neglect_delta_k_S_t1 = 100. 64 | transfer_neglect_delta_k_S_t2 = 100. 65 | transfer_neglect_delta_k_S_e = 100. 66 | transfer_neglect_delta_k_V_t1 = 100. 67 | transfer_neglect_delta_k_V_t2 = 100. 68 | transfer_neglect_delta_k_V_e = 100. 69 | transfer_neglect_delta_k_V_b = 100. 70 | transfer_neglect_delta_k_T_t2 = 100. 71 | transfer_neglect_delta_k_T_e = 100. 72 | transfer_neglect_delta_k_T_b = 100. 73 | 74 | neglect_CMB_sources_below_visibility = 1.e-30 75 | transfer_neglect_late_source = 3000. 76 | 77 | halofit_k_per_decade = 3000. 78 | 79 | l_switch_limber = 40. 80 | accurate_lensing=1 81 | num_mu_minus_lmax = 1000. 82 | delta_l_max = 1000. -------------------------------------------------------------------------------- /class/cpp/Engine.cc: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------- 2 | // 3 | // Description: 4 | // class Engine : see header file (Engine.hh) for description. 5 | // 6 | //------------------------------------------------------------------------ 7 | //----------------------- 8 | // This Class's Header -- 9 | //----------------------- 10 | #include "Engine.hh" 11 | // ------------------------ 12 | // Collaborating classes -- 13 | //------------------------- 14 | //-------------------- 15 | // C++ 16 | //-------------------- 17 | #include 18 | #include 19 | #include 20 | //-------------------- 21 | // C 22 | //---------------- 23 | 24 | using namespace std; 25 | //--------------- 26 | // Constructors -- 27 | //---------------- 28 | Engine::Engine():_lmax(-1) 29 | { 30 | } 31 | //-------------- 32 | // Destructor -- 33 | //-------------- 34 | 35 | //----------------- 36 | // Member functions -- 37 | //----------------- 38 | 39 | void 40 | Engine::writeCls(std::ostream &of){ 41 | 42 | vector lvec(_lmax-1,1); 43 | lvec[0]=2; 44 | partial_sum(lvec.begin(),lvec.end(),lvec.begin()); 45 | 46 | vector cltt,clte,clee,clbb,clpp,cltp,clep; 47 | bool hasLensing=false; 48 | try{ 49 | getCls(lvec,cltt,clte,clee,clbb); 50 | hasLensing=getLensing(lvec,clpp,cltp,clep); 51 | } 52 | catch (std::exception &e){ 53 | cout << "GIOSH" << e.what() << endl; 54 | } 55 | 56 | cout.precision( 16 ); 57 | for (size_t i=0;i 20 | #include 21 | 22 | class Engine 23 | { 24 | 25 | public: 26 | 27 | enum cltype {TT=0,EE,TE,BB,PP,TP,EP}; //P stands for phi (lensing potential) 28 | 29 | //constructors 30 | Engine(); 31 | 32 | //pure virtual: 33 | virtual bool updateParValues(const std::vector& cosmopars)=0; 34 | 35 | // units = (micro-K)^2 36 | virtual void getCls(const std::vector& lVec, //input 37 | std::vector& cltt, 38 | std::vector& clte, 39 | std::vector& clee, 40 | std::vector& clbb)=0; 41 | 42 | 43 | virtual bool getLensing(const std::vector& lVec, //input 44 | std::vector& clpp, 45 | std::vector& cltp, 46 | std::vector& clep)=0; 47 | 48 | 49 | virtual double z_drag() const=0; 50 | virtual double rs_drag() const =0; 51 | 52 | virtual double get_Dv(double z)=0; 53 | 54 | virtual double get_Da(double z)=0; 55 | virtual double get_sigma8(double z)=0; 56 | virtual double get_f(double z)=0; 57 | virtual double get_Fz(double z)=0; 58 | virtual double get_Az(double z)=0; 59 | virtual double get_Hz(double z)=0; 60 | 61 | virtual double getTauReio() const=0; 62 | 63 | // destructor 64 | virtual ~Engine(){}; 65 | 66 | //write Cl model+lensing in ostream 67 | virtual void writeCls(std::ostream &o); 68 | inline int lmax() {return _lmax;} 69 | 70 | protected: 71 | int _lmax; 72 | 73 | }; 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /class/cpp/README: -------------------------------------------------------------------------------- 1 | The C++ wrapper ClassEngine.cc for Class (written by S. Plaszczynski) is distributed together with a test code, testKlass.cc, in which you can write a list of input parameters. This test code can be compiled with (assuming you are already in the directory cpp/ and you have a c++ compiler compatible with openmp): 2 | 3 | > c++ -O2 -fopenmp -I../include -c Engine.cc -o Engine.o 4 | > c++ -O2 -fopenmp -I../include -c ClassEngine.cc -o ClassEngine.o 5 | > c++ -O2 -fopenmp -I../include -c testKlass.cc -o testKlass.o 6 | > cd .. 7 | > c++ -O2 -fopenmp build/arrays.o build/background.o build/common.o build/dei_rkck.o build/evolver_ndf15.o build/evolver_rkck.o build/growTable.o build/helium.o build/history.o build/hydrogen.o build/hyperspherical.o build/hyrectools.o build/input.o build/lensing.o build/nonlinear.o build/output.o build/parser.o build/perturbations.o build/primordial.o build/quadrature.o build/sparse.o build/spectra.o build/thermodynamics.o build/transfer.o cpp/ClassEngine.o cpp/Engine.o cpp/testKlass.o -o testKlass 8 | 9 | then run with: 10 | 11 | > ./testKlass 12 | -------------------------------------------------------------------------------- /class/cpp/testKlass.cc: -------------------------------------------------------------------------------- 1 | 2 | //KLASS 3 | #include"ClassEngine.hh" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | 12 | // example run: one can specify as a second argument a preicison file 13 | int main(int argc,char** argv){ 14 | 15 | //jusqu'a ou en l 16 | const int l_max_scalars=1200; 17 | 18 | //CLASS config 19 | ClassParams pars; 20 | 21 | //pars.add("H0",70.3); 22 | pars.add("100*theta_s",1.04); 23 | pars.add("omega_b",0.0220); 24 | pars.add("omega_cdm",0.1116); 25 | pars.add("A_s",2.42e-9); 26 | pars.add("n_s",.96); 27 | pars.add("tau_reio",0.09); 28 | 29 | pars.add("k_pivot",0.05); 30 | pars.add("YHe",0.25); 31 | pars.add("output","tCl,pCl,lCl"); //pol +clphi 32 | 33 | pars.add("l_max_scalars",l_max_scalars); 34 | pars.add("lensing",true); //note boolean 35 | 36 | 37 | ClassEngine* KKK(0); 38 | 39 | try{ 40 | //le calculateur de spectres 41 | if (argc==2){ 42 | string pre=string(argv[1]); 43 | KKK=new ClassEngine(pars,pre); 44 | } 45 | else{ 46 | KKK=new ClassEngine(pars); 47 | } 48 | 49 | cout.precision( 16 ); 50 | KKK->writeCls(cout); 51 | } 52 | catch (std::exception &e){ 53 | cout << "GIOSH" << e.what() << endl; 54 | } 55 | 56 | delete KKK; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /class/doc/README: -------------------------------------------------------------------------------- 1 | CLASS automatic documentation folders 2 | ===================================== 3 | (Deanna Hooper, 25.03.2016) 4 | 5 | * the automatically generated PDF manual can be found in 6 | 7 | doc/manual/CLASS_MANUAL.pdf 8 | 9 | * the files in doc/input/ are auxiliary files for generating it 10 | 11 | * if you wish to update this manual yourself using doxygen, look at instructions in section 6 of CLASS_MANUAL.pdf 12 | 13 | * there is also an html version that you can access from the CLASS webpages. The html version used to be distributed together with CLASS, but we removed it because the html directory was too big. If you do wish to get the html source files on your own computer, you just need to recompile the manual with "cd doc/input/; ./make1.sh" (assuming that you have doxygen installed). -------------------------------------------------------------------------------- /class/doc/input/chap2.md: -------------------------------------------------------------------------------- 1 | Where to find information and documentation on CLASS? 2 | ====================================================== 3 | 4 | Author: Julien Lesgourgues 5 | 6 | 7 | * __For what the code can actually compute__: all possible input parameters, all coded cosmological models, all functionalities, all observables, etc.: read the file `explanatory.ini` in the main `CLASS` directory: it is THE reference file where we keep track of all possible input and the definition of all input parameters. For that reason we recommend to leave it always unchanged and to work with copies of it, or with short input files written from scratch. 8 | 9 | 10 | * __For the structure, style, and concrete aspects of the code__: this documentation, especially the `CLASS overview` chapter (the extensive automatically-generated part of this documentation is more for advanced users); plus the slides of our `CLASS` lectures, for instance those from Tokyo 2014 available at 11 | 12 | `http://lesgourg.github.io/class-tour-Tokyo.html` 13 | 14 | or the more recent and concise summary from the Narbonne 2016 lecture available at 15 | 16 | `http://lesgourg.github.io/class-tour/Narbonne.pdf` 17 | 18 | An updated overview of available `CLASS` lecture slides is always available at 19 | 20 | `http://lesgourg.github.io/courses.html` 21 | 22 | in the section `Courses on numerical tools`. 23 | 24 | 25 | * __For the python wrapper of `CLASS`__: at the moment, the best are the last slides (pages 75-96) of the Narbonne 2016 lectures 26 | 27 | `http://lesgourg.github.io/class-tour/Narbonne.pdf` 28 | 29 | Later we will expand the wrapper documentation with a dedicated chapter here. 30 | 31 | * __For the physics and equations used in the code__: mainly, the following papers: 32 | - *Cosmological perturbation theory in the synchronous and conformal Newtonian gauges* 33 | 34 | C. P. Ma and E. Bertschinger. 35 | 36 | http://arxiv.org/abs/astro-ph/9506072 37 | 38 | 10.1086/176550 39 | 40 | Astrophys. J. __455__, 7 (1995) 41 | 42 | - *The Cosmic Linear Anisotropy Solving System (CLASS) II: Approximation schemes* 43 | 44 | D. Blas, J. Lesgourgues and T. Tram. 45 | 46 | http://arxiv.org/abs/1104.2933 [astro-ph.CO] 47 | 48 | 10.1088/1475-7516/2011/07/034 49 | 50 | JCAP __1107__, 034 (2011) 51 | 52 | - *The Cosmic Linear Anisotropy Solving System (CLASS) IV: efficient implementation of non-cold relics* 53 | 54 | J. Lesgourgues and T. Tram. 55 | 56 | http://arxiv.org/abs/1104.2935 [astro-ph.CO] 57 | 58 | 10.1088/1475-7516/2011/09/032 59 | 60 | JCAP __1109__, 032 (2011) 61 | 62 | - *Optimal polarisation equations in FLRW universes* 63 | 64 | T. Tram and J. Lesgourgues. 65 | 66 | http://arxiv.org/abs/1305.3261 [astro-ph.CO] 67 | 68 | 10.1088/1475-7516/2013/10/002 69 | 70 | JCAP __1310__, 002 (2013) 71 | 72 | - *Fast and accurate CMB computations in non-flat FLRW universes* 73 | 74 | J. Lesgourgues and T. Tram. 75 | 76 | http://arxiv.org/abs/1312.2697 [astro-ph.CO] 77 | 78 | 10.1088/1475-7516/2014/09/032 79 | 80 | JCAP __1409__, no. 09, 032 (2014) 81 | 82 | - *The CLASSgal code for Relativistic Cosmological Large Scale Structure* 83 | 84 | E. Di Dio, F. Montanari, J. Lesgourgues and R. Durrer. 85 | 86 | http://arxiv.org/abs/1307.1459 [astro-ph.CO] 87 | 88 | 10.1088/1475-7516/2013/11/044 89 | 90 | JCAP __1311__, 044 (2013) 91 | 92 | plus also some latex notes on specific sectors: 93 | 94 | - *Equations for perturbed recombination* 95 | 96 | (can be turned on optionally by the user since v2.1.0) 97 | 98 | L. Voruz. 99 | 100 | http://lesgourg.github.io/class_public/perturbed_recombination.pdf 101 | 102 | - *PPF formalism in Newtonian and synchronous gauge* 103 | 104 | (used by default for the fluid perturbations since v2.6.0) 105 | 106 | T. Tram. 107 | 108 | http://lesgourg.github.io/class_public/PPF_formalism.pdf -------------------------------------------------------------------------------- /class/doc/input/latex/class.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | \@writefile{toc}{\contentsline {section}{\numberline {1}Overall architecture of {\sc class}}{2}} 3 | \@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Files and directories}{2}} 4 | \@writefile{toc}{\contentsline {subsection}{\numberline {1.2}The ten-module backbone}{4}} 5 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {1.2.1}Ten tasks}{4}} 6 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {1.2.2}Ten structures}{5}} 7 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {1.2.3}Ten modules}{5}} 8 | \@writefile{toc}{\contentsline {subsection}{\numberline {1.3}{\tt main()} function(s)}{7}} 9 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {1.3.1}The {\tt main.c} file}{7}} 10 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {1.3.2}The {\tt test\_<...>.c} files}{8}} 11 | \@writefile{toc}{\contentsline {section}{\numberline {2}Input/output}{9}} 12 | \@writefile{toc}{\contentsline {subsection}{\numberline {2.1}Input}{9}} 13 | \@writefile{toc}{\contentsline {subsection}{\numberline {2.2}Output}{11}} 14 | \@writefile{toc}{\contentsline {section}{\numberline {3}General principles}{12}} 15 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.1}Error management}{12}} 16 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.2}Dynamical allocation of indices}{13}} 17 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.3}No hard coding}{13}} 18 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.4}Modifying the code}{13}} 19 | \@writefile{toc}{\contentsline {section}{\numberline {4}Units and equations}{13}} 20 | -------------------------------------------------------------------------------- /class/doc/input/latex/class.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/doc/input/latex/class.pdf -------------------------------------------------------------------------------- /class/doc/input/latex/class.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/doc/input/latex/class.synctex.gz -------------------------------------------------------------------------------- /class/doc/input/make1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | doxygen doxyconf 4 | 5 | cp doxygen.sty ../manual/latex/doxygen.sty -------------------------------------------------------------------------------- /class/doc/input/make2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd ../manual/latex 4 | 5 | make 6 | 7 | make 8 | 9 | cp refman.pdf ../CLASS_MANUAL.pdf 10 | cd ../../input 11 | -------------------------------------------------------------------------------- /class/doc/input/mod.md: -------------------------------------------------------------------------------- 1 | Updating the manual 2 | =================== 3 | Author: D. C. Hooper (hooper@physik.rwth-aachen.de) 4 | 5 | This pdf manual and accompanying web version have been generated using the `doxygen` software (http://www.doxygen.org). This software directly reads the code and extracts the necessary comments to form the manual, meaning it is very easy to generate newer versions of the manual as desired. 6 | 7 | ### For CLASS developpers: ### 8 | 9 | To maintain the usefulness of the manual, a new version should be generated after any major upgrade to `CLASS`. To keep track of how up-to-date the manual is the title page also displays the last modification date. The manual is generated automatically from the code, excepted a few chapters written manually in the files 10 | 11 | README.md 12 | doc/input/chap2.md 13 | doc/input/chap3.md 14 | doc/input/mod.md 15 | external_Pk/README.md 16 | 17 | You can update these files, or add new ones that should be declared in the `INPUT=` field of `doc/input/doxyconf`. 18 | 19 | Generating a new version of this manual is straightforward. First, you need to install the `doxygen` software, which can be done by following the instructions on the software's webpage. The location where you install this software is irrelevant; it doesn't need to be in the same folder as `CLASS`. For Mac OSX, homebrew users can install the software with `brew install doxygen --with-graphviz`. 20 | 21 | Once installed, navigate to the class/doc/input directory and run the first script 22 | 23 | ` . make1.sh` 24 | 25 | This will generate a new version of the html manual and the necessary files to make the pdf version. Unfortunately, `doxygen` does not yet offer the option to automatically order the output chapters in the pdf version of the manual. Hence, before compiling the pdf, this must be done manually. To do this you need to find the `refman.tex` file in class/doc/manual/latex. With this file you can modify the title page, headers, footers, and chapter ordering for the final pdf. Usually we just make two things: add manually the line 26 | 27 | \vspace*{1cm} 28 | {\large Last updated \today}\\ 29 | 30 | after 31 | 32 | {\Large C\+L\+A\+SS M\+A\+N\+U\+AL }\\ 33 | 34 | and move manually the chapters `"The external Pk mode"` and `"Updating the manual"` to the end, after the automatically generated part. Once you have this file with your desired configuration, navigate back to the class/doc/input directory, and run the second script 35 | 36 | ` . make2.sh` 37 | 38 | You should now be able to find the finished pdf in `class/doc/manual/CLASS_MANUAL.pdf`. Finally you can commit the changes to git, but not all the content of `doc/` is necessary: only `doc/README`, `doc/input/` and `doc/manual/CLASS_MANUAL.pdf`. Since version 2.8, we are not committing anymore `doc/manual/html/` because it was too big (and complicating the version history): users only get the PDF manual from git. 39 | 40 | As a final comment, doxygen uses two main configuration files: `doxyconf` and `doxygen.sty`, both located in class/doc/input. Changes to these files can dramatically impact the outcome, so any modifications to these files should be done with great care. 41 | -------------------------------------------------------------------------------- /class/doc/manual/CLASS_MANUAL.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/doc/manual/CLASS_MANUAL.pdf -------------------------------------------------------------------------------- /class/external_Pk/generate_Pk_example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from __future__ import print_function 3 | import sys 4 | from math import exp 5 | 6 | # README: 7 | # 8 | # This is an example python script for the external_Pk mode of Class. 9 | # It generates the primordial spectrum of LambdaCDM. 10 | # It can be edited and used directly, though keeping a copy of it is recommended. 11 | # 12 | # Two (maybe three) things need to be edited: 13 | # 14 | # 1. The name of the parameters needed for the calculation of Pk. 15 | # "sys.argv[1]" corresponds to "custom1" in Class, an so on 16 | 17 | try : 18 | k_0 = float(sys.argv[1]) 19 | A = float(sys.argv[2]) 20 | n_s = float(sys.argv[3]) 21 | 22 | # Error control, no need to touch 23 | except IndexError : 24 | raise IndexError("It seems you are calling this script with too few arguments.") 25 | except ValueError : 26 | raise ValueError("It seems some of the arguments are not correctly formatted. "+ 27 | "Remember that they must be floating point numbers.") 28 | 29 | # 2. The function giving P(k), including the necessary import statements. 30 | # Inside this function, you can use the parameters named in the previous step. 31 | 32 | def P(k) : 33 | return A * (k/k_0)**(n_s-1.) 34 | 35 | # 3. Limits for k and precision: 36 | # Check that the boundaries are correct for your case. 37 | # It is safer to set k_per_decade primordial slightly bigger than that of Class. 38 | 39 | k_min = 1.e-6 40 | k_max = 10. 41 | k_per_decade_primordial = 200. 42 | 43 | # 44 | # And nothing should need to be edited from here on. 45 | # 46 | 47 | # Filling the array of k's 48 | ks = [float(k_min)] 49 | while ks[-1] <= float(k_max) : 50 | ks.append(ks[-1]*10.**(1./float(k_per_decade_primordial))) 51 | 52 | # Filling the array of Pk's 53 | for k in ks : 54 | P_k = P(k) 55 | print("%.18g %.18g" % (k, P_k)) 56 | 57 | -------------------------------------------------------------------------------- /class/external_Pk/generate_Pk_example_w_tensors.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from __future__ import print_function 3 | import sys 4 | from math import exp 5 | 6 | # README: 7 | # 8 | # This is an example python script for the external_Pk mode of Class. 9 | # It generates the primordial spectrum of LambdaCDM. 10 | # It can be edited and used directly, though keeping a copy of it is recommended. 11 | # 12 | # Two (maybe three) things need to be edited: 13 | # 14 | # 1. The name of the parameters needed for the calculation of Pk. 15 | # "sys.argv[1]" corresponds to "custom1" in Class, an so on 16 | 17 | try : 18 | k_0 = float(sys.argv[1]) 19 | A_s = float(sys.argv[2]) 20 | n_s = float(sys.argv[3]) 21 | A_t = float(sys.argv[4]) 22 | n_t = float(sys.argv[5]) 23 | 24 | # Error control, no need to touch 25 | except IndexError : 26 | raise IndexError("It seems you are calling this script with too few arguments.") 27 | except ValueError : 28 | raise ValueError("It seems some of the arguments are not correctly formatted. "+ 29 | "Remember that they must be floating point numbers.") 30 | 31 | # 2. The function giving P(k), including the necessary import statements. 32 | # Inside this function, you can use the parameters named in the previous step. 33 | 34 | def P_s(k) : 35 | return A_s * (k/k_0)**(n_s-1.) 36 | 37 | def P_t(k) : 38 | return A_t * (k/k_0)**(n_t) 39 | 40 | # 3. Limits for k and precision: 41 | # Check that the boundaries are correct for your case. 42 | # It is safer to set k_per_decade primordial slightly bigger than that of Class. 43 | 44 | k_min = 1.e-6 45 | k_max = 10. 46 | k_per_decade_primordial = 200. 47 | 48 | # 49 | # And nothing should need to be edited from here on. 50 | # 51 | 52 | # Filling the array of k's 53 | ks = [float(k_min)] 54 | while ks[-1] <= float(k_max) : 55 | ks.append(ks[-1]*10.**(1./float(k_per_decade_primordial))) 56 | 57 | # Filling the array of Pk's 58 | for k in ks : 59 | print("%.18g %.18g %.18g" % (k, P_s(k), P_t(k))) 60 | 61 | -------------------------------------------------------------------------------- /class/figures-for-paper/cmb/DellEEandTE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/cmb/DellEEandTE.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/cmb/DellTT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/cmb/DellTT.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/cmb/Dellpp.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/cmb/Dellpp.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/mPk/PkDES.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/mPk/PkDES.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/mPk/PkDiffOnePlot-ratio.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/mPk/PkDiffOnePlot-ratio.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/mPk/PkDiff_fEDE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/mPk/PkDiff_fEDE.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/mPk/PkDiff_zc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/mPk/PkDiff_zc.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/mPk/Pkh.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/mPk/Pkh.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/mPk/growth.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/mPk/growth.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/mPk/s8s.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/mPk/s8s.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/fEDE-shooting-Us.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/fEDE-shooting-Us.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/fEDE-shooting_Smith.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/fEDE-shooting_Smith.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/fEDE_no_shooting.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/fEDE_no_shooting.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/log10f_scf-shooting-Smith.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/log10f_scf-shooting-Smith.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/log10f_scf-shooting-Us.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/log10f_scf-shooting-Us.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/log10m_scf-shooting-Smith.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/log10m_scf-shooting-Smith.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/log10m_scf-shooting-Us.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/log10m_scf-shooting-Us.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/log10z_c-shooting-Smith.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/log10z_c-shooting-Smith.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/log10z_c-shooting-Us.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/log10z_c-shooting-Us.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/log10z_c_no_shooting.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/log10z_c_no_shooting.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/thetai_scf-shooting-Smith.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/thetai_scf-shooting-Smith.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/thetai_scf-shooting-Us.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/thetai_scf-shooting-Us.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/data/thetai_scf_no_shooting.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/data/thetai_scf_no_shooting.npy -------------------------------------------------------------------------------- /class/figures-for-paper/priors/priors-f-m-shooting-Smith.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/priors-f-m-shooting-Smith.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/priors/priors-f-m-shooting-Smith.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/priors-f-m-shooting-Smith.png -------------------------------------------------------------------------------- /class/figures-for-paper/priors/priors-f-m-shooting-Us.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/priors-f-m-shooting-Us.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/priors/priors-f-m-shooting-Us.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/priors-f-m-shooting-Us.png -------------------------------------------------------------------------------- /class/figures-for-paper/priors/priors-fEDE-z_c-no-shooting.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/priors-fEDE-z_c-no-shooting.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/priors/priors-fEDE-z_c-no-shooting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/priors/priors-fEDE-z_c-no-shooting.png -------------------------------------------------------------------------------- /class/figures-for-paper/scf/fEDE-example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/scf/fEDE-example.pdf -------------------------------------------------------------------------------- /class/figures-for-paper/scf/fEDE_v_z.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/figures-for-paper/scf/fEDE_v_z.png -------------------------------------------------------------------------------- /class/hyrec/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | AR = ar rv 3 | CCFLAG = -O3 4 | LDFLAG = -O3 5 | 6 | %.o: %.c 7 | $(CC) $(CCFLAG) -c $*.c -o $*.o 8 | 9 | HYREC_SRC = hyrectools.o helium.o hydrogen.o history.o 10 | HYREC_EXE = hyrec.o 11 | 12 | clean: 13 | rm *.o 14 | 15 | hyrec: $(HYREC_SRC) $(HYREC_EXE) 16 | $(CC) $(LDFLAG) -o hyrec $(HYREC_SRC) $(HYREC_EXE) -lm 17 | 18 | libhyrec.a: $(HYREC_SRC) 19 | $(AR) $@ $(HYREC_SRC) 20 | -------------------------------------------------------------------------------- /class/hyrec/R_inf.dat: -------------------------------------------------------------------------------- 1 | 1.7280364e-270 2 | 6.6039762e-258 3 | 6.7635594e-246 4 | 1.9708577e-234 5 | 1.7300431e-223 6 | 4.8313008e-213 7 | 4.5215162e-203 8 | 1.4903791e-193 9 | 1.8142665e-184 10 | 8.5341394e-176 11 | 1.6197268e-167 12 | 1.2925969e-159 13 | 4.5115458e-152 14 | 7.1507716e-145 15 | 5.3349221e-138 16 | 1.9387643e-131 17 | 3.5460250e-125 18 | 3.3676825e-119 19 | 1.7109205e-113 20 | 4.7839499e-108 21 | 7.5646529e-103 22 | 6.9420654e-98 23 | 3.7898850e-93 24 | 1.2602397e-88 25 | 2.6106959e-84 26 | 3.4425222e-80 27 | 2.9493845e-76 28 | 1.6742940e-72 29 | 6.4165620e-69 30 | 1.6900470e-65 31 | 3.1118869e-62 32 | 4.0714008e-59 33 | 3.8441840e-56 34 | 2.6585412e-53 35 | 1.3658643e-50 36 | 5.2840064e-48 37 | 1.5592320e-45 38 | 3.5530007e-43 39 | 6.3258596e-41 40 | 8.8992663e-39 41 | 9.9988163e-37 42 | 9.0644363e-35 43 | 6.6952578e-33 44 | 4.0669811e-31 45 | 2.0498201e-29 46 | 8.6453638e-28 47 | 3.0760453e-26 48 | 9.3047039e-25 49 | 2.4105662e-23 50 | 5.3864587e-22 51 | 1.0451486e-20 52 | 1.7722856e-19 53 | 2.6426216e-18 54 | 3.4851890e-17 55 | 4.0882520e-16 56 | 4.2883440e-15 57 | 4.0429523e-14 58 | 3.4425611e-13 59 | 2.6598731e-12 60 | 1.8731305e-11 61 | 1.2073920e-10 62 | 7.1526105e-10 63 | 3.9093178e-09 64 | 1.9786383e-08 65 | 9.3067478e-08 66 | 4.0819149e-07 67 | 1.6748158e-06 68 | 6.4483254e-06 69 | 2.3365930e-05 70 | 7.9909245e-05 71 | 0.00025861567 72 | 0.00079408899 73 | 0.0023190028 74 | 0.0064559897 75 | 0.017171875 76 | 0.043730414 77 | 0.10683990 78 | 0.25089798 79 | 0.56736529 80 | 1.2375935 81 | 2.6082657 82 | 5.3193132 83 | 10.512952 84 | 20.163234 85 | 37.577705 86 | 68.135235 87 | 120.33502 88 | 207.23852 89 | 348.38577 90 | 572.25626 91 | 919.32050 92 | 1445.6878 93 | 2227.3000 94 | 3364.5516 95 | 4987.1358 96 | 7258.8380 97 | 10381.923 98 | 14600.711 99 | 20203.910 100 | 27525.291 101 | -------------------------------------------------------------------------------- /class/hyrec/helium.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************/ 2 | /* HYREC: Hydrogen and Helium Recombination Code */ 3 | /* Written by Yacine Ali-Haimoud and Chris Hirata (Caltech) */ 4 | /* */ 5 | /* helium.h: all functions related to helium recombination */ 6 | /* */ 7 | /* Version: January 2011 (first released November 2010) */ 8 | /*************************************************************************************************/ 9 | 10 | double rec_sahaHeII(double nH0, double Tr0, double fHe, double z, double *xHeIII); 11 | double rec_sahaHeI(double nH0, double Tr0, double fHe, double z); 12 | double rec_helium_dxedt(double xe, double nH0, double Tr0, double fHe, double H, double z); 13 | double rec_saha_xe_H(double nH0, double T0, double z); 14 | double xe_PostSahaHe(double nH0, double Tr0, double fHe, double H, double z, double *Delta_xe); 15 | -------------------------------------------------------------------------------- /class/hyrec/hyrec.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************************************/ 2 | /* HYREC: Hydrogen and Helium Recombination Code */ 3 | /* Written by Yacine Ali-Haimoud and Chris Hirata (Caltech) */ 4 | /* */ 5 | /* hyrec.c: main module */ 6 | /* */ 7 | /* Version: November 2011 */ 8 | /* Revision history: */ 9 | /* - written November 2010 */ 10 | /* - January 2011: changed various switches (notably for post-Saha expansions) */ 11 | /* so that they remain valid for arbitrary cosmologies */ 12 | /* - November 2011: extended integration down to z = 0 with Peeble's model for z < 20 */ 13 | /* changed dTm/dlna so it can be used at all times */ 14 | /*************************************************************************************************/ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "hyrec.h" 22 | 23 | int main(void) { 24 | 25 | REC_COSMOPARAMS param; 26 | HRATEEFF rate_table; 27 | TWO_PHOTON_PARAMS twog_params; 28 | double *xe_output, *Tm_output; 29 | long iz; 30 | 31 | double dz = -1; 32 | unsigned nz = 8001; 33 | double z, xe, Tm; 34 | 35 | 36 | /* Build effective rate table */ 37 | rate_table.logTR_tab = create_1D_array(NTR); 38 | rate_table.TM_TR_tab = create_1D_array(NTM); 39 | rate_table.logAlpha_tab[0] = create_2D_array(NTM, NTR); 40 | rate_table.logAlpha_tab[1] = create_2D_array(NTM, NTR); 41 | rate_table.logR2p2s_tab = create_1D_array(NTR); 42 | read_rates(&rate_table); 43 | 44 | /* Read two-photon rate tables */ 45 | read_twog_params(&twog_params); 46 | 47 | 48 | /* Get cosmological parameters */ 49 | rec_get_cosmoparam(stdin, stderr, ¶m); 50 | 51 | /* Compute the recombination history */ 52 | xe_output = (double*)malloc((size_t)(param.nz*sizeof(double))); 53 | Tm_output = (double*)malloc((size_t)(param.nz*sizeof(double))); 54 | 55 | rec_build_history(¶m, &rate_table, &twog_params, xe_output, Tm_output); 56 | 57 | /* Interpolate at the desired output redshifts */ 58 | for(iz=0; iz 0. ? (a) : (-(a)) ) 85 | 86 | #define _MAXSTP_ 100000 87 | #define _TINY_ 1.0e-30 88 | #define _SAFETY_ 0.9 89 | #define _PGROW_ -0.2 90 | #define _PSHRNK_ -0.25 91 | #define _ERRCON_ 1.89e-4 92 | 93 | #define _RKCK_a2_ 0.2 94 | #define _RKCK_a3_ 0.3 95 | #define _RKCK_a4_ 0.6 96 | #define _RKCK_a5_ 1.0 97 | #define _RKCK_a6_ 0.875 98 | #define _RKCK_b21_ 0.2 99 | #define _RKCK_b31_ 3.0/40.0 100 | #define _RKCK_b32_ 9.0/40.0 101 | #define _RKCK_b41_ 0.3 102 | #define _RKCK_b42_ -0.9 103 | #define _RKCK_b43_ 1.2 104 | #define _RKCK_b51_ -11.0/54.0 105 | #define _RKCK_b52_ 2.5 106 | #define _RKCK_b53_ -70.0/27.0 107 | #define _RKCK_b54_ 35.0/27.0 108 | #define _RKCK_b61_ 1631.0/55296.0 109 | #define _RKCK_b62_ 175.0/512.0 110 | #define _RKCK_b63_ 575.0/13824.0 111 | #define _RKCK_b64_ 44275.0/110592.0 112 | #define _RKCK_b65_ 253.0/4096.0 113 | #define _RKCK_c1_ 37.0/378.0 114 | #define _RKCK_c3_ 250.0/621.0 115 | #define _RKCK_c4_ 125.0/594.0 116 | #define _RKCK_c6_ 512.0/1771.0 117 | #define _RKCK_dc5_ -277.00/14336.0 118 | #define _RKCK_dc1_ (37.0/378.0-2825.0/27648.) 119 | #define _RKCK_dc3_ (250.0/621.0-18575.0/48384.0) 120 | #define _RKCK_dc4_ (125.0/594.0-13525.0/55296.0) 121 | #define _RKCK_dc6_ (512.0/1771.0-0.25) 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /class/include/evolver_ndf15.h: -------------------------------------------------------------------------------- 1 | #ifndef __EVO__ 2 | #define __EVO__ 3 | #include "common.h" 4 | // #include "perturbations.h" 5 | #include "sparse.h" 6 | #define TINY 1e-50 7 | /**************************************************************/ 8 | 9 | struct jacobian{ 10 | /*Stuff for normal method: */ 11 | double **dfdy; 12 | double *jacvec; /*Stores experience gained from subsequent calls */ 13 | double **LU; 14 | double *LUw; 15 | int *luidx; 16 | /*Sparse stuff:*/ 17 | int use_sparse; 18 | int sparse_stuff_initialized; 19 | int max_nonzero; /*Maximal number of non-zero entries to be considered sparse */ 20 | int repeated_pattern; 21 | int trust_sparse; /* Number of times a pattern is repeated (actually included) before we trust it. */ 22 | int has_grouping; 23 | int has_pattern; 24 | int new_jacobian; /* True if sp_ludcmp has not been run on the current jacobian. */ 25 | int cnzmax; 26 | int *col_group; /* Column grouping. Groups go from 0 to max_group*/ 27 | int *col_wi; /* Workarray for column grouping*/ 28 | int max_group; /*Number of columngroups -1 */ 29 | sp_mat *spJ; /* Stores the matrix we want to decompose */ 30 | double *xjac; /*Stores the values of the sparse jacobian. (Same pattern as spJ) */ 31 | sp_num *Numerical; /*Stores the LU decomposition.*/ 32 | int *Cp; /* Stores the column pointers of the spJ+spJ' sparsity pattern. */ 33 | int *Ci; /* Stores the row indices of the spJ+spJ' sparsity pattern. */ 34 | }; 35 | 36 | struct numjac_workspace{ 37 | /* Allocate vectors and matrices: */ 38 | double *yscale; 39 | double *del; 40 | double * Difmax; 41 | double * absFdelRm; 42 | double * absFvalue; 43 | double * absFvalueRm; 44 | double * Fscale; 45 | double * ffdel; 46 | double * yydel; 47 | double * tmp; 48 | 49 | double **ydel_Fdel; 50 | 51 | int * logj; 52 | int * Rowmax; 53 | }; 54 | 55 | /** 56 | * Boilerplate for C++ 57 | */ 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | 62 | int initialize_jacobian(struct jacobian *jac, int neq, ErrorMsg error_message); 63 | int uninitialize_jacobian(struct jacobian *jac); 64 | int initialize_numjac_workspace(struct numjac_workspace * nj_ws,int neq, ErrorMsg error_message); 65 | int uninitialize_numjac_workspace(struct numjac_workspace * nj_ws); 66 | int calc_C(struct jacobian *jac); 67 | int interp_from_dif(double tinterp,double tnew,double *ynew,double h,double **dif,int k, double *yinterp, 68 | double *ypinterp, double *yppinterp, int* index, int neq, int output); 69 | int new_linearisation(struct jacobian *jac,double hinvGak,int neq, ErrorMsg error_message); 70 | int adjust_stepsize(double **dif, double abshdivabshlast, int neq,int k); 71 | void eqvec(double *datavec,double *emptyvec, int n); 72 | int lubksb(double **a, int n, int *indx, double b[]); 73 | int ludcmp(double **a, int n, int *indx, double *d, double *vv); 74 | int fzero_Newton(int (*func)(double *x, 75 | int x_size, 76 | void *param, 77 | double *F, 78 | ErrorMsg error_message), 79 | double *x_inout, 80 | double *dxdF, 81 | int x_size, 82 | double tolx, 83 | double tolF, 84 | void *param, 85 | int *fevals, 86 | ErrorMsg error_message); 87 | 88 | int numjac(int (*derivs)(double x,double * y,double * dy,void * parameters_and_workspace,ErrorMsg error_message), 89 | double t, double *y, double *fval, struct jacobian *jac, struct numjac_workspace *nj_ws, 90 | double thresh, int neq, int *nfe, 91 | void * parameters_and_workspace_for_derivs, ErrorMsg error_message); 92 | 93 | 94 | int evolver_ndf15( 95 | int (*derivs)(double x,double * y,double * dy, 96 | void * parameters_and_workspace, ErrorMsg error_message), 97 | double x_ini, 98 | double x_final, 99 | double * y_inout, 100 | int * used_in_output, 101 | int neq, 102 | void * parameters_and_workspace_for_derivs, 103 | double rtol, 104 | double minimum_variation, 105 | int (*timescale_and_approximation)(double x, 106 | void * parameters_and_workspace, 107 | double * timescales, 108 | ErrorMsg error_message), 109 | double timestep_over_timescale, 110 | double * t_vec, 111 | int t_res, 112 | int (*output)(double x,double y[],double dy[],int index_x,void * parameters_and_workspace, 113 | ErrorMsg error_message), 114 | int (*print_variables)(double x, double y[], double dy[], void *parameters_and_workspace, 115 | ErrorMsg error_message), 116 | ErrorMsg error_message); 117 | 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | /**************************************************************/ 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /class/include/evolver_rkck.h: -------------------------------------------------------------------------------- 1 | #ifndef __EVO__ 2 | #define __EVO__ 3 | 4 | #include "dei_rkck.h" 5 | 6 | /**************************************************************/ 7 | 8 | /** 9 | * Boilerplate for C++ 10 | */ 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | int evolver_rk(int (*derivs)(double x, 16 | double * y, 17 | double * dy, 18 | void * parameters_and_workspace, 19 | ErrorMsg error_message), 20 | double x_ini, 21 | double x_end, 22 | double * y, 23 | int * used_in_output, 24 | int y_size, 25 | void * parameters_and_workspace_for_derivs, 26 | double tolerance, 27 | double minimum_variation, 28 | int (*evaluate_timescale)(double x, 29 | void * parameters_and_workspace, 30 | double * timescale, 31 | ErrorMsg error_message), 32 | double timestep_over_timescale, 33 | double * x_sampling, 34 | int x_size, 35 | int (*output)(double x, 36 | double y[], 37 | double dy[], 38 | int index_x, 39 | void * parameters_and_workspace, 40 | ErrorMsg error_message), 41 | int (*print_variables)(double x, 42 | double y[], 43 | double dy[], 44 | void * parameters_and_workspace, 45 | ErrorMsg error_message), 46 | ErrorMsg error_message); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | /**************************************************************/ 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /class/include/growTable.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * A table that grows automatically. 3 | */ 4 | 5 | #ifndef __GROWTABLE__ 6 | #define __GROWTABLE__ 7 | 8 | #include "common.h" 9 | 10 | #define _GT_INITSIZE_ 4096 /**< Init size of a growTable (in bytes)*/ 11 | #define _GT_FACTOR_ 2 /**< inflating factor when current max size is reached */ 12 | #define _GT_END_ -1 /**< flag meaning the end of the current data in the growTable */ 13 | 14 | /** 15 | * growTable structure. 16 | */ 17 | typedef struct { 18 | void* buffer; /**< stack of data */ 19 | long sz; /**< total size */ 20 | long csz; /**< real size */ 21 | int freeze; /**< if set to _TRUE_ no data can be added */ 22 | 23 | ErrorMsg error_message; /**< error message slot */ 24 | } growTable; 25 | 26 | /** Boilerplate for C++ */ 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | int gt_init(growTable*); 32 | 33 | int gt_add(growTable*, long idx, void* data, long sz); 34 | int gt_retrieve(growTable *,long idx, long sz, void* data); 35 | int gt_retrieveAll(growTable *,void* data); 36 | 37 | int gt_getSize(growTable*, long *idx); 38 | 39 | int gt_getPtr(growTable*, void** ptr); 40 | 41 | int gt_free(growTable*); 42 | 43 | /** Boilerplate for C++ */ 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | #endif 48 | -------------------------------------------------------------------------------- /class/include/parser.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARSER__ 2 | #define __PARSER__ 3 | 4 | #include "common.h" 5 | 6 | #define _LINE_LENGTH_MAX_ 1024 /**< size of the string read in each line of the file (extra characters not taken into account) */ 7 | #define _ARGUMENT_LENGTH_MAX_ 1024 /**< maximum size of each argument (name or value), including the final null character */ 8 | 9 | typedef char FileArg[_ARGUMENT_LENGTH_MAX_]; 10 | 11 | /* after reading a given file, all relevant information stored in this structure, in view of being processed later*/ 12 | struct file_content { 13 | char * filename; 14 | int size; 15 | FileArg * name; /**< list of (size) names */ 16 | FileArg * value; /**< list of (size) values */ 17 | short * read; /**< set to _TRUE_ if this parameter is effectively read */ 18 | }; 19 | 20 | /**************************************************************/ 21 | 22 | /* 23 | * Boilerplate for C++ 24 | */ 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | int parser_read_file( 30 | char * filename, 31 | struct file_content * pfc, 32 | ErrorMsg errmsg 33 | ); 34 | 35 | int parser_init( 36 | struct file_content * pfc, 37 | int size, 38 | char * filename, 39 | ErrorMsg errmsg 40 | ); 41 | 42 | int parser_free( 43 | struct file_content * pfc 44 | ); 45 | 46 | int parser_read_line( 47 | char * line, 48 | int * is_data, 49 | char * name, 50 | char * value, 51 | ErrorMsg errmsg 52 | ); 53 | 54 | int parser_read_int( 55 | struct file_content * pfc, 56 | char * name, 57 | int * value, 58 | int * found, 59 | ErrorMsg errmsg 60 | ); 61 | 62 | int parser_read_double( 63 | struct file_content * pfc, 64 | char * name, 65 | double * value, 66 | int * found, 67 | ErrorMsg errmsg 68 | ); 69 | 70 | int parser_read_double_and_position( 71 | struct file_content * pfc, 72 | char * name, 73 | double * value, 74 | int * position, 75 | int * found, 76 | ErrorMsg errmsg 77 | ); 78 | 79 | int parser_read_string( 80 | struct file_content * pfc, 81 | char * name, 82 | FileArg * value, 83 | int * found, 84 | ErrorMsg errmsg 85 | ); 86 | 87 | int parser_read_list_of_doubles( 88 | struct file_content * pfc, 89 | char * name, 90 | int * size, 91 | double ** pointer_to_list, 92 | int * found, 93 | ErrorMsg errmsg 94 | ); 95 | 96 | int parser_read_list_of_integers( 97 | struct file_content * pfc, 98 | char * name, 99 | int * size, 100 | int ** pointer_to_list, 101 | int * found, 102 | ErrorMsg errmsg 103 | ); 104 | 105 | int parser_read_list_of_strings( 106 | struct file_content * pfc, 107 | char * name, 108 | int * size, 109 | char ** pointer_to_list, 110 | int * found, 111 | ErrorMsg errmsg 112 | ); 113 | 114 | int parser_cat( 115 | struct file_content * pfc1, 116 | struct file_content * pfc2, 117 | struct file_content * pfc3, 118 | ErrorMsg errmsg 119 | ); 120 | 121 | #ifdef __cplusplus 122 | } 123 | #endif 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /class/include/precision_macros.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file should not be modified 3 | * */ 4 | 5 | #ifdef __ASSIGN_DEFAULT_PRECISION__ 6 | #define class_precision_parameter(NAME,TYPE,DEF_VALUE) \ 7 | ppr->NAME = DEF_VALUE; 8 | #endif 9 | #ifdef __ALLOCATE_PRECISION_PARAMETER__ 10 | #define class_precision_parameter(NAME,TYPE,DEF_VALUE) \ 11 | TYPE NAME; 12 | #endif 13 | #ifdef __PARSE_PRECISION_PARAMETER__ 14 | #define class_precision_parameter(NAME,TYPE,DEF_VALUE) \ 15 | class_read_ ## TYPE(#NAME,ppr->NAME); 16 | #endif 17 | 18 | 19 | #ifdef __ASSIGN_DEFAULT_PRECISION__ 20 | #define class_string_parameter(NAME,DIR,STRING) \ 21 | sprintf(ppr->NAME,__CLASSDIR__); \ 22 | strcat(ppr->NAME,DIR); 23 | #endif 24 | #ifdef __ALLOCATE_PRECISION_PARAMETER__ 25 | #define class_string_parameter(NAME,DIR,STRING) \ 26 | FileName NAME; 27 | #endif 28 | #ifdef __PARSE_PRECISION_PARAMETER__ 29 | #define class_string_parameter(NAME,DIR,STRING) \ 30 | class_read_string(STRING,ppr->NAME); 31 | #endif 32 | 33 | 34 | #ifdef __ASSIGN_DEFAULT_PRECISION__ 35 | #define class_type_parameter(NAME,READ_TP,REAL_TP,DEF_VAL) \ 36 | ppr->NAME = DEF_VAL; 37 | #endif 38 | #ifdef __ALLOCATE_PRECISION_PARAMETER__ 39 | #define class_type_parameter(NAME,READ_TP,REAL_TP,DEF_VAL) \ 40 | REAL_TP NAME; 41 | #endif 42 | #ifdef __PARSE_PRECISION_PARAMETER__ 43 | #define class_type_parameter(NAME,READ_TP,REAL_TP,DEF_VAL) \ 44 | class_read_ ## READ_TP(#NAME,ppr->NAME); 45 | #endif 46 | -------------------------------------------------------------------------------- /class/include/quadrature.h: -------------------------------------------------------------------------------- 1 | #ifndef __QSS__ 2 | #define __QSS__ 3 | 4 | #define _MIN_NUMBER_OF_LAGUERRE_POINTS_ 5 5 | 6 | /******************************************/ 7 | /* Quadrature Sampling Strategy for CLASS */ 8 | /* 10/12 2010 */ 9 | /* Thomas Tram */ 10 | /******************************************/ 11 | #include "common.h" 12 | 13 | enum ncdm_quadrature_method {qm_auto, qm_Laguerre, qm_trapz_indefinite, qm_trapz}; 14 | 15 | /* Structures for QSS */ 16 | 17 | typedef struct adaptive_integration_tree_node{ 18 | /* binary tree node: */ 19 | double I; /* Estimate of integral */ 20 | double err; /* Estimated error */ 21 | double *x; /* Pointer to the abscissas of node */ 22 | double *w; /* Pointer to the corresponding weights */ 23 | int leaf_childs;/* Number of leafs under current node. 1 means that the node is a leaf. */ 24 | /* Pointer to children: */ 25 | struct adaptive_integration_tree_node *left, *right; /* Pointer to left child. */ 26 | } qss_node; 27 | 28 | /** 29 | * Boilerplate for C++ 30 | */ 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | int get_qsampling(double *x, 35 | double *w, 36 | int *N, 37 | int N_max, double rtol, 38 | double *qvec, 39 | int qsiz, 40 | int (*test)(void * params_for_function, double q, double *psi), 41 | int (*function)(void * params_for_function, double q, double *f0), 42 | void * params_for_function, 43 | ErrorMsg errmsg); 44 | int get_qsampling_manual(double *x, 45 | double *w, 46 | int N, 47 | double qmax, 48 | enum ncdm_quadrature_method method, 49 | double *qvec, 50 | int qsiz, 51 | int (*function)(void * params_for_function, double q, double *f0), 52 | void * params_for_function, 53 | ErrorMsg errmsg); 54 | 55 | int sort_x_and_w(double *x, double *w, double *workx, double *workw, int startidx, int endidx); 56 | int get_leaf_x_and_w(qss_node *node, int *ind, double *x, double *w,int isindefinite); 57 | int reduce_tree(qss_node *node, int level); 58 | int burn_tree(qss_node *node); 59 | int leaf_count(qss_node *node); 60 | double get_integral(qss_node *node, int level); 61 | int gk_adapt( 62 | qss_node **node, 63 | int (*test)(void * params_for_function, double q, double *psi), 64 | int (*function)(void * params_for_function, double q, double *f0), 65 | void * params_for_function, 66 | double tol, 67 | int treemode, 68 | double a, 69 | double b, 70 | int isindefinite, 71 | ErrorMsg errmsg); 72 | int compute_Hermite(double *x, double *w, int N, int alpha, double *b, double *c); 73 | int compute_Laguerre(double *x, double *w, int N, double alpha, double *b, double *c, int totalweight); 74 | int gk_quad(int (*test)(void * params_for_function, double q, double *psi), 75 | int (*function)(void * params_for_function, double q, double *f0), 76 | void * params_for_function, 77 | qss_node* node, 78 | double a, 79 | double b, 80 | int isindefinite); 81 | double testfun(double x); 82 | 83 | int quadrature_gauss_legendre( 84 | double *mu, 85 | double *w8, 86 | int n, 87 | double tol, 88 | ErrorMsg error_message); 89 | 90 | int quadrature_gauss_legendre_2D( 91 | int n, 92 | double * x, 93 | double * y, 94 | double * w, 95 | ErrorMsg error_message); 96 | 97 | int quadrature_in_rectangle( 98 | double xl, 99 | double xr, 100 | double yl, 101 | double yr, 102 | int *n, 103 | double ** x, 104 | double ** y, 105 | double ** w, 106 | ErrorMsg error_message); 107 | 108 | int cubature_order_eleven( 109 | double xl, 110 | double xr, 111 | double yl, 112 | double yr, 113 | double *x, 114 | double *y, 115 | double *w, 116 | ErrorMsg error_message); 117 | 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /class/include/sparse.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPA__ 2 | #define __SPA__ 3 | /****************************************/ 4 | /* Sparse Matrix algorithms for CLASS */ 5 | /* 15/11 2010 */ 6 | /* Thomas Tram */ 7 | /****************************************/ 8 | #include "common.h" 9 | 10 | /* Structures: */ 11 | typedef struct sparse_matrix{ 12 | /* Sparse matrix in compressed column form: */ 13 | int ncols; /* Number of columns */ 14 | int nrows; /* Number of rows */ 15 | int maxnz; /* Maximum number of non-zero entries*/ 16 | int *Ap; /* Ap[0..ncols]. Ap[k+1]-Ap[k] is the number of entries in the k'th column. */ 17 | int *Ai; /* Ai[0..(maxnz-1)]. Contains the row indices of the entries. */ 18 | double *Ax; /* Ax[0..(maxnz-1)]. Contains the values of the entries. */ 19 | } sp_mat; 20 | 21 | typedef struct sparse_numerical{ 22 | /* Sparse LU decomposition along with enough information to do a fast refactorization: */ 23 | int n; /*Matrix assumed square, [nxn] */ 24 | sp_mat *L; /*L and U is the factors of the decomposed matrix.*/ 25 | sp_mat *U; 26 | int **xi; /*xi[k] points to a row of xi, which holds the topological ordered indices.*/ 27 | int *topvec; /*topvec[k] holds the first index in xi[k].*/ 28 | int *pinv; /*Inverse row permutation. */ 29 | int *p; /*Row permutation. */ 30 | int *q; /* Column permutation */ 31 | int *wamd; /* Work array for sp_amd */ 32 | double *w; /* Work array for sp_lu */ 33 | } sp_num; 34 | 35 | 36 | /** 37 | * Boilerplate for C++ 38 | */ 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | /* Routines and macros: */ 43 | int sp_mat_alloc(sp_mat** A, int ncols, int nrows, int maxnz, ErrorMsg error_message); 44 | int sp_mat_free(sp_mat *A); 45 | int sp_num_alloc(sp_num** N, int n,ErrorMsg error_message); 46 | int sp_num_free(sp_num *N); 47 | int reachr(sp_mat *G, sp_mat *B,int k, int *xik,int *pinv); 48 | void dfsr(int j, sp_mat *G, int *top, int *xik, int *pinv); 49 | int sp_splsolve(sp_mat *G, sp_mat *B, int k, int*xik, int top, double *x, int *pinv); 50 | int sp_ludcmp(sp_num *N, sp_mat *A, double pivtol); 51 | int sp_lusolve(sp_num *N, double *b, double *x); 52 | int sp_refactor(sp_num *N, sp_mat *A); 53 | int column_grouping(sp_mat *G, int *col_g, int *col_wi); 54 | int sp_amd(int *Cp, int *Ci, int n, int cnzmax, int *P, int *W); 55 | int sp_wclear(int mark, int lemax, int *w, int n); 56 | int sp_tdfs(int j, int k, int *head, const int *next, int *post, int *stack); 57 | 58 | 59 | #define SPFLIP(i) (-(i)-2) 60 | #define SPUNFLIP(i) (((i)<0) ? SPFLIP(i) : (i)) 61 | #define SPMARKED(w,j) (w[j] < 0) 62 | #define SPMARK(w,j) {w[j] = SPFLIP(w[j]);} 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /class/include/svnversion.h: -------------------------------------------------------------------------------- 1 | #define _SVN_VERSION_ "6142M" 2 | -------------------------------------------------------------------------------- /class/include/trigonometric_integrals.h: -------------------------------------------------------------------------------- 1 | /** 2 | * definitions for module trigonometric_integrals.c 3 | */ 4 | 5 | #ifndef __TRIGONOMETRIC_INTEGRALS__ 6 | #define __TRIGONOMETRIC_INTEGRALS__ 7 | 8 | #include "common.h" 9 | 10 | /** 11 | * Boilerplate for C++ 12 | */ 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | int cosine_integral( 18 | double x, 19 | double *Ci, 20 | ErrorMsg error_message 21 | ); 22 | 23 | int sine_integral( 24 | double x, 25 | double *Si, 26 | ErrorMsg error_message 27 | ); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /class/main/class.c: -------------------------------------------------------------------------------- 1 | /** @file class.c 2 | * Julien Lesgourgues, 17.04.2011 3 | */ 4 | 5 | #include "class.h" 6 | 7 | int main(int argc, char **argv) { 8 | 9 | struct precision pr; /* for precision parameters */ 10 | struct background ba; /* for cosmological background */ 11 | struct thermo th; /* for thermodynamics */ 12 | struct perturbs pt; /* for source functions */ 13 | struct primordial pm; /* for primordial spectra */ 14 | struct nonlinear nl; /* for non-linear spectra */ 15 | struct transfers tr; /* for transfer functions */ 16 | struct spectra sp; /* for output spectra */ 17 | struct lensing le; /* for lensed spectra */ 18 | struct output op; /* for output files */ 19 | ErrorMsg errmsg; /* for error messages */ 20 | 21 | if (input_init_from_arguments(argc, argv,&pr,&ba,&th,&pt,&tr,&pm,&sp,&nl,&le,&op,errmsg) == _FAILURE_) { 22 | printf("\n\nError running input_init_from_arguments \n=>%s\n",errmsg); 23 | return _FAILURE_; 24 | } 25 | 26 | if (background_init(&pr,&ba) == _FAILURE_) { 27 | printf("\n\nError running background_init \n=>%s\n",ba.error_message); 28 | return _FAILURE_; 29 | } 30 | 31 | if (thermodynamics_init(&pr,&ba,&th) == _FAILURE_) { 32 | printf("\n\nError in thermodynamics_init \n=>%s\n",th.error_message); 33 | return _FAILURE_; 34 | } 35 | 36 | if (perturb_init(&pr,&ba,&th,&pt) == _FAILURE_) { 37 | printf("\n\nError in perturb_init \n=>%s\n",pt.error_message); 38 | return _FAILURE_; 39 | } 40 | 41 | if (primordial_init(&pr,&pt,&pm) == _FAILURE_) { 42 | printf("\n\nError in primordial_init \n=>%s\n",pm.error_message); 43 | return _FAILURE_; 44 | } 45 | 46 | if (nonlinear_init(&pr,&ba,&th,&pt,&pm,&nl) == _FAILURE_) { 47 | printf("\n\nError in nonlinear_init \n=>%s\n",nl.error_message); 48 | return _FAILURE_; 49 | } 50 | 51 | if (transfer_init(&pr,&ba,&th,&pt,&nl,&tr) == _FAILURE_) { 52 | printf("\n\nError in transfer_init \n=>%s\n",tr.error_message); 53 | return _FAILURE_; 54 | } 55 | 56 | if (spectra_init(&pr,&ba,&pt,&pm,&nl,&tr,&sp) == _FAILURE_) { 57 | printf("\n\nError in spectra_init \n=>%s\n",sp.error_message); 58 | return _FAILURE_; 59 | } 60 | 61 | if (lensing_init(&pr,&pt,&sp,&nl,&le) == _FAILURE_) { 62 | printf("\n\nError in lensing_init \n=>%s\n",le.error_message); 63 | return _FAILURE_; 64 | } 65 | 66 | if (output_init(&ba,&th,&pt,&pm,&tr,&sp,&nl,&le,&op) == _FAILURE_) { 67 | printf("\n\nError in output_init \n=>%s\n",op.error_message); 68 | return _FAILURE_; 69 | } 70 | 71 | /****** all calculations done, now free the structures ******/ 72 | 73 | if (lensing_free(&le) == _FAILURE_) { 74 | printf("\n\nError in lensing_free \n=>%s\n",le.error_message); 75 | return _FAILURE_; 76 | } 77 | 78 | if (spectra_free(&sp) == _FAILURE_) { 79 | printf("\n\nError in spectra_free \n=>%s\n",sp.error_message); 80 | return _FAILURE_; 81 | } 82 | 83 | if (transfer_free(&tr) == _FAILURE_) { 84 | printf("\n\nError in transfer_free \n=>%s\n",tr.error_message); 85 | return _FAILURE_; 86 | } 87 | 88 | if (nonlinear_free(&nl) == _FAILURE_) { 89 | printf("\n\nError in nonlinear_free \n=>%s\n",nl.error_message); 90 | return _FAILURE_; 91 | } 92 | 93 | if (primordial_free(&pm) == _FAILURE_) { 94 | printf("\n\nError in primordial_free \n=>%s\n",pm.error_message); 95 | return _FAILURE_; 96 | } 97 | 98 | if (perturb_free(&pt) == _FAILURE_) { 99 | printf("\n\nError in perturb_free \n=>%s\n",pt.error_message); 100 | return _FAILURE_; 101 | } 102 | 103 | if (thermodynamics_free(&th) == _FAILURE_) { 104 | printf("\n\nError in thermodynamics_free \n=>%s\n",th.error_message); 105 | return _FAILURE_; 106 | } 107 | 108 | if (background_free(&ba) == _FAILURE_) { 109 | printf("\n\nError in background_free \n=>%s\n",ba.error_message); 110 | return _FAILURE_; 111 | } 112 | 113 | return _SUCCESS_; 114 | 115 | } 116 | -------------------------------------------------------------------------------- /class/myevolution.dat: -------------------------------------------------------------------------------- 1 | 0.1 0.0010000000000000002 2 | 0.2 0.008 3 | 0.3 0.02699999999999939 4 | 0.4 0.0639999999999378 5 | 0.5 0.1249999999977896 6 | 0.6 0.21599999995913313 7 | 0.7 0.34299999951858506 8 | 0.8 0.5119999959225299 9 | 0.9 0.728999973156994 10 | 1. 0.999999855139168 11 | 1.1 1.330999334368509 12 | 1.2 1.7279973217531261 13 | 1.3 2.196990360740088 14 | 1.4 2.743968450165843 15 | 1.5 3.3749048508244637 16 | 1.6 4.095732787627785 17 | 1.7 4.912295140442309 18 | 1.8 5.830241082017937 19 | 1.9 6.854822885825836 20 | 2. 7.990512030628799 21 | 2.1 9.240299830454715 22 | 2.2 10.604466399010644 23 | 2.3 12.078486025087846 24 | 2.4 13.649587865208744 25 | 2.5 15.291333774900915 26 | 2.6 16.955497974925894 27 | 2.7 18.56075979355865 28 | 2.8 19.97872820320106 29 | 2.9 21.02045222024772 30 | 3. 21.431930578229572 31 | 3.1 20.915524906920037 32 | 3.2 19.201919576687313 33 | 3.3 16.190881291907615 34 | 3.4 12.133254618683612 35 | 3.5 7.729006674620789 36 | 3.6 3.942205156623325 37 | 3.7 1.4868118911900279 38 | 3.8 0.3732807590089654 39 | 3.9 0.05436027966326381 40 | 4. 0.003838922724865479 41 | 4.1 0.00010430820255980766 42 | 4.2 8.102007168749191e-7 43 | 4.3 1.2314496393552691e-9 44 | 4.4 2.2644902011221728e-13 45 | 4.5 2.7467569667648903e-18 46 | 4.6 1.0265616267989809e-24 47 | -------------------------------------------------------------------------------- /class/myselection.dat: -------------------------------------------------------------------------------- 1 | 0.0 0.0 2 | 0.1 0.030591786603680816 3 | 0.2 0.10619451692325403 4 | 0.30000000000000004 0.19886750367043496 5 | 0.4 0.28446992920441827 6 | 0.5 0.34735619337280493 7 | 0.6 0.38083288182668446 8 | 0.7000000000000001 0.3853875240364537 9 | 0.8 0.3660955463257228 10 | 0.9 0.330122848124979 11 | 1. 0.2848017764321144 12 | -------------------------------------------------------------------------------- /class/output/README: -------------------------------------------------------------------------------- 1 | CLASS will put output here when run in C. 2 | -------------------------------------------------------------------------------- /class/pk_ref.pre: -------------------------------------------------------------------------------- 1 | # this file achieves maximum precision for the CMB: each ClTT and ClEE, lensed and unlensed, are stable at the 0.01% level 2 | 3 | tol_ncdm_bg = 1.e-10 4 | 5 | recfast_Nz0=100000 6 | tol_thermo_integration=1.e-5 7 | 8 | recfast_x_He0_trigger_delta = 0.01 9 | recfast_x_H0_trigger_delta = 0.01 10 | 11 | evolver=0 12 | 13 | k_min_tau0=0.002 14 | k_max_tau0_over_l_max=3. 15 | k_step_sub=0.015 16 | k_step_super=0.0001 17 | k_step_super_reduction=0.1 18 | 19 | start_small_k_at_tau_c_over_tau_h = 0.0004 20 | start_large_k_at_tau_h_over_tau_k = 0.05 21 | tight_coupling_trigger_tau_c_over_tau_h=0.005 22 | tight_coupling_trigger_tau_c_over_tau_k=0.008 23 | start_sources_at_tau_c_over_tau_h = 0.006 24 | 25 | l_max_g=50 26 | l_max_pol_g=25 27 | l_max_ur=150 28 | l_max_ncdm=50 29 | 30 | tol_perturb_integration=1.e-6 31 | perturb_sampling_stepsize=0.01 32 | 33 | radiation_streaming_approximation = 2 34 | radiation_streaming_trigger_tau_over_tau_k = 240. 35 | radiation_streaming_trigger_tau_c_over_tau = 100. 36 | 37 | ur_fluid_approximation = 2 38 | ur_fluid_trigger_tau_over_tau_k = 50. 39 | 40 | ncdm_fluid_approximation = 3 41 | ncdm_fluid_trigger_tau_over_tau_k = 51. 42 | 43 | tol_ncdm_synchronous = 1.e-10 44 | tol_ncdm_newtonian = 1.e-10 45 | 46 | l_logstep=1.026 47 | l_linstep=25 48 | 49 | hyper_sampling_flat = 12. 50 | hyper_sampling_curved_low_nu = 10. 51 | hyper_sampling_curved_high_nu = 10. 52 | hyper_nu_sampling_step = 10. 53 | hyper_phi_min_abs = 1.e-10 54 | hyper_x_tol = 1.e-4 55 | hyper_flat_approximation_nu = 1.e6 56 | 57 | q_linstep=0.20 58 | q_logstep_spline= 20. 59 | q_logstep_trapzd = 0.5 60 | q_numstep_transition = 250 61 | 62 | transfer_neglect_delta_k_S_t0 = 100. 63 | transfer_neglect_delta_k_S_t1 = 100. 64 | transfer_neglect_delta_k_S_t2 = 100. 65 | transfer_neglect_delta_k_S_e = 100. 66 | transfer_neglect_delta_k_V_t1 = 100. 67 | transfer_neglect_delta_k_V_t2 = 100. 68 | transfer_neglect_delta_k_V_e = 100. 69 | transfer_neglect_delta_k_V_b = 100. 70 | transfer_neglect_delta_k_T_t2 = 100. 71 | transfer_neglect_delta_k_T_e = 100. 72 | transfer_neglect_delta_k_T_b = 100. 73 | 74 | neglect_CMB_sources_below_visibility = 1.e-30 75 | transfer_neglect_late_source = 3000. 76 | 77 | halofit_k_per_decade = 3000. 78 | 79 | l_switch_limber = 40. 80 | accurate_lensing=1 81 | num_mu_minus_lmax = 1000. 82 | delta_l_max = 1000. -------------------------------------------------------------------------------- /class/psd_FD_single.dat: -------------------------------------------------------------------------------- 1 | 0.0000000e+000 4.0314418e-003 2 | 1.2121212e-001 3.7874107e-003 3 | 2.4242424e-001 3.5451614e-003 4 | 3.6363636e-001 3.3064240e-003 5 | 4.8484848e-001 3.0728285e-003 6 | 6.0606061e-001 2.8458621e-003 7 | 7.2727273e-001 2.6268350e-003 8 | 8.4848485e-001 2.4168557e-003 9 | 9.6969697e-001 2.2168165e-003 10 | 1.0909091e+000 2.0273889e-003 11 | 1.2121212e+000 1.8490284e-003 12 | 1.3333333e+000 1.6819863e-003 13 | 1.4545455e+000 1.5263281e-003 14 | 1.5757576e+000 1.3819553e-003 15 | 1.6969697e+000 1.2486299e-003 16 | 1.8181818e+000 1.1259993e-003 17 | 1.9393939e+000 1.0136210e-003 18 | 2.0606061e+000 9.1098552e-004 19 | 2.1818182e+000 8.1753726e-004 20 | 2.3030303e+000 7.3269281e-004 21 | 2.4242424e+000 6.5585650e-004 22 | 2.5454545e+000 5.8643326e-004 23 | 2.6666667e+000 5.2383885e-004 24 | 2.7878788e+000 4.6750783e-004 25 | 2.9090909e+000 4.1689940e-004 26 | 3.0303030e+000 3.7150144e-004 27 | 3.1515152e+000 3.3083316e-004 28 | 3.2727273e+000 2.9444641e-004 29 | 3.3939394e+000 2.6192609e-004 30 | 3.5151515e+000 2.3288982e-004 31 | 3.6363636e+000 2.0698701e-004 32 | 3.7575758e+000 1.8389754e-004 33 | 3.8787879e+000 1.6333015e-004 34 | 4.0000000e+000 1.4502072e-004 35 | 4.1212121e+000 1.2873034e-004 36 | 4.2424242e+000 1.1424347e-004 37 | 4.3636364e+000 1.0136608e-004 38 | 4.4848485e+000 8.9923795e-005 39 | 4.6060606e+000 7.9760183e-005 40 | 4.7272727e+000 7.0735118e-005 41 | 4.8484848e+000 6.2723239e-005 42 | 4.9696970e+000 5.5612518e-005 43 | 5.0909091e+000 4.9302948e-005 44 | 5.2121212e+000 4.3705328e-005 45 | 5.3333333e+000 3.8740163e-005 46 | 5.4545455e+000 3.4336653e-005 47 | 5.5757576e+000 3.0431782e-005 48 | 5.6969697e+000 2.6969493e-005 49 | 5.8181818e+000 2.3899944e-005 50 | 5.9393939e+000 2.1178837e-005 51 | 6.0606061e+000 1.8766816e-005 52 | 6.1818182e+000 1.6628928e-005 53 | 6.3030303e+000 1.4734139e-005 54 | 6.4242424e+000 1.3054902e-005 55 | 6.5454545e+000 1.1566771e-005 56 | 6.6666667e+000 1.0248056e-005 57 | 6.7878788e+000 9.0795173e-006 58 | 6.9090909e+000 8.0440884e-006 59 | 7.0303030e+000 7.1266354e-006 60 | 7.1515152e+000 6.3137388e-006 61 | 7.2727273e+000 5.5935005e-006 62 | 7.3939394e+000 4.9553726e-006 63 | 7.5151515e+000 4.3900052e-006 64 | 7.6363636e+000 3.8891104e-006 65 | 7.7575758e+000 3.4453427e-006 66 | 7.8787879e+000 3.0521921e-006 67 | 8.0000000e+000 2.7038891e-006 68 | 8.1212121e+000 2.3953211e-006 69 | 8.2424242e+000 2.1219577e-006 70 | 8.3636364e+000 1.8797842e-006 71 | 8.4848485e+000 1.6652437e-006 72 | 8.6060606e+000 1.4751843e-006 73 | 8.7272727e+000 1.3068135e-006 74 | 8.8484848e+000 1.1576570e-006 75 | 8.9696970e+000 1.0255226e-006 76 | 9.0909091e+000 9.0846835e-007 77 | 9.2121212e+000 8.0477343e-007 78 | 9.3333333e+000 7.1291348e-007 79 | 9.4545455e+000 6.3153795e-007 80 | 9.5757576e+000 5.5945039e-007 81 | 9.6969697e+000 4.9559083e-007 82 | 9.8181818e+000 4.3902025e-007 83 | 9.9393939e+000 3.8890677e-007 84 | 1.0060606e+001 3.4451341e-007 85 | 1.0181818e+001 3.0518733e-007 86 | 1.0303030e+001 2.7035015e-007 87 | 1.0424242e+001 2.3948953e-007 88 | 1.0545455e+001 2.1215157e-007 89 | 1.0666667e+001 1.8793419e-007 90 | 1.0787879e+001 1.6648120e-007 91 | 1.0909091e+001 1.4747706e-007 92 | 1.1030303e+001 1.3064224e-007 93 | 1.1151515e+001 1.1572912e-007 94 | 1.1272727e+001 1.0251835e-007 95 | 1.1393939e+001 9.0815608e-008 96 | 1.1515152e+001 8.0448749e-008 97 | 1.1636364e+001 7.1265286e-008 98 | 1.1757576e+001 6.3130135e-008 99 | 1.1878788e+001 5.5923630e-008 100 | 1.2000000e+001 4.9539765e-008 101 | -------------------------------------------------------------------------------- /class/python/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwt5345/class_ede_v2/fc9a9fd79673a0022b766523f5f51dea1e3fab57/class/python/.DS_Store -------------------------------------------------------------------------------- /class/python/README: -------------------------------------------------------------------------------- 1 | To use this python wrapper for class, you should first compile class with 'make all', not just 'make class': this is important in order to create libraries. Be sure that you did not remove the -fPIC compiling flag in the Makefile, important for compatibility between OpenMP and the python wrapper. 2 | 3 | Check that the command 'python' points towards a version of python > 2.7 but < 3.0. Then, execute: 4 | 5 | > python setup.py build 6 | > python setup.py install --user 7 | 8 | (it's really 'user', not your own user name). 9 | 10 | You can check that these steps worked by typing 11 | 12 | > python 13 | >>> from classy import Class 14 | 15 | If python does not complain, the Class module has been correctly installed in your python distribution. You can now import it and use its functions from your python codes. -------------------------------------------------------------------------------- /class/python/extract_errors.py: -------------------------------------------------------------------------------- 1 | # From the dumped stdout and stderr of a nosetests test_class.py, extract all 2 | # the failed steps. 3 | # Usage: python extract_errors.py output 4 | from __future__ import print_function 5 | import sys 6 | import os 7 | 8 | 9 | def main(path): 10 | """ 11 | Create a shorter file containing only the errors from nosetests 12 | 13 | """ 14 | assert os.path.isfile(path) is True 15 | 16 | trimmed_path = path + '_errors' 17 | destination = open(trimmed_path, 'w') 18 | contains_error = False 19 | with open(path, 'r') as source: 20 | text = source.readlines() 21 | start = 0 22 | for index, line in enumerate(text): 23 | if line.find('------------------') != -1: 24 | if text[index+2].find('----------------') != -1: 25 | stop = index-1 26 | # Check that an error is contained 27 | if stop > 0: 28 | for i in range(start, stop+1): 29 | if text[i].startswith('E'): 30 | contains_error = True 31 | if contains_error: 32 | print('Found an error') 33 | for i in range(start, stop+1): 34 | print(text[i], end=' ') 35 | destination.write(text[i]) 36 | start = index 37 | contains_error = False 38 | elif text[index+2].find('=================') != -1: 39 | break 40 | else: 41 | pass 42 | destination.close() 43 | 44 | 45 | if __name__ == "__main__": 46 | print(sys.argv) 47 | if len(sys.argv) != 2: 48 | print('Please specify the output file to analyse') 49 | exit() 50 | else: 51 | main(sys.argv[-1]) 52 | -------------------------------------------------------------------------------- /class/python/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | from distutils.extension import Extension 3 | from Cython.Distutils import build_ext 4 | 5 | import numpy as nm 6 | import os 7 | import subprocess as sbp 8 | import os.path as osp 9 | 10 | # Recover the gcc compiler 11 | GCCPATH_STRING = sbp.Popen( 12 | ['gcc', '-print-libgcc-file-name'], 13 | stdout=sbp.PIPE).communicate()[0] 14 | GCCPATH = osp.normpath(osp.dirname(GCCPATH_STRING)).decode() 15 | 16 | liblist = ["class"] 17 | MVEC_STRING = sbp.Popen( 18 | ['gcc', '-lmvec'], 19 | stderr=sbp.PIPE).communicate()[1] 20 | if b"mvec" not in MVEC_STRING: 21 | liblist += ["mvec","m"] 22 | 23 | # define absolute paths 24 | root_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") 25 | include_folder = os.path.join(root_folder, "include") 26 | classy_folder = os.path.join(root_folder, "python") 27 | 28 | # Recover the CLASS version 29 | with open(os.path.join(include_folder, 'common.h'), 'r') as v_file: 30 | for line in v_file: 31 | if line.find("_VERSION_") != -1: 32 | # get rid of the " and the v 33 | VERSION = line.split()[-1][2:-1] 34 | break 35 | 36 | setup( 37 | name='classy', 38 | version=VERSION, 39 | description='Python interface to the Cosmological Boltzmann code CLASS', 40 | url='http://www.class-code.net', 41 | cmdclass={'build_ext': build_ext}, 42 | ext_modules=[Extension("classy", [os.path.join(classy_folder, "classy.pyx")], 43 | include_dirs=[nm.get_include(), include_folder], 44 | libraries=liblist, 45 | library_dirs=[root_folder, GCCPATH], 46 | extra_link_args=['-lgomp'], 47 | )], 48 | #data_files=[('bbn', ['../bbn/sBBN.dat'])] 49 | ) 50 | -------------------------------------------------------------------------------- /class/scripts/cltt_terms.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # In[ ]: 5 | 6 | # import necessary modules 7 | # uncomment to get plots displayed in notebook 8 | #%matplotlib inline 9 | import matplotlib 10 | import matplotlib.pyplot as plt 11 | import numpy as np 12 | from classy import Class 13 | from scipy.optimize import fsolve 14 | from scipy.interpolate import interp1d 15 | import math 16 | 17 | 18 | # In[ ]: 19 | 20 | # esthetic definitions for the plots 21 | font = {'size' : 16, 'family':'STIXGeneral'} 22 | axislabelfontsize='large' 23 | matplotlib.rc('font', **font) 24 | matplotlib.mathtext.rcParams['legend.fontsize']='medium' 25 | plt.rcParams["figure.figsize"] = [8.0,6.0] 26 | 27 | 28 | # In[ ]: 29 | 30 | ############################################# 31 | # 32 | # Cosmological parameters and other CLASS parameters 33 | # 34 | common_settings = {# wich output? ClTT, transfer functions delta_i and theta_i 35 | 'output':'tCl,pCl,lCl', 36 | 'lensing':'yes', 37 | # LambdaCDM parameters 38 | 'h':0.67556, 39 | 'omega_b':0.022032, 40 | 'omega_cdm':0.12038, 41 | 'A_s':2.215e-9, 42 | 'n_s':0.9619, 43 | 'tau_reio':0.0925, 44 | # Take fixed value for primordial Helium (instead of automatic BBN adjustment) 45 | 'YHe':0.246, 46 | # other output and precision parameters 47 | 'l_max_scalars':5000} 48 | ############### 49 | # 50 | # call CLASS 51 | # 52 | M = Class() 53 | M.set(common_settings) 54 | M.compute() 55 | cl_tot = M.raw_cl(3000) 56 | cl_lensed = M.lensed_cl(3000) 57 | M.struct_cleanup() # clean output 58 | M.empty() # clean input 59 | # 60 | M.set(common_settings) # new input 61 | M.set({'temperature contributions':'tsw'}) 62 | M.compute() 63 | cl_tsw = M.raw_cl(3000) 64 | M.struct_cleanup() 65 | M.empty() 66 | # 67 | M.set(common_settings) 68 | M.set({'temperature contributions':'eisw'}) 69 | M.compute() 70 | cl_eisw = M.raw_cl(3000) 71 | M.struct_cleanup() 72 | M.empty() 73 | # 74 | M.set(common_settings) 75 | M.set({'temperature contributions':'lisw'}) 76 | M.compute() 77 | cl_lisw = M.raw_cl(3000) 78 | M.struct_cleanup() 79 | M.empty() 80 | # 81 | M.set(common_settings) 82 | M.set({'temperature contributions':'dop'}) 83 | M.compute() 84 | cl_dop = M.raw_cl(3000) 85 | # 86 | ################# 87 | # 88 | # start plotting 89 | # 90 | ################# 91 | # 92 | plt.xlim([2,3000]) 93 | plt.xlabel(r"$\ell$") 94 | plt.ylabel(r"$\ell (\ell+1) C_l^{TT} / 2 \pi \,\,\, [\times 10^{10}]$") 95 | plt.grid() 96 | # 97 | ell = cl_tot['ell'] 98 | factor = 1.e10*ell*(ell+1.)/2./math.pi 99 | plt.semilogx(ell,factor*cl_tsw['tt'],'c-',label=r'$\mathrm{T+SW}$') 100 | plt.semilogx(ell,factor*cl_eisw['tt'],'r-',label=r'$\mathrm{early-ISW}$') 101 | plt.semilogx(ell,factor*cl_lisw['tt'],'y-',label=r'$\mathrm{late-ISW}$') 102 | plt.semilogx(ell,factor*cl_dop['tt'],'g-',label=r'$\mathrm{Doppler}$') 103 | plt.semilogx(ell,factor*cl_tot['tt'],'r-',label=r'$\mathrm{total}$') 104 | plt.semilogx(ell,factor*cl_lensed['tt'],'k-',label=r'$\mathrm{lensed}$') 105 | # 106 | plt.legend(loc='right',bbox_to_anchor=(1.4, 0.5)) 107 | 108 | 109 | # In[ ]: 110 | 111 | plt.savefig('cltt_terms.pdf',bbox_inches='tight') 112 | -------------------------------------------------------------------------------- /class/scripts/distances.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # In[ ]: 5 | 6 | # import necessary modules 7 | # uncomment to get plots displayed in notebook 8 | #%matplotlib inline 9 | import matplotlib 10 | import matplotlib.pyplot as plt 11 | import numpy as np 12 | from classy import Class 13 | 14 | 15 | # In[ ]: 16 | 17 | font = {'size' : 20, 'family':'STIXGeneral'} 18 | axislabelfontsize='large' 19 | matplotlib.rc('font', **font) 20 | matplotlib.mathtext.rcParams['legend.fontsize']='medium' 21 | 22 | 23 | # In[ ]: 24 | 25 | #Lambda CDM 26 | LCDM = Class() 27 | LCDM.set({'Omega_cdm':0.25,'Omega_b':0.05}) 28 | LCDM.compute() 29 | 30 | 31 | # In[ ]: 32 | 33 | #Einstein-de Sitter 34 | CDM = Class() 35 | CDM.set({'Omega_cdm':0.95,'Omega_b':0.05}) 36 | CDM.compute() 37 | 38 | # Just to cross-check that Omega_Lambda is negligible 39 | # (but not exactly zero because we neglected radiation) 40 | derived = CDM.get_current_derived_parameters(['Omega0_lambda']) 41 | print derived 42 | print "Omega_Lambda =",derived['Omega0_lambda'] 43 | 44 | 45 | # In[ ]: 46 | 47 | #Get background quantities and recover their names: 48 | baLCDM = LCDM.get_background() 49 | baCDM = CDM.get_background() 50 | baCDM.viewkeys() 51 | 52 | 53 | # In[ ]: 54 | 55 | #Get H_0 in order to plot the distances in this unit 56 | fLCDM = LCDM.Hubble(0) 57 | fCDM = CDM.Hubble(0) 58 | 59 | 60 | # In[ ]: 61 | 62 | namelist = ['lum. dist.','comov. dist.','ang.diam.dist.'] 63 | colours = ['b','g','r'] 64 | for name in namelist: 65 | idx = namelist.index(name) 66 | plt.loglog(baLCDM['z'],fLCDM*baLCDM[name],colours[idx]+'-') 67 | plt.legend(namelist,loc='upper left') 68 | for name in namelist: 69 | idx = namelist.index(name) 70 | plt.loglog(baCDM['z'],fCDM*baCDM[name],colours[idx]+'--') 71 | plt.xlim([0.07, 10]) 72 | plt.ylim([0.08, 20]) 73 | 74 | plt.xlabel(r"$z$") 75 | plt.ylabel(r"$\mathrm{Distance}\times H_0$") 76 | plt.tight_layout() 77 | 78 | 79 | # In[ ]: 80 | 81 | plt.savefig('distances.pdf') 82 | -------------------------------------------------------------------------------- /class/scripts/neutrinohierarchy.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # In[1]: 5 | 6 | # import necessary modules 7 | # uncomment to get plots displayed in notebook 8 | #%matplotlib inline 9 | import matplotlib 10 | import matplotlib.pyplot as plt 11 | import numpy as np 12 | from classy import Class 13 | from scipy.optimize import fsolve 14 | 15 | 16 | # In[2]: 17 | 18 | # esthetic definitions for the plots 19 | font = {'size' : 16, 'family':'STIXGeneral'} 20 | axislabelfontsize='large' 21 | matplotlib.rc('font', **font) 22 | matplotlib.mathtext.rcParams['legend.fontsize']='medium' 23 | 24 | 25 | # In[3]: 26 | 27 | # a function returning the three masses given the Delta m^2, the total mass, and the hierarchy (e.g. 'IN' or 'IH') 28 | # taken from a piece of MontePython written by Thejs Brinckmann 29 | def get_masses(delta_m_squared_atm, delta_m_squared_sol, sum_masses, hierarchy): 30 | # any string containing letter 'n' will be considered as refering to normal hierarchy 31 | if 'n' in hierarchy.lower(): 32 | # Normal hierarchy massive neutrinos. Calculates the individual 33 | # neutrino masses from M_tot_NH and deletes M_tot_NH 34 | #delta_m_squared_atm=2.45e-3 35 | #delta_m_squared_sol=7.50e-5 36 | m1_func = lambda m1, M_tot, d_m_sq_atm, d_m_sq_sol: M_tot**2. + 0.5*d_m_sq_sol - d_m_sq_atm + m1**2. - 2.*M_tot*m1 - 2.*M_tot*(d_m_sq_sol+m1**2.)**0.5 + 2.*m1*(d_m_sq_sol+m1**2.)**0.5 37 | m1,opt_output,success,output_message = fsolve(m1_func,sum_masses/3.,(sum_masses,delta_m_squared_atm,delta_m_squared_sol),full_output=True) 38 | m1 = m1[0] 39 | m2 = (delta_m_squared_sol + m1**2.)**0.5 40 | m3 = (delta_m_squared_atm + 0.5*(m2**2. + m1**2.))**0.5 41 | return m1,m2,m3 42 | else: 43 | # Inverted hierarchy massive neutrinos. Calculates the individual 44 | # neutrino masses from M_tot_IH and deletes M_tot_IH 45 | #delta_m_squared_atm=-2.45e-3 46 | #delta_m_squared_sol=7.50e-5 47 | delta_m_squared_atm = -delta_m_squared_atm 48 | m1_func = lambda m1, M_tot, d_m_sq_atm, d_m_sq_sol: M_tot**2. + 0.5*d_m_sq_sol - d_m_sq_atm + m1**2. - 2.*M_tot*m1 - 2.*M_tot*(d_m_sq_sol+m1**2.)**0.5 + 2.*m1*(d_m_sq_sol+m1**2.)**0.5 49 | m1,opt_output,success,output_message = fsolve(m1_func,sum_masses/3.,(sum_masses,delta_m_squared_atm,delta_m_squared_sol),full_output=True) 50 | m1 = m1[0] 51 | m2 = (delta_m_squared_sol + m1**2.)**0.5 52 | m3 = (delta_m_squared_atm + 0.5*(m2**2. + m1**2.))**0.5 53 | return m1,m2,m3 54 | 55 | 56 | # In[4]: 57 | 58 | # test of this function, returning the 3 masses for total mass of 0.1eV 59 | m1,m2,m3 = get_masses(2.45e-3,7.50e-5,0.1,'NH') 60 | print 'NH:',m1,m2,m3,m1+m2+m3 61 | m1,m2,m3 = get_masses(2.45e-3,7.50e-5,0.1,'IH') 62 | print 'IH:',m1,m2,m3,m1+m2+m3 63 | 64 | 65 | # In[5]: 66 | 67 | # The goal of this cell is to compute the ratio of P(k) for NH and IH with the same total mass 68 | commonsettings = {'N_ur':0, 69 | 'N_ncdm':3, 70 | 'output':'mPk', 71 | 'P_k_max_1/Mpc':3.0, 72 | # The next line should be uncommented fgor higher precision (but significantly slower running) 73 | 'ncdm_fluid_approximation':3, 74 | # You may uncomment this line to get more info on the ncdm sector from Class: 75 | 'background_verbose':1 76 | } 77 | 78 | # array of k values in 1/Mpc 79 | kvec = np.logspace(-4,np.log10(3),100) 80 | # array for storing legend 81 | legarray = [] 82 | 83 | # loop over total mass values 84 | for sum_masses in [0.1, 0.115, 0.13]: 85 | # normal hierarchy 86 | [m1, m2, m3] = get_masses(2.45e-3,7.50e-5, sum_masses, 'NH') 87 | NH = Class() 88 | NH.set(commonsettings) 89 | NH.set({'m_ncdm':str(m1)+','+str(m2)+','+str(m3)}) 90 | NH.compute() 91 | # inverted hierarchy 92 | [m1, m2, m3] = get_masses(2.45e-3,7.50e-5, sum_masses, 'IH') 93 | IH = Class() 94 | IH.set(commonsettings) 95 | IH.set({'m_ncdm':str(m1)+','+str(m2)+','+str(m3)}) 96 | IH.compute() 97 | pkNH = [] 98 | pkIH = [] 99 | for k in kvec: 100 | pkNH.append(NH.pk(k,0.)) 101 | pkIH.append(IH.pk(k,0.)) 102 | NH.struct_cleanup() 103 | IH.struct_cleanup() 104 | # extract h value to convert k from 1/Mpc to h/Mpc 105 | h = NH.h() 106 | plt.semilogx(kvec/h,1-np.array(pkNH)/np.array(pkIH)) 107 | legarray.append(r'$\Sigma m_i = '+str(sum_masses)+'$eV') 108 | 109 | plt.axhline(0,color='k') 110 | plt.xlim(kvec[0]/h,kvec[-1]/h) 111 | plt.xlabel(r'$k [h \mathrm{Mpc}^{-1}]$') 112 | plt.ylabel(r'$1-P(k)^\mathrm{NH}/P(k)^\mathrm{IH}$') 113 | plt.legend(legarray) 114 | 115 | 116 | # In[6]: 117 | 118 | plt.savefig('neutrinohierarchy.pdf') 119 | -------------------------------------------------------------------------------- /class/scripts/thermo.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # In[ ]: 5 | 6 | # import necessary modules 7 | # uncomment to get plots displayed in notebook 8 | #%matplotlib inline 9 | import matplotlib 10 | import matplotlib.pyplot as plt 11 | import numpy as np 12 | from classy import Class 13 | from scipy.optimize import fsolve 14 | from scipy.interpolate import interp1d 15 | import math 16 | 17 | 18 | # In[ ]: 19 | 20 | # esthetic definitions for the plots 21 | font = {'size' : 16, 'family':'STIXGeneral'} 22 | axislabelfontsize='large' 23 | matplotlib.rc('font', **font) 24 | matplotlib.mathtext.rcParams['legend.fontsize']='medium' 25 | plt.rcParams["figure.figsize"] = [8.0,6.0] 26 | 27 | 28 | # In[ ]: 29 | 30 | common_settings = {'output' : 'tCl', 31 | # LambdaCDM parameters 32 | 'h':0.67556, 33 | 'omega_b':0.022032, 34 | 'omega_cdm':0.12038, 35 | 'A_s':2.215e-9, 36 | 'n_s':0.9619, 37 | 'tau_reio':0.0925, 38 | # Take fixed value for primordial Helium (instead of automatic BBN adjustment) 39 | 'YHe':0.246, 40 | 'thermodynamics_verbose':1 41 | } 42 | ############## 43 | # 44 | # call CLASS 45 | # 46 | ############### 47 | M = Class() 48 | M.set(common_settings) 49 | M.compute() 50 | derived = M.get_current_derived_parameters(['tau_rec','conformal_age']) 51 | thermo = M.get_thermodynamics() 52 | print thermo.viewkeys() 53 | 54 | 55 | # In[ ]: 56 | 57 | tau = thermo['conf. time [Mpc]'] 58 | g = thermo['g [Mpc^-1]'] 59 | # to make the reionisation peak visible, rescale g by 100 for late times 60 | g[:500] *= 100 61 | ################# 62 | # 63 | # start plotting 64 | # 65 | ################# 66 | # 67 | plt.xlim([1.e2,derived['conformal_age']]) 68 | plt.xlabel(r'$\tau \,\,\, \mathrm{[Mpc]}$') 69 | plt.ylabel(r'$\mathrm{visibility} \,\,\, g \,\,\, [\mathrm{Mpc}^{-1}]$') 70 | plt.axvline(x=derived['tau_rec'],color='k') 71 | # The conformal time at reionisation could be extracted from the code. 72 | # But we know it because it is part of the standard output 73 | # when thermodynamics_verbose=1 74 | plt.axvline(x=4255.316282,color='k') 75 | # 76 | # Print functions one by one, saving between each (for slides) 77 | # 78 | plt.semilogx(tau,g,'r',label=r'$\psi$') 79 | 80 | 81 | # In[ ]: 82 | 83 | plt.savefig('thermo.pdf',bbox_inches='tight') 84 | -------------------------------------------------------------------------------- /class/scripts/varying_pann.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # In[ ]: 5 | 6 | # import necessary modules 7 | # uncomment to get plots displayed in notebook 8 | #%matplotlib inline 9 | import matplotlib 10 | import matplotlib.pyplot as plt 11 | import numpy as np 12 | from classy import Class 13 | from scipy.optimize import fsolve 14 | import math 15 | 16 | 17 | # In[ ]: 18 | 19 | # esthetic definitions for the plots 20 | font = {'size' : 16, 'family':'STIXGeneral'} 21 | axislabelfontsize='large' 22 | matplotlib.rc('font', **font) 23 | matplotlib.mathtext.rcParams['legend.fontsize']='medium' 24 | plt.rcParams["figure.figsize"] = [8.0,6.0] 25 | 26 | 27 | # In[ ]: 28 | 29 | ############################################ 30 | # 31 | # Varying parameter (others fixed to default) 32 | # 33 | var_name = 'annihilation' 34 | var_array = np.linspace(0,1.e-5,5) 35 | var_num = len(var_array) 36 | var_legend = r'$p_\mathrm{ann}$' 37 | var_figname = 'pann' 38 | # 39 | ############################################# 40 | # 41 | # Fixed settings 42 | # 43 | common_settings = {'output':'tCl,pCl,lCl,mPk', 44 | 'lensing':'yes', 45 | # LambdaCDM parameters 46 | 'h':0.67556, 47 | 'omega_b':0.022032, 48 | 'omega_cdm':0.12038, 49 | 'A_s':2.215e-9, 50 | 'n_s':0.9619, 51 | 'tau_reio':0.0925, 52 | # Take fixed value for primordial Helium (instead of automatic BBN adjustment) 53 | 'YHe':0.246, 54 | # other output and precision parameters 55 | 'P_k_max_1/Mpc':3.0, 56 | 'l_switch_limber':9} 57 | #'background_verbose':1} 58 | # 59 | # arrays for output 60 | # 61 | kvec = np.logspace(-4,np.log10(3),1000) 62 | legarray = [] 63 | twopi = 2.*math.pi 64 | # 65 | # Create figures 66 | # 67 | fig_Pk, ax_Pk = plt.subplots() 68 | fig_TT, ax_TT = plt.subplots() 69 | fig_EE, ax_EE = plt.subplots() 70 | fig_PP, ax_PP = plt.subplots() 71 | # 72 | # loop over varying parameter values 73 | # 74 | for i,var in enumerate(var_array): 75 | # 76 | print ' * Compute with %s=%e'%(var_name,var) 77 | # 78 | # deal with colors and legends 79 | # 80 | if i == 0: 81 | var_color = 'k' 82 | var_alpha = 1. 83 | legarray.append(r'ref. $\Lambda CDM$') 84 | else: 85 | var_color = 'r' 86 | var_alpha = 1.*i/(var_num-1.) 87 | if i == var_num-1: 88 | legarray.append(var_legend) 89 | # 90 | # call CLASS 91 | # 92 | M = Class() 93 | M.set(common_settings) 94 | M.set({var_name:var}) 95 | M.compute() 96 | # 97 | # get Cls 98 | # 99 | clM = M.lensed_cl(2500) 100 | ll = clM['ell'][2:] 101 | clTT = clM['tt'][2:] 102 | clEE = clM['ee'][2:] 103 | clPP = clM['pp'][2:] 104 | # 105 | # get P(k) for common k values 106 | # 107 | pkM = [] 108 | for k in kvec: 109 | pkM.append(M.pk(k,0.)) 110 | # 111 | # plot P(k) 112 | # 113 | ax_Pk.loglog(kvec,np.array(pkM),color=var_color,alpha=var_alpha,linestyle='-') 114 | # 115 | # plot C_l^TT 116 | # 117 | ax_TT.semilogx(ll,clTT*ll*(ll+1)/twopi,color=var_color,alpha=var_alpha,linestyle='-') 118 | # 119 | # plot Cl EE 120 | # 121 | ax_EE.loglog(ll,clEE*ll*(ll+1)/twopi,color=var_color,alpha=var_alpha,linestyle='-') 122 | # 123 | # plot Cl phiphi 124 | # 125 | ax_PP.loglog(ll,clPP*ll*(ll+1)*ll*(ll+1)/twopi,color=var_color,alpha=var_alpha,linestyle='-') 126 | # 127 | # reset CLASS 128 | # 129 | M.struct_cleanup() 130 | M.empty() 131 | # 132 | # output of P(k) figure 133 | # 134 | ax_Pk.set_xlim([1.e-4,3.]) 135 | ax_Pk.set_xlabel(r'$k \,\,\,\, [h/\mathrm{Mpc}]$') 136 | ax_Pk.set_ylabel(r'$P(k) \,\,\,\, [\mathrm{Mpc}/h]^3$') 137 | ax_Pk.legend(legarray) 138 | fig_Pk.tight_layout() 139 | fig_Pk.savefig('spectra_%s_Pk.pdf' % var_figname) 140 | # 141 | # output of C_l^TT figure 142 | # 143 | ax_TT.set_xlim([2,2500]) 144 | ax_TT.set_xlabel(r'$\ell$') 145 | ax_TT.set_ylabel(r'$[\ell(\ell+1)/2\pi] C_\ell^\mathrm{TT}$') 146 | ax_TT.legend(legarray) 147 | fig_TT.tight_layout() 148 | fig_TT.savefig('spectra_%s_cltt.pdf' % var_figname) 149 | # 150 | # output of C_l^EE figure 151 | # 152 | ax_EE.set_xlim([2,2500]) 153 | ax_EE.set_xlabel(r'$\ell$') 154 | ax_EE.set_ylabel(r'$[\ell(\ell+1)/2\pi] C_\ell^\mathrm{EE}$') 155 | ax_EE.legend(legarray) 156 | fig_EE.tight_layout() 157 | fig_EE.savefig('spectra_%s_clee.pdf' % var_figname) 158 | # 159 | # output of C_l^pp figure 160 | # 161 | ax_PP.set_xlim([10,2500]) 162 | ax_PP.set_xlabel(r'$\ell$') 163 | ax_PP.set_ylabel(r'$[\ell^2(\ell+1)^2/2\pi] C_\ell^\mathrm{\phi \phi}$') 164 | ax_PP.legend(legarray) 165 | fig_PP.tight_layout() 166 | fig_PP.savefig('spectra_%s_clpp.pdf' % var_figname) 167 | 168 | 169 | # In[ ]: 170 | 171 | 172 | 173 | 174 | # In[ ]: 175 | -------------------------------------------------------------------------------- /class/scripts/warmup.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # In[ ]: 5 | 6 | # import classy module 7 | from classy import Class 8 | 9 | 10 | # In[ ]: 11 | 12 | # create instance of the class "Class" 13 | LambdaCDM = Class() 14 | # pass input parameters 15 | LambdaCDM.set({'omega_b':0.022032,'omega_cdm':0.12038,'h':0.67556,'A_s':2.215e-9,'n_s':0.9619,'tau_reio':0.0925}) 16 | LambdaCDM.set({'output':'tCl,pCl,lCl,mPk','lensing':'yes','P_k_max_1/Mpc':3.0}) 17 | # run class 18 | LambdaCDM.compute() 19 | 20 | 21 | # In[ ]: 22 | 23 | # get all C_l output 24 | cls = LambdaCDM.lensed_cl(2500) 25 | # To check the format of cls 26 | cls.viewkeys() 27 | 28 | 29 | # In[ ]: 30 | 31 | ll = cls['ell'][2:] 32 | clTT = cls['tt'][2:] 33 | clEE = cls['ee'][2:] 34 | clPP = cls['pp'][2:] 35 | 36 | 37 | # In[ ]: 38 | 39 | # uncomment to get plots displayed in notebook 40 | #%matplotlib inline 41 | import matplotlib.pyplot as plt 42 | from math import pi 43 | 44 | 45 | # In[ ]: 46 | 47 | # plot C_l^TT 48 | plt.figure(1) 49 | plt.xscale('log');plt.yscale('linear');plt.xlim(2,2500) 50 | plt.xlabel(r'$\ell$') 51 | plt.ylabel(r'$[\ell(\ell+1)/2\pi] C_\ell^\mathrm{TT}$') 52 | plt.plot(ll,clTT*ll*(ll+1)/2./pi,'r-') 53 | 54 | 55 | # In[ ]: 56 | 57 | plt.savefig('warmup_cltt.pdf') 58 | 59 | 60 | # In[ ]: 61 | 62 | # get P(k) at redhsift z=0 63 | import numpy as np 64 | kk = np.logspace(-4,np.log10(3),1000) # k in h/Mpc 65 | Pk = [] # P(k) in (Mpc/h)**3 66 | h = LambdaCDM.h() # get reduced Hubble for conversions to 1/Mpc 67 | for k in kk: 68 | Pk.append(LambdaCDM.pk(k*h,0.)*h**3) # function .pk(k,z) 69 | 70 | 71 | # In[ ]: 72 | 73 | # plot P(k) 74 | plt.figure(2) 75 | plt.xscale('log');plt.yscale('log');plt.xlim(kk[0],kk[-1]) 76 | plt.xlabel(r'$k \,\,\,\, [h/\mathrm{Mpc}]$') 77 | plt.ylabel(r'$P(k) \,\,\,\, [\mathrm{Mpc}/h]^3$') 78 | plt.plot(kk,Pk,'b-') 79 | 80 | 81 | # In[ ]: 82 | 83 | plt.savefig('warmup_pk.pdf') 84 | 85 | 86 | # In[ ]: 87 | 88 | # optional: clear content of LambdaCDM (to reuse it for another model) 89 | LambdaCDM.struct_cleanup() 90 | # optional: reset parameters to default 91 | LambdaCDM.empty() 92 | 93 | # In[ ]: 94 | -------------------------------------------------------------------------------- /class/test/test_2D_quadrature.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "quadrature.h" 3 | 4 | int main(){ 5 | double I,fxy; 6 | int i,n; 7 | double *x,*y,*w; 8 | ErrorMsg error_message; 9 | 10 | n=2; 11 | 12 | class_call(quadrature_in_rectangle(-2.0,2.0,1.0,4.0,&n,&x,&y,&w,error_message), 13 | error_message, 14 | error_message); 15 | 16 | 17 | for(i=0,I=0.0; i%s\n",errmsg); 25 | return _FAILURE_; 26 | } 27 | 28 | if (background_init(&pr,&ba) == _FAILURE_) { 29 | printf("\n\nError running background_init \n=>%s\n",ba.error_message); 30 | return _FAILURE_; 31 | } 32 | 33 | /****** here you can output the evolution of any background 34 | quanitity you are interested in ******/ 35 | 36 | int index_tau; 37 | 38 | for (index_tau=0; index_tau%s\n",ba.error_message); 53 | return _FAILURE_; 54 | } 55 | 56 | return _SUCCESS_; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /class/test/test_bessel.c: -------------------------------------------------------------------------------- 1 | /** @file class.c 2 | * Julien Lesgourgues, 18.04.2010 3 | */ 4 | 5 | #include "class.h" 6 | 7 | main(int argc, char **argv) { 8 | 9 | struct precision pr; /* for precision parameters */ 10 | struct background ba; /* for cosmological background */ 11 | struct thermo th; /* for thermodynamics */ 12 | struct perturbs pt; /* for source functions */ 13 | struct bessels bs; /* for bessel functions */ 14 | struct transfers tr; /* for transfer functions */ 15 | struct primordial pm; /* for primordial spectra */ 16 | struct spectra sp; /* for output spectra */ 17 | struct nonlinear nl; /* for non-linear spectra */ 18 | struct lensing le; /* for lensed spectra */ 19 | struct output op; /* for output files */ 20 | ErrorMsg errmsg; 21 | 22 | if (input_init_from_arguments(argc, argv,&pr,&ba,&th,&pt,&bs,&tr,&pm,&sp,&nl,&le,&op,errmsg) == _FAILURE_) { 23 | printf("\n\nError running input_init_from_arguments \n=>%s\n",errmsg); 24 | return _FAILURE_; 25 | } 26 | 27 | /* 28 | if (background_init(&pr,&ba) == _FAILURE_) { 29 | printf("\n\nError running background_init \n=>%s\n",ba.error_message); 30 | return _FAILURE_; 31 | } 32 | 33 | if (thermodynamics_init(&pr,&ba,&th) == _FAILURE_) { 34 | printf("\n\nError in thermodynamics_init \n=>%s\n",th.error_message); 35 | return _FAILURE_; 36 | } 37 | 38 | if (perturb_init(&pr,&ba,&th,&pt) == _FAILURE_) { 39 | printf("\n\nError in perturb_init \n=>%s\n",pt.error_message); 40 | return _FAILURE_; 41 | } 42 | */ 43 | 44 | if (bessel_init(&pr,&bs) == _FAILURE_) { 45 | printf("\n\nError in bessel_init \n =>%s\n",bs.error_message); 46 | return _FAILURE_; 47 | } 48 | 49 | /****** here you could output the bessel functions ******/ 50 | 51 | int index_l=10; 52 | int index_x; 53 | for (index_x=0; index_x%s\n",bs.error_message); 65 | return _FAILURE_; 66 | } 67 | 68 | /* 69 | if (perturb_free(&pt) == _FAILURE_) { 70 | printf("\n\nError in perturb_free \n=>%s\n",pt.error_message); 71 | return _FAILURE_; 72 | } 73 | 74 | if (thermodynamics_free(&th) == _FAILURE_) { 75 | printf("\n\nError in thermodynamics_free \n=>%s\n",th.error_message); 76 | return _FAILURE_; 77 | } 78 | 79 | if (background_free(&ba) == _FAILURE_) { 80 | printf("\n\nError in background_free \n=>%s\n",ba.error_message); 81 | return _FAILURE_; 82 | } 83 | */ 84 | 85 | } 86 | -------------------------------------------------------------------------------- /class/test/test_hyperspherical.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "hyperspherical.h" 3 | 4 | 5 | int main(){ 6 | 7 | int sgnK; 8 | double nu; 9 | int *lvec; 10 | int l_size; 11 | int index_l, index_x, index_nu; 12 | double xmax, sampling, supersampling; 13 | double *xvec, *Phi, *nuvec; 14 | int nu_size; 15 | double dx; 16 | double Inum; 17 | double Iexact, l; 18 | FILE * outnum, *outexact, *out; 19 | double maxerr; 20 | 21 | HyperInterpStruct HIS; 22 | ErrorMsg error_message; 23 | 24 | sgnK = 1; 25 | 26 | switch(sgnK){ 27 | case 0: 28 | outnum = fopen("I_num.dat","w"); 29 | outexact = fopen("I_exact.dat","w"); 30 | case -1: 31 | outnum = fopen("I_num_open.dat","w"); 32 | outexact = fopen("I_exact.dat","w"); 33 | case 1: 34 | outnum = fopen("I_num_closed.dat","w"); 35 | outexact = fopen("I_exact.dat","w"); 36 | } 37 | 38 | 39 | l_size = 400; 40 | int l_size_in = l_size; 41 | nu_size = 100; 42 | 43 | nu = 10.0; 44 | 45 | lvec = malloc(sizeof(int)*l_size); 46 | out = fopen("lvec.dat","w"); 47 | for (index_l=0; index_l=nu){ 75 | l_size = k-1; 76 | break; 77 | } 78 | } 79 | } 80 | 81 | 82 | sampling = 6.0; 83 | 84 | class_call(hyperspherical_HIS_create(sgnK, 85 | nu, 86 | l_size, 87 | lvec, 88 | 1e-6, 89 | xmax, 90 | sampling, 91 | lvec[l_size-1]+1, 92 | 1e-20, 93 | &HIS, 94 | error_message), 95 | error_message, 96 | error_message); 97 | 98 | supersampling = 100*HIS.x_size; 99 | xvec = malloc(sizeof(double)*supersampling); 100 | Phi = malloc(sizeof(double)*supersampling); 101 | 102 | for (index_x=0; index_x%s\n",errmsg); 25 | return _FAILURE_; 26 | } 27 | 28 | if (background_init(&pr,&ba) == _FAILURE_) { 29 | printf("\n\nError running background_init \n=>%s\n",ba.error_message); 30 | return _FAILURE_; 31 | } 32 | 33 | if (thermodynamics_init(&pr,&ba,&th) == _FAILURE_) { 34 | printf("\n\nError in thermodynamics_init \n=>%s\n",th.error_message); 35 | return _FAILURE_; 36 | } 37 | 38 | if (perturb_init(&pr,&ba,&th,&pt) == _FAILURE_) { 39 | printf("\n\nError in perturb_init \n=>%s\n",pt.error_message); 40 | return _FAILURE_; 41 | } 42 | 43 | if (primordial_init(&pr,&pt,&pm) == _FAILURE_) { 44 | printf("\n\nError in primordial_init \n=>%s\n",pm.error_message); 45 | return _FAILURE_; 46 | } 47 | 48 | if (nonlinear_init(&pr,&ba,&th,&pt,&pm,&nl) == _FAILURE_) { 49 | printf("\n\nError in nonlinear_init \n=>%s\n",nl.error_message); 50 | return _FAILURE_; 51 | } 52 | 53 | /****** output the transfer functions ******/ 54 | 55 | double z,k_nl,k; 56 | FILE * output; 57 | double * pvecback; 58 | int index_tau,index_k; 59 | int junk; 60 | double r_nl; 61 | 62 | if (nl.method == nl_halofit) { 63 | 64 | printf("Non-linear scale k_NL found by halofit:\n"); 65 | 66 | z=0.; 67 | if (nonlinear_k_nl_at_z(&ba,&nl,z,&k_nl) == _FAILURE_) { 68 | printf("\n\nError in nonlinear_k_nl_at_z \n=>%s\n",nl.error_message); 69 | return _FAILURE_; 70 | } 71 | printf(" z=%f k_nl=%e\n",z,k_nl); 72 | 73 | z=0.5; 74 | if (nonlinear_k_nl_at_z(&ba,&nl,z,&k_nl) == _FAILURE_) { 75 | printf("\n\nError in nonlinear_k_nl_at_z \n=>%s\n",nl.error_message); 76 | return _FAILURE_; 77 | } 78 | printf(" z=%f k_nl=%e\n",z,k_nl); 79 | 80 | z=1.0; 81 | if (nonlinear_k_nl_at_z(&ba,&nl,z,&k_nl) == _FAILURE_) { 82 | printf("\n\nError in nonlinear_k_nl_at_z \n=>%s\n",nl.error_message); 83 | return _FAILURE_; 84 | } 85 | printf(" z=%f k_nl=%e\n",z,k_nl); 86 | 87 | printf("Non-linear correction factor r_nl=sqrt(P_nl/P_l) written in file with columns (z, k, r_nl\n"); 88 | 89 | output=fopen("output/r_nl.dat","w"); 90 | 91 | pvecback=malloc(ba.bg_size_short*sizeof(double)); 92 | 93 | for (index_tau=0; index_tau%s\n",ba.error_message); 102 | return _FAILURE_; 103 | } 104 | 105 | z=ba.a_today/pvecback[ba.index_bg_a]-1.; 106 | 107 | for (index_k=0; index_k%s\n",nl.error_message); 125 | return _FAILURE_; 126 | } 127 | 128 | if (primordial_free(&pm) == _FAILURE_) { 129 | printf("\n\nError in primordial_free \n=>%s\n",pm.error_message); 130 | return _FAILURE_; 131 | } 132 | 133 | if (perturb_free(&pt) == _FAILURE_) { 134 | printf("\n\nError in perturb_free \n=>%s\n",pt.error_message); 135 | return _FAILURE_; 136 | } 137 | 138 | if (thermodynamics_free(&th) == _FAILURE_) { 139 | printf("\n\nError in thermodynamics_free \n=>%s\n",th.error_message); 140 | return _FAILURE_; 141 | } 142 | 143 | if (background_free(&ba) == _FAILURE_) { 144 | printf("\n\nError in background_free \n=>%s\n",ba.error_message); 145 | return _FAILURE_; 146 | } 147 | 148 | return _SUCCESS_; 149 | 150 | } 151 | -------------------------------------------------------------------------------- /class/test/test_perturbations.c: -------------------------------------------------------------------------------- 1 | /** @file class.c 2 | * Julien Lesgourgues, 17.04.2011 3 | */ 4 | 5 | /* this main runs only the background, thermodynamics and perturbation part */ 6 | 7 | #include "class.h" 8 | 9 | int main(int argc, char **argv) { 10 | 11 | struct precision pr; /* for precision parameters */ 12 | struct background ba; /* for cosmological background */ 13 | struct thermo th; /* for thermodynamics */ 14 | struct perturbs pt; /* for source functions */ 15 | struct transfers tr; /* for transfer functions */ 16 | struct primordial pm; /* for primordial spectra */ 17 | struct spectra sp; /* for output spectra */ 18 | struct nonlinear nl; /* for non-linear spectra */ 19 | struct lensing le; /* for lensed spectra */ 20 | struct output op; /* for output files */ 21 | ErrorMsg errmsg; /* for error messages */ 22 | 23 | if (input_init_from_arguments(argc, argv,&pr,&ba,&th,&pt,&tr,&pm,&sp,&nl,&le,&op,errmsg) == _FAILURE_) { 24 | printf("\n\nError running input_init_from_arguments \n=>%s\n",errmsg); 25 | return _FAILURE_; 26 | } 27 | 28 | if (background_init(&pr,&ba) == _FAILURE_) { 29 | printf("\n\nError running background_init \n=>%s\n",ba.error_message); 30 | return _FAILURE_; 31 | } 32 | 33 | if (thermodynamics_init(&pr,&ba,&th) == _FAILURE_) { 34 | printf("\n\nError in thermodynamics_init \n=>%s\n",th.error_message); 35 | return _FAILURE_; 36 | } 37 | 38 | if (perturb_init(&pr,&ba,&th,&pt) == _FAILURE_) { 39 | printf("\n\nError in perturb_init \n=>%s\n",pt.error_message); 40 | return _FAILURE_; 41 | } 42 | 43 | if (pt.has_perturbations == _TRUE_) { 44 | 45 | /*********************************************************************/ 46 | /* here you can output the source function S(k,tau) of your choice */ 47 | /*********************************************************************/ 48 | 49 | FILE * output; 50 | int index_k,index_tau; 51 | 52 | /* choose a mode (scalar, tensor, ...) */ 53 | int index_md=pt.index_md_scalars; 54 | 55 | /* choose a type (temperature, polarization, grav. pot., ...) */ 56 | int index_type=pt.index_tp_t0; 57 | 58 | /* choose an initial condition (ad, bi, cdi, nid, niv, ...) */ 59 | int index_ic=pt.index_ic_ad; 60 | 61 | output=fopen("output/source.dat","w"); 62 | fprintf(output,"# k tau S\n"); 63 | 64 | for (index_k=0; index_k < pt.k_size[index_md]; index_k++) { 65 | for (index_tau=0; index_tau < pt.tau_size; index_tau++) { 66 | 67 | fprintf(output,"%e %e %e\n", 68 | pt.k[index_md][index_k], 69 | pt.tau_sampling[index_tau], 70 | pt.sources[index_md] 71 | [index_ic * pt.tp_size[index_md] + index_type] 72 | [index_tau * pt.k_size[index_md] + index_k] 73 | ); 74 | } 75 | fprintf(output,"\n"); 76 | } 77 | 78 | fclose(output); 79 | 80 | } 81 | 82 | /****** all calculations done, now free the structures ******/ 83 | 84 | if (perturb_free(&pt) == _FAILURE_) { 85 | printf("\n\nError in perturb_free \n=>%s\n",pt.error_message); 86 | return _FAILURE_; 87 | } 88 | 89 | if (thermodynamics_free(&th) == _FAILURE_) { 90 | printf("\n\nError in thermodynamics_free \n=>%s\n",th.error_message); 91 | return _FAILURE_; 92 | } 93 | 94 | if (background_free(&ba) == _FAILURE_) { 95 | printf("\n\nError in background_free \n=>%s\n",ba.error_message); 96 | return _FAILURE_; 97 | } 98 | 99 | return _SUCCESS_; 100 | 101 | } 102 | -------------------------------------------------------------------------------- /class/test/test_spectra.c: -------------------------------------------------------------------------------- 1 | /** @file test_spectra.c 2 | * 3 | * Julien Lesgourgues, 26.08.2010 4 | * 5 | * main intended for computing power spectra, not using the output module. 6 | * 7 | */ 8 | 9 | #include "class.h" 10 | 11 | int main(int argc, char **argv) { 12 | 13 | struct precision pr; /* for precision parameters */ 14 | struct background ba; /* for cosmological background */ 15 | struct thermo th; /* for thermodynamics */ 16 | struct perturbs pt; /* for source functions */ 17 | struct primordial pm; /* for primordial spectra */ 18 | struct nonlinear nl; /* for non-linear spectra */ 19 | struct transfers tr; /* for transfer functions */ 20 | struct spectra sp; /* for output spectra */ 21 | struct lensing le; /* for lensed spectra */ 22 | struct output op; /* for output files */ 23 | ErrorMsg errmsg; /* for error messages */ 24 | 25 | if (input_init_from_arguments(argc, argv,&pr,&ba,&th,&pt,&tr,&pm,&sp,&nl,&le,&op,errmsg) == _FAILURE_) { 26 | printf("\n\nError running input_init_from_arguments \n=>%s\n",errmsg); 27 | return _FAILURE_; 28 | } 29 | 30 | if (background_init(&pr,&ba) == _FAILURE_) { 31 | printf("\n\nError running background_init \n=>%s\n",ba.error_message); 32 | return _FAILURE_; 33 | } 34 | 35 | if (thermodynamics_init(&pr,&ba,&th) == _FAILURE_) { 36 | printf("\n\nError in thermodynamics_init \n=>%s\n",th.error_message); 37 | return _FAILURE_; 38 | } 39 | 40 | if (perturb_init(&pr,&ba,&th,&pt) == _FAILURE_) { 41 | printf("\n\nError in perturb_init \n=>%s\n",pt.error_message); 42 | return _FAILURE_; 43 | } 44 | 45 | if (primordial_init(&pr,&pt,&pm) == _FAILURE_) { 46 | printf("\n\nError in primordial_init \n=>%s\n",pm.error_message); 47 | return _FAILURE_; 48 | } 49 | 50 | if (nonlinear_init(&pr,&ba,&th,&pt,&pm,&nl) == _FAILURE_) { 51 | printf("\n\nError in nonlinear_init \n=>%s\n",nl.error_message); 52 | return _FAILURE_; 53 | } 54 | 55 | if (transfer_init(&pr,&ba,&th,&pt,&nl,&tr) == _FAILURE_) { 56 | printf("\n\nError in transfer_init \n=>%s\n",tr.error_message); 57 | return _FAILURE_; 58 | } 59 | 60 | if (spectra_init(&pr,&ba,&pt,&pm,&nl,&tr,&sp) == _FAILURE_) { 61 | printf("\n\nError in spectra_init \n=>%s\n",sp.error_message); 62 | return _FAILURE_; 63 | } 64 | 65 | /****** output Cls ******/ 66 | 67 | FILE * output; 68 | int index_mode=0; 69 | int index_ic1_ic2=0; 70 | int index_ct=0; 71 | int index_l; 72 | 73 | if (pt.has_cmb == _TRUE_) { 74 | 75 | output=fopen("output/testing_cls.dat","w"); 76 | 77 | for (index_l=0; index_l < sp.l_size[index_mode]; index_l++) 78 | fprintf(output,"%g %g\n", 79 | sp.l[index_l], 80 | sp.cl[index_mode][(index_l * sp.ic_ic_size[index_mode] + index_ic1_ic2) * sp.ct_size + index_ct]); 81 | 82 | fclose(output); 83 | 84 | } 85 | 86 | /****************************/ 87 | 88 | if (spectra_free(&sp) == _FAILURE_) { 89 | printf("\n\nError in spectra_free \n=>%s\n",sp.error_message); 90 | return _FAILURE_; 91 | } 92 | 93 | if (transfer_free(&tr) == _FAILURE_) { 94 | printf("\n\nError in transfer_free \n=>%s\n",tr.error_message); 95 | return _FAILURE_; 96 | } 97 | 98 | if (nonlinear_free(&nl) == _FAILURE_) { 99 | printf("\n\nError in nonlinear_free \n=>%s\n",nl.error_message); 100 | return _FAILURE_; 101 | } 102 | 103 | if (primordial_free(&pm) == _FAILURE_) { 104 | printf("\n\nError in primordial_free \n=>%s\n",pm.error_message); 105 | return _FAILURE_; 106 | } 107 | 108 | if (perturb_free(&pt) == _FAILURE_) { 109 | printf("\n\nError in perturb_free \n=>%s\n",pt.error_message); 110 | return _FAILURE_; 111 | } 112 | 113 | if (thermodynamics_free(&th) == _FAILURE_) { 114 | printf("\n\nError in thermodynamics_free \n=>%s\n",th.error_message); 115 | return _FAILURE_; 116 | } 117 | 118 | if (background_free(&ba) == _FAILURE_) { 119 | printf("\n\nError in background_free \n=>%s\n",ba.error_message); 120 | return _FAILURE_; 121 | } 122 | 123 | return _SUCCESS_; 124 | 125 | } 126 | -------------------------------------------------------------------------------- /class/test/test_trg.c: -------------------------------------------------------------------------------- 1 | /** @file test_trg.c 2 | * 3 | */ 4 | 5 | #include "precision.h" 6 | #include "background.h" 7 | #include "thermodynamics.h" 8 | #include "perturbations.h" 9 | #include "bessel.h" 10 | #include "transfer.h" 11 | #include "primordial.h" 12 | #include "spectra.h" 13 | #include "output.h" 14 | #include "trg.h" 15 | 16 | main(int argc, char **argv) { 17 | 18 | struct precision pr; /* for precision parameters */ 19 | struct background ba; /* for cosmological background */ 20 | struct thermo th; /* for thermodynamics */ 21 | struct perturbs pt; /* for source functions */ 22 | struct bessels bs; /* for bessel functions */ 23 | struct transfers tr; /* for transfer functions */ 24 | struct primordial pm; /* for primordial spectra */ 25 | struct output op; 26 | struct lensing le; 27 | struct spectra sp; /* for output spectra */ 28 | struct spectra_nl nl; /* for calculation of non-linear spectra */ 29 | 30 | ErrorMsg errmsg; 31 | 32 | if (input_init_from_arguments(argc, argv,&pr,&ba,&th,&pt,&bs,&tr,&pm,&sp,&le,&op,&nl,errmsg) == _FAILURE_) { 33 | printf("\n\nError running input_init_from_arguments \n=>%s\n",errmsg); 34 | return _FAILURE_; 35 | } 36 | 37 | if (background_init(&pr,&ba) == _FAILURE_) { 38 | printf("\n\nError running background_init \n=>%s\n",ba.error_message); 39 | return _FAILURE_; 40 | } 41 | 42 | if (thermodynamics_init(&pr,&ba,&th) == _FAILURE_) { 43 | printf("\n\nError in thermodynamics_init \n=>%s\n",th.error_message); 44 | return _FAILURE_; 45 | } 46 | 47 | if (perturb_init(&pr,&ba,&th,&pt) == _FAILURE_) { 48 | printf("\n\nError in perturb_init \n=>%s\n",pt.error_message); 49 | return _FAILURE_; 50 | } 51 | 52 | if (bessel_init(&pr,&bs) == _FAILURE_) { 53 | printf("\n\nError in bessel_init \n =>%s\n",bs.error_message); 54 | return _FAILURE_; 55 | } 56 | 57 | if (transfer_init(&pr,&ba,&th,&pt,&bs,&tr) == _FAILURE_) { 58 | printf("\n\nError in transfer_init \n=>%s\n",tr.error_message); 59 | return _FAILURE_; 60 | } 61 | 62 | if (primordial_init(&pr,&pt,&pm) == _FAILURE_) { 63 | printf("\n\nError in transfer_init \n=>%s\n",pm.error_message); 64 | return _FAILURE_; 65 | } 66 | 67 | if (spectra_init(&ba,&pt,&tr,&pm,&sp) == _FAILURE_) { 68 | printf("\n\nError in spectra_init \n=>%s\n",sp.error_message); 69 | return _FAILURE_; 70 | } 71 | 72 | if (trg_init(&pr,&ba,&th,&pm,&sp,&nl) == _FAILURE_) { 73 | printf("\n\nError in trg_init \n=>%s\n",nl.error_message); 74 | return _FAILURE_; 75 | } 76 | 77 | /****** done ******/ 78 | 79 | 80 | if (trg_free(&nl) == _FAILURE_) { 81 | printf("\n\nError in trg_free \n=>%s\n",nl.error_message); 82 | return _FAILURE_; 83 | } 84 | 85 | if (spectra_free(&sp) == _FAILURE_) { 86 | printf("\n\nError in spectra_free \n=>%s\n",sp.error_message); 87 | return _FAILURE_; 88 | } 89 | 90 | if (primordial_free(&pm) == _FAILURE_) { 91 | printf("\n\nError in primordial_free \n=>%s\n",pm.error_message); 92 | return _FAILURE_; 93 | } 94 | 95 | if (transfer_free(&tr) == _FAILURE_) { 96 | printf("\n\nError in transfer_free \n=>%s\n",tr.error_message); 97 | return _FAILURE_; 98 | } 99 | 100 | if (bessel_free(&bs) == _FAILURE_) { 101 | printf("\n\nError in bessel_free \n=>%s\n",bs.error_message); 102 | return _FAILURE_; 103 | } 104 | 105 | if (perturb_free(&pt) == _FAILURE_) { 106 | printf("\n\nError in perturb_free \n=>%s\n",pt.error_message); 107 | return _FAILURE_; 108 | } 109 | 110 | if (thermodynamics_free(&th) == _FAILURE_) { 111 | printf("\n\nError in thermodynamics_free \n=>%s\n",th.error_message); 112 | return _FAILURE_; 113 | } 114 | 115 | if (background_free(&ba) == _FAILURE_) { 116 | printf("\n\nError in background_free \n=>%s\n",ba.error_message); 117 | return _FAILURE_; 118 | } 119 | 120 | return _SUCCESS_; 121 | 122 | } 123 | -------------------------------------------------------------------------------- /class/tools/common.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | void class_protect_sprintf(char* dest, char* tpl,...) { 4 | va_list args; 5 | va_start(args,tpl); 6 | vsnprintf(dest, 2048,tpl,args); 7 | va_end(args); 8 | } 9 | 10 | void class_protect_fprintf(FILE* stream, char* tpl,...) { 11 | va_list args; 12 | char dest[6000]; 13 | va_start(args,tpl); 14 | vsnprintf(dest, 2048,tpl,args); 15 | va_end(args); 16 | fprintf(stream,"%s",dest); 17 | } 18 | 19 | void* class_protect_memcpy(void* dest, void* from, size_t sz) { 20 | return memcpy(dest, from,sz); 21 | } 22 | 23 | int get_number_of_titles(char * titlestring){ 24 | int i; 25 | int number_of_titles=0; 26 | 27 | for (i=0; i x_sampling[x_size-1], 43 | error_message, 44 | "called with x=%e, last x_sampling=%e",x_ini,x_sampling[x_size-1]); 45 | 46 | next_index_x=0; 47 | 48 | while (x_sampling[next_index_x] < x_ini) next_index_x++; 49 | 50 | class_call(initialize_generic_integrator(y_size, &gi), 51 | gi.error_message, 52 | error_message); 53 | 54 | class_alloc(dy,y_size*sizeof(double),error_message); 55 | 56 | x1=x_ini; 57 | 58 | call_output = _FALSE_; 59 | 60 | while ((x1 < x_end) && (next_index_x x_end) { 84 | x2 = x_end; 85 | call_output = _FALSE_; 86 | } 87 | 88 | if (print_variables != NULL) { 89 | 90 | if (x1 == x_ini) { 91 | 92 | class_call((*derivs)(x1, 93 | y, 94 | dy, 95 | parameters_and_workspace_for_derivs, 96 | error_message), 97 | error_message, 98 | error_message); 99 | } 100 | 101 | class_call((*print_variables)(x1, 102 | y, 103 | dy, 104 | parameters_and_workspace_for_derivs, 105 | error_message), 106 | error_message, 107 | error_message); 108 | } 109 | 110 | class_call(generic_integrator(derivs, 111 | x1, 112 | x2, 113 | y, 114 | parameters_and_workspace_for_derivs, 115 | tolerance, 116 | x1*minimum_variation, 117 | &gi), 118 | gi.error_message, 119 | error_message); 120 | 121 | if (call_output == _TRUE_) { 122 | 123 | class_call((*derivs)(x2, 124 | y, 125 | dy, 126 | parameters_and_workspace_for_derivs, 127 | error_message), 128 | error_message, 129 | error_message); 130 | 131 | class_call((*output)(x2, 132 | y, 133 | dy, 134 | next_index_x, 135 | parameters_and_workspace_for_derivs, 136 | error_message), 137 | error_message, 138 | error_message); 139 | 140 | call_output = _FALSE_; 141 | 142 | next_index_x++; 143 | 144 | } 145 | 146 | x1 = x2; 147 | 148 | } 149 | 150 | /* a last call is compulsory to ensure that all quantitites in 151 | y,dy,parameters_and_workspace_for_derivs are updated to the last 152 | point in the covered range */ 153 | class_call((*derivs)(x1, 154 | y, 155 | dy, 156 | parameters_and_workspace_for_derivs, 157 | error_message), 158 | error_message, 159 | error_message); 160 | 161 | if (print_variables != NULL) 162 | class_call((*print_variables)(x1, 163 | y, 164 | dy, 165 | parameters_and_workspace_for_derivs, 166 | error_message), 167 | error_message, 168 | error_message); 169 | 170 | class_call(cleanup_generic_integrator(&gi), 171 | gi.error_message, 172 | error_message); 173 | 174 | free(dy); 175 | 176 | return _SUCCESS_; 177 | 178 | } 179 | -------------------------------------------------------------------------------- /class/tools/growTable.c: -------------------------------------------------------------------------------- 1 | /*** 2 | * growTable provides automatically growing tables. 3 | */ 4 | 5 | #include "growTable.h" 6 | 7 | /*** 8 | * gt_init Initialize the growTable. 9 | * gt_init will initialize the growTable structure. It must be already allocated. 10 | * 11 | * Called by background_solve(). 12 | */ 13 | int gt_init( 14 | growTable* self /***< a pointer on an empty growTable */ 15 | ) { 16 | 17 | class_alloc(self->buffer,_GT_INITSIZE_,self->error_message); 18 | self->sz=_GT_INITSIZE_; 19 | self->csz=0; 20 | self->freeze=_FALSE_; /**< This line added by JL */ 21 | return _SUCCESS_; 22 | } 23 | 24 | /** 25 | * Add data to the growTable. 26 | * 27 | * Called by background_solve(). 28 | */ 29 | int gt_add( 30 | growTable* self, /**< a growTable*/ 31 | long idx, /**< index at wich to add the data (in bytes). #_GT_END_ means the end of the currently written data*/ 32 | void* data, /**< data to be added*/ 33 | long sz /**< size of the data (in bytes)*/ 34 | ) { 35 | long ridx; 36 | void *res; 37 | void *nbuffer; 38 | 39 | /** - assumes the growTable is correctly initialized */ 40 | 41 | class_test(self->freeze == _TRUE_, 42 | self->error_message, 43 | "cannot add any more data in the growTable (freeze is on)"); 44 | 45 | if (idx==_GT_END_) { 46 | ridx=self->csz; 47 | } 48 | else { 49 | ridx=idx; 50 | } 51 | class_test(ridx<0, 52 | self->error_message, 53 | "Don't know what to do with idx=%ld",ridx); 54 | 55 | if (ridx+sz>self->sz) { 56 | /** - test -> pass -> ok we need to grow */ 57 | nbuffer=realloc(self->buffer,self->sz*_GT_FACTOR_); 58 | class_test(nbuffer==NULL, 59 | self->error_message, 60 | "Cannot grow growTable"); 61 | self->buffer=nbuffer; 62 | self->sz=self->sz*_GT_FACTOR_; 63 | } 64 | 65 | res=memcpy((void*) (self->buffer+ridx),(void*) data,(size_t) sz); 66 | class_test(res!=self->buffer+ridx, 67 | self->error_message, 68 | "Cannot add data to growTable"); 69 | self->csz=ridx+sz; 70 | 71 | return _SUCCESS_; 72 | } 73 | 74 | /** 75 | * Retrieve data from the growTable. 76 | * 77 | * Not called. 78 | */ 79 | int gt_retrieve( 80 | growTable *self, /**< a growTable*/ 81 | long idx, /**< index at wich to retrieve the data (in bytes).*/ 82 | long sz, /**< size of the data (in bytes)*/ 83 | void* data /**< OUTPUT : data must be allocated to ::sz bytes*/ 84 | ) { 85 | void *res; 86 | 87 | class_test(idx<0, 88 | self->error_message, 89 | "don't know what to do with idx=%ld",idx); 90 | 91 | class_test((idx>self->csz) || (idx+sz>self->csz), 92 | self->error_message, 93 | "not enough data in growTable"); 94 | 95 | res=memcpy(data,self->buffer+idx,sz); 96 | class_test(res!=self->buffer+idx, 97 | self->error_message, 98 | "cannot retrieve data from the growTable"); 99 | 100 | return _SUCCESS_; 101 | } 102 | 103 | /** 104 | * Retrieve all data from the growTable. 105 | * 106 | * Not called. 107 | */ 108 | int gt_retrieveAll( 109 | growTable *self, /**< a growTable*/ 110 | void* data /**< OUTPUT : data must be allocated to the size of the growTable (see gt_getSize)*/ 111 | ) { 112 | return gt_retrieve(self,0,self->csz,data); 113 | } 114 | 115 | /** 116 | * returns the size of the growTable 117 | * 118 | * Not called. 119 | */ 120 | int gt_getSize( 121 | growTable* self,/**< a growTable*/ 122 | long *idx /**< OUTPUT : the size of the growTable ::self*/ 123 | ) { 124 | class_test(self->csz<0, 125 | self->error_message, 126 | "growTable does not make sense"); 127 | *idx=self->csz; 128 | return _SUCCESS_; 129 | } 130 | 131 | /** 132 | * returns a pointer on the data contained in the growTable. 133 | * No Data can be added afterward !!!!! This is not for the faint of heart. 134 | * 135 | * Called by background_solve(). 136 | */ 137 | int gt_getPtr( 138 | growTable* self, /**< a growTable*/ 139 | void** ptr /**< OUTPUT : pointer on the data */ 140 | ) { 141 | self->freeze=_TRUE_; 142 | *ptr=self->buffer; 143 | 144 | return _SUCCESS_; 145 | } 146 | 147 | 148 | /** 149 | * free the growTable 150 | * 151 | * Called by background_solve(). 152 | */ 153 | int gt_free(growTable* self) { 154 | free(self->buffer); 155 | self->csz=-1; 156 | self->sz=-1; 157 | self->freeze=_FALSE_; /**< This line added by JL */ 158 | 159 | return _SUCCESS_; 160 | } 161 | 162 | -------------------------------------------------------------------------------- /class/tools/trigonometric_integrals.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Module with tools for trigonometric integrals 3 | * Samuel Brieden, 2018 4 | */ 5 | 6 | #include "trigonometric_integrals.h" 7 | 8 | /** this is the Cosine Integral function Ci(x) */ 9 | int cosine_integral( 10 | double x, 11 | double *Ci, 12 | ErrorMsg error_message 13 | ){ 14 | 15 | double x2, y, f, g, ci8; 16 | double em_const = 0.577215664901532861e0; 17 | 18 | if (fabs(x)<=4.){ 19 | x2=x*x; 20 | 21 | ci8=em_const+log(x)+x2*(-0.25e0+x2*(7.51851524438898291e-3+x2*(-1.27528342240267686e-4 22 | +x2*(1.05297363846239184e-6+x2*(-4.68889508144848019e-9+x2*(1.06480802891189243e-11 23 | +x2*(-9.93728488857585407e-15)))))))/ (1.+x2*(1.1592605689110735e-2+ 24 | x2*(6.72126800814254432e-5+x2*(2.55533277086129636e-7+x2*(6.97071295760958946e-10+ 25 | x2*(1.38536352772778619e-12+x2*(1.89106054713059759e-15+x2*(1.39759616731376855e-18)))))))); 26 | 27 | *Ci=ci8; 28 | } 29 | else { 30 | y=1./(x*x); 31 | 32 | f = (1.e0 + y*(7.44437068161936700618e2 + y*(1.96396372895146869801e5 + 33 | y*(2.37750310125431834034e7 +y*(1.43073403821274636888e9 + y*(4.33736238870432522765e10 34 | + y*(6.40533830574022022911e11 + y*(4.20968180571076940208e12 + y*(1.00795182980368574617e13 35 | + y*(4.94816688199951963482e12 +y*(-4.94701168645415959931e11)))))))))))/ 36 | (x*(1. +y*(7.46437068161927678031e2 +y*(1.97865247031583951450e5 + 37 | y*(2.41535670165126845144e7 + y*(1.47478952192985464958e9 + 38 | y*(4.58595115847765779830e10 +y*(7.08501308149515401563e11 + y*(5.06084464593475076774e12 39 | + y*(1.43468549171581016479e13 + y*(1.11535493509914254097e13))))))))))); 40 | 41 | g = y*(1.e0 + y*(8.1359520115168615e2 + y*(2.35239181626478200e5 + y*(3.12557570795778731e7 42 | + y*(2.06297595146763354e9 + y*(6.83052205423625007e10 + 43 | y*(1.09049528450362786e12 + y*(7.57664583257834349e12 + 44 | y*(1.81004487464664575e13 + y*(6.43291613143049485e12 +y*(-1.36517137670871689e12))))))))))) 45 | / (1. + y*(8.19595201151451564e2 +y*(2.40036752835578777e5 + 46 | y*(3.26026661647090822e7 + y*(2.23355543278099360e9 + y*(7.87465017341829930e10 47 | + y*(1.39866710696414565e12 + y*(1.17164723371736605e13 + y*(4.01839087307656620e13 +y*(3.99653257887490811e13)))))))))); 48 | *Ci=f*sin(x)-g*cos(x); 49 | } 50 | return _SUCCESS_; 51 | } 52 | 53 | /** this is the Sine Integral function Si(x) */ 54 | int sine_integral( 55 | double x, 56 | double *Si, 57 | ErrorMsg error_message 58 | ){ 59 | 60 | double x2, y, f, g, si8; 61 | double pi8=3.1415926535897932384626433; 62 | 63 | if (fabs(x)<=4.){ 64 | x2=x*x; 65 | 66 | si8 = x*(1.e0+x2*(-4.54393409816329991e-2+x2*(1.15457225751016682e-3 67 | +x2*(-1.41018536821330254e-5+x2*(9.43280809438713025e-8+x2*(-3.53201978997168357e-10 68 | +x2*(7.08240282274875911e-13+x2*(-6.05338212010422477e-16))))))))/ 69 | (1.+x2*(1.01162145739225565e-2 +x2*(4.99175116169755106e-5+ 70 | x2*(1.55654986308745614e-7+x2*(3.28067571055789734e-10+x2*(4.5049097575386581e-13 71 | +x2*(3.21107051193712168e-16))))))); 72 | 73 | *Si=si8; 74 | } 75 | else { 76 | y=1./(x*x); 77 | 78 | f = (1.e0 + y*(7.44437068161936700618e2 + y*(1.96396372895146869801e5 + 79 | y*(2.37750310125431834034e7 +y*(1.43073403821274636888e9 + y*(4.33736238870432522765e10 80 | + y*(6.40533830574022022911e11 + y*(4.20968180571076940208e12 + 81 | y*(1.00795182980368574617e13 + y*(4.94816688199951963482e12 + 82 | y*(-4.94701168645415959931e11)))))))))))/ (x*(1. +y*(7.46437068161927678031e2 + 83 | y*(1.97865247031583951450e5 +y*(2.41535670165126845144e7 + 84 | y*(1.47478952192985464958e9 + y*(4.58595115847765779830e10 + 85 | y*(7.08501308149515401563e11 + y*(5.06084464593475076774e12 + 86 | y*(1.43468549171581016479e13 + y*(1.11535493509914254097e13))))))))))); 87 | 88 | 89 | g = y*(1.e0 + y*(8.1359520115168615e2 + y*(2.35239181626478200e5 + 90 | y*(3.12557570795778731e7 + y*(2.06297595146763354e9 + y*(6.83052205423625007e10 + 91 | y*(1.09049528450362786e12 + y*(7.57664583257834349e12 +y*(1.81004487464664575e13 + 92 | y*(6.43291613143049485e12 +y*(-1.36517137670871689e12)))))))))))/ 93 | (1. + y*(8.19595201151451564e2 +y*(2.40036752835578777e5 + y*(3.26026661647090822e7 94 | + y*(2.23355543278099360e9 + y*(7.87465017341829930e10 + y*(1.39866710696414565e12 95 | + y*(1.17164723371736605e13 + y*(4.01839087307656620e13 +y*(3.99653257887490811e13)))))))))); 96 | 97 | *Si=pi8/2.-f*cos(x)-g*sin(x); 98 | } 99 | return _SUCCESS_; 100 | } 101 | --------------------------------------------------------------------------------