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

Last change on this file since 3336 was 3317, checked in by cmv, 18 years ago

hu_power et hu_tf_fit NE PEUVENT ETRE apples dans le meme program sans interferer l'un avec l'autre cvstatcvstat cmv 28/08/2007

File size: 5.0 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-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/*
100openppf cmvchkwhu.ppf
101
102set k k
103set k log10(k)
104
105######################
106zone 3 1
107n/plot nt.tf%$k ! ! "nsta connectpoints"
108n/plot nt.hutf%$k ! ! "nsta connectpoints red same"
109n/plot nt.tfc%$k ! ! "nsta connectpoints"
110n/plot nt.hutfc%$k ! ! "nsta connectpoints red same"
111n/plot nt.tfb%$k ! ! "nsta connectpoints"
112n/plot nt.hutfb%$k ! ! "nsta connectpoints red same"
113zone 2 1
114n/plot nt.tfnw%$k ! ! "nsta connectpoints"
115n/plot nt.hutfnw%$k ! ! "nsta connectpoints red same"
116n/plot nt.tfnb%$k ! ! "nsta connectpoints"
117n/plot nt.hutfnb%$k ! ! "nsta connectpoints red same"
118
119######################
120zone 3 1
121n/plot nt.tf-hutf%$k ! ! "nsta connectpoints"
122n/plot nt.tfc-hutfc%$k ! ! "nsta connectpoints"
123n/plot nt.tfb-hutfb%$k ! ! "nsta connectpoints"
124zone 2 1
125n/plot nt.tfnw-hutfnw%$k ! ! "nsta connectpoints"
126n/plot nt.tfnb-hutfnb%$k ! ! "nsta connectpoints"
127
128zone 3 1
129n/plot nt.(tf-hutf)/hutf%$k ! ! "nsta connectpoints"
130n/plot nt.(tfc-hutfc)/hutfc%$k ! ! "nsta connectpoints"
131n/plot nt.(tfb-hutfb)/hutfb%$k ! ! "nsta connectpoints"
132zone 2 1
133n/plot nt.(tfnw-hutfnw)/hutfnw%$k ! ! "nsta connectpoints"
134n/plot nt.(tfnb-hutfnb)/hutfnb%$k ! ! "nsta connectpoints"
135
136######################
137zone
138n/plot nt.tf%$k ! ! "nsta connectpoints"
139n/plot nt.tfnw%$k ! ! "nsta connectpoints red same"
140n/plot nt.tfnb%$k ! ! "nsta connectpoints blue same"
141
142zone
143n/plot nt.tf/tfnw%$k tfnw>0. ! "nsta connectpoints"
144n/plot nt.hutf/hutfnw%$k hutfnw>0. ! "nsta connectpoints same blue"
145addline -1000 1 1000 1 "red"
146
147zone
148n/plot nt.tf/tfnb%$k tfnb>0. ! "nsta connectpoints"
149n/plot nt.hutf/hutfnb%$k hutfnb>0. ! "nsta connectpoints same blue"
150addline -1000 1 1000 1 "red"
151*/
Note: See TracBrowser for help on using the repository browser.