source: Sophya/trunk/Cosmo/SimLSS/cmvtstpk.cc@ 3120

Last change on this file since 3120 was 3120, checked in by cmv, 19 years ago

Suite de la mise dans la base cvs cmv 21/12/2006

File size: 6.4 KB
Line 
1#include "sopnamsp.h"
2#include "machdefs.h"
3#include <iostream>
4#include <stdlib.h>
5#include <stdio.h>
6#include <string.h>
7#include <math.h>
8#include <unistd.h>
9#include "timing.h"
10#include "histos.h"
11#include "tvector.h"
12#include "ntuple.h"
13#include "perandom.h"
14
15#include "constcosmo.h"
16#include "pkspectrum.h"
17#include "geneutils.h"
18
19void usage(void);
20void usage(void) {
21 cout<<"cmvtstpk [options] z_redshift"<<endl
22 <<" -H h100 -B Ob0 -M Om0 -L Ol0,w0"<<endl
23 <<" -k npt,lkmin,lkmax : les valeurs sont en log10"<<endl
24 <<" -s scale : on multiplie pkz par scale"<<endl;
25}
26
27int main(int narg,char *arg[])
28{
29 double Ob0 = 0.0444356;
30 // -- WMAP
31 double h100=0.71, Om0=0.267804, Ol0=0.73,w0=-1.;
32 // -- ouvert matter only
33 //double h100=0.71, Om0=0.3, Ol0=0.,w0=-1.;
34 // -- plat matter only
35 //double h100=0.71, Om0=1., Ol0=0.,w0=-1.;
36
37
38 double ns = 1., as = 1.;
39
40 int npt = 10000;
41 double lkmin = -3., lkmax=2.;
42 double scale = 1.;
43
44 char c;
45 while((c = getopt(narg,arg,"hk:s:H:M:B:L:")) != -1) {
46 switch (c) {
47 case 'H' :
48 sscanf(optarg,"%lf",&h100);
49 break;
50 case 'M' :
51 sscanf(optarg,"%lf",&Om0);
52 break;
53 case 'B' :
54 sscanf(optarg,"%lf",&Ob0);
55 break;
56 case 'L' :
57 sscanf(optarg,"%lf,%lf",&Ol0,&w0);
58 break;
59 case 'k' :
60 sscanf(optarg,"%d,%lf,%lf",&npt,&lkmin,&lkmax);
61 if(npt<=0) npt=1000;
62 if(lkmax<lkmin) {lkmin=-4.; lkmax=2.;}
63 break;
64 case 's' :
65 sscanf(optarg,"%lf",&scale);
66 break;
67 case 'h' :
68 default :
69 usage(); return -1;
70 }
71 }
72 double dlk=(lkmax-lkmin)/npt;
73
74 // Fill z value into list
75 double zval = 0.;
76 if(optind<narg) zval = atof(arg[optind]);
77
78 cout<<"h100="<<h100<<" Om0="<<Om0<<" Ob0="<<Ob0<<" Ol0="<<Ol0<<" w0="<<w0<<endl;
79 cout<<"lkmin="<<lkmin<<" lkmax="<<lkmax<<" npt="<<npt<<" dlk="<<dlk<<endl;
80 cout<<"scale="<<scale<<endl;
81 cout<<"zval="<<zval<<endl;
82
83 //--------------------------
84 InitialSpectrum pkini(ns,as);
85
86 TransfertEisenstein tf(h100,Om0-Ob0,Ob0,T_CMB_Par,false);
87 cout<<"kpeak="<<tf.KPeak()<<endl;
88 TransfertEisenstein tfnosc2(tf); tfnosc2.SetNoOscEnv(2);
89 TransfertEisenstein tfnosc1(tf); tfnosc1.SetNoOscEnv(1);
90 TransfertEisenstein tfnob(h100,Om0,0.,T_CMB_Par,true);
91
92 GrowthFactor d1(Om0,Ol0);
93 cout<<"GrowthFactor: "<<d1(zval)<<endl;
94
95 PkSpectrum0 pk0(pkini,tf);
96 PkSpectrum0 pk0nosc2(pkini,tfnosc2);
97 PkSpectrum0 pk0nosc1(pkini,tfnosc1);
98 PkSpectrum0 pk0nob(pkini,tfnob);
99
100 PkSpectrumZ pkz(pk0,d1,zval);
101 PkSpectrumZ pkznosc2(pk0nosc2,d1,zval);
102 PkSpectrumZ pkznosc1(pk0nosc1,d1,zval);
103 PkSpectrumZ pkznob(pk0nob,d1,zval);
104
105 //--------------------------
106 Histo hd1(0.,20.,10000); hd1.ReCenterBin();
107 FuncToHisto(d1,hd1,false);
108
109 Histo hpkz(lkmin,lkmax,npt); hpkz.ReCenterBin();
110 FuncToHisto(pkz,hpkz,true);
111 TVector<r_8> vpkz(npt);
112 FuncToVec(pkz,vpkz,lkmin,lkmax,true);
113
114 FunRan talea(hpkz,true);
115 Histo halea(hpkz); halea.Zero();
116 int nalea = 100000;
117 for(int i=0;i<nalea;i++) halea.Add(talea.Random());
118 halea *= hpkz.Sum()/halea.Sum();
119
120 //--------------------------
121 const int n = 14;
122 char *vname[n] = {
123 "k","pkini",
124 "tf","pk0","pk",
125 "tfnosc2","pk0nosc2","pknosc2",
126 "tfnosc1","pk0nosc1","pknosc1",
127 "tfnob","pk0nob","pknob"
128 };
129 NTuple nt(n,vname);
130 double xnt[n];
131
132 for(double lk=lkmin;lk<lkmax+dlk/2.;lk+=dlk) {
133 double k = pow(10.,lk);
134 xnt[0] = k;
135 xnt[1] = pkini(k);
136 xnt[2] = tf(k);
137 xnt[3] = pk0(k);
138 xnt[4] = pkz(k,zval);
139 xnt[5] = tfnosc2(k);
140 xnt[6] = pk0nosc2(k);
141 xnt[7] = pkznosc2(k,zval);
142 xnt[8] = tfnosc1(k);
143 xnt[9] = pk0nosc1(k);
144 xnt[10] = pkznosc1(k,zval);
145 xnt[11] = tfnob(k);
146 xnt[12] = pk0nob(k);
147 xnt[13] = pkznob(k,zval);
148 nt.Fill(xnt);
149 }
150
151 //--------------------------
152 cout<<">>>> ASCII"<<endl;
153 if(1) {
154 FILE * fdata = fopen("cmvtstpk.data","w");
155 fprintf(fdata,"# z= %g : k(Mpc^-1) pkini, tf pk0 pkz, tfnosc2 pk0nosc2 pkznosc2, ",zval);
156 fprintf(fdata,"tfnosc1 pk0nosc1 pkznosc1, tfnob pk0nob pkznob\n");
157 for(double lk=lkmin;lk<lkmax+dlk/2.;lk+=dlk) {
158 double k = pow(10.,lk);
159 fprintf(fdata,"%e %e %e %e %e %e %e %e %e %e %e %e %e %e\n",
160 k,pkini(k),
161 tf(k),pk0(k),scale*pkz(k,zval),
162 tfnosc2(k),pk0nosc2(k),scale*pkznosc2(k,zval),
163 tfnosc1(k),pk0nosc1(k),scale*pkznosc1(k,zval),
164 tfnob(k),pk0nob(k),scale*pkznob(k,zval));
165 }
166 fclose(fdata);
167 }
168
169 //--------------------------
170 cout<<">>>> Ecriture"<<endl;
171 string tag = "cmvtstpk.ppf";
172 POutPersist pos(tag);
173 tag = "nt"; pos.PutObject(nt,tag);
174 tag = "hd1"; pos.PutObject(hd1,tag);
175 tag = "hpkz"; pos.PutObject(hpkz,tag);
176 tag = "vpkz"; pos.PutObject(vpkz,tag);
177 tag = "halea"; pos.PutObject(halea,tag);
178 return 0;
179}
180
181/*
182openppf cmvtstpk.ppf
183
184#### growth-factor
185zone
186n/plot hd1.val%x ! ! "nsta connectpoints"
187
188#### Spectre initial
189zone
190n/plot nt.log10(pkini)%log10(k) pkini>0. ! "nsta connectpoints"
191
192#### Gestion des abscisses
193set xk log10(k)
194set xk k
195
196#### fct de transfert
197zone
198n/plot nt.tf%$xk ! ! "nsta connectpoints"
199n/plot nt.tfnosc2%$xk ! ! "nsta connectpoints same red"
200n/plot nt.tfnosc1%$xk ! ! "nsta connectpoints same blue"
201n/plot nt.tfnob%$xk ! ! "nsta connectpoints same green"
202
203n/plot nt.tf/tfnosc2%$xk ! ! "nsta connectpoints red"
204n/plot nt.tf/tfnosc1%$xk ! ! "nsta connectpoints same blue"
205n/plot nt.tf/tfnob%$xk ! ! "nsta connectpoints same green"
206addline -10 1 10 1
207
208#### Spectre a z=0
209zone
210n/plot nt.pk0%$xk ! ! "nsta connectpoints"
211n/plot nt.pk0nosc2%$xk ! ! "nsta connectpoints same red"
212n/plot nt.pk0nosc1%$xk ! ! "nsta connectpoints same blue"
213n/plot nt.pk0nob%$xk ! ! "nsta connectpoints same green"
214
215# Check
216zone 2 2
217n/plot nt.pk0/pkini-tf*tf%$xk pkini>0 ! "nsta crossmarker3"
218n/plot nt.pk0nosc2/pkini-tfnosc2*tfnosc2%$xk pkini>0 ! "nsta crossmarker3"
219n/plot nt.pk0nosc1/pkini-tfnosc1*tfnosc1%$xk pkini>0 ! "nsta crossmarker3"
220n/plot nt.pk0nob/pkini-tfnob*tfnob%$xk pkini>0 ! "nsta crossmarker3"
221
222#### Spectre a z
223zone
224n/plot nt.pk%$xk ! ! "nsta connectpoints"
225n/plot nt.pknosc2%$xk ! ! "nsta connectpoints same red"
226n/plot nt.pknosc1%$xk ! ! "nsta connectpoints same blue"
227n/plot nt.pknob%$xk ! ! "nsta connectpoints same green"
228
229n/plot nt.pk/pknosc2%$xk ! ! "nsta connectpoints red"
230n/plot nt.pk/pknosc1%$xk ! ! "nsta connectpoints same blue"
231n/plot nt.pk/pknob%$xk ! ! "nsta connectpoints same green"
232addline -10 1 10 1
233
234#### Le spectre version Delta^2
235set D2 k*k*k*pk/(2*M_PI*M_PI)
236n/plot nt.$D2%$xk ! ! "nsta crossmarker3 connectpoints"
237
238#### Test des transferts dans Histo et TVector
239zone 1 2
240n/plot nt.pk%log10(k) ! ! "nsta crossmarker3"
241disp hpkz "same red"
242
243disp vpkz
244c++exec cout<<hpkz(0)<<" =?= "<<vpkz(0)<<endl;
245
246zone
247disp hpkz
248disp halea "same red"
249
250*/
Note: See TracBrowser for help on using the repository browser.