Changeset 3313 in Sophya
- Timestamp:
- Aug 24, 2007, 4:59:12 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/cmvtuniv.cc
r3285 r3313 13 13 #include "geneutils.h" 14 14 15 void usage(void);16 void usage(void) {cout<<"cmvtuniv z1,z2,dz [perc,dzinc,dzmax,glorder]"<<endl;}17 18 15 void tstprint(CosmoCalc& univ,double z1,double z2,double dz); 19 16 void tstprint(CosmoCalc& univ1,CosmoCalc& univ2,double z1,double z2,double dz); … … 23 20 24 21 const double deg2rad = M_PI/180.; 22 23 void usage(void); 24 void usage(void) { 25 cout 26 <<"cmvtuniv [options] z1,z2"<<endl 27 <<" -D dz"<<endl 28 <<" -U h100,om0,or0,ol0,w0"<<endl 29 <<" -F flat(0,1,2)"<<endl 30 <<" -I perc,dzinc,dzmax,glorder"<<endl 31 <<" --- What has to be done:"<<endl 32 <<" -W 1/2/3/4/5"<<endl 33 <<" 1 : print info from z1 to z2 by step dz"<<endl 34 <<" 2 : compare with/without spline from z1 to z2 by step dz"<<endl 35 <<" 3 : test speed from z1 to z2 by step dz"<<endl 36 <<" 4 : fill ntuple with infos from z1 to z2 by step dz"<<endl 37 <<" 5 : test interpolation loscom from z1 to z2 by step dz"<<endl 38 <<endl; 39 } 25 40 26 41 int main(int narg,char *arg[]) … … 36 51 //double h100=0.71, om0=0., or0=0., ol0=1.,w0=-1.; flat = 2; 37 52 53 // -- parametre d'integration 54 double perc=0.01,dzinc=-1.,dzmax=-1.; 55 unsigned short glorder=4; 56 // -- redshift 38 57 double z1=0., z2=-1., dz=-1.; 39 if(narg>1) sscanf(arg[1],"%lf,%lf,%lf",&z1,&z2,&dz); 58 // -- Work to be done 59 int todo = 1; 60 61 InitTim(); 62 63 // Read arguments 64 char c; 65 while ((c = getopt(narg, arg, "hD:U:F:I:W:")) != -1) { 66 switch (c) { 67 case 'D' : 68 sscanf(optarg,"%lf",&dz); 69 break; 70 case 'U' : 71 sscanf(optarg,"%lf,%lf,%lf,%lf,%lf",&h100,&om0,&or0,&ol0,&w0); 72 break; 73 case 'F' : 74 sscanf(optarg,"%hu",&flat); 75 break; 76 case 'I' : 77 sscanf(optarg,"%lf,%lf,%lf,%hu",&perc,&dzinc,&dzmax,&glorder); 78 break; 79 case 'W' : 80 sscanf(optarg,"%d",&todo); 81 break; 82 case 'h' : 83 default: 84 usage(); 85 return -1; 86 } 87 } 88 if(optind<narg) sscanf(arg[optind],"%lf,%lf",&z1,&z2); 89 90 if(z1<0.) z1 = 0.; 40 91 if(z2<=z1) z2 = z1+1.; 41 if(dz< 0.) dz = 10.*(z2-z1);92 if(dz<=0.) dz = 10.*(z2-z1); 42 93 cout<<"z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl; 43 44 double perc=0.01,dzinc=-1.,dzmax=-1.; unsigned short glorder=4; 45 if(narg>2) sscanf(arg[2],"%lf,%lf,%lf,%hu",&perc,&dzinc,&dzmax,&glorder); 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); 51 univ.PrtInteg(); 52 univ.Print(); 53 54 CosmoCalc univ1(univ); 94 cout<<"perc="<<perc<<" dzinc="<<dzinc<<" dzmax="<<dzmax<<" glorder="<<glorder<<endl; 95 cout<<"h100="<<h100<<" om0="<<om0<<" or0="<<or0<<" ol0="<<ol0<<" w0="<<w0<<" flat="<<flat<<endl; 96 cout<<"todo ="<<todo<<endl; 97 98 CosmoCalc univ1(flat,true,z2); 55 99 univ1.SetInteg(perc,dzinc,dzmax,glorder); 56 100 univ1.SetDynParam(h100,om0,or0,ol0,w0); 57 101 univ1.PrtInteg(); 58 102 univ1.Print(); 59 60 tstprint(univ,z1,z2,dz); 61 //tstprint(univ,univ1,z1,z2,dz); 62 //tstspeed(univ,z1,z2,dz); 63 //tstntuple(univ,z1,z2,dz); 64 //tstinterp(univ,z1,z2,dz); 103 cout<<endl; 104 105 if(todo==1) tstprint(univ1,z1,z2,dz); 106 else if(todo==2) { 107 CosmoCalc univ2(flat,false,z2); 108 univ2.SetInteg(perc,dzinc,dzmax,glorder); 109 univ2.SetDynParam(h100,om0,or0,ol0,w0); 110 univ2.PrtInteg(); 111 univ2.Print(); 112 tstprint(univ1,univ2,z1,z2,dz); 113 } 114 else if(todo==3) tstspeed(univ1,z1,z2,dz); 115 else if(todo==4) tstntuple(univ1,z1,z2,dz); 116 else if(todo==5)tstinterp(univ1,z1,z2,dz); 117 else cout<<"Unknown job to be done !!!!! todo="<<todo<<endl; 65 118 66 119 return 0; … … 70 123 void tstprint(CosmoCalc& univ,double z1,double z2,double dz) 71 124 { 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;125 if(dz>z2-z1) dz = z2-z1; 126 cout<<"\nTSTPRINT(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl; 127 for(double z=z1;z<z2+dz/2.;z+=dz) { 128 cout<<"-- z = "<<z<<endl; 76 129 univ.Print(z); 77 cout<<"Volume comoving in [z,z+"<<dz z<<"] for 4Pi sr: "78 <<univ.Vol4Pi(z,z+dz z)<<" Mpc^3"<<endl;130 cout<<"Volume comoving in [z,z+"<<dz<<"] for 4Pi sr: " 131 <<univ.Vol4Pi(z,z+dz)<<" Mpc^3"<<endl; 79 132 double dang = univ.Dang(z); 80 133 double a = deg2rad/3600.; … … 86 139 double dloscom = univ.Dhubble() / univ.E(z); 87 140 cout<<"dz=1 -> "<<dloscom<<" Mpc com"<<endl; 88 89 } 141 } 142 90 143 } 91 144 … … 93 146 void tstprint(CosmoCalc& univ1,CosmoCalc& univ2,double z1,double z2,double dz) 94 147 { 95 cout<<"\nTSTPRINT()"<<endl; 96 for(double z=z1;z<z2+dz/2.;z+=dz) { 97 cout<<endl<<"--spline:"<<endl; 148 if(dz>z2-z1) dz = z2-z1; 149 cout<<"\nTSTPRINT(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl; 150 for(double z=z1;z<z2+dz/2.;z+=dz) { 151 cout<<endl<<"--spline: z = "<<z<<endl; 98 152 univ1.Print(z); 99 153 cout<<"Volume comoving in [z,z+dz] for 4Pi sr: " 100 154 <<univ1.Vol4Pi(z,z+dz)<<" Mpc^3"<<endl; 101 cout<<"--integ: "<<endl;155 cout<<"--integ: z = "<<z<<endl; 102 156 univ2.Print(z); 103 157 cout<<"Volume comoving in [z,z+dz] for 4Pi sr: " … … 109 163 void tstspeed(CosmoCalc& univ,double z1,double z2,double dz) 110 164 { 111 cout<<"\nTSTSPEED()"<<endl; 165 if(dz>z2-z1) dz = z2-z1; 166 cout<<"\nTSTSPEED(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl; 112 167 double sum = 0.; 113 168 int_4 n=0; 169 PrtTim("-- Beginning"); 114 170 for(double z=z1;z<z2+dz/2.;z+=dz) { 115 171 sum += univ.Dang(z); 116 172 n++; 117 173 } 118 if(n>0) cout<<"... "<<sum/n<<endl; 174 if(n>0) cout<<"n="<<n<<" ...dum="<<sum/n<<endl; 175 PrtTim("-- Ending"); 119 176 } 120 177 … … 122 179 void tstntuple(CosmoCalc& univ,double z1,double z2,double dz) 123 180 { 124 cout<<"\nTSTNTUPLE()"<<endl; 181 if(dz>z2-z1) dz = z2-z1; 182 cout<<"\nTSTNTUPLE(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl; 125 183 double norm = univ.Dhubble(); // 1. 126 184 double norm3 = pow(norm,3.); … … 152 210 } 153 211 cout<<">>>> Ecriture"<<endl; 154 string tag = "cmvtuniv .ppf";212 string tag = "cmvtuniv_nt.ppf"; 155 213 POutPersist pos(tag); 156 214 tag = "nt"; pos.PutObject(nt,tag); … … 159 217 160 218 /* 161 openppf cmvtuniv .ppf219 openppf cmvtuniv_nt.ppf 162 220 163 221 set cut 1 … … 191 249 void tstinterp(CosmoCalc& univ,double z1,double z2,double dz) 192 250 { 193 cout<<"\nTSTINTERP()"<<endl;194 195 // On re pmplit les donnes completes251 if(dz>z2-z1) dz = z2-z1; 252 cout<<"\nTSTINTERP(): z1="<<z1<<" z2="<<z2<<" dz="<<dz<<endl; 253 // On remplit les donnes completes 196 254 vector<double> Z,D; 197 255 for(double z=z1;z<z2+dz/2.;z+=dz) { … … 226 284 } 227 285 cout<<">>>> Ecriture"<<endl; 228 string tag = "cmvtuniv .ppf";286 string tag = "cmvtuniv_int.ppf"; 229 287 POutPersist pos(tag); 230 288 tag = "nt"; pos.PutObject(nt,tag); … … 232 290 233 291 /* 234 openppf cmvtuniv .ppf292 openppf cmvtuniv_int.ppf 235 293 236 294 n/plot nt.d%z ! ! "nsta connectpoints"
Note:
See TracChangeset
for help on using the changeset viewer.