Changeset 3318 in Sophya for trunk/Cosmo/SimLSS
- Timestamp:
- Aug 28, 2007, 11:41:49 AM (18 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/cmvtransf.cc
r3115 r3318 14 14 15 15 void usage(void); 16 void usage(void) {cout<<"cmvtuniv [k1,k2,npt] [h100,Om0,Ob0,tcmb]"<<endl;} 16 void usage(void) { 17 cout 18 <<"cmvtransf [options]"<<endl 19 <<" -k k1,k2,npt : k range in Mpc^-1"<<endl 20 <<" -U h100,Om0,Ob0,tcmb : cosmology"<<endl 21 <<" -F filename : read also CMBFast file"<<endl 22 <<endl; 23 } 17 24 18 25 int main(int narg,char *arg[]) … … 20 27 double k1 = 1e-6, k2 = 10.; int_4 npt = 100; 21 28 double h100 = 0.71, Om0 = 0.267804, Ob0 = 0.0444356, tcmb = T_CMB_Par; 29 string fcmbfast = ""; 22 30 23 if(narg>1) sscanf(arg[1],"%lf,%lf,%d",&k1,&k2,&npt); 31 char c; 32 while((c = getopt(narg,arg,"hk:U:F:")) != -1) { 33 switch (c) { 34 case 'k' : 35 sscanf(optarg,"%d,%lf,%lf",&npt,&k1,&k2); 36 break; 37 case 'U' : 38 sscanf(optarg,"%lf,%lf,%lf,%lf",&h100,&Om0,&Ob0,&tcmb); 39 break; 40 case 'F' : 41 fcmbfast = optarg; 42 break; 43 case 'h' : 44 default : 45 usage(); return -1; 46 } 47 } 48 24 49 if(k1<=0.) {cout<<"k1 must be >0"<<endl; return -1;} 25 if(npt<=0) npt = 100; 50 if(npt<=0) npt = 1000; 51 if(k2<=k1) {k1=1.e-4; k2=1.e+2;} 26 52 cout<<"k1="<<k1<<" k2="<<k2<<" npt="<<npt<<endl; 27 if(narg>2) sscanf(arg[2],"%lf,%lf,%lf,%lf",&h100,&Om0,&Ob0,&tcmb);28 53 cout<<"h100="<<h100<<" Om0="<<Om0<<" Ob0="<<Ob0<<" Tcmb="<<tcmb<<endl; 54 cout<<"fcmbfast="<<fcmbfast<<endl; 29 55 30 56 cout<<"TransfertEisenstein with baryon"<<endl; … … 43 69 TransfertEisenstein tfnob(h100,Om0-Ob0,Ob0,tcmb,true); // No baryons 44 70 45 const int n = 5; 46 char *vname[n] = {"k","t","tnosc1","tnosc2","tnob"}; 71 TransfertTabulate tfcmbfast(h100,Om0-Ob0,Ob0); 72 bool cmbfastOK = false; 73 if(fcmbfast.size()>0) { 74 cout<<endl<<"TransfertTabulate for CMBfast"<<endl; 75 tfcmbfast.ReadCMBFast(fcmbfast); 76 tfcmbfast.SetInterpTyp(1); 77 if(tfcmbfast.NPoints()>0) cmbfastOK = true; 78 } 79 80 const int n = 6; 81 char *vname[n] = {"k","t","tnosc1","tnosc2","tnob","tcmbf"}; 47 82 NTuple nt(n,vname); 48 83 double xnt[n]; 84 for(int i=0;i<n;i++) xnt[i]=0.; 49 85 50 86 double lnk1 = log10(k1), lnk2=log10(k2), dlnk=(lnk2-lnk1)/npt; … … 56 92 xnt[3] = tfnosc2(k); 57 93 xnt[4] = tfnob(k); 94 if(cmbfastOK) xnt[5] = tfcmbfast(k); 58 95 nt.Fill(xnt); 59 96 } … … 73 110 set k log10(k) 74 111 75 n/plot nt.t%$k ! ! "nsta crossmarker3" 76 n/plot nt.tnob%$k ! ! "nsta red crossmarker3 same" 77 n/plot nt.tnosc1%$k ! ! "nsta blue circlemarker3 same" 78 n/plot nt.tnosc2%$k ! ! "nsta green trianglemarker3 same" 112 # Eisenstein 113 n/plot nt.t%$k ! ! "nsta connectpoints" 114 n/plot nt.tnob%$k ! ! "nsta red same connectpoints" 115 n/plot nt.tnosc2%$k ! ! "nsta blue same connectpoints" 116 n/plot nt.tnosc1%$k ! ! "nsta green same connectpoints" 79 117 80 n/plot nt.t/tnosc1%$k ! ! "nsta crossmarker3" 81 n/plot nt.t/tnosc2%$k ! ! "nsta crossmarker3 red same" 118 n/plot nt.t/tnob%$k tnob>0 ! "nsta red connectpoints" 119 n/plot nt.t/tnosc2%$k tnosc2>0 ! "nsta blue same connectpoints" 120 n/plot nt.t/tnosc1%$k tnosc1>0 ! "nsta green same connectpoints" 121 122 # CMBFast 123 n/plot nt.t%$k ! ! "nsta connectpoints" 124 n/plot nt.tcmbf%$k ! ! "nsta red same connectpoints" 125 126 n/plot nt.(tcmbf-t)%$k tcmbf>0. ! "nsta connectpoints" 127 n/plot nt.(tcmbf-t)/tcmbf%$k tcmbf>0. ! "nsta connectpoints" 82 128 */ -
trunk/Cosmo/SimLSS/cmvtstpk.cc
r3193 r3318 28 28 int main(int narg,char *arg[]) 29 29 { 30 double Ob0 = 0.0444356;31 30 // -- WMAP 32 double h100=0.71, Om0=0.267804, Ol0=0.73,w0=-1.; 33 // -- ouvert matter only 34 //double h100=0.71, Om0=0.3, Ol0=0.,w0=-1.; 35 // -- plat matter only 36 //double h100=0.71, Om0=1., Ol0=0.,w0=-1.; 37 31 double h100=0.71, Om0=0.267804, Ob0 = 0.0444356, Ol0=0.73,w0=-1.; 38 32 39 33 double ns = 1., as = 1.; 40 41 34 int npt = 10000; 42 35 double lkmin = -3., lkmax=2.; -
trunk/Cosmo/SimLSS/pkspectrum.cc
r3314 r3318 65 65 zero_(); 66 66 Init_(); 67 } 68 69 void TransfertEisenstein::zero_(void) 70 { 71 th2p7_=zeq_=keq_=zd_=Req_=Rd_=s_=ksilk_=alphac_=betac_=bnode_ 72 =alphab_=betab_=alphag_=sfit_=kpeak_=1.e99; 67 73 } 68 74 … … 275 281 276 282 /////////////////////////////////////////////////////////// 283 //******************* TransfertTabulate *****************// 284 /////////////////////////////////////////////////////////// 285 286 TransfertTabulate::TransfertTabulate(double h100,double OmegaCDM0,double OmegaBaryon0) 287 : Oc_(OmegaCDM0) , Ob_(OmegaBaryon0) , h_(h100) , kmin_(1.) , kmax_(-1.) 288 , interptyp_(0) 289 { 290 } 291 292 TransfertTabulate::TransfertTabulate(TransfertTabulate& tf) 293 : Oc_(tf.Oc_) , Ob_(tf.Ob_) , h_(tf.h_) , kmin_(tf.kmin_) , kmax_(tf.kmax_) 294 , interptyp_(tf.interptyp_) , k_(tf.k_) , tf_(tf.tf_) 295 { 296 } 297 298 TransfertTabulate::~TransfertTabulate(void) 299 { 300 } 301 302 void TransfertTabulate::SetInterpTyp(int typ) 303 // see comment in InterpTab 304 { 305 if(typ<0) typ=0; else if(typ>2) typ=2; 306 interptyp_ = typ; 307 } 308 309 double TransfertTabulate::operator() (double k) 310 { 311 return InterpTab(k,k_,tf_,interptyp_); 312 } 313 314 int TransfertTabulate::ReadCMBFast(string filename) 315 { 316 FILE *file = fopen(filename.c_str(),"r"); 317 if(file==NULL) return -1; 318 319 const int lenline = 512; 320 char *line = new char[lenline]; 321 322 int nread = 0; 323 double tmax = -1.; 324 while ( fgets(line,lenline,file) != NULL ) { 325 double k,tc,tb,tf; 326 sscanf(line,"%lf %lf %lf",&k,&tc,&tb); 327 k *= h_; // convert h^-1 Mpc -> Mpc 328 tf = (Oc_*tc+Ob_*tb)/(Oc_+Ob_); 329 if(tf>tmax) tmax = tf; 330 k_.push_back(k); 331 tf_.push_back(tf); 332 nread++; 333 } 334 335 cout<<"TransfertTabulate::ReadCMBFast: nread="<<nread<<" tf_max="<<tmax<<endl; 336 delete [] line; 337 if(nread==0) return nread; 338 339 for(unsigned int i=0;i<tf_.size();i++) tf_[i] /= tmax; 340 341 return nread; 342 } 343 344 /////////////////////////////////////////////////////////// 277 345 //********************* GrowthFactor ********************// 278 346 /////////////////////////////////////////////////////////// -
trunk/Cosmo/SimLSS/pkspectrum.h
r3314 r3318 43 43 double T0tild(double k,double alphac,double betac); 44 44 void Init_(void); 45 inline void zero_(void) 46 {th2p7_=zeq_=keq_=zd_=Req_=Rd_=s_=ksilk_=alphac_=betac_=bnode_= 47 alphab_=betab_=alphag_=sfit_=kpeak_=0.;} 45 void zero_(void); 46 }; 47 48 //----------------------------------------------------------------------------------- 49 class TransfertTabulate : public GenericFunc { 50 public: 51 TransfertTabulate(double h100,double OmegaCDM0,double OmegaBaryon0); 52 TransfertTabulate(TransfertTabulate& tf); 53 virtual ~TransfertTabulate(void); 54 virtual double operator() (double k); 55 int NPoints(void) {return k_.size();} 56 void SetInterpTyp(int typ=0); 57 int ReadCMBFast(string filename); 58 protected: 59 double Oc_,Ob_,h_; 60 double kmin_,kmax_; 61 int interptyp_; 62 vector<double> k_, tf_; 48 63 }; 49 64
Note:
See TracChangeset
for help on using the changeset viewer.