EFTCAMB  Reference documentation for version 3.0
11_EFTCAMB_main.f90
Go to the documentation of this file.
1 !----------------------------------------------------------------------------------------
2 !
3 ! This file is part of EFTCAMB.
4 !
5 ! Copyright (C) 2013-2016 by the EFTCAMB authors
6 !
7 ! The EFTCAMB code is free software;
8 ! You can use it, redistribute it, and/or modify it under the terms
9 ! of the GNU General Public License as published by the Free Software Foundation;
10 ! either version 3 of the License, or (at your option) any later version.
11 ! The full text of the license can be found in the file eftcamb/LICENSE at
12 ! the top level of the EFTCAMB distribution.
13 !
14 !----------------------------------------------------------------------------------------
15 
19 
20 
21 !----------------------------------------------------------------------------------------
24 
26 
28 
29  use precision
30  use inifile
31  use amlutils
32  use eft_def
41 
42  implicit none
43 
44  private
45 
46  public eftcamb_version, eftcamb
47 
48  character(LEN=*), parameter :: eftcamb_version = 'V3.0 Dec16'
49 
50  !----------------------------------------------------------------------------------------
54  type eftcamb
55 
56  ! EFTCAMB output root:
57  character(LEN=:), allocatable :: outroot
58 
59  ! EFTCAMB model selection flags:
60  integer :: eftflag
61  integer :: pureeftmodel
62  integer :: altpareftmodel
63  integer :: designereftmodel
64  integer :: fullmappingeftmodel
65 
66  ! EFTCAMB stability flags:
67  logical :: eft_mathematical_stability
68  logical :: eft_physical_stability
69  logical :: eft_additional_priors
70 
71  ! EFTCAMB model:
72  class(eftcamb_model), allocatable :: model
73 
74  ! EFTCAMB working flags:
75  integer :: eftcamb_feedback_level
76  real(dl) :: eftcamb_turn_on_time
77  logical :: eftcamb_model_is_designer
78 
79  contains
80 
81  ! utility functions:
82  procedure :: eftcamb_init_from_file => read_eftcamb_flags_from_file
83  procedure :: eftcamb_init_model_from_file => init_eftcamb_model_from_file
84  procedure :: eftcamb_print_header => print_eftcamb_header
85  procedure :: eftcamb_print_cosmomc_header => print_eftcosmomc_header
86  procedure :: eftcamb_print_model_feedback => print_eftcamb_flags
87  ! model allocation:
88  procedure :: eftcamb_allocate_model => allocate_eftcamb_model
89  procedure :: eftcamb_read_model_selection => read_eftcamb_model_selection
90  procedure :: eftcamb_allocate_model_functions => allocate_eftcamb_model_functions
91  procedure :: eftcamb_read_model_parameters => read_eftcamb_model_parameters
92 
93  end type eftcamb
94 
95  ! ---------------------------------------------------------------------------------------------
96 
97 contains
98 
99  ! ---------------------------------------------------------------------------------------------
101  subroutine read_eftcamb_flags_from_file( self, Ini )
102 
103  implicit none
104 
105  class(eftcamb) :: self
106  type(tinifile) :: ini
107 
108  ! read from the INI file the main EFT flag:
109  self%EFTflag = ini_read_int_file( ini, 'EFTflag' , 0 )
110  ! read the model selection flags:
111  self%PureEFTmodel = ini_read_int_file( ini, 'PureEFTmodel' , 0 )
112  self%AltParEFTmodel = ini_read_int_file( ini, 'AltParEFTmodel' , 0 )
113  self%DesignerEFTmodel = ini_read_int_file( ini, 'DesignerEFTmodel' , 0 )
114  self%FullMappingEFTmodel = ini_read_int_file( ini, 'FullMappingEFTmodel', 0 )
115  ! read the stability flags:
116  self%EFT_mathematical_stability = ini_read_logical_file( ini, 'EFT_mathematical_stability', .true. )
117  self%EFT_physical_stability = ini_read_logical_file( ini, 'EFT_physical_stability' , .true. )
118  self%EFT_additional_priors = ini_read_logical_file( ini, 'EFT_additional_priors' , .true. )
119 
120  ! EFTCAMB working stuff:
121  self%EFTCAMB_feedback_level = ini_read_int_file( ini, 'feedback_level', 1 )
122  self%EFTCAMB_turn_on_time = ini_read_double_file( ini, 'EFTCAMB_turn_on_time', eftturnonpiinitial )
123 
124  end subroutine read_eftcamb_flags_from_file
125 
126  ! ---------------------------------------------------------------------------------------------
128  subroutine init_eftcamb_model_from_file( self, Ini )
129 
130  implicit none
131 
132  class(eftcamb) :: self
133  type(tinifile) :: ini
134 
135  ! allocate model:
136  call self%EFTCAMB_allocate_model()
137  ! read the parameters defining the model from file:
138  call self%EFTCAMB_read_model_selection( ini )
139  ! allocate model functions and parameters:
140  call self%EFTCAMB_allocate_model_functions( )
141  ! read model parameters from file:
142  call self%EFTCAMB_read_model_parameters( ini )
143  ! compute model number of parameters:
144  call self%model%compute_param_number()
145 
146  end subroutine init_eftcamb_model_from_file
147 
148  ! ---------------------------------------------------------------------------------------------
150  subroutine print_eftcamb_header( self )
151 
152  implicit none
153 
154  class(eftcamb) :: self
155 
156  ! check feedback level:
157  if ( .not. self%EFTCAMB_feedback_level > 0 ) return
158  ! if GR return:
159  if ( self%EFTflag == 0 ) return
160  ! print the header:
161  write(*,'(a)') "***************************************************************"
162  write(*,'(a)') " ______________________ __ ______ "
163  write(*,'(a)') " / __/ __/_ __/ ___/ _ | / |/ / _ ) "
164  write(*,'(a)') " / _// _/ / / / /__/ __ |/ /|_/ / _ | "
165  write(*,'(a)') " /___/_/ /_/ \___/_/ |_/_/ /_/____/ "//" "//eftcamb_version
166  write(*,'(a)') " "
167  write(*,'(a)') "***************************************************************"
168 
169  end subroutine print_eftcamb_header
170 
171  ! ---------------------------------------------------------------------------------------------
173  subroutine print_eftcosmomc_header( self )
174 
175  implicit none
176 
177  class(eftcamb) :: self
178 
179  ! check feedback level:
180  if ( .not. self%EFTCAMB_feedback_level > 0 ) return
181  ! if GR return:
182  if ( self%EFTflag == 0 ) return
183  ! print the header:
184  write(*,'(a)') "***************************************************************"
185  write(*,'(a)') " ___________________ __ ________"
186  write(*,'(a)') " / __/ __/_ __/ ___/__ ___ __ _ ___ / |/ / ___/"
187  write(*,'(a)') " / _// _/ / / / /__/ _ \(_-</ ' \/ _ \/ /|_/ / /__ "
188  write(*,'(a)') " /___/_/ /_/ \___/\___/___/_/_/_/\___/_/ /_/\___/ "
189  write(*,'(a)') " "
190  write(*,'(a)') " "//eftcamb_version
191  write(*,'(a)') "***************************************************************"
192 
193  end subroutine print_eftcosmomc_header
194 
195  ! ---------------------------------------------------------------------------------------------
197  subroutine print_eftcamb_flags( self, print_params )
198 
199  implicit none
200 
201  class(eftcamb) :: self
202  logical, optional :: print_params
204 
205  character(len=500) :: temp_name
206  real(dl) :: temp_value
207  integer :: i
208 
209  ! check the allocation of the model:
210  if ( .not. allocated(self%model) ) then
211  write(*,*) 'EFTCAMB WARNING: trying to call EFTCAMB model feedback without allocating the model'
212  call mpistop('EFTCAMB error')
213  end if
214  ! check feedback level:
215  if ( .not. self%EFTCAMB_feedback_level > 0 ) return
216  ! if GR return:
217  if ( self%EFTflag == 0 ) return
218  ! print feedback flag:
219  write(*,*)
220  write(*,'(a, I3)') ' EFTCAMB feedback level =', self%EFTCAMB_feedback_level
221 
222  ! print stability flags:
223  write(*,*)
224  write(*,*) 'EFTCAMB stability flags:'
225 
226  write(*,*) ' Mathematical stability = ', self%EFT_mathematical_stability
227  write(*,*) ' Physical stability = ', self%EFT_physical_stability
228  write(*,*) ' Additional priors = ', self%EFT_additional_priors
229  write(*,*)
230  ! print model selection flags:
231  write(*,*) 'EFTCAMB model flags:'
232  write(*,"(A24,I3)") ' EFTflag =', self%EFTflag
233  if ( self%EFTflag == 1 ) &
234  write(*,"(A24,I3)") ' PureEFTmodel =', self%PureEFTmodel
235  if ( self%EFTflag == 2 ) &
236  write(*,"(A24,I3)") ' AltParEFTmodel =', self%AltParEFTmodel
237  if ( self%EFTflag == 3 ) &
238  write(*,"(A24,I3)") ' DesignerEFTmodel =', self%DesignerEFTmodel
239  if ( self%EFTflag == 4 ) &
240  write(*,"(A24,I3)") ' FullMappingEFTmodel =', self%FullMappingEFTmodel
241  ! print model informations:
242  call self%model%feedback( print_params )
243  ! leave one white line:
244  write(*,*)
245 
246  end subroutine print_eftcamb_flags
247 
248  ! ---------------------------------------------------------------------------------------------
251  subroutine allocate_eftcamb_model( self )
252 
253  implicit none
254 
255  class(eftcamb) :: self
256 
257  ! check the allocation of the model:
258  if ( allocated(self%model) ) deallocate(self%model)
259 
260  ! do the allocation:
261  select case ( self%EFTflag )
262 
263  case (0) ! GR: no need to allocate
264 
265  case (1) ! Pure EFT:
266 
267  select case ( self%PureEFTmodel )
268  case(1)
269  allocate( eftcamb_std_pure_eft::self%model )
270  call self%model%init( 'Standard Pure EFT', 'Standard Pure EFT' )
271  case default
272  write(*,'(a,I3)') 'No model corresponding to EFTFlag =', self%EFTflag
273  write(*,'(a,I3)') 'and PureEFTmodel =', self%PureEFTmodel
274  write(*,'(a)') 'Please select an appropriate model:'
275  write(*,'(a)') 'PureEFTmodel=1 standard Pure EFT'
276  call mpistop('EFTCAMB error')
277  end select
278 
279  case (2) ! Alternative EFT:
280 
281  select case ( self%AltParEFTmodel )
282  case(1)
283  allocate( eftcamb_rph::self%model )
284  call self%model%init( 'RPH', 'RPH' )
285  case default
286  write(*,'(a,I3)') 'No model corresponding to EFTFlag =', self%EFTflag
287  write(*,'(a,I3)') 'and AltParEFTmodel =', self%AltParEFTmodel
288  write(*,'(a)') 'Please select an appropriate model:'
289  write(*,'(a)') 'AltParEFTmodel=1 reparametrized Horndeski'
290  call mpistop('EFTCAMB error')
291  end select
292 
293  case (3) ! Designer mapping EFT:
294 
295  select case ( self%DesignerEFTmodel )
296  case(1)
297  allocate( eftcamb_fr_designer::self%model )
298  call self%model%init( 'Designer f(R)', 'Designer f(R)' )
299  case(2)
300  allocate( eftcamb_des_mc_quint::self%model )
301  call self%model%init( 'Designer minimally coupled quintessence', 'Designer minimally coupled quintessence' )
302  case default
303  write(*,'(a,I3)') 'No model corresponding to EFTFlag =', self%EFTflag
304  write(*,'(a,I3)') 'and DesignerEFTmodel =', self%DesignerEFTmodel
305  write(*,'(a)') 'Please select an appropriate model:'
306  write(*,'(a)') 'DesignerEFTmodel=1 designer f(R)'
307  write(*,'(a)') 'DesignerEFTmodel=2 designer minimally coupled quintessence'
308  call mpistop('EFTCAMB error')
309  end select
310 
311  case (4) ! Full mapping EFT:
312 
313  select case ( self%FullMappingEFTmodel )
314  case(1)
315  allocate( eftcamb_horava::self%model )
316  call self%model%init( 'Horava', 'Horava' )
317  case default
318  write(*,'(a,I3)') 'No model corresponding to EFTFlag =', self%EFTflag
319  write(*,'(a,I3)') 'and FullMappingEFTmodel =', self%FullMappingEFTmodel
320  write(*,'(a)') 'Please select an appropriate model:'
321  write(*,'(a)') 'FullMappingEFTmodel=1 Horava gravity'
322  call mpistop('EFTCAMB error')
323  end select
324 
325  case default ! not found:
326 
327  write(*,'(a,I3)') 'No model corresponding to EFTFlag =', self%EFTflag
328  write(*,'(a)') 'Please select an appropriate model:'
329  write(*,'(a)') 'EFTFlag=0 GR code'
330  write(*,'(a)') 'EFTFlag=1 Pure EFT'
331  write(*,'(a)') 'EFTFlag=2 EFT alternative parametrizations'
332  write(*,'(a)') 'EFTFlag=3 designer mapping EFT'
333  write(*,'(a)') 'EFTFlag=4 full mapping EFT'
334  call mpistop('EFTCAMB error')
335 
336  end select
337 
338  ! now store the designer flag:
339  select type ( model => self%model )
340  class is ( eftcamb_full_model )
341  self%EFTCAMB_model_is_designer = .false.
342  class is ( eftcamb_designer_model )
343  self%EFTCAMB_model_is_designer = .true.
344  end select
345 
346  end subroutine allocate_eftcamb_model
347 
348  ! ---------------------------------------------------------------------------------------------
350  subroutine read_eftcamb_model_selection( self, Ini )
351 
352  implicit none
353 
354  class(eftcamb) :: self
355  type(tinifile) :: ini
356 
357  ! check the allocation of the model:
358  if ( .not. allocated(self%model) ) then
359  write(*,*) 'EFTCAMB WARNING: trying to call EFTCAMB model read_model_selection'
360  write(*,*) ' without allocating the model'
361  call mpistop('EFTCAMB error')
362  end if
363 
364  ! call the model specific read parameters:
365  call self%model%read_model_selection( ini )
366 
367  end subroutine read_eftcamb_model_selection
368 
369  ! ---------------------------------------------------------------------------------------------
372  subroutine allocate_eftcamb_model_functions( self )
373 
374  implicit none
375 
376  class(eftcamb) :: self
377 
378  ! check the allocation of the model:
379  if ( .not. allocated(self%model) ) then
380  write(*,*) 'EFTCAMB WARNING: trying to call EFTCAMB model allocate_model_selection'
381  write(*,*) ' without allocating the model'
382  call mpistop('EFTCAMB error')
383  end if
384 
385  ! call the model specific read parameters:
386  call self%model%allocate_model_selection( )
387 
388  end subroutine allocate_eftcamb_model_functions
389 
390  ! ---------------------------------------------------------------------------------------------
392  subroutine read_eftcamb_model_parameters( self, Ini )
393 
394  implicit none
395 
396  class(eftcamb) :: self
397  type(tinifile) :: ini
398 
399  ! check the allocation of the model:
400  if ( .not. allocated(self%model) ) then
401  write(*,*) 'EFTCAMB WARNING: trying to call EFTCAMB model read_model_parameters_from_file'
402  write(*,*) ' without allocating the model'
403  call mpistop('EFTCAMB error')
404  end if
405 
406  ! call the model specific read parameters:
407  call self%model%init_model_parameters_from_file( ini )
408 
409  end subroutine read_eftcamb_model_parameters
410 
411  ! ---------------------------------------------------------------------------------------------
412 
413 end module eftcamb_main
414 
415 !----------------------------------------------------------------------------------------
real(dl), parameter eftturnonpiinitial
Turn on pi field flag: Sets the scale factor at which the code starts to evolve the pi field...
Definition: 01_EFT_def.f90:33
This module contains the definition of the designer minimally coupled quintessence model...
This module contains the abstract definition of all the places where EFTCAMB interacts with CAMB...
This module contains the definition of low energy (LE) Horava gravity. Please refer to the numerical ...
Definition: 10p1_Horava.f90:27
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.
Definition: 01_EFT_def.f90:25
This module contains the definition of the Pure EFT model in which the EFT is described by six functi...
This module contains the general EFTCAMB driver. We have a type that encapsulate all EFTCAMB paramete...
This module contains the definition of an EFT reparametrization of Horndeski models. This is described by four functions of time and w_DE. Please refer to the numerical notes for details.
Definition: 08p1_RPH.f90:28
character(len=*), parameter, public eftcamb_version
This module contains the relevant code for designer f(R) models.