diff --git a/README b/README new file mode 100644 index 0000000..a220f52 --- /dev/null +++ b/README @@ -0,0 +1,76 @@ +********************************************************************** +Adds trans-Planckian like modulation to primordial power spectra +expanded at first order in Hubble and sound flow parameters (valid for +k-inflation). A switch allows the inclusion of second order +corrections but in the Hubble flow functions only (valid for +canonically normalised fields). +********************************************************************** + +-These patches modify the cosmomc or camb codes and therefore may have +bugs that are not present in the originals. The authors of the +original versions should not be bothered with problems resulting in +the use of these patches. Feel free to insult me, or at least contact +me, in case of bugs! + +-Apply the patch in the cosmomc/ directory: +patch -p1 < purpose_MMYY.patch + +*Modifications traced by the comment "wig" in the source files. + +*Please note that the genuine Makefiles have been heavily changed and +may require edition to work on your system. They assume the existence +of a directory "cosmomc/WMAP" which points to the WMAP team likelihood +code directory. The WMAP data are also assumed to reside in the +"cosmomc/data" directory. + + +*Modified files and settings + +- camb/cmbmain.f90 +New switches "kSrcSampleBoost" and "kIntSampleBoost" to check accuracy. + +- camb/modules.f90 +New switches "DoClsInterpol" and "ComputeEveryl". AccuracyBoost and +lAccuracyBoost default values modified. points=10000 to accurately +sample oscillatory matter power spectra. + +- camb/power_sr.f90 +Implementation of Slow-Roll/k-inflation power spectrum and its +trans-Planckian extension. + +- camb/inidriver.F90 +New keys for the above material. + +- camb/params.ini +New keys for the above material. + +- cosmomc/CMB_Cls_simple.f90 +Added screen output to check camb accuracy default values. New +switches kSrcSampleLevel, kIntSampleLevel, CambComputeEveryl to +control the camb accuracy from cosmomc. + +- cosmomc/cmbtypes.f90 +Default value for "write_all_cls" to true. + +- cosmomc/params_CMB.f90 +Take care of the new power spectra parameters + +- cosmomc/settings.f90 +num_init_power modified + +- cosmomc/MCMC.f90 +Add MpiRank output in the logs + +- cosmomc/GetDist.f90 +3d transparent plots of the mean likelihoods. Try colormap('copper'). + +- cosmomc/driver.F90 +2nd instance in mpirun shifts the file names. + +- cosmomc/params.ini +New keys for the above material. + +- cosmomc/distparams.ini +New keys for the above material. + + diff --git a/camb/Makefile b/camb/Makefile index 5c09a67..65d2274 100644 --- a/camb/Makefile +++ b/camb/Makefile @@ -1,83 +1,115 @@ -#CAMB Makefile +# >>> DESIGNED FOR GMAKE <<< +#CAMB System unified Makefile + +ext=$(shell uname | cut -c1-3) +ifeq ($(ext),IRI) +F90C=f90 +FFLAGS = -Ofast -mp -n32 -LANG:recursive=ON +LFLAGS= +endif -#Set FISHER=Y to compile bispectrum fisher matrix code -FISHER= +ifeq ($(ext),Lin) +F90C=gfortran +FFLAGS= -O -fopenmp +LFLAGS= +endif -#Edit for your compiler -#Note there are many old ifc versions, some of which behave oddly +ifeq ($(ext),OSF) +F90C=f90 +FFLAGS= -omp -O -arch host -math_library fast -tune host -fpe1 +LFLAGS= +endif +ifeq ($(ext),Sun) +F90C=f90 +FFLAGS= -O4 -xarch=native64 -openmp -ftrap=%none +LFLAGS= +endif -#Intel , -openmp toggles mutli-processor: -#note version 10.0 gives wrong result for lensed when compiled with -openmp [fixed in 10.1] -F90C = ifort -FFLAGS = -openmp -fast -W0 -WB -fpp2 -vec_report0 -ifneq ($(FISHER),) -FFLAGS += -mkl +ifeq ($(ext),AIX) +F90C=xlf90_r +FFLAGS= -O4 -qsmp=omp -qmaxmem=-1 -qstrict -qfree=f90 -qsuffix=f=f90:cpp=F90 +LFLAGS= endif -#Gfortran compiler: -#The options here work in v4.5, delete from RHS in earlier versions (15% slower) -#if pre v4.3 add -D__GFORTRAN__ -#With v4.6+ try -Ofast -march=native -fopenmp -#On my machine v4.5 is about 20% slower than ifort -#F90C = gfortran -#FFLAGS = -O3 -fopenmp -ffast-math -march=native -funroll-loops - - -#Old Intel ifc, add -openmp for multi-processor (some have bugs): -#F90C = ifc -#FFLAGS = -O2 -Vaxlib -ip -W0 -WB -quiet -fpp2 -#some systems can can also add e.g. -tpp7 -xW - -#G95 compiler -#F90C = g95 -#FFLAGS = -O2 - -#SGI, -mp toggles multi-processor. Use -O2 if -Ofast gives problems. -#F90C = f90 -#FFLAGS = -Ofast -mp - -#Digital/Compaq fortran, -omp toggles multi-processor -#F90C = f90 -#FFLAGS = -omp -O4 -arch host -math_library fast -tune host -fpe1 - -#Absoft ProFortran, single processor: -#F90C = f95 -#FFLAGS = -O2 -cpu:athlon -s -lU77 -w -YEXT_NAMES="LCS" -YEXT_SFX="_" - -#NAGF95, single processor: -#F90C = f95 -#FFLAGS = -DNAGF95 -O3 - -#PGF90 -#F90C = pgf90 -#FFLAGS = -O2 -DESCAPEBACKSLASH -Mpreprocess - -#Sun V880 -#F90C = mpf90 -#FFLAGS = -O4 -openmp -ftrap=%none -dalign -DMPI - -#Sun parallel enterprise: -#F90C = f95 -#FFLAGS = -O2 -xarch=native64 -openmp -ftrap=%none -#try removing -openmp if get bus errors. -03, -04 etc are dodgy. - -#IBM XL Fortran, multi-processor (run gmake) -#F90C = xlf90_r -#FFLAGS = -DESCAPEBACKSLASH -DIBMXL -qsmp=omp -qsuffix=f=f90:cpp=F90 -O3 -qstrict -qarch=pwr3 -qtune=pwr3 - -#Settings for building camb_fits -#Location of FITSIO and name of library -FITSDIR = /home/cpac/cpac-tools/lib -FITSLIB = cfitsio -#Location of HEALPIX for building camb_fits -HEALPIXDIR = /home/cpac/cpac-tools/healpix - -ifneq ($(FISHER),) + +#Files containing evolution equations initial power spectrum module +EQUATIONS = equations +POWERSPECTRUM = power_sr +REIONIZATION = reionization +RECOMBINATION = recfast +BISPECTRUM = SeparableBispectrum +DENABLE_FISHER= + +#Module doing non-linear scaling +NONLINEAR = halofit + +#Driver program +DRIVER = inidriver.F90 +#DRIVER = sigma8.f90 +#DRIVER = tester.f90 + + +CAMBLIB = libcamb.a + +ifneq ($(DENABLE_FISHER),) FFLAGS += -DFISHER +LFLAGS += -llapack -lblas EXTCAMBFILES = Matrix_utils.o else EXTCAMBFILES = endif -include ./Makefile_main +HEALPIXDIR= + +#Shouldn't need to change anything else... + +F90FLAGS = $(FFLAGS) +HEALPIXLD = -L$(HEALPIXDIR)/lib -lhealpix + +CAMBOBJ = constants.o utils.o $(EXTCAMBFILES) subroutines.o inifile.o $(POWERSPECTRUM).o $(RECOMBINATION).o $(REIONIZATION).o modules.o \ + bessels.o $(EQUATIONS).o $(NONLINEAR).o lensing.o $(BISPECTRUM).o \ + cmbmain.o camb.o + +default: camb.$(ext) + +all: camb.$(ext) $(CAMBLIB) + +subroutines.o: constants.o utils.o +$(POWERSPECTRUM): subroutines.o inifile.o +$(RECOMBINATION).o: subroutines.o inifile.o +$(REIONIZATION).o: constants.o inifile.o +modules.o: $(REIONIZATION).o $(POWERSPECTRUM).o $(RECOMBINATION).o +bessels.o: modules.o +$(EQUATIONS): bessels.o +$(NONLINEAR).o: modules.o +lensing.o: bessels.o +$(BISPECTRUM).o: lensing.o modules.o +cmbmain.o: lensing.o $(NONLINEAR).o $(EQUATIONS).o $(BISPECTRUM).o +camb.o: cmbmain.o +Matrix_utils.o: utils.o + +camb.$(ext): $(CAMBOBJ) $(DRIVER) + $(F90C) $(F90FLAGS) $(CAMBOBJ) $(DRIVER) $(LFLAGS) -o $@ + +$(CAMBLIB): $(CAMBOBJ) + ar -r $@ $? + +camb_fits: writefits.f90 $(CAMBOBJ) $(DRIVER) + $(F90C) $(F90FLAGS) -I$(HEALPIXDIR)/include tils.o $(CAMBOBJ) writefits.f90 $(DRIVER) $(HEALPIXLD) $(LFLAGS) -DWRITE_FITS -o $@ + +%.o: %.f90 + $(F90C) $(F90FLAGS) -c $*.f90 + +utils.o: + $(F90C) $(F90FLAGS) -c utils.F90 + +$(BISPECTRUM).o: + $(F90C) $(F90FLAGS) -c $(BISPECTRUM).F90 + +Matrix_utils.o: + $(F90C) $(F90FLAGS) -c Matrix_utils.F90 + +clean: + -rm -f *.o *.a *.d core *.mod + diff --git a/camb/cmbmain.f90 b/camb/cmbmain.f90 index 90ce721..821b73c 100644 --- a/camb/cmbmain.f90 +++ b/camb/cmbmain.f90 @@ -657,17 +657,24 @@ contains SourceAccuracyBoost = AccuracyBoost if (CP%WantScalars .and. CP%Reion%Reionization .and. CP%AccuratePolarization) then - dlnk0=2._dl/10/SourceAccuracyBoost +!wig +! dlnk0=2._dl/10/SourceAccuracyBoost + dlnk0=2._dl/10/SourceAccuracyBoost/kSrcSampleBoost !Need this to get accurate low l polarization else - dlnk0=5._dl/10/SourceAccuracyBoost +! dlnk0=5._dl/10/SourceAccuracyBoost + dlnk0=5._dl/10/SourceAccuracyBoost/kSrcSampleBoost +!end wig if (CP%closed) dlnk0=dlnk0/2 end if if (CP%AccurateReionization) dlnk0 = dlnk0/2 - - dkn1=0.6_dl/taurst/SourceAccuracyBoost - dkn2=0.9_dl/taurst/SourceAccuracyBoost +!wig +! dkn1=0.6_dl/taurst/SourceAccuracyBoost +! dkn2=0.9_dl/taurst/SourceAccuracyBoost + dkn1=0.6_dl/taurst/SourceAccuracyBoost/kSrcSampleBoost + dkn2=0.9_dl/taurst/SourceAccuracyBoost/kSrcSampleBoost +!end wig if (HighAccuracyDefault) dkn2=dkn2/1.2 if (CP%WantTensors .or. CP%WantVectors) then dkn1=dkn1 *0.8_dl @@ -1082,8 +1089,10 @@ contains qmax_int = min(qmax,max_bessels_etak/CP%tau0) - - IntSampleBoost=AccuracyBoost +!wig +! IntSampleBoost=AccuracyBoost + IntSampleBoost=AccuracyBoost*kIntSampleBoost +!end wig if (do_bispectrum) then IntSampleBoost = IntSampleBoost * 2 if (hard_bispectrum) IntSampleBoost = IntSampleBoost * 2 diff --git a/camb/inidriver.F90 b/camb/inidriver.F90 index b355761..73102b4 100644 --- a/camb/inidriver.F90 +++ b/camb/inidriver.F90 @@ -282,6 +282,20 @@ end if end if +!wig + + kSrcSampleBoost= Ini_Read_Double('k_src_sample_boost',1.d0) + kIntSampleBoost= Ini_Read_Double('k_int_sample_boost',1.d0) + DoClsInterpol = Ini_Read_Logical('do_cls_interpol',.true.) + ComputeEveryl = Ini_Read_Logical('compute_every_l',.true.) + + if (FeedbackLevel > 0) then + write (*,*)'do_cls_interpol is',DoClsInterpol + write (*,*)'compute_every_l is',ComputeEveryl + write (*,*)'primordial power spectra is: ',Power_Name + endif +!end wig + call Ini_Close if (.not. CAMB_ValidateParams(P)) stop 'Stopped due to parameter error' @@ -293,6 +307,23 @@ if (FeedbackLevel > 0) then Age = CAMB_GetAge(P) write (*,'("Age of universe/GYr = ",f7.3)') Age +!wig + if ((Power_Name.eq.'power_sr').or.(Power_Name.eq.'power_dbi')) then + + do i=1,P%InitPower%nn + write (*,'("Slow-roll epsilon1 = ",f12.8)') P%InitPower%eps1(i) + write (*,'("Slow-roll epsilon2 = ",f12.8)') P%InitPower%eps2(i) + write (*,'("Slow-roll epsilon3 = ",f12.8)') P%InitPower%eps3(i) + write (*,'("DBI delta1 = ",f12.8)') P%InitPower%del1(i) + write (*,'("DBI gamma = ",f12.8)') P%InitPower%gam(i) + write (*,'("TPL amplitude = ",f12.8)') P%InitPower%Xsigma0(i) + write (*,'("TPL scale = ",f12.8)') P%InitPower%loginvsigma0(i) + write (*,'("TPL phase = ",f12.8)') P%InitPower%varphi(i) + enddo + else + stop 'Power_Name unknown' + endif +!end wig end if if (global_error_flag==0) call CAMB_GetResults(P) diff --git a/camb/modules.f90 b/camb/modules.f90 index 6053b4c..7764896 100644 --- a/camb/modules.f90 +++ b/camb/modules.f90 @@ -38,8 +38,10 @@ character(LEN=*), parameter :: version = 'Jan_12' integer :: FeedbackLevel = 0 !if >0 print out useful information about the model - - logical, parameter :: DebugMsgs=.false. !Set to true to view progress and timing +!wig +! logical, parameter :: DebugMsgs=.false. !Set to true to view progress and timing + logical, parameter :: DebugMsgs=.false. +!end wig logical, parameter :: DebugEvolution = .false. !Set to true to do all the evolution for all k @@ -187,15 +189,17 @@ real(dl) :: lSampleBoost=1._dl !Increase lSampleBoost to increase sampling in lSamp%l for Cl interpolation - - real(dl) :: AccuracyBoost =1._dl +!wig + real(dl) :: AccuracyBoost =8._dl +!end wig !Decrease step sizes, etc. by this parameter. Useful for checking accuracy. !Can also be used to improve speed significantly if less accuracy is required. !or improving accuracy for extreme models. !Note this does not increase lSamp%l sampling or massive neutrino q-sampling - - real(sp) :: lAccuracyBoost=1. +!wig + real(sp) :: lAccuracyBoost=2._dl +!end wig !Boost number of multipoles integrated in Boltzman heirarchy integer, parameter :: lmin = 2 @@ -212,6 +216,13 @@ ! lmax is max possible number of l's evaluated integer, parameter :: lmax_arr = l0max + +!wig + real(dl) :: kSrcSampleBoost=1._dl + real(dl) :: kIntSampleBoost=1._dl + logical :: DoClsInterpol=.true. + logical :: ComputeEveryl=.true. +!end wig character(LEN=1024) :: highL_unlensed_cl_template = 'HighLExtrapTemplate_lenspotentialCls.dat' !fiducial high-accuracy high-L C_L used for making small cosmology-independent numerical corrections @@ -581,6 +592,25 @@ integer lind, lvar, step,top,bot,ls(lmax_arr) real(dl) AScale +!wig + if (ComputeEveryl) then + write(*,*) 'Warning: computing every l' + if (max_l.gt.lmax_arr) then + write(*,*)'lmax_arr maxl',lmax_arr,max_l + stop + endif + lind=0 + do lvar=2, max_l + lind=lind+1 + ls(lind)=lvar + end do + + lSet%l0=lind + lSet%l = ls(1:lind) + + else +!end wig + Ascale=scale/lSampleBoost if (lSampleBoost >=50) then @@ -720,6 +750,9 @@ end if lSet%l0=lind lSet%l(1:lind) = ls(1:lind) +!wig + endif +!end wig end subroutine initlval @@ -738,8 +771,10 @@ if (max_ind > lSet%l0) stop 'Wrong max_ind in InterpolateClArr' xl = real(lSet%l(1:lSet%l0),dl) - call spline(xl,iCL(1),max_ind,cllo,clhi,ddCl(1)) - + call spline(xl,iCl(1),max_ind,cllo,clhi,ddCl(1)) +!wig + if (DoClsInterpol) then + llo=1 do il=lmin,lSet%l(max_ind) xi=il @@ -755,7 +790,22 @@ +(b0**3-b0)*ddCl(lhi))*ho**2/6 end do - + + else + llo=1 + do il=2,lSet%l(max_ind) + xi=il + if ((xi > lSet%l(llo+1)).and.(llo < max_ind)) then + llo=llo+1 + end if + + all_Cl(il) = iCl(llo+1) + + end do + all_Cl(2)=iCl(1) + endif +!end wig + end subroutine InterpolateClArr subroutine InterpolateClArrTemplated(lSet,iCl, all_Cl, max_ind, template_index) @@ -2041,6 +2091,10 @@ dlnkh = 0.02 points = log(MTrans%TransferData(Transfer_kh,MTrans%num_q_trans,itf)/minkh)/dlnkh+1 ! dlnkh = log(MTrans%TransferData(Transfer_kh,MTrans%num_q_trans,itf)/minkh)/(points-0.999) +!wig + write(*,*)'Transfert_SaveToFiles: dlnkh= points= ',dlnkh,points + write(*,*)'You should check with transfer_k_per_logint > 0' +!endwig allocate(outpower(points,CP%InitPower%nn)) do in = 1, CP%InitPower%nn call Transfer_GetMatterPower(MTrans,outpower(1,in), itf, in, minkh,dlnkh, points) diff --git a/camb/params.ini b/camb/params.ini index cf5b821..54fdde6 100644 --- a/camb/params.ini +++ b/camb/params.ini @@ -1,12 +1,12 @@ #Parameters for CAMB #output_root is prefixed to output file names -output_root = test +output_root = tpl #What to do get_scalar_cls = T get_vector_cls = F -get_tensor_cls = F +get_tensor_cls = T get_transfer = F #if do_lensing then scalar_output_file contains additional columns of l^4 C_l^{pp} and l^3 C_l^{pT} @@ -65,18 +65,27 @@ nu_mass_degeneracies = 0 #Fraction of total omega_nu h^2 accounted for by each eigenstate, eg. 0.5 0.5 nu_mass_fractions = 1 -#Initial power spectrum, amplitude, spectral index and running. Pivot k in Mpc^{-1}. -initial_power_num = 1 -pivot_scalar = 0.05 -pivot_tensor = 0.05 -scalar_amp(1) = 2.1e-9 -scalar_spectral_index(1) = 0.96 -scalar_nrun(1) = 0 -tensor_spectral_index(1) = 0 -#ratio is that of the initial tens/scal power spectrum amplitudes -initial_ratio(1) = 1 -#note vector modes use the scalar settings above +#Type of initial power spectrum: power_sr or power_dbi +initial_power_num = 1 +power_name = power_sr + +#slow-roll parameters +ln[10^{10} P_scalar] = 0.303161E+01 +eps1(1) = 0.210391E-02 +eps2(1) = 0.421584E-01 +eps3(1) = 0 +#dbi parameter +gam(1) = 1. +del1(1) = 0. + +#wiggles parameters +logeps1invsigma0(1) = 1.5 +Xsigma0(1) = 0.1 +varphi(1) = 0 + +#tpl pivot +k_star = 0.05 #Reionization, ignored unless reionization = T, re_redshift measures where x_e=0.5 reionization = T @@ -98,6 +107,7 @@ RECFAST_fudge_He = 0.86 RECFAST_Heswitch = 6 RECFAST_Hswitch = T + #Initial scalar perturbation mode (adiabatic=1, CDM iso=2, Baryon iso=3, # neutrino density iso =4, neutrino velocity iso = 5) initial_condition = 1 @@ -121,7 +131,7 @@ CMB_outputscale = 7.4311e12 #transfer_k_per_logint=5 samples fixed spacing in log-k #transfer_interp_matterpower =T produces matter power in regular interpolated grid in log k; # use transfer_interp_matterpower =F to output calculated values (e.g. for later interpolation) -transfer_high_precision = F +transfer_high_precision = T transfer_kmax = 2 transfer_k_per_logint = 0 transfer_num_redshifts = 1 @@ -208,7 +218,7 @@ high_accuracy_default=F #Increase accuracy_boost to decrease time steps, use more k values, etc. #Decrease to speed up at cost of worse accuracy. Suggest 0.8 to 3. -accuracy_boost = 1 +accuracy_boost = 4 #Larger to keep more terms in the hierarchy evolution. l_accuracy_boost = 1 @@ -218,3 +228,15 @@ l_accuracy_boost = 1 #interpolation errors may be up to 3% #Decrease to speed up non-flat models a bit l_sample_boost = 1 + +# Boost the sampling on k sources only, in unit of AccuracyBoost +k_src_sample_boost = 1. + +# Boost the sampling on k line of sight integral only, in unit of AccuracyBoost +k_int_sample_boost = 1. + +#Use spline interpolation for the Cls +do_cls_interpol = F + +# Remove undersampling of the Cls: if true lSampleBoost has no effect +compute_every_l = T diff --git a/camb/power_sr.f90 b/camb/power_sr.f90 new file mode 100644 index 0000000..5a518d2 --- /dev/null +++ b/camb/power_sr.f90 @@ -0,0 +1,544 @@ +!This module provides the initial power spectra, parameterized as an expansion in ln k +! +! ln P = ln A_s + (n_s -1)*ln(k/k_0) + n_{run}/2 * ln(k/k_0)^2 +! +! so if n_run = 0 +! +! P = A_s (k/k_0_scalar)^(n_s-1) +! +!for the scalar spectrum, when an(in) is the in'th spectral index. k_0_scalar +!is a pivot scale, fixed here to 0.05/Mpc (change it below as desired). +! +!This module uses the same inputs an(in), ant(in) and rat(in) as CMBFAST, however here +!rat(in) is used to set the ratio of the initial power spectra, so here +! +!** rat(in) is not the Cl quadrupole ratio *** +! +!in general models the quadrupole ratio depends in a complicated way on the ratio of the initial +!power spectra + +!The absolute normalization of the Cls is unimportant here, but the relative ratio +!of the tensor and scalar Cls generated with this module will be correct for general models + + +!The OutputNormalization parameter controls the final output +!Absolute Cls can be obtained by setting OuputNormalization=outNone, otherwise the overall normalization +!of the power spectra doesn't matter + +!This version December 2003 - changed default tensor pivot to 0.05 (consistent with CMBFAST 4.5) + + module InitialPower + use Precision + implicit none + + private + +!wig character(LEN=*), parameter :: Power_Name = 'power_tilt' + character(80) :: Power_Name = 'power_sr' + logical, parameter :: useTplPhase = .false. + logical, save :: useSecondOrder = .false. +!end wig + integer, parameter :: nnmax= 5 + !Maximum possible number of different power spectra to use + + Type InitialPowerParams + + integer nn !Must have this variable + !The actual number of power spectra to use + + !For the default implementation return power spectra based on spectral indices + real(dl) an(nnmax) !scalar spectral indices + real(dl) n_run(nnmax) !running of spectral index + real(dl) ant(nnmax) !tensor spectral indices + real(dl) rat(nnmax) !ratio of scalar to tensor initial power spectrum amplitudes + real(dl) k_0_scalar, k_0_tensor + real(dl) ScalarPowerAmp(nnmax) + +!wig +! slow-roll power + real(dl) P_scalar + real(dl) k_star + real(dl) eps1(nnmax) + real(dl) eps2(nnmax) + real(dl) eps3(nnmax) +!dbi params + real(dl) gam(nnmax) + real(dl) del1(nnmax) +! tpl power + real(dl) invsigma0(nnmax) + real(dl) loginvsigma0(nnmax) + real(dl) logeps1invsigma0(nnmax) + real(dl) Xsigma0(nnmax) + real(dl) varphi(nnmax) +!Internal parameters + real(dl) ks_pivot !scalar pivot wave number + real(dl) kt_pivot !tensor pivot wave number + real(dl) ko_pivot !wiggles pivot wave number + real(dl) P_0_scalar(nnmax) !scalar normalisation during inflation + real(dl) P_0_tensor(nnmax) !tensor normalisation during inflation + real(dl) as0(nnmax) !scalar power spectrum coefficients: order 0 + real(dl) as1(nnmax) !order 1 + real(dl) as2(nnmax) !order 2 + real(dl) amps0(nnmax) !amplitudes of tpl effect in scalar power: order 0 + real(dl) amps1(nnmax) !order 1 + real(dl) amps2(nnmax) !order 2 + real(dl) args0(nnmax) !argument of the modulations: order 0 + real(dl) args1(nnmax) !order 1 + real(dl) args2(nnmax) !order 2 + real(dl) at0(nnmax) !Tensor power spectrum coefficients: same as scalars + real(dl) at1(nnmax) + real(dl) at2(nnmax) + real(dl) ampt0(nnmax) + real(dl) ampt1(nnmax) + real(dl) ampt2(nnmax) + real(dl) argt0(nnmax) + real(dl) argt1(nnmax) + real(dl) argt2(nnmax) +!end wig + + end Type InitialPowerParams + + real(dl) curv !Curvature contant, set in InitializePowers + + Type(InitialPowerParams) :: P + +!Make things visible as neccessary... + + public InitialPowerParams, InitialPower_ReadParams, InitializePowers, ScalarPower, TensorPower + public nnmax,Power_Descript, Power_Name, SetDefPowerParams +! public + contains + + + subroutine SetDefPowerParams(AP) + Type (InitialPowerParams) :: AP + + AP%nn = 1 !number of initial power spectra +!wig + + AP%an = 1 !scalar spectral index + AP%n_run = 0 !running of scalar spectral index + AP%ant = 0 !tensor spectra index + AP%rat = 1 + AP%k_0_scalar = 0.05 + AP%k_0_tensor = 0.05 + AP%ScalarPowerAmp = 1 + + AP%eps1 = 0.01 + AP%eps2 = 0.01 + AP%eps3 = 0. + AP%P_scalar=1.d-9 + AP%k_star = 0.05 + + AP%del1 = 0. + AP%gam = 1. + + + AP%Xsigma0 = 0. + AP%logeps1invsigma0 = 0. + AP%loginvsigma0 = AP%logeps1invsigma0 - log10(AP%eps1) + AP%invsigma0=10**(AP%loginvsigma0) + AP%varphi=0. + +!end wig + + end subroutine SetDefPowerParams + + subroutine InitializePowers(AParamSet,acurv) + Type (InitialPowerParams) :: AParamSet + !Called before computing final Cls in cmbmain.f90 + !Could read spectra from disk here, do other processing, etc. + + real(dl) acurv +!wig + integer :: i +!from Hankel functions + real(dl), parameter :: C_const = -0.7296 +!wkb or uniform approx gives a slightly different constant + real(dl), parameter :: D_const = -0.7652 +! real(dl), parameter :: C_const = D_const + + real(dl), parameter :: pi = 3.14159265 +!end wig + + if (AParamSet%nn > nnmax) then + write (*,*) 'To use ',AParamSet%nn,'power spectra you need to increase' + write (*,*) 'nnmax in power_tilt.f90, currently ',nnmax + end if + P = AParamSet + + curv=acurv + +!Write implementation specific code here... +!wig + + if ((Power_Name.eq.'power_sr').or.(Power_Name.eq.'power_dbi')) then + if(abs(curv) .gt. 1.d-3) then + write(*,*)'Non flat cosmology, curv = ',curv + write(*,*)'Cannot use SR or TPL spectrum.' + stop + endif + + P%ks_pivot = P%k_star + P%kt_pivot = P%k_star + P%ko_pivot = P%k_star + + + do i=1, P%nn + +!TODO: derive second order tpl corrections? + if (useSecondOrder) then + if (P%Xsigma0(i).ne.0.) then + useSecondOrder=.false. + write(*,*)'PowerIni: SR second order disabled: TPL not implemented! ' + endif + if ((P%del1(i).ne.0.).or.(P%gam(i).ne.1.)) then + useSecondorder = .false. + write(*,*)'PowerIni: SR second order disabled: DBI slow-roll not implemented!' + endif + endif + + if ((power_Name.eq.'power_sr').and. & + ((P%del1(i).ne.0.).or.(P%gam(i).ne.1.)) ) then + write(*,*)'power_sr with non-vanishing DBI params!' + write(*,*)'resetting to standard SR' + P%del1(i) = 0. + P%gam(i) = 1. + endif + + +!first order tpl corrections + + P%loginvsigma0(i) = P%logeps1invsigma0(i) - log10(P%eps1(i)) + P%invsigma0(i)=10**(P%loginvsigma0(i)) + + P%amps0(i) = 2.*P%Xsigma0(i) + P%amps1(i) = pi*P%Xsigma0(i)*(2.*P%eps1(i) + P%eps2(i)) + P%amps2(i) = 0. + if (useTplPhase) then + P%args0(i) = 2.*P%invsigma0(i)*(1. + P%eps1(i)) + P%varphi(i) + else + P%args0(i) = P%varphi(i) + endif + P%args1(i) = 2.*P%invsigma0(i)*P%eps1(i) + P%args2(i) = 0. + + P%ampt0(i) = P%amps0(i) + P%ampt1(i) = pi*P%Xsigma0(i)*2.*P%eps1(i) + P%ampt2(i) = 0. + P%argt0(i) = P%args0(i) + P%argt1(i) = P%args1(i) + P%argt2(i) = 0. + + +!first and second order slowroll + + P%as0(i) = 1. + P%eps1(i)*(-2.*(C_const+1.))-P%eps2(i)*C_const & + + (C_const + 2.)*P%del1(i) + P%as1(i) = -2.*P%eps1(i) - P%eps2(i) + P%del1(i) + P%as2(i) = 0. + + P%at0(i) = 1. + P%eps1(i)*(-2.*(C_const+1.)) + P%at1(i) = -2.*P%eps1(i) + P%at2(i) = 0. + + if (useSecondOrder) then + + + P%as0(i) = P%as0(i) & + + P%eps1(i)*P%eps1(i) * (2.*C_const**2 + 2.*C_const + pi**2/2. - 5.) & + + P%eps1(i)*P%eps2(i) * (C_const**2 - C_const + 7.*pi**2/12. - 7.) & + + P%eps2(i)*P%eps2(i) * (0.5*C_const**2 + pi**2/8. - 1.) & + + P%eps2(i)*P%eps3(i) * (-0.5*C_const**2 + pi**2/24.) + + P%as1(i) = P%as1(i) & + + P%eps1(i)*P%eps1(i) * 2.*(2.*C_const + 1.) & + + P%eps1(i)*P%eps2(i) * (2.*C_const - 1.) & + + P%eps2(i)*P%eps2(i) * C_const & + + P%eps2(i)*P%eps3(i) * (-C_const) + + P%as2(i) = P%as2(i) & + + P%eps1(i)*P%eps1(i) * 4. & + + P%eps1(i)*P%eps2(i) * 2. & + + P%eps2(i)*P%eps2(i) * 1. & + + P%eps2(i)*P%eps3(i) * (-1.) + + + P%at0(i) = P%at0(i) & + + P%eps1(i)*P%eps1(i) * (2.*C_const**2 + 2.*C_const + pi**2/2. - 5.) & + + P%eps1(i)*P%eps2(i) * (-C_const**2 - 2.*C_const + pi**2/12. - 2.) + + P%at1(i) = P%at1(i) & + + P%eps1(i)*P%eps1(i) * 2.*(2.*C_const + 1.) & + + P%eps1(i)*P%eps2(i) * 2.*(-C_const - 1.) + + P%at2(i) = P%at2(i) & + + P%eps1(i)*P%eps1(i) * 4. & + + P%eps1(i)*P%eps2(i) * (-2.) + + endif + + + !Relative normalisation of scalar and tensor spectra + + P%P_0_scalar(i)=P%P_scalar/(P%as0(i)) +! P%P_0_tensor(i)=P%P_scalar/(P%as0(i))*P%eps1(i)*16. + P%P_0_tensor(i)=P%P_scalar/(P%as0(i))*P%eps1(i)*16/P%gam(i) + + enddo + + else + stop 'No such initial power spectra' + endif +!end wig + + end subroutine InitializePowers + + + function ScalarPower(k,in) + + !"in" gives the index of the power to return for this k + !ScalarPower = const for scale invariant spectrum + !The normalization is defined so that for adiabatic perturbations the gradient of the 3-Ricci + !scalar on co-moving hypersurfaces receives power + ! < |D_a R^{(3)}|^2 > = int dk/k 16 k^6/S^6 (1-3K/k^2)^2 ScalarPower(k) + !In other words ScalarPower is the power spectrum of the conserved curvature perturbation given by + !-chi = \Phi + 2/3*\Omega^{-1} \frac{H^{-1}\Phi' - \Psi}{1+w} + !(w=p/\rho), so < |\chi(x)|^2 > = \int dk/k ScalarPower(k). + !Near the end of inflation chi is equal to 3/2 Psi. + !Here nu^2 = (k^2 + curv)/|curv| + + !This power spectrum is also used for isocurvature modes where + !< |\Delta(x)|^2 > = \int dk/k ScalarPower(k) + !For the isocurvture velocity mode ScalarPower is the power in the neutrino heat flux. + + real(dl) ScalarPower,k, lnrat + integer in + +!wig + real :: angle + +! lnrat = log(k/P%k_0_scalar) +! ScalarPower=P%ScalarPowerAmp(in)*exp((P%an(in)-1)*lnrat + P%n_run(in)/2*lnrat**2) + + lnrat = log(k/P%ks_pivot) + + + if ((Power_Name.eq.'power_sr').or.(Power_Name.eq.'power_dbi')) then + + angle = P%args0(in) + P%args1(in) * log(k/P%ko_pivot) + + ScalarPower = (P%as0(in) + P%as1(in)*lnrat + 0.5*P%as2(in)*lnrat**2) & + * (1. - P%amps0(in)*cos(angle)) - P%amps1(in)*sin(angle) + + else + stop 'No such initial power spectra' + endif + + ScalarPower = ScalarPower*P%P_0_scalar(in) + + if(ScalarPower .lt. 0.0) then + ScalarPower =0. + end if + + +!end wig + +! ScalarPower = ScalarPower * (1 + 0.1*cos( lnrat*30 ) ) + + end function ScalarPower + + + function TensorPower(k,in) + + !TensorPower= const for scale invariant spectrum + !The normalization is defined so that + ! < h_{ij}(x) h^{ij}(x) > = \sum_nu nu /(nu^2-1) (nu^2-4)/nu^2 TensorPower(k) + !for a closed model + ! < h_{ij}(x) h^{ij}(x) > = int d nu /(nu^2+1) (nu^2+4)/nu^2 TensorPower(k) + !for an open model + !"in" gives the index of the power spectrum to return + !Here nu^2 = (k^2 + 3*curv)/|curv| + + + real(dl) TensorPower,k + real(dl), parameter :: PiByTwo=3.14159265d0/2._dl + + integer in + +!wig + real :: lnrat,angle + +! TensorPower=P%rat(in)*P%ScalarPowerAmp(in)*exp(P%ant(in)*log(k/P%k_0_tensor)) +! if (curv < 0) TensorPower=TensorPower*tanh(PiByTwo*sqrt(-k**2/curv-3)) + + lnrat = log(k/P%kt_pivot) + + if ((Power_Name.eq.'power_sr').or.(Power_Name.eq.'power_dbi')) then + + angle = P%argt0(in) + P%argt1(in) * log(k/P%ko_pivot) + + TensorPower = (P%at0(in) + P%at1(in)*lnrat + 0.5*P%at2(in)*lnrat**2) & + * (1. - P%ampt0(in)*cos(angle)) - P%ampt1(in)*sin(angle) + + else + stop 'No such initial power spectra' + endif + + TensorPower = TensorPower*P%P_0_tensor(in) + + if (curv < 0) TensorPower=TensorPower*tanh(PiByTwo*sqrt(-k**2/curv-3)) + + if(TensorPower .lt. 0.0) then + TensorPower=0. + endif + +!end wig + + + end function TensorPower + + !Get parameters describing parameterisation (for FITS file) + function Power_Descript(in, Scal, Tens, Keys, Vals) + character(LEN=8), intent(out) :: Keys(*) + real(dl), intent(out) :: Vals(*) + integer, intent(IN) :: in + logical, intent(IN) :: Scal, Tens + integer num, Power_Descript + num=0 +!wig + + + if (Power_Name.eq.'power_sr') then + + num=num+1 + Keys(num) = 'k_star' + Vals(num) = P%k_star + num=num+1 + Keys(num) = 'P_scalar' + Vals(num) = P%P_scalar + num=num+1 + Keys(num) = 'eps1' + Vals(num) = P%eps1(in) + num=num+1 + Keys(num) = 'eps2' + Vals(num) = P%eps2(in) + num=num+1 + Keys(num) = 'eps3' + Vals(num) = P%eps3(in) + num=num+1 + Keys(num) = 'isigma0' + Vals(num) = P%invsigma0(in) + num=num+1 + Keys(num) = 'lisigma0' + Vals(num) = P%loginvsigma0(in) + num=num+1 + Keys(num) = 'Xsigma0' + Vals(num) = P%Xsigma0(in) + num=num+1 + Keys(num) = 'varphi' + Vals(num) = P%varphi(in) + + elseif (Power_Name.eq.'power_dbi') then + + num=num+1 + Keys(num) = 'k_star' + Vals(num) = P%k_star + num=num+1 + Keys(num) = 'P_scalar' + Vals(num) = P%P_scalar + num=num+1 + Keys(num) = 'eps1' + Vals(num) = P%eps1(in) + num=num+1 + Keys(num) = 'eps2' + Vals(num) = P%eps2(in) + num=num+1 + Keys(num) = 'eps3' + Vals(num) = P%eps3(in) + num=num+1 + Keys(num) = 'gam' + Vals(num) = P%gam(in) + num=num+1 + Keys(num) = 'del1' + Vals(num) = P%del1(in) + num=num+1 + Keys(num) = 'isigma0' + Vals(num) = P%invsigma0(in) + num=num+1 + Keys(num) = 'lisigma0' + Vals(num) = P%loginvsigma0(in) + num=num+1 + Keys(num) = 'Xsigma0' + Vals(num) = P%Xsigma0(in) + num=num+1 + Keys(num) = 'varphi' + Vals(num) = P%varphi(in) + + else + stop 'No such initial power spectra' + endif +!end wig + Power_Descript = num + + end function Power_Descript + + subroutine InitialPower_ReadParams(InitPower, Ini, WantTensors) + use IniFile + Type(InitialPowerParams) :: InitPower + Type(TIniFile) :: Ini + logical, intent(in) :: WantTensors + integer i + + InitPower%k_0_scalar = Ini_Read_Double_File(Ini,'pivot_scalar',InitPower%k_0_scalar) + InitPower%k_0_tensor = Ini_Read_Double_File(Ini,'pivot_tensor',InitPower%k_0_tensor) + InitPower%nn = Ini_Read_Int('initial_power_num') + if (InitPower%nn>nnmax) stop 'Too many initial power spectra - increase nnmax in InitialPower' + +!wig + + Power_Name = Ini_Read_String('power_name') + + if ((Power_Name.eq.'power_sr').or.(Power_Name.eq.'power_dbi')) then + + do i=1, InitPower%nn + +! if (P%WantScalars .or. P%WantTransfer) then + + InitPower%eps1(i)= Ini_Read_Double_Array_File(Ini,'eps1',i,0.01d0) + InitPower%eps2(i)=Ini_Read_Double_Array_File(Ini,'eps2',i,0.01d0) + InitPower%eps3(i)=Ini_Read_Double_Array_File(Ini,'eps3',i,0.00d0) + InitPower%gam(i)=Ini_Read_Double_Array_File(Ini,'gam',i,1.00d0) + InitPower%del1(i)=Ini_Read_Double_Array_File(Ini,'del1',i,0.00d0) + InitPower%logeps1invsigma0(i) & + = Ini_Read_Double_Array_File(Ini,'logeps1invsigma0',i,1d0) + InitPower%loginvsigma0(i) = InitPower%logeps1invsigma0(i) & + - log10(InitPower%eps1(i)) + InitPower%invsigma0(i) = 10**(InitPower%loginvsigma0(i)) + InitPower%Xsigma0(i) = Ini_Read_Double_Array_File(Ini,'Xsigma0',i,0d0) + InitPower%varphi(i) = Ini_Read_Double_Array_file(Ini,'varphi',i,0.d0) + +! endif + + enddo + + InitPower%k_star= Ini_Read_Double('k_star',0.05d0) + InitPower%P_scalar= 1e-10*exp(Ini_Read_Double('ln[10^{10} P_scalar]',1d0)) + + else + + stop 'No such initial power spectrum' + + endif + +!end wig + + + + + + + end subroutine InitialPower_ReadParams + + + end module InitialPower diff --git a/camb/readme.html b/camb/readme.html index f5ada26..cff517b 100644 --- a/camb/readme.html +++ b/camb/readme.html @@ -112,7 +112,7 @@ where all quantities are in the synchronous gauge and evaluated at the requested
halofit.f90
-Implements the NonLinear module, to calculate non linear scalings of the matter power spectrum as a function of redshift. Uses HALOFIT (astro-ph/0207664, code thanks to Robert Smith. Note this is only reliable at the several percent level for standard ΛCDM models with power law initial power spectra. This module can be replaced to use a different non-linear fitting method. +Implements the NonLinear module, to calculate non linear scalings of the matter power spectrum as a function of redshift. Uses HALOFIT (astro-ph/0207664, code thanks to Robert Smith, with tweaks from arXiv:1109.4416. Note this is only reliable at the several percent level for standard ΛCDM models with power law initial power spectra. This module can be replaced to use a different non-linear fitting method.
@@ -563,7 +563,9 @@ Implements the NonLinear module, to calculate non linear scalings of the matter
-Scalar errors should rarely exceed 0.3% for min(2500, L well into the damping tail) at default accuracy setting, and 0.1% for 500<L<2000 with high_accuracy_default=T. Matter power spectrum errors are usually dominated by interpolation in the acoustic oscillations, with about 0.2% accuracy with high_accuracy_default (but much better rms accuracy). +Scalar numerical errors should rarely exceed 0.3% for min(2500, L well into the damping tail) at default accuracy setting, and 0.1% for 500<L<2000 with high_accuracy_default=T. Matter power spectrum errors are usually dominated by interpolation in the acoustic oscillations, with about 0.2% accuracy with high_accuracy_default (but much better rms accuracy). For a detailed study of numerical accuracy as of January 2012 see arXiv:1201.3654. + + See also comparison with CMBFAST. Accuracy of course assumes the model is correct, and is dependent on RECFAST being the correct ionization history. Lensed C_l TT, TE and EE are accurate at the same level (to within the approximation that the lensing potential is linear, or the accuracy of the the HALOFIT non-linear model).Extreme models (e.g. scale > 4, h>1) may give errors of 5% or more. @@ -594,10 +596,15 @@ See also comparison with CMBFAST. Accuracy of course assu
REFERENCES
-Some notes and relevant Maple derivations are given here (see also the Appendix of astro-ph/0406096). The CAMB notes outline the equations and approximations used, and relation to standard synchronous-gauge and Newtonian-gauge variables. +Some notes and relevant Maple derivations are given here (see also the Appendix of astro-ph/0406096). The CAMB notes outline the equations and approximations used, and relation to standard synchronous-gauge and Newtonian-gauge variables; see also arXiv:1201.3654. There is a BibTex file of references (including CosmoMC).
+CMB power spectrum parameter degeneracies in the era of precision cosmology
+Cullan Howlett, Antony Lewis, Alex Hall, Anthony Challinor arXiv:1201.3654. +Efficient computation of CMB anisotropies in closed FRW Models
Antony Lewis, Anthony Challinor and Anthony Lasenby astro-ph/9911177 Ap. J. 538:473-476, 2000. @@ -647,7 +654,8 @@ Antony Lewis, astro-ph/0403583 HALOFITStable clustering, the halo model and nonlinear cosmological power spectra
-Smith, R. E. and others, astro-ph/0207664 +Smith, R. E. and others, astro-ph/0207664. +RECOMBINATION
@@ -696,13 +704,25 @@ The Cosmic Linear Anisotropy Solving System (CLASS) II: Blas, Diego and Lesgourgues, Julien and Tram, Thomas. arXiv:1104.2933
+Massive Neutrinos ++CMB power spectrum parameter degeneracies in the era of precision cosmology +
+Cullan Howlett, Antony Lewis, Alex Hall, Anthony Challinor. +arXiv:1201.3654 ++
Evolution of cosmological dark matter perturbations
+Antony Lewis and Anthony Challinor astro-ph/0203507 +Phys. Rev. D66, 023531 (2002) + +Synchronous gauge theory and non-flat models
Complete treatment of CMB anisotropies in a FRW universe
Wayne Hu, Uros Seljak and Matias Zaldarriaga. Phys. Rev. D57:6, 3290-3301, 1998. astro-ph/9709066. -
WKB approx to hyperspherical Bessel functions @@ -719,10 +739,16 @@ Blas, Diego and Lesgourgues, Julien and Tram, Thomas. astro-ph/9603033 Ap.J. 469:2 437-444, 1996
+ +Integral solution for the microwave background + anisotropies in nonflat universes
+ Matias Zaldarriaga, Uros Seljak, Edmund Bertschinger. + ApJ. 494:491-501, 1998. astro-ph/9704265. + +CMBFAST for spatially closed universes
Uros Seljak and Matias Zaldariaga, astro-ph/9911219 --See also the references on the CMBFAST home page. +