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

Last change on this file since 3617 was 3607, checked in by cmv, 16 years ago

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