EFTCAMB  Reference documentation for version 3.0
04p2_linear_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 linear_parametrization_1d
40 
41  ! ---------------------------------------------------------------------------------------------
43  type, extends ( parametrized_function_1d ) :: linear_parametrization_1d
44 
45  real(dl) :: linear_value
46 
47  contains
48 
49  ! utility functions:
50  procedure :: set_param_number => linearparametrized1dsetparamnumber
51  procedure :: init_parameters => linearparametrized1dinitparams
52  procedure :: parameter_value => linearparametrized1dparametervalues
53  procedure :: feedback => linearparametrized1dfeedback
54 
55  ! evaluation procedures:
56  procedure :: value => linearparametrized1dvalue
57  procedure :: first_derivative => linearparametrized1dfirstderivative
58  procedure :: second_derivative => linearparametrized1dsecondderivative
59  procedure :: third_derivative => linearparametrized1dthirdderivative
60  procedure :: integral => linearparametrized1dintegral
61 
62  end type linear_parametrization_1d
63 
64 contains
65 
66  ! ---------------------------------------------------------------------------------------------
67  ! Implementation of the linear function.
68  ! ---------------------------------------------------------------------------------------------
69 
70  ! ---------------------------------------------------------------------------------------------
72  subroutine linearparametrized1dsetparamnumber( self )
73 
74  implicit none
75 
76  class(linear_parametrization_1d) :: self
77 
78  ! initialize the number of parameters:
79  self%parameter_number = 1
80 
81  end subroutine linearparametrized1dsetparamnumber
82 
83  ! ---------------------------------------------------------------------------------------------
85  subroutine linearparametrized1dinitparams( self, array )
86 
87  implicit none
88 
89  class(linear_parametrization_1d) :: self
90  real(dl), dimension(self%parameter_number), intent(in) :: array
91 
92  self%linear_value = array(1)
93 
94  end subroutine linearparametrized1dinitparams
95 
96  ! ---------------------------------------------------------------------------------------------
98  subroutine linearparametrized1dparametervalues( self, i, value )
99 
100  implicit none
101 
102  class(linear_parametrization_1d) :: self
103  integer , intent(in) :: i
104  real(dl) , intent(out) :: value
105 
106  select case (i)
107  case(1)
108  value = self%linear_value
109  case default
110  write(*,*) 'Illegal index for parameter_names.'
111  write(*,*) 'Maximum value is:', self%parameter_number
112  call mpistop('EFTCAMB error')
113  end select
114 
115  end subroutine linearparametrized1dparametervalues
116 
117  ! ---------------------------------------------------------------------------------------------
119  subroutine linearparametrized1dfeedback( self, print_params )
120 
121  implicit none
122 
123  class(linear_parametrization_1d) :: self
124  logical, optional :: print_params
126 
127  integer :: i
128  real(dl) :: param_value
129  character(len=EFT_names_max_length) :: param_name
130  logical :: print_params_temp
131 
132  if ( present(print_params) ) then
133  print_params_temp = print_params
134  else
135  print_params_temp = .true.
136  end if
137 
138  write(*,*) 'Linear function: ', self%name
139  if ( print_params_temp ) then
140  do i=1, self%parameter_number
141  call self%parameter_names( i, param_name )
142  call self%parameter_value( i, param_value )
143  write(*,'(a23,a,F12.6)') param_name, '=', param_value
144  end do
145  end if
146 
147  end subroutine linearparametrized1dfeedback
148 
149  ! ---------------------------------------------------------------------------------------------
151  function linearparametrized1dvalue( self, x, eft_cache )
152 
153  implicit none
154 
155  class(linear_parametrization_1d) :: self
156  real(dl), intent(in) :: x
157  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
158  real(dl) :: linearparametrized1dvalue
159 
160  linearparametrized1dvalue = self%linear_value*x
161 
162  end function linearparametrized1dvalue
163 
164  ! ---------------------------------------------------------------------------------------------
166  function linearparametrized1dfirstderivative( self, x, eft_cache )
167 
168  implicit none
169 
170  class(linear_parametrization_1d) :: self
171  real(dl), intent(in) :: x
172  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
173  real(dl) :: linearparametrized1dfirstderivative
174 
175  linearparametrized1dfirstderivative = self%linear_value
176 
177  end function linearparametrized1dfirstderivative
178 
179  ! ---------------------------------------------------------------------------------------------
181  function linearparametrized1dsecondderivative( self, x, eft_cache )
182 
183  implicit none
184 
185  class(linear_parametrization_1d) :: self
186  real(dl), intent(in) :: x
187  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
188  real(dl) :: linearparametrized1dsecondderivative
189 
190  linearparametrized1dsecondderivative = 0._dl
191 
192  end function linearparametrized1dsecondderivative
193 
194  ! ---------------------------------------------------------------------------------------------
196  function linearparametrized1dthirdderivative( self, x, eft_cache )
197 
198  implicit none
199 
200  class(linear_parametrization_1d) :: self
201  real(dl), intent(in) :: x
202  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
203  real(dl) :: linearparametrized1dthirdderivative
204 
205  linearparametrized1dthirdderivative = 0._dl
206 
207  end function linearparametrized1dthirdderivative
208 
209  ! ---------------------------------------------------------------------------------------------
211  function linearparametrized1dintegral( self, x, eft_cache )
212 
213  implicit none
214 
215  class(linear_parametrization_1d) :: self
216  real(dl), intent(in) :: x
217  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
218  real(dl) :: linearparametrized1dintegral
219 
220  linearparametrized1dintegral = exp(-3._dl*(x-1._dl)*self%linear_value)/x
221 
222  end function linearparametrized1dintegral
223 
224  ! ---------------------------------------------------------------------------------------------
225 
227 
228 !----------------------------------------------------------------------------------------
This module contains the definition of the EFTCAMB caches. These are used to store parameters that ca...
This module contains the definition of the linear parametrization, inheriting from parametrized_funct...
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...