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 | int NPoints(void) {return k_.size();}
|
---|
157 | void SetInterpTyp(int typ=0);
|
---|
158 | int ReadCAMB(string filename, double h100=0.71, double zreftab = 0.);
|
---|
159 | protected:
|
---|
160 | double kmin_,kmax_;
|
---|
161 | int interptyp_;
|
---|
162 | vector<double> k_, pk_;
|
---|
163 | };
|
---|
164 |
|
---|
165 | //-----------------------------------------------------------------------------------
|
---|
166 | class PkEisenstein : public PkSpectrum {
|
---|
167 | public:
|
---|
168 | PkEisenstein(InitialPowerLaw& pkinf,TransfertEisenstein& tf,GrowthEisenstein& d1,double zref=0.);
|
---|
169 | PkEisenstein(PkEisenstein& pkz);
|
---|
170 | virtual ~PkEisenstein(void);
|
---|
171 | virtual double operator() (double k);
|
---|
172 | virtual double operator() (double k,double z);
|
---|
173 | InitialPowerLaw& GetPkIni(void) {return pkinf_;}
|
---|
174 | TransfertEisenstein& GetTransfert(void) {return tf_;}
|
---|
175 | GrowthEisenstein& GetGrowthFactor(void) {return d1_;}
|
---|
176 | protected:
|
---|
177 | InitialPowerLaw& pkinf_;
|
---|
178 | TransfertEisenstein& tf_;
|
---|
179 | GrowthEisenstein& d1_;
|
---|
180 | };
|
---|
181 |
|
---|
182 | //-----------------------------------------------------------------------------------
|
---|
183 | class VarianceSpectrum : public GenericFunc {
|
---|
184 | public:
|
---|
185 |
|
---|
186 | typedef enum {TOPHAT=0, GAUSSIAN=1, NOFILTER=2} TypeFilter;
|
---|
187 |
|
---|
188 | VarianceSpectrum(GenericFunc& pk,double R,TypeFilter typfilter);
|
---|
189 | VarianceSpectrum(VarianceSpectrum& vpk);
|
---|
190 | virtual ~VarianceSpectrum(void);
|
---|
191 |
|
---|
192 | void SetRadius(double R);
|
---|
193 | void SetFilter(TypeFilter typfilter=TOPHAT);
|
---|
194 | void SetInteg(double dperc=0.1,double dlogkinc=-1.,double dlogkmax=-1.,unsigned short glorder=4);
|
---|
195 |
|
---|
196 | double Variance(double kmin,double kmax);
|
---|
197 |
|
---|
198 | // ATTENTION: La fonction a integrer est : f(k)dk = k^3*Pk(k)/(2Pi^2) *filter2(k*R) *dk/k
|
---|
199 | virtual double operator() (double k) {return k*k*pk_(k)*Filter2(k*R_)/(2.*M_PI*M_PI);}
|
---|
200 | double Filter2(double x);
|
---|
201 |
|
---|
202 | // Aide a l'integration
|
---|
203 | double FindMaximum(double kmin,double kmax,double eps=1.e-3);
|
---|
204 | int FindLimits(double high,double &kmin,double &kmax,double eps=1.e-3);
|
---|
205 |
|
---|
206 | protected:
|
---|
207 |
|
---|
208 | GenericFunc& pk_;
|
---|
209 | TypeFilter typfilter_;
|
---|
210 | double R_;
|
---|
211 |
|
---|
212 | double dperc_,dlogkinc_,dlogkmax_;
|
---|
213 | unsigned short glorder_;
|
---|
214 |
|
---|
215 | };
|
---|
216 |
|
---|
217 | } // Fin du namespace SOPHYA
|
---|
218 |
|
---|
219 | #endif
|
---|