source: Sophya/trunk/Cosmo/SimLSS/cmvtuniv.cc@ 3285

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

update logique Init_Spline de CosmoCalc cmv 29/07/07

File size: 6.8 KB
RevLine 
[3115]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 "ntuple.h"
11
12#include "cosmocalc.h"
13#include "geneutils.h"
14
15void usage(void);
16void usage(void) {cout<<"cmvtuniv z1,z2,dz [perc,dzinc,dzmax,glorder]"<<endl;}
17
18void tstprint(CosmoCalc& univ,double z1,double z2,double dz);
19void tstprint(CosmoCalc& univ1,CosmoCalc& univ2,double z1,double z2,double dz);
20void tstspeed(CosmoCalc& univ,double z1,double z2,double dz);
21void tstntuple(CosmoCalc& univ,double z1,double z2,double dz);
22void tstinterp(CosmoCalc& univ,double z1,double z2,double dz);
23
24const double deg2rad = M_PI/180.;
25
26int main(int narg,char *arg[])
27{
28 unsigned short flat = 0;
29 // -- WMAP
30 double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
31 // -- ouvert matter only
32 //double h100=0.71, om0=0.3, or0=0., ol0=0.,w0=-1.;
33 // -- plat matter only
34 //double h100=0.71, om0=1., or0=0., ol0=0.,w0=-1.; flat = 1;
35 // -- plat lambda only
36 //double h100=0.71, om0=0., or0=0., ol0=1.,w0=-1.; flat = 2;
37
38 double z1=0., z2=-1., dz=-1.;
39 if(narg>1) sscanf(arg[1],"%lf,%lf,%lf",&z1,&z2,&dz);
40 if(z2<=z1) z2 = z1+1.;
41 if(dz<0.) dz = 10.*(z2-z1);
42 cout<<"z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl;
43
[3285]44 double perc=0.01,dzinc=-1.,dzmax=-1.; unsigned short glorder=4;
[3248]45 if(narg>2) sscanf(arg[2],"%lf,%lf,%lf,%hu",&perc,&dzinc,&dzmax,&glorder);
[3115]46 cout<<" perc="<<perc<<" dzinc="<<dzinc<<" dzmax="<<dzmax<<" glorder="<<glorder<<endl;
47
48 CosmoCalc univ(flat,true,z2);
49 univ.SetInteg(perc,dzinc,dzmax,glorder);
50 univ.SetDynParam(h100,om0,or0,ol0,w0);
[3285]51 univ.PrtInteg();
[3115]52 univ.Print();
53
54 CosmoCalc univ1(univ);
55 univ1.SetInteg(perc,dzinc,dzmax,glorder);
56 univ1.SetDynParam(h100,om0,or0,ol0,w0);
[3285]57 univ1.PrtInteg();
[3115]58 univ1.Print();
59
[3193]60 tstprint(univ,z1,z2,dz);
[3115]61 //tstprint(univ,univ1,z1,z2,dz);
62 //tstspeed(univ,z1,z2,dz);
63 //tstntuple(univ,z1,z2,dz);
[3193]64 //tstinterp(univ,z1,z2,dz);
[3115]65
66 return 0;
67}
68
69/* ----------------------------------------------------- */
70void tstprint(CosmoCalc& univ,double z1,double z2,double dz)
71{
72 cout<<"\nTSTPRINT()"<<endl;
73 double dzz = dz; if(dzz>z2-z1) dzz = 0.01;
74 for(double z=z1;z<z2+dz/2.;z+=dz) {
75 cout<<"--"<<endl;
76 univ.Print(z);
77 cout<<"Volume comoving in [z,z+"<<dzz<<"] for 4Pi sr: "
78 <<univ.Vol4Pi(z,z+dzz)<<" Mpc^3"<<endl;
79 double dang = univ.Dang(z);
80 double a = deg2rad/3600.;
81 cout<<"1\" -> "<<dang*a<<" Mpc = "<<dang*a*(1.+z)<<" Mpc com"<<endl;
82 a = deg2rad/60.;
83 cout<<"1\' -> "<<dang*a<<" Mpc = "<<dang*a*(1.+z)<<" Mpc com"<<endl;
84 a = deg2rad;
85 cout<<"1d -> "<<dang*a<<" Mpc = "<<dang*a*(1.+z)<<" Mpc com"<<endl;
86 double dloscom = univ.Dhubble() / univ.E(z);
87 cout<<"dz=1 -> "<<dloscom<<" Mpc com"<<endl;
88
89 }
90}
91
92/* ----------------------------------------------------- */
93void tstprint(CosmoCalc& univ1,CosmoCalc& univ2,double z1,double z2,double dz)
94{
95 cout<<"\nTSTPRINT()"<<endl;
96 for(double z=z1;z<z2+dz/2.;z+=dz) {
97 cout<<endl<<"--spline:"<<endl;
98 univ1.Print(z);
99 cout<<"Volume comoving in [z,z+dz] for 4Pi sr: "
100 <<univ1.Vol4Pi(z,z+dz)<<" Mpc^3"<<endl;
101 cout<<"--integ:"<<endl;
102 univ2.Print(z);
103 cout<<"Volume comoving in [z,z+dz] for 4Pi sr: "
104 <<univ2.Vol4Pi(z,z+dz)<<" Mpc^3"<<endl;
105 }
106}
107
108/* ----------------------------------------------------- */
109void tstspeed(CosmoCalc& univ,double z1,double z2,double dz)
110{
111 cout<<"\nTSTSPEED()"<<endl;
112 double sum = 0.;
113 int_4 n=0;
114 for(double z=z1;z<z2+dz/2.;z+=dz) {
115 sum += univ.Dang(z);
116 n++;
117 }
118 if(n>0) cout<<"... "<<sum/n<<endl;
119}
120
121/* ----------------------------------------------------- */
122void tstntuple(CosmoCalc& univ,double z1,double z2,double dz)
123{
124 cout<<"\nTSTNTUPLE()"<<endl;
125 double norm = univ.Dhubble(); // 1.
126 double norm3 = pow(norm,3.);
127 const int n = 15;
128 char *vname[n] = {
129 "z","hz","om","or","ol","ok","ot","ob",
130 "dtc","dlc","da","dl",
131 "dvc","vc0","vcdz"
132 };
133 NTuple nt(n,vname);
134 double xnt[n];
135 for(double z=z1;z<z2+dz/2.;z+=dz) {
136 xnt[0] = z;
137 xnt[1] = univ.H(z);
138 xnt[2] = univ.Omatter(z);
139 xnt[3] = univ.Orelat(z);
140 xnt[4] = univ.Olambda(z);
141 xnt[5] = univ.Ocurv(z);
142 xnt[6] = univ.Otot(z);
143 xnt[7] = univ.Obaryon(z);
144 xnt[8] = univ.Dtrcom(z)/norm;
145 xnt[9] = univ.Dloscom(z)/norm;
146 xnt[10] = univ.Dang(z)/norm;
147 xnt[11] = univ.Dlum(z)/norm;
148 xnt[12] = univ.dVol(z)/norm3;
149 xnt[13] = univ.Vol4Pi(z)/norm3;
150 xnt[14] = univ.Vol4Pi(z,z+dz)/norm3;
151 nt.Fill(xnt);
152 }
153 cout<<">>>> Ecriture"<<endl;
154 string tag = "cmvtuniv.ppf";
155 POutPersist pos(tag);
156 tag = "nt"; pos.PutObject(nt,tag);
157}
158
159
160/*
161openppf cmvtuniv.ppf
162
163set cut 1
164set cut z<100.
165set cut z<10.
166
167zone
168n/plot nt.hz%z $cut ! "nsta connectpoints"
169
170zone
171n/plot nt.dl%z $cut ! "nsta connectpoints"
172n/plot nt.da%z $cut ! "nsta connectpoints same red"
173n/plot nt.dtc%z $cut ! "nsta connectpoints same blue"
174n/plot nt.dlc%z $cut ! "nsta connectpoints same green"
175
176zone 2 2
177n/plot nt.dvc%z $cut ! "nsta connectpoints"
178n/plot nt.vc0%z $cut ! "nsta connectpoints"
179n/plot nt.vcdz%z $cut ! "nsta connectpoints"
180
181zone
182n/plot nt.ot%z $cut ! "nsta connectpoints"
183n/plot nt.om%z $cut ! "nsta connectpoints same blue"
184n/plot nt.or%z $cut ! "nsta connectpoints same red"
185n/plot nt.ol%z $cut ! "nsta connectpoints same green"
186n/plot nt.ok%z $cut ! "nsta connectpoints same orange"
187
188 */
189
190/* ----------------------------------------------------- */
191void tstinterp(CosmoCalc& univ,double z1,double z2,double dz)
192{
193 cout<<"\nTSTINTERP()"<<endl;
194
195 // On repmplit les donnes completes
196 vector<double> Z,D;
197 for(double z=z1;z<z2+dz/2.;z+=dz) {
198 Z.push_back(z);
199 D.push_back(univ.Dloscom(z));
200 }
201 // On remplit un sous tableau
202 int ninc = 5;
203 vector<double> Dinterp;
204 double zmin = Z[0], zmax = Z[0];
[3285]205 for(unsigned int i=0;i<Z.size();i+=ninc) {
[3115]206 Dinterp.push_back(D[i]);
207 zmax = Z[i];
208 }
209 InterpFunc interp(zmin,zmax,Dinterp);
210 unsigned short ok;
211
212 const int n = 8;
213 char *vname[n] = {"z","d","di","dl","dp","zi","zl","zp"};
214 NTuple nt(n,vname);
215 double xnt[n];
216
[3285]217 for(unsigned int i=0;i<Z.size();i++) {
[3115]218 if(Z[i]>zmax) break;
219 xnt[0] = Z[i];
220 xnt[1] = D[i];
221 xnt[2] = interp(Z[i]);
222 xnt[3] = interp.Linear(Z[i],ok);
223 xnt[4] = interp.Parab(Z[i],ok);
224 xnt[5] = xnt[6] = xnt[7] = 0.;
225 nt.Fill(xnt);
226 }
227 cout<<">>>> Ecriture"<<endl;
228 string tag = "cmvtuniv.ppf";
229 POutPersist pos(tag);
230 tag = "nt"; pos.PutObject(nt,tag);
231}
232
233/*
234openppf cmvtuniv.ppf
235
236n/plot nt.d%z ! ! "nsta connectpoints"
237n/plot nt.di%z ! ! "nsta connectpoints same green"
238n/plot nt.dl%z ! ! "nsta connectpoints same red"
239n/plot nt.dp%z ! ! "nsta connectpoints same blue"
240
241n/plot nt.di-d%z ! ! "nsta connectpoints green"
242n/plot nt.dl-d%z ! ! "nsta connectpoints same red"
243n/plot nt.dp-d%z ! ! "nsta connectpoints same blue"
244
245n/plot nt.(di-d)/d%z d>0 ! "nsta connectpoints green"
246n/plot nt.(dl-d)/d%z d>0 ! "nsta connectpoints same red"
247n/plot nt.(dp-d)/d%z d>0 ! "nsta connectpoints same blue"
248
249*/
Note: See TracBrowser for help on using the repository browser.