| [3315] | 1 | // Check cmv / Wayne Hu coding of the transfert functions | 
|---|
| [3317] | 2 | // ATTENTION: ne pas appeler hu_power.c ici car il ecrase les initialisations de hu_tf_fit.c | 
|---|
| [3315] | 3 | #include "sopnamsp.h" | 
|---|
|  | 4 | #include "machdefs.h" | 
|---|
|  | 5 | #include <iostream> | 
|---|
|  | 6 | #include <stdlib.h> | 
|---|
|  | 7 | #include <stdio.h> | 
|---|
|  | 8 | #include <string.h> | 
|---|
|  | 9 | #include <math.h> | 
|---|
|  | 10 | #include <unistd.h> | 
|---|
|  | 11 | #include "ntuple.h" | 
|---|
|  | 12 |  | 
|---|
|  | 13 | #include "constcosmo.h" | 
|---|
|  | 14 | #include "pkspectrum.h" | 
|---|
|  | 15 | #include "hu_tf_fit.h" | 
|---|
|  | 16 |  | 
|---|
|  | 17 | int main(int narg,char *arg[]) | 
|---|
|  | 18 | { | 
|---|
| [3607] | 19 | double k1 = 1e-4, k2 = 10.; int_4 npt = 10000; | 
|---|
| [3315] | 20 | double h100 = 0.71, Om0 = 0.267804, Ob0 = 0.0444356, tcmb = T_CMB_Par; | 
|---|
| [3607] | 21 | //double h100 = 0.71, Om0 = 0.2736, Ob0 = 0.0456, tcmb = T_CMB_Par; //WMAP5+BAO+SN | 
|---|
|  | 22 | //double h100 = 0.5, Om0 = 0.2, Ob0 = 0.1, tcmb = T_CMB_Par; //papier de Hu | 
|---|
| [3619] | 23 | //double h100 = 0.71, Om0 = 1.0, Ob0 = 0.0444356, tcmb = T_CMB_Par; // Om=1 Ob<<1 | 
|---|
| [3315] | 24 |  | 
|---|
|  | 25 | cout<<"k1="<<k1<<"  k2="<<k2<<" npt="<<npt<<endl; | 
|---|
|  | 26 | cout<<"h100="<<h100<<" Om0="<<Om0<<" Ob0="<<Ob0<<" Tcmb="<<tcmb<<endl; | 
|---|
|  | 27 | cout<<"Om0*h^2="<<Om0*h100*h100<<" Ob0*h^2="<<Ob0*h100*h100<<endl; | 
|---|
|  | 28 | double fbaryon = Ob0/Om0; | 
|---|
|  | 29 | cout<<"fbaryon="<<fbaryon<<endl; | 
|---|
|  | 30 |  | 
|---|
|  | 31 | cout<<endl<<"TFset_parameters"<<endl; | 
|---|
|  | 32 | TFset_parameters(Om0*h100*h100,fbaryon,tcmb); | 
|---|
|  | 33 | TFprint_parameters(); | 
|---|
|  | 34 | double soundfithu = TFsound_horizon_fit(Om0,fbaryon,h100)/h100; | 
|---|
|  | 35 | cout<<"TFsound_horizon_fit = "<<soundfithu<<" Mpc"<<endl; | 
|---|
|  | 36 |  | 
|---|
|  | 37 | cout<<endl<<"TransfertEisenstein with baryon"<<endl; | 
|---|
|  | 38 | TransfertEisenstein Tfull(h100,Om0-Ob0,Ob0,tcmb,false,1); | 
|---|
|  | 39 |  | 
|---|
|  | 40 | cout<<endl<<"TransfertEisenstein with baryon without oscillation approx.2"<<endl; | 
|---|
|  | 41 | TransfertEisenstein Tnowig(h100,Om0-Ob0,Ob0,tcmb,false,1); | 
|---|
|  | 42 | Tnowig.SetNoOscEnv(2); | 
|---|
|  | 43 |  | 
|---|
|  | 44 | cout<<endl<<"TransfertEisenstein without baryon"<<endl; | 
|---|
|  | 45 | TransfertEisenstein Tnob(h100,Om0,0.,tcmb,true,1); | 
|---|
|  | 46 |  | 
|---|
|  | 47 | cout<<endl<<"Compare kpeak"<<endl; | 
|---|
|  | 48 | double kpeak = Tfull.KPeak(); | 
|---|
|  | 49 | double kpeakhu = TFk_peak(Om0,fbaryon,h100)*h100; | 
|---|
|  | 50 | cout<<"kpeak = "<<kpeak<<" "<<kpeakhu<<"  Mpc^-1  -> diff "<<kpeak-kpeakhu<<endl; | 
|---|
|  | 51 |  | 
|---|
| [3317] | 52 | const int n = 11; | 
|---|
| [3572] | 53 | const char *vname[n] = {"k","tf","tfnw","tfnb","tfc","tfb" | 
|---|
| [3317] | 54 | ,"hutf","hutfnw","hutfnb","hutfc","hutfb"}; | 
|---|
| [3315] | 55 | NTuple nt(n,vname); | 
|---|
|  | 56 | double xnt[n]; | 
|---|
|  | 57 |  | 
|---|
|  | 58 | double kmax[5]={0,0,0,0,0}; | 
|---|
|  | 59 | double tmax[5]={0.,0.,0.,0.,0.}; | 
|---|
|  | 60 | double lnk1 = log10(k1), lnk2=log10(k2), dlnk=(lnk2-lnk1)/npt; | 
|---|
|  | 61 | for(double lnk=lnk1;lnk<lnk2+dlnk/2.;lnk+=dlnk) { | 
|---|
|  | 62 | double k = pow(10.,lnk); | 
|---|
|  | 63 | //if(fabs(lnk-log10(0.0186209))>1e-5) continue; | 
|---|
| [3348] | 64 | Tfull.SetReturnPart(TransfertEisenstein::ALL); double tf = Tfull(k); | 
|---|
| [3315] | 65 | double tfnw = Tnowig(k); | 
|---|
|  | 66 | double tfnb = Tnob(k); | 
|---|
| [3348] | 67 | Tfull.SetReturnPart(TransfertEisenstein::CDM); double tfc = Tfull(k); | 
|---|
|  | 68 | Tfull.SetReturnPart(TransfertEisenstein::BARYON); double tfb = Tfull(k); | 
|---|
| [3315] | 69 | double hutfc, hutfb; | 
|---|
|  | 70 | double hutf = TFfit_onek(k,&hutfb,&hutfc); | 
|---|
|  | 71 | double hutfnw = TFnowiggles(Om0,fbaryon,h100,tcmb,k/h100); | 
|---|
|  | 72 | double hutfnb = TFzerobaryon(Om0,h100,tcmb,k/h100); | 
|---|
|  | 73 |  | 
|---|
|  | 74 |  | 
|---|
|  | 75 | if(fabs(tf-hutf)>tmax[0])     {kmax[0]=k; tmax[0]=fabs(tf-hutf);} | 
|---|
|  | 76 | if(fabs(tfnw-hutfnw)>tmax[1]) {kmax[1]=k; tmax[1]=fabs(tfnw-hutfnw);} | 
|---|
|  | 77 | if(fabs(tfnb-hutfnb)>tmax[2]) {kmax[2]=k; tmax[2]=fabs(tfnb-hutfnb);} | 
|---|
|  | 78 | if(fabs(tfc-hutfc)>tmax[3])   {kmax[3]=k; tmax[3]=fabs(tfc-hutfc);} | 
|---|
|  | 79 | if(fabs(tfb-hutfb)>tmax[4])   {kmax[4]=k; tmax[4]=fabs(tfb-hutfb);} | 
|---|
|  | 80 |  | 
|---|
|  | 81 | xnt[0]=k; | 
|---|
|  | 82 | xnt[1]=tf; xnt[2]=tfnw; xnt[3]=tfnb; xnt[4]=tfc; xnt[5]=tfb; | 
|---|
|  | 83 | xnt[6]=hutf; xnt[7]=hutfnw; xnt[8]=hutfnb; xnt[9]=hutfc; xnt[10]=hutfb; | 
|---|
|  | 84 | nt.Fill(xnt); | 
|---|
|  | 85 | } | 
|---|
|  | 86 |  | 
|---|
|  | 87 | cout<<"Maximum difference for:"<<endl; | 
|---|
|  | 88 | cout<<"tf:   "<<tmax[0]<<"  for k="<<kmax[0]<<endl; | 
|---|
|  | 89 | cout<<"tfnw: "<<tmax[1]<<"  for k="<<kmax[1]<<endl; | 
|---|
|  | 90 | cout<<"tfnb: "<<tmax[2]<<"  for k="<<kmax[2]<<endl; | 
|---|
|  | 91 | cout<<"tfc:  "<<tmax[3]<<"  for k="<<kmax[3]<<endl; | 
|---|
|  | 92 | cout<<"tfb:  "<<tmax[4]<<"  for k="<<kmax[4]<<endl; | 
|---|
|  | 93 |  | 
|---|
|  | 94 | cout<<">>>> Ecriture"<<endl; | 
|---|
|  | 95 | string tag = "cmvchkwhu.ppf"; | 
|---|
|  | 96 | POutPersist pos(tag); | 
|---|
|  | 97 | tag = "nt"; pos.PutObject(nt,tag); | 
|---|
|  | 98 |  | 
|---|
|  | 99 | return 0; | 
|---|
|  | 100 | } | 
|---|
|  | 101 |  | 
|---|
|  | 102 | /* | 
|---|
|  | 103 | openppf cmvchkwhu.ppf | 
|---|
|  | 104 |  | 
|---|
|  | 105 | set k k | 
|---|
|  | 106 | set k log10(k) | 
|---|
|  | 107 |  | 
|---|
|  | 108 | ###################### | 
|---|
|  | 109 | zone 3 1 | 
|---|
|  | 110 | n/plot nt.tf%$k ! ! "nsta connectpoints" | 
|---|
|  | 111 | n/plot nt.hutf%$k ! ! "nsta connectpoints red same" | 
|---|
|  | 112 | n/plot nt.tfc%$k ! ! "nsta connectpoints" | 
|---|
|  | 113 | n/plot nt.hutfc%$k ! ! "nsta connectpoints red same" | 
|---|
|  | 114 | n/plot nt.tfb%$k ! ! "nsta connectpoints" | 
|---|
|  | 115 | n/plot nt.hutfb%$k ! ! "nsta connectpoints red same" | 
|---|
|  | 116 | zone 2 1 | 
|---|
|  | 117 | n/plot nt.tfnw%$k ! ! "nsta connectpoints" | 
|---|
|  | 118 | n/plot nt.hutfnw%$k ! ! "nsta connectpoints red same" | 
|---|
|  | 119 | n/plot nt.tfnb%$k ! ! "nsta connectpoints" | 
|---|
|  | 120 | n/plot nt.hutfnb%$k ! ! "nsta connectpoints red same" | 
|---|
|  | 121 |  | 
|---|
|  | 122 | ###################### | 
|---|
|  | 123 | zone 3 1 | 
|---|
|  | 124 | n/plot nt.tf-hutf%$k ! ! "nsta connectpoints" | 
|---|
|  | 125 | n/plot nt.tfc-hutfc%$k ! ! "nsta connectpoints" | 
|---|
|  | 126 | n/plot nt.tfb-hutfb%$k ! ! "nsta connectpoints" | 
|---|
|  | 127 | zone 2 1 | 
|---|
|  | 128 | n/plot nt.tfnw-hutfnw%$k ! ! "nsta connectpoints" | 
|---|
|  | 129 | n/plot nt.tfnb-hutfnb%$k ! ! "nsta connectpoints" | 
|---|
|  | 130 |  | 
|---|
|  | 131 | zone 3 1 | 
|---|
|  | 132 | n/plot nt.(tf-hutf)/hutf%$k ! ! "nsta connectpoints" | 
|---|
|  | 133 | n/plot nt.(tfc-hutfc)/hutfc%$k ! ! "nsta connectpoints" | 
|---|
|  | 134 | n/plot nt.(tfb-hutfb)/hutfb%$k ! ! "nsta connectpoints" | 
|---|
|  | 135 | zone 2 1 | 
|---|
|  | 136 | n/plot nt.(tfnw-hutfnw)/hutfnw%$k ! ! "nsta connectpoints" | 
|---|
|  | 137 | n/plot nt.(tfnb-hutfnb)/hutfnb%$k ! ! "nsta connectpoints" | 
|---|
|  | 138 |  | 
|---|
|  | 139 | ###################### | 
|---|
|  | 140 | zone | 
|---|
|  | 141 | n/plot nt.tf%$k ! ! "nsta connectpoints" | 
|---|
|  | 142 | n/plot nt.tfnw%$k ! ! "nsta connectpoints red same" | 
|---|
|  | 143 | n/plot nt.tfnb%$k ! ! "nsta connectpoints blue same" | 
|---|
|  | 144 |  | 
|---|
|  | 145 | zone | 
|---|
|  | 146 | n/plot nt.tf/tfnw%$k tfnw>0. ! "nsta connectpoints" | 
|---|
|  | 147 | n/plot nt.hutf/hutfnw%$k hutfnw>0. ! "nsta connectpoints same blue" | 
|---|
|  | 148 | addline -1000 1 1000 1 "red" | 
|---|
| [3317] | 149 |  | 
|---|
|  | 150 | zone | 
|---|
|  | 151 | n/plot nt.tf/tfnb%$k tfnb>0. ! "nsta connectpoints" | 
|---|
|  | 152 | n/plot nt.hutf/hutfnb%$k hutfnb>0. ! "nsta connectpoints same blue" | 
|---|
|  | 153 | addline -1000 1 1000 1 "red" | 
|---|
| [3607] | 154 |  | 
|---|
|  | 155 | ###################### | 
|---|
|  | 156 | zone | 
|---|
|  | 157 | n/scan nt ! ! -f:cmvchkwhu.data k tf tfnb | 
|---|
| [3315] | 158 | */ | 
|---|