Changeset 3381 in Sophya for trunk/Cosmo/SimLSS/pkspectrum.cc


Ignore:
Timestamp:
Nov 14, 2007, 7:25:34 PM (18 years ago)
Author:
cmv
Message:

1-/ pkspectrum: GrowthFactor + PkSpectrum on enleve les memorisations

des calculs precedents, tout est recalcule

2-/ cmvfitpk: mise de Ob+Ol+Oc+h100+ns dans le fit

cmv 14/11/2007

File:
1 edited

Legend:

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

    r3378 r3381  
    3131InitialSpectrum::~InitialSpectrum(void)
    3232{
    33 }
    34 
    35 void InitialSpectrum::SetNorm(double a)
    36 {
    37   A_ = a;
    38 }
    39 
    40 void InitialSpectrum::SetSlope(double n)
    41 {
    42   n_ = n;
    4333}
    4434
     
    177167}
    178168
    179 bool TransfertEisenstein::SetParTo(double h100,double OmegaCDM0,double OmegaBaryon0,double tcmb,bool nobaryon)
     169bool TransfertEisenstein::SetParTo(double h100,double OmegaCDM0,double OmegaBaryon0)
    180170// Changement des valeurs des parametres (suivi de re-init eventuel)
     171// Si h100,Omega...<=0. alors pas de changement, on garde l'ancienne valeur
    181172{
    182173 bool haschanged = false;
     
    185176 if(OmegaCDM0>0.) {Oc_ = OmegaCDM0; haschanged = true;}
    186177 if(OmegaBaryon0>0.) {Ob_ = OmegaBaryon0; haschanged = true;}
    187  if(tcmb>0.) {tcmb_ = tcmb; haschanged = true;}
    188  if(nobaryon!=nobaryon_) {nobaryon_ = nobaryon; haschanged = true;}
    189178
    190179 // et on recalcule les initialisations
     
    371360// Pour avoir D(z) = 1/(1+z) faire: OmegaMatter0=1 OmegaLambda0=0
    372361GrowthFactor::GrowthFactor(double OmegaMatter0,double OmegaLambda0)
    373   : O0_(OmegaMatter0) , Ol_(OmegaLambda0) , Ok_(1.-OmegaMatter0-OmegaLambda0)
     362  : O0_(OmegaMatter0) , Ol_(OmegaLambda0)
    374363{
    375364  if(OmegaMatter0==0.) {
     
    377366    throw ParmError("GrowthFactor::GrowthFactor: Error badOmegaMatter0  value");
    378367  }
    379   norm_ = 1.; // puisque (*this)(0.) a besoin de norm_
    380   norm_ = (*this)(0.);
    381   cout<<"GrowthFactor::GrowthFactor : norm="<<norm_<<endl;
    382368}
    383369
    384370GrowthFactor::GrowthFactor(GrowthFactor& d1)
    385   : O0_(d1.O0_) , Ol_(d1.Ol_) , Ok_(d1.Ok_) , norm_(d1.norm_)
     371  : O0_(d1.O0_) , Ol_(d1.Ol_)
    386372{
    387373}
     
    396382 z += 1.;
    397383 double z2 = z*z, z3 = z2*z;
    398  double den = Ol_ + Ok_*z2 + O0_*z3;
     384
     385 // Calcul de la normalisation (pour z=0 -> growth=1.)
     386 double D1z0 = pow(O0_,4./7.) - Ol_ + (1.+O0_/2.)*(1.+Ol_/70.);
     387 D1z0 = 2.5*O0_ / D1z0;
     388
     389 // Calcul du growthfactor pour z
     390 double Ok = 1. - O0_ - Ol_;
     391 double den = Ol_ + Ok*z2 + O0_*z3;
    399392 double o0z = O0_ *z3 / den;
    400393 double olz = Ol_ / den;
    401394
    402  // 4./7. = 0.571429
    403  double D1z = pow(o0z,0.571429) - olz + (1.+o0z/2.)*(1.+olz/70.);
     395 double D1z = pow(o0z,4./7.) - olz + (1.+o0z/2.)*(1.+olz/70.);
    404396 D1z = 2.5*o0z / z / D1z;
    405397
    406  return D1z / norm_;
    407 }
    408 
    409 bool GrowthFactor::SetParTo(double OmegaMatter0,double OmegaLambda0)
    410 {
    411  bool haschanged = false;
    412 
    413  if(OmegaMatter0>0.) {O0_ = OmegaMatter0; haschanged = true;}
    414  if(fabs(OmegaLambda0+12345.)>1e-6) {Ol_ = OmegaLambda0; haschanged = true;}
    415 
    416  // et on recalcule les initialisations
    417  if(haschanged) {
    418    Ok_ = 1. - O0_ - Ol_;
    419    norm_ = 1.; // puisque (*this)(0.) a besoin de norm_
    420    norm_ = (*this)(0.);
    421  }
    422 
    423  return haschanged;
     398 return D1z / D1z0;
     399}
     400
     401void GrowthFactor::SetParTo(double OmegaMatter0,double OmegaLambda0)
     402{
     403 if(OmegaMatter0>0.) O0_ = OmegaMatter0;
     404 Ol_ = OmegaLambda0;
     405}
     406
     407bool GrowthFactor::SetParTo(double OmegaMatter0)
     408// idem precedent sans changer OmegaLambda0
     409{
     410 if(OmegaMatter0<=0.) return false;
     411 O0_ = OmegaMatter0;
     412 return true;
    424413}
    425414
     
    453442PkSpectrumZ::PkSpectrumZ(PkSpectrum0& pk0,GrowthFactor& d1,double zref)
    454443  : pk0_(pk0) , d1_(d1) , zref_(zref) , scale_(1.) , typspec_(PK)
    455   , zold_(-1.) , d1old_(1.)
    456444{
    457445}
     
    459447PkSpectrumZ::PkSpectrumZ(PkSpectrumZ& pkz)
    460448  : pk0_(pkz.pk0_) , d1_(pkz.d1_) , zref_(pkz.zref_) , scale_(pkz.scale_) , typspec_(PK)
    461   , zold_(pkz.zold_) , d1old_(pkz.d1old_)
    462449{
    463450}
     
    481468double PkSpectrumZ::operator() (double k,double z)
    482469{
    483   double d1;
    484   if(z == zold_) d1 = d1old_;
    485     else {d1 = d1old_ = d1_(z); zold_ = z;}
     470  double d1 = d1_(z);
    486471
    487472  double v = pk0_(k) * d1*d1;
Note: See TracChangeset for help on using the changeset viewer.