EFTCAMB  Reference documentation for version 3.0
05p2_bilinear_parametrizations_2D.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 bilinear_parametrization_2d
40 
41  ! ---------------------------------------------------------------------------------------------
43  type, extends ( parametrized_function_2d ) :: bilinear_parametrization_2d
44 
45  real(dl) :: linear_value_1
46  real(dl) :: linear_value_2
47 
48  contains
49 
50  ! utility functions:
51  procedure :: set_param_number => bilinearparametrized2dsetparamnumber
52  procedure :: init_parameters => bilinearparametrized2dinitparams
53  procedure :: parameter_value => bilinearparametrized2dparametervalues
54  procedure :: feedback => bilinearparametrized2dfeedback
55 
56  ! evaluation procedures:
57  procedure :: value => bilinearparametrized2dvalue
58  procedure :: first_derivative_x => bilinearparametrized2dfirstderivativex
59  procedure :: first_derivative_y => bilinearparametrized2dfirstderivativey
60  procedure :: second_derivative_x => bilinearparametrized2dsecondderivativex
61  procedure :: second_derivative_y => bilinearparametrized2dsecondderivativey
62  procedure :: second_derivative_xy => bilinearparametrized2dsecondderivativexy
63 
64  end type bilinear_parametrization_2d
65 
66 contains
67 
68  ! ---------------------------------------------------------------------------------------------
69  ! Implementation of the bilinear parametrization for 2D functions.
70  ! ---------------------------------------------------------------------------------------------
71 
72  ! ---------------------------------------------------------------------------------------------
74  subroutine bilinearparametrized2dsetparamnumber( self )
75 
76  implicit none
77 
78  class(bilinear_parametrization_2d) :: self
79 
80  ! initialize the number of parameters:
81  self%parameter_number = 2
82 
83  end subroutine bilinearparametrized2dsetparamnumber
84 
85  ! ---------------------------------------------------------------------------------------------
87  subroutine bilinearparametrized2dinitparams( self, array )
88 
89  implicit none
90 
91  class(bilinear_parametrization_2d) :: self
92  real(dl), dimension(self%parameter_number), intent(in) :: array
93 
94  self%linear_value_1 = array(1)
95  self%linear_value_2 = array(2)
96 
97  end subroutine bilinearparametrized2dinitparams
98 
99  ! ---------------------------------------------------------------------------------------------
101  subroutine bilinearparametrized2dparametervalues( self, i, value )
102 
103  implicit none
104 
105  class(bilinear_parametrization_2d) :: self
106  integer , intent(in) :: i
107  real(dl) , intent(out) :: value
108 
109  select case (i)
110  case(1)
111  value = self%linear_value_1
112  case(2)
113  value = self%linear_value_2
114  case default
115  write(*,*) 'Illegal index for parameter_names.'
116  write(*,*) 'Maximum value is:', self%parameter_number
117  call mpistop('EFTCAMB error')
118  end select
119 
120  end subroutine bilinearparametrized2dparametervalues
121 
122  ! ---------------------------------------------------------------------------------------------
124  subroutine bilinearparametrized2dfeedback( self, print_params )
125 
126  implicit none
127 
128  class(bilinear_parametrization_2d) :: self
129  logical, optional :: print_params
131 
132  integer :: i
133  real(dl) :: param_value
134  character(len=EFT_names_max_length) :: param_name
135  logical :: print_params_temp
136 
137  if ( present(print_params) ) then
138  print_params_temp = print_params
139  else
140  print_params_temp = .true.
141  end if
142 
143  write(*,*) 'Bilinear function: ', self%name
144  if ( print_params_temp ) then
145  do i=1, self%parameter_number
146  call self%parameter_names( i, param_name )
147  call self%parameter_value( i, param_value )
148  write(*,'(a23,a,F12.6)') param_name, '=', param_value
149  end do
150  end if
151 
152  end subroutine bilinearparametrized2dfeedback
153 
154  ! ---------------------------------------------------------------------------------------------
156 
157  function bilinearparametrized2dvalue( self, x, y, eft_cache )
158 
159  implicit none
160 
161  class(bilinear_parametrization_2d) :: self
162  real(dl), intent(in) :: x
163  real(dl), intent(in) :: y
164  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
165  real(dl) :: bilinearparametrized2dvalue
166 
167  bilinearparametrized2dvalue = self%linear_value_1*x + self%linear_value_2*y
168 
169  end function bilinearparametrized2dvalue
170 
171  ! ---------------------------------------------------------------------------------------------
173  ! first variable, of the bilinear function.
174 
175  function bilinearparametrized2dfirstderivativex( self, x, y, eft_cache )
176 
177  implicit none
178 
179  class(bilinear_parametrization_2d) :: self
180  real(dl), intent(in) :: x
181  real(dl), intent(in) :: y
182  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
183  real(dl) :: bilinearparametrized2dfirstderivativex
184 
185  bilinearparametrized2dfirstderivativex = self%linear_value_1
186 
187  end function bilinearparametrized2dfirstderivativex
188 
189  ! ---------------------------------------------------------------------------------------------
191  ! second variable, of the bilinear function.
192 
193  function bilinearparametrized2dfirstderivativey( self, x, y, eft_cache )
194 
195  implicit none
196 
197  class(bilinear_parametrization_2d) :: self
198  real(dl), intent(in) :: x
199  real(dl), intent(in) :: y
200  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
201  real(dl) :: bilinearparametrized2dfirstderivativey
202 
203  bilinearparametrized2dfirstderivativey = self%linear_value_2
204 
205  end function bilinearparametrized2dfirstderivativey
206 
207  ! ---------------------------------------------------------------------------------------------
209  function bilinearparametrized2dsecondderivativex( self, x, y, eft_cache )
210 
211  implicit none
212 
213  class(bilinear_parametrization_2d) :: self
214  real(dl), intent(in) :: x
215  real(dl), intent(in) :: y
216  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
217  real(dl) :: bilinearparametrized2dsecondderivativex
218 
219  bilinearparametrized2dsecondderivativex = 0._dl
220 
221  end function bilinearparametrized2dsecondderivativex
222 
223  ! ---------------------------------------------------------------------------------------------
225  function bilinearparametrized2dsecondderivativey( self, x, y, eft_cache )
226 
227  implicit none
228 
229  class(bilinear_parametrization_2d) :: self
230  real(dl), intent(in) :: x
231  real(dl), intent(in) :: y
232  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
233  real(dl) :: bilinearparametrized2dsecondderivativey
234 
235  bilinearparametrized2dsecondderivativey = 0._dl
236 
237  end function bilinearparametrized2dsecondderivativey
238 
239  ! ---------------------------------------------------------------------------------------------
241  function bilinearparametrized2dsecondderivativexy( self, x, y, eft_cache )
242 
243  implicit none
244 
245  class(bilinear_parametrization_2d) :: self
246  real(dl), intent(in) :: x
247  real(dl), intent(in) :: y
248  type(eftcamb_timestep_cache), intent(in), optional :: eft_cache
249  real(dl) :: bilinearparametrized2dsecondderivativexy
250 
251  bilinearparametrized2dsecondderivativexy = 0._dl
252 
253  end function bilinearparametrized2dsecondderivativexy
254 
255  !----------------------------------------------------------------------------------------
256 
258 
259 !----------------------------------------------------------------------------------------
This module contains the definition of the EFTCAMB caches. These are used to store parameters that ca...
This module contains the definition of the bilinear parametrization, inheriting from parametrized_fun...
This module contains the abstract class for generic parametrizations for 2D functions that are used b...
This module contains the definitions of all the EFTCAMB compile time flags.
Definition: 01_EFT_def.f90:25