forked from sfu-cosmo/MGCAMB_v4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mgcamb.f90
1464 lines (1086 loc) · 56.9 KB
/
mgcamb.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module MGCAMB
use precision
! new model selection flags
integer :: MG_flag
integer :: pure_MG_flag
integer :: alt_MG_flag
integer :: QSA_flag
integer :: mugamma_par
integer :: muSigma_par
integer :: QR_par
! DE model flag
integer :: DE_model
real(dl) :: GRtrans !< scale factor at which MG is switched on
! BZ parametrization (and QS f(R))
real(dl) :: B1
real(dl) :: B2
real(dl) :: lambda1_2
real(dl) :: lambda2_2
real(dl) :: ss
! Planck Parametrization
real(dl) :: E11
real(dl) :: E22
! Q-R parametrization 1
real(dl) :: MGQfix
real(dl) :: MGRfix
! Q-R parametrization 2
real(dl) :: Qnot
real(dl) :: Rnot
real(dl) :: sss
! Growth rate gamma
real(dl) :: Linder_gamma
! Symmetron
real(dl) :: beta_star
real(dl) :: a_star
real(dl) :: xi_star
! Dilaton
real(dl) :: beta0
real(dl) :: xi0
real(dl) :: DilR
real(dl) :: DilS
! Hu-Sawicki f(R) gravity
real(dl) :: F_R0
real(dl) :: FRn
! DES parametrization
real(dl) :: mu0
real(dl) :: sigma0
! effective Newton's constant
real(dl) :: ga
real(dl) :: nn
! DE model parameters
real(dl) :: w0DE !< w0 parameters for DE
real(dl) :: waDE !< waDE parameters for DE
character(len=(10)) :: MGCAMB_version = 'v 3.0'
! define the type MGCAMB_par_cache
type :: MGCAMB_parameter_cache
real(dl) :: omegab
real(dl) :: omegac
real(dl) :: omegav
real(dl) :: h0
real(dl) :: h0_Mpc
character(len=30) :: output_root
end type MGCAMB_parameter_cache
type(MGCAMB_parameter_cache) :: mgcamb_par_cache
! define the tyoe MGCAMB_timestep_cache
type :: MGCAMB_timestep_cache
! 1. Background quantities
real(dl) :: adotoa
real(dl) :: Hdot
real(dl) :: grho
real(dl) :: gpres
real(dl) :: grhob_t
real(dl) :: grhoc_t
real(dl) :: grhog_t
real(dl) :: grhor_t
real(dl) :: grhov_t
real(dl) :: gpresv_t
real(dl) :: grhonu_t
real(dl) :: gpresnu_t
! 2. Perturbation quantities
real(dl) :: k
real(dl) :: k2
real(dl) :: dgrho
real(dl) :: dgq
real(dl) :: pidot_sum
real(dl) :: dgpi_w_sum
real(dl) :: dgpi
real(dl) :: dgpi_diff
real(dl) :: dgpidot
real(dl) :: rhoDelta
real(dl) :: rhoDeltadot
! 3. MG functions
real(dl) :: mu
real(dl) :: mudot
real(dl) :: gamma
real(dl) :: gammadot
real(dl) :: q
real(dl) :: qdot
real(dl) :: r
real(dl) :: rdot
!> 4. Perturbations evolution variables
real(dl) :: z
real(dl) :: sigma
real(dl) :: sigmadot
real(dl) :: etak
real(dl) :: etadot
!> 5. ISW and lensing realted quantities
real(dl) :: MG_alpha
real(dl) :: MG_alphadot
real(dl) :: MG_phi
real(dl) :: MG_phidot
real(dl) :: MG_psi
real(dl) :: MG_psidot
real(dl) :: MG_ISW
real(dl) :: MG_lensing
real(dl) :: source1
real(dl) :: source3
end type MGCAMB_timestep_cache
#ifdef DEBUG
logical , parameter :: DebugMGCAMB = .true. !< MGCAMB debug flag.This will turn on printing of many things to aid debugging the code.
#else
logical , parameter :: DebugMGCAMB = .false. !< MGCAMB debug flag.This will turn on printing of many things to aid debugging the code.
#endif
contains
!---------------------------------------------------------------------------
!> this subroutine computes the MG functions at a time-step
subroutine MGCAMB_compute_MG_functions( a, mg_par_cache, mg_cache )
use precision
implicit none
real(dl) :: a !< scale factor
type(MGCAMB_timestep_cache), intent(inout) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
! Divide the cases here
if (( MG_flag == 1 .and. pure_MG_flag /= 3 ) & ! all the mu, gamma parametrizations
.or. MG_flag == 2 &
.or. MG_flag == 3 ) then
mg_cache%mu = MGCAMB_Mu( a, mg_par_cache, mg_cache )
mg_cache%mudot = MGCAMB_MuDot( a, mg_par_cache, mg_cache )
mg_cache%gamma = MGCAMB_Gamma( a, mg_par_cache, mg_cache )
mg_cache%gammadot = MGCAMB_GammaDot( a, mg_par_cache, mg_cache )
!write(*,*) 'a, k, mu, mudot, gamma, gammadot', a, mg_cache%k, mg_cache%mu,&
! mg_cache%mudot, mg_cache%gamma, mg_cache%gammadot
! other EFT functions are zero
mg_cache%q = 0._dl
mg_cache%qdot = 0._dl
mg_cache%r = 0._dl
mg_cache%rdot = 0._dl
else if ( MG_flag == 1 .and. pure_MG_flag == 3 ) then ! the Q,R parametrization
mg_cache%q = MGCAMB_Q( a, mg_par_cache, mg_cache )
mg_cache%qdot = MGCAMB_Qdot( a, mg_par_cache, mg_cache )
mg_cache%r = MGCAMB_R( a, mg_par_cache, mg_cache )
mg_cache%rdot = MGCAMB_Rdot( a, mg_par_cache, mg_cache )
! other MG functions are zero
mg_cache%mu = 0._dl
mg_cache%mudot = 0._dl
mg_cache%gamma = 0._dl
mg_cache%gammadot = 0._dl
end if
end subroutine MGCAMB_compute_MG_functions
!---------------------------------------------------------------------------
!> this subroutine computes the shear sigma in MG
subroutine MGCAMB_compute_sigma( a, mg_par_cache, mg_cache )
use precision
implicit none
real(dl) :: a !< scale factor
type(MGCAMB_timestep_cache), intent(inout) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
if (( MG_flag == 1 .and. pure_MG_flag /= 3 ) & ! all the mu, gamma parametrizations
.or. MG_flag == 2 &
.or. MG_flag == 3 ) then
! first calculate MG_alpha
mg_cache%MG_alpha = ( mg_cache%etak/mg_cache%k + mg_cache%mu * ( mg_cache%gamma*mg_cache%rhoDelta+ &
( mg_cache%gamma -1._dl )*2._dl* mg_cache%dgpi)/(2._dl*mg_cache%k2)) / mg_cache%adotoa
! then calculate sigma
mg_cache%sigma = mg_cache%k * mg_cache%MG_alpha
else if ( MG_flag == 1 .and. pure_MG_flag == 3 ) then
mg_cache%MG_phi = - mg_cache%rhoDelta * mg_cache%q/(2._dl*mg_cache%k2)
mg_cache%sigma = (mg_cache%etak - mg_cache%k * mg_cache%MG_phi)/mg_cache%adotoa
mg_cache%MG_alpha = mg_cache%sigma/mg_cache%k
end if
end subroutine MGCAMB_compute_sigma
!---------------------------------------------------------------------------
!> this subroutine computes the perturbation Z in MG
subroutine MGCAMB_compute_z( a, mg_par_cache, mg_cache )
use precision
implicit none
real(dl) :: a !< scale factor
type(MGCAMB_timestep_cache), intent(inout) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
!> other parameters
real(dl) :: fmu
real(dl) :: f1
real(dl) :: fQ
real(dl) :: term1
real(dl) :: term2
real(dl) :: term3
real(dl) :: term4
real(dl) :: term5
real(dl) :: term6
real(dl) :: k2alpha
if (( MG_flag == 1 .and. pure_MG_flag /= 3 ) & ! all the mu, gamma parametrizations
.or. MG_flag == 2 &
.or. MG_flag == 3 ) then
!> adding the massive neutrinos contibutions
fmu = mg_cache%k2+0.5d0*mg_cache%gamma*mg_cache%mu*(3._dl*(mg_cache%grhoc_t+mg_cache%grhob_t) &
& + 4._dl*(mg_cache%grhog_t+mg_cache%grhor_t) +3._dl * (mg_cache%grhonu_t + mg_cache%gpresnu_t ))
!> adding massive neutrinos contributions
f1 = mg_cache%k2+3._dl*( mg_cache%adotoa**2 - mg_cache%Hdot )
!f1 = mg_cache%k2+0.5d0*(3._dl*(mg_cache%grhoc_t+mg_cache%grhob_t) &
! & + 4._dl*(mg_cache%grhog_t+mg_cache%grhor_t) + 3._dl*(mg_cache%grhonu_t+mg_cache%gpresnu_t) &
! & + 3._dl*(mg_cache%grhov_t+mg_cache%gpresv_t))
term1 = mg_cache%gamma*mg_cache%mu* f1 * mg_cache%dgq/mg_cache%k
!> adding massive neutrinos contribution, if w_DE /= -1 this has to be changed
!term2 = mg_cache%k2*mg_cache%MG_alpha* ((mg_cache%mu* mg_cache%gamma- 1._dl)*(mg_cache%grhoc_t+mg_cache%grhob_t&
! & +(4._dl/3._dl)*(mg_cache%grhog_t+mg_cache%grhor_t) + (mg_cache%grhonu_t + mg_cache%gpresnu_t)) &
! & - (mg_cache%grhov_t+ mg_cache%gpresv_t))
term2 = mg_cache%k2*mg_cache%MG_alpha* (mg_cache%mu* mg_cache%gamma*( mg_cache%grhoc_t+mg_cache%grhob_t &
& +(4._dl/3._dl)*(mg_cache%grhog_t+mg_cache%grhor_t) + (mg_cache%grhonu_t + mg_cache%gpresnu_t) ) &
& - 2._dl*(mg_cache%adotoa**2 - mg_cache%Hdot))
term3= (mg_cache%mu * ( mg_cache%gamma -1._dl)* mg_cache%adotoa - mg_cache%gamma*mg_cache%mudot &
& - mg_cache%gammadot*mg_cache%mu )*mg_cache%rhoDelta
! typo corrected here
term4 = 2._dl*mg_cache%mu*(mg_cache%gamma - 1._dl)*mg_cache%adotoa*mg_cache%dgpi_w_sum
! separated fromt the previous term
term5 = -2._dl*((mg_cache%gamma-1._dl)*mg_cache%mudot -mg_cache%gammadot*mg_cache%mu)*mg_cache%dgpi
!> adding massive neutrinos contribution
term6= 2._dl * mg_cache%mu*(1._dl - mg_cache%gamma)* mg_cache%pidot_sum
!> calculate etadot
mg_cache%etadot = (term1 + term2 + term3 + term4 + term5 + term6)/( 2._dl * fmu)
!> finally calculate Z
mg_cache%z = mg_cache%sigma - 3._dl * mg_cache%etadot/mg_cache%k
!> Calculate the Newtonian potential
mg_cache%MG_psi = - mg_cache%mu * ( mg_cache%rhoDelta + 2._dl* mg_cache%dgpi)/(2._dl*mg_cache%k2)
!> calculate the curvature perturbation potential
mg_cache%MG_phi = mg_cache%gamma * mg_cache%MG_psi + mg_cache%mu* 1._dl*mg_cache%dgpi/mg_cache%k2
mg_cache%MG_phidot = mg_cache%etadot - mg_cache%adotoa * (mg_cache%MG_psi - mg_cache%adotoa * mg_cache%MG_alpha) &
& - mg_cache%Hdot * mg_cache%MG_alpha
else if ( MG_flag == 1 .and. pure_MG_flag == 3 ) then
! adding massive neutrinos contributions
fQ = mg_cache%k2 + 0.5d0*mg_cache%q * (3._dl*(mg_cache%grhob_t+mg_cache%grhoc_t)+&
& 4._dl*(mg_cache%grhor_t+mg_cache%grhog_t)+3._dl*(mg_cache%grhonu_t + mg_cache%gpresnu_t))
! fixed for w_DE /= -1
!f1=mg_cache%k2+3._dl*( mg_cache%adotoa**2 - mg_cache%Hdot )
f1 = mg_cache%k2+0.5d0*(3._dl*(mg_cache%grhoc_t+mg_cache%grhob_t) &
& + 4._dl*(mg_cache%grhog_t+mg_cache%grhor_t) + 3._dl*(mg_cache%grhonu_t+mg_cache%gpresnu_t) &
& + 3._dl*(mg_cache%grhov_t+mg_cache%gpresv_t))
k2alpha= mg_cache%k * mg_cache%sigma
term1 = mg_cache%q * f1 * mg_cache%dgq/mg_cache%k
term2 = k2alpha * ((mg_cache%q - 1._dl) * ( mg_cache%grhob_t+mg_cache%grhoc_t+(4._dl/3._dl) &
& *(mg_cache%grhor_t+mg_cache%grhog_t) + (mg_cache%grhonu_t + mg_cache%gpresnu_t) &
& ) -mg_cache%grhov_t - mg_cache%gpresv_t)
!term2 = k2alpha * ((mg_cache%q) * ( mg_cache%grhob_t+mg_cache%grhoc_t+(4._dl/3._dl) &
! & *(mg_cache%grhor_t+mg_cache%grhog_t) + (mg_cache%grhonu_t + mg_cache%gpresnu_t)) &
! & - 2._dl *(mg_cache%adotoa**2 - mg_cache%Hdot))
term3 = -( mg_cache%qdot + (mg_cache%r-1._dl) * mg_cache%q * mg_cache%adotoa ) * mg_cache%rhoDelta
mg_cache%etadot = (term1 + term2 + term3)/( 2._dl * fQ )
mg_cache%z = mg_cache%sigma - 3._dl * mg_cache%etadot/mg_cache%k
!calculating also ISW related quantities
mg_cache%MG_psi = mg_cache%r * mg_cache%MG_phi - mg_cache%q * 1._dl * mg_cache%dgpi/mg_cache%k2
mg_cache%MG_phidot = mg_cache%etadot - mg_cache%adotoa * (mg_cache%MG_psi - mg_cache%adotoa * mg_cache%MG_alpha) &
& - mg_cache%Hdot * mg_cache%MG_alpha
end if
! calculate sigmadot
mg_cache%sigmadot = mg_cache%k * (mg_cache%MG_psi - mg_cache%adotoa * mg_cache%MG_alpha)
end subroutine MGCAMB_compute_z
!---------------------------------------------------------------------------
!> this subroutine computes the ISW term in MG
subroutine MGCAMB_compute_ISW( a, mg_par_cache, mg_cache )
use precision
implicit none
real(dl) :: a !< scale factor
type(MGCAMB_timestep_cache), intent(inout) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
!local variables
real(dl) :: term0
term0 = mg_cache%k2 + 3._dl* (mg_cache%adotoa**2._dl - mg_cache%Hdot)
!adding MG_rhoDeltadot
mg_cache%rhoDeltadot = -term0 * mg_cache%dgq/mg_cache%k - (mg_cache%grho + mg_cache%gpres)* mg_cache%k*mg_cache%z &
& - mg_cache%adotoa * mg_cache%rhoDelta - 2._dl * mg_cache%adotoa * mg_cache%dgpi
!adding dgpidot
mg_cache%dgpidot = mg_cache%pidot_sum - (2._dl*mg_cache%dgpi+ mg_cache%dgpi_diff )*mg_cache%adotoa
if (( MG_flag == 1 .and. pure_MG_flag /= 3 ) & ! all the mu, gamma parametrizations
.or. MG_flag == 2 &
.or. MG_flag == 3 ) then
mg_cache%MG_psidot = - 0.5d0*mg_cache%mu/mg_cache%k2*(mg_cache%rhoDeltadot+2._dl*mg_cache%dgpidot) &
& - 0.5d0*mg_cache%mudot/mg_cache%k2*(mg_cache%rhoDelta+2._dl*mg_cache%dgpi)
else if ( MG_flag == 1 .and. pure_MG_flag == 3 ) then
mg_cache%MG_psidot = mg_cache%R * mg_cache%MG_phidot + mg_cache%Rdot * mg_cache%MG_phi - &
& mg_cache%Qdot*mg_cache%dgpi/mg_cache%k2 - mg_cache%Q * mg_cache%dgpidot /mg_cache%k2
end if
mg_cache%MG_ISW = mg_cache%MG_phidot+mg_cache%MG_psidot
mg_cache%MG_alphadot = mg_cache%MG_psi - mg_cache%adotoa * mg_cache%MG_alpha
end subroutine MGCAMB_compute_ISW
!---------------------------------------------------------------------------
!> this subroutine computes the lensing term in MG
subroutine MGCAMB_compute_lensing( a, mg_par_cache, mg_cache )
use precision
implicit none
real(dl) :: a !< scale factor
type(MGCAMB_timestep_cache), intent(inout) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
mg_cache%MG_lensing = mg_cache%MG_phi + mg_cache%MG_psi
end subroutine MGCAMB_compute_lensing
!-----------------------------------------------
!> mu(a,k) function
function MGCAMB_Mu( a, mg_par_cache, mg_cache )
!use ModelParams
implicit none
real(dl) :: a !< scale factor
real(dl) :: MGCAMB_Mu !< MG mu function
type(MGCAMB_timestep_cache), intent(in) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
! local variables
real(dl) :: LKA1 ! \lambda_1^2 k^2 a^s
real(dl) :: LKA2 ! \lambda_1^2 k^2 a^s
real(dl) :: t1, t2, t1dot, t2dot
real(dl) :: omm, ommdot
real(dl) :: omegaDE_t
! beta, m parametrization
real(dl) :: beta, m
!> pure MG models
if ( MG_flag == 1 .and. pure_MG_flag /= 3 ) then
if ( pure_MG_flag == 1 ) then ! mu-gamma
if ( mugamma_par == 1 ) then ! BZ parametrization
LKA1 = lambda1_2 * mg_cache%k2 * a**ss
LKA2 = lambda2_2 * mg_cache%k2 * a**ss
MGCAMB_Mu = (1._dl + B1 * LKA1)/(1._dl + LKA1)
else if ( mugamma_par == 2 ) then ! Planck parametrization
! changing the following
!omegaDE_t = mg_cache%grhov_t / a**2 / 3._dl / mg_par_cache%h0_Mpc**2
omegaDE_t = mg_cache%grhov_t / 3._dl / mg_cache%adotoa**2
MGCAMB_Mu = 1._dl + E11*omegaDE_t
else if ( mugamma_par == 3 ) then ! effective Newton constant
MGCAMB_Mu = 1._dl+ga*(1._dl)**nn - ga*(1._dl)**(2._dl*nn)
else if ( mugamma_par == 4 ) then
MGCAMB_Mu = 1._dl
end if
else if ( pure_MG_flag == 2 ) then ! mu-Sigma
if ( muSigma_par == 1 ) then ! DES parametrization
!omegaDE_t = mg_cache%grhov_t / a**2 / 3._dl / mg_par_cache%h0_Mpc**2
!MGCAMB_Mu = 1._dl + mu0 * omegaDE_t/mg_par_cache%omegav
! this is being changed
omegaDE_t = mg_cache%grhov_t / 3._dl / mg_cache%adotoa**2
MGCAMB_Mu = 1._dl + mu0 * omegaDE_t/mg_par_cache%omegav
else if ( muSigma_par == 2 ) then
MGCAMB_Mu = 1._dl
end if
end if
!> alternative MG
else if ( MG_flag == 2 ) then
if (alt_MG_flag == 1) then !(Linder Gamma)
omm=(mg_par_cache%omegab+mg_par_cache%omegac)/((mg_par_cache%omegab+mg_par_cache%omegac) &
& + (1-mg_par_cache%omegab-mg_par_cache%omegac)*a**3)
ommdot=-3._dl*omm**2*a**3*mg_cache%adotoa*(1-mg_par_cache%omegab-mg_par_cache%omegac) &
& /(mg_par_cache%omegab+mg_par_cache%omegac)
MGCAMB_Mu=2._dl/3._dl*omm**(Linder_gamma-1._dl)*&
(omm**Linder_gamma+2-3._dl*Linder_gamma+3._dl*(Linder_gamma-0.5d0)*omm)
else if ( alt_MG_flag == 2 ) then
MGCAMB_Mu = 1._dl
end if
!> QSA models
else if ( MG_flag == 3 ) then
if ( QSA_flag == 1 ) then ! f(R)
LKA1 = lambda1_2 * mg_cache%k2 * a**ss
LKA2 = lambda2_2 * mg_cache%k2 * a**ss
MGCAMB_Mu = (1._dl + B1 * LKA1)/(1._dl + LKA1)
MGCAMB_Mu = MGCAMB_Mu/(1._dl - 1.4d-8 * lambda1_2 * a**3)
else if ( QSA_flag == 2 .or. & ! beta, m parametrization
QSA_flag == 3 .or. &
QSA_flag == 4 ) then
beta = MGCAMB_Beta( a, mg_par_cache, mg_cache )
m = MGCAMB_M( a, mg_par_cache, mg_cache )
t1 = (2._dl*beta**2._dl)*mg_cache%k2
t2 = (m**2._dl)*a**2._dl
MGCAMB_Mu = (mg_cache%k2 + t1 + t2)/(mg_cache%k2 + t2)
else if ( QSA_flag == 5 ) then
MGCAMB_Mu = 1._dl
end if
end if
end function MGCAMB_Mu
!-----------------------------------------------
!> \dot{mu}(a,k) function
function MGCAMB_Mudot( a, mg_par_cache, mg_cache )
implicit none
real(dl) :: a !< scale factor
real(dl) :: MGCAMB_Mudot !< MG mudot function
type(MGCAMB_timestep_cache), intent(in) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
! local variables
real(dl) :: LKA1 ! \lambda_1^2 k^2 a^s
real(dl) :: LKA2 ! \lambda_1^2 k^2 a^s
real(dl) :: t1,t2,t1dot,t2dot
real(dl) :: omm, ommdot
! mapping beta,m into mu,gamma
real(dl) :: beta, betadot, m, mdot
real(dl) :: mu
real(dl) :: omegaDEdot
!> pure MG models
if ( MG_flag == 1 .and. pure_MG_flag /= 3 ) then
if ( pure_MG_flag == 1 ) then ! mu-gamma
if ( mugamma_par == 1 ) then ! BZ parametrization
LKA1 = lambda1_2 * mg_cache%k2 * a**ss
LKA2 = lambda2_2 * mg_cache%k2 * a**ss
MGCAMB_Mudot = ((B1 - 1._dl) * mg_cache%adotoa * ss * LKA1) / ((1._dl+LKA1)**2._dl)
else if ( mugamma_par == 2 ) then ! Planck parametrization
! changingh the following quantity
!omegaDEdot = - 3._dl * mg_cache%adotoa * (mg_cache%grhov_t + mg_cache%gpresv_t) &
! & / a**2 / 3._dl / mg_par_cache%h0_Mpc**2
omegaDEdot=-(mg_cache%grhov_t+3._dl*mg_cache%gpresv_t)/3._dl/mg_cache%adotoa &
& - 2._dl*mg_cache%Hdot/3._dl/mg_cache%adotoa**3*mg_cache%grhov_t
MGCAMB_Mudot = E11*omegaDEdot
else if ( mugamma_par == 3 ) then
MGCAMB_Mudot = mg_cache%adotoa*a*ga*nn*(-1._dl+2._dl*(1._dl-a)**nn)*(1._dl-a)**(nn-1._dl)
else if ( mugamma_par == 4 ) then
MGCAMB_Mudot = 0._dl
end if
else if ( pure_MG_flag == 2 ) then ! mu-Sigma
if ( muSigma_par == 1 ) then ! DES parametrization
! changing the following
!omegaDEdot = - 3._dl * mg_cache%adotoa * (mg_cache%grhov_t + mg_cache%gpresv_t) &
! & / a**2 / 3._dl / mg_par_cache%h0_Mpc**2
omegaDEdot=-(mg_cache%grhov_t+3._dl*mg_cache%gpresv_t)/3._dl/mg_cache%adotoa &
& - 2._dl*mg_cache%Hdot/3._dl/mg_cache%adotoa**3*mg_cache%grhov_t
MGCAMB_Mudot = mu0 * omegaDEdot/mg_par_cache%omegav
else if ( muSigma_par == 2 ) then
MGCAMB_Mudot = 0._dl
end if
end if
!> alternative MG
else if ( MG_flag == 2 ) then
if (alt_MG_flag == 1) then !(Linder Gamma)
mu = MGCAMB_Mu( a, mg_par_cache, mg_cache )
omm=(mg_par_cache%omegab+mg_par_cache%omegac)/((mg_par_cache%omegab+mg_par_cache%omegac) &
& +(1-mg_par_cache%omegab-mg_par_cache%omegac)*a**3)
ommdot=-3._dl*omm**2*a**3*mg_cache%adotoa*(1-mg_par_cache%omegab-mg_par_cache%omegac) &
& /(mg_par_cache%omegab+mg_par_cache%omegac)
MGCAMB_Mudot = mu/omm*(Linder_gamma-1._dl)*ommdot+&
2._dl/3._dl*omm**(Linder_gamma-1._dl)*ommdot*&
(Linder_gamma*omm**(Linder_gamma-1._dl)+3._dl*(Linder_gamma-0.5d0))
else if ( alt_MG_flag == 2 ) then
MGCAMB_Mudot = 0._dl
end if
!> QSA models
else if ( MG_flag == 3 ) then
if ( QSA_flag == 1 ) then ! f(R)
LKA1 = lambda1_2 * mg_cache%k2 * a**ss
LKA2 = lambda2_2 * mg_cache%k2 * a**ss
MGCAMB_Mudot = ((B1 - 1._dl) * mg_cache%adotoa * ss * LKA1) / ((1._dl+LKA1)**2._dl)
mu = MGCAMB_Mu( a, mg_par_cache, mg_cache )
MGCAMB_Mudot = MGCAMB_Mudot/(1._dl - 1.4d-8 * lambda1_2 * a**3) + 3._dl * &
mu* mg_cache%adotoa *a**3 *(1.4d-8 * lambda1_2 ) &
/(1._dl - 1.4d-8 * lambda1_2 * a**3)
else if ( QSA_flag == 2 .or. & ! beta, m parametrization
QSA_flag == 3 .or. &
QSA_flag == 4 ) then
beta = MGCAMB_Beta( a, mg_par_cache, mg_cache )
m = MGCAMB_M( a, mg_par_cache, mg_cache )
betadot = MGCAMB_Betadot( a, mg_par_cache, mg_cache )
mdot = MGCAMB_Mdot( a, mg_par_cache, mg_cache )
t1 = (2._dl*beta**2._dl)*mg_cache%k2
t2 = (m**2._dl)*a**2._dl
t1dot = 4._dl*beta*betadot*mg_cache%k2
t2dot = (2._dl*a**2._dl)*(m*mdot+ (m**2._dl) *mg_cache%adotoa)
MGCAMB_Mudot = (t1dot*(mg_cache%k2 + t2) - t1*t2dot)/((mg_cache%k2 + t2)**2._dl)
else if ( QSA_flag == 5 ) then
MGCAMB_Mudot = 0._dl
end if
end if
end function MGCAMB_Mudot
!-----------------------------------------------
! gamma(a,k) function
function MGCAMB_Gamma( a, mg_par_cache, mg_cache )
implicit none
real(dl) :: a !< scale factor
real(dl) :: MGCAMB_Gamma !< MG gamma function
type(MGCAMB_timestep_cache), intent(in) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
real(dl) :: LKA1 ! \lambda_1^2 k^2 a^s
real(dl) :: LKA2 ! \lambda_1^2 k^2 a^s
real(dl) :: t1,t2, t1dot, t2dot
real(dl) :: beta, m
real(dl) :: omegaDE_t
real(dl) :: sigma_t
real(dl) :: mu_t
!> pure MG models
if ( MG_flag == 1 .and. pure_MG_flag /= 3 ) then
if ( pure_MG_flag == 1 ) then ! mu-gamma
if ( mugamma_par == 1 ) then ! BZ parametrization
LKA1 = lambda1_2 * mg_cache%k2 * a**ss
LKA2 = lambda2_2 * mg_cache%k2 * a**ss
MGCAMB_Gamma = (1._dl + B2 * LKA2)/(1._dl +LKA2)
else if ( mugamma_par == 2 ) then ! Planck parametrization
! changing the following
!omegaDE_t = mg_cache%grhov_t / a**2 / 3._dl / mg_par_cache%h0_Mpc**2
omegaDE_t = mg_cache%grhov_t / 3._dl / mg_cache%adotoa**2
MGCAMB_Gamma = 1._dl+E22*omegaDE_t
else if ( mugamma_par == 3 ) then
MGCAMB_Gamma = 1._dl
else if ( mugamma_par == 4 ) then
MGCAMB_Gamma = 1._dl
end if
else if ( pure_MG_flag == 2 ) then ! mu-Sigma
if ( muSigma_par == 1 ) then ! DES parametrization
! changing the following
!omegaDE_t = mg_cache%grhov_t / a**2 / 3._dl / mg_par_cache%h0_Mpc**2
omegaDE_t = mg_cache%grhov_t / 3._dl / mg_cache%adotoa**2
sigma_t = 1._dl + sigma0 * omegaDE_t / mg_par_cache%omegav
mu_t = 1._dl + mu0 * omegaDE_t / mg_par_cache%omegav
MGCAMB_Gamma = 2._dl * sigma_t / mu_t - 1._dl
else if ( muSigma_par == 2 ) then
MGCAMB_Gamma = 1._dl
end if
end if
!> alternative MG
else if ( MG_flag == 2 ) then
if (alt_MG_flag == 1) then !(Linder Gamma)
MGCAMB_Gamma = 1._dl
else if ( alt_MG_flag == 2 ) then
MGCAMB_Gamma = 1._dl
end if
!> QSA models
else if ( MG_flag == 3 ) then
if ( QSA_flag == 1 ) then ! f(R)
LKA1 = lambda1_2 * mg_cache%k2 * a**ss
LKA2 = lambda2_2 * mg_cache%k2 * a**ss
MGCAMB_Gamma = (1._dl + B2 * LKA2)/(1._dl +LKA2)
else if ( QSA_flag == 2 .or. & ! beta, m parametrization
QSA_flag == 3 .or. &
QSA_flag == 4 ) then
beta = MGCAMB_Beta( a, mg_par_cache, mg_cache )
m = MGCAMB_M( a, mg_par_cache, mg_cache )
t1 = (2._dl*beta**2._dl)*mg_cache%k2
t2 = (m**2._dl)*a**2._dl
MGCAMB_Gamma = (mg_cache%k2 - t1 + t2)/(mg_cache%k2 + t1 + t2)
else if ( QSA_flag == 5 ) then
MGCAMB_Gamma = 1._dl
end if
end if
end function MGCAMB_Gamma
!-----------------------------------------------
! \dot{gamma}(a,k) function
function MGCAMB_Gammadot( a, mg_par_cache, mg_cache )
implicit none
real(dl) :: a !< scale factor
real(dl) :: MGCAMB_Gammadot !< MG gammadot function
type(MGCAMB_timestep_cache), intent(in) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
real(dl) :: LKA1 ! \lambda_1^2 k^2 a^s
real(dl) :: LKA2 ! \lambda_1^2 k^2 a^s
real(dl) :: t1,t2,t1dot,t2dot
real(dl) :: beta, betadot, m, mdot
real(dl) :: omegaDE_t, omegaDEdot
real(dl) :: sigma_t, sigmadot_t
real(dl) :: mu_t, mudot_t
!> pure MG models
if ( MG_flag == 1 .and. pure_MG_flag /= 3 ) then
if ( pure_MG_flag == 1 ) then ! mu-gamma
if ( mugamma_par == 1 ) then ! BZ parametrization
LKA1 = lambda1_2 * mg_cache%k2 * a**ss
LKA2 = lambda2_2 * mg_cache%k2 * a**ss
MGCAMB_Gammadot = ((B2 -1._dl)*mg_cache%adotoa * ss* LKA2)/((1._dl+LKA2)**2._dl)
else if ( mugamma_par == 2 ) then ! Planck parametrization
! changing the following
!omegaDEdot = - 3._dl * mg_cache%adotoa * (mg_cache%grhov_t + mg_cache%gpresv_t) &
! & / a**2 / 3._dl / mg_par_cache%h0_Mpc**2
omegaDEdot=-(mg_cache%grhov_t+3._dl*mg_cache%gpresv_t)/3._dl/mg_cache%adotoa &
& - 2._dl*mg_cache%Hdot/3._dl/mg_cache%adotoa**3*mg_cache%grhov_t
MGCAMB_Gammadot = E22*omegaDEdot
else if ( mugamma_par == 3 ) then
MGCAMB_Gammadot = 0._dl
else if ( mugamma_par == 4 ) then
MGCAMB_Gammadot = 0._dl
end if
else if ( pure_MG_flag == 2 ) then ! mu-Sigma
if ( muSigma_par == 1 ) then ! DES parametrization
! changing the following
omegaDE_t = mg_cache%grhov_t / 3._dl / mg_cache%adotoa**2
omegaDEdot =-(mg_cache%grhov_t+3._dl*mg_cache%gpresv_t)/3._dl/mg_cache%adotoa &
& - 2._dl*mg_cache%Hdot/3._dl/mg_cache%adotoa**3*mg_cache%grhov_t
sigma_t = 1._dl + sigma0 * omegaDE_t / mg_par_cache%omegav
sigmadot_t = sigma0 * omegaDEdot / mg_par_cache%omegav
mu_t = 1._dl + mu0 * omegaDE_t / mg_par_cache%omegav
mudot_t = mu0 * omegaDEdot / mg_par_cache%omegav
MGCAMB_Gammadot = 2._dl * sigmadot_t / mu_t - 2._dl *sigma_t*mudot_t/mu_t**2
else if ( muSigma_par == 2 ) then
MGCAMB_Gammadot = 0._dl
end if
end if
!> alternative MG
else if ( MG_flag == 2 ) then
if (alt_MG_flag == 1) then !(Linder Gamma)
MGCAMB_Gammadot = 0._dl
else if ( alt_MG_flag == 2 ) then
MGCAMB_Gammadot = 0._dl
end if
!> QSA models
else if ( MG_flag == 3 ) then
if ( QSA_flag == 1 ) then ! f(R)
LKA1 = lambda1_2 * mg_cache%k2 * a**ss
LKA2 = lambda2_2 * mg_cache%k2 * a**ss
MGCAMB_Gammadot = ((B2 -1._dl)*mg_cache%adotoa * ss* LKA2)/((1._dl+LKA2)**2._dl)
else if ( QSA_flag == 2 .or. & ! beta, m parametrization
QSA_flag == 3 .or. &
QSA_flag == 4 ) then
beta = MGCAMB_Beta( a, mg_par_cache, mg_cache )
m = MGCAMB_M( a, mg_par_cache, mg_cache )
betadot = MGCAMB_Betadot( a, mg_par_cache, mg_cache )
mdot = MGCAMB_Mdot( a, mg_par_cache, mg_cache )
t1 = (2._dl*beta**2._dl)*mg_cache%k2
t2 = (m**2._dl)*a**2._dl
t1dot = 4._dl*beta*betadot*mg_cache%k2
t2dot = (2._dl*a**2._dl)*(m*mdot + (m**2._dl) *mg_cache%adotoa)
MGCAMB_Gammadot = 2._dl*(t1*t2dot-t1dot*(mg_cache%k2 + t2))/((mg_cache%k2 + t1 + t2)**2._dl)
else if ( QSA_flag == 5 ) then
MGCAMB_Gammadot = 0._dl
end if
end if
end function MGCAMB_Gammadot
!----------------------------------------------------------------------------------------------
!> MGCAMB (beta, m) parametrization, QSA for scalar-tensor models
!-----------------------------------------------
!> m(a) function
function MGCAMB_M( a, mg_par_cache, mg_cache )
implicit none
real(dl) :: a !< scale factor
real(dl) :: MGCAMB_M !< MG m function
type(MGCAMB_timestep_cache), intent(in) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
real(dl) :: FRm0
! SYMMETRON
if( QSA_flag == 2 ) then
MGCAMB_M = (mg_par_cache%H0/3.0D05) / (xi_star) * sqrt(1._dl-(a_star/a)**3._dl)
! DILATON: based on 1206.3568
else if ( QSA_flag == 3 ) then
MGCAMB_M = (mg_par_cache%H0/3.0D05) /(xi0) * a**(- DilR)
! Hu-Sawicki f(R) model: m, beta parametrization as in 1305.5647
else if ( QSA_flag == 4 )then
FRm0 = (mg_par_cache%h0/3.0D05)*sqrt((4._dl*mg_par_cache%omegav + mg_par_cache%omegab + mg_par_cache%omegac) &
& /((FRn+1._dl)*F_R0))!note factor of c here
MGCAMB_M = FRm0 * ((4._dl * mg_par_cache%omegav + (mg_par_cache%omegab + mg_par_cache%omegac)*a**(-3._dl)) &
& /(4._dl * mg_par_cache%omegav + mg_par_cache%omegab + mg_par_cache%omegac))**(FRn/2._dl+1._dl)
end if
end function MGCAMB_M
!-----------------------------------------------
!> \dot{m}(a) function
function MGCAMB_Mdot( a, mg_par_cache, mg_cache )
implicit none
real(dl) :: a !< scale factor
real(dl) :: MGCAMB_Mdot !< MG mdot function
type(MGCAMB_timestep_cache), intent(in) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
real(dl) :: FRm0
real(dl) :: m
m = MGCAMB_M( a, mg_par_cache, mg_cache )
! SYMMETRON
if( QSA_flag == 2 ) then
MGCAMB_Mdot = 1.5d0*(mg_par_cache%H0/3.0D05)/(xi_star)*((a_star/a)**3._dl*mg_cache%adotoa)/&
& (sqrt(1._dl-(a_star/a)**3._dl))
! DILATON
else if ( QSA_flag == 3 ) then
MGCAMB_Mdot = - DilR * m * mg_cache%adotoa
! Hu-Sawicki f(R) model
else if ( QSA_flag == 4 )then
FRm0 = (mg_par_cache%h0/3.0D05)*sqrt((4._dl*mg_par_cache%omegav + mg_par_cache%omegab + mg_par_cache%omegac)/ &
& ((FRn+1._dl)*F_R0))
MGCAMB_Mdot = m / (4._dl * mg_par_cache%omegav + (mg_par_cache%omegab + mg_par_cache%omegac)*a**(-3._dl)) &
& * (-3._dl*FRn/2._dl-3._dl)*((mg_par_cache%omegab + mg_par_cache%omegac)* a**(-3._dl)*mg_cache%adotoa)!/(4._dl * mg_par_cache%omegav + mg_par_cache%omegab + mg_par_cache%omegac)) ! complete this
end if
end function MGCAMB_Mdot
!-----------------------------------------------
!> beta(a) function
function MGCAMB_Beta( a, mg_par_cache, mg_cache )
implicit none
real(dl) :: a !< scale factor
real(dl) :: MGCAMB_Beta !< MG beta function
type(MGCAMB_timestep_cache), intent(in) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
! SYMMETRON
if( QSA_flag == 2 ) then
MGCAMB_Beta = beta_star * sqrt(1._dl-(a_star/a)**3._dl)
! DILATON
else if ( QSA_flag == 3 ) then
MGCAMB_Beta = beta0 * exp((DilS)/(2._dl* DilR - 3._dl)*(a**(2._dl* DilR - 3._dl)-1._dl))
! Hu-Sawicki f(R) model
else if ( QSA_flag == 4 )then
MGCAMB_Beta = beta0
end if
end function MGCAMB_Beta
!-----------------------------------------------
!> \dot{beta}(a) function
function MGCAMB_Betadot( a, mg_par_cache, mg_cache )
implicit none
real(dl) :: a !< scale factor
real(dl) :: MGCAMB_Betadot !< MG betadot function
type(MGCAMB_timestep_cache), intent(in) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
real(dl) :: beta
beta = MGCAMB_Beta( a, mg_par_cache, mg_cache )
! SYMMETRON
if( QSA_flag == 2 ) then
MGCAMB_Betadot = 1.5d0 * (beta_star * (a_star/a)**3._dl * mg_cache%adotoa) /( sqrt(1._dl-(a_star/a)**3._dl))
! DILATON
else if ( QSA_flag == 3 ) then
MGCAMB_Betadot = beta * (DilS * a**(2._dl* DilR - 3._dl) * mg_cache%adotoa)
! Hu-Sawicki f(R) model
else if ( QSA_flag == 4 )then
MGCAMB_Betadot = 0._dl
end if
end function MGCAMB_Betadot
!----------------------------------------------------------------------------------------------
!> MGCAMB (Q,R) parametrization, QSA for scalar-tensor models
!-----------------------------------------------
!> Q(a,k) function
function MGCAMB_Q( a, mg_par_cache, mg_cache )
implicit none
real(dl) :: a !< scale factor
real(dl) :: MGCAMB_Q !< MG Q function
type(MGCAMB_timestep_cache), intent(in) :: mg_cache !< cache containing the time-dependent quantities
type(MGCAMB_parameter_cache), intent(in) :: mg_par_cache !< cache containing the parameters
if ( QR_par == 1) then
MGCAMB_Q = MGQfix