50 return 0.5*(1.+erf((log10(x)-logMmin)/logsigma_c));
59 return 0.5*pow((x-M0)/M1,
alpha);
68 return (M_h>M_min) ? 1. : 0.;
77 return pow(x/M1,
alpha);
89 auto fsigma_c = [](
double x)
92 const double sigma_infinity = 0.1592;
93 const double sigma_1 = 0.0460;
94 const double chsi = 4.2503;
95 const double M_2 = pow(10, 11.8045);
97 return sigma_infinity + sigma_1 * (1. - (2. /
cbl::par::pi) * atan(chsi * log10(x / M_2)));
101 auto fPhi_s = [](
double x)
103 const double lamda = 0.8032;
104 const double phi_0 = pow(10., -10.8924);
106 return phi_0 * pow(x, lamda);
110 auto falpha_s = [](
double x)
112 const double alpha_infinity = -1.3676;
113 const double alpha_1 = -0.0524;
114 const double zeta = 9.5727;
115 const double M_3 = pow(10, 12.3646);
117 return alpha_infinity + alpha_1 * (1. - (2. /
cbl::par::pi) * atan(zeta * log10(x / M_3)));
122 auto mag_mstar = [&cosm](
double x)
124 const double MoverL = 1.;
125 return MoverL*pow(10., (4.77-x)/2.5);
128 auto startTimer = chrono::steady_clock::now();
131 double starMass_threshold = 0;
136 double logsigma_c = 0.;
170 if (parameter.size() < 1)
171 parameter = {-99., -99., -99., -99., -99., -99., -99., -99., -99., -99., -99., -99., -99., -99., -99., -99.};
175 if (HOD_Type==HODType::_Zehavi11_) {
176 if (threshold == -22)
177 starMass_threshold = mag_mstar(-22.);
178 else if (threshold == -21.5)
179 starMass_threshold = mag_mstar(-21.5);
180 else if (threshold == -21.)
181 starMass_threshold = mag_mstar(-21.);
182 else if (threshold == -20.5)
183 starMass_threshold = mag_mstar(-20.5);
184 else if (threshold == -20.)
185 starMass_threshold = mag_mstar(-20.);
186 else if (threshold == -19.5)
187 starMass_threshold = mag_mstar(-19.5);
188 else if (threshold == -19.)
189 starMass_threshold = mag_mstar(-19.);
190 else if (threshold == -18.5)
191 starMass_threshold = mag_mstar(-18.5);
192 else if (threshold == -18.)
193 starMass_threshold = mag_mstar(-18.);
195 ErrorCBL(
"Not default parameters available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
197 for (
int ii = 0; ii < 5; ii++) {
198 if (parameter[ii] == -99) {
200 if (threshold == -22)
201 parameter[0] = 14.06;
202 else if (threshold == -21.5)
203 parameter[0] = 13.38;
204 else if (threshold == -21.)
205 parameter[0] = 12.78;
206 else if (threshold == -20.5)
207 parameter[0] = 12.14;
208 else if (threshold == -20.)
209 parameter[0] = 11.83;
210 else if (threshold == -19.5)
211 parameter[0] = 11.57;
212 else if (threshold == -19.)
213 parameter[0] = 11.45;
214 else if (threshold == -18.5)
215 parameter[0] = 11.33;
216 else if (threshold == -18.)
217 parameter[0] = 11.18;
219 ErrorCBL(
"Not default parameters available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
222 if (threshold == -22)
224 else if (threshold == -21.5)
226 else if (threshold == -21.)
228 else if (threshold == -20.5)
230 else if (threshold == -20.)
232 else if (threshold == -19.5)
234 else if (threshold == -19.)
236 else if (threshold == -18.5)
238 else if (threshold == -18.)
241 ErrorCBL(
"Not default parameters available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
244 if (threshold == -22)
245 parameter[2] = pow(10., 13.72);
246 else if (threshold == -21.5)
247 parameter[2] = pow(10., 13.35);
248 else if (threshold == -21.)
249 parameter[2] = pow(10., 12.71);
250 else if (threshold == -20.5)
251 parameter[2] = pow(10, 11.62);
252 else if (threshold == -20.)
253 parameter[2] = pow(10., 12.35);
254 else if (threshold == -19.5)
255 parameter[2] = pow(10., 12.33);
256 else if (threshold == -19.)
257 parameter[2] = pow(10., 9.77);
258 else if (threshold == -18.5)
259 parameter[2] = pow(10., 8.99);
260 else if (threshold == -18.)
261 parameter[2] = pow(10., 9.81);
263 ErrorCBL(
"Not default parameters available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
266 if (threshold == -22)
267 parameter[3] = pow(10, 14.80);
268 else if (threshold == -21.5)
269 parameter[3] = pow(10., 14.20);
270 else if (threshold == -21.)
271 parameter[3] = pow(10., 13.76);
272 else if (threshold == -20.5)
273 parameter[3] = pow(10., 13.43);
274 else if (threshold == -20.)
275 parameter[3] = pow(10., 12.98);
276 else if (threshold == -19.5)
277 parameter[3] = pow(10., 12.75);
278 else if (threshold == -19.)
279 parameter[3] = pow(10., 12.63);
280 else if (threshold == -18.5)
281 parameter[3] = pow(10., 12.50);
282 else if (threshold == -18.)
283 parameter[3] = pow(10., 12.42);
285 ErrorCBL(
"Not default parameters available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
288 if (threshold == -22)
290 else if (threshold == -21.5)
292 else if (threshold == -21.)
294 else if (threshold == -20.5)
296 else if (threshold == -20.)
298 else if (threshold == -19.5)
300 else if (threshold == -19.)
302 else if (threshold == -18.5)
304 else if (threshold == -18.)
307 ErrorCBL(
"Not default parameters available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
327 if (parameter[5] == -99)
328 parameter[5] = 0.0267;
329 if (parameter[6] == -99)
330 parameter[6] = pow(10, 11.9347);
331 if (parameter[7] == -99)
332 parameter[7] = 1.0059;
333 if (parameter[8] == -99)
334 parameter[8] = 0.5611;
335 if (parameter[9] == -99)
341 if (parameter[10] == -99)
342 parameter[10] = 0.0186;
343 if (parameter[11] == -99)
344 parameter[11] = pow(10, 12.1988);
345 if (parameter[12] == -99)
346 parameter[12] = 0.7817;
347 if (parameter[13] == -99)
348 parameter[13] = 0.7334;
349 if (parameter[14] == -99)
355 if (parameter[15] == -99)
364 logMmin = parameter[0];
365 logsigma_c = parameter[1];
368 alpha = parameter[4];
373 beta_c = parameter[7];
374 gamma_c = parameter[8];
375 sigma_c = parameter[9];
379 M1_s = parameter[11];
380 beta_s = parameter[12];
381 gamma_s = parameter[13];
382 Phi_s = parameter[14];
383 alpha_s = parameter[15];
385 cout <<
" Chosen parameters for HOD: " << endl;
386 cout <<
" LogMmin = " << logMmin << endl;
387 cout <<
" Logsigma_c = " << logsigma_c << endl;
388 cout <<
" M0 = " << M0 <<
" M_sun/h" << endl;
389 cout <<
" M1 = " << M1 <<
" M_sun/h" << endl;
390 cout <<
" alpha = " <<
alpha << endl;
391 cout <<
" Minimum stellar mass = " << starMass_threshold <<
" M_sun/h" << endl
394 cout <<
" Chosen parameters for stellar masses: " << endl;
395 cout <<
" k_c = " << k_c << endl;
396 cout <<
" M1_c = " << M1_c <<
" M_sun" << endl;
397 cout <<
" beta_c = " << beta_c << endl;
398 cout <<
" gamma_c = " << gamma_c << endl;
399 cout <<
" sigma_c = " << sigma_c << endl;
401 cout <<
" k_s = " << k_s << endl;
402 cout <<
" M1_s = " << M1_s <<
" M_sun" << endl;
403 cout <<
" beta_s = " << beta_s << endl;
404 cout <<
" gamma_s = " << gamma_s << endl;
405 cout <<
" Phi_s = " << Phi_s << endl;
406 cout <<
" alpha_s = " << alpha_s << endl
410 else if (HOD_Type == HODType::_Zehavi05_) {
411 if (threshold == -22)
412 starMass_threshold = mag_mstar(-22.);
413 else if (threshold == -21.5)
414 starMass_threshold = mag_mstar(-21.5);
415 else if (threshold == -21.)
416 starMass_threshold = mag_mstar(-21.);
417 else if (threshold == -20.5)
418 starMass_threshold = mag_mstar(-20.5);
419 else if (threshold == -20.)
420 starMass_threshold = mag_mstar(-20.);
421 else if (threshold == -19.5)
422 starMass_threshold = mag_mstar(-19.5);
423 else if (threshold == -19.)
424 starMass_threshold = mag_mstar(-19.);
425 else if (threshold == -18.5)
426 starMass_threshold = mag_mstar(-18.5);
427 else if (threshold == -18.)
428 starMass_threshold = mag_mstar(-18.);
430 ErrorCBL(
"Not default parameters available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
432 for (
int ii = 0; ii < 3; ii++) {
433 if (parameter[ii] == -99) {
435 if (threshold == -22)
436 parameter[0] = pow(10, 13.91);
437 else if (threshold == -21.5)
438 parameter[0] = pow(10, 13.27);
439 else if (threshold == -21.)
440 parameter[0] = pow(10, 12.72);
441 else if (threshold == -20.5)
442 parameter[0] = pow(10, 12.30);
443 else if (threshold == -20.)
444 parameter[0] = pow(10, 12.01);
445 else if (threshold == -19.5)
446 parameter[0] = pow(10, 11.76);
447 else if (threshold == -19.)
448 parameter[0] = pow(10, 11.59);
449 else if (threshold == -18.5)
450 parameter[0] = pow(10, 11.44);
451 else if (threshold == -18.)
452 parameter[0] = pow(10, 11.27);
454 ErrorCBL(
"Not default parameters available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
457 if (threshold == -22)
458 parameter[1] = pow(10, 14.92);
459 else if (threshold == -21.5)
460 parameter[1] = pow(10., 14.60);
461 else if (threshold == -21.)
462 parameter[1] = pow(10., 14.09);
463 else if (threshold == -20.5)
464 parameter[1] = pow(10., 13.67);
465 else if (threshold == -20.)
466 parameter[1] = pow(10., 13.42);
467 else if (threshold == -19.5)
468 parameter[1] = pow(10., 13.15);
469 else if (threshold == -19.)
470 parameter[1] = pow(10., 12.94);
471 else if (threshold == -18.5)
472 parameter[1] = pow(10., 12.77);
473 else if (threshold == -18.)
474 parameter[1] = pow(10., 12.57);
476 ErrorCBL(
"Not default parameter available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
479 if (threshold == -22)
481 else if (threshold == -21.5)
483 else if (threshold == -21.)
485 else if (threshold == -20.5)
487 else if (threshold == -20.)
489 else if (threshold == -19.5)
491 else if (threshold == -19.)
493 else if (threshold == -18.5)
495 else if (threshold == -18.)
498 ErrorCBL(
"not default parameter available for this threshold",
"Catalogue",
"HODCatalogue.cpp");
503 if (parameter[3] == -99)
504 parameter[3] = 0.0267;
505 if (parameter[4] == -99)
506 parameter[4] = pow(10, 11.9347);
507 if (parameter[5] == -99)
508 parameter[5] = 1.0059;
509 if (parameter[6] == -99)
510 parameter[6] = 0.5611;
511 if (parameter[7] == -99)
516 if (parameter[8] == -99)
517 parameter[8] = 0.0186;
518 if (parameter[9] == -99)
519 parameter[9] = pow(10, 12.1988);
520 if (parameter[10] == -99)
521 parameter[10] = 0.7817;
522 if (parameter[11] == -99)
523 parameter[11] = 0.7334;
524 if (parameter[12] == -99)
530 if (parameter[13] == -99)
536 M_min = parameter[0];
538 alpha = parameter[2];
542 beta_c = parameter[5];
543 gamma_c = parameter[6];
544 sigma_c = parameter[7];
548 beta_s = parameter[10];
549 gamma_s = parameter[11];
550 Phi_s = parameter[12];
551 alpha_s = parameter[13];
553 coutCBL <<
" Chosen parameters for HOD: " << endl;
554 coutCBL <<
" M_min = " << M_min <<
" M_sun/h" << endl;
555 coutCBL <<
" M1 = " << M1 <<
" M_sun/h" << endl;
557 coutCBL <<
" Minimum stellar mass = " << starMass_threshold <<
"M_sun/h" << endl
560 coutCBL <<
" Chosen parameters for stellar masses: " << endl;
561 coutCBL <<
" k_c = " << k_c << endl;
562 coutCBL <<
" M1_c = " << M1_c <<
" M_sun" << endl;
563 coutCBL <<
" beta_c = " << beta_c << endl;
564 coutCBL <<
" gamma_c = " << gamma_c << endl;
565 coutCBL <<
" sigma_c = " << sigma_c << endl;
567 coutCBL <<
" k_s = " << k_s << endl;
568 coutCBL <<
" M1_s = " << M1_s <<
" M_sun" << endl;
569 coutCBL <<
" beta_s = " << beta_s << endl;
570 coutCBL <<
" gamma_s = " << gamma_s << endl;
571 coutCBL <<
" Phi_s = " << Phi_s << endl;
572 coutCBL <<
" alpha_s = " << alpha_s << endl << endl;
578 else if (HOD_Type == HODType::_Moster10_)
582 ErrorCBL(
"Warning: threshold in Moster is minimum stellar mass!",
"Catalogue",
"HODCatalogue.cpp");
586 if (parameter[0] == -99)
587 parameter[0] = 0.0297;
588 if (parameter[1] == -99)
589 parameter[1] = pow(10., 11.9008);
590 if (parameter[2] == -99)
591 parameter[2] = 1.0757;
592 if (parameter[3] == -99)
593 parameter[3] = 0.6310;
594 if (parameter[4] == -99)
599 if (parameter[5] == -99)
600 parameter[5] = 0.0198;
601 if (parameter[6] == -99)
602 parameter[6] = pow(10., 12.0640);
603 if (parameter[7] == -99)
604 parameter[7] = 0.8097;
605 if (parameter[8] == -99)
606 parameter[8] = 0.6910;
607 if (parameter[9] == -99)
613 if (parameter[10] == -99)
619 starMass_threshold = threshold;
623 beta_c = parameter[2];
624 gamma_c = parameter[3];
625 sigma_c = parameter[4];
629 beta_s = parameter[7];
630 gamma_s = parameter[8];
631 Phi_s = parameter[9];
632 alpha_s = parameter[10];
635 coutCBL <<
" k_c = " << k_c << endl;
636 coutCBL <<
" M1_c = " << M1_c <<
" M_sun" << endl;
637 coutCBL <<
" beta_c = " << beta_c << endl;
638 coutCBL <<
" gamma_c = " << gamma_c << endl;
639 coutCBL <<
" sigma_c = " << sigma_c << endl;
641 coutCBL <<
" k_s = " << k_s << endl;
642 coutCBL <<
" M1_s = " << M1_s <<
" M_sun" << endl;
643 coutCBL <<
" beta_s = " << beta_s << endl;
644 coutCBL <<
" gamma_s = " << gamma_s << endl;
645 coutCBL <<
" Phi_s = " << Phi_s << endl;
646 coutCBL <<
" alpha_s = " << alpha_s << endl << endl;
650 ErrorCBL(
"HOD_type not available...",
"Catalogue",
"HODCatalogue.cpp");
659 vector<double> par_stellar_c = {k_c, M1_c, beta_c, gamma_c, sigma_c};
662 const cbl::distribution_func CMF_c = [&cosm, &fsigma_c, &starMass_threshold] (
double x,
const shared_ptr<void> modelInput, vector<double> par_stellar_c)
664 const vector<double> fix_par = *static_pointer_cast<std::vector<double>>(modelInput);
665 if (par_stellar_c[4] == -99)
666 par_stellar_c[4] = fsigma_c(fix_par[0]);
667 double m_c = 2. * fix_par[0] * par_stellar_c[0] * pow(pow(fix_par[0] / par_stellar_c[1], -par_stellar_c[2]) + pow(fix_par[0] / par_stellar_c[1], par_stellar_c[3]), -1);
669 return (1. / (par_stellar_c[4] * sqrt(2. *
cbl::par::pi) * x * log(10))) * exp(-pow(log10(x / m_c) / (sqrt(2) * par_stellar_c[4]), 2.));
674 vector<double> par_stellar_s = {k_s, M1_s, beta_s, gamma_s, Phi_s, alpha_s};
677 const cbl::distribution_func CMF_s = [&cosm, &fPhi_s, &falpha_s](
double x,
const shared_ptr<void> modelInput, vector<double> par_stellar_s)
679 const vector<double> fix_par = *static_pointer_cast<std::vector<double>>(modelInput);
680 if (par_stellar_s[4] == -99)
681 par_stellar_s[4] = fPhi_s(fix_par[0]);
682 if (par_stellar_s[5] == -99)
683 par_stellar_s[5] = falpha_s(fix_par[0]);
684 double m_s = 2. * fix_par[0] * par_stellar_s[0] * pow(pow(fix_par[0] / par_stellar_s[1], -par_stellar_s[2]) + pow(fix_par[0] / par_stellar_s[1], par_stellar_s[3]), -1.);
686 return (par_stellar_s[4] / m_s) * pow(x / m_s, par_stellar_s[5]) * exp(-pow((x / m_s), 2.));
696 auto Average_c_Moster_2010 = [&cosm, &fsigma_c] (
double x,
double star_threshold,
double k_c,
double M1_c,
double beta_c,
double gamma_c,
double sigma_c)
699 sigma_c = fsigma_c(x);
700 double m_c = 2. * x * k_c / (pow(x / M1_c, -beta_c) + pow(x / M1_c, gamma_c));
702 return 0.5 * (1 - erf(log10(star_threshold / m_c) / (sqrt(2) * sigma_c)));
705 auto Average_s_Moster_2010 = [&fPhi_s, &falpha_s](
double x,
double star_threshold,
double k_s,
double M1_s,
double beta_s,
double gamma_s,
double Phi_s,
double alpha_s)
710 alpha_s = falpha_s(x);
711 double m_s = 2. * x * k_s * pow(pow(x / M1_s, -beta_s) + pow(x / M1_s, gamma_s), -1.);
712 double lower = pow(star_threshold / m_s, 2.);
714 return (Phi_s / 2.) * gsl_sf_gamma_inc(0.5 * alpha_s + 0.5, lower);
723 vector<double> parameter_NFW{z};
728 const double A = 9.33 * 1e-4;
729 const double zres = sqrt(1 + z);
730 const double alpha_SubHalo = -0.9;
731 const double betha_SubHalo = -12.2715;
733 vector<double> par_SubHalo{A, zres, alpha_SubHalo, betha_SubHalo};
735 const cbl::distribution_func SubMass = [&] (
double lx,
const shared_ptr<void> modelInput,
const vector<double> par_SubHalo)
737 const std::vector<double> fix_par_h = *static_pointer_cast<std::vector<double>>(modelInput);
738 double x = pow(10., lx);
739 return pow(x, par_SubHalo[2] + 1) * exp(par_SubHalo[3] * pow(x, 3));
747 const cbl::distribution_func NFW_profile = [&cosm] (
double x,
const shared_ptr<void> modelInput,
const vector<double> parameter_NFW)
749 const vector<double> fix_par_h = *static_pointer_cast<std::vector<double>>(modelInput);
750 double r_vir = cosm.
r_vir(fix_par_h[0], parameter_NFW[0]);
752 double r_s = r_vir / c_vir;
753 double A = pow(r_s + r_vir, 2) / pow(r_s, 2);
755 return A * x / (pow(1 + x * c_vir, 2));
763 auto InfallMass = [&cosm] (
double x,
const shared_ptr<void> modelInput,
const vector<double> par_infall)
765 const vector<double> fix_par_h = *static_pointer_cast<std::vector<double>>(modelInput);
767 double M_infall = par_infall[0] * pow(pow(x / cosm.
r_vir(fix_par_h[0], z), 2. / 3.), -1);
777 const double M_stellarmax = pow(10., 12.);
780 const int limit_size = 1000;
782 const double prec = 1.e-5;
784 const double h = cosm.
hh();
786 const double x_NFW_min = 1.e-5;
787 const double x_NFW_max = 1.;
791 const int N_halo = halo_catalogue.
nObjects();
793 vector<bool> occupied(N_halo,
false);
794 std::default_random_engine generator;
795 std::vector<std::vector<std::shared_ptr<Object>>> support_tot(N_halo);
798 #pragma omp parallel num_threads(omp_get_max_threads())
801 #pragma omp for schedule(dynamic)
803 for (
int i = 0; i < N_halo; ++i) {
806 ErrorCBL(
"number of iterations exeed number of halos, possible infinite loop",
"Catalogue",
"HODCatalogue.cpp");
809 coutCBL <<
"..." << int(
double(i) /
double(N_halo) * 100) <<
"% completed\r"; cout.flush();
815 std::vector<std::shared_ptr<Object>> support;
816 const int seedtheta = 333 + i;
817 const int seedphi = 8782 + i;
818 const int seed = 34562 + i;
821 double halo_mass = halo_catalogue.
mass(i);
822 const double halo_catalogue_x = halo_catalogue.
xx(i);
823 const double halo_catalogue_y = halo_catalogue.
yy(i);
824 const double halo_catalogue_z = halo_catalogue.
zz(i);
827 const vector<double> vect{halo_mass / h};
828 const vector<double> vect_h{halo_mass};
830 auto fix_par = make_shared<vector<double>>(vect);
831 auto fix_par_h = make_shared<vector<double>>(vect_h);
834 const double halo_mass_wo_h = halo_mass / h;
842 if (HOD_Type == HODType::_Zehavi11_)
844 if (HOD_Type == HODType::_Zehavi05_)
846 if (HOD_Type == HODType::_Moster10_)
847 Navg_c = Average_c_Moster_2010(halo_mass_wo_h, starMass_threshold, k_c, M1_c, beta_c, gamma_c, sigma_c);
856 auto galaxy_c = std::make_shared<cbl::catalogue::Galaxy>();
857 auto number_c = nearbyint(Navg_c);
859 for (
size_t j = 0; j < number_c; ++j) {
861 galaxy_c->set_xx(halo_catalogue_x);
862 galaxy_c->set_yy(halo_catalogue_y);
863 galaxy_c->set_zz(halo_catalogue_z);
866 galaxy_c->set_mstar(StellarMass_c());
867 galaxy_c->set_massinfall(halo_mass);
868 galaxy_c->set_mass(halo_mass);
869 galaxy_c->set_galaxyTag(0);
871 support_tot[i].emplace_back(galaxy_c);
881 if (HOD_Type == HODType::_Zehavi11_)
883 else if (HOD_Type == HODType::_Zehavi05_)
885 else if (HOD_Type == HODType::_Moster10_)
886 Navg_s = Average_s_Moster_2010(halo_mass_wo_h, starMass_threshold, k_s, M1_s, beta_s, gamma_s, Phi_s, alpha_s);
893 std::poisson_distribution<int> Poisson_s(Navg_s);
894 int number_s = Poisson_s(generator);
897 vector<double> stellarmass_s(number_s);
898 for (
int j = 0; j < number_s; ++j)
899 stellarmass_s[j] = StellarMass_s();
904 std::function<double(
double)> shmf = [&par_SubHalo, &vect_h](
const double lx)
906 double x = pow(10., lx);
908 return (x * vect_h[0]) * par_SubHalo[0] * par_SubHalo[1] * pow(x * vect_h[0], par_SubHalo[2]) * exp(par_SubHalo[3] * pow(x, 3)) * log(10);
911 double MinLogExtraction = log10(starMass_threshold / halo_mass);
914 double MaxLogExtraction = log10(f);
918 const double a = 1.e-4;
919 double delta = 0.2 + a * number_s;
920 int retryCounter = 0;
922 vector<double> subhalomass = {};
928 vector<double> temp_subtot;
940 while (temp_sum < 1. || temp_count < number_s) {
941 temp_subtot.emplace_back(pow(10., SubHaloMass()));
942 temp_sum += temp_subtot[temp_subtot.size() - 1];
946 counter_s = number_s;
948 for (
int jj = 0; jj < number_s; jj++)
949 comp_f += temp_subtot[jj];
950 if (comp_f < f + f * delta / 2.) {
951 while (!(comp_f > f - f * delta / 2. && comp_f < f + f * delta / 2.)) {
953 comp_f += temp_subtot[counter_s - 1];
954 if (comp_f > f + f * delta / 2.)
958 if (comp_f > f - f * delta / 2. && comp_f < f + f * delta / 2.)
963 for (
int kk = 0; kk < counter_s; kk++)
964 subhalomass.emplace_back(temp_subtot[kk] * halo_mass);
969 for (
int j = 0; j < number_s; ++j)
970 subhalomass.emplace_back(pow(10, SubHaloMass()) * halo_mass);
973 for (
size_t j = 0; j < subhalomass.size(); j++)
974 Sum += subhalomass[j];
976 if (subhalomass.size() > 0) {
977 std::sort(subhalomass.begin(), subhalomass.end(), greater<double>());
978 std::sort(stellarmass_s.begin(), stellarmass_s.end(), greater<double>());
980 for (
int j = 0; j < number_s; ++j) {
981 auto galaxy_s = std::make_shared<cbl::catalogue::Galaxy>();
983 vector<double> par_infall{subhalomass[j]};
984 const double radius = cosm.
r_vir(halo_mass, z) *
Radius();
985 const double theta = Theta();
986 const double phi = Phi();
987 double M_infall = InfallMass(radius, fix_par_h, par_infall);
989 galaxy_s->set_xx(halo_catalogue_x + radius * sin(theta) * cos(phi));
990 galaxy_s->set_yy(halo_catalogue_y + radius * sin(theta) * sin(phi));
991 galaxy_s->set_zz(halo_catalogue_z + radius * cos(theta));
993 galaxy_s->set_mstar(stellarmass_s[j] * h);
994 galaxy_s->set_massinfall(M_infall);
995 galaxy_s->set_mass(subhalomass[j]);
996 galaxy_s->set_galaxyTag(1);
998 support_tot[i].emplace_back(galaxy_s);
1008 for (
int i=0; i<N_halo; ++i)
1009 for (
size_t j = 0; j < support_tot[i].size(); j++)
1010 m_object.emplace_back(support_tot[i][j]);
1012 if (HOD_Type!=HODType::_Zehavi11_) {
1020 if (HOD_Type!=HODType::_Zehavi05_) {
1027 coutCBL <<
"\n ...Done!" << endl;
1029 auto endTimer = chrono::steady_clock::now();
1031 float seconds = chrono::duration_cast<chrono::seconds>(endTimer - startTimer).count();
1034 coutCBL <<
"Time spent to compute: " << seconds <<
" seconds " << endl;
1037 coutCBL <<
"Writing time log file: timeLog.txt" << endl;
1041 ofstream timeLogFile(
"./output/timelog.txt");
1044 timeLogFile <<
"Time spent to compute: " << seconds <<
" seconds " << endl;
1047 timeLogFile.close();
#define coutCBL
CBL print message.
Catalogue()=default
default constructor
double yy(const int i) const
get the private member Catalogue::m_object[i]->m_yy
double mass(const int i) const
get the private member Catalogue::m_object[i]->m_mass
size_t nObjects() const
get the number of objects of the catalogue
double xx(const int i) const
get the private member Catalogue::m_object[i]->m_xx
double zz(const int i) const
get the private member Catalogue::m_object[i]->m_zz
double hh() const
get the private member Cosmology::m_hh
double r_vir(const double M_vir, const double redshift, const std::string author="BryanNorman", const bool unit1=false) const
the virial radius, given the virial mass and the redshift
double concentration_NFW_Duffy(const double Mass, const double redshift, const std::string halo_def="vir") const
the halo concentration-mass relation for NFW prfile and Duffy model
The class CustomDistributionRandomNumbers.
static const std::string col_green
green colour (used when printing something on the screen)
static const std::string col_default
default colour (used when printing something on the screen)
static const double pi
: the ratio of a circle's circumference to its diameter
static const double alpha
: the fine-structure constant
double Average_c_Zehavi_2005(const double x, const double Mmin)
return the average number of central galaies inside an halo of mass x
double Average_c_Zehavi_2011(const double x, const double logMmin, const double logsigma_c)
return the average number of central galaies inside an halo of mass x
HODType
type of HOD catalogue, which corresponds to the authors of the calibrated HOD model
double Average_s_Zehavi_2005(const double x, const double alpha, const double M1)
return the average number of satellite galaies per halo of mass x
double Average_s_Zehavi_2011(const double x, const double M0, const double M1, const double alpha)
return the average number of satellite galaies per halo of mass x
double GSL_integrate_qag(gsl_function Func, const double a, const double b, const double rel_err=1.e-3, const double abs_err=0, const int limit_size=1000, const int rule=6)
integral, computed using the GSL qag method
The global namespace of the CosmoBolognaLib
T Radius(const T Mass, const T Rho)
the radius of a sphere of a given mass and density
int ErrorCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL, const cbl::glob::ExitCode exitCode=cbl::glob::ExitCode::_error_)
throw an exception: it is used for handling exceptions inside the CosmoBolognaLib
std::function< double(double, std::shared_ptr< void >, std::vector< double >)> distribution_func
generic distribution function