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