23 Spline & logY_of_logx_spline,
27 std::string
label =
"logY(log(x)) extrapolated"){
30 const auto logx_array = logY_of_logx_spline.
get_x_data();
31 const double logxmin = logx_array.front();
32 const double logxmax = logx_array.back();
35 double slope_min = logY_of_logx_spline.
deriv_x(logxmin*0.99);
36 double slope_max = logY_of_logx_spline.
deriv_x(logxmax*1.01);
39 auto logY_extrapolated = [&](
double logx){
41 return logY_of_logx_spline(logxmin) + (logx-logxmin) * slope_min;
42 }
else if(logx > logxmax){
43 return logY_of_logx_spline(logxmax) + (logx-logxmax) * slope_max;
45 return logY_of_logx_spline(logx);
49 const auto logx_array_new =
FML::MATH::linspace(std::log(xmin_new), std::log(xmax_new), npts_new);
51 for(
const auto logx : logx_array_new){
52 logY_array_new.push_back( logY_extrapolated(logx) );
54 logY_of_logx_spline =
Spline(logx_array_new, logY_array_new,
label);
62 const std::string filename_pofk,
63 Spline & logDelta_of_logk_spline,
72 DVector logk_array, logDelta_array;
73 for(
size_t i = 0; i <
data.size(); i++){
74 double k =
data[i][col_k];
76 double Delta_over_pofk = (
k*
k*
k) / (2.0*M_PI*M_PI);
77 logk_array.push_back( std::log(
k) );
78 logDelta_array.push_back( std::log(
pofk * Delta_over_pofk * normalization ) );
82 logDelta_of_logk_spline =
Spline(logk_array, logDelta_array,
"logDelta(logk)");
86 const double kmin = 1e-12;
87 const double kmax = 1e12;
88 const int npts_spline = 1000;
90 logDelta_of_logk_spline,
94 "logDelta(logk) extrapolated");
102 const Spline & logsigma_of_logR_spline,
103 const Spline & lognu_of_logR_spline){
104 const double logRmin = std::log(1e-4);
105 const double logRmax = std::log(1e4);
106 const double epsilon = 1e-10;
108 const double lognu_goal = std::log(1.0);
109 auto condition = [&](
double logR){
110 return lognu_of_logR_spline(logR) - lognu_goal;
113 const double neff = -3.0 - 2.0 * logsigma_of_logR_spline.
deriv_x(logR);
114 return std::pair(
std::exp(logR), neff);
122 const Func1 logDelta_of_logk,
125 const DVector *fiducial_logk_array){
126 auto integrand = [&](
double logk){
127 const double W = window_of_kR(
std::exp(logk)*R);
131 const double kmin = 1e-8, kmax = 1e4;
132 const int npts_k = 1000;
134 if(fiducial_logk_array !=
nullptr)
135 logk_array = *fiducial_logk_array;
136 auto k_array = logk_array;
138 double integral = 0.0;
139 for(
const auto logk : logk_array){
140 integral += integrand(logk);
142 integral *= (logk_array[1]-logk_array[0]);
143 return std::sqrt(integral);
150 const Func1 logDelta_of_logk,
152 Spline & logsigma_of_logR_spline,
153 const DVector *fiducial_logR_array,
154 const DVector *fiducial_logk_array){
160 const double Rmin = 1e-8, Rmax = 1e8;
161 const int npts_R = 500;
163 if(fiducial_logR_array !=
nullptr)
164 logR_array = *fiducial_logR_array;
165 auto R_array = logR_array;
166 for(
auto & R : R_array) R =
std::exp(R);
172 const double kmin = 1e-8, kmax = 1e8;
173 const int npts_k = 500;
175 if(fiducial_logk_array !=
nullptr)
176 logk_array = *fiducial_logk_array;
177 auto k_array = logk_array;
184 for(
const auto R : R_array){
186 auto integrand = [&logDelta_of_logk,&window_of_kR](
double logk,
double R){
188 const double W = window_of_kR(
k*R);
189 return std::exp(logDelta_of_logk(logk)) * W * W;
192 double integral = 0.0;
193 for(
const auto logk : logk_array){
194 integral += integrand(logk, R);
196 integral *= (logk_array[1]-logk_array[0]);
197 logsigma_array.push_back(0.5*std::log(integral));
199 logsigma_of_logR_spline =
Spline(logR_array, logsigma_array,
"sigma(R)");
210 return RofM(
M,
OmegaM,
x) * std::pow(DeltaVir, -1.0/3.0);
220 const double Mpl2overMsunH0overh = 2.493e21;
221 const double H0overh_in_hmpc = 1.0 / 2997.92458;
222 const double rho_mean_in_msunh_over_mpch3 = 3.0 *
OmegaM *
std::exp(-3.0*
x)
223 * std::pow(H0overh_in_hmpc,3) * Mpl2overMsunH0overh;
224 return std::pow(
M / (4.0 * M_PI / 3.0 * rho_mean_in_msunh_over_mpch3), 1.0/3.0);
245 const double Mpl2overMsunH0overh = 2.493e21;
246 const double H0overh_in_hmpc = 1.0 / 2997.92458;
247 const double rho_mean_in_msunh_over_mpch3 = 3.0 *
OmegaM *
std::exp(-3.0*
x)
248 * std::pow(H0overh_in_hmpc,3) * Mpl2overMsunH0overh;
249 return 4.0 * M_PI / 3.0 * rho_mean_in_msunh_over_mpch3 * std::pow(R, 3);
258 const Func2 & rho_function,
269 double rho_start = rho_function(Rvir/10.0,
M);
271 while(power_min < 5) {
273 double rho = rho_function(Rvir/std::pow(10,power_min),
M);
274 if(rho < 1e-4 * rho_start)
break;
281 while(power_max < 7) {
283 double rho = rho_function(Rvir*std::pow(2,power_max),
M);
284 if(rho == 0.0)
break;
290 const double rmin = Rvir/std::pow(10,power_min), rmax = Rvir*std::pow(2,power_max);
291 const int npts_r = (power_max+power_min) * 50 * accuracy_boost;
293 auto r_array = logr_array;
294 for(
auto & r : r_array) r =
std::exp(r);
297 for(
const auto k : k_array){
299 auto integrand = [&rho_function](
double k,
double r,
double M){
300 return rho_function(r,
M) * std::sin(
k*r)/(
k*r);
304 double integral = 0.0;
305 for(
const auto r : r_array){
306 integral += integrand(
k, r,
M);
308 integral *= (logr_array[1] - logr_array[0]);
309 y_array.push_back(integral);
314 const double norm = y_array[0];
315 for(
auto &
y : y_array)
y /= norm;
326 const Func2 & rho_function,
327 Spline2D & y_of_logR_and_logk_spline,
328 const double DeltaVir,
331 const DVector *fiducial_logR_array,
332 const DVector *fiducial_logk_array){
339 const double kmin = 1e-8, kmax = 1e8;
340 const int npts_k = 75 * accuracy_boost;
342 if(fiducial_logk_array !=
nullptr)
343 logk_array = *fiducial_logk_array;
344 auto k_array = logk_array;
350 const double Rmin = 1e-8, Rmax = 1e8;
351 const int npts_R = 75 * accuracy_boost;
353 if(fiducial_logR_array !=
nullptr)
354 logR_array = *fiducial_logR_array;
355 auto R_array = logR_array;
356 for(
auto & R : R_array) R =
std::exp(R);
360#pragma omp parallel for schedule(dynamic,1)
362 for(
size_t i = 0; i < R_array.size(); i++){
363 const double R = R_array[i];
365 const double Rvir = R / std::pow(DeltaVir,1.0/3.0);
367 yofkandM_array[i] = result;
369 y_of_logR_and_logk_spline =
Spline2D(logR_array, logk_array, yofkandM_array,
"y(logR,logk)");
378 const Spline & logsigma_of_logR_spline,
379 Spline & lognu_of_logR_spline,
380 Spline & logR_of_lognu_spline,
381 const DVector *fiducial_logR_array){
386 const double logRmin = logsigma_of_logR_spline.
get_xrange().first;
387 const double logRmax = logsigma_of_logR_spline.
get_xrange().second;
388 const int npts_R = 500;
390 if(fiducial_logR_array !=
nullptr)
391 logR_array = *fiducial_logR_array;
394 for(
const auto logR : logR_array){
395 const double sigma =
std::exp(logsigma_of_logR_spline(logR));
396 const double nu =
deltac/sigma;
397 lognu_array.push_back(std::log(nu));
400 lognu_of_logR_spline =
Spline(logR_array, lognu_array,
"lognu(logR)");
401 logR_of_lognu_spline =
Spline(lognu_array, logR_array,
"logR(lognu)");
409 const Spline & logR_of_lognu_spline,
410 const Spline & lognu_of_logR_spline,
411 Spline & dndlogM_of_logM_spline,
412 Spline & n_of_logM_spline,
413 const Func1 & pdf_of_nu,
418 auto dndlogM_of_lognu = [&](
double lognu){
420 const double logR = logR_of_lognu_spline(lognu);
422 const double f = pdf_of_nu(nu);
423 const double dnudlogR = nu * lognu_of_logR_spline.
deriv_x(logR);
424 return f * std::abs(dnudlogR) / (4.0 * M_PI * R * R * R);
430 const double Mmin = 1e5, Mmax = 1e18;
431 const int npts_M = 500;
433 const double dlogM = logM_array[1]-logM_array[0];
435 DVector dndlogM_array(npts_M), n_array(npts_M, 0.0), lognu_array(npts_M,0.0);
436 for(
int i = npts_M-1; i >= 0; i--){
437 const double logM = logM_array[i];
440 const double logR = std::log(R);
441 const double lognu = lognu_of_logR_spline(logR);
442 const double dndlogM = dndlogM_of_lognu(lognu);
446 n_array[i] += n_array[i+1];
448 dndlogM_of_logM_spline =
Spline(logM_array, dndlogM_array,
"dndlogM(logM)");
449 n_of_logM_spline =
Spline(logM_array, n_array,
"n(logM)");
459 const Spline & logR_of_lognu_spline,
460 const Spline2D & y_of_logR_and_logk_spline,
461 Spline & logDelta_onehalo_of_logk_spline,
462 Spline & logDelta_twohalo_of_logk_spline,
463 Spline & logDelta_full_of_logk_spline,
464 const Func1 & logDeltaLin_of_logk,
465 const Func1 & pdf_of_nu,
466 const Func1 & bias_of_nu,
467 const double eta_hmcode,
477 const double numin = 1e-10, numax = 10;
478 const int npts_nu = 200 * accuracy_boost;
485 auto k_array = logk_array;
488 auto integrand_onehalo = [&logR_of_lognu_spline,&y_of_logR_and_logk_spline,&eta_hmcode,&pdf_of_nu](
double lognu,
double logk){
490 const double logR = logR_of_lognu_spline(lognu);
491 const double y = y_of_logR_and_logk_spline(logR, logk + lognu*eta_hmcode);
492 const double f = pdf_of_nu(nu);
493 const double Moverrhomean = 4.0 * M_PI / 3.0 *
std::exp(3.0*logR);
494 return Moverrhomean * f * (
y*
y) * nu;
497 auto integrand_twohalo = [&eta_hmcode,&logR_of_lognu_spline,&y_of_logR_and_logk_spline,&pdf_of_nu,&bias_of_nu](
double lognu,
double logk){
499 const double logR = logR_of_lognu_spline(lognu);
500 const double y = y_of_logR_and_logk_spline(logR, logk + lognu*eta_hmcode);
501 const double f = pdf_of_nu(nu);
502 const double bias = bias_of_nu(nu);
503 return bias * f *
y * nu;
507 auto integrand_norm_onehalo = [&pdf_of_nu](
double lognu){
509 const double f = pdf_of_nu(nu);
514 auto integrand_norm_twohalo = [&pdf_of_nu,&bias_of_nu](
double lognu){
516 const double f = pdf_of_nu(nu);
517 const double bias = bias_of_nu(nu);
518 return bias * f * nu;
523 double normone = 0.0;
524 double normtwo = 0.0;
525 for(
const auto lognu : lognu_array){
526 normone += integrand_norm_onehalo(lognu);
527 normtwo += integrand_norm_twohalo(lognu);
529 normone *= (lognu_array[1]-lognu_array[0]);
530 normtwo *= (lognu_array[1]-lognu_array[0]);
532 if(std::abs(normone-1.0) > 0.001 or std::abs(normtwo-1.0) > 0.001){
534 std::cout <<
"Warning: Unity check failed for Int f(nu)dnu = " << normone <<
" Int b(nu)f(nu)dnu = " << normtwo <<
"\n";
535 std::cout <<
"Could be that massfunction is not normalized. In that case this should be unity: " << normtwo/normone <<
"\n";
538 DVector logDelta_onehalo_array;
539 DVector logDelta_twohalo_array;
541 for(
const auto logk : logk_array){
545 double onehalo = 0.0;
546 double twohalo = 0.0;
548 for(
const auto lognu : lognu_array){
549 onehalo += integrand_onehalo(lognu, logk);
550 twohalo += integrand_twohalo(lognu, logk);
552 onehalo *= (lognu_array[1]-lognu_array[0]);
553 twohalo *= (lognu_array[1]-lognu_array[0]);
556 onehalo *= (
k*
k*
k)/(2.0*M_PI*M_PI) / normone;
557 twohalo *= 1.0 / normtwo;
558 twohalo = twohalo * twohalo *
std::exp(logDeltaLin_of_logk(logk));
559 full = onehalo + twohalo;
561 logDelta_onehalo_array.push_back(std::log(onehalo));
562 logDelta_twohalo_array.push_back(std::log(twohalo));
563 logDelta_full_array.push_back(std::log(full));
567 logDelta_onehalo_of_logk_spline =
Spline(logk_array, logDelta_onehalo_array,
"logDelta1h(logk)");
568 logDelta_twohalo_of_logk_spline =
Spline(logk_array, logDelta_twohalo_array,
"logDelta2h(logk)");
569 logDelta_full_of_logk_spline =
Spline(logk_array, logDelta_full_array,
"logDelta(logk)");
581 const Spline & growthfactor_of_x_spline,
582 const Spline & logsigma_of_logR_spline,
583 Spline & formationredshift_of_logM_spline,
587 double massfraction){
591 auto compute_formation_redshift = [&](
double M){
592 const double Mform = massfraction *
M;
593 const double R =
RofM(Mform,
OmegaM, xcollapse);
594 auto condition = [&](
double x){
595 const double xminspline = growthfactor_of_x_spline.
get_xrange().first;
596 double growthratio = growthfactor_of_x_spline(
x) / growthfactor_of_x_spline(xcollapse);
598 growthratio = growthfactor_of_x_spline(xminspline) / growthfactor_of_x_spline(xcollapse);
601 const double sigma =
std::exp(logsigma_of_logR_spline(std::log(R)));
602 return growthratio * sigma -
deltac;
604 double xformation = xcollapse;
615 const double Rmin = 1e-8, Rmax = 1e8;
616 const int npts_R = 10000;
622 for(
const auto logR : logR_array){
624 const double xformation = compute_formation_redshift(
M);
625 formationtime_array.push_back(
std::exp(-xformation)-1.0);
626 logM_array.push_back(std::log(
M));
628 formationredshift_of_logM_spline =
Spline(logM_array, formationtime_array,
"zf(logM)");
636 Spline logDelta_of_logk_spline,
644 logDelta_of_logk_spline(logDelta_of_logk_spline),
645 xinput_pofk(xinput_pofk),
648 xini_spherical_collapse(xini),
649 npts_spherical_collapse(npts) {
659 const double A_ST = hm->A_ST;
660 const double p_ST = hm->p_ST;
661 const double a_ST = hm->a_ST;
662 return A_ST * (1.0 + std::pow(a_ST*nu*nu,-p_ST)) *
std::exp(-a_ST*nu*nu/2.0);
667 const double deltac = hm->deltac;
668 const double p_ST = hm->p_ST;
669 const double a_ST = hm->a_ST;
670 return 1.0 + (a_ST*nu*nu-1.0)/
deltac + 2.0*p_ST/
deltac/(1.0+std::pow(a_ST*nu*nu,p_ST));
678 return [](
double kR){
679 if(kR < 1e-6)
return 1.0 - kR*kR/10.;
680 return 3.0/(kR*kR*kR)*(std::sin(kR)-kR*std::cos(kR));
704 std::cout <<
"\n#=====================================================\n";
705 std::cout <<
"# Initializing the halomodel\n";
706 std::cout <<
"#=====================================================\n";
707 std::cout <<
"# OmegaM " <<
OmegaM <<
"\n";
708 std::cout <<
"# HMCode? " << std::boolalpha <<
hmcode <<
"\n";
716 std::cout <<
"Performing spherical collapse and computing growth\n";
738 std::cout <<
"Computing growth\n";
753 xcollapse = std::log(1.0/(1.0 + zcollapse));
756 std::cout <<
"\n#=====================================================\n";
757 std::cout <<
"# Compute at z = " << zcollapse <<
"\n";
758 std::cout <<
"#=====================================================\n";
766 const Func1 logDeltaLin_of_logk = [&](
double logk){
775 std::cout <<
"Computing sigmas\n";
797 std::cout <<
"Computing DeltaVir and deltac\n";
813 std::cout <<
"Computing nu-R relation\n";
826 neff = neff_data.second;
833 std::cout <<
"# Applying HMCode fits\n";
845 std::cout <<
"# f = " <<
hmcode_f <<
"\n";
847 std::cout <<
"# eta = " <<
hmcode_eta <<
"\n";
850 std::cout <<
"# deltac = " <<
deltac <<
"\n";
851 std::cout <<
"# DeltaVir = " <<
DeltaVir <<
"\n";
859 std::cout <<
"Computing formation redshifts\n";
872 const Func2 rho_function = [&](
double r,
double M){
880 std::cout <<
"Computing fourier transform of rho\n";
896 const Func1 pdf_of_nu = [&](
double nu){
899 const Func1 bias_of_nu = [&](
double nu){
907 std::cout <<
"Computing massfunction\n";
924 std::cout <<
"Computing halomodel pofk\n";
947 DVector logDeltaHM_onehalo_of_logk, logDeltaHM_twohalo_of_logk, logDeltaHM_full_of_logk;
950 for(
auto logk : logk_array){
955 double Delta_lin =
std::exp(logDeltaLin_of_logk(logk));
959 Delta_twohalo = Delta_lin;
963 Delta_twohalo *= std::max(1e-12,(1.0 -
hmcode_f * std::pow( std::tanh(
k *
sigmav / std::sqrt(
hmcode_f)), 2) ));
969 double factor = k_over_kstar < 1e-5 ? k_over_kstar*k_over_kstar : 1.0 -
std::exp(-k_over_kstar*k_over_kstar);
970 Delta_onehalo *= factor;
974 if(Delta_onehalo < 1e-30) Delta_onehalo = 1e-30;
975 if(Delta_twohalo < 1e-30) Delta_twohalo = 1e-30;
976 if(Delta_full< 1e-30) Delta_full = 1e-30;
982 Delta_full = Delta_onehalo + Delta_twohalo;
984 logDeltaHM_onehalo_of_logk.push_back(std::log(Delta_onehalo));
985 logDeltaHM_twohalo_of_logk.push_back(std::log(Delta_twohalo));
986 logDeltaHM_full_of_logk.push_back(std::log(Delta_full));
1003 if(hm->cofM_model ==
"Bullock2001"){
1004 const double zf = hm->formationredshift_of_logM_spline(std::log(
M));
1005 const double z =
std::exp(-hm->xcollapse)-1;
1006 return hm->hmcode_cmin * std::max(1.0, (1.0+zf)/(1+
z) );
1009 return hm->cofM_0 * std::pow(
M / hm->cofM_M0, -hm->cofM_beta) *
std::exp(hm->xcollapse);
1018 return [&](
double r,
double M,
HaloModel *hm){
1019 const double DeltaVir = hm->DeltaVir;
1020 const double OmegaM = hm->OmegaM;
1021 const double x = hm->xcollapse;
1022 const double c = hm->halo_mass_concentration_relation(
M,hm);
1024 double Rvir = R / std::pow(DeltaVir,1.0/3.0);
1032 const double rs = Rvir / c;
1033 if(r > Rvir)
return 0.0;
1034 return std::pow(r/rs, 3) / ( (r/rs) * (1 + r/rs) * (1 + r/rs) ) / (std::log(1 + c) - c/(1 + c));
1044 const auto x_array =
FML::MATH::linspace(std::log(1.0/(1.0+zmax)), std::log(1.0/(1.0+zmin)), npts_z);;
1049 fp <<
"# z deltaC(z) DeltaVir(z) kstar(z) fdamp(z) eta(z) cmin(z) [HMCode]\n";
1050 for(
const auto x : x_array){
1052 fp << std::setw(10) <<
z <<
" ";
1065 fp <<
"# z deltaC(z) DeltaVir(z)\n";
1066 for(
const auto x : x_array){
1068 fp << std::setw(10) <<
z <<
" ";
1087 fp <<
"# M (Msun/h) dlogndlogM n (h/Mpc)^3 R (Mpc/h) Rvir (Mpc/h) nu [z = " << std::to_string(
std::exp(-
xcollapse)-1) <<
"]\n";
1088 for(
const auto logM : logM_array){
1092 const double logR = std::log(R);
1097 fp << std::setw(10) <<
M <<
" ";
1098 fp << std::setw(10) << dlogndlogM <<
" ";
1099 fp << std::setw(10) << n <<
" ";
1100 fp << std::setw(10) << R <<
" ";
1101 fp << std::setw(10) << Rvir <<
" ";
1102 fp << std::setw(10) << nu <<
" ";
1117 Spline logDeltaNL_of_logk_spline;
1124 fp <<
"# k (h/Mpc) P_NL(k) P_Lin(k) P_1h(k) P_2h(k) (Mpc/h)^3 [z = " << std::to_string(
std::exp(-
xcollapse)-1) <<
"]\n";
1125 for(
const auto logk : logk_array){
1127 const double Delta_over_P = 2.0 * M_PI * M_PI / (
k*
k*
k);
1129 fp << std::setw(10) <<
k <<
" ";
1145 const bool extraverbose =
true;
1147 std::cout <<
"\n#=====================================================\n";
1148 std::cout <<
"# Halomodel info ( z = " << (isnan(
xcollapse) ?
" not yet set " : std::to_string(
std::exp(-
xcollapse)-1.0)) <<
" )\n";
1149 std::cout <<
"#=====================================================\n";
1150 std::cout <<
"# OmegaM : " <<
OmegaM <<
"\n";
1151 std::cout <<
"# fnu : " <<
fnu <<
"\n";
1157 std::cout <<
"# with a : " <<
a_ST <<
" p : " <<
p_ST <<
"\n";
1158 std::cout <<
"# Density profile : " <<
halo_profile <<
"\n";
1160 std::cout <<
"# with c(M) : " <<
cofM_model <<
"\n";
1162 std::cout <<
"# Running with HMCode settings\n";
1166 const Func1 logDeltaLin_of_logk = [&](
double logk){
1169 Spline _logsigma_of_logR_spline;
1171 logDeltaLin_of_logk,
1173 _logsigma_of_logR_spline,
1176 double sigma8ic =
std::exp(_logsigma_of_logR_spline(std::log(8.0)));
1177 std::cout <<
"# sigma8 of provided Plin at z = " <<
std::exp(-
xinput_pofk)-1 <<
" is " << sigma8ic <<
"\n";
1178 std::cout <<
"# NB: compute_at_redshift has not yet been run so not much more computed\n";
1183 std::cout <<
"# deltaC : " <<
deltac <<
"\n";
1184 std::cout <<
"# DeltaVir : " <<
DeltaVir <<
"\n";
1194 std::cout <<
"# sigmav : " <<
sigmav <<
" (Mpc/h)\n";
1195 std::cout <<
"# sigmav100 : " <<
sigmav100 <<
" (Mpc/h)\n";
1196 std::cout <<
"# rnl_nu : " <<
rnl_nu <<
" (Mpc/h)\n";
1197 std::cout <<
"# knl_nu : " << 1.0/
rnl_nu <<
" (h/Mpc)\n";
1198 std::cout <<
"# neff : " <<
neff <<
"\n";
1211 double sigma8ofx =
sigma8 * Dofx_over_Dofx_sigma;
1213 double deltacofx = 1.59 + 0.0314*std::log(sigma8ofx);
1214 deltacofx *= 1.0 + 0.0123*std::log10(OmegaMofx);
1215 deltacofx *= (1.+0.262*
fnu);
1221 DeltaVirofx *= (1.+0.916*
fnu);
1227 double sigma8ofx =
sigma8 * Dofx_over_Dofx_sigma;
1228 double etaofx = 0.603-0.3*sigma8ofx;
1234 double sigmav100ofx =
sigmav100 * Dofx_over_Dofx_sigma;
1235 double fofx = std::max(std::min(0.0095*std::pow(sigmav100ofx, 1.37), 0.99), 1e-3);
1241 double sigmavofx =
sigmav * Dofx_over_Dofx_sigma;
1242 double kstarofx = 0.584/sigmavofx;
1252 return 3.24*std::pow(1.85,
neff);
const std::string filename
Class for computing the standard halomodel predictions for plus or just doing spherical collapse.
std::string halo_massfunction
HaloBiasFunction halo_bias_function
void output_nofM(std::string filename, double Mmin=1e8, double Mmax=1e16, int npts_M=100) const
Spline delta_ini_of_x_spline
RhoFunction halo_density_profile
double get_f_hmcode(double x) const
Spline2D y_of_logR_and_logk_spline
Spline deltac_of_x_spline
Spline logsigma_of_logR_spline
Spline lognu_of_logR_spline
Spline formationredshift_of_logM_spline
Spline logDeltaHM_full_of_logk_spline
Spline logDelta_of_logk_spline
double DeltaVir_multiplier
void compute_at_redshift(double zcollapse)
double get_DeltaVir_hmcode(double x) const
double xini_spherical_collapse
Spline DeltaVir_of_x_spline
int npts_spherical_collapse
std::shared_ptr< DVector > fiducial_logR_array
Spline growthrate_of_x_spline
WindowFunction fourier_window_function
double get_cmin_hmcode(double x) const
HaloMultiplicityFunction halo_multiplicity_function
Spline growthfactor_of_x_spline
void output_deltac(std::string filename, double zmin=0.0, double zmax=10.0, int npts_z=100) const
double get_deltac_hmcode(double x) const
Spline logR_of_lognu_spline
std::shared_ptr< DVector > fiducial_logk_array
void output_pofk(std::string filename, double kmin=1e-5, double kmax=100, int npts_k=1000) const
SphericalCollapseModel spcmodel
Spline logDeltaHM_twohalo_of_logk_spline
Spline logDeltaHM_onehalo_of_logk_spline
double get_kstar_hmcode(double x) const
double get_alpha_hmcode() const
double get_eta_hmcode(double x) const
Spline dndlogM_of_logM_spline
Class for doing general spherical collapse calculations, i.e.
void run_at_all_redshifts(Spline &deltac_of_x_spline, Spline &DeltaVir_of_x_spline, Spline &xta_of_x_spline, Spline &xnl_of_x_spline, Spline &xvir_of_x_spline, Spline &delta_ini_of_x_spline, Spline &growthfactor_of_x_spline, Spline &growthrate_of_x_spline)
Perform the spherical collapse calculation for a given model with collapse at for several values of ...
The class contains all the info about the model needed to run the spherical collapse and halomodel Co...
void info() const
Print useful info.
This is a wrapper class for easy use of GSL splines It is (OpenMP) thread safe as long as splines are...
double deriv_x(double x) const
Get the value of the first derivative of the spline.
DVector get_x_data()
Get the raw GSL data for x used to create the spline.
std::pair< double, double > get_xrange() const
Get the range the spline was created on.
void StartTiming(const char *name)
Start timing.
void PrintAllTimings() const
Output all the recorded timings.
double EndTiming(const char *name, bool print=false)
End timing.
FML::INTERPOLATION::SPLINE::Spline2D Spline2D
std::function< double(double)> WindowFunction
double RofM(double M, double OmegaM, double x)
void compute_lognu_of_logR(const double deltac, const Spline &logsigma_of_logR_spline, Spline &lognu_of_logR_spline, Spline &logR_of_lognu_spline, const DVector *fiducial_logR_array)
std::function< double(double, HaloModel *hm)> HaloMultiplicityFunction
void compute_sigma(const Func1 logDelta_of_logk, const WindowFunction window_of_kR, Spline &logsigma_of_logR_spline, const DVector *fiducial_logR_array, const DVector *fiducial_logk_array)
void powerlaw_extend_logY_of_logx_spline(Spline &logY_of_logx_spline, double xmin_new, double xmax_new, int npts_new, std::string label="logY(log(x)) extrapolated")
double compute_sigmav(const Func1 logDelta_of_logk, const WindowFunction window_of_kR, double R, const DVector *fiducial_logk_array)
FML::SOLVERS::ODESOLVER::DVector DVector
std::function< double(double, HaloModel *hm)> HaloBiasFunction
std::pair< double, double > compute_neff(const Spline &logsigma_of_logR_spline, const Spline &lognu_of_logR_spline)
void compute_one_and_two_halo_terms(const Spline &logR_of_lognu_spline, const Spline2D &y_of_logR_and_logk_spline, Spline &logDelta_onehalo_of_logk_spline, Spline &logDelta_twohalo_of_logk_spline, Spline &logDelta_full_of_logk_spline, const Func1 &logDeltaLin_of_logk, const Func1 &pdf_of_nu, const Func1 &bias_of_nu, const double eta_hmcode, const double kmin, const double kmax, const int npts_k)
cofMFunction get_nfw_halo_mass_concentration_relation()
void compute_formation_redshift_factor(const Spline &growthfactor_of_x_spline, const Spline &logsigma_of_logR_spline, Spline &formationredshift_of_logM_spline, double deltac, double OmegaM, double xcollapse, double massfraction)
DVector compute_rho_fourier_single(const Func2 &rho_function, const DVector &k_array, const double M, const double Rvir)
HaloBiasFunction get_sheth_tormen_halo_bias_function()
std::function< double(double, double, HaloModel *hm)> RhoFunction
FML::INTERPOLATION::SPLINE::Spline Spline
double MofRvir(double Rvir, double DeltaVir, double OmegaM, double x)
WindowFunction get_tophat_window_fourier()
double RvirofM(double M, double DeltaVir, double OmegaM, double x)
RhoFunction get_nfw_halo_density_profile()
std::function< double(double, HaloModel *hm)> cofMFunction
HaloMultiplicityFunction get_sheth_tormen_halo_multiplicity_function()
void compute_rho_fourier(const Func2 &rho_function, Spline2D &y_of_logR_and_logk_spline, const double DeltaVir, const double OmegaM, const double x, const DVector *fiducial_logR_array, const DVector *fiducial_logk_array)
void compute_massfunction(const Spline &logR_of_lognu_spline, const Spline &lognu_of_logR_spline, Spline &dndlogM_of_logM_spline, Spline &n_of_logM_spline, const Func1 &pdf_of_nu, const double OmegaM, const double x)
void read_pofk_file(const std::string filename_pofk, Spline &logDelta_of_logk_spline, double normalization, int col_k, int col_pofk)
FML::SOLVERS::ODESOLVER::DVector2D DVector2D
std::function< double(double, double)> Func2
double MofR(double R, double OmegaM, double x)
std::function< double(double)> Func1
void compute_growthfactor(const SphericalCollapseModel &model, Spline &growthfactor_of_x_spline, Spline &growthrate_of_x_spline, const double xini, const double xend, const int npts)
Computes the growth factor (not normalized) and growth rate for a given model and returns splines wit...
DVector2D loadtxt(std::string filename, int nreserve_rows, int nreserve_cols)
Similar to pythons loadtxt function Gives warning if file is not regular Skips lines starting with #,...
DVector linspace(double xmin, double xmax, int num)
Python linspace. Generate a lineary spaced array.
double find_root_bisection(const std::function< double(double)> &function, std::pair< double, double > xrange, double epsilon)
Find roots using bisection.