FML
SphericalCollapseModel.h
Go to the documentation of this file.
1#ifndef SPHERICALCOLLAPSEMODEL
2#define SPHERICALCOLLAPSEMODEL
4#include <FML/Math/Math.h>
5#include <functional>
6#include <iostream>
7#include <cmath>
8
9namespace FML {
10 namespace COSMOLOGY {
11 namespace SPHERICALCOLLAPSE {
12
14 using Func1 = std::function<double(double)>;
15
16 //============================================================
17 /// The class contains all the info about the model
18 /// needed to run the spherical collapse and halomodel
19 /// Cosmology/gravity functions provided using lambda functions
20 //============================================================
22 public:
23
24 //============================================================
25 // Cosmological functions. Below x = log(a). w(x) is equation of state
26 // E(x) == H(x)/H0, mu(x) == Geff/G, logEprimeofx = dlogE/dx
27 //============================================================
33
34 //============================================================
35 // Cosmological parameters
36 //============================================================
37 double OmegaM{0.3};
38
41 }
43 Func1 Eofx,
47 Func1 wofx) :
48 Eofx(Eofx),
51 muofx(muofx),
52 wofx(wofx),
53 OmegaM(OmegaMofx(0.0)) {}
54
55 //============================================================
56 /// Virial condition. Virialization when this quantity is zero
57 /// Standard condition 2*Ek+Ep = 0 where Ek is kinetic and Ep is
58 /// potential energy Ep/M of a spherical tophat overdensity
59 //============================================================
60 double virial_condition(
61 double delta,
62 double delta_prime,
63 double roverR,
64 double x) const;
65
66 //============================================================
67 /// Define the non-linear time when this quantity is zero
68 /// Using delta-1 = 0
69 //============================================================
71 double delta,
72 [[maybe_unused]] double delta_prime,
73 [[maybe_unused]] double roverR,
74 [[maybe_unused]] double x) const;
75
76 //============================================================
77 /// Print useful info
78 //============================================================
79 void info() const;
80
81 //============================================================
82 /// Set the model to be lcdm
83 //============================================================
90 }
91
92 //============================================================
93 /// Define the linear ODE system
94 /// 0 = delta_lin
95 /// 1 = ddeltadloga_lin
96 //============================================================
97 int ode_system_linear_growth(double x, const double * y, double * dydx) const {
98 const double mu = muofx(x);
99 const double om = OmegaMofx(x);
100 const double dlogEdloga = logEprimeofx(x);
101 const double delta = y[0];
102 const double ddeltadx = y[1];
103
104 // Growth ODE
105 dydx[0] = ddeltadx;
106 dydx[1] = -(2.0+dlogEdloga)*ddeltadx + 1.5*om*mu*delta;
107 return GSL_SUCCESS;
108 }
109
110 //============================================================
111 /// Define the non-linear + linear ODE system for spherical
112 /// collapse
113 /// 0 = delta
114 /// 1 = ddeltadloga
115 /// 2 = delta_lin
116 /// 3 = ddelta_lindloga
117 //============================================================
118 int ode_system_non_linear_growth(double x, const double * y, double * dydx) const {
119 const double mu = muofx(x);
120 const double om = OmegaMofx(x);
121 const double dlogEdloga = logEprimeofx(x);
122 const double delta = y[0];
123 const double ddeltadx = y[1];
124 const double delta_lin = y[2];
125 const double ddeltadx_lin = y[3];
126
127 // Spherical collapse
128 dydx[0] = ddeltadx;
129 dydx[1] = -(2.0+dlogEdloga)*ddeltadx + 1.5*om*mu*delta*(1+delta) + 4.0/3.0*ddeltadx*ddeltadx/(1.0+delta);
130
131 // Linear evolution
132 dydx[2] = ddeltadx_lin;
133 dydx[3] = -(2.0+dlogEdloga)*ddeltadx_lin + 1.5*om*mu*delta_lin;
134 return GSL_SUCCESS;
135 }
136
137 //============================================================
138 // LCDM functions which can be used if none is provided
139 //============================================================
141 [&](double x){ return std::sqrt(OmegaM*std::exp(-3*x) + 1.0 - OmegaM); };
143 [&](double x){ return OmegaM*std::exp(-3*x)/(OmegaM*std::exp(-3*x) + 1.0 - OmegaM); };
145 [&](double x){ return -1.5*OmegaMofx(x); };
147 [&]([[maybe_unused]]double x){ return 1.0; };
149 [&]([[maybe_unused]]double x){ return -1.0; };
150
151 };
152
153 }
154 }
155}
156
157#endif
FML::SOLVERS::ODESOLVER::ODEFunction ODEFunction
Definition: Simulation.h:42
The class contains all the info about the model needed to run the spherical collapse and halomodel Co...
double virial_condition(double delta, double delta_prime, double roverR, double x) const
Virial condition.
SphericalCollapseModel(Func1 Eofx, Func1 OmegaMofx, Func1 logEprimeofx, Func1 muofx, Func1 wofx)
int ode_system_non_linear_growth(double x, const double *y, double *dydx) const
Define the non-linear + linear ODE system for spherical collapse 0 = delta 1 = ddeltadloga 2 = delta_...
int ode_system_linear_growth(double x, const double *y, double *dydx) const
Define the linear ODE system 0 = delta_lin 1 = ddeltadloga_lin.
double nonlinear_condition(double delta, double delta_prime, double roverR, double x) const
Define the non-linear time when this quantity is zero Using delta-1 = 0.
std::function< double(double)> Func1
std::function< int(double, const double *, double *)> ODEFunction
Definition: ODESolver.h:33
Definition: CAMBReader.h:10
return y
Definition: Global.h:265
const double exp
Definition: Global.h:259
x
Definition: test.py:18