Changeset 3348 in Sophya
- Timestamp:
- Oct 11, 2007, 4:37:03 PM (18 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/cmvchkwhu.cc
r3317 r3348 59 59 double k = pow(10.,lnk); 60 60 //if(fabs(lnk-log10(0.0186209))>1e-5) continue; 61 Tfull.SetReturnPart( 0); double tf = Tfull(k);61 Tfull.SetReturnPart(TransfertEisenstein::ALL); double tf = Tfull(k); 62 62 double tfnw = Tnowig(k); 63 63 double tfnb = Tnob(k); 64 Tfull.SetReturnPart( 1); double tfc = Tfull(k);65 Tfull.SetReturnPart( 2); double tfb = Tfull(k);64 Tfull.SetReturnPart(TransfertEisenstein::CDM); double tfc = Tfull(k); 65 Tfull.SetReturnPart(TransfertEisenstein::BARYON); double tfb = Tfull(k); 66 66 double hutfc, hutfb; 67 67 double hutf = TFfit_onek(k,&hutfb,&hutfc); -
trunk/Cosmo/SimLSS/cmvtvarspec.cc
r3329 r3348 91 91 //---- 92 92 cout<<endl<<"Filtrage top_hat"<<endl; 93 VarianceSpectrum varpk_th(pkz, 0);94 double kfind_th = varpk_th.FindMaximum( R,kmin,kmax,eps);93 VarianceSpectrum varpk_th(pkz,R,VarianceSpectrum::TOPHAT); 94 double kfind_th = varpk_th.FindMaximum(kmin,kmax,eps); 95 95 double pkmax_th = varpk_th(kfind_th); 96 96 cout<<"kfind_th = "<<kfind_th<<" ("<<log10(kfind_th)<<"), integrand="<<pkmax_th<<endl; 97 97 k1=kmin, k2=kmax; 98 rc = varpk_th.FindLimits( R,pkmax_th*fracmax,k1,k2,eps);98 rc = varpk_th.FindLimits(pkmax_th*fracmax,k1,k2,eps); 99 99 cout<<"limit_th: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "<<k2<<" ("<<log10(k2)<<")"<<endl; 100 100 101 101 varpk_th.SetInteg(0.01,dlk,-1.,4); 102 cout<<"varpk_th="<<varpk_th.Variance( R,k1,k2)<<endl;102 cout<<"varpk_th="<<varpk_th.Variance(k1,k2)<<endl; 103 103 104 104 //---- 105 105 cout<<endl<<"Filtrage gaussien"<<endl; 106 VarianceSpectrum varpk_ga(pkz, 1);107 double kfind_ga = varpk_ga.FindMaximum( Rg,kmin,kmax,eps);106 VarianceSpectrum varpk_ga(pkz,Rg,VarianceSpectrum::GAUSSIAN); 107 double kfind_ga = varpk_ga.FindMaximum(kmin,kmax,eps); 108 108 double pkmax_ga = varpk_ga(kfind_ga); 109 109 cout<<"kfind_ga = "<<kfind_ga<<" -> "<<log10(kfind_ga)<<", integrand="<<pkmax_ga<<endl; 110 110 k1=kmin, k2=kmax; 111 rc = varpk_ga.FindLimits( Rg,pkmax_ga*fracmax,k1,k2,eps);111 rc = varpk_ga.FindLimits(pkmax_ga*fracmax,k1,k2,eps); 112 112 cout<<"limit_ga: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "<<k2<<" ("<<log10(k2)<<")"<<endl; 113 113 114 114 varpk_ga.SetInteg(0.01,dlk,-1.,4); 115 cout<<"varpk_ga="<<varpk_ga.Variance( Rg,k1,k2)<<endl;115 cout<<"varpk_ga="<<varpk_ga.Variance(k1,k2)<<endl; 116 116 117 117 //---- 118 118 cout<<endl<<"Filtrage 1 (integrale du spectre)"<<endl; 119 VarianceSpectrum varpk_int(pkz, 2);120 double kfind_int = varpk_int.FindMaximum( Rg,kmin,kmax,eps);119 VarianceSpectrum varpk_int(pkz,Rg,VarianceSpectrum::NOFILTER); 120 double kfind_int = varpk_int.FindMaximum(kmin,kmax,eps); 121 121 double pkmax_int = varpk_int(kfind_int); 122 122 cout<<"kfind_int = "<<kfind_int<<" -> "<<log10(kfind_int)<<", integrand="<<pkmax_int<<endl; 123 123 k1=kmin, k2=kmax; 124 rc = varpk_int.FindLimits( Rg,pkmax_int*fracmax,k1,k2,eps);124 rc = varpk_int.FindLimits(pkmax_int*fracmax,k1,k2,eps); 125 125 cout<<"limit_int: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "<<k2<<" ("<<log10(k2)<<")"<<endl; 126 126 127 127 varpk_int.SetInteg(0.01,dlk,-1.,4); 128 cout<<"varpk_int="<<varpk_int.Variance( Rg,k1,k2)<<endl;128 cout<<"varpk_int="<<varpk_int.Variance(k1,k2)<<endl; 129 129 130 130 //----------------------------------------------------------------- -
trunk/Cosmo/SimLSS/pkspectrum.cc
r3329 r3348 52 52 : lp_(lp) 53 53 , Oc_(OmegaCDM0) , Ob_(OmegaBaryon0) , h_(h100) , tcmb_(tcmb) 54 , nobaryon_(nobaryon) , nooscenv_(0), retpart_( 0)54 , nobaryon_(nobaryon) , nooscenv_(0), retpart_(ALL) 55 55 { 56 56 zero_(); … … 192 192 } 193 193 194 void TransfertEisenstein::SetReturnPart( unsigned short retpart)194 void TransfertEisenstein::SetReturnPart(ReturnPart retpart) 195 195 // To return only baryon or CDM part part of transfert function 196 // retpart = 1 : return only CDM part oftransfert function197 // retpart = 2 : return only Baryonpart of transfert function198 // retpart = anything else: return only fulltransfert function196 // retpart = ALL: return full transfert function 197 // = CDM : return only CDM part of transfert function 198 // = BARYON : return only Baryon part of transfert function 199 199 // WARNING: only relevant for nobaryon_=false AND nooscenv!=2 200 200 { 201 if(retpart!=1 && retpart!=2) retpart = 0;202 201 retpart_ = retpart; 203 202 } … … 244 243 double f = 1. / (1. + pow(k*s_/5.4,4.)); 245 244 double Tc = f*T0tild(k,1.,betac_) + (1.-f)*T0tild(k,alphac_,betac_); 246 if(retpart_ == 1) return Tc;245 if(retpart_ == CDM) return Tc; 247 246 248 247 // --- Baryons … … 264 263 Tb += alphab_/(1.+pow(betab_/(k*s_),3.)) * exp(-pow(k/ksilk_,1.4)); 265 264 Tb *= j0kst; 266 if(retpart_ == 2) return Tb;265 if(retpart_ == BARYON) return Tb; 267 266 268 267 // --- Total … … 413 412 //------------------------------------ 414 413 PkSpectrumZ::PkSpectrumZ(PkSpectrum0& pk0,GrowthFactor& d1,double zref) 415 : pk0_(pk0) , d1_(d1) , zref_(zref) , scale_(1.) , typspec_( 0)414 : pk0_(pk0) , d1_(d1) , zref_(zref) , scale_(1.) , typspec_(PK) 416 415 , zold_(-1.) , d1old_(1.) 417 416 { … … 419 418 420 419 PkSpectrumZ::PkSpectrumZ(PkSpectrumZ& pkz) 421 : pk0_(pkz.pk0_) , d1_(pkz.d1_) , zref_(pkz.zref_) , scale_(pkz.scale_) , typspec_( 0)420 : pk0_(pkz.pk0_) , d1_(pkz.d1_) , zref_(pkz.zref_) , scale_(pkz.scale_) , typspec_(PK) 422 421 , zold_(pkz.zold_) , d1old_(pkz.d1old_) 423 422 { … … 428 427 } 429 428 430 void PkSpectrumZ::SetTypSpec(unsigned short typspec) 431 // typsec = 0 : compute Pk(k) 432 // = 1 : compute Delta^2(k) = k^3*Pk(k)/2Pi^2 433 { 434 if(typspec>1) { 435 cout<<"PkSpectrumZ::SetTypSpec: Error bad typspec value: "<<typspec<<endl; 436 throw ParmError("PkSpectrumZ::SetTypSpec: Error bad typspec value"); 437 } 429 void PkSpectrumZ::SetTypSpec(ReturnSpectrum typspec) 430 // typsec = PK : compute Pk(k) 431 // = DELTA : compute Delta^2(k) = k^3*Pk(k)/2Pi^2 432 { 438 433 typspec_ = typspec; 439 434 } … … 451 446 452 447 double v = pk0_(k) * d1*d1; 453 if(typspec_ ) v *= k*k*k/(2.*M_PI*M_PI);448 if(typspec_==DELTA) v *= k*k*k/(2.*M_PI*M_PI); 454 449 455 450 return scale_ * v; … … 462 457 /////////////////////////////////////////////////////////// 463 458 464 VarianceSpectrum::VarianceSpectrum(GenericFunc& pk,unsigned short typfilter=0) 465 : pk_(pk) , R_(0.) 466 { 459 VarianceSpectrum::VarianceSpectrum(GenericFunc& pk,double R,TypeFilter typfilter) 460 : pk_(pk) 461 { 462 SetRadius(R); 467 463 SetFilter(typfilter); 468 464 } … … 478 474 } 479 475 476 void VarianceSpectrum::SetRadius(double R) 477 // R = taille du filter top-hat ou gaussien 478 { 479 if(R<=0.) { 480 cout<<"VarianceSpectrum::SetRadius: Error R<=0"<<endl; 481 throw ParmError("VarianceSpectrum::SetRadius: Error R<=0"); 482 } 483 R_ = R; 484 } 485 480 486 //------------------------------------ 481 void VarianceSpectrum::SetFilter(unsigned short typfilter) 482 // typfilter = 0 : spherical 3D top-hat 483 // = 1 : spherical 3D gaussian 484 // = 2 : no filter juste integrate spectrum) 485 { 486 if(typfilter>2) { 487 cout<<"VarianceSpectrum::SetFilter: Error bad value for type of filter"<<endl; 488 throw ParmError("VarianceSpectrum::SetFilter: Error bad value for type of filter"); 489 } 487 void VarianceSpectrum::SetFilter(TypeFilter typfilter) 488 // typfilter = TOPHAT : spherical 3D top-hat 489 // = GAUSSIAN : spherical 3D gaussian 490 // = NOFILTER : no filter juste integrate spectrum) 491 // Remarque: 492 // la meilleure approximation du filtre top-hat (R) est un filtre gaussien avec (Rg=R/sqrt(5)) 493 { 490 494 typfilter_ = typfilter; 491 495 } … … 507 511 { 508 512 // Just integrate the spectrum without filtering 509 if(typfilter_ == 2) return 1.;513 if(typfilter_ == NOFILTER) return 1.; 510 514 511 515 double x2 = x*x; … … 515 519 // DL(x) = 1-x^2*(1-x^2/2) 516 520 // pour x<0.01 |DL(x)-G(X)^2|<2.0e-13 517 if(typfilter_ == 1)521 if(typfilter_ == GAUSSIAN) 518 522 if(x<0.01) return 1.-x2*(1.-x2/2.); else return exp(-x2); 519 523 … … 534 538 } 535 539 536 double VarianceSpectrum::Variance(double R,doublekmin,double kmax)540 double VarianceSpectrum::Variance(double kmin,double kmax) 537 541 // Compute variance of spectrum pk_ by integration 538 542 // Input: 539 // R = taille du filter top-hat ou gaussien540 543 // kmin,kmax = bornes en k de l'integrale pour calculer la variance 541 544 // Return: 542 545 // valeur de la variance (sigma^2) 543 546 // Remarque: 544 // la meilleure approximation du filtre top-hat (R) est un filtre gaussien avec (Rg=R/sqrt(5))545 547 // la variance renvoyee est la variance de la masse 546 548 { 547 if(R<=0. || kmin<=0 || kmax<=0. || kmin>=kmax) { 548 cout<<"VarianceSpectrum::Variance: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax"<<endl; 549 throw ParmError("VarianceSpectrum::Variance: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax"); 550 } 551 552 R_ = R; 549 if(kmin<=0 || kmax<=0. || kmin>=kmax) { 550 cout<<"VarianceSpectrum::Variance: Error kmin<=0 or kmax<=0 or kmin>=kmax"<<endl; 551 throw ParmError("VarianceSpectrum::Variance: Error kmin<=0 or kmax<=0 or kmin>=kmax"); 552 } 553 553 554 double lkmin = log10(kmin), lkmax = log10(kmax); 554 555 … … 559 560 560 561 //------------------------------------ 561 double VarianceSpectrum::FindMaximum(double R,doublekmin,double kmax,double eps)562 double VarianceSpectrum::FindMaximum(double kmin,double kmax,double eps) 562 563 // Retourne le maximum de la fonction a integrer 563 564 // La recherche a lieu entre [kmin,kmax] par pas logarithmiques 564 565 // Input: 565 // R : taille du filter top-hat ou gaussien566 566 // kmin,kmax : intervalle de recherche 567 567 // eps : precision requise sur les valeurs … … 569 569 // position (en k) du maximum 570 570 { 571 if(R<=0. || kmin<=0 || kmax<=0. || kmin>=kmax) { 572 cout<<"VarianceSpectrum::FindMaximum: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"<<endl; 573 throw ParmError("VarianceSpectrum::FindMaximum: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"); 574 } 575 576 R_ = R; 571 if(kmin<=0 || kmax<=0. || kmin>=kmax) { 572 cout<<"VarianceSpectrum::FindMaximum: Error kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"<<endl; 573 throw ParmError("VarianceSpectrum::FindMaximum: Error kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"); 574 } 577 575 578 576 int n = 10; // toujours >2 … … 600 598 } 601 599 602 int VarianceSpectrum::FindLimits(double R,doublehigh,double &kmin,double &kmax,double eps)600 int VarianceSpectrum::FindLimits(double high,double &kmin,double &kmax,double eps) 603 601 // Retourne "[kmin,kmax]" tel que la fonction a integrer soit "f(k) <= high" 604 602 // La recherche a lieu entre [kmin,kmax] par pas logarithmiques 605 603 // Input: 606 // R : taille du filter top-hat ou gaussien607 604 // kmin,kmax : intervalle de recherche 608 605 // eps : precision requise sur les valeurs kmin et kmax … … 615 612 // rc |= 4 "f(k) < high pour tout k" (bit2 =1) 616 613 { 617 if(R<=0. || kmin<=0 || kmax<=0. || kmin>=kmax || eps<=0.) { 618 cout<<"VarianceSpectrum::FindLimits: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax or eps<=0"<<endl; 619 throw ParmError("VarianceSpectrum::FindLimits: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"); 620 } 621 622 R_ = R; 614 if(kmin<=0 || kmax<=0. || kmin>=kmax || eps<=0.) { 615 cout<<"VarianceSpectrum::FindLimits: Error kmin<=0 or kmax<=0 or kmin>=kmax or eps<=0"<<endl; 616 throw ParmError("VarianceSpectrum::FindLimits: Error kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"); 617 } 618 623 619 int n = 10; // toujours >2 624 620 -
trunk/Cosmo/SimLSS/pkspectrum.h
r3325 r3348 23 23 class TransfertEisenstein : public GenericFunc { 24 24 public: 25 26 typedef enum{ALL=0, CDM=1, BARYON=2} ReturnPart; 27 25 28 TransfertEisenstein(double h100,double OmegaCDM0,double OmegaBaryon0,double tcmb,bool nobaryon=false,int lp=0); 26 29 TransfertEisenstein(TransfertEisenstein& tf); … … 29 32 double KPeak(void); 30 33 void SetNoOscEnv(unsigned short nooscenv=0); 31 void SetReturnPart( unsigned short retpart=0);34 void SetReturnPart(ReturnPart retpart=ALL); 32 35 protected: 33 36 int lp_; … … 39 42 40 43 bool nobaryon_; 41 unsigned short nooscenv_, retpart_; 44 unsigned short nooscenv_; 45 ReturnPart retpart_; 42 46 43 47 double T0tild(double k,double alphac,double betac); … … 94 98 class PkSpectrumZ : public GenericFunc { 95 99 public: 100 typedef enum {PK=0, DELTA=1} ReturnSpectrum; 96 101 PkSpectrumZ(PkSpectrum0& pk0,GrowthFactor& d1,double zref=0.); 97 102 PkSpectrumZ(PkSpectrumZ& pkz); … … 101 106 inline void SetZ(double z) {zref_ = z;} 102 107 inline double GetZ(void) {return zref_;} 103 void SetTypSpec( unsigned short typspec=0);108 void SetTypSpec(ReturnSpectrum typspec=PK); 104 109 inline void SetScale(double scale=1.) {scale_=scale; zold_=-1.;} 105 110 inline double GetScale(void) {return scale_;} … … 110 115 GrowthFactor& d1_; 111 116 double zref_, scale_; 112 unsigned shorttypspec_;117 ReturnSpectrum typspec_; 113 118 mutable double zold_, d1old_; 114 119 }; … … 117 122 class VarianceSpectrum : public GenericFunc { 118 123 public: 119 VarianceSpectrum(GenericFunc& pk,unsigned short typfilter); 124 125 typedef enum {TOPHAT=0, GAUSSIAN=1, NOFILTER=2} TypeFilter; 126 127 VarianceSpectrum(GenericFunc& pk,double R,TypeFilter typfilter); 120 128 VarianceSpectrum(VarianceSpectrum& pkinf); 121 129 virtual ~VarianceSpectrum(void); 122 130 123 void SetFilter(unsigned short typfilter=0); 131 void SetRadius(double R); 132 void SetFilter(TypeFilter typfilter=TOPHAT); 124 133 void SetInteg(double dperc=0.1,double dlogkinc=-1.,double dlogkmax=-1.,unsigned short glorder=4); 125 134 126 double Variance(double R,doublekmin,double kmax);135 double Variance(double kmin,double kmax); 127 136 128 137 // ATTENTION: La fonction a integrer est : f(k)dk = k^3*Pk(k)/(2Pi^2) *filter2(k*R) *dk/k … … 131 140 132 141 // Aide a l'integration 133 double FindMaximum(double R,doublekmin,double kmax,double eps=1.e-3);134 int FindLimits(double R,doublehigh,double &kmin,double &kmax,double eps=1.e-3);142 double FindMaximum(double kmin,double kmax,double eps=1.e-3); 143 int FindLimits(double high,double &kmin,double &kmax,double eps=1.e-3); 135 144 136 145 protected: 137 146 138 147 GenericFunc& pk_; 139 unsigned shorttypfilter_;148 TypeFilter typfilter_; 140 149 double R_; 141 150
Note:
See TracChangeset
for help on using the changeset viewer.