42 real(dl),
save :: pasta1 = 0._dl
43 real(dl),
save :: pastat = 0._dl
54 logical ,
intent(out) :: success
55 class(eftcamb) ,
intent(in) :: input_EFTCAMB
56 type(eftcamb_parameter_cache),
intent(inout) :: params_cache
57 real(dl) ,
intent(in) :: astart
58 real(dl) ,
intent(in) :: aend
59 real(dl) ,
intent(inout) :: k_max
62 integer ,
parameter :: indMax = 10000
63 real(dl),
parameter :: LogSamplingScale = -10._dl
69 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
then 70 write(*,
'(a)')
'***************************************************************' 71 write(*,
'(a)')
' EFTCAMB: checking stability of the theory' 73 if ( input_eftcamb%EFTCAMB_feedback_level > 2 )
then 83 atest = astart +
REAL(ind-1)*(aend-astart)/
REAL(indmax-1)
85 if ( .not. success )
then 86 if ( input_eftcamb%EFTCAMB_feedback_level > 2 )
then 88 write(*,
'(a,E14.4)')
' Instability detected at a =', atest
97 y = logsamplingscale +
REAL(ind-1)*(0._dl-logsamplingscale)/
REAL(indmax-1)
98 atest = astart +(aend-astart)*10._dl**y
100 if ( .not. success )
then 101 if ( input_eftcamb%EFTCAMB_feedback_level > 2 )
then 103 write(*,
'(a,E14.4)')
' Instability detected at a =', atest
112 atest = aend +(astart-aend)*10._dl**y
114 if ( .not. success )
then 115 if ( input_eftcamb%EFTCAMB_feedback_level > 2 )
then 117 write(*,
'(a,E14.4)')
' Instability detected at a =', atest
124 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
then 125 write(*,
'(a)')
' EFTCAMB: theory stable' 136 real(dl) ,
intent(in) :: a
137 real(dl) ,
intent(inout) :: k_max
138 class(eftcamb) ,
intent(in) :: input_EFTCAMB
139 type(eftcamb_parameter_cache),
intent(inout) :: params_cache
140 logical :: EFTTestStability
143 type(eftcamb_timestep_cache ) :: eft_cache
144 logical :: EFT_HaveNan_parameter, EFT_HaveNan_timestep
145 real(dl) :: EFT_instability_rate, tempk, temp1, temp2, temp3, temp4, temp5
146 integer :: ind_max, ind
149 eftteststability = .true.
151 call eft_cache%initialize()
155 if ( k_max < 0.1_dl ) k_max = 0.1_dl
160 call params_cache%is_nan( eft_havenan_parameter )
161 if ( eft_havenan_parameter )
then 162 eftteststability = .false.
163 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a)')
' Model has Nan in the parameter cache' 167 call eft_cache%is_nan( eft_havenan_timestep )
168 if ( eft_havenan_timestep )
then 169 eftteststability = .false.
170 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a)')
' Model has Nan in the timestep cache' 174 if ( input_eftcamb%EFT_mathematical_stability )
then 180 if ( eft_cache%EFTpiA1*pasta1 < 0._dl )
then 181 eftteststability = .false.
182 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a)')
' Mathematical instability: A is zero in time' 184 pasta1 = eft_cache%EFTpiA1
186 if ( (eft_cache%EFTpiA1 > 0 .and. eft_cache%EFTpiA1 + k_max**2*eft_cache%EFTpiA2 < 0) .or. &
187 &(eft_cache%EFTpiA1 < 0 .and. eft_cache%EFTpiA1 + k_max**2*eft_cache%EFTpiA2 > 0) )
then 188 eftteststability = .false.
189 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a)')
' Mathematical instability: A is zero in k' 196 if ( eft_cache%EFTAT*pastat < 0._dl )
then 197 eftteststability = .false.
198 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a)')
' Mathematical instability: AT is zero in time' 200 pastat = eft_cache%EFTAT
208 eft_instability_rate = 0._dl
215 tempk = 0._dl +
REAL(ind-1)*(k_max)/
REAL(ind_max-1)
217 temp1 = (eft_cache%EFTpiB1 +eft_cache%EFTpiB2*tempk**2)
218 temp2 = (eft_cache%EFTpiA1 +eft_cache%EFTpiA2*tempk**2)
219 temp3 = temp1**2 -4._dl*temp2*(eft_cache%EFTpiC +eft_cache%EFTpiD1*tempk**2 + eft_cache%EFTpiD2*tempk**4)
222 if ( temp3 > 0._dl .and. temp2 /= 0._dl )
then 223 temp4 = +0.5_dl*(-temp1 +sqrt(temp3))/temp2
224 temp5 = +0.5_dl*(-temp1 -sqrt(temp3))/temp2
225 if ( temp4>eft_instability_rate .or. temp5>eft_instability_rate )
then 226 eftteststability = .false.
227 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
then 228 write(*,
'(a,E11.4)')
' Mathematical instability: growing exponential at k =', tempk
229 write(*,
'(a,E11.4,E11.4)')
' Rate of instability: ', temp4, temp5
234 else if ( temp2 /= 0._dl )
then 235 temp4 = -0.5_dl*temp1/temp2
236 if ( temp4>eft_instability_rate )
then 237 eftteststability = .false.
238 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
then 239 write(*,
'(a,E11.4)')
' Mathematical instability: growing exponential at k =', tempk
240 write(*,
'(a,E11.4,E11.4)')
' Rate of instability: ', temp4
250 if ( input_eftcamb%EFT_additional_priors )
then 251 eftteststability = input_eftcamb%model%additional_model_stability( a, params_cache, eft_cache )
252 if ( .not. eftteststability )
then 253 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a)')
' Model specific stability criteria are not met' 257 if ( input_eftcamb%EFT_physical_stability )
then 260 if ( (eft_cache%EFTGamma6V /= 0._dl) .or. &
261 & ( (eft_cache%EFTGamma3V + eft_cache%EFTGamma4V) /= 0._dl) )
then 262 write(*,
'(a)')
' EFTCAMB WARNING: stability for model beyond GLPV has not been worked out.' 263 write(*,
'(a)')
' It will be added in a future release.' 264 write(*,
'(a)')
' If you want to run this model disable EFT_physical_stability.' 265 eftteststability = .false.
270 if ( 1._dl +eft_cache%EFTOmegaV <= 0 )
then 271 eftteststability = .false.
272 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a,E11.4)')
' Physical instability: negative gravitational constant = ', 1._dl +eft_cache%EFTOmegaV
276 if ( eft_cache%EFT_kinetic < 0._dl )
then 277 eftteststability = .false.
278 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a,E11.4)')
' Physical instability: ghost instability. Kinetic term = ', eft_cache%EFT_kinetic
282 if ( eft_cache%EFT_gradient < 0._dl )
then 283 eftteststability = .false.
284 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a,E11.4)')
' Physical instability: gradient instability. Gradient term = ', eft_cache%EFT_gradient
288 if ( eft_cache%EFTAT < 0 )
then 289 eftteststability = .false.
290 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a,E11.4)')
' Physical instability: tensor ghost instability. Tensor kinetic term = ', eft_cache%EFTAT
294 if ( eft_cache%EFTDT < 0 )
then 295 eftteststability = .false.
296 if ( input_eftcamb%EFTCAMB_feedback_level > 1 )
write(*,
'(a,E11.4)')
' Physical instability: tensor gradient instability. Tensor gradient term = ', eft_cache%EFTDT
321 real(dl),
intent(in) :: a
322 class(eftcamb_model) ,
intent(in) :: input_model
323 type(eftcamb_parameter_cache),
intent(inout) :: params_cache
324 type(eftcamb_timestep_cache ),
intent(inout) :: eft_cache
327 real(dl) :: grhonu, gpinu, grhormass_t, grhonudot, gpinudot
328 integer :: nu_i, ind, ind_max
333 eft_cache%grhob_t = params_cache%grhob/a
334 eft_cache%grhoc_t = params_cache%grhoc/a
335 eft_cache%grhor_t = params_cache%grhornomass/a/a
336 eft_cache%grhog_t = params_cache%grhog/a/a
338 if ( params_cache%Num_Nu_Massive /= 0 )
then 339 do nu_i = 1, params_cache%Nu_mass_eigenstates
342 grhormass_t = params_cache%grhormass(nu_i)/a**2
343 call params_cache%Nu_background(a*params_cache%nu_masses(nu_i), grhonu, gpinu )
344 eft_cache%grhonu_tot = eft_cache%grhonu_tot +grhormass_t*grhonu
345 eft_cache%gpinu_tot = eft_cache%gpinu_tot +grhormass_t*gpinu
349 eft_cache%grhom_t = eft_cache%grhob_t +eft_cache%grhoc_t +eft_cache%grhor_t +eft_cache%grhog_t +eft_cache%grhonu_tot
350 eft_cache%gpresm_t = (+eft_cache%grhor_t +eft_cache%grhog_t)/3._dl +eft_cache%gpinu_tot
352 select type ( model_temp => input_model )
354 class is ( eftcamb_full_model )
357 call input_model%compute_background_EFT_functions( a, params_cache , eft_cache )
358 call input_model%compute_adotoa( a, params_cache , eft_cache )
359 class is ( eftcamb_designer_model )
363 call input_model%compute_adotoa( a, params_cache , eft_cache )
367 if ( params_cache%Num_Nu_Massive /= 0 )
then 368 do nu_i = 1, params_cache%Nu_mass_eigenstates
373 grhormass_t = params_cache%grhormass(nu_i)/a**2
374 call params_cache%Nu_background( a*params_cache%nu_masses(nu_i), grhonu, gpinu )
375 eft_cache%grhonu_tot = eft_cache%grhonu_tot + grhormass_t*grhonu
376 eft_cache%gpinu_tot = eft_cache%gpinu_tot + grhormass_t*gpinu
377 eft_cache%grhonudot_tot = eft_cache%grhonudot_tot + grhormass_t*( params_cache%Nu_drho(a*params_cache%nu_masses(nu_i) ,eft_cache%adotoa, grhonu)&
378 & -4._dl*eft_cache%adotoa*grhonu)
379 eft_cache%gpinudot_tot = eft_cache%gpinudot_tot + grhormass_t*( params_cache%Nu_pidot(a*params_cache%nu_masses(nu_i),eft_cache%adotoa, gpinu )&
380 & -4._dl*eft_cache%adotoa*gpinu)
384 eft_cache%gpresdotm_t = -4._dl*eft_cache%adotoa*( eft_cache%grhog_t +eft_cache%grhor_t )/3._dl +eft_cache%gpinudot_tot
386 call input_model%compute_H_derivs( a, params_cache , eft_cache )
388 select type ( model_temp => input_model )
389 class is ( eftcamb_designer_model )
390 call input_model%compute_background_EFT_functions( a, params_cache , eft_cache )
393 call input_model%compute_rhoQPQ( a, params_cache , eft_cache )
395 call input_model%compute_secondorder_EFT_functions( a, params_cache , eft_cache )
397 call input_model%compute_pi_factors( a, params_cache , eft_cache )
399 call input_model%compute_tensor_factors( a, params_cache , eft_cache )
401 call input_model%compute_stability_factors( a, params_cache , eft_cache )
This module contains the definition of the EFTCAMB caches. These are used to store parameters that ca...
This module contains the abstract definition of all the places where EFTCAMB interacts with CAMB...
subroutine, public eftstabilitycomputation(a, input_model, params_cache, eft_cache)
Subroutine that fills the caches to check the stability of the theory.
This module contains the stability detection algorithm of EFTCAMB.
subroutine, public eftstability_cleanup()
Subroutine that restores the values stored in the module to the default. Needed for successive calls...
This module contains the abstract definition of all the places where EFTCAMB interacts with CAMB in c...
This module contains the abstract definition of all the places where EFTCAMB interacts with CAMB in c...
This module contains the definitions of all the EFTCAMB compile time flags.
logical function, public eftteststability(a, k_max, input_EFTCAMB, params_cache)
Function that fills the caches to check the stability of the theory.
This module contains the general EFTCAMB driver. We have a type that encapsulate all EFTCAMB paramete...
subroutine, public eftcamb_stability_check(success, input_EFTCAMB, params_cache, astart, aend, k_max)
Subroutine that tests the stability of a theory in a time range. To ensure best time coverage scans w...