Changeset 3353 in Sophya for trunk/Cosmo/SimLSS/genefluct3d.cc
- Timestamp:
- Oct 17, 2007, 4:44:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/genefluct3d.cc
r3351 r3353 1021 1021 int_8 GeneFluct3D::VarianceFrReal(double R,double& var) 1022 1022 // Recompute MASS variance in spherical top-hat (rayon=R) 1023 // Par definition: SigmaR^2 = <(M-<M>)^2>/<M>^2 1024 // ou M = masse dans sphere de rayon R 1023 1025 { 1024 1026 if(lp_>0) cout<<"--- VarianceFrReal R="<<R<<endl; 1025 1027 check_array_alloc(); 1026 1028 1027 long dnx = long(R/Dx_ +0.5); if(dnx<=0) dnx = 1;1028 long dny = long(R/Dy_ +0.5); if(dny<=0) dny = 1;1029 long dnz = long(R/Dz_ +0.5); if(dnz<=0) dnz = 1;1029 long dnx = long(R/Dx_)+1; if(dnx<=0) dnx = 1; 1030 long dny = long(R/Dy_)+1; if(dny<=0) dny = 1; 1031 long dnz = long(R/Dz_)+1; if(dnz<=0) dnz = 1; 1030 1032 if(lp_>0) cout<<"dnx="<<dnx<<" dny="<<dny<<" dnz="<<dnz<<endl; 1031 1033 1032 double sum=0., sum2=0., r2 = R*R; int_8 nsum=0; 1033 1034 for(long i=dnx;i<Nx_-dnx;i+=dnx) { 1035 for(long j=dny;j<Ny_-dny;j+=dny) { 1036 for(long l=dnz;l<Nz_-dnz;l+=dnz) { 1037 double s=0.; int_8 n=0; 1034 double sum=0., sum2=0., sn=0., r2 = R*R; 1035 int_8 nsum=0; 1036 1037 for(long i=dnx;i<Nx_-dnx;i+=2*dnx) { 1038 for(long j=dny;j<Ny_-dny;j+=2*dny) { 1039 for(long l=dnz;l<Nz_-dnz;l+=2*dnz) { 1040 double m=0.; int_8 n=0; 1038 1041 for(long ii=i-dnx;ii<=i+dnx;ii++) { 1039 1042 double x = (ii-i)*Dx_; x *= x; … … 1044 1047 if(x+y+z>r2) continue; 1045 1048 int_8 ip = IndexR(ii,jj,ll); 1046 s += 1.+data_[ip];1049 m += 1.+data_[ip]; // 1+drho/rho 1047 1050 n++; 1048 1051 } 1049 1052 } 1050 1053 } 1051 if(n>0) {sum += s; sum2 += s*s; nsum++;}1052 //cout<<i<<","<<j<<","<<l<<" n="<<n<<" s="<<s<<" sum="<<sum<<" sum2="<<sum2<<endl;1054 if(n>0) {sum += m; sum2 += m*m; nsum++; sn += n;} 1055 //cout<<i<<","<<j<<","<<l<<" n="<<n<<" m="<<m<<" sum="<<sum<<" sum2="<<sum2<<endl; 1053 1056 } 1054 1057 } … … 1056 1059 1057 1060 if(nsum<=1) {var=0.; return nsum;} 1058 1059 1061 sum /= nsum; 1060 1062 sum2 = sum2/nsum - sum*sum; 1061 if(lp_>0) cout<<"...nsum="<<nsum<<" <M>="<<sum<<" <(M-<M>)^2>="<<sum2<<endl; 1062 1063 var = sum2/(sum*sum); // <dM>^2/<M>^2 1064 if(lp_>0) cout<<"...sigmaR^2="<<var<<" -> "<<sqrt(var)<<endl; 1063 sn /= nsum; 1064 if(lp_>0) cout<<"...<n>="<<sn<<", nsum="<<nsum<<" <M>="<<sum<<" <(M-<M>)^2>="<<sum2<<endl; 1065 var = sum2/(sum*sum); // <dM^2>/<M>^2 1066 if(lp_>0) cout<<"...sigmaR^2 = <(M-<M>)^2>/<M>^2 = "<<var 1067 <<" -> sigmaR = "<<sqrt(var)<<endl; 1065 1068 1066 1069 return nsum;
Note:
See TracChangeset
for help on using the changeset viewer.