PROGRESS  master
prg_xlbo_mod.F90
Go to the documentation of this file.
1 
7 
9  use bml
11 
12  implicit none
13 
14  private
15 
16  integer, parameter :: dp = kind(1.0d0)
17 
19  real(dp), parameter :: c0 = -6.0_dp
20  real(dp), parameter :: c1 = 14.0_dp
21  real(dp), parameter :: c2 = -8.0_dp
22  real(dp), parameter :: c3 = -3.0_dp
23  real(dp), parameter :: c4 = 4.0_dp
24  real(dp), parameter :: c5 = -1.0_dp;
25 
27  real(dp), parameter :: kappa = 1.82_dp;
28  real(dp), parameter :: alpha = 0.018_dp;
29  real(dp), parameter :: cc = 0.9_dp; ! Scaled prg_delta kernel
30 
33  type, public :: xlbo_type
34 
35  character(20) :: jobname
36 
37  integer :: verbose
38 
40  integer :: maxscfiter
41 
43  integer :: maxscfinititer
44 
45  real(dp) :: threshold
46 
48  integer :: minit
49 
51  real(dp) :: cc
52 
53  end type xlbo_type
54 
57 
58 contains
59 
62  subroutine prg_parse_xlbo(xlbo,filename)
63 
64  implicit none
65  type(xlbo_type), intent(inout) :: xlbo
66  integer, parameter :: nkey_char = 1, nkey_int = 4, nkey_re = 2, nkey_log = 1
67  character(len=*) :: filename
68 
69  !Library of keywords with the respective defaults.
70  character(len=50), parameter :: keyvector_char(nkey_char) = [character(len=100) :: &
71  'JobName=']
72  character(len=100) :: valvector_char(nkey_char) = [character(len=100) :: &
73  'MyJob']
74 
75  character(len=50), parameter :: keyvector_int(nkey_int) = [character(len=50) :: &
76  'Verbose=','Mprg_init=','MaxSCFIter=', 'MaxSCFInitIter=']
77  integer :: valvector_int(nkey_int) = (/ &
78  0, 6, 0, 4 /)
79 
80  character(len=50), parameter :: keyvector_re(nkey_re) = [character(len=50) :: &
81  'NumThresh=', 'ScaledDeltaKernel=' ]
82  real(dp) :: valvector_re(nkey_re) = (/&
83  0.0, 0.99 /)
84 
85  character(len=50), parameter :: keyvector_log(nkey_log) = [character(len=100) :: &
86  'Log1=']
87  logical :: valvector_log(nkey_log) = (/&
88  .false. /)
89 
90  !Start and stop characters
91  character(len=50), parameter :: startstop(2) = [character(len=50) :: &
92  'XLBO{', '}']
93 
94  call prg_parsing_kernel(keyvector_char,valvector_char&
95  ,keyvector_int,valvector_int,keyvector_re,valvector_re,&
96  keyvector_log,valvector_log,trim(filename),startstop)
97 
98  !Characters
99  xlbo%JobName = valvector_char(1)
100 
101  !Reals
102  xlbo%threshold = valvector_re(1)
103  xlbo%cc = valvector_re(2)
104 
105  !Logicals
106 
107  !Integers
108  xlbo%verbose = valvector_int(1)
109  xlbo%minit = valvector_int(2)
110  xlbo%maxscfiter = valvector_int(3)
111  xlbo%maxscfinititer = valvector_int(4)
112 
113  end subroutine prg_parse_xlbo
114 
115 
118  subroutine prg_xlbo_nint(charges,n,n_0,n_1,n_2,n_3,n_4,n_5,mdstep,xl)
119  implicit none
120  real(dp), allocatable, intent(inout) :: n(:), n_0(:), n_1(:), n_2(:), n_3(:), n_4(:), n_5(:)
121  real(dp), allocatable, intent(in) :: charges(:)
122  type(xlbo_type), intent(in) :: xl
123 
124  integer, intent(in) :: mdstep
125  integer :: nats
126 
127  nats = size(charges,dim=1)
128 
129  if(.not.allocated(n))then
130  allocate(n(nats))
131  allocate(n_0(nats))
132  allocate(n_1(nats))
133  allocate(n_2(nats))
134  allocate(n_3(nats))
135  allocate(n_4(nats))
136  allocate(n_5(nats))
137  endif
138 
139  if(mdstep.le.1)then
140  n = charges;
141  n_0 = charges;
142  n_1 = charges;
143  n_2 = charges;
144  n_3 = charges;
145  n_4 = charges;
146  n_5 = charges;
147  endif
148 
149  n = 2.0_dp*n_0 - n_1 + xl%cc*kappa*(charges-n) &
150  + alpha*(c0*n_0+c1*n_1+c2*n_2+c3*n_3+c4*n_4+c5*n_5);
151  n_5 = n_4; n_4 = n_3; n_3 = n_2; n_2 = n_1; n_1 = n_0; n_0 = n;
152 
153  end subroutine prg_xlbo_nint
154 
155 
158  subroutine prg_xlbo_nint_kernel(charges,n,n_0,n_1,n_2,n_3,n_4,n_5,mdstep,kernel,xl)
159  implicit none
160  real(dp), allocatable, intent(inout) :: n(:), n_0(:), n_1(:), n_2(:), n_3(:), n_4(:), n_5(:)
161  real(dp), allocatable, intent(in) :: charges(:)
162  real(dp), allocatable, intent(in) :: kernel(:,:)
163  type(xlbo_type), intent(in) :: xl
164 
165  integer, intent(in) :: mdstep
166  integer :: nats
167 
168  nats = size(charges,dim=1)
169 
170  if(.not.allocated(n))then
171  allocate(n(nats))
172  allocate(n_0(nats))
173  allocate(n_1(nats))
174  allocate(n_2(nats))
175  allocate(n_3(nats))
176  allocate(n_4(nats))
177  allocate(n_5(nats))
178  endif
179 
180  if(mdstep.le.1)then
181  n = charges;
182  n_0 = charges;
183  n_1 = charges;
184  n_2 = charges;
185  n_3 = charges;
186  n_4 = charges;
187  n_5 = charges;
188  endif
189 
190  ! From developper's code
191  ! dn2dt2 = -MATMUL(KK0,(q-n))
192  ! n = 2*n_0 - n_1 + kappa*dn2dt2 +
193  ! alpha*(C0*n_0+C1*n_1+C2*n_2+C3*n_3+C4*n_4+C5*n_5+C6*n_6)
194  ! n_6 = n_5; n_5 = n_4; n_4 = n_3; n_3 = n_2; n_2 = n_1; n_1 = n_0; n_0 = n
195 
196  !call bml_print_matrix("ker",kernel,1,10,1,10)
197  !write(*,*)matmul(kernel,(charges-n))
198  !n = 2.0_dp*n_0 - n_1 + xl%cc*kappa*(charges-n) &
199  n = 2.0_dp*n_0 - n_1 - 1.0_dp*kappa*matmul(kernel,(charges-n)) &
200  + alpha*(c0*n_0+c1*n_1+c2*n_2+c3*n_3+c4*n_4+c5*n_5);
201  n_5 = n_4; n_4 = n_3; n_3 = n_2; n_2 = n_1; n_1 = n_0; n_0 = n;
202 
203  end subroutine prg_xlbo_nint_kernel
204 
205 
210  subroutine prg_xlbo_nint_kerneltimesres(charges,n,n_0,n_1,n_2,n_3,n_4,n_5,mdstep,kernelTimesRes,xl)
211  implicit none
212  real(dp), allocatable, intent(inout) :: n(:), n_0(:), n_1(:), n_2(:), n_3(:), n_4(:), n_5(:)
213  real(dp), allocatable, intent(in) :: charges(:)
214  real(dp), allocatable, intent(in) :: kerneltimesres(:)
215  type(xlbo_type), intent(in) :: xl
216 
217  integer, intent(in) :: mdstep
218  integer :: nats
219 
220  nats = size(charges,dim=1)
221 
222  if(.not.allocated(n))then
223  allocate(n(nats))
224  allocate(n_0(nats))
225  allocate(n_1(nats))
226  allocate(n_2(nats))
227  allocate(n_3(nats))
228  allocate(n_4(nats))
229  allocate(n_5(nats))
230  endif
231 
232  if(mdstep.le.1)then
233  n = charges;
234  n_0 = charges;
235  n_1 = charges;
236  n_2 = charges;
237  n_3 = charges;
238  n_4 = charges;
239  n_5 = charges;
240  endif
241 
242  n = 2.0_dp*n_0 - n_1 - 1.0_dp*kappa*kerneltimesres &
243  & + alpha*(c0*n_0+c1*n_1+c2*n_2+c3*n_3+c4*n_4+c5*n_5);
244  n_5 = n_4; n_4 = n_3; n_3 = n_2; n_2 = n_1; n_1 = n_0; n_0 = n;
245 
246  end subroutine prg_xlbo_nint_kerneltimesres
247 
248 
249 
252  subroutine prg_xlbo_fcoulupdate(fcoul,charges,n)
253  implicit none
254  real(dp), intent(inout) :: fcoul(:,:),charges(:)
255  real(dp), intent(inout) :: n(:)
256 
257  fcoul(1,:) = (2.0_dp*charges(:)-n(:))*fcoul(1,:)/n(:);
258  fcoul(2,:) = (2.0_dp*charges(:)-n(:))*fcoul(2,:)/n(:);
259  fcoul(3,:) = (2.0_dp*charges(:)-n(:))*fcoul(3,:)/n(:);
260 
261  end subroutine prg_xlbo_fcoulupdate
262 
263 end module prg_xlbo_mod
Some general parsing functions.
subroutine, public prg_parsing_kernel(keyvector_char, valvector_char, keyvector_int, valvector_int, keyvector_re, valvector_re, keyvector_log, valvector_log, filename, startstop)
The general parsing function. It is used to vectorize a set of "keywords" "value" pairs as included i...
Module to handle input output files for the PROGRESS lib.
A module to perform XLBO integration.
Definition: prg_xlbo_mod.F90:6
real(dp), parameter kappa
Coefficients for modified Verlet integration.
real(dp), parameter c5
subroutine, public prg_xlbo_nint_kernel(charges, n, n_0, n_1, n_2, n_3, n_4, n_5, mdstep, kernel, xl)
This routine integrates the dynamical variable "n".
real(dp), parameter c3
real(dp), parameter c1
real(dp), parameter c4
real(dp), parameter alpha
subroutine, public prg_xlbo_nint(charges, n, n_0, n_1, n_2, n_3, n_4, n_5, mdstep, xl)
This routine integrates the dynamical variable "n".
subroutine, public prg_xlbo_fcoulupdate(fcoul, charges, n)
Adjust forces for the linearized XLBOMD functional.
real(dp), parameter c2
real(dp), parameter c0
Coefficients for modified Verlet integration.
subroutine, public prg_parse_xlbo(xlbo, filename)
The parser for XLBO parser.
subroutine, public prg_xlbo_nint_kerneltimesres(charges, n, n_0, n_1, n_2, n_3, n_4, n_5, mdstep, kernelTimesRes, xl)
This routine integrates the dynamical variable "n".
real(dp), parameter cc
General xlbo solver type.