Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
bcm_bm.c File Reference

Go to the source code of this file.

Functions

 if (pnl->method==nl_baryon)
 

Function Documentation

if ( pnl->  method = = nl_baryon)

This file contains the modification made to the hi_class code (1st anniversary release - https://github.com/miguelzuma/hi_class_public/releases/tag/v1.1) to directly output the baryon-corrected matter power spectrum. Note that this is an excerpt from the actual code, and therefore won't run on its own.

  • loop over time to add baryonic correction

Definition at line 13 of file bcm_bm.c.

References pow(), and sqrt().

Referenced by ccl_cosmology_compute_power_emu().

13  {
14  if (pnl->nonlinear_verbose > 0)
15  printf("Adding baryonic effects (eq 4.2 of 1510.06034) \n");
16 
19  for (index_tau = pnl->tau_size-1; index_tau>=0; index_tau--) {
20 
21  /* get P_L(k) at this time */
22  class_call(nonlinear_pk_l(ppt,ppm,pnl,index_tau,pk_l),
23  pnl->error_message,
24  pnl->error_message);
25 
26  class_alloc(pvecback,pba->bg_size*sizeof(double),pnl->error_message);
27 
28  class_call(background_at_tau(pba,pnl->tau[index_tau],pba->long_info,pba->inter_normal,&last_index,pvecback),
29  pba->error_message,
30  pnl->error_message);
31 
32  /* correct the spectrum */
33  for (index_k=0; index_k<pnl->k_size; index_k++) {
34 
35  /*Section 4.6 of 1510.06034
36  * NOTE: factors of h!
37  */
38  B = 0.105*log10(pnl->baryon_M_c) - 1.27;
39  B /= (1.+pow((1./pvecback[pba->index_bg_a]-1.)/2.3, 2.5));
40 
41  k_g = pba->h*0.7*pow(1.-B, 4)*pow(pnl->baryon_eta_b,-1.6);
42 
43  G = 1. + B*(1./(1. + pow(pnl->k[index_k]/k_g,3)) -1.);
44 
45  //multiply by the stellar correction
46  G *= 1. + pow(pnl->k[index_k]/55./pba->h,2);
47 
48  // sqrt(pk_nl[index_k]/pk_l[index_k])
49  pnl->nl_corr_density[index_tau * pnl->k_size + index_k] *= sqrt(G);
50  }
51  }
52 
53  }
Grid< NDIM, T > sqrt(Grid< NDIM, T > lhs)
Definition: grid.h:231
float pow(float base, unsigned long int exp)
Definition: precision.hpp:39