421 {
422
423
424
425
428 const double astart = 1.0 / (1.0 + zstart);
431 }
433 throw std::runtime_error(
434 "Transferdata provided are only up to z = " + std::to_string(zstart) +
435 ", but we want to start simulation at z = " + std::to_string(1.0 /
aini - 1.0) +
436 " Provide the required data, put OmegaMNu = 0.0 or set it so that we don't use scaledependent "
437 "growth!");
439 }
440 }
441
442
443
444
447 if (y > 0.1 and y < 1e4)
449 }
451
452
453
457 }
458
462
463
464
465
466
467
468
470 const bool solve_for_neutrinos = false;
471
472
473 auto solve_growth_equations = [&](double koverH0) -> std::tuple<DVector, DVector, DVector, DVector, DVector> {
475 const double fnu =
cosmo->get_fMNu();
477 const double a = std::exp(x);
478 const double H =
cosmo->HoverH0_of_a(a);
479 const double dlogHdx =
cosmo->dlogHdloga_of_a(a);
480
481
482
483
490
491 const double D1 =
y[0];
492 const double dD1dx =
y[1];
493 const double D2 =
y[2];
494 const double dD2dx =
y[3];
495 const double D3a =
y[4];
496 const double dD3adx =
y[5];
497 const double D3b =
y[6];
498 const double dD3bdx =
y[7];
499
500
501 dydx[0] = dD1dx;
502 dydx[1] = rhs_1LPT *
D1 - (2.0 + dlogHdx) * dD1dx;
503 dydx[2] = dD2dx;
504 dydx[3] = rhs_2LPT * (
D2 - nonlinear_2LPT *
D1 *
D1) - (2.0 + dlogHdx) * dD2dx;
505 dydx[4] = dD3adx;
506 dydx[5] = rhs_3LPTa * (D3a - 2.0 *
D1 *
D1 *
D1) - (2.0 + dlogHdx) * dD3adx;
507 dydx[6] = dD3bdx;
508 dydx[7] = rhs_3LPTb * (D3b +
D1 *
D1 *
D1 -
D2 *
D1) - (2.0 + dlogHdx) * dD3bdx;
509
510
511 if (solve_for_neutrinos) {
512
513 const double k_over_kfs = koverH0 *
H0_hmpc /
cosmo->get_neutrino_free_streaming_scale_hmpc(a);
514 const double k_over_kfs2 = k_over_kfs * k_over_kfs;
515
516 const double D1mnu =
y[8];
517 const double dD1mnudx =
y[9];
518 dydx[8] = dD1mnudx;
519 dydx[9] =
rhs * (
D1 * (1.0 - fnu) + (fnu - k_over_kfs2) * D1mnu) - (2.0 + dlogHdx) * dD1mnudx;
520
521
522 dydx[1] =
rhs * (
D1 * (1.0 - fnu) + fnu * D1mnu) - (2.0 + dlogHdx) * dD1dx;
523 } else {
524 dydx[8] = dydx[9] = 0.0;
525 }
526
527 return GSL_SUCCESS;
528 };
529
530
531
532
533 std::array<double, 8>
ini;
534 if (y_low < 0.5) {
536 } else {
537 ini = {1.0, 1.0, -3.0 / 7.0, -6.0 / 7.0, -1.0 / 3.0, -1.0, 5.0 / 21.0, 5.0 / 7.0};
538 }
539 const double D1_ini =
ini[0];
540 double dD1dx_ini =
ini[1];
541 const double D2_ini =
ini[2];
542 const double dD2dx_ini =
ini[3];
543 const double D3a_ini =
ini[4];
544 const double dD3adx_ini =
ini[5];
545 const double D3b_ini =
ini[6];
546 const double dD3bdx_ini =
ini[7];
547
548
549 double D1mnu_ini = D1_ini;
550 double dD1mnu_ini = dD1dx_ini;
551
552
553
554 if (use_neutrino_transfer and koverH0 > 0.0)
556 if (solve_for_neutrinos and koverH0 > 0.0) {
560 }
561
562 std::vector<double> yini{D1_ini,
563 dD1dx_ini,
564 D2_ini,
565 dD2dx_ini,
566 D3a_ini,
567 dD3adx_ini,
568 D3b_ini,
569 dD3bdx_ini,
570 D1mnu_ini,
571 dD1mnu_ini};
572
573
575 ode.
solve(deriv, loga_arr, yini);
581
582
584 tmp.
create(loga_arr, D1,
"Temporary D1(loga) Spline");
585 const double D = tmp(std::log(
aini));
586 for (
size_t i = 0;
i <
D1.size();
i++) {
592 if (not solve_for_neutrinos) {
593
595
598 std::exp(loga_arr[i])) /
600 }
601 }
602 }
603
604 return {
D1,
D2, D3a, D3b, D1mnu};
605 };
606
607
608
609 auto data = solve_growth_equations(0.0);
615
616
618
624#ifdef USE_OMP
625#pragma omp parallel for
626#endif
628 auto data = solve_growth_equations(std::exp(logkoverH0_arr[i]));
629 D1[
i] = std::get<0>(data);
630 D2[
i] = std::get<1>(data);
631 D3a[
i] = std::get<2>(data);
632 D3b[
i] = std::get<3>(data);
633 D1mnu[
i] = std::get<4>(data);
634 }
640 }
641 }
FML::SOLVERS::FFTLog::DVector DVector
FML::INTERPOLATION::SPLINE::DVector2D DVector2D
void create(const double *x, const double *y, const double *z, int nx, int ny, std::string splinename="NoName", const gsl_interp2d_type *interpoltype=SPLINE_FIDUCIAL_INTERPOL_TYPE_2D)
Create a spline from pointers to x, y and z. z must have nx * ny elements.
This is a wrapper class for easy use of GSL splines It is (OpenMP) thread safe as long as splines are...
void create(const double *x, const double *y, int nx, std::string splinename="NoName", const gsl_interp_type *interpoltype=SPLINE_FIDUCIAL_INTERPOL_TYPE)
Create a spline from pointers to x and y. Both must have nx elements.
This is a wrapper around the GSL library to easily solve ODEs and return the data in whatever format ...
DVector get_data_by_component(int icomponent) const
Get the data for a particular component y_i(xarr)
void solve(ODEFunctionPointer ode_equation, void *parameters, const DVector &xarr, const DVector &yinitial, const gsl_odeiv2_step_type *stepper=ODESOLVER_FIDUCIAL_STEPPER, ODEFunctionPointerJacobian jacobian=nullptr)
static std::array< double, 8 > radiation_matter_growing_mode(double y, int nterms=200)
virtual double source_factor_2LPT(double a, double koverH0=0) const
Spline2D D_3LPTa_of_logkoverH0_loga
Spline2D D_1LPT_of_logkoverH0_loga
Spline2D Dmnu_1LPT_of_logkoverH0_loga
virtual double nonlinear_source_factor_2LPT(double a, double koverH0=0) const
FML::INTERPOLATION::SPLINE::DVector DVector
virtual double source_factor_3LPTb(double a, double koverH0=0) const
Spline2D D_2LPT_of_logkoverH0_loga
double a_over_aeq(double a) const
virtual double GeffOverG(double a, double koverH0=0) const =0
virtual double source_factor_3LPTa(double a, double koverH0=0) const
virtual double source_factor_1LPT(double a, double koverH0=0) const
std::shared_ptr< LinearTransferData > transferdata
Spline2D D_3LPTb_of_logkoverH0_loga
bool scaledependent_growth
std::function< int(double, const double *, double *)> ODEFunction