| [3115] | 1 | #ifndef PKSPECTRUM_SEEN | 
|---|
|  | 2 | #define PKSPECTRUM_SEEN | 
|---|
|  | 3 |  | 
|---|
|  | 4 | #include "machdefs.h" | 
|---|
|  | 5 | #include "genericfunc.h" | 
|---|
|  | 6 |  | 
|---|
|  | 7 | namespace SOPHYA { | 
|---|
|  | 8 |  | 
|---|
|  | 9 | //----------------------------------------------------------------------------------- | 
|---|
|  | 10 | class InitialSpectrum : public GenericFunc { | 
|---|
|  | 11 | public: | 
|---|
| [3805] | 12 | InitialSpectrum(void) {}; | 
|---|
|  | 13 | InitialSpectrum(InitialSpectrum& pkinf) {}; | 
|---|
|  | 14 | virtual ~InitialSpectrum(void) {}; | 
|---|
|  | 15 | }; | 
|---|
|  | 16 |  | 
|---|
|  | 17 | //----------------------------------------------------------------------------------- | 
|---|
|  | 18 | class InitialPowerLaw : public InitialSpectrum { | 
|---|
|  | 19 | public: | 
|---|
|  | 20 | InitialPowerLaw(double n,double a=1.); | 
|---|
|  | 21 | InitialPowerLaw(InitialPowerLaw& pkinf); | 
|---|
|  | 22 | virtual ~InitialPowerLaw(void); | 
|---|
| [3115] | 23 | virtual double operator() (double k) {return A_ * pow(k,n_);} | 
|---|
| [3381] | 24 | void SetNorm(double a) {A_ = a;} | 
|---|
|  | 25 | void SetSlope(double n) {n_ = n;} | 
|---|
| [3115] | 26 | protected: | 
|---|
|  | 27 | double n_, A_; | 
|---|
|  | 28 | }; | 
|---|
|  | 29 |  | 
|---|
|  | 30 | //----------------------------------------------------------------------------------- | 
|---|
| [3805] | 31 | class TransfertFunction : public GenericFunc { | 
|---|
| [3115] | 32 | public: | 
|---|
| [3805] | 33 | TransfertFunction(void) {}; | 
|---|
|  | 34 | virtual ~TransfertFunction(void) {}; | 
|---|
|  | 35 | }; | 
|---|
| [3348] | 36 |  | 
|---|
| [3805] | 37 | //----------------------------------------------------------------------------------- | 
|---|
|  | 38 | class TransfertEisenstein : public TransfertFunction { | 
|---|
|  | 39 | public: | 
|---|
|  | 40 |  | 
|---|
| [3348] | 41 | typedef enum{ALL=0, CDM=1, BARYON=2} ReturnPart; | 
|---|
|  | 42 |  | 
|---|
| [3314] | 43 | TransfertEisenstein(double h100,double OmegaCDM0,double OmegaBaryon0,double tcmb,bool nobaryon=false,int lp=0); | 
|---|
| [3115] | 44 | TransfertEisenstein(TransfertEisenstein& tf); | 
|---|
|  | 45 | virtual ~TransfertEisenstein(void); | 
|---|
| [3381] | 46 | bool SetParTo(double h100,double OmegaCDM0,double OmegaBaryon0); | 
|---|
| [3115] | 47 | virtual double operator() (double k); | 
|---|
|  | 48 | double KPeak(void); | 
|---|
|  | 49 | void SetNoOscEnv(unsigned short nooscenv=0); | 
|---|
| [3348] | 50 | void SetReturnPart(ReturnPart retpart=ALL); | 
|---|
| [3378] | 51 | void SetPrintLevel(int lp=0); | 
|---|
| [3115] | 52 | protected: | 
|---|
| [3314] | 53 | int lp_; | 
|---|
| [3378] | 54 | double O0_,Oc_,Ob_,h100_,tcmb_; | 
|---|
| [3314] | 55 | double th2p7_; | 
|---|
| [3115] | 56 | double zeq_,keq_,zd_,Req_,Rd_,s_,ksilk_,alphac_,betac_,bnode_,alphab_,betab_; | 
|---|
|  | 57 | double alphag_; | 
|---|
| [3314] | 58 | double sfit_,kpeak_; | 
|---|
| [3115] | 59 |  | 
|---|
|  | 60 | bool nobaryon_; | 
|---|
| [3348] | 61 | unsigned short nooscenv_; | 
|---|
|  | 62 | ReturnPart retpart_; | 
|---|
| [3314] | 63 |  | 
|---|
| [3115] | 64 | double T0tild(double k,double alphac,double betac); | 
|---|
| [3314] | 65 | void Init_(void); | 
|---|
| [3318] | 66 | void zero_(void); | 
|---|
| [3115] | 67 | }; | 
|---|
|  | 68 |  | 
|---|
| [3318] | 69 | //----------------------------------------------------------------------------------- | 
|---|
| [3805] | 70 | class TransfertTabulate : public TransfertFunction { | 
|---|
| [3318] | 71 | public: | 
|---|
| [3802] | 72 | TransfertTabulate(void); | 
|---|
| [3318] | 73 | TransfertTabulate(TransfertTabulate& tf); | 
|---|
|  | 74 | virtual ~TransfertTabulate(void); | 
|---|
|  | 75 | virtual double operator() (double k); | 
|---|
|  | 76 | int NPoints(void) {return k_.size();} | 
|---|
|  | 77 | void SetInterpTyp(int typ=0); | 
|---|
| [3802] | 78 | int ReadCMBFast(string filename,double h100,double OmegaCDM0,double OmegaBaryon0); | 
|---|
| [3805] | 79 | int ReadCAMB(string filename, double h100=0.71); | 
|---|
| [3318] | 80 | protected: | 
|---|
|  | 81 | double kmin_,kmax_; | 
|---|
|  | 82 | int interptyp_; | 
|---|
|  | 83 | vector<double> k_, tf_; | 
|---|
|  | 84 | }; | 
|---|
| [3115] | 85 |  | 
|---|
| [3318] | 86 |  | 
|---|
| [3115] | 87 | //----------------------------------------------------------------------------------- | 
|---|
|  | 88 | class GrowthFactor : public GenericFunc { | 
|---|
|  | 89 | public: | 
|---|
| [3805] | 90 | GrowthFactor(void) {}; | 
|---|
|  | 91 | virtual ~GrowthFactor(void) {}; | 
|---|
|  | 92 | virtual double DsDz(double z, double); | 
|---|
|  | 93 | }; | 
|---|
|  | 94 |  | 
|---|
|  | 95 | //----------------------------------------------------------------------------------- | 
|---|
|  | 96 | class GrowthEisenstein : public GrowthFactor { | 
|---|
|  | 97 | public: | 
|---|
|  | 98 | GrowthEisenstein(double OmegaMatter0,double OmegaLambda0); | 
|---|
|  | 99 | GrowthEisenstein(GrowthEisenstein& d1); | 
|---|
|  | 100 | virtual ~GrowthEisenstein(void); | 
|---|
| [3115] | 101 | virtual double operator() (double z); | 
|---|
| [3768] | 102 | virtual double DsDz(double z,double dzinc=0.01); | 
|---|
| [3381] | 103 | void SetParTo(double OmegaMatter0,double OmegaLambda0); | 
|---|
|  | 104 | bool SetParTo(double OmegaMatter0); | 
|---|
| [3115] | 105 | protected: | 
|---|
| [3381] | 106 | double O0_,Ol_; | 
|---|
| [3115] | 107 | }; | 
|---|
|  | 108 |  | 
|---|
|  | 109 |  | 
|---|
|  | 110 | //----------------------------------------------------------------------------------- | 
|---|
| [3805] | 111 | class PkSpectrum : public GenericFunc { | 
|---|
| [3115] | 112 | public: | 
|---|
| [3805] | 113 | // typsec = PK : compute Pk(k) | 
|---|
|  | 114 | //        = DELTA : compute Delta^2(k) = k^3*Pk(k)/2Pi^2 | 
|---|
|  | 115 | typedef enum {PK=0, DELTA=1} ReturnSpectrum; | 
|---|
|  | 116 |  | 
|---|
|  | 117 | PkSpectrum(void); | 
|---|
|  | 118 | PkSpectrum(PkSpectrum& pk); | 
|---|
|  | 119 | virtual ~PkSpectrum(void) {}; | 
|---|
|  | 120 | virtual void   SetZ(double z) {zref_ = z;} | 
|---|
|  | 121 | virtual double GetZ(void) {return zref_;} | 
|---|
|  | 122 | virtual void SetScale(double scale=1.) {scale_ = scale;} | 
|---|
|  | 123 | virtual double GetScale(void) {return scale_;} | 
|---|
|  | 124 | virtual void SetTypSpec(ReturnSpectrum typspec=PK) {typspec_ = typspec;} | 
|---|
|  | 125 | virtual ReturnSpectrum GetTypSpec(void) {return typspec_ ;} | 
|---|
| [3115] | 126 | protected: | 
|---|
| [3805] | 127 | double zref_, scale_; | 
|---|
|  | 128 | ReturnSpectrum typspec_; | 
|---|
| [3115] | 129 | }; | 
|---|
|  | 130 |  | 
|---|
|  | 131 | //----------------------------------------------------------------------------------- | 
|---|
| [3805] | 132 | class PkSpecCalc : public PkSpectrum { | 
|---|
| [3115] | 133 | public: | 
|---|
| [3805] | 134 | PkSpecCalc(InitialSpectrum& pkinf,TransfertFunction& tf,GrowthFactor& d1,double zref=0.); | 
|---|
|  | 135 | PkSpecCalc(PkSpecCalc& pkz); | 
|---|
|  | 136 | virtual ~PkSpecCalc(void); | 
|---|
| [3115] | 137 | virtual double operator() (double k); | 
|---|
|  | 138 | virtual double operator() (double k,double z); | 
|---|
| [3805] | 139 | InitialSpectrum& GetPkIni(void) {return pkinf_;} | 
|---|
|  | 140 | TransfertFunction& GetTransfert(void) {return tf_;} | 
|---|
| [3115] | 141 | GrowthFactor& GetGrowthFactor(void) {return d1_;} | 
|---|
|  | 142 | protected: | 
|---|
| [3805] | 143 | InitialSpectrum& pkinf_; | 
|---|
|  | 144 | TransfertFunction& tf_; | 
|---|
| [3115] | 145 | GrowthFactor& d1_; | 
|---|
|  | 146 | }; | 
|---|
|  | 147 |  | 
|---|
|  | 148 | //----------------------------------------------------------------------------------- | 
|---|
| [3805] | 149 | class PkTabulate : public PkSpectrum { | 
|---|
|  | 150 | public: | 
|---|
|  | 151 | PkTabulate(void); | 
|---|
|  | 152 | PkTabulate(PkTabulate& pkz); | 
|---|
|  | 153 | virtual ~PkTabulate(void); | 
|---|
|  | 154 | virtual double operator() (double k); | 
|---|
|  | 155 | virtual double operator() (double k,double z); | 
|---|
| [3806] | 156 | virtual void SetZ(double z); | 
|---|
| [3805] | 157 | int NPoints(void) {return k_.size();} | 
|---|
|  | 158 | void SetInterpTyp(int typ=0); | 
|---|
| [3806] | 159 | int ReadCAMB(string filename, double h100tab=0.71, double zreftab=0.); | 
|---|
|  | 160 | void SetGrowthFactor(GrowthFactor* d1) {d1_ = d1;} | 
|---|
|  | 161 | GrowthFactor* GetGrowthFactor(void) {return d1_;} | 
|---|
|  | 162 | double KMin(void) {if(k_.size()!=0) return k_[0]; else return 0.;} | 
|---|
|  | 163 | double KMax(void) {if(k_.size()!=0) return k_[k_.size()-1]; else return 0.;} | 
|---|
| [3805] | 164 | protected: | 
|---|
|  | 165 | double kmin_,kmax_; | 
|---|
|  | 166 | int interptyp_; | 
|---|
|  | 167 | vector<double> k_, pk_; | 
|---|
| [3806] | 168 | GrowthFactor* d1_; | 
|---|
| [3805] | 169 | }; | 
|---|
|  | 170 |  | 
|---|
|  | 171 | //----------------------------------------------------------------------------------- | 
|---|
|  | 172 | class PkEisenstein : public PkSpectrum { | 
|---|
|  | 173 | public: | 
|---|
|  | 174 | PkEisenstein(InitialPowerLaw& pkinf,TransfertEisenstein& tf,GrowthEisenstein& d1,double zref=0.); | 
|---|
|  | 175 | PkEisenstein(PkEisenstein& pkz); | 
|---|
|  | 176 | virtual ~PkEisenstein(void); | 
|---|
|  | 177 | virtual double operator() (double k); | 
|---|
|  | 178 | virtual double operator() (double k,double z); | 
|---|
|  | 179 | InitialPowerLaw& GetPkIni(void) {return pkinf_;} | 
|---|
|  | 180 | TransfertEisenstein& GetTransfert(void) {return tf_;} | 
|---|
|  | 181 | GrowthEisenstein& GetGrowthFactor(void) {return d1_;} | 
|---|
|  | 182 | protected: | 
|---|
|  | 183 | InitialPowerLaw& pkinf_; | 
|---|
|  | 184 | TransfertEisenstein& tf_; | 
|---|
|  | 185 | GrowthEisenstein& d1_; | 
|---|
|  | 186 | }; | 
|---|
|  | 187 |  | 
|---|
|  | 188 | //----------------------------------------------------------------------------------- | 
|---|
| [3115] | 189 | class VarianceSpectrum : public GenericFunc { | 
|---|
|  | 190 | public: | 
|---|
| [3348] | 191 |  | 
|---|
|  | 192 | typedef enum {TOPHAT=0, GAUSSIAN=1, NOFILTER=2} TypeFilter; | 
|---|
|  | 193 |  | 
|---|
|  | 194 | VarianceSpectrum(GenericFunc& pk,double R,TypeFilter typfilter); | 
|---|
| [3805] | 195 | VarianceSpectrum(VarianceSpectrum& vpk); | 
|---|
| [3115] | 196 | virtual ~VarianceSpectrum(void); | 
|---|
|  | 197 |  | 
|---|
| [3348] | 198 | void SetRadius(double R); | 
|---|
|  | 199 | void SetFilter(TypeFilter typfilter=TOPHAT); | 
|---|
| [3115] | 200 | void SetInteg(double dperc=0.1,double dlogkinc=-1.,double dlogkmax=-1.,unsigned short glorder=4); | 
|---|
|  | 201 |  | 
|---|
| [3348] | 202 | double Variance(double kmin,double kmax); | 
|---|
| [3115] | 203 |  | 
|---|
|  | 204 | // ATTENTION: La fonction a integrer est : f(k)dk = k^3*Pk(k)/(2Pi^2) *filter2(k*R) *dk/k | 
|---|
|  | 205 | virtual double operator() (double k) {return k*k*pk_(k)*Filter2(k*R_)/(2.*M_PI*M_PI);} | 
|---|
|  | 206 | double Filter2(double x); | 
|---|
|  | 207 |  | 
|---|
|  | 208 | // Aide a l'integration | 
|---|
| [3348] | 209 | double FindMaximum(double kmin,double kmax,double eps=1.e-3); | 
|---|
|  | 210 | int FindLimits(double high,double &kmin,double &kmax,double eps=1.e-3); | 
|---|
| [3115] | 211 |  | 
|---|
|  | 212 | protected: | 
|---|
|  | 213 |  | 
|---|
|  | 214 | GenericFunc& pk_; | 
|---|
| [3348] | 215 | TypeFilter typfilter_; | 
|---|
| [3115] | 216 | double R_; | 
|---|
|  | 217 |  | 
|---|
|  | 218 | double dperc_,dlogkinc_,dlogkmax_; | 
|---|
|  | 219 | unsigned short glorder_; | 
|---|
|  | 220 |  | 
|---|
|  | 221 | }; | 
|---|
|  | 222 |  | 
|---|
| [3325] | 223 | } // Fin du namespace SOPHYA | 
|---|
| [3115] | 224 |  | 
|---|
|  | 225 | #endif | 
|---|