Changeset 3318 in Sophya for trunk/Cosmo/SimLSS


Ignore:
Timestamp:
Aug 28, 2007, 11:41:49 AM (18 years ago)
Author:
cmv
Message:

TransfertTabulate pour avoir les fct de transfert de CMBFast cmv 28/08/2007

Location:
trunk/Cosmo/SimLSS
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosmo/SimLSS/cmvtransf.cc

    r3115 r3318  
    1414
    1515void usage(void);
    16 void usage(void) {cout<<"cmvtuniv [k1,k2,npt] [h100,Om0,Ob0,tcmb]"<<endl;}
     16void usage(void) {
     17cout
     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}
    1724
    1825int main(int narg,char *arg[])
     
    2027 double k1 = 1e-6, k2 = 10.; int_4 npt = 100;
    2128 double h100 = 0.71, Om0 = 0.267804, Ob0 = 0.0444356, tcmb = T_CMB_Par;
     29 string fcmbfast = "";
    2230
    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
    2449 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;}
    2652 cout<<"k1="<<k1<<"  k2="<<k2<<" npt="<<npt<<endl;
    27  if(narg>2) sscanf(arg[2],"%lf,%lf,%lf,%lf",&h100,&Om0,&Ob0,&tcmb);
    2853 cout<<"h100="<<h100<<" Om0="<<Om0<<" Ob0="<<Ob0<<" Tcmb="<<tcmb<<endl;
     54 cout<<"fcmbfast="<<fcmbfast<<endl;
    2955
    3056 cout<<"TransfertEisenstein with baryon"<<endl;
     
    4369 TransfertEisenstein tfnob(h100,Om0-Ob0,Ob0,tcmb,true);  // No baryons
    4470
    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"};
    4782 NTuple nt(n,vname);
    4883 double xnt[n];
     84 for(int i=0;i<n;i++) xnt[i]=0.;
    4985
    5086 double lnk1 = log10(k1), lnk2=log10(k2), dlnk=(lnk2-lnk1)/npt;
     
    5692   xnt[3]  = tfnosc2(k);
    5793   xnt[4]  = tfnob(k);
     94   if(cmbfastOK) xnt[5]  = tfcmbfast(k);
    5895   nt.Fill(xnt);
    5996 }
     
    73110set k log10(k)
    74111
    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
     113n/plot nt.t%$k ! ! "nsta connectpoints"
     114n/plot nt.tnob%$k ! ! "nsta red same connectpoints"
     115n/plot nt.tnosc2%$k ! ! "nsta blue same connectpoints"
     116n/plot nt.tnosc1%$k ! ! "nsta green same connectpoints"
    79117
    80 n/plot nt.t/tnosc1%$k ! ! "nsta crossmarker3"
    81 n/plot nt.t/tnosc2%$k ! ! "nsta crossmarker3 red same"
     118n/plot nt.t/tnob%$k   tnob>0   ! "nsta red connectpoints"
     119n/plot nt.t/tnosc2%$k tnosc2>0 ! "nsta blue same connectpoints"
     120n/plot nt.t/tnosc1%$k tnosc1>0 ! "nsta green same connectpoints"
     121
     122# CMBFast
     123n/plot nt.t%$k ! ! "nsta connectpoints"
     124n/plot nt.tcmbf%$k ! ! "nsta red same connectpoints"
     125
     126n/plot nt.(tcmbf-t)%$k tcmbf>0. ! "nsta connectpoints"
     127n/plot nt.(tcmbf-t)/tcmbf%$k tcmbf>0. ! "nsta connectpoints"
    82128*/
  • trunk/Cosmo/SimLSS/cmvtstpk.cc

    r3193 r3318  
    2828int main(int narg,char *arg[])
    2929{
    30  double Ob0 = 0.0444356;
    3130 // -- 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.;
    3832
    3933 double ns = 1., as = 1.;
    40 
    4134 int npt = 10000;
    4235 double lkmin = -3., lkmax=2.;
  • trunk/Cosmo/SimLSS/pkspectrum.cc

    r3314 r3318  
    6565 zero_();
    6666 Init_();
     67}
     68
     69void TransfertEisenstein::zero_(void)
     70{
     71 th2p7_=zeq_=keq_=zd_=Req_=Rd_=s_=ksilk_=alphac_=betac_=bnode_
     72       =alphab_=betab_=alphag_=sfit_=kpeak_=1.e99;
    6773}
    6874
     
    275281
    276282///////////////////////////////////////////////////////////
     283//******************* TransfertTabulate *****************//
     284///////////////////////////////////////////////////////////
     285
     286TransfertTabulate::TransfertTabulate(double h100,double OmegaCDM0,double OmegaBaryon0)
     287: Oc_(OmegaCDM0) , Ob_(OmegaBaryon0) , h_(h100) , kmin_(1.) , kmax_(-1.)
     288, interptyp_(0)
     289{
     290}
     291
     292TransfertTabulate::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
     298TransfertTabulate::~TransfertTabulate(void)
     299{
     300}
     301
     302void 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
     309double TransfertTabulate::operator() (double k)
     310{
     311 return InterpTab(k,k_,tf_,interptyp_);
     312}
     313
     314int 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///////////////////////////////////////////////////////////
    277345//********************* GrowthFactor ********************//
    278346///////////////////////////////////////////////////////////
  • trunk/Cosmo/SimLSS/pkspectrum.h

    r3314 r3318  
    4343  double T0tild(double k,double alphac,double betac);
    4444  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//-----------------------------------------------------------------------------------
     49class TransfertTabulate : public GenericFunc {
     50public:
     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);
     58protected:
     59  double Oc_,Ob_,h_;
     60  double kmin_,kmax_;
     61  int interptyp_;
     62  vector<double> k_, tf_;
    4863};
    4964
Note: See TracChangeset for help on using the changeset viewer.