Esempio n. 1
0
double cosmo_get_amp_k( double k )
{
    
    if( ptf == NULL )
    {
        ptf = new TransferFunction_Eisenstein();
        
        double D0 = Dplus(1.0);
        double Dz = Dplus(1.0/(1.0+g_zstart))/D0;
        
        //.. compute normalization first ..
        double sigma0;
        {
            std::vector<double> scale(1,0.0);
            scale[0] = 8.0;
            double intt(0.0), dint(1.0), dx(2.0*M_PI/scale[0]), atmp(0.0);
            for(;;){
                dint = integrate( &dsigma, scale, atmp, atmp+dx );
                atmp+=dx;
                intt+=dint;
                if( dint/intt < REL_PRECISION )
                    break;
            }
            sigma0 = sqrt(4.0*M_PI*intt);
            
            cosmo_norm_fac = Dz * g_sigma_8/sigma0;
        }
        
    }
    
    return ptf->compute(k) * pow( k, 0.5*g_nspect ) * cosmo_norm_fac;
}
Esempio n. 2
0
double linear_growth_factor(double z, cosmo_info **cosmo) {
    // Repeat the integral only if we change
    //    redshift from the last call.
    static double b_z    = 1.;
    static double z_last = -42.;
    if(z != z_last) {
        double Dplus_a = Dplus(a_of_z(z), cosmo);
        double Dplus_1 = Dplus(1., cosmo);
        b_z            = Dplus_a / Dplus_1;
        z_last         = z;
    }
    return (b_z);
}
Esempio n. 3
0
float ComputeVFact( float a ){
    float fomega, dlogadt, eta;
    float Omega_k = 1.0 - g_Omega_m - g_Omega_L;
    
    float Dp = Dplus( a )/Dplus(1.0);
    
    eta     = sqrt( (double)(g_Omega_m/a+ g_Omega_L*a*a + Omega_k ));
    fomega  = (2.5/Dp-1.5*g_Omega_m/a-Omega_k)/eta/eta;
    dlogadt = a*eta;
    
    //... /100.0 since we would have to multiply by H0 to convert
    //... the displacement to velocity units. But displacement is
    //... in Mpc/h, and H0 in units of h is 100.
    return fomega * dlogadt/a *100.0;
}
Esempio n. 4
0
void compute_powerspectrum( const std::vector<double>& k, std::vector<double>& Pk, double z )
{
    double D0 = Dplus(1.0);
    double Dz = Dplus(1.0/(1.0+z))/D0;
    
    //.. compute normalization first ..
    double sigma0;
    {
        std::vector<double> scale(1,0.0);
        scale[0] = 8.0;
        double intt(0.0), dint(1.0), dx(2.0*M_PI/scale[0]), atmp(0.0);
        for(;;){
            dint = integrate( &dsigma, scale, atmp, atmp+dx );
            atmp+=dx;
            intt+=dint;
            if( dint/intt < REL_PRECISION )
                break;
        }
        sigma0 = sqrt(4.0*M_PI*intt);
    }
    
    
    //... compute normalized power spectrum
    Pk.clear();
    
    static double nspect = g_nspect;
#if TRANSFERF_TYPE==0
    static TransferFunction_BBKS TF(false);
#elif TRANSFERF_TYPE==1
    static TransferFunction_BBKS TF(true);
#elif TRANSFERF_TYPE==2
    static TransferFunction_Eisenstein TF;
#else
#error "Undefined Transfer Function Type."
#endif
    
    for(unsigned i=0; i<k.size(); ++i ){  
        double tfk = TF.compute(k[i]);
        Pk.push_back( Dz*Dz*pow(k[i],nspect)*tfk*tfk
                     /sigma0/sigma0*g_sigma_8*g_sigma_8 );
        
    }
    
}
Esempio n. 5
0
void MatterFreeE::Sound(double *S,double *Dencity,double *Energy,int Num)
{
   VecCl T(Num),Eplus(Num),Tplus(Num),Dplus(Num),Pplus(Num),P(Num);
   Temperature(T.Ptr,Dencity,Energy,Num);
   FreeEPtr->Pressure(P.Ptr,Dencity,T.Ptr,Num);
   Tplus= T * (1 + MinimT2EstpCoef) + MinimT2EstpMin;
   FreeEPtr->Energy(Eplus.Ptr,Dencity,Tplus.Ptr,Num);
   for (int k=1;k<=Num;k++)
    { 
     Dplus[k]=Dencity[k];
     if (Dencity[k]<MathZer) { cout<<"MatterFreeEIO::Sound; Dencity<MathZer :"
                                <<Dencity<<"\n";Tplus[k]=0;continue;}
     double dE=max<double>(Eplus[k]-Energy[k],MathZer);
     double dr=Dencity[k]+dE*sqr(Dencity[k])/max<double>(1e-4,P.Ptr[k]);
     if (fabs(dr)<MathZer) {Tplus[k]=0;continue;}
     Dplus[k]=Dplus[k]+dr;
    }
   FreeEPtr->Pressure(Pplus.Ptr,Dplus.Ptr,Tplus.Ptr,Num);
   for (int k=1;k<=Num;k++)   S[k]=sqrt( max<double>(0,Pplus[k]-P[k])/(Dplus[k]-Dencity[k]) );
  };