Example #1
0
int main(int argc, char* argv[])
{
  if(argc < 2) {
    printf("rescale_power <P(k) file name> <sigma8>");
    return 0;
  }

  char* filename= argv[1];
  double sigma8= atof(argv[2]);

  read_power_table_camb(filename);

  const double R8 = 8.0; // 8 /h Mpc

  double sigma2 = TopHatSigma2(R8); 
  double fac= sigma8*sigma8/sigma2*(2.0*M_PI*M_PI);

  fprintf(stderr, "Input power spectrum sigma8 %f\n", sqrt(sigma2));

  for(int i=0; i<NPowerTable; i++) {
    double k= pow(10.0, PowerTable[i].logk); 
    double pk= fac*pow(10.0, PowerTable[i].logD)/(k*k*k);

    printf("%e %e\n", k, pk);
  }
    
  return 0;
}
Example #2
0
//Definitions for the normalized power spectrum
//These mostly compute sigma_8 via the GSL
NormalizedPowerSpec::NormalizedPowerSpec(PowerSpec * PSpec, double Sigma8, double PrimordialIndex, double Dplus, double UnitLength_in_cm): Dplus(Dplus), PSpec(PSpec), PrimordialIndex(PrimordialIndex), Norm(1.)
{
        /* 8 Mpc/h */
        R8 = 8 * (3.085678e24 / UnitLength_in_cm);
        //Uses R8
        Norm = Sigma8 * Sigma8 / TopHatSigma2();
        printf("Normalization adjusted by %g so  Sigma8 = %g\n", Norm, Sigma8);
}
Example #3
0
double normalize_power(const double a_init, const double sigma8)
{
  // Assume that input power spectrum already has a proper sigma8
  const double R8 = 8.0; // 8 Mpc

  double res = TopHatSigma2(R8); 
  double sigma8_input= sqrt(res);

  if(fabs(sigma8_input - sigma8)/sigma8 > 0.05)
    msg_abort(3010, "Input sigma8 %f is far from target sigma8 %f\n",
	      sigma8_input, sigma8);

  msg_printf(info, "Input power spectrum sigma8 %f\n", sigma8_input);

  return 1.0;
}
Example #4
0
// Set up the power spectrum
// =========================
void initialize_powerspectrum(void) {

  double res;

  // R8 = 8 MPc/h
  R8 = 8 * (3.085678e24 / UnitLength_in_cm);

  // Read power spectrum from input file if requested
  if(WhichSpectrum == 1) read_power_table();

  Norm = 1.0;
  res = TopHatSigma2(R8);
  if(ThisTask == 0 && WhichSpectrum == 1) printf("Normalization of spectrum in file: Sigma8 = %lf...\n",sqrt(res));

  Norm = Sigma8 * Sigma8 / res;
  if(ThisTask == 0) printf("Normalization adjusted to Sigma8=%lf (Normfac=%lf)...\n",Sigma8,Norm);

  // for WhichSpectrum == 0 do not use power spectrum, only transfer function,
  // the file of which is set in the run parameters
  if (WhichSpectrum == 0) Anorm = Norm;

  return;
}
Example #5
0
void initialize_powerspectrum(void) {
  double res;

  InitTime = 1 / (1 + Redshift);

  AA = 6.4 / ShapeGamma * (3.085678e24 / UnitLength_in_cm);
  BB = 3.0 / ShapeGamma * (3.085678e24 / UnitLength_in_cm);
  CC = 1.7 / ShapeGamma * (3.085678e24 / UnitLength_in_cm);
  nu = 1.13;

  R8 = 8 * (3.085678e24 / UnitLength_in_cm);	/* 8 Mpc/h */


  if(WhichSpectrum == 2)
    read_power_table();

#ifdef DIFFERENT_TRANSFER_FUNC
  Type = 1;
#endif

  Norm = 1.0;
  res = TopHatSigma2(R8);
  #ifdef VERB
  if(ThisTask == 0 && WhichSpectrum == 2)
    	fprintf(stderr,"\tNormalization of spectrum in file: Sigma8 = %g\n", sqrt(res));
  #endif

  Norm = Sigma8 * Sigma8 / res;

  #ifdef VERB
  if(ThisTask == 0 && WhichSpectrum == 2)
   	fprintf(stderr,"\tNormalization adjusted to Sigma8=%g (Normfac=%g)\n", Sigma8, Norm);
  #endif

  Dplus = GrowthFactor(InitTime, 1.0);
}