source: Sophya/trunk/Cosmo/SimLSS/cmvchkwhu.cc@ 4056

Last change on this file since 4056 was 3619, checked in by cmv, 16 years ago

add various #include<> for g++ 4.3 (jaunty 9.04), cmv 05/05/2009

File size: 5.3 KB
Line 
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
17int main(int narg,char *arg[])
18{
19 double k1 = 1e-4, k2 = 10.; int_4 npt = 10000;
20 double h100 = 0.71, Om0 = 0.267804, Ob0 = 0.0444356, tcmb = T_CMB_Par;
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
23 //double h100 = 0.71, Om0 = 1.0, Ob0 = 0.0444356, tcmb = T_CMB_Par; // Om=1 Ob<<1
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
52 const int n = 11;
53 const char *vname[n] = {"k","tf","tfnw","tfnb","tfc","tfb"
54 ,"hutf","hutfnw","hutfnb","hutfc","hutfb"};
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;
64 Tfull.SetReturnPart(TransfertEisenstein::ALL); double tf = Tfull(k);
65 double tfnw = Tnowig(k);
66 double tfnb = Tnob(k);
67 Tfull.SetReturnPart(TransfertEisenstein::CDM); double tfc = Tfull(k);
68 Tfull.SetReturnPart(TransfertEisenstein::BARYON); double tfb = Tfull(k);
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/*
103openppf cmvchkwhu.ppf
104
105set k k
106set k log10(k)
107
108######################
109zone 3 1
110n/plot nt.tf%$k ! ! "nsta connectpoints"
111n/plot nt.hutf%$k ! ! "nsta connectpoints red same"
112n/plot nt.tfc%$k ! ! "nsta connectpoints"
113n/plot nt.hutfc%$k ! ! "nsta connectpoints red same"
114n/plot nt.tfb%$k ! ! "nsta connectpoints"
115n/plot nt.hutfb%$k ! ! "nsta connectpoints red same"
116zone 2 1
117n/plot nt.tfnw%$k ! ! "nsta connectpoints"
118n/plot nt.hutfnw%$k ! ! "nsta connectpoints red same"
119n/plot nt.tfnb%$k ! ! "nsta connectpoints"
120n/plot nt.hutfnb%$k ! ! "nsta connectpoints red same"
121
122######################
123zone 3 1
124n/plot nt.tf-hutf%$k ! ! "nsta connectpoints"
125n/plot nt.tfc-hutfc%$k ! ! "nsta connectpoints"
126n/plot nt.tfb-hutfb%$k ! ! "nsta connectpoints"
127zone 2 1
128n/plot nt.tfnw-hutfnw%$k ! ! "nsta connectpoints"
129n/plot nt.tfnb-hutfnb%$k ! ! "nsta connectpoints"
130
131zone 3 1
132n/plot nt.(tf-hutf)/hutf%$k ! ! "nsta connectpoints"
133n/plot nt.(tfc-hutfc)/hutfc%$k ! ! "nsta connectpoints"
134n/plot nt.(tfb-hutfb)/hutfb%$k ! ! "nsta connectpoints"
135zone 2 1
136n/plot nt.(tfnw-hutfnw)/hutfnw%$k ! ! "nsta connectpoints"
137n/plot nt.(tfnb-hutfnb)/hutfnb%$k ! ! "nsta connectpoints"
138
139######################
140zone
141n/plot nt.tf%$k ! ! "nsta connectpoints"
142n/plot nt.tfnw%$k ! ! "nsta connectpoints red same"
143n/plot nt.tfnb%$k ! ! "nsta connectpoints blue same"
144
145zone
146n/plot nt.tf/tfnw%$k tfnw>0. ! "nsta connectpoints"
147n/plot nt.hutf/hutfnw%$k hutfnw>0. ! "nsta connectpoints same blue"
148addline -1000 1 1000 1 "red"
149
150zone
151n/plot nt.tf/tfnb%$k tfnb>0. ! "nsta connectpoints"
152n/plot nt.hutf/hutfnb%$k hutfnb>0. ! "nsta connectpoints same blue"
153addline -1000 1 1000 1 "red"
154
155######################
156zone
157n/scan nt ! ! -f:cmvchkwhu.data k tf tfnb
158*/
Note: See TracBrowser for help on using the repository browser.