EFTCAMB  Reference documentation for version 3.0
04p4_exponential_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 exponential_parametrization_1d
40 
41  ! ---------------------------------------------------------------------------------------------
43  type, extends ( parametrized_function_1d ) :: exponential_parametrization_1d
44 
45  real(dl) :: coefficient
46  real(dl) :: exponent
47 
48  contains
49 
50  ! utility functions:
51  procedure :: set_param_number => exponentialparametrized1dsetparamnumber
52  procedure :: init_parameters => exponentialparametrized1dinitparams
53  procedure :: parameter_value => exponentialparametrized1dparametervalues
54  procedure :: feedback => exponentialparametrized1dfeedback
55 
56  ! evaluation procedures:
57  procedure :: value => exponentialparametrized1dvalue
58  procedure :: first_derivative => exponentialparametrized1dfirstderivative
59  procedure :: second_derivative => exponentialparametrized1dsecondderivative
60  procedure :: third_derivative => exponentialparametrized1dthirdderivative
61  procedure :: integral => exponentialparametrized1dintegral
62 
63  end type exponential_parametrization_1d
64 
65 contains
66 
67  ! ---------------------------------------------------------------------------------------------
68  ! Implementation of the exponential function.
69  ! ---------------------------------------------------------------------------------------------
70 
71  ! ---------------------------------------------------------------------------------------------
73  subroutine exponentialparametrized1dsetparamnumber( self )
74 
75  implicit none
76 
77  class(exponential_parametrization_1d) :: self
78 
79  ! initialize the number of parameters:
80  self%parameter_number = 2
81 
82  end subroutine exponentialparametrized1dsetparamnumber
83 
84  ! ---------------------------------------------------------------------------------------------
86  subroutine exponentialparametrized1dinitparams( self, array )
87 
88  implicit none
89 
90  class(exponential_parametrization_1d) :: self
91  real(dl), dimension(self%parameter_number), intent(in) :: array
92 
93  self%coefficient = array(1)
94  self%exponent = array(2)
95 
96  end subroutine exponentialparametrized1dinitparams
97 
98  ! ---------------------------------------------------------------------------------------------
100  subroutine exponentialparametrized1dparametervalues( self, i, value )
101 
102  implicit none
103 
104  class(exponential_parametrization_1d):: self
105  integer , intent(in) :: i
106  real(dl) , intent(out) :: value
107 
108  select case (i)
109  case(1)
110  value = self%coefficient
111  case(2)
112  value = self%exponent
113  case default
114  write(*,*) 'Illegal index for parameter_names.'
115  write(*,*) 'Maximum value is:', self%parameter_number
116  call mpistop('EFTCAMB error')
117  end select
118 
119  end subroutine exponentialparametrized1dparametervalues
120 
121  ! ---------------------------------------------------------------------------------------------
123  subroutine exponentialparametrized1dfeedback( self, print_params )
124 
125  implicit none
126 
127  class(exponential_parametrization_1d) :: self
128  logical, optional :: print_params
130 
131  integer :: i
132  real(dl) :: param_value
133  character(len=EFT_names_max_length) :: param_name
134  logical :: print_params_temp
135 
136  if ( present(print_params) ) then
137  print_params_temp = print_params
138  else
139  print_params_temp = .true.
140  end if
141 
142  write(*,*) 'Exponential function: ', self%name
143  if ( print_params_temp ) then
144  do i=1, self%parameter_number
145  call self%parameter_names( i, param_name )
146  call self%parameter_value( i, param_value )
147  write(*,'(a23,a,F12.6)') param_name, '=', param_value
148  end do
149  end if
150 
151  end subroutine exponentialparametrized1dfeedback
152 
153  ! ---------------------------------------------------------------------------------------------
155  function exponentialparametrized1dvalue( self, x, eft_cache )
156 
157  implicit none
158 
159  class(exponential_parametrization_1d) :: self
160  real(dl), intent(in) :: x
161  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
162  real(dl) :: exponentialparametrized1dvalue
163 
164  exponentialparametrized1dvalue = exp(self%coefficient*x**self%exponent) -1._dl
165  end function exponentialparametrized1dvalue
166 
167  ! ---------------------------------------------------------------------------------------------
169  function exponentialparametrized1dfirstderivative( self, x, eft_cache )
170 
171  implicit none
172 
173  class(exponential_parametrization_1d) :: self
174  real(dl), intent(in) :: x
175  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
176  real(dl) :: exponentialparametrized1dfirstderivative
177 
178  exponentialparametrized1dfirstderivative = self%coefficient*self%exponent*x**(self%exponent-1._dl)*exp(self%coefficient*x**self%exponent)
179 
180  end function exponentialparametrized1dfirstderivative
181 
182  ! ---------------------------------------------------------------------------------------------
184  function exponentialparametrized1dsecondderivative( self, x, eft_cache )
185 
186  implicit none
187 
188  class(exponential_parametrization_1d) :: self
189  real(dl), intent(in) :: x
190  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
191  real(dl) :: exponentialparametrized1dsecondderivative
192 
193  exponentialparametrized1dsecondderivative = self%coefficient*self%exponent*(self%exponent -1._dl +x**self%exponent*self%coefficient*self%exponent)*x**(self%exponent-2._dl)*exp(self%coefficient*x**self%exponent)
194 
195  end function exponentialparametrized1dsecondderivative
196 
197  ! ---------------------------------------------------------------------------------------------
199  function exponentialparametrized1dthirdderivative( self, x, eft_cache )
200 
201  implicit none
202 
203  class(exponential_parametrization_1d) :: self
204  real(dl), intent(in) :: x
205  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
206  real(dl) :: exponentialparametrized1dthirdderivative
207 
208  exponentialparametrized1dthirdderivative = self%coefficient*self%exponent*exp(self%coefficient*x**self%exponent)*x**(self%exponent-3._dl)&
209  & *(2._dl +self%exponent*(-3._dl +self%exponent +x**self%exponent*self%coefficient*(-3._dl +self%exponent*(3._dl +x**self%exponent*self%coefficient))))
210 
211  end function exponentialparametrized1dthirdderivative
212 
213  ! ---------------------------------------------------------------------------------------------
215  function exponentialparametrized1dintegral( self, x, eft_cache )
216 
217  implicit none
218 
219  class(exponential_parametrization_1d) :: self
220  real(dl), intent(in) :: x
221  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
222  real(dl) :: exponentialparametrized1dintegral
223 
224  exponentialparametrized1dintegral = 0._dl
225 
226 
227  write(*,*) 'ExponentialParametrized1DIntegral is not implemented.'
228  write(*,*) 'Calculations cannot proceed.'
229  call mpistop('EFTCAMB error')
230 
231  end function exponentialparametrized1dintegral
232 
233  ! ---------------------------------------------------------------------------------------------
234 
236 
237 !----------------------------------------------------------------------------------------
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 definition of the exponential parametrization, inheriting from parametrized_...
This module contains the abstract class for generic parametrizations for 1D functions that are used b...