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

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

suite de la mise au point pour lecture fichiers CAMB, cmv 24/07/2010

File size: 7.2 KB
RevLine 
[3115]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:
[3805]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);
[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]26protected:
27 double n_, A_;
28};
29
30//-----------------------------------------------------------------------------------
[3805]31class TransfertFunction : public GenericFunc {
[3115]32public:
[3805]33 TransfertFunction(void) {};
34 virtual ~TransfertFunction(void) {};
35};
[3348]36
[3805]37//-----------------------------------------------------------------------------------
38class TransfertEisenstein : public TransfertFunction {
39public:
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]52protected:
[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]70class TransfertTabulate : public TransfertFunction {
[3318]71public:
[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]80protected:
81 double kmin_,kmax_;
82 int interptyp_;
83 vector<double> k_, tf_;
84};
[3115]85
[3318]86
[3115]87//-----------------------------------------------------------------------------------
88class GrowthFactor : public GenericFunc {
89public:
[3805]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);
[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]105protected:
[3381]106 double O0_,Ol_;
[3115]107};
108
109
110//-----------------------------------------------------------------------------------
[3805]111class PkSpectrum : public GenericFunc {
[3115]112public:
[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]126protected:
[3805]127 double zref_, scale_;
128 ReturnSpectrum typspec_;
[3115]129};
130
131//-----------------------------------------------------------------------------------
[3805]132class PkSpecCalc : public PkSpectrum {
[3115]133public:
[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_;}
142protected:
[3805]143 InitialSpectrum& pkinf_;
144 TransfertFunction& tf_;
[3115]145 GrowthFactor& d1_;
146};
147
148//-----------------------------------------------------------------------------------
[3805]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);
[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]164protected:
165 double kmin_,kmax_;
166 int interptyp_;
167 vector<double> k_, pk_;
[3806]168 GrowthFactor* d1_;
[3805]169};
170
171//-----------------------------------------------------------------------------------
172class PkEisenstein : public PkSpectrum {
173public:
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_;}
182protected:
183 InitialPowerLaw& pkinf_;
184 TransfertEisenstein& tf_;
185 GrowthEisenstein& d1_;
186};
187
188//-----------------------------------------------------------------------------------
[3115]189class VarianceSpectrum : public GenericFunc {
190public:
[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
212protected:
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
Note: See TracBrowser for help on using the repository browser.