source: Sophya/trunk/Cosmo/SimLSS/pkspectrum.h@ 3805

Last change on this file since 3805 was 3805, checked in by cmv, 15 years ago

Refonte totale de la structure des classes InitialSpectrum, TransfertFunction, GrowthFactor, PkSpectrum et classes tabulate pour lecture des fichiers CAMB, cmv 24/07/2010

File size: 6.9 KB
Line 
1#ifndef PKSPECTRUM_SEEN
2#define PKSPECTRUM_SEEN
3
4#include "machdefs.h"
5#include "genericfunc.h"
6
7namespace SOPHYA {
8
9//-----------------------------------------------------------------------------------
10class InitialSpectrum : public GenericFunc {
11public:
12 InitialSpectrum(void) {};
13 InitialSpectrum(InitialSpectrum& pkinf) {};
14 virtual ~InitialSpectrum(void) {};
15};
16
17//-----------------------------------------------------------------------------------
18class InitialPowerLaw : public InitialSpectrum {
19public:
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;}
26protected:
27 double n_, A_;
28};
29
30//-----------------------------------------------------------------------------------
31class TransfertFunction : public GenericFunc {
32public:
33 TransfertFunction(void) {};
34 virtual ~TransfertFunction(void) {};
35};
36
37//-----------------------------------------------------------------------------------
38class TransfertEisenstein : public TransfertFunction {
39public:
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);
52protected:
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//-----------------------------------------------------------------------------------
70class TransfertTabulate : public TransfertFunction {
71public:
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);
80protected:
81 double kmin_,kmax_;
82 int interptyp_;
83 vector<double> k_, tf_;
84};
85
86
87//-----------------------------------------------------------------------------------
88class GrowthFactor : public GenericFunc {
89public:
90 GrowthFactor(void) {};
91 virtual ~GrowthFactor(void) {};
92 virtual double DsDz(double z, double);
93};
94
95//-----------------------------------------------------------------------------------
96class GrowthEisenstein : public GrowthFactor {
97public:
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);
105protected:
106 double O0_,Ol_;
107};
108
109
110//-----------------------------------------------------------------------------------
111class PkSpectrum : public GenericFunc {
112public:
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_ ;}
126protected:
127 double zref_, scale_;
128 ReturnSpectrum typspec_;
129};
130
131//-----------------------------------------------------------------------------------
132class PkSpecCalc : public PkSpectrum {
133public:
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_;}
142protected:
143 InitialSpectrum& pkinf_;
144 TransfertFunction& tf_;
145 GrowthFactor& d1_;
146};
147
148//-----------------------------------------------------------------------------------
149class PkTabulate : public PkSpectrum {
150public:
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.);
159protected:
160 double kmin_,kmax_;
161 int interptyp_;
162 vector<double> k_, pk_;
163};
164
165//-----------------------------------------------------------------------------------
166class PkEisenstein : public PkSpectrum {
167public:
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_;}
176protected:
177 InitialPowerLaw& pkinf_;
178 TransfertEisenstein& tf_;
179 GrowthEisenstein& d1_;
180};
181
182//-----------------------------------------------------------------------------------
183class VarianceSpectrum : public GenericFunc {
184public:
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
206protected:
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
Note: See TracBrowser for help on using the repository browser.