| 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:
|
|---|
| 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);
|
|---|
| 23 | virtual double operator() (double k) {return A_ * pow(k,n_);}
|
|---|
| 24 | void SetNorm(double a) {A_ = a;}
|
|---|
| 25 | void SetSlope(double n) {n_ = n;}
|
|---|
| 26 | protected:
|
|---|
| 27 | double n_, A_;
|
|---|
| 28 | };
|
|---|
| 29 |
|
|---|
| 30 | //-----------------------------------------------------------------------------------
|
|---|
| 31 | class TransfertFunction : public GenericFunc {
|
|---|
| 32 | public:
|
|---|
| 33 | TransfertFunction(void) {};
|
|---|
| 34 | virtual ~TransfertFunction(void) {};
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 | //-----------------------------------------------------------------------------------
|
|---|
| 38 | class TransfertEisenstein : public TransfertFunction {
|
|---|
| 39 | public:
|
|---|
| 40 |
|
|---|
| 41 | typedef enum{ALL=0, CDM=1, BARYON=2} ReturnPart;
|
|---|
| 42 |
|
|---|
| 43 | TransfertEisenstein(double h100,double OmegaCDM0,double OmegaBaryon0,double tcmb,bool nobaryon=false,int lp=0);
|
|---|
| 44 | TransfertEisenstein(TransfertEisenstein& tf);
|
|---|
| 45 | virtual ~TransfertEisenstein(void);
|
|---|
| 46 | bool SetParTo(double h100,double OmegaCDM0,double OmegaBaryon0);
|
|---|
| 47 | virtual double operator() (double k);
|
|---|
| 48 | double KPeak(void);
|
|---|
| 49 | void SetNoOscEnv(unsigned short nooscenv=0);
|
|---|
| 50 | void SetReturnPart(ReturnPart retpart=ALL);
|
|---|
| 51 | void SetPrintLevel(int lp=0);
|
|---|
| 52 | protected:
|
|---|
| 53 | int lp_;
|
|---|
| 54 | double O0_,Oc_,Ob_,h100_,tcmb_;
|
|---|
| 55 | double th2p7_;
|
|---|
| 56 | double zeq_,keq_,zd_,Req_,Rd_,s_,ksilk_,alphac_,betac_,bnode_,alphab_,betab_;
|
|---|
| 57 | double alphag_;
|
|---|
| 58 | double sfit_,kpeak_;
|
|---|
| 59 |
|
|---|
| 60 | bool nobaryon_;
|
|---|
| 61 | unsigned short nooscenv_;
|
|---|
| 62 | ReturnPart retpart_;
|
|---|
| 63 |
|
|---|
| 64 | double T0tild(double k,double alphac,double betac);
|
|---|
| 65 | void Init_(void);
|
|---|
| 66 | void zero_(void);
|
|---|
| 67 | };
|
|---|
| 68 |
|
|---|
| 69 | //-----------------------------------------------------------------------------------
|
|---|
| 70 | class TransfertTabulate : public TransfertFunction {
|
|---|
| 71 | public:
|
|---|
| 72 | TransfertTabulate(void);
|
|---|
| 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);
|
|---|
| 78 | int ReadCMBFast(string filename,double h100,double OmegaCDM0,double OmegaBaryon0);
|
|---|
| 79 | int ReadCAMB(string filename, double h100=0.71);
|
|---|
| 80 | protected:
|
|---|
| 81 | double kmin_,kmax_;
|
|---|
| 82 | int interptyp_;
|
|---|
| 83 | vector<double> k_, tf_;
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | //-----------------------------------------------------------------------------------
|
|---|
| 88 | class GrowthFactor : public GenericFunc {
|
|---|
| 89 | public:
|
|---|
| 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);
|
|---|
| 101 | virtual double operator() (double z);
|
|---|
| 102 | virtual double DsDz(double z,double dzinc=0.01);
|
|---|
| 103 | void SetParTo(double OmegaMatter0,double OmegaLambda0);
|
|---|
| 104 | bool SetParTo(double OmegaMatter0);
|
|---|
| 105 | protected:
|
|---|
| 106 | double O0_,Ol_;
|
|---|
| 107 | };
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 | //-----------------------------------------------------------------------------------
|
|---|
| 111 | class PkSpectrum : public GenericFunc {
|
|---|
| 112 | public:
|
|---|
| 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_ ;}
|
|---|
| 126 | protected:
|
|---|
| 127 | double zref_, scale_;
|
|---|
| 128 | ReturnSpectrum typspec_;
|
|---|
| 129 | };
|
|---|
| 130 |
|
|---|
| 131 | //-----------------------------------------------------------------------------------
|
|---|
| 132 | class PkSpecCalc : public PkSpectrum {
|
|---|
| 133 | public:
|
|---|
| 134 | PkSpecCalc(InitialSpectrum& pkinf,TransfertFunction& tf,GrowthFactor& d1,double zref=0.);
|
|---|
| 135 | PkSpecCalc(PkSpecCalc& pkz);
|
|---|
| 136 | virtual ~PkSpecCalc(void);
|
|---|
| 137 | virtual double operator() (double k);
|
|---|
| 138 | virtual double operator() (double k,double z);
|
|---|
| 139 | InitialSpectrum& GetPkIni(void) {return pkinf_;}
|
|---|
| 140 | TransfertFunction& GetTransfert(void) {return tf_;}
|
|---|
| 141 | GrowthFactor& GetGrowthFactor(void) {return d1_;}
|
|---|
| 142 | protected:
|
|---|
| 143 | InitialSpectrum& pkinf_;
|
|---|
| 144 | TransfertFunction& tf_;
|
|---|
| 145 | GrowthFactor& d1_;
|
|---|
| 146 | };
|
|---|
| 147 |
|
|---|
| 148 | //-----------------------------------------------------------------------------------
|
|---|
| 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);
|
|---|
| 156 | virtual void SetZ(double z);
|
|---|
| 157 | int NPoints(void) {return k_.size();}
|
|---|
| 158 | void SetInterpTyp(int typ=0);
|
|---|
| 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.;}
|
|---|
| 164 | protected:
|
|---|
| 165 | double kmin_,kmax_;
|
|---|
| 166 | int interptyp_;
|
|---|
| 167 | vector<double> k_, pk_;
|
|---|
| 168 | GrowthFactor* d1_;
|
|---|
| 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 | //-----------------------------------------------------------------------------------
|
|---|
| 189 | class VarianceSpectrum : public GenericFunc {
|
|---|
| 190 | public:
|
|---|
| 191 |
|
|---|
| 192 | typedef enum {TOPHAT=0, GAUSSIAN=1, NOFILTER=2} TypeFilter;
|
|---|
| 193 |
|
|---|
| 194 | VarianceSpectrum(GenericFunc& pk,double R,TypeFilter typfilter);
|
|---|
| 195 | VarianceSpectrum(VarianceSpectrum& vpk);
|
|---|
| 196 | virtual ~VarianceSpectrum(void);
|
|---|
| 197 |
|
|---|
| 198 | void SetRadius(double R);
|
|---|
| 199 | void SetFilter(TypeFilter typfilter=TOPHAT);
|
|---|
| 200 | void SetInteg(double dperc=0.1,double dlogkinc=-1.,double dlogkmax=-1.,unsigned short glorder=4);
|
|---|
| 201 |
|
|---|
| 202 | double Variance(double kmin,double kmax);
|
|---|
| 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
|
|---|
| 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);
|
|---|
| 211 |
|
|---|
| 212 | protected:
|
|---|
| 213 |
|
|---|
| 214 | GenericFunc& pk_;
|
|---|
| 215 | TypeFilter typfilter_;
|
|---|
| 216 | double R_;
|
|---|
| 217 |
|
|---|
| 218 | double dperc_,dlogkinc_,dlogkmax_;
|
|---|
| 219 | unsigned short glorder_;
|
|---|
| 220 |
|
|---|
| 221 | };
|
|---|
| 222 |
|
|---|
| 223 | } // Fin du namespace SOPHYA
|
|---|
| 224 |
|
|---|
| 225 | #endif
|
|---|