Changeset 3196 in Sophya for trunk/Cosmo/SimLSS
- Timestamp:
- Apr 3, 2007, 4:06:50 PM (18 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 3 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/Makefile
r3157 r3196 19 19 $(EXE)cmvtstsch $(EXE)cmvtstblack $(EXE)cmvtvarspec \ 20 20 $(EXE)cmvdefsurv $(EXE)cmvobserv3d $(EXE)cmvtintfun \ 21 $(EXE)cmvtpoisson $(EXE)cmvconcherr $(EXE)cmvtinterp 21 $(EXE)cmvtpoisson $(EXE)cmvconcherr $(EXE)cmvtinterp \ 22 $(EXE)cmvtstagn 22 23 #$(EXE)cmvtluc 23 24 … … 26 27 $(OBJ)cmvtstsch.o $(OBJ)cmvtstblack.o $(OBJ)cmvtvarspec.o $(OBJ)cmvdefsurv.o \ 27 28 $(OBJ)cmvobserv3d.o $(OBJ)cmvtintfun.o $(OBJ)cmvtinterp.o \ 28 $(OBJ)cmvtpoisson.o $(OBJ)cmvconcherr.o $(OBJ)cmvtluc.o 29 $(OBJ)cmvtpoisson.o $(OBJ)cmvconcherr.o $(OBJ)cmvtluc.o \ 30 $(OBJ)cmvtstagn.o 29 31 30 32 LIBROBJ = \ 31 33 $(OBJ)cosmocalc.o $(OBJ)pkspectrum.o $(OBJ)schechter.o \ 32 $(OBJ)planckspectra.o $(OBJ) integfunc.o $(OBJ)geneutils.o \34 $(OBJ)planckspectra.o $(OBJ)geneutils.o $(OBJ)agnjackson.o \ 33 35 $(OBJ)genefluct3d.o 34 36 … … 56 58 $(OBJ)schechter.o: schechter.cc schechter.h constcosmo.h 57 59 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ schechter.cc 58 $(OBJ)integfunc.o: integfunc.cc integfunc.h59 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ integfunc.cc60 60 $(OBJ)planckspectra.o: planckspectra.cc planckspectra.h constcosmo.h 61 61 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ planckspectra.cc 62 $(OBJ)pkspectrum.o: pkspectrum.cc pkspectrum.h constcosmo.h integfunc.h62 $(OBJ)pkspectrum.o: pkspectrum.cc pkspectrum.h constcosmo.h 63 63 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ pkspectrum.cc 64 64 $(OBJ)geneutils.o: geneutils.cc geneutils.h 65 65 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ geneutils.cc 66 $(OBJ)agnjackson.o: agnjackson.cc agnjackson.h 67 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ agnjackson.cc 66 68 $(OBJ)genefluct3d.o: genefluct3d.cc genefluct3d.h 67 69 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ genefluct3d.cc … … 173 175 174 176 ############################################################################## 177 cmvtstagn: $(EXE)cmvtstagn 178 echo $@ " done" 179 $(EXE)cmvtstagn: $(OBJ)cmvtstagn.o $(LIB)libcmvsimbao.a 180 $(CXXLINK) $(CXXREP) -o $@ $(OBJ)cmvtstagn.o $(MYLIB) 181 $(OBJ)cmvtstagn.o: cmvtstagn.cc 182 $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ cmvtstagn.cc 183 184 ############################################################################## 175 185 cmvtluc: $(EXE)cmvtluc 176 186 echo $@ " done" -
trunk/Cosmo/SimLSS/cmvdefsurv.cc
r3193 r3196 11 11 #include "cosmocalc.h" 12 12 #include "geneutils.h" 13 #include "integfunc.h"14 13 #include "schechter.h" 15 14 #include "planckspectra.h" 16 15 17 16 /* --- Check Peterson at al. astro-ph/0606104 v1 18 cmvdefsurv -z 0.0025 -x 1 -U 0.75,0.3,0.7,-1,1 -V 300 -O 400000,6000 - A75 -M 6.156e9 -F 3 -2 1.517 cmvdefsurv -z 0.0025 -x 1 -U 0.75,0.3,0.7,-1,1 -V 300 -O 400000,6000 -N 75 -M 6.156e9 -F 3 -2 1.5 19 18 --- */ 20 19 … … 35 34 <<" -L lobewidth : taille du lobe d\'observation (FWHM) en arcmin (def= 1\')"<<endl 36 35 <<" -O surf,tobs : surface effective (m^2) et temps d\'observation (s)"<<endl 37 <<" - ATsys : temperature du system (K)"<<endl36 <<" -N Tsys : temperature du system (K)"<<endl 38 37 <<" -S Tsynch,indnu : temperature (K) synch a 408 Mhz, index d\'evolution"<<endl 39 38 <<" (indnu==0 no evolution with freq.)"<<endl … … 43 42 <<" -U h100,om0,ol0,w0,or0,flat : cosmology"<<endl 44 43 <<" -2 : two polarisations measured"<<endl 44 <<" -A <log10(S_agn)> : moyenne du flux AGN en Jy dans le pixel"<<endl 45 45 <<" redshift : redshift moyen du survey"<<endl 46 46 <<endl; … … 59 59 double alpha = -1.37; 60 60 cout<<"nstar= "<<nstar<<" mstar="<<mstar<<" alpha="<<alpha<<endl; 61 62 61 63 62 // --- Arguments … … 76 75 double vrot = 300.; // largeur en vitesse (km/s) pour elargissement doppler 77 76 double facpolar = 0.5; // si on ne mesure les 2 polars -> 1.0 77 double lflux_agn = -3.; 78 78 79 79 // --- Decodage arguments 80 80 char c; 81 while((c = getopt(narg,arg,"hP2x:y:z: A:S:O:M:F:V:U:L:")) != -1) {81 while((c = getopt(narg,arg,"hP2x:y:z:N:S:O:M:F:V:U:L:A:")) != -1) { 82 82 switch (c) { 83 83 case 'P' : … … 99 99 sscanf(optarg,"%lf",&lobewidth); 100 100 break; 101 case ' A' :101 case 'N' : 102 102 sscanf(optarg,"%lf",&Tsys); 103 103 break; … … 119 119 case '2' : 120 120 facpolar = 1.0; 121 break; 122 case 'A' : 123 sscanf(optarg,"%lf",&lflux_agn); 121 124 break; 122 125 case 'h' : … … 281 284 double lobecyl = sqrt(8.)*slobe; // diametre du lobe cylindrique equiv en arcmin 282 285 double lobearea = M_PI*lobecyl*lobecyl/4.; // en arcmin^2 (hypothese lobe gaussien) 286 double nlobes = rad2min(adtx)*rad2min(adty)/lobearea; 287 if(lobewidth<=0.) nlobes = 1.; 283 288 cout<<"\nBeam FWHM = "<<lobewidth<<"\' -> sigma = "<<slobe<<"\' -> " 284 289 <<" Dcyl = "<<lobecyl<<"\' -> area = "<<lobearea<<" arcmin^2"<<endl; 285 double nlobes = rad2min(adtx)*rad2min(adty)/lobearea;286 290 cout<<"Number of beams in one transversal pixel = "<<nlobes<<endl; 287 291 … … 290 294 cout<<"flux factor = "<<hifactor<<" at redshift = "<<redshift<<endl; 291 295 292 double fhi = hifactor* FluxHI(mhiref,dlum);296 double fhi = hifactor*Msol2FluxHI(mhiref,dlum); 293 297 cout<<"FluxHI("<<dlum<<" Mpc) all polar:"<<endl 294 298 <<" Flux= "<<fhi<<" W/m^2 = "<<fhi/Jansky2Watt_cst<<" Jy.Hz"<<endl 295 <<" in ["<<hifactor* FluxHI(mhiref,dlumlim[0])296 <<","<<hifactor* FluxHI(mhiref,dlumlim[1])<<"] W/m^2"<<endl;299 <<" in ["<<hifactor*Msol2FluxHI(mhiref,dlumlim[0]) 300 <<","<<hifactor*Msol2FluxHI(mhiref,dlumlim[1])<<"] W/m^2"<<endl; 297 301 double sfhi = fhi / (dnuhiz*1e9) / Jansky2Watt_cst; 298 302 cout<<"If spread over "<<dnuhiz<<" GHz, flux density = "<<sfhi<<" Jy"<<endl; … … 342 346 cout<<" flux density = "<<scmb<<" Jy"<<endl; 343 347 348 // AGN 349 double flux_agn = pow(10.,lflux_agn); 350 cout<<"AGN: log10(S_agn)="<<lflux_agn<<" -> S_agn="<<flux_agn<<" Jy"<<endl; 351 double flux_agn_pix = flux_agn*(dnuhiz*1e9); 352 double mass_agn_pix = FluxHI2Msol(flux_agn_pix*Jansky2Watt_cst,dlum); 353 double lmass_agn_pix = log10(mass_agn_pix); 354 cout<<"...pixel: f="<<flux_agn_pix<<" 10^-26 W/m^2" 355 <<" -> "<<mass_agn_pix<<" Msol -> log10 = "<<lmass_agn_pix<<endl; 356 344 357 // --- Noise analysis 345 358 cout<<"\n--- Noise analysis"<<endl; -
trunk/Cosmo/SimLSS/cmvobserv3d.cc
r3193 r3196 15 15 #include "schechter.h" 16 16 #include "geneutils.h" 17 #include "integfunc.h"18 17 #include "genefluct3d.h" 19 18 … … 32 31 <<" -2 : compute 2D spectrum"<<endl 33 32 <<" -M schmin,schmax,nsch : min,max mass and nb points for schechter HI"<<endl 33 <<" -A <log10(S_agn en Msol)>,sigma : distribution des AGN par pixel"<<endl 34 34 <<" -W : write cube in FITS format"<<endl 35 35 <<" -P : write cube in PPF format"<<endl … … 77 77 double snoise= 0.; // en equivalent MSol 78 78 79 // *** AGN 80 bool do_agn = false; 81 double lmsol_agn=-99., lsigma_agn=0.; // en equivalent MSol 82 79 83 // *** type de generation 80 84 bool computefourier0=false; … … 91 95 92 96 char c; 93 while((c = getopt(narg,arg,"ha0PWV2Gx:y:z:s:Z:M: ")) != -1) {97 while((c = getopt(narg,arg,"ha0PWV2Gx:y:z:s:Z:M:A:")) != -1) { 94 98 switch (c) { 95 99 case 'a' : … … 122 126 case 'M' : 123 127 sscanf(optarg,"%lf,%lf,%d",&schmin,&schmax,&schnpt); 128 break; 129 case 'A' : 130 do_agn = true; 131 sscanf(optarg,"%lf,%lf",&lmsol_agn,&lsigma_agn); 124 132 break; 125 133 case 'V' : … … 153 161 <<", schnpt="<<schnpt<<endl; 154 162 cout<<"snoise="<<snoise<<" equivalent Msol"<<endl; 163 if(do_agn) cout<<"AGN: <log10(Msol)>="<<lmsol_agn<<" , sigma="<<lsigma_agn<<endl; 155 164 156 165 //----------------------------------------------------------------- … … 476 485 } 477 486 487 if(do_agn) { 488 cout<<"\n--- Add AGN: <mass>="<<lmsol_agn<<" , sigma="<<lsigma_agn<<endl; 489 fluct3d.AddAGN(lmsol_agn,lsigma_agn); 490 nm = fluct3d.MeanSigma2(rm,rs2); 491 cout<<"HI mass with AGN: ("<<nm<<") Mean = "<<rm<<", Sigma^2 = " 492 <<rs2<<" -> "<<sqrt(rs2)<<endl; 493 PrtTim(">>>> End Add AGN"); 494 } 495 478 496 if(snoise>0.) { 479 497 cout<<"\n--- Add noise to HI Flux snoise="<<snoise<<endl; -
trunk/Cosmo/SimLSS/cmvtintfun.cc
r3115 r3196 10 10 #include "ntuple.h" 11 11 12 #include " integfunc.h"12 #include "geneutils.h" 13 13 14 14 // cmvtintfun [n] [xmin,xmax,npt] -
trunk/Cosmo/SimLSS/cmvtstblack.cc
r3115 r3196 10 10 #include "ntuple.h" 11 11 12 #include "integfunc.h"13 12 #include "constcosmo.h" 13 #include "geneutils.h" 14 14 #include "planckspectra.h" 15 15 -
trunk/Cosmo/SimLSS/cmvtstsch.cc
r3120 r3196 14 14 15 15 #include "geneutils.h" 16 #include "integfunc.h"17 16 #include "cosmocalc.h" 18 17 #include "schechter.h" … … 113 112 cout<<endl; 114 113 double d = 1000.; 114 double f = Msol2FluxHI(mstar,d); 115 115 cout<<"FluxHI: d="<<d<<" Mpc:"<<" M= "<<mstar<<" Msol " 116 <<"-> Flux= "<<FluxHI(mstar,d)<<" W/m^2"<<endl; 116 <<"-> Flux= "<<f<<" W/m^2"<<endl; 117 cout<<"Check... MassHI: d="<<d<<" Mpc:"<<" f= "<<f<<" W/m^2 " 118 <<"-> Mass= "<<FluxHI2Msol(f,d)<<" Msol"<<endl; 117 119 118 120 //------- Random -
trunk/Cosmo/SimLSS/cosmocalc.cc
r3193 r3196 13 13 #include "constcosmo.h" 14 14 #include "cosmocalc.h" 15 #include " integfunc.h"15 #include "geneutils.h" 16 16 17 17 -
trunk/Cosmo/SimLSS/genefluct3d.cc
r3157 r3196 20 20 21 21 #include "constcosmo.h" 22 #include "integfunc.h"23 22 #include "geneutils.h" 24 23 … … 970 969 } 971 970 971 void GeneFluct3D::AddAGN(double lmsol,double lsigma) 972 // Add AGN flux into simulation: 973 // --- Procedure: 974 // 1. lancer "cmvdefsurv" avec les parametres du survey 975 // et recuperer l'angle solide "angsol sr" du pixel elementaire 976 // au centre du cube. 977 // 2. lancer "cmvtstagn" pour cet angle solide -> cmvtstagn.ppf 978 // 3. regarder l'histo "hlfang" et en deduire un equivalent gaussienne 979 // cad une moyenne <log10(S)> et un sigma "sig" 980 // Attention: la distribution n'etant pas gaussienne 981 // 4. re-lancer "cmvdefsurv" en ajoutant l'info sur les AGN 982 // "cmvdefsurv ... -G <log10(S)> ..." 983 // et recuperer le log10(masse solaire equivalente) 984 // --- Limitations actuelle du code: 985 // a. l'angle solide du pixel est pris au centre du cube 986 // et ne varie pas avec la distance a l'interieur du cube 987 // b. la taille en dNu des pixels (selon z) est supposee constante 988 // et egale a celle calculee pour le centre du cube 989 // c. les AGN sont supposes plats en flux 990 // d. le flux des AGN est mis dans une colonne Oz (indice k) 991 // et pas sur la ligne de visee 992 // e. la distribution est approximee a une gaussienne 993 // .. C'est une approximation pour un observateur loin du centre du cube 994 // et pour un cube peu epais / distance observateur 995 // --- Parametres de la routine: 996 // lmsol : c'est le <log10(Msol)> qui est la conversion en masse solaire 997 // du flux depose dans un pixel par les AGN 998 // lsigma : c'est le sigma de la distribution 999 // - Comme on est en echelle log10(): 1000 // on tire log10(Msol) + X 1001 // ou X est une realisation sur une gaussienne de variance "sig^2" 1002 // La masse realisee est donc: Msol*10^X 1003 // - Pas de probleme de pixel negatif car on a une multiplication! 1004 { 1005 if(lp_>0) cout<<"--- AddAGN: lmsol = "<<lmsol<<" , sigma = "<<lsigma<<endl; 1006 check_array_alloc(); 1007 1008 double m = pow(10.,lmsol); 1009 1010 double sum=0., sum2=0., nsum=0.; 1011 for(long l=0;l<Nz_;l++) { 1012 double a = lsigma*NorRand(); 1013 a = m*pow(10.,a); 1014 // On met le meme tirage le long de Oz (indice k) 1015 for(long i=0;i<Nx_;i++) for(long j=0;j<Ny_;j++) { 1016 int_8 ip = IndexR(i,j,l); 1017 data_[ip] += a; 1018 } 1019 sum += a; sum2 += a*a; nsum += 1.; 1020 } 1021 1022 if(nsum>1.) { 1023 sum /= nsum; 1024 sum2 = sum2/nsum - sum*sum; 1025 cout<<"...Mean mass="<<sum<<" Msol , s^2="<<sum2<<" s="<<sqrt(fabs(sum2))<<endl; 1026 } 1027 1028 } 1029 972 1030 void GeneFluct3D::AddNoise2Real(double snoise) 973 1031 // add noise to every pixels (meme les <=0 !) -
trunk/Cosmo/SimLSS/genefluct3d.h
r3157 r3196 83 83 double TurnNGal2Mass(FunRan& massdist,bool axeslog=false); 84 84 double TurnMass2Flux(void); 85 void AddAGN(double lmsol,double lsigma); 85 86 void AddNoise2Real(double snoise); 86 87 -
trunk/Cosmo/SimLSS/geneutils.cc
r3157 r3196 150 150 } 151 151 152 //---------------------------------------------------- 153 double InterpTab(double x0,vector<double>& X,vector<double>& Y,unsigned short typint) 154 // Interpole in x0 the table Y = f(X) 155 // X doit etre ordonne par ordre croissant (strictement) 156 // typint = 0 : nearest value 157 // 1 : linear interpolation 158 // 2 : parabolique interpolation 159 { 160 long n = X.size(); 161 if(Y.size()<n || n<2) 162 throw ParmError("InterpTab_Error : incompatible size between X and Y tables!"); 163 164 if(x0<X[0] || x0>X[n-1]) return 0.; 165 if(typint>2) typint = 0; 166 167 // Recherche des indices encadrants par dichotomie 168 long k, klo=0, khi=n-1; 169 while (khi-klo > 1) { 170 k = (khi+klo) >> 1; 171 if (X[k] > x0) khi=k; else klo=k; 172 } 173 174 // Quel est le plus proche? 175 k = (x0-X[klo]<X[khi]-x0) ? klo: khi; 176 177 // On retourne le plus proche 178 if(typint==0) return Y[k]; 179 180 // On retourne l'extrapolation lineaire 181 if(typint==1 || n<3) 182 return Y[klo] + (Y[khi]-Y[klo])/(X[khi]-X[klo])*(x0-X[klo]); 183 184 // On retourne l'extrapolation parabolique 185 if(k==0) k++; else if(k==n-1) k--; 186 klo = k-1; khi = k+1; 187 double x1 = X[klo]-X[k], x2 = X[khi]-X[k]; 188 double y1 = Y[klo]-Y[k], y2 = Y[khi]-Y[k]; 189 double den = x1*x2*(x1-x2); 190 double a = (y1*x2-y2*x1)/den; 191 double b = (y2*x1*x1-y1*x2*x2)/den; 192 x0 -= X[k]; 193 return Y[k] + (a*x0+b)*x0;; 194 195 } 196 152 197 //------------------------------------------------------------------- 153 198 int FuncToHisto(GenericFunc& func,Histo& h,bool logaxex) … … 252 297 return n; 253 298 } 299 300 //------------------------------------------------------------------- 301 302 static unsigned short IntegrateFunc_GlOrder = 0; 303 static vector<double> IntegrateFunc_x; 304 static vector<double> IntegrateFunc_w; 305 306 /////////////////////////////////////////////////////////// 307 //************** Integration of Functions ***************// 308 /////////////////////////////////////////////////////////// 309 310 311 //////////////////////////////////////////////////////////////////////////////////// 312 double IntegrateFunc(GenericFunc& func,double xmin,double xmax 313 ,double perc,double dxinc,double dxmax,unsigned short glorder) 314 // --- Integration adaptative --- 315 // Integrate[func[x], {x,xmin,xmax}] 316 // ..xmin,xmax are the integration limits 317 // ..dxinc is the searching increment x = xmin+i*dxinc 318 // if <0 npt = int(|dxinc|) (si<2 alors npt=100) 319 // et dxinc = (xmax-xmin)/npt 320 // ..dxmax is the maximum possible increment (if dxmax<=0 no test) 321 // --- 322 // Partition de [xmin,xmax] en intervalles [x(i),x(i+1)]: 323 // on parcourt [xmin,xmax] par pas de "dxinc" : x(i) = xmin + i*dxinc 324 // on cree un intervalle [x(i),x(i+1)] 325 // - si |f[x(i+1)] - f[x(i)]| > perc*|f[[x(i)]| 326 // - si |x(i+1)-x(i)| >= dxmax (si dxmax>0.) 327 // Dans un intervalle [x(i),x(i+1)] la fonction est integree 328 // avec une methode de gauss-legendre d'ordre "glorder" 329 { 330 double signe = 1.; 331 if(xmin>xmax) {double tmp=xmax; xmax=xmin; xmin=tmp; signe=-1.;} 332 333 if(glorder==0) glorder = 4; 334 if(perc<=0.) perc=0.1; 335 if(dxinc<=0.) {int n=int(-dxinc); if(n<2) n=100; dxinc=(xmax-xmin)/n;} 336 if(glorder != IntegrateFunc_GlOrder) { 337 IntegrateFunc_GlOrder = glorder; 338 Compute_GaussLeg(glorder,IntegrateFunc_x,IntegrateFunc_w,0.,1.); 339 } 340 341 // Recherche des intervalles [x(i),x(i+1)] 342 int_4 ninter = 0; 343 double sum = 0., xbas=xmin, fbas=func(xbas), fabsfbas=fabs(fbas); 344 for(double x=xmin+dxinc; x<xmax+dxinc/2.; x += dxinc) { 345 double f = func(x); 346 double dx = x-xbas; 347 bool doit = false; 348 if( x>xmax ) {doit = true; x=xmax;} 349 else if( dxmax>0. && dx>dxmax ) doit = true; 350 else if( fabs(f-fbas)>perc*fabsfbas ) doit = true; 351 if( ! doit ) continue; 352 double s = 0.; 353 for(unsigned short i=0;i<IntegrateFunc_GlOrder;i++) 354 s += IntegrateFunc_w[i]*func(xbas+IntegrateFunc_x[i]*dx); 355 sum += s*dx; 356 xbas = x; fbas = f; fabsfbas=fabs(fbas); ninter++; 357 } 358 //cout<<"Ninter="<<ninter<<endl; 359 360 return sum*signe; 361 } 362 363 //////////////////////////////////////////////////////////////////////////////////// 364 double IntegrateFuncLog(GenericFunc& func,double lxmin,double lxmax 365 ,double perc,double dlxinc,double dlxmax,unsigned short glorder) 366 // --- Integration adaptative --- 367 // Idem IntegrateFunc but integrate on logarithmic (base 10) intervals: 368 // Int[ f(x) dx ] = Int[ x*f(x) dlog10(x) ] * log(10) 369 // ..lxmin,lxmax are the log10() of the integration limits 370 // ..dlxinc is the searching logarithmic (base 10) increment lx = lxmin+i*dlxinc 371 // ..dlxmax is the maximum possible logarithmic (base 10) increment (if dlxmax<=0 no test) 372 // Remarque: to be use if "x*f(x) versus log10(x)" looks like a polynomial 373 // better than "f(x) versus x" 374 // ATTENTION: la fonction func que l'on passe en argument 375 // est "func(x)" et non pas "func(log10(x))" 376 { 377 double signe = 1.; 378 if(lxmin>lxmax) {double tmp=lxmax; lxmax=lxmin; lxmin=tmp; signe=-1.;} 379 380 if(glorder==0) glorder = 4; 381 if(perc<=0.) perc=0.1; 382 if(dlxinc<=0.) {int n=int(-dlxinc); if(n<2) n=100; dlxinc=(lxmax-lxmin)/n;} 383 if(glorder != IntegrateFunc_GlOrder) { 384 IntegrateFunc_GlOrder = glorder; 385 Compute_GaussLeg(glorder,IntegrateFunc_x,IntegrateFunc_w,0.,1.); 386 } 387 388 // Recherche des intervalles [lx(i),lx(i+1)] 389 int_4 ninter = 0; 390 double sum = 0., lxbas=lxmin, fbas=func(pow(10.,lxbas)), fabsfbas=fabs(fbas); 391 for(double lx=lxmin+dlxinc; lx<lxmax+dlxinc/2.; lx += dlxinc) { 392 double f = func(pow(10.,lx)); 393 double dlx = lx-lxbas; 394 bool doit = false; 395 if( lx>lxmax ) {doit = true; lx=lxmax;} 396 else if( dlxmax>0. && dlx>dlxmax ) doit = true; 397 else if( fabs(f-fbas)>perc*fabsfbas ) doit = true; 398 if( ! doit ) continue; 399 double s = 0.; 400 for(unsigned short i=0;i<IntegrateFunc_GlOrder;i++) { 401 double y = pow(10.,lxbas+IntegrateFunc_x[i]*dlx); 402 s += IntegrateFunc_w[i]*y*func(y); 403 } 404 sum += s*dlx; 405 lxbas = lx; fbas = f; fabsfbas=fabs(fbas); ninter++; 406 } 407 //cout<<"Ninter="<<ninter<<endl; 408 409 return M_LN10*sum*signe; 410 } 411 412 //////////////////////////////////////////////////////////////////////////////////// 413 /* 414 Integration des fonctions a une dimension y=f(x) par la Methode de Gauss-Legendre. 415 --> Calcul des coefficients du developpement pour [x1,x2] 416 | INPUT: 417 | x1,x2 : bornes de l'intervalle (dans nbinteg.h -> x1=-0.5 x2=0.5) 418 | glorder = degre n du developpement de Gauss-Legendre 419 | OUTPUT: 420 | x[] = valeur des abscisses ou l'on calcule (dim=n) 421 | w[] = valeur des coefficients associes 422 | REMARQUES: 423 | - x et w seront dimensionnes a n. 424 | - l'integration est rigoureuse si sur l'intervalle d'integration 425 | la fonction f(x) peut etre approximee par un polynome 426 | de degre 2*m (monome le + haut x**(2*n-1) ) 427 */ 428 void Compute_GaussLeg(unsigned short glorder,vector<double>& x,vector<double>& w,double x1,double x2) 429 { 430 if(glorder==0) return; 431 int n = (int)glorder; 432 x.resize(n,0.); w.resize(n,0.); 433 434 int m,j,i; 435 double z1,z,xm,xl,pp,p3,p2,p1; 436 437 m=(n+1)/2; 438 xm=0.5*(x2+x1); 439 xl=0.5*(x2-x1); 440 for (i=1;i<=m;i++) { 441 z=cos(M_PI*(i-0.25)/(n+0.5)); 442 do { 443 p1=1.0; 444 p2=0.0; 445 for (j=1;j<=n;j++) { 446 p3=p2; 447 p2=p1; 448 p1=((2.0*j-1.0)*z*p2-(j-1.0)*p3)/j; 449 } 450 pp=n*(z*p1-p2)/(z*z-1.0); 451 z1=z; 452 z=z1-p1/pp; 453 } while (fabs(z-z1) > 3.0e-11); // epsilon 454 x[i-1]=xm-xl*z; 455 x[n-i]=xm+xl*z; 456 w[i-1]=2.0*xl/((1.0-z*z)*pp*pp); 457 w[n-i]=w[i-1]; 458 } 459 } -
trunk/Cosmo/SimLSS/geneutils.h
r3157 r3196 79 79 80 80 //---------------------------------------------------- 81 double InterpTab(double x0,vector<double>& X,vector<double>& Y,unsigned short typint=0); 82 83 //---------------------------------------------------- 81 84 int FuncToHisto(GenericFunc& func,Histo& h,bool logaxex=false); 82 85 int FuncToVec(GenericFunc& func,TVector<r_8>& h,double xmin,double xmax,bool logaxex=false); … … 89 92 unsigned long PoissRandLimit(double mu,double mumax=10.); 90 93 94 //---------------------------------------------------- 95 double IntegrateFunc(GenericFunc& func,double xmin,double xmax 96 ,double perc=0.1,double dxinc=-1.,double dxmax=-1.,unsigned short glorder=4); 97 98 double IntegrateFuncLog(GenericFunc& func,double lxmin,double lxmax 99 ,double perc=0.1,double dlxinc=-1.,double dlxmax=-1.,unsigned short glorder=4); 100 101 void Compute_GaussLeg(unsigned short glorder,vector<double>& x,vector<double>& w,double x1=0.,double x2=1.); 102 91 103 #endif -
trunk/Cosmo/SimLSS/pkspectrum.cc
r3193 r3196 11 11 12 12 #include "constcosmo.h" 13 #include " integfunc.h"13 #include "geneutils.h" 14 14 #include "pkspectrum.h" 15 15 … … 390 390 void VarianceSpectrum::SetInteg(double dperc,double dlogkinc,double dlogkmax,unsigned short glorder) 391 391 // ATTENTION: on n'integre pas f(k)*dk mais k*f(k)*d(log10(k)) 392 // see argument details in function IntegrateFuncLog ( integfunc.cc)392 // see argument details in function IntegrateFuncLog (geneutils.cc) 393 393 { 394 394 dperc_ = dperc; if(dperc_<=0.) dperc_ = 0.1; -
trunk/Cosmo/SimLSS/schechter.cc
r3193 r3196 68 68 /////////////////////////////////////////////////////////// 69 69 70 double FluxHI(double m,double d)70 double Msol2FluxHI(double m,double d) 71 71 // Input: 72 72 // m : masse de HI en "Msol" … … 88 88 return 2.0e-28 * m / (d*d); 89 89 } 90 91 double FluxHI2Msol(double f,double d) 92 // Input: 93 // f : flux total emis a 21 cm en W/m^2 94 // d : distance en "Mpc" (si cosmo d=DLum(z)) 95 // Return: 96 // m : masse de HI en "Msol" 97 { 98 return f *d*d / 2.0e-28; 99 } -
trunk/Cosmo/SimLSS/schechter.h
r3193 r3196 25 25 26 26 //----------------------------------------------------------------------------------- 27 double FluxHI(double m,double d); 27 double Msol2FluxHI(double m,double d); 28 double FluxHI2Msol(double f,double d); 28 29 29 30 #endif
Note:
See TracChangeset
for help on using the changeset viewer.