EFTCAMB  Reference documentation for version 3.0
04p1_constant_parametrizations_1D.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 amlutils
31  use eft_def
32  use eftcamb_cache
34 
35  implicit none
36 
37  private
38 
39  public constant_parametrization_1d
40 
41  ! ---------------------------------------------------------------------------------------------
43  type, extends ( parametrized_function_1d ) :: constant_parametrization_1d
44 
45  real(dl) :: constant_value
46 
47  contains
48 
49  ! utility functions:
50  procedure :: set_param_number => constantparametrized1dsetparamnumber
51  procedure :: init_parameters => constantparametrized1dinitparams
52  procedure :: parameter_value => constantparametrized1dparametervalues
53  procedure :: feedback => constantparametrized1dfeedback
54 
55  ! evaluation procedures:
56  procedure :: value => constantparametrized1dvalue
57  procedure :: first_derivative => constantparametrized1dfirstderivative
58  procedure :: second_derivative => constantparametrized1dsecondderivative
59  procedure :: third_derivative => constantparametrized1dthirdderivative
60  procedure :: integral => constantparametrized1dintegral
61 
62  end type constant_parametrization_1d
63 
64 contains
65 
66  ! ---------------------------------------------------------------------------------------------
67  ! Implementation of the constant function.
68  ! ---------------------------------------------------------------------------------------------
69 
70  ! ---------------------------------------------------------------------------------------------
72  subroutine constantparametrized1dsetparamnumber( self )
73 
74  implicit none
75 
76  class(constant_parametrization_1d) :: self
77 
78  ! initialize the number of parameters:
79  self%parameter_number = 1
80 
81  end subroutine constantparametrized1dsetparamnumber
82 
83  ! ---------------------------------------------------------------------------------------------
85  subroutine constantparametrized1dinitparams( self, array )
86 
87  implicit none
88 
89  class(constant_parametrization_1d) :: self
90  real(dl), dimension(self%parameter_number), intent(in) :: array
91 
92  self%constant_value = array(1)
93 
94  end subroutine constantparametrized1dinitparams
95 
96  ! ---------------------------------------------------------------------------------------------
98  subroutine constantparametrized1dfeedback( self, print_params )
99 
100  implicit none
101 
102  class(constant_parametrization_1d) :: self
103  logical, optional :: print_params
105 
106  integer :: i
107  real(dl) :: param_value
108  character(len=EFT_names_max_length) :: param_name
109  logical :: print_params_temp
110 
111  if ( present(print_params) ) then
112  print_params_temp = print_params
113  else
114  print_params_temp = .true.
115  end if
116 
117  write(*,*) 'Constant function: ', self%name
118  if ( print_params_temp ) then
119  do i=1, self%parameter_number
120  call self%parameter_names( i, param_name )
121  call self%parameter_value( i, param_value )
122  write(*,'(a23,a,F12.6)') param_name, '=', param_value
123  end do
124  end if
125 
126  end subroutine constantparametrized1dfeedback
127 
128  ! ---------------------------------------------------------------------------------------------
130  subroutine constantparametrized1dparametervalues( self, i, value )
131 
132  implicit none
133 
134  class(constant_parametrization_1d) :: self
135  integer , intent(in) :: i
136  real(dl) , intent(out) :: value
137 
138  select case (i)
139  case(1)
140  value = self%constant_value
141  case default
142  write(*,*) 'In constant_parametrization_1D:', self%name
143  write(*,*) 'Illegal index for parameter_names.'
144  write(*,*) 'Maximum value is:', self%parameter_number
145  call mpistop('EFTCAMB error')
146  end select
147 
148  end subroutine constantparametrized1dparametervalues
149 
150  ! ---------------------------------------------------------------------------------------------
152  function constantparametrized1dvalue( self, x, eft_cache )
153 
154  implicit none
155 
156  class(constant_parametrization_1d) :: self
157  real(dl), intent(in) :: x
158  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
159  real(dl) :: constantparametrized1dvalue
160 
161  constantparametrized1dvalue = self%constant_value
162 
163  end function constantparametrized1dvalue
164 
165  ! ---------------------------------------------------------------------------------------------
167  function constantparametrized1dfirstderivative( self, x, eft_cache )
168 
169  implicit none
170 
171  class(constant_parametrization_1d) :: self
172  real(dl), intent(in) :: x
173  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
174  real(dl) :: constantparametrized1dfirstderivative
175 
176  constantparametrized1dfirstderivative = 0._dl
177 
178  end function constantparametrized1dfirstderivative
179 
180  ! ---------------------------------------------------------------------------------------------
182  function constantparametrized1dsecondderivative( self, x, eft_cache )
183 
184  implicit none
185 
186  class(constant_parametrization_1d) :: self
187  real(dl), intent(in) :: x
188  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
189  real(dl) :: constantparametrized1dsecondderivative
190 
191  constantparametrized1dsecondderivative = 0._dl
192 
193  end function constantparametrized1dsecondderivative
194 
195  ! ---------------------------------------------------------------------------------------------
197  function constantparametrized1dthirdderivative( self, x, eft_cache )
198 
199  implicit none
200 
201  class(constant_parametrization_1d) :: self
202  real(dl), intent(in) :: x
203  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
204  real(dl) :: constantparametrized1dthirdderivative
205 
206  constantparametrized1dthirdderivative = 0._dl
207 
208  end function constantparametrized1dthirdderivative
209 
210  ! ---------------------------------------------------------------------------------------------
212  function constantparametrized1dintegral( self, x, eft_cache )
213 
214  implicit none
215 
216  class(constant_parametrization_1d) :: self
217  real(dl), intent(in) :: x
218  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
219  real(dl) :: constantparametrized1dintegral
220 
221  constantparametrized1dintegral = x**(-1._dl-3._dl*self%constant_value)
222 
223  end function constantparametrized1dintegral
224 
225  ! ---------------------------------------------------------------------------------------------
226 
228 
229 !----------------------------------------------------------------------------------------
This module contains the definition of the constant parametrization, inheriting from parametrized_fun...
This module contains the definition of the EFTCAMB caches. These are used to store parameters that ca...
This module contains the definitions of all the EFTCAMB compile time flags.
Definition: 01_EFT_def.f90:25
This module contains the abstract class for generic parametrizations for 1D functions that are used b...