4 #define PI_L 3.141592653589793238462643383279502884L 19 std::vector< std::pair<RT,RT> > fluids;
23 RT phi_K1 = 0.0, K_K1 = 0.0, alpha_K1 = 0.0,
24 phi_K2 = 0.0, K_K2 = 0.0, alpha_K2 = 0.0,
25 phi_K3 = 0.0, K_K3 = 0.0, alpha_K3 = 0.0,
26 phi_K4 = 0.0, K_K4 = 0.0, alpha_K4 = 0.0;
27 std::vector<RT> fluids_K1 = {0},
33 RT phi_get = 0.0, K_get = 0.0, alpha_get = 0.0,
34 rho_get = 0.0, S_get = 0.0;
37 FRW(RT phi_in, RT K_in)
39 phi_get = phi = phi_in;
41 alpha_get = alpha = 1.0;
48 void set_phi(RT phi_in)
50 phi_get = phi = phi_in;
56 void set_alpha(RT alpha_in)
58 alpha_get = alpha = alpha_in;
60 void addFluid(RT rho_in, RT w_in)
62 fluids.emplace_back(rho_in, w_in);
64 fluids_K1.resize(num_fluids);
65 fluids_K2.resize(num_fluids);
66 fluids_K3.resize(num_fluids);
67 fluids_K4.resize(num_fluids);
70 for(
int n=0; n<num_fluids; ++n)
72 RT rho = fluids[n].first;
74 S_get += 3.0*rho*fluids[n].second;
79 RT get_phi() {
return phi_get; }
80 RT get_K() {
return K_get; }
81 RT get_alpha() {
return alpha_get; }
82 RT get_rho() {
return rho_get; }
83 RT get_S() {
return S_get; }
89 void RK_total_step(RT h);
93 template <
typename RT>
101 for(
int n=0; n<num_fluids; ++n)
103 std::pair<RT,RT> x = fluids[n];
104 K_source += 4.0*PI_L*x.first*(1.0 + 3.0*x.second);
106 K_K1 = 1.0/3.0*K*K + K_source;
109 for(
int n=0; n<num_fluids; ++n)
111 std::pair<RT,RT> x = fluids[n];
114 fluids_K1[n] = K*rho*(1.0 + x.second);
118 phi_get = phi + (h/2.0)*phi_K1;
119 K_get = K + (h/2.0)*K_K1;
123 for(
int n=0; n<num_fluids; ++n)
125 RT rho = fluids[n].first + (h/2.0)*fluids_K1[n];
127 S_get += 3.0*rho*fluids[n].second;
131 template <
typename RT>
135 RT K_interm = K + (h/2.0)*K_K1;
136 phi_K2 = -1.0*K_interm/6.0;
140 for(
int n=0; n<num_fluids; ++n)
142 std::pair<RT,RT> x = fluids[n];
143 RT rho_interm = fluids[n].first + (h/2.0)*fluids_K1[n];
144 K_source += 4.0*PI_L*rho_interm*(1.0 + 3.0*x.second);
146 K_K2 = 1.0/3.0*K_interm*K_interm + K_source;
149 for(
int n=0; n<num_fluids; ++n)
151 std::pair<RT,RT> x = fluids[n];
153 RT rho_interm = fluids[n].first + (h/2.0)*fluids_K1[n];
154 fluids_K2[n] = K_interm*rho_interm*(1.0 + x.second);
158 phi_get = phi + (h/2.0)*phi_K2;
159 K_get = K + (h/2.0)*K_K2;
163 for(
int n=0; n<num_fluids; ++n)
165 RT rho = fluids[n].first + (h/2.0)*fluids_K2[n];
167 S_get += 3.0*rho*fluids[n].second;
171 template <
typename RT>
175 RT K_interm = K + (h/2.0)*K_K2;
176 phi_K3 = -1.0*K_interm/6.0;
180 for(
int n=0; n<num_fluids; ++n)
182 std::pair<RT,RT> x = fluids[n];
183 RT rho_interm = fluids[n].first + (h/2.0)*fluids_K2[n];
184 K_source += 4.0*PI_L*rho_interm*(1.0 + 3.0*x.second);
186 K_K3 = 1.0/3.0*K_interm*K_interm + K_source;
189 for(
int n=0; n<num_fluids; ++n)
191 std::pair<RT,RT> x = fluids[n];
193 RT rho_interm = fluids[n].first + (h/2.0)*fluids_K2[n];
194 fluids_K3[n] = K_interm*rho_interm*(1.0 + x.second);
198 phi_get = phi + h*phi_K3;
203 for(
int n=0; n<num_fluids; ++n)
205 RT rho = fluids[n].first + h*fluids_K3[n];
207 S_get += 3.0*rho*fluids[n].second;
211 template <
typename RT>
215 RT K_interm = K + h*K_K3;
216 phi_K4 = -1.0*K_interm/6.0;
220 for(
int n=0; n<num_fluids; ++n)
222 std::pair<RT,RT> x = fluids[n];
223 RT rho_interm = fluids[n].first + h*fluids_K3[n];
224 K_source += 4.0*PI_L*rho_interm*(1.0 + 3.0*x.second);
226 K_K4 = 1.0/3.0*K_interm*K_interm + K_source;
229 for(
int n=0; n<num_fluids; ++n)
231 std::pair<RT,RT> x = fluids[n];
233 RT rho_interm = fluids[n].first + h*fluids_K3[n];
234 fluids_K4[n] = K_interm*rho_interm*(1.0 + x.second);
238 phi += h/6.0*(phi_K1 + 2.0*phi_K2 + 2.0*phi_K3 + phi_K4);
239 K += h/6.0*(K_K1 + 2.0*K_K2 + 2.0*K_K3 + K_K4);
240 for(
int n=0; n<num_fluids; ++n)
241 fluids[n].first += h/6.0*(fluids_K1[n] + 2.0*fluids_K2[n] + 2.0*fluids_K3[n] + fluids_K4[n]);
248 for(
int n=0; n<num_fluids; ++n)
250 RT rho = fluids[n].first;
252 S_get += 3.0*rho*fluids[n].second;