25 submodule(gaugeinterface) eftcamb_ic
35 module subroutine eftcambinitialconditions( y, ev, tau )
41 type(evolutionvars) ev
42 real(dl) :: y(ev%nvar)
45 real(dl) :: a, a2, k, k2, etak, grhob_t, grhoc_t, grhor_t, grhog_t, grhov_t, gpres, grho_matter
46 real(dl) :: dgrho_matter, dgq, dgpnu, grho, adotoa, eft_grhonu, eft_gpinu, eft_grhonudot
47 real(dl) :: eft_gpinudot, grhormass_t, adotdota, cothxor, cs2, dopacity, dgrho, z, dz
48 real(dl) :: clxr, qr, pir, clxg, qg, pig, opacity, vb, clxc, clxb, eftpiedot
49 real(dl) :: wnu_arr(max_nu)
66 grhor_t = grhornomass/a2
72 grho_matter = grhob_t +grhoc_t
74 dgrho_matter = grhob_t*clxb +grhoc_t*clxc
79 if (cp%Num_Nu_Massive > 0)
then 80 call massivenuvars(ev,y,a,grho_matter,gpres,dgrho_matter,dgq, wnu_arr, dgp=dgpnu)
84 grho = grho_matter +grhor_t +grhog_t +grhov_t
87 gpres = gpres + (grhog_t+grhor_t)/3._dl
89 call ev%eft_cache%initialize()
92 ev%eft_cache%tau = tau
94 ev%eft_cache%grhom_t = grho
95 ev%eft_cache%gpresm_t = gpres
96 ev%eft_cache%grhob_t = grhob_t
97 ev%eft_cache%grhoc_t = grhoc_t
98 ev%eft_cache%grhor_t = grhor_t
99 ev%eft_cache%grhog_t = grhog_t
101 select type ( model => cp%EFTCAMB%model )
103 class is ( eftcamb_full_model )
106 call cp%EFTCAMB%model%compute_background_EFT_functions( a, cp%eft_par_cache , ev%eft_cache )
107 call cp%EFTCAMB%model%compute_adotoa( a, cp%eft_par_cache , ev%eft_cache )
108 class is ( eftcamb_designer_model )
112 call cp%EFTCAMB%model%compute_adotoa( a, cp%eft_par_cache , ev%eft_cache )
115 adotoa = ev%eft_cache%adotoa
118 if ( cp%Num_Nu_Massive /= 0 )
then 119 do nu_i = 1, cp%Nu_mass_eigenstates
122 eft_grhonudot = 0._dl
124 grhormass_t=grhormass(nu_i)/a**2
125 call nu_background(a*nu_masses(nu_i),eft_grhonu,eft_gpinu)
126 ev%eft_cache%grhonu_tot = ev%eft_cache%grhonu_tot + grhormass_t*eft_grhonu
127 ev%eft_cache%gpinu_tot = ev%eft_cache%gpinu_tot + grhormass_t*eft_gpinu
128 ev%eft_cache%grhonudot_tot = ev%eft_cache%grhonudot_tot + grhormass_t*(nu_drho(a*nu_masses(nu_i) ,adotoa, eft_grhonu)&
129 & -4._dl*adotoa*eft_grhonu)
130 ev%eft_cache%gpinudot_tot = ev%eft_cache%gpinudot_tot + grhormass_t*(nu_pidot(a*nu_masses(nu_i),adotoa, eft_gpinu )&
131 & -4._dl*adotoa*eft_gpinu)
135 ev%eft_cache%gpresdotm_t = -4._dl*adotoa*( grhog_t+grhor_t )/3._dl +ev%eft_cache%gpinudot_tot
137 call cp%EFTCAMB%model%compute_H_derivs( a, cp%eft_par_cache , ev%eft_cache )
139 adotdota = ev%eft_cache%Hdot +ev%eft_cache%adotoa**2
141 select type ( model => cp%EFTCAMB%model )
142 class is ( eftcamb_designer_model )
143 call cp%EFTCAMB%model%compute_background_EFT_functions( a, cp%eft_par_cache , ev%eft_cache )
146 call cp%EFTCAMB%model%compute_rhoQPQ( a, cp%eft_par_cache , ev%eft_cache )
148 call cp%EFTCAMB%model%compute_secondorder_EFT_functions( a, cp%eft_par_cache , ev%eft_cache )
153 if ( ev%TightCoupling )
then 154 call thermo( tau, cs2, opacity, dopacity )
156 call thermo( tau, cs2, opacity )
163 z = (0.5_dl*dgrho/k + etak)/adotoa
164 dz = -2._dl*adotoa*z + etak
166 if ( ev%no_nu_multpoles )
then 177 if ( ev%no_phot_multpoles )
then 178 if ( .not. ev%no_nu_multpoles )
then 179 clxg = -4*dz/k -4/k*opacity*( vb +z )
182 clxg = clxr -4/k*opacity*( vb +z )
192 dgrho = dgrho +grhog_t*clxg +grhor_t*clxr
193 dgq = dgq +grhog_t*qg +grhor_t*qr
196 z = (0.5_dl*dgrho/k + etak)/adotoa
197 dz = -2._dl*adotoa*z + etak
202 ev%eft_cache%clxg = clxg
203 ev%eft_cache%clxr = clxr
204 ev%eft_cache%dgpnu = dgpnu
205 ev%eft_cache%dgrho = dgrho
206 ev%eft_cache%dgq = dgq
209 call cp%EFTCAMB%model%compute_pi_factors( a, cp%eft_par_cache , ev%eft_cache )
211 if ( ev%eft_cache%EFTGamma1V /= 0._dl .or. ev%eft_cache%EFTGamma2V /= 0._dl .or. &
212 &ev%eft_cache%EFTGamma3V /= 0._dl .or. ev%eft_cache%EFTGamma4V /= 0._dl .or. &
213 &ev%eft_cache%EFTGamma5V /= 0._dl .or. ev%eft_cache%EFTGamma6V /= 0._dl )
then 219 eftpiedot = ( ev%eft_cache%EFTcdot +0.75_dl*(2._dl*ev%eft_cache%adotoa*ev%eft_cache%Hdot*a*a*ev%eft_cache%EFTOmegaP**2/(1._dl+ev%eft_cache%EFTOmegaV)&
220 & +2._dl*ev%eft_cache%adotoa**3*a**3*ev%eft_cache%EFTOmegaP*ev%eft_cache%EFTOmegaPP/(1._dl + ev%eft_cache%EFTOmegaV)-a**3*ev%eft_cache%adotoa**3*ev%eft_cache%EFTOmegaP**3/(1._dl+ev%eft_cache%EFTOmegaV)**2))*k*ev%eft_cache%z &
221 & +(ev%eft_cache%EFTc+0.75_dl*ev%eft_cache%adotoa**2*(a*a*ev%eft_cache%EFTOmegaP**2)/(1._dl+ev%eft_cache%EFTOmegaV))*k*ev%eft_cache%dz +2._dl*ev%eft_cache%adotoa*ev%eft_cache%EFTpiE&
222 & +(-ev%eft_cache%dgrho +(ev%eft_cache%grhog_t*ev%eft_cache%clxg+ev%eft_cache%grhor_t*ev%eft_cache%clxr))/4._dl*(+a*ev%eft_cache%adotoa**2*ev%eft_cache%EFTOmegaP +a*ev%eft_cache%Hdot*ev%eft_cache%EFTOmegaP+a*a*ev%eft_cache%adotoa**2*ev%eft_cache%EFTOmegaPP &
223 & -a*a*ev%eft_cache%adotoa**2*ev%eft_cache%EFTOmegaP**2/(1._dl+ev%eft_cache%EFTOmegaV))/(1._dl+ev%eft_cache%EFTOmegaV)&
224 & -ev%eft_cache%adotoa/4._dl*a*ev%eft_cache%EFTOmegaP/(1._dl+ev%eft_cache%EFTOmegaV)*(ev%eft_cache%grhob_t*(-k*(ev%eft_cache%z +vb)-3._dl*ev%eft_cache%adotoa*clxb) + ev%eft_cache%grhoc_t*(-k*ev%eft_cache%z -3._dl*ev%eft_cache%adotoa*clxc))
228 if ( ev%eft_cache%EFTpiC +k2*ev%eft_cache%EFTpiD1 +k2**2*ev%eft_cache%EFTpiD2 /= 0._dl )
then 229 y(ev%w_ix) = -cp%eft_par_cache%h0_Mpc*ev%eft_cache%EFTpiE/( ev%eft_cache%EFTpiC +k2*ev%eft_cache%EFTpiD1 +k2**2*ev%eft_cache%EFTpiD2 )
230 y(ev%w_ix+1) = cp%eft_par_cache%h0_Mpc*(ev%eft_cache%EFTpiE/( ev%eft_cache%EFTpiC +k2*ev%eft_cache%EFTpiD1 +k2**2*ev%eft_cache%EFTpiD2 )**2*a*ev%eft_cache%adotoa*(eftpicdotfunction(a,k)+k*k*eftpiddotfunction(a,k))&
231 & -eftpiedot/(ev%eft_cache%EFTpiC +k2*ev%eft_cache%EFTpiD1 +k2**2*ev%eft_cache%EFTpiD2 ) )
238 call ev%eft_cache%initialize()
240 end subroutine eftcambinitialconditions
244 function eftpicfunction( a, k )
248 real(dl),
intent(in) :: a
249 real(dl),
intent(in) :: k
250 real(dl) :: eftpicfunction
252 type(eftcamb_timestep_cache) :: eft_cache
254 real(dl) :: grhormass_t, eft_gpinudot, eft_grhonudot, eft_gpinu, eft_grhonu
255 real(dl) :: adotoa, adotdota, grho, grhob_t, grhoc_t, grhor_t, grhog_t, gpres, grho_matter, a2
258 call eft_cache%initialize()
266 grhor_t = grhornomass/a2
270 grho_matter = grhob_t +grhoc_t
271 gpres = (grhog_t+grhor_t)/3._dl
274 grho = grho_matter +grhor_t +grhog_t
276 if ( cp%Num_Nu_Massive /= 0 )
then 277 do nu_i = 1, cp%Nu_mass_eigenstates
280 grhormass_t=grhormass(nu_i)/a**2
281 call nu_background(a*nu_masses(nu_i),eft_grhonu,eft_gpinu)
282 eft_cache%grhonu_tot = eft_cache%grhonu_tot + grhormass_t*eft_grhonu
283 eft_cache%gpinu_tot = eft_cache%gpinu_tot + grhormass_t*eft_gpinu
287 grho = grho +eft_cache%grhonu_tot
288 gpres = gpres +eft_cache%gpinu_tot
293 eft_cache%grhom_t = grho
294 eft_cache%gpresm_t = gpres
295 eft_cache%grhob_t = grhob_t
296 eft_cache%grhoc_t = grhoc_t
297 eft_cache%grhor_t = grhor_t
298 eft_cache%grhog_t = grhog_t
300 select type ( model => cp%EFTCAMB%model )
302 class is ( eftcamb_full_model )
305 call cp%EFTCAMB%model%compute_background_EFT_functions( a, cp%eft_par_cache , eft_cache )
306 call cp%EFTCAMB%model%compute_adotoa( a, cp%eft_par_cache , eft_cache )
307 class is ( eftcamb_designer_model )
311 call cp%EFTCAMB%model%compute_adotoa( a, cp%eft_par_cache , eft_cache )
314 adotoa = eft_cache%adotoa
317 eft_cache%grhonu_tot = 0._dl
318 eft_cache%gpinu_tot = 0._dl
319 if ( cp%Num_Nu_Massive /= 0 )
then 320 do nu_i = 1, cp%Nu_mass_eigenstates
323 eft_grhonudot = 0._dl
325 grhormass_t=grhormass(nu_i)/a**2
326 call nu_background(a*nu_masses(nu_i),eft_grhonu,eft_gpinu)
327 eft_cache%grhonu_tot = eft_cache%grhonu_tot + grhormass_t*eft_grhonu
328 eft_cache%gpinu_tot = eft_cache%gpinu_tot + grhormass_t*eft_gpinu
329 eft_cache%grhonudot_tot = eft_cache%grhonudot_tot + grhormass_t*(nu_drho(a*nu_masses(nu_i) ,adotoa, eft_grhonu)&
330 & -4._dl*adotoa*eft_grhonu)
331 eft_cache%gpinudot_tot = eft_cache%gpinudot_tot + grhormass_t*(nu_pidot(a*nu_masses(nu_i),adotoa, eft_gpinu )&
332 & -4._dl*adotoa*eft_gpinu)
336 eft_cache%gpresdotm_t = -4._dl*adotoa*( grhog_t+grhor_t )/3._dl +eft_cache%gpinudot_tot
338 call cp%EFTCAMB%model%compute_H_derivs( a, cp%eft_par_cache , eft_cache )
340 adotdota = eft_cache%Hdot +eft_cache%adotoa**2
342 select type ( model => cp%EFTCAMB%model )
343 class is ( eftcamb_designer_model )
344 call cp%EFTCAMB%model%compute_background_EFT_functions( a, cp%eft_par_cache , eft_cache )
347 call cp%EFTCAMB%model%compute_rhoQPQ( a, cp%eft_par_cache , eft_cache )
349 call cp%EFTCAMB%model%compute_secondorder_EFT_functions( a, cp%eft_par_cache , eft_cache )
352 call cp%EFTCAMB%model%compute_pi_factors( a, cp%eft_par_cache , eft_cache )
354 eftpicfunction = eft_cache%EFTpiC
358 end function eftpicfunction
362 function eftpidfunction(a,k)
366 real(dl),
intent(in) :: a
367 real(dl),
intent(in) :: k
368 real(dl) :: eftpidfunction
370 type(eftcamb_timestep_cache) :: eft_cache
373 real(dl) :: grhormass_t, eft_gpinudot, eft_grhonudot, eft_gpinu, eft_grhonu
374 real(dl) :: adotoa, adotdota, grho, grhob_t, grhoc_t, grhor_t, grhog_t, gpres, grho_matter, a2
377 call eft_cache%initialize()
385 grhor_t = grhornomass/a2
389 grho_matter = grhob_t +grhoc_t
390 gpres = (grhog_t+grhor_t)/3._dl
393 grho = grho_matter +grhor_t +grhog_t
395 if ( cp%Num_Nu_Massive /= 0 )
then 396 do nu_i = 1, cp%Nu_mass_eigenstates
399 grhormass_t=grhormass(nu_i)/a**2
400 call nu_background(a*nu_masses(nu_i),eft_grhonu,eft_gpinu)
401 eft_cache%grhonu_tot = eft_cache%grhonu_tot + grhormass_t*eft_grhonu
402 eft_cache%gpinu_tot = eft_cache%gpinu_tot + grhormass_t*eft_gpinu
406 grho = grho +eft_cache%grhonu_tot
407 gpres = gpres +eft_cache%gpinu_tot
412 eft_cache%grhom_t = grho
413 eft_cache%gpresm_t = gpres
414 eft_cache%grhob_t = grhob_t
415 eft_cache%grhoc_t = grhoc_t
416 eft_cache%grhor_t = grhor_t
417 eft_cache%grhog_t = grhog_t
419 select type ( model => cp%EFTCAMB%model )
421 class is ( eftcamb_full_model )
424 call cp%EFTCAMB%model%compute_background_EFT_functions( a, cp%eft_par_cache , eft_cache )
425 call cp%EFTCAMB%model%compute_adotoa( a, cp%eft_par_cache , eft_cache )
426 class is ( eftcamb_designer_model )
430 call cp%EFTCAMB%model%compute_adotoa( a, cp%eft_par_cache , eft_cache )
433 adotoa = eft_cache%adotoa
436 eft_cache%grhonu_tot = 0._dl
437 eft_cache%gpinu_tot = 0._dl
438 if ( cp%Num_Nu_Massive /= 0 )
then 439 do nu_i = 1, cp%Nu_mass_eigenstates
442 eft_grhonudot = 0._dl
444 grhormass_t=grhormass(nu_i)/a**2
445 call nu_background(a*nu_masses(nu_i),eft_grhonu,eft_gpinu)
446 eft_cache%grhonu_tot = eft_cache%grhonu_tot + grhormass_t*eft_grhonu
447 eft_cache%gpinu_tot = eft_cache%gpinu_tot + grhormass_t*eft_gpinu
448 eft_cache%grhonudot_tot = eft_cache%grhonudot_tot + grhormass_t*(nu_drho(a*nu_masses(nu_i) ,adotoa, eft_grhonu)&
449 & -4._dl*adotoa*eft_grhonu)
450 eft_cache%gpinudot_tot = eft_cache%gpinudot_tot + grhormass_t*(nu_pidot(a*nu_masses(nu_i),adotoa, eft_gpinu )&
451 & -4._dl*adotoa*eft_gpinu)
455 eft_cache%gpresdotm_t = -4._dl*adotoa*( grhog_t+grhor_t )/3._dl +eft_cache%gpinudot_tot
457 call cp%EFTCAMB%model%compute_H_derivs( a, cp%eft_par_cache , eft_cache )
459 adotdota = eft_cache%Hdot +eft_cache%adotoa**2
461 select type ( model => cp%EFTCAMB%model )
462 class is ( eftcamb_designer_model )
463 call cp%EFTCAMB%model%compute_background_EFT_functions( a, cp%eft_par_cache , eft_cache )
466 call cp%EFTCAMB%model%compute_rhoQPQ( a, cp%eft_par_cache , eft_cache )
468 call cp%EFTCAMB%model%compute_secondorder_EFT_functions( a, cp%eft_par_cache , eft_cache )
471 call cp%EFTCAMB%model%compute_pi_factors( a, cp%eft_par_cache , eft_cache )
473 eftpidfunction = eft_cache%EFTpiD1 + k*k*eft_cache%EFTpiD1
477 end function eftpidfunction
482 function eftpicdotfunction(a,k)
486 real(dl),
intent(in) :: a
487 real(dl),
intent(in) :: k
488 real(dl) :: eftpicdotfunction
492 eftpicdotfunction = dfridr( eftpicfunction, a, k, 0.03_dl*a, err )
496 end function eftpicdotfunction
501 function eftpiddotfunction(a,k)
505 real(dl),
intent(in) :: a
506 real(dl),
intent(in) :: k
507 real(dl) :: eftpiddotfunction
512 eftpiddotfunction = dfridr( eftpidfunction, a, k, 0.03_dl*a, err )
516 end function eftpiddotfunction
521 function dfridr( func, x, k, h, err )
525 integer,
parameter :: ntab = 100
526 real(dl) dfridr,err,h,x,k,func
529 real(dl),
parameter :: con=1.4_dl
530 real(dl),
parameter :: con2=con*con
531 real(dl),
parameter :: big=1.d+30
532 real(dl),
parameter :: safe=2._dl
535 real(dl) errt, fac, hh
536 real(dl),
dimension(ntab,ntab) :: a
538 if (h.eq.0._dl) h = 1.d-8
541 a(1,1)=(func(x+hh,k)-func(x-hh,k))/(2.0_dl*hh)
546 a(1,i)=(func(x+hh,k)-func(x-hh,k))/(2.0_dl*hh)
549 a(j,i)=(a(j-1,i)*fac-a(j-1,i-1))/(fac-1._dl)
551 errt=max(abs(a(j,i)-a(j-1,i)),abs(a(j,i)-a(j-1,i-1)))
552 if (errt.le.err)
then 557 if(abs(a(i,i)-a(i-1,i-1)).ge.safe*err)
return 564 end submodule eftcamb_ic