double halo_mass_function(double mass)
{
  double sig,logm,a,slo,shi,rm,rlo,rhi,mlo,mhi,dsdM,n,nuprime,nufnu,p,A, fac;
  static int flag=0,SO180=0,SO324=0,WARREN=0,ST=0,JENKINS=0;
  static double pnorm, prev_delta, prev_cosmo;
  double btemp = -1;

  static double
    a1 = 0.325277,
    a2 = 0.492785,
    a3 = 0.310289,
    a4 = 1.317104,
    a5 = 2.425681;
    
  /* Jenkins et al. SO 180 best-fit
   */
  if(SO180)
    {
      JENKINS_A = 0.301;
      JENKINS_B = 0.64;
      JENKINS_C = 3.82;
    }      
  if(SO324)
    {
      JENKINS_A = 0.316;
      JENKINS_B = 0.67;
      JENKINS_C = 3.82;
    }      
  if(JENKINS) //their .2 fof function
    {
      JENKINS_A = 0.315;
      JENKINS_B = 0.61;
      JENKINS_C = 3.8;
    }      


  /* First normalize the power spectrum
   */
  pnorm=SIGMA_8/sigmac(8.0);
  rm=pow(3.0*mass/(4.0*PI*OMEGA_M*RHO_CRIT),1.0/3.0);
  sig=pnorm*sigmac(rm);
  logm=log10(mass);
  
  mlo=0.99*mass;
  mhi=1.01*mass;
  rlo=pow(3.0*mlo/(4.0*PI*OMEGA_M*RHO_CRIT),1.0/3.0);
  rhi=pow(3.0*mhi/(4.0*PI*OMEGA_M*RHO_CRIT),1.0/3.0);

  slo=pnorm*sigmac(rlo);
  shi=pnorm*sigmac(rhi);
  dsdM=(shi-slo)/(mhi-mlo);

  if(SO324)goto JENKINS_FUNCTION;
  if(SO180)goto JENKINS_FUNCTION;
  if(WARREN)goto WARREN_FUNCTION;
  if(ST)goto ST_FUNCTION;
  if(JENKINS)goto JENKINS_FUNCTION;

  /* Tinker et al. (2008) for SO as a function of DELTA_HALO
   */
  if(DELTA_HALO != prev_delta || prev_cosmo != RESET_COSMOLOGY)
    {
      initialize_mass_function(&a1,&a2,&a3,&a4);
      prev_delta = DELTA_HALO;
      prev_cosmo = RESET_COSMOLOGY;
      //a4*=1.3;
      //a1*=1.15;
      fprintf(stderr,"MF PARAMS for DELTA=%f %f %f %f %f\n",DELTA_HALO,a1,a2,a3,a4);
    }
  
  n = -a1*(pow(sig/a3,-a2)+1)*exp(-a4/sig/sig)*OMEGA_M*RHO_CRIT/mass/sig*dsdM;
  // NB! factor for accounting for satellites
  mass = log10(mass)-11;
  fac = 1.0;
  //fac = 1.1;
  //if(mass>0.15)
  // fac = pow(mass-0.15,0.5)/(1+exp(pow(mass,1.1))*2)*wpl.satfac + 1;
  //printf("NB! altering halo mass function by: %f %f\n",fac,mass);
  n = n*fac;
  return(n);

  /* Jenkins et al. FOF .2 best-fit (unless SO180==1)
   */
 JENKINS_FUNCTION:
  a=-JENKINS_A*OMEGA_M*RHO_CRIT/mass/sig;
  n=a*dsdM*exp(-pow(fabs(JENKINS_B-log(sig)),JENKINS_C));
  return(n);

  /* Warren et al. (calibrated only on concordance cosmology, FOF.2)
   */
 WARREN_FUNCTION:
  n = -0.7234*(pow(sig,-1.625)+0.2538)*exp(-1.198/sig/sig)*OMEGA_M*RHO_CRIT/mass/sig*dsdM;
  return(n);

 ST_FUNCTION:

  /* This is a bunch of Sheth-Tormen stuff.
   */
  nuprime=0.841*DELTA_CRIT/sig;
  nufnu=0.644*(1+1.0/pow(nuprime,0.6))*(sqrt(nuprime*nuprime/2/PI))*exp(-nuprime*nuprime/2);
  //n=RHO_CRIT*OMEGA_M/mass*mass*nufnu*fabs(dsdM);
  n=RHO_CRIT*OMEGA_M/mass*nufnu*fabs(dsdM)/sig;
  return(n);

}
Esempio n. 2
0
double halo_mass_function(double mass)
{
  double sig,logm,a,slo,shi,rm,rlo,rhi,mlo,mhi,dsdM,n,nuprime,nufnu,p,A;
  static int flag=0,SO180=0,SO324=0,WARREN=0,ST=0,JENKINS=0,prev_cosmo=0;
  static double pnorm, prev_delta;
  double btemp = -1;

  static double
    a1 = 0.325277,
    a2 = 0.492785,
    a3 = 0.310289,
    a4 = 1.317104,
    a5 = 2.425681;
    
  /* Jenkins et al. SO 180 best-fit
   */
  if(SO180)
    {
      JENKINS_A = 0.301;
      JENKINS_B = 0.64;
      JENKINS_C = 3.82;
    }      
  if(SO324)
    {
      JENKINS_A = 0.316;
      JENKINS_B = 0.67;
      JENKINS_C = 3.82;
    }      
  if(JENKINS) //their .2 fof function
    {
      JENKINS_A = 0.315;
      JENKINS_B = 0.61;
      JENKINS_C = 3.8;
    }      


  /* First normalize the power spectrum
   */
  pnorm=SIGMA_8/sigmac(8.0);
  rm=pow(3.0*mass/(4.0*PI*OMEGA_M*RHO_CRIT),1.0/3.0);
  sig=pnorm*sigmac(rm);
  logm=log10(mass);
  
  mlo=0.99*mass;
  mhi=1.01*mass;
  rlo=pow(3.0*mlo/(4.0*PI*OMEGA_M*RHO_CRIT),1.0/3.0);
  rhi=pow(3.0*mhi/(4.0*PI*OMEGA_M*RHO_CRIT),1.0/3.0);

  slo=pnorm*sigmac(rlo);
  shi=pnorm*sigmac(rhi);
  dsdM=(shi-slo)/(mhi-mlo);

  if(SO324)goto JENKINS_FUNCTION;
  if(SO180)goto JENKINS_FUNCTION;
  if(WARREN)goto WARREN_FUNCTION;
  if(ST)goto ST_FUNCTION;
  if(JENKINS)goto JENKINS_FUNCTION;

  /* Tinker et al. (in prep) for SO 200
   */
  if(DELTA_HALO != prev_delta || prev_cosmo != RESET_COSMOLOGY)
    {
      initialize_mass_function(&a1,&a2,&a3,&a4);
      prev_delta = DELTA_HALO;
      prev_cosmo = RESET_COSMOLOGY;

      // if we're using systematic errors in an MCMC, adjust parameter a1 (amplitude)
      if(USE_ERRORS)
	a1 *= M2N.mf_amp;
      fprintf(stderr,"MF PARAMS for DELTA=%f %f %f %f %f\n",DELTA_HALO,a1,a2,a3,a4);
    }
  
  n = -a1*(pow(sig/a3,-a2)+1)*exp(-a4/sig/sig)*OMEGA_M*RHO_CRIT/mass/sig*dsdM;
  return(n);

  /* Jenkins et al. FOF .2 best-fit (unless SO180==1)
   */
 JENKINS_FUNCTION:
  a=-JENKINS_A*OMEGA_M*RHO_CRIT/mass/sig;
  n=a*dsdM*exp(-pow(fabs(JENKINS_B-log(sig)),JENKINS_C));
  return(n);

  /* Warren et al. (calibrated only on concordance cosmology, FOF.2)
   */
 WARREN_FUNCTION:
  n = -0.7234*(pow(sig,-1.625)+0.2538)*exp(-1.198/sig/sig)*OMEGA_M*RHO_CRIT/mass/sig*dsdM;
  return(n);



  /* Need to find the derivative dlog(sig)/dlog(M)
   */
  mlo=0.99*logm;
  mhi=1.01*logm;
  rlo=pow(3.0*pow(10.0,mlo)/(4.0*PI*OMEGA_M*RHO_CRIT),1.0/3.0);
  rhi=pow(3.0*pow(10.0,mhi)/(4.0*PI*OMEGA_M*RHO_CRIT),1.0/3.0);
  slo=log10(pnorm*sigmac(rlo));
  shi=log10(pnorm*sigmac(rhi));
  dsdM=(shi-slo)/(mhi-mlo);

 ST_FUNCTION:

  /* This is a bunch of Sheth-Tormen stuff.
   * NB! because I'm skipping the above derivative (dlogs/dlogM), i'm using the lower
   */
  nuprime=0.841*DELTA_CRIT/sig;
  nufnu=0.644*(1+1.0/pow(nuprime,0.6))*(sqrt(nuprime*nuprime/2/PI))*exp(-nuprime*nuprime/2);
  //n=RHO_CRIT*OMEGA_M/mass*mass*nufnu*fabs(dsdM);
  n=RHO_CRIT*OMEGA_M/mass*nufnu*fabs(dsdM)/sig;
  return(n);




}