Changeset 3314 in Sophya for trunk/Cosmo


Ignore:
Timestamp:
Aug 24, 2007, 5:00:00 PM (18 years ago)
Author:
cmv
Message:

correction bug (petit) dans fct transfert cmv 24/08/2007

Location:
trunk/Cosmo/SimLSS
Files:
2 edited

Legend:

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

    r3246 r3314  
    4848///////////////////////////////////////////////////////////
    4949
    50 // From Eisenstein & Hu ApJ 496:605-614 1998 April 1
    51 TransfertEisenstein::TransfertEisenstein(double h100,double OmegaCDM0,double OmegaBaryon0,double tcmb,bool nobaryon)
    52   : Oc_(OmegaCDM0) , Ob_(OmegaBaryon0) , h_(h100) , tcmb_(tcmb)
    53   , nobaryon_(nobaryon) , nooscenv_(0)
    54 {
    55   if(nobaryon_ == false && Ob_>0.) Init_With_Baryons();
    56   else Init_Without_Baryon();
     50// From Eisenstein & Hu ApJ 496:605-614 1998 April 1 (ou astro-ph/9709112)
     51TransfertEisenstein::TransfertEisenstein(double h100,double OmegaCDM0,double OmegaBaryon0,double tcmb,bool nobaryon,int lp)
     52  : lp_(lp)
     53  , Oc_(OmegaCDM0) , Ob_(OmegaBaryon0) , h_(h100) , tcmb_(tcmb)
     54  , nobaryon_(nobaryon) , nooscenv_(0), retpart_(0)
     55{
     56 zero_();
     57 Init_();
    5758}
    5859
    5960TransfertEisenstein::TransfertEisenstein(TransfertEisenstein& tf)
    60   : Oc_(tf.Oc_) , Ob_(tf.Ob_) , h_(tf.h_) , tcmb_(tf.tcmb_)
    61   , nobaryon_(tf.nobaryon_) , nooscenv_(tf.nooscenv_)
    62 {
    63   if(nobaryon_ == false && Ob_>0.) Init_With_Baryons();
    64   else Init_Without_Baryon();
    65 }
    66 
    67 void TransfertEisenstein::Init_With_Baryons(void)
    68 {
    69   int lp = 1;
    70 
    71   nobaryon_ = false;
     61  : lp_(tf.lp_)
     62  ,Oc_(tf.Oc_) , Ob_(tf.Ob_) , h_(tf.h_) , tcmb_(tf.tcmb_)
     63  , nobaryon_(tf.nobaryon_) , nooscenv_(tf.nooscenv_), retpart_(tf.retpart_)
     64{
     65 zero_();
     66 Init_();
     67}
     68
     69void TransfertEisenstein::Init_(void)
     70{
     71
    7272  O0_ = Oc_ + Ob_;
    73   if(lp) cout<<"h100="<<h_<<" Omatter="<<O0_<<" Ocdm="<<Oc_<<" Ob="<<Ob_<<endl;
     73  if(nobaryon_) {O0_ = Oc_; Ob_ = 0.;}
     74  if(lp_) cout<<"h100="<<h_<<" Omatter="<<O0_<<" Ocdm="<<Oc_<<" Ob="<<Ob_<<endl;
    7475
    7576  double H0 = 100. * h_, h2 = h_*h_;
    7677
     78  if(tcmb_<0.) tcmb_ = T_CMB_Par;
    7779  th2p7_ = tcmb_/2.7;
    7880  double th2p7P4 = th2p7_*th2p7_*th2p7_*th2p7_;
     81  if(lp_) cout<<"tcmb = "<<tcmb_<<" K = "<<th2p7_<<" *2.7K "<<endl;
    7982
    8083  // Formule 2 p 606
    8184  zeq_ = 2.50e4 * O0_ * h2 / th2p7P4;
    82     if(lp) cout<<"zeq = "<<zeq_<<endl;
     85  if(lp_) cout<<"zeq = "<<zeq_<<" (redshift of matter-radiation equality)"<<endl;
    8386
    8487  // Formule 3 p 607
     
    8689  //  keq_ = sqrt(2.*O0_*H0*H0*zeq_) / SpeedOfLight_Cst;
    8790  keq_ = 7.46e-2 * O0_ * h2 / (th2p7_*th2p7_);
    88     if(lp) cout<<"keq = "<<keq_<<" Mpc^-1"<<endl;
     91  if(lp_) cout<<"keq = "<<keq_<<" Mpc^-1 (scale of equality)"<<endl;
     92
     93  // On s'arrete ici si pas de baryons
     94  if(nobaryon_) return;
    8995
    9096  // Formule 4 p 607
    9197  double b1_eq4 = 0.313*pow(O0_*h2,-0.419)*(1. + 0.607*pow(O0_*h2,0.674));
    9298  double b2_eq4 = 0.238*pow(O0_*h2,0.223);
    93   double zd_ = 1291. * pow(O0_*h2,0.251) / (1.+0.659* pow(O0_*h2,0.828))
    94              * (1. + b1_eq4*pow(Ob_*h2,b2_eq4));
    95     if(lp) cout<<"zd = "<<zd_<<endl;
    96 
    97   // Formule 5 page 607
     99  zd_ = 1291. * pow(O0_*h2,0.251) / (1.+0.659* pow(O0_*h2,0.828))
     100              * (1. + b1_eq4*pow(Ob_*h2,b2_eq4));
     101  if(lp_) cout<<"zd = "<<zd_<<" (Redshift of drag epoch)"<<endl;
     102
     103  // Formule 5 page 607    (R = 3*rho_baryon/4*rho_gamma)
    98104  Req_ = 31.5*Ob_*h2 / th2p7P4 * (1.e3/zeq_);
     105  //WARNING: W.Hu code (tf_fit.c) en des-accord avec l'article: zd -> (1+zd)
    99106  Rd_  = 31.5*Ob_*h2 / th2p7P4 * (1.e3/zd_);
    100     if(lp) cout<<"Req = "<<Req_<<" Rd = "<<Rd_<<endl;
     107  //in tf_fit.c: Rd_  = 31.5*Ob_*h2 / th2p7P4 * (1.e3/(1.+zd_));
     108  if(lp_) {
     109    cout<<"Req = "<<Req_<<" Rd = "<<Rd_
     110        <<" (Photon-baryon ratio at equality/drag epoch)"<<endl;
     111    cout<<"Sound speed at equality "<<1./sqrt(3.*(1.+Req_))
     112        <<", at drag "<<1./sqrt(3.*(1.+Rd_))<<" in unit of C"<<endl;
     113  }
    101114
    102115  // Formule 6 p 607
    103116  s_ = 2./(3.*keq_) * sqrt(6./Req_)
    104117      * log( (sqrt(1.+Rd_) + sqrt(Rd_+Req_)) / (1.+sqrt(Req_)) );
    105     if(lp) cout<<"s = "<<s_<<" Mpc"<<endl;
     118  if(lp_) cout<<"s = "<<s_<<" Mpc (sound horizon at drag epoch)"<<endl;
    106119
    107120  // Formule 7 page 607
    108121  ksilk_ = 1.6*pow(Ob_*h2,0.52)*pow(O0_*h2,0.73) * (1. + pow(10.4*O0_*h2,-0.95));
    109     if(lp) cout<<"ksilk = "<<ksilk_<<" Mpc^-1"<<endl;
     122  if(lp_) cout<<"ksilk = "<<ksilk_<<" Mpc^-1 (silk damping scale)"<<endl;
    110123
    111124  // Formules 10 page 608
     
    116129  double b2 = pow(0.395*O0_*h2,-0.0266);
    117130  betac_ = 1 / ( 1. + b1*(pow(Oc_/O0_,b2) - 1.) );
     131  if(lp_) cout<<"alphac = "<<alphac_<<" betac = "<<betac_
     132               <<" (CDM suppression/log shift)"<<endl;
    118133
    119134  // Formule 23 page 610
    120135  bnode_ = 8.41 * pow(O0_*h2,0.435);
    121     if(lp) cout<<"bnode = "<<bnode_<<endl;
     136  if(lp_) cout<<"bnode = "<<bnode_<<" (sound horizon shift)"<<endl;
    122137
    123138  // Formule 14 page 608
     139  //WARNING: W.Hu code (tf_fit.c) en des-accord avec l'article: (1+zeq) -> zeq
    124140  double y = (1.+zeq_)/(1.+zd_);
     141  //in tf_fit.c: double y = zeq_/(1.+zd_);
    125142  double s1py = sqrt(1.+y);
    126143  double Gy = y*( -6.*s1py + (2.+3.*y)*log((s1py+1.)/(s1py-1.)) );
     
    130147  betab_ = 0.5 + Ob_/O0_
    131148         + (3.-2.*Ob_/O0_) * sqrt(pow(17.2*O0_*h2,2.) + 1.);
     149  if(lp_) cout<<"alphab = "<<alphab_<<" betab = "<<betab_
     150               <<" (Baryon suppression/envelope shift)"<<endl;
    132151
    133152  // Formule 31 page 612
     
    135154          - 0.328*log(431.*O0_*h2)*Ob_/O0_
    136155          + 0.38*log(22.3*O0_*h2)*pow(Ob_/O0_,2.);
    137 
    138  // --- Pour la positon du premier pic acoustique
    139  // Formule 26 page 611
    140  double s_peak = 44.5*log(9.83/(O0_*h2)) / sqrt(1.+10.*pow(Ob_*h2,3./4.));  // Mpc
    141  // Formule 25 page 611
    142  kpeak_ = 5*M_PI/(2.*s_peak) * (1.+0.217*O0_*h2);  // 1/Mpc
    143    if(lp) cout<<"for 1er peak: s="<<s_peak<<" kpeak="<<kpeak_<<endl;
     156  if(lp_) cout<<"alphag = "<<alphag_<<" (gamma suppression in approximate TF)"<<endl;
     157
     158 // The approximate value of the sound horizon, formule 26 page 611
     159 sfit_ = 44.5*log(9.83/(O0_*h2)) / sqrt(1.+10.*pow(Ob_*h2,3./4.));  // Mpc
     160 if(lp_) cout<<"sfit="<<sfit_<<" Mpc (fit to sound horizon)"<<endl;
     161
     162 // La positoin du premier pic acoustique, formule 25 page 611
     163 kpeak_ = 5*M_PI/(2.*sfit_) * (1.+0.217*O0_*h2);  // 1/Mpc
     164 if(lp_) cout<<"kpeak="<<kpeak_<<" Mpc^-1 (fit to wavenumber of first peak)"<<endl;
    144165
    145166  return;
    146167}
    147168
    148 void TransfertEisenstein::Init_Without_Baryon(void)
    149 {
    150   int lp = 1;
    151 
    152   nobaryon_ = true;
    153   O0_ = Oc_;
    154   if(lp) cout<<"Omatter="<<O0_<<" Ocdm="<<Oc_<<endl;
    155   th2p7_ = tcmb_/2.7;
    156 }
    157 
    158169TransfertEisenstein::~TransfertEisenstein(void)
    159170{
     
    161172
    162173void TransfertEisenstein::SetNoOscEnv(unsigned short nooscenv)
    163 // To obtain the non-oscillatory part of the spectrum
    164 // nooscenv = 0 : use the baryon oscillatory part of transfert function
     174// To obtain an approximate form of the non-oscillatory part of the transfert function
     175// nooscenv = 0 : use the baryon oscillatory part of transfert function (full tf)
    165176// nooscenv = 1 : use approx. paragraph 3.3 p610 (middle of right column)
     177//                Replace  j0(k*stilde)  ->  [1+(k*stilde)^4]^(-1/4)
    166178// nooscenv = 2 : use formulae 29+30+31 page 612
    167 {
    168   if(nooscenv>2) {
    169     cout<<"TransfertEisenstein::SetNoOscEnv: Error bad nooscenv value: "<<nooscenv<<endl;
    170     throw ParmError("TransfertEisenstein::SetNoOscEnv: Error bad nooscenv value");
    171   }
    172   nooscenv_ = nooscenv;
     179//                The value of an approximate transfer function that captures
     180//                the non-oscillatory part of a partial baryon transfer function.
     181//                In other words, the baryon oscillations are left out,
     182//                but the suppression of power below the sound horizon is included.
     183{
     184 if(nooscenv!=1 && nooscenv!=2) nooscenv = 0;
     185 nooscenv_ = nooscenv;
     186}
     187
     188void TransfertEisenstein::SetReturnPart(unsigned short retpart)
     189// To return only baryon or CDM part part of transfert function
     190// retpart = 1 : return only CDM part of transfert function
     191// retpart = 2 : return only Baryon part of transfert function
     192// retpart = anything else: return only full transfert function
     193// WARNING: only relevant for nobaryon_=false AND nooscenv!=2
     194{
     195 if(retpart!=1 && retpart!=2) retpart = 0;
     196 retpart_ = retpart;
    173197}
    174198
     
    192216  if(nobaryon_  || nooscenv_ == 2) {
    193217    double gamma = O0_*h_;
    194     // Formule 30 page 612 (pour fct lissee)
     218    // Calcul de Gamma_eff, formule 30 page 612 (pour fct lissee)
    195219    if( nobaryon_==false && nooscenv_ == 2 )
    196       gamma = O0_*h_*(alphag_ + (1.-alphag_)/(1.+pow(0.43*k*s_,4.)));
    197     // Formule 28 page 612
    198     double q = k / h_ * th2p7_*th2p7_/gamma;  // Mpc^-1
     220      gamma = O0_*h_*(alphag_ + (1.-alphag_)/(1.+pow(0.43*k*sfit_,4.))); // Gamma_eff
     221    // Formule 28 page 612 : qui est est equivalent a:
     222    //    q = k / h_ * th2p7_*th2p7_ / gamma;
     223    // qui est est equivalent a:
     224    //    q = k / (13.41 * keq)                   pour Ob=0
     225    //    q = k / (13.41 * keq) * (O0*h/Gamma)    pour le spectre lisse
     226    // Les resultats sont legerement differents a cause des valeurs approx.
     227    // des constantes numeriques: on prend comme W.Hu (tf_fit.c)
     228    //double q = k / h_ * th2p7_*th2p7_ / gamma;  // Mpc^-1
     229    double q = k/(13.41*keq_) * (O0_*h_/gamma);  // Mpc^-1
    199230    // Formules 29 page 612
    200231    double l0 = log(2.*M_E + 1.8*q);
     
    203234  }
    204235
     236  // --- Pour CDM + Baryons
    205237  // --- CDM
    206238  double f = 1. / (1. + pow(k*s_/5.4,4.));
    207239  double Tc = f*T0tild(k,1.,betac_) + (1.-f)*T0tild(k,alphac_,betac_);
     240  if(retpart_ == 1) return Tc;
    208241
    209242  // --- Baryons
    210243  // Formule 22 page 610
    211   double stk, ksbnode = k*s_/bnode_;
    212   if(ksbnode<0.001) stk =s_ * ksbnode;
    213      else   stk = s_ / pow(1. + pow(1./ksbnode,3.), 1/.3);
     244  double stilde, ksbnode = k*s_/bnode_;
     245  if(ksbnode<0.001) stilde =s_ * ksbnode;
     246     else   stilde = s_ / pow(1. + pow(1./ksbnode,3.), 1./3.);
    214247  // Formule 21 page 610
    215248  double j0kst = 0.;
    216   if(nooscenv_ == 1) j0kst = pow(1.+pow(k*stk,4.) , -1./4.); //lissee sans oscillation baryon
    217   else {
    218     double x = k*stk;
     249  if(nooscenv_ == 1) {
     250    j0kst = pow(1.+pow(k*stilde,4.) , -1./4.); //lissee sans oscillation baryon
     251  } else {
     252    double x = k*stilde;
    219253    if(x<0.01) j0kst = 1. - x*x/6.*(1.-x*x/20.);
    220254      else j0kst = sin(x)/x;
    221     ////if(k>0.038&&k<0.07) cout<<"k="<<k<<" stk="<<stk<<" x="<<x<<endl;
     255    //cout<<"DEBUG: k="<<k<<" stilde="<<stilde<<" x="<<x<<" j0kst="<<j0kst<<endl;
    222256  }
    223257  double Tb = T0tild(k,1.,1.) / (1. + pow(k*s_/5.2,2.));
    224   Tb += alphab_/(1.+pow(betab_/(k*s_),3.)) * exp(-pow(k/ksilk_,1/4.));
     258  Tb += alphab_/(1.+pow(betab_/(k*s_),3.)) * exp(-pow(k/ksilk_,1.4));
    225259  Tb *= j0kst;
     260  if(retpart_ == 2) return Tb;
    226261
    227262  // --- Total
     
    528563    lkfind = lkmin;
    529564    for(int i=0;i<=n;i++) {
    530       if( (*this)(pow(10,lkfind)) >= high ) break;   //cmvbug
     565      if( (*this)(pow(10,lkfind)) >= high ) break;
    531566      lkfind = lkmin + i*dlk;
    532567    }
     
    548583    lkfind=lkmax;
    549584    for(int i=0;i<=n;i++) {
    550       if( (*this)(pow(10,lkfind)) >= high ) break;   //cmvbug
     585      if( (*this)(pow(10,lkfind)) >= high ) break;
    551586      lkfind -= dlk;
    552587      lkfind = lkmax - i*dlk;
  • trunk/Cosmo/SimLSS/pkspectrum.h

    r3115 r3314  
    2323class TransfertEisenstein : public GenericFunc {
    2424public:
    25   TransfertEisenstein(double h100,double OmegaCDM0,double OmegaBaryon0,double tcmb,bool nobaryon=false);
     25  TransfertEisenstein(double h100,double OmegaCDM0,double OmegaBaryon0,double tcmb,bool nobaryon=false,int lp=0);
    2626  TransfertEisenstein(TransfertEisenstein& tf);
    2727  virtual ~TransfertEisenstein(void);
     
    2929  double KPeak(void);
    3030  void SetNoOscEnv(unsigned short nooscenv=0);
     31  void SetReturnPart(unsigned short retpart=0);
    3132protected:
    32   double O0_,Oc_,Ob_,h_,tcmb_,th2p7_;
     33  int lp_;
     34  double O0_,Oc_,Ob_,h_,tcmb_;
     35  double th2p7_;
    3336  double zeq_,keq_,zd_,Req_,Rd_,s_,ksilk_,alphac_,betac_,bnode_,alphab_,betab_;
    3437  double alphag_;
    35   double kpeak_;
     38  double sfit_,kpeak_;
    3639
    3740  bool nobaryon_;
    38   unsigned short nooscenv_;
     41  unsigned short nooscenv_, retpart_;
     42
    3943  double T0tild(double k,double alphac,double betac);
    40   void Init_With_Baryons(void);
    41   void Init_Without_Baryon(void);
     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.;}
    4248};
    4349
Note: See TracChangeset for help on using the changeset viewer.