(git:08825b9)
Loading...
Searching...
No Matches
xc_ke_gga.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Calculate the several different kinetic energy functionals
10!> with a GGA form
11!> \par History
12!> JGH (26.02.2003) : OpenMP enabled
13!> fawzi (04.2004) : adapted to the new xc interface
14!> \author JGH (20.02.2002)
15! **************************************************************************************************
17
19 USE kinds, ONLY: dp
20 USE mathconstants, ONLY: pi
24 deriv_rho,&
33 USE xc_input_constants, ONLY: ke_lc,&
34 ke_llp,&
35 ke_ol1,&
36 ke_ol2,&
37 ke_pbe,&
38 ke_pw86,&
39 ke_pw91,&
40 ke_t92
44#include "../base/base_uses.f90"
45
46 IMPLICIT NONE
47
48 PRIVATE
49
50 REAL(KIND=dp), PARAMETER :: f13 = 1.0_dp/3.0_dp, &
51 f23 = 2.0_dp*f13, &
52 f43 = 4.0_dp*f13, &
53 f53 = 5.0_dp*f13
54
56
57 REAL(KIND=dp) :: cf, b, b_lda, b_lsd, flda, flsd, sfac, t13
58 REAL(KIND=dp) :: fact, tact
59 REAL(KIND=dp) :: eps_rho
60
61 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'xc_ke_gga'
62
63CONTAINS
64
65! **************************************************************************************************
66!> \brief ...
67!> \param cutoff ...
68! **************************************************************************************************
69 SUBROUTINE ke_gga_init(cutoff)
70
71 REAL(KIND=dp), INTENT(IN) :: cutoff
72
73 eps_rho = cutoff
74 CALL set_util(cutoff)
75
76 cf = 0.3_dp*(3.0_dp*pi*pi)**f23
77 flda = cf
78 flsd = flda*2.0_dp**f23
79! the_factor 2^(1/3) for LDA is here
80 b_lda = 2.0_dp**f43*(3.0_dp*pi*pi)**(f13)
81 b_lsd = 2.0_dp*(3.0_dp*pi*pi)**(f13)
82 sfac = 1.0_dp/(2.0_dp*(3.0_dp*pi*pi)**f13)
83 t13 = 2.0_dp**f13
84
85 END SUBROUTINE ke_gga_init
86
87! **************************************************************************************************
88!> \brief ...
89!> \param functional ...
90!> \param lsd ...
91!> \param reference ...
92!> \param shortform ...
93!> \param needs ...
94!> \param max_deriv ...
95! **************************************************************************************************
96 SUBROUTINE ke_gga_info(functional, lsd, reference, shortform, needs, max_deriv)
97 INTEGER, INTENT(in) :: functional
98 LOGICAL, INTENT(in) :: lsd
99 CHARACTER(LEN=*), INTENT(OUT), OPTIONAL :: reference, shortform
100 TYPE(xc_rho_cflags_type), INTENT(inout), OPTIONAL :: needs
101 INTEGER, INTENT(out), OPTIONAL :: max_deriv
102
103 IF (PRESENT(reference)) THEN
104 SELECT CASE (functional)
105 CASE (ke_ol1)
106 reference = "H. Ou-Yang and M. Levy, "// &
107 "Intl. J. Quant. Chem. 40, 379 (1991); Functional 1"
108 CASE (ke_ol2)
109 reference = "H. Ou-Yang and M. Levy, "// &
110 "Intl. J. Quant. Chem. 40, 379 (1991); Functional 2"
111 CASE (ke_llp)
112 reference = "H. Lee, C. Lee, R.G. Parr, Phys. Rev. A, 44, 768 (1991)"
113 CASE (ke_pw86)
114 reference = "J.P. Perdew and Y. Wang, Phys. Rev. B, 33, 8800 (1986)"
115 CASE (ke_pw91)
116 reference = "J.P. Perdew and Y. Wang, Electronic Structure of Solids 91"
117 CASE (ke_lc)
118 reference = "A. Lembarki and H. Chermette, Phys. Rev. A, 50, 5328 (1994)"
119 CASE (ke_t92)
120 reference = "A.J. Thakkar, Phys. Rev. A, 46, 6920 (1992)"
121 CASE (ke_pbe)
122 reference = "J.P.Perdew, K.Burke, M.Ernzerhof, Phys. Rev. Letter, 77, 3865 (1996)"
123 END SELECT
124 IF (.NOT. lsd) THEN
125 IF (len_trim(reference) + 6 < len(reference)) THEN
126 reference(len_trim(reference):len_trim(reference) + 6) = ' {spin unpolarized}'
127 END IF
128 END IF
129 END IF
130 IF (PRESENT(shortform)) THEN
131 SELECT CASE (functional)
132 CASE (ke_ol1)
133 shortform = "Ou-Yang-Levy Functional 1"
134 CASE (ke_ol2)
135 shortform = "Ou-Yang-Levy Functional 2"
136 CASE (ke_llp)
137 shortform = "Lee-Lee-Parr Functional"
138 CASE (ke_pw86)
139 shortform = "Perdew-Wang 1986 Functional (kinetic energy)"
140 CASE (ke_pw91)
141 shortform = "Perdew-Wang 1991 Functional (kinetic energy)"
142 CASE (ke_lc)
143 shortform = "Lembarki-Chermette kinetic energy functional"
144 CASE (ke_t92)
145 shortform = "Thakkar 1992 Functional"
146 CASE (ke_pbe)
147 shortform = "Perdew-Burke-Ernzerhof Functional (kinetic energy)"
148 END SELECT
149 IF (.NOT. lsd) THEN
150 IF (len_trim(shortform) + 6 < len(shortform)) THEN
151 shortform(len_trim(shortform):len_trim(shortform) + 6) = ' {spin unpolarized}'
152 END IF
153 END IF
154 END IF
155 IF (PRESENT(needs)) THEN
156 IF (lsd) THEN
157 needs%rho_spin = .true.
158 needs%rho_spin_1_3 = .true.
159 needs%norm_drho_spin = .true.
160 ELSE
161 needs%rho = .true.
162 needs%rho_1_3 = .true.
163 needs%norm_drho = .true.
164 END IF
165 END IF
166 IF (PRESENT(max_deriv)) max_deriv = 3
167
168 END SUBROUTINE ke_gga_info
169
170! **************************************************************************************************
171!> \brief ...
172!> \param functional ...
173!> \param rho_set ...
174!> \param deriv_set ...
175!> \param order ...
176! **************************************************************************************************
177 SUBROUTINE ke_gga_lda_eval(functional, rho_set, deriv_set, order)
178
179 INTEGER, INTENT(IN) :: functional
180 TYPE(xc_rho_set_type), INTENT(IN) :: rho_set
181 TYPE(xc_derivative_set_type), INTENT(IN) :: deriv_set
182 INTEGER, INTENT(IN) :: order
183
184 CHARACTER(LEN=*), PARAMETER :: routinen = 'ke_gga_lda_eval'
185
186 INTEGER :: handle, npoints
187 INTEGER, DIMENSION(2, 3) :: bo
188 REAL(kind=dp) :: drho_cutoff, rho_cutoff
189 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: s
190 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: fs
191 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_0, e_ndrho, e_ndrho_ndrho, &
192 e_ndrho_ndrho_ndrho, e_rho, e_rho_ndrho, e_rho_ndrho_ndrho, e_rho_rho, e_rho_rho_ndrho, &
193 e_rho_rho_rho, grho, rho, rho13
194 TYPE(xc_derivative_type), POINTER :: deriv
195
196 CALL timeset(routinen, handle)
197 NULLIFY (rho, rho13, e_0, e_rho, e_ndrho, &
198 e_rho_rho, e_rho_ndrho, e_ndrho_ndrho, &
199 e_rho_rho_rho, e_rho_rho_ndrho, e_rho_ndrho_ndrho, e_ndrho_ndrho_ndrho)
200
201 CALL xc_rho_set_get(rho_set, rho_1_3=rho13, rho=rho, &
202 norm_drho=grho, local_bounds=bo, rho_cutoff=rho_cutoff, &
203 drho_cutoff=drho_cutoff)
204 npoints = (bo(2, 1) - bo(1, 1) + 1)*(bo(2, 2) - bo(1, 2) + 1)*(bo(2, 3) - bo(1, 3) + 1)
205 CALL ke_gga_init(rho_cutoff)
206
207 ALLOCATE (s(npoints))
208 ALLOCATE (fs(npoints, order + 1))
209
210! s = norm_drho/(rho^(4/3)*2*(pi*pi*3)^(1/3))
211 CALL calc_wave_vector("p", rho, grho, s)
212
213 fact = flda
214! Definition of s has changed
215 b = b_lda
216! tact = t13
217 tact = 1.0_dp
218
219 SELECT CASE (functional)
220 CASE (ke_ol1)
221 CALL efactor_ol1(s, fs, order)
222 cpabort("OL1 functional currently not working properly")
223 CASE (ke_ol2)
224 CALL efactor_ol2(s, fs, order)
225 cpabort("OL2 functional currently not working properly")
226 CASE (ke_llp)
227 CALL efactor_llp(s, fs, order)
228 CASE (ke_pw86)
229 CALL efactor_pw86(s, fs, order)
230 CASE (ke_pw91)
231 CALL efactor_pw91(s, fs, order, 1)
232 CASE (ke_lc)
233 CALL efactor_pw91(s, fs, order, 2)
234 CASE (ke_t92)
235 CALL efactor_t92(s, fs, order)
236 CASE (ke_pbe)
237 CALL efactor_pbex(s, fs, order, 1)
238 CASE DEFAULT
239 cpabort("Unsupported functional")
240 END SELECT
241
242 deriv => xc_dset_get_derivative(deriv_set, [INTEGER::], &
243 allocate_deriv=.true.)
244 CALL xc_derivative_get(deriv, deriv_data=e_0)
245
246 CALL kex_p_0(rho, rho13, fs, e_0, npoints)
247
248 IF (order >= 1) THEN
249 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho], &
250 allocate_deriv=.true.)
251 CALL xc_derivative_get(deriv, deriv_data=e_rho)
252 deriv => xc_dset_get_derivative(deriv_set, [deriv_norm_drho], &
253 allocate_deriv=.true.)
254 CALL xc_derivative_get(deriv, deriv_data=e_ndrho)
255
256 CALL kex_p_1(rho, rho13, s, fs, e_rho=e_rho, e_ndrho=e_ndrho, &
257 npoints=npoints)
258 END IF
259 IF (order >= 2) THEN
260 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho], &
261 allocate_deriv=.true.)
262 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho)
263 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_norm_drho], &
264 allocate_deriv=.true.)
265 CALL xc_derivative_get(deriv, deriv_data=e_rho_ndrho)
266 deriv => xc_dset_get_derivative(deriv_set, &
267 [deriv_norm_drho, deriv_norm_drho], allocate_deriv=.true.)
268 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrho)
269
270 CALL kex_p_2(rho, rho13, s, fs, e_rho_rho=e_rho_rho, &
271 e_rho_ndrho=e_rho_ndrho, e_ndrho_ndrho=e_ndrho_ndrho, npoints=npoints)
272 END IF
273 IF (order >= 3) THEN
274 deriv => xc_dset_get_derivative(deriv_set, [deriv_rho, deriv_rho, deriv_rho], &
275 allocate_deriv=.true.)
276 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_rho)
277 deriv => xc_dset_get_derivative(deriv_set, &
278 [deriv_rho, deriv_rho, deriv_norm_drho], allocate_deriv=.true.)
279 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_ndrho)
280 deriv => xc_dset_get_derivative(deriv_set, &
281 [deriv_rho, deriv_norm_drho, deriv_norm_drho], allocate_deriv=.true.)
282 CALL xc_derivative_get(deriv, deriv_data=e_rho_ndrho_ndrho)
283 deriv => xc_dset_get_derivative(deriv_set, &
284 [deriv_norm_drho, deriv_norm_drho, deriv_norm_drho], allocate_deriv=.true.)
285 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrho_ndrho)
286
287 CALL kex_p_3(rho, rho13, s, fs, e_rho_rho_rho=e_rho_rho_rho, &
288 e_rho_rho_ndrho=e_rho_rho_ndrho, e_rho_ndrho_ndrho=e_rho_ndrho_ndrho, &
289 e_ndrho_ndrho_ndrho=e_ndrho_ndrho_ndrho, npoints=npoints)
290 END IF
291 IF (order > 3) THEN
292 cpabort("derivatives bigger than 3 not implemented")
293 END IF
294
295 DEALLOCATE (s)
296 DEALLOCATE (fs)
297
298 CALL timestop(handle)
299
300 END SUBROUTINE ke_gga_lda_eval
301
302! **************************************************************************************************
303!> \brief ...
304!> \param functional ...
305!> \param rho_set ...
306!> \param deriv_set ...
307!> \param order ...
308! **************************************************************************************************
309 SUBROUTINE ke_gga_lsd_eval(functional, rho_set, deriv_set, order)
310
311 INTEGER, INTENT(IN) :: functional
312 TYPE(xc_rho_set_type), INTENT(IN) :: rho_set
313 TYPE(xc_derivative_set_type), INTENT(IN) :: deriv_set
314 INTEGER, INTENT(IN), OPTIONAL :: order
315
316 CHARACTER(len=*), PARAMETER :: routinen = 'ke_gga_lsd_eval'
317 INTEGER, DIMENSION(2), PARAMETER :: &
318 norm_drho_spin_name = [deriv_norm_drhoa, deriv_norm_drhob], &
319 rho_spin_name = [deriv_rhoa, deriv_rhob]
320
321 INTEGER :: handle, ispin, npoints
322 INTEGER, DIMENSION(2, 3) :: bo
323 REAL(kind=dp) :: rho_cutoff
324 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: s
325 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: fs
326 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :, :), POINTER :: e_0, e_ndrho, e_ndrho_ndrho, &
327 e_ndrho_ndrho_ndrho, e_rho, e_rho_ndrho, e_rho_ndrho_ndrho, e_rho_rho, e_rho_rho_ndrho, &
328 e_rho_rho_rho
329 TYPE(cp_3d_r_cp_type), DIMENSION(2) :: norm_drho, rho, rho_1_3
330 TYPE(xc_derivative_type), POINTER :: deriv
331
332 CALL timeset(routinen, handle)
333 NULLIFY (e_0, e_ndrho, e_ndrho_ndrho, e_ndrho_ndrho_ndrho, e_rho_ndrho_ndrho, &
334 e_rho_ndrho, e_rho_rho_ndrho, e_rho, e_rho_rho, e_rho_rho_rho)
335 DO ispin = 1, 2
336 NULLIFY (norm_drho(ispin)%array, rho(ispin)%array, rho_1_3(ispin)%array)
337 END DO
338
339 CALL xc_rho_set_get(rho_set, rhoa_1_3=rho_1_3(1)%array, &
340 rhob_1_3=rho_1_3(2)%array, rhoa=rho(1)%array, &
341 rhob=rho(2)%array, norm_drhoa=norm_drho(1)%array, &
342 norm_drhob=norm_drho(2)%array, rho_cutoff=rho_cutoff, &
343 local_bounds=bo)
344 npoints = (bo(2, 1) - bo(1, 1) + 1)*(bo(2, 2) - bo(1, 2) + 1)*(bo(2, 3) - bo(1, 3) + 1)
345 CALL ke_gga_init(rho_cutoff)
346
347 ALLOCATE (s(npoints))
348 ALLOCATE (fs(npoints, order + 1))
349
350 fact = flsd
351 b = b_lsd
352 tact = 1.0_dp
353
354 DO ispin = 1, 2
355
356 CALL calc_wave_vector("p", rho(ispin)%array, norm_drho(ispin)%array, s)
357
358 SELECT CASE (functional)
359 CASE (ke_ol1)
360 CALL efactor_ol1(s, fs, order)
361 CASE (ke_ol2)
362 CALL efactor_ol2(s, fs, order)
363 CASE (ke_llp)
364 CALL efactor_llp(s, fs, order)
365 CASE (ke_pw86)
366 tact = (1.0_dp/2.0_dp)**(1.0_dp/3.0_dp)
367 CALL efactor_pw86(s, fs, order, f2_lsd=tact)
368 tact = 1.0_dp
369 CASE (ke_pbe)
370 tact = (1.0_dp/2.0_dp)**(1.0_dp/3.0_dp)
371 CALL efactor_pbex(s, fs, order, 1, f2_lsd=tact)
372 tact = 1.0_dp
373 CASE (ke_pw91)
374 tact = (1.0_dp/2.0_dp)**(1.0_dp/3.0_dp)
375 CALL efactor_pw91(s, fs, order, 1, f2_lsd=tact)
376 tact = 1.0_dp
377 CASE (ke_lc)
378 tact = (1.0_dp/2.0_dp)**(1.0_dp/3.0_dp)
379 CALL efactor_pw91(s, fs, order, 2, f2_lsd=tact)
380 tact = 1.0_dp
381 CASE (ke_t92)
382 CALL efactor_t92(s, fs, order)
383 CASE DEFAULT
384 cpabort("Unsupported functional")
385 END SELECT
386
387 deriv => xc_dset_get_derivative(deriv_set, [INTEGER::], &
388 allocate_deriv=.true.)
389 CALL xc_derivative_get(deriv, deriv_data=e_0)
390
391 CALL kex_p_0(rho(ispin)%array, rho_1_3(ispin)%array, fs, &
392 e_0=e_0, npoints=npoints)
393 IF (order >= 1) THEN
394 deriv => xc_dset_get_derivative(deriv_set, [rho_spin_name(ispin)], &
395 allocate_deriv=.true.)
396 CALL xc_derivative_get(deriv, deriv_data=e_rho)
397 deriv => xc_dset_get_derivative(deriv_set, [norm_drho_spin_name(ispin)], &
398 allocate_deriv=.true.)
399 CALL xc_derivative_get(deriv, deriv_data=e_ndrho)
400
401 CALL kex_p_1(rho=rho(ispin)%array, &
402 r13=rho_1_3(ispin)%array, s=s, fs=fs, e_rho=e_rho, &
403 e_ndrho=e_ndrho, npoints=npoints)
404 END IF
405 IF (order >= 2) THEN
406 deriv => xc_dset_get_derivative(deriv_set, [rho_spin_name(ispin), &
407 rho_spin_name(ispin)], allocate_deriv=.true.)
408 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho)
409 deriv => xc_dset_get_derivative(deriv_set, [rho_spin_name(ispin), &
410 norm_drho_spin_name(ispin)], allocate_deriv=.true.)
411 CALL xc_derivative_get(deriv, deriv_data=e_rho_ndrho)
412 deriv => xc_dset_get_derivative(deriv_set, [norm_drho_spin_name(ispin), &
413 norm_drho_spin_name(ispin)], allocate_deriv=.true.)
414 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrho)
415
416 CALL kex_p_2(rho(ispin)%array, rho_1_3(ispin)%array, &
417 s, fs, e_rho_rho, e_rho_ndrho, e_ndrho_ndrho, npoints)
418 END IF
419 IF (order >= 3) THEN
420 deriv => xc_dset_get_derivative(deriv_set, [rho_spin_name(ispin), &
421 rho_spin_name(ispin), rho_spin_name(ispin)], &
422 allocate_deriv=.true.)
423 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_rho)
424 deriv => xc_dset_get_derivative(deriv_set, [rho_spin_name(ispin), &
425 rho_spin_name(ispin), norm_drho_spin_name(ispin)], &
426 allocate_deriv=.true.)
427 CALL xc_derivative_get(deriv, deriv_data=e_rho_rho_ndrho)
428 deriv => xc_dset_get_derivative(deriv_set, [rho_spin_name(ispin), &
429 norm_drho_spin_name(ispin), norm_drho_spin_name(ispin)], &
430 allocate_deriv=.true.)
431 CALL xc_derivative_get(deriv, deriv_data=e_rho_ndrho_ndrho)
432 deriv => xc_dset_get_derivative(deriv_set, [norm_drho_spin_name(ispin), &
433 norm_drho_spin_name(ispin), norm_drho_spin_name(ispin)], &
434 allocate_deriv=.true.)
435 CALL xc_derivative_get(deriv, deriv_data=e_ndrho_ndrho_ndrho)
436
437 CALL kex_p_3(rho(ispin)%array, &
438 rho_1_3(ispin)%array, s, fs, e_rho_rho_rho, e_rho_rho_ndrho, &
439 e_rho_ndrho_ndrho, e_ndrho_ndrho_ndrho, npoints)
440 END IF
441 IF (order > 3) THEN
442 cpabort("derivatives bigger than 3 not implemented")
443 END IF
444
445 END DO
446
447 DEALLOCATE (s)
448 DEALLOCATE (fs)
449 CALL timestop(handle)
450 END SUBROUTINE ke_gga_lsd_eval
451
452! **************************************************************************************************
453!> \brief ...
454!> \param rho ...
455!> \param r13 ...
456!> \param fs ...
457!> \param e_0 ...
458!> \param npoints ...
459! **************************************************************************************************
460 SUBROUTINE kex_p_0(rho, r13, fs, e_0, npoints)
461
462 REAL(kind=dp), DIMENSION(*), INTENT(IN) :: rho, r13
463 REAL(kind=dp), DIMENSION(:, :), INTENT(IN) :: fs
464 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_0
465 INTEGER, INTENT(in) :: npoints
466
467 INTEGER :: ip
468
469!$OMP PARALLEL DO DEFAULT(NONE) &
470!$OMP SHARED(npoints, rho, e_0, fact, r13, fs, eps_rho) &
471!$OMP PRIVATE(ip)
472
473 DO ip = 1, npoints
474
475 IF (rho(ip) > eps_rho) THEN
476 e_0(ip) = e_0(ip) + fact*r13(ip)*r13(ip)*rho(ip)*fs(ip, 1)
477 END IF
478
479 END DO
480
481!$OMP END PARALLEL DO
482
483 END SUBROUTINE kex_p_0
484
485! **************************************************************************************************
486!> \brief ...
487!> \param rho ...
488!> \param r13 ...
489!> \param s ...
490!> \param fs ...
491!> \param e_rho ...
492!> \param e_ndrho ...
493!> \param npoints ...
494! **************************************************************************************************
495 SUBROUTINE kex_p_1(rho, r13, s, fs, e_rho, e_ndrho, npoints)
496
497 REAL(kind=dp), DIMENSION(*), INTENT(IN) :: rho, r13, s
498 REAL(kind=dp), DIMENSION(:, :), INTENT(IN) :: fs
499 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho, e_ndrho
500 INTEGER, INTENT(in) :: npoints
501
502 INTEGER :: ip
503 REAL(kind=dp) :: a0, a1, sx, sy
504
505!$OMP PARALLEL DO DEFAULT(NONE) &
506!$OMP SHARED(npoints, rho, eps_rho, fact, r13, sfac, tact) &
507!$OMP SHARED(fs, e_rho, e_ndrho, s) &
508!$OMP PRIVATE(ip,a0,a1,sx,sy)
509
510 DO ip = 1, npoints
511
512 IF (rho(ip) > eps_rho) THEN
513
514 a0 = fact*r13(ip)*r13(ip)*rho(ip)
515 a1 = f53*fact*r13(ip)*r13(ip)
516 sx = -f43*s(ip)/rho(ip)
517 sy = sfac*tact/(r13(ip)*rho(ip))
518 e_rho(ip) = e_rho(ip) + a1*fs(ip, 1) + a0*fs(ip, 2)*sx
519 e_ndrho(ip) = e_ndrho(ip) + a0*fs(ip, 2)*sy
520
521 END IF
522
523 END DO
524
525!$OMP END PARALLEL DO
526
527 END SUBROUTINE kex_p_1
528
529! **************************************************************************************************
530!> \brief ...
531!> \param rho ...
532!> \param r13 ...
533!> \param s ...
534!> \param fs ...
535!> \param e_rho_rho ...
536!> \param e_rho_ndrho ...
537!> \param e_ndrho_ndrho ...
538!> \param npoints ...
539! **************************************************************************************************
540 SUBROUTINE kex_p_2(rho, r13, s, fs, e_rho_rho, e_rho_ndrho, e_ndrho_ndrho, &
541 npoints)
542
543 REAL(kind=dp), DIMENSION(*), INTENT(IN) :: rho, r13, s
544 REAL(kind=dp), DIMENSION(:, :), INTENT(IN) :: fs
545 REAL(kind=dp), DIMENSION(*), INTENT(INOUT) :: e_rho_rho, e_rho_ndrho, e_ndrho_ndrho
546 INTEGER, INTENT(in) :: npoints
547
548 INTEGER :: ip
549 REAL(kind=dp) :: a0, a1, a2, sx, sxx, sxy, sy
550
551!$OMP PARALLEL DO DEFAULT(NONE) &
552!$OMP SHARED (npoints, rho, eps_rho, fact, r13) &
553!$OMP SHARED (e_rho_rho, e_rho_ndrho, e_ndrho_ndrho, fs) &
554!$OMP SHARED(s, sfac, tact) &
555!$OMP PRIVATE(ip,a0,a1,a2,sx,sy,sxx,sxy)
556
557 DO ip = 1, npoints
558
559 IF (rho(ip) > eps_rho) THEN
560
561 a0 = fact*r13(ip)*r13(ip)*rho(ip)
562 a1 = f53*fact*r13(ip)*r13(ip)
563 a2 = f23*f53*fact/r13(ip)
564 sx = -f43*s(ip)/rho(ip)
565 sy = sfac*tact/(r13(ip)*rho(ip))
566 sxx = 28.0_dp/9.0_dp*s(ip)/(rho(ip)*rho(ip))
567 sxy = -f43*sfac*tact/(r13(ip)*rho(ip)*rho(ip))
568 e_rho_rho(ip) = e_rho_rho(ip) + a2*fs(ip, 1) + 2.0_dp*a1*fs(ip, 2)*sx + &
569 a0*fs(ip, 3)*sx*sx + a0*fs(ip, 2)*sxx
570 e_rho_ndrho(ip) = e_rho_ndrho(ip) + a1*fs(ip, 2)*sy + a0*fs(ip, 3)*sx*sy + &
571 a0*fs(ip, 2)*sxy
572 e_ndrho_ndrho(ip) = e_ndrho_ndrho(ip) + a0*fs(ip, 3)*sy*sy
573
574 END IF
575
576 END DO
577
578!$OMP END PARALLEL DO
579
580 END SUBROUTINE kex_p_2
581
582! **************************************************************************************************
583!> \brief ...
584!> \param rho ...
585!> \param r13 ...
586!> \param s ...
587!> \param fs ...
588!> \param e_rho_rho_rho ...
589!> \param e_rho_rho_ndrho ...
590!> \param e_rho_ndrho_ndrho ...
591!> \param e_ndrho_ndrho_ndrho ...
592!> \param npoints ...
593! **************************************************************************************************
594 SUBROUTINE kex_p_3(rho, r13, s, fs, e_rho_rho_rho, e_rho_rho_ndrho, &
595 e_rho_ndrho_ndrho, e_ndrho_ndrho_ndrho, npoints)
596
597 REAL(kind=dp), DIMENSION(*), INTENT(IN) :: rho, r13, s
598 REAL(kind=dp), DIMENSION(:, :), INTENT(IN) :: fs
599 REAL(kind=dp), DIMENSION(*), INTENT(inout) :: e_rho_rho_rho, e_rho_rho_ndrho, &
600 e_rho_ndrho_ndrho, e_ndrho_ndrho_ndrho
601 INTEGER, INTENT(in) :: npoints
602
603 INTEGER :: ip
604 REAL(kind=dp) :: a0, a1, a2, a3, sx, sxx, sxxx, sxxy, &
605 sxy, sy
606
607!$OMP PARALLEL DO DEFAULT(NONE) &
608!$OMP SHARED(npoints, rho, eps_rho, fact, r13) &
609!$OMP SHARED(s, sfac, tact, fs, e_rho_rho_rho) &
610!$OMP SHARED(e_rho_rho_ndrho, e_rho_ndrho_ndrho) &
611!$OMP SHARED(e_ndrho_ndrho_ndrho) &
612!$OMP PRIVATE(ip,a0,a1,a2,a3,sx,sy,sxx,sxy,sxxx,sxxy)
613
614 DO ip = 1, npoints
615
616 IF (rho(ip) > eps_rho) THEN
617
618 a0 = fact*r13(ip)*r13(ip)*rho(ip)
619 a1 = f53*fact*r13(ip)*r13(ip)
620 a2 = f23*f53*fact/r13(ip)
621 a3 = -f13*f23*f53*fact/(r13(ip)*rho(ip))
622 sx = -f43*s(ip)/rho(ip)
623 sy = sfac*tact/(r13(ip)*rho(ip))
624 sxx = 28.0_dp/9.0_dp*s(ip)/(rho(ip)*rho(ip))
625 sxy = -f43*sfac*tact/(r13(ip)*rho(ip)*rho(ip))
626 sxxx = -280.0_dp/27.0_dp*s(ip)/(rho(ip)*rho(ip)*rho(ip))
627 sxxy = 28.0_dp/9.0_dp*sfac*tact/(r13(ip)*rho(ip)*rho(ip)*rho(ip))
628 e_rho_rho_rho(ip) = e_rho_rho_rho(ip) + a3*fs(ip, 1) + 3.0_dp*a2*fs(ip, 2)*sx + &
629 3.0_dp*a1*fs(ip, 3)*sx*sx + 3.0_dp*a1*fs(ip, 2)*sxx + &
630 a0*fs(ip, 4)*sx*sx*sx + 3.0_dp*a0*fs(ip, 3)*sx*sxx + &
631 a0*fs(ip, 2)*sxxx
632 e_rho_rho_ndrho(ip) = e_rho_rho_ndrho(ip) + a2*fs(ip, 2)*sy + 2.0_dp*a1*fs(ip, 3)*sx*sy + &
633 2.0_dp*a1*fs(ip, 2)*sxy + a0*fs(ip, 4)*sx*sx*sy + &
634 2.0_dp*a0*fs(ip, 3)*sx*sxy + a0*fs(ip, 3)*sxx*sy + &
635 a0*fs(ip, 2)*sxxy
636 e_rho_ndrho_ndrho(ip) = e_rho_ndrho_ndrho(ip) + a1*fs(ip, 3)*sy*sy + a0*fs(ip, 4)*sx*sy*sy + &
637 2.0_dp*a0*fs(ip, 3)*sxy*sy
638 e_ndrho_ndrho_ndrho(ip) = e_ndrho_ndrho_ndrho(ip) + a0*fs(ip, 4)*sy*sy*sy
639
640 END IF
641
642 END DO
643
644!$OMP END PARALLEL DO
645
646 END SUBROUTINE kex_p_3
647
648! Enhancement Factors
649! **************************************************************************************************
650!> \brief ...
651!> \param s ...
652!> \param fs ...
653!> \param m ...
654! **************************************************************************************************
655 SUBROUTINE efactor_ol1(s, fs, m)
656 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: s
657 REAL(kind=dp), DIMENSION(:, :), INTENT(OUT) :: fs
658 INTEGER, INTENT(IN) :: m
659
660 INTEGER :: ip
661 REAL(kind=dp) :: t1, t2
662
663 t1 = b*b/(72.0_dp*cf)
664 t2 = 0.001878_dp*b
665
666!$OMP PARALLEL DO DEFAULT(NONE) &
667!$OMP SHARED(s, m, fs, t1, t2) &
668!$OMP PRIVATE(ip)
669
670 DO ip = 1, SIZE(s)
671 SELECT CASE (m)
672 CASE (0)
673 fs(ip, 1) = 1.0_dp + t1*s(ip)*s(ip) + t2*s(ip)
674 CASE (1)
675 fs(ip, 1) = 1.0_dp + t1*s(ip)*s(ip) + t2*s(ip)
676 fs(ip, 2) = 2.0_dp*t1*s(ip) + t2
677 CASE (2:3)
678 fs(ip, 1) = 1.0_dp + t1*s(ip)*s(ip) + t2*s(ip)
679 fs(ip, 2) = 2.0_dp*t1*s(ip) + t2
680 fs(ip, 3) = 2.0_dp*t1
681 CASE DEFAULT
682 cpabort("Illegal order.")
683 END SELECT
684 END DO
685
686!$OMP END PARALLEL DO
687
688 IF (m == 3) fs(:, 4) = 0.0_dp
689
690 END SUBROUTINE efactor_ol1
691! **************************************************************************************************
692!> \brief ...
693!> \param s ...
694!> \param fs ...
695!> \param m ...
696! **************************************************************************************************
697 SUBROUTINE efactor_ol2(s, fs, m)
698 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: s
699 REAL(kind=dp), DIMENSION(:, :), INTENT(OUT) :: fs
700 INTEGER, INTENT(IN) :: m
701
702 INTEGER :: ip
703 REAL(kind=dp) :: t1, t2, t3, y
704
705 t1 = b*b/(72.0_dp*cf)
706 t2 = 0.0245_dp*b
707 t3 = 2.0_dp**f53*b
708
709!$OMP PARALLEL DO DEFAULT(NONE) &
710!$OMP SHARED(s, m, t1, t2, t3, fs) &
711!$OMP PRIVATE(ip,y)
712
713 DO ip = 1, SIZE(s)
714 y = 1.0_dp/(1.0_dp + t3*s(ip))
715 SELECT CASE (m)
716 CASE (0)
717 fs(ip, 1) = 1.0_dp + t1*s(ip)*s(ip) + t2*s(ip)*y
718 CASE (1)
719 fs(ip, 1) = 1.0_dp + t1*s(ip)*s(ip) + t2*s(ip)*y
720 fs(ip, 2) = 2.0_dp*t1*s(ip) + t2*y*y
721 CASE (2)
722 fs(ip, 1) = 1.0_dp + t1*s(ip)*s(ip) + t2*s(ip)*y
723 fs(ip, 2) = 2.0_dp*t1*s(ip) + t2*y*y
724 fs(ip, 3) = 2.0_dp*(t1 - t2*t3*y*y*y)
725 CASE (3)
726 fs(ip, 1) = 1.0_dp + t1*s(ip)*s(ip) + t2*s(ip)*y
727 fs(ip, 2) = 2.0_dp*t1*s(ip) + t2*y*y
728 fs(ip, 3) = 2.0_dp*(t1 - t2*t3*y*y*y)
729 fs(ip, 4) = 6.0_dp*t2*t3*t3*y*y*y*y
730 CASE DEFAULT
731 cpabort("Illegal order.")
732 END SELECT
733 END DO
734
735!$OMP END PARALLEL DO
736
737 END SUBROUTINE efactor_ol2
738! **************************************************************************************************
739!> \brief ...
740!> \param s ...
741!> \param fs ...
742!> \param m ...
743! **************************************************************************************************
744 SUBROUTINE efactor_llp(s, fs, m)
745 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: s
746 REAL(kind=dp), DIMENSION(:, :), INTENT(OUT) :: fs
747 INTEGER, INTENT(IN) :: m
748
749 INTEGER :: ip
750 REAL(kind=dp) :: as, bs, p, q, sas, sbs, t1, t10, t11, t12, t133, t16, t17, t19, t2, t20, &
751 t22, t23, t26, t28, t29, t3, t30, t33, t36, t39, t4, t40, t42, t43, t45, t46, t47, t49, &
752 t5, t50, t54, t55, t7, t71, t8, t9, x, ys
753
754 p = 0.0044188_dp*b*b
755 q = 0.0253_dp*b
756
757!$OMP PARALLEL DO DEFAULT(NONE) &
758!$OMP SHARED(s, m, fs, p, q, b) &
759!$OMP PRIVATE(ip,x,bs,sbs,as,sas,ys,t2,t4,t5,t8,t9,t10,t12) &
760!$OMP PRIVATE(t1,t3,t7,t11,t16,t17,t20,t22,t23,t26,t30,t33) &
761!$OMP PRIVATE(t40,t42,t43,t45,t46,t47,t49,t50,t71,t133) &
762!$OMP PRIVATE(t19,t28,t29,t36,t39,t54,t55)
763
764 DO ip = 1, SIZE(s)
765 x = s(ip)
766 bs = b*x
767 sbs = sqrt(bs*bs + 1.0_dp)
768 as = log(bs + sbs)
769 sas = x*as
770 ys = 1.0_dp/(1.0_dp + q*sas)
771 SELECT CASE (m)
772 CASE (0)
773 fs(ip, 1) = 1.0_dp + p*x*x*ys
774 CASE (1)
775 fs(ip, 1) = 1.0_dp + p*x*x*ys
776 t2 = q*x
777 t4 = b**2
778 t5 = x**2
779 t8 = sqrt(1.0_dp + t4*t5)
780 t9 = b*x + t8
781 t10 = log(t9)
782 t12 = 1.0_dp + t2*t10
783 t17 = t12**2
784 fs(ip, 2) = 2.0_dp*p*x/t12 - p*t5/t17*(q*t10 + t2*(b + 1.0_dp/t8*t4*x)/t9)
785
786 CASE (2)
787 fs(ip, 1) = 1.0_dp + p*x*x*ys
788 ! first der
789 t2 = q*x
790 t4 = b**2
791 t5 = x**2
792 t8 = sqrt(1.0_dp + t4*t5)
793 t9 = b*x + t8
794 t10 = log(t9)
795 t12 = 1.0_dp + t2*t10
796 t17 = t12**2
797 fs(ip, 2) = 2.0_dp*p*x/t12 - p*t5/t17*(q*t10 + t2*(b + 1.0_dp/t8*t4*x)/t9)
798
799 ! second der
800 t1 = q*x
801 t3 = b**2
802 t4 = x**2
803 t7 = sqrt(1.0_dp + t3*t4)
804 t8 = b*x + t7
805 t9 = log(t8)
806 t11 = 1.0_dp + t1*t9
807 t16 = t11**2
808 t17 = 1.0_dp/t16
809 t20 = 1.0_dp/t7*t3
810 t22 = b + t20*x
811 t23 = 1/t8
812 t26 = q*t9 + t1*t22*t23
813 t30 = p*t4
814 t33 = t26**2
815 t40 = t7**2
816 t43 = t3**2
817 t49 = t22**2
818 t50 = t8**2
819 fs(ip, 3) = 2.0_dp*p/t11 - 4.0_dp*p*x*t17*t26 + 2.0_dp*t30/t16/ &
820 t11*t33 - t30*t17*(2.0_dp*q*t22*t23 + t1* &
821 (-1.0_dp/t40/t7*t43*t4 + t20)*t23 - t1*t49/t50)
822
823 CASE (3)
824
825 fs(ip, 1) = 1.0_dp + p*x*x*ys
826 ! first der
827 t2 = q*x
828 t4 = b**2
829 t5 = x**2
830 t8 = sqrt(1.0_dp + t4*t5)
831 t9 = b*x + t8
832 t10 = log(t9)
833 t12 = 1.0_dp + t2*t10
834 t17 = t12**2
835 fs(ip, 2) = 2.0_dp*p*x/t12 - p*t5/t17*(q*t10 + t2*(b + 1.0_dp/t8*t4*x)/t9)
836
837 ! second der
838 t1 = q*x
839 t3 = b**2
840 t4 = x**2
841 t7 = sqrt(1.0_dp + t3*t4)
842 t8 = b*x + t7
843 t9 = log(t8)
844 t11 = 1.0_dp + t1*t9
845 t16 = t11**2
846 t17 = 1.0_dp/t16
847 t20 = 1.0_dp/t7*t3
848 t22 = b + t20*x
849 t23 = 1/t8
850 t26 = q*t9 + t1*t22*t23
851 t30 = p*t4
852 t33 = t26**2
853 t40 = t7**2
854 t43 = t3**2
855 t49 = t22**2
856 t50 = t8**2
857 fs(ip, 3) = 2.0_dp*p/t11 - 4.0_dp*p*x*t17*t26 + 2.0_dp*t30/t16/ &
858 t11*t33 - t30*t17*(2.0_dp*q*t22*t23 + t1* &
859 (-1.0_dp/t40/t7*t43*t4 + t20)*t23 - t1*t49/t50)
860
861 t1 = q*x
862 t3 = b**2
863 t4 = x**2
864 t7 = sqrt(1 + t3*t4)
865 t8 = b*x + t7
866 t9 = log(t8)
867 t11 = 1.0_dp + t1*t9
868 t12 = t11**2
869 t133 = 1.0_dp/t12
870 t17 = 1.0_dp/t7*t3
871 t19 = b + t17*x
872 t20 = 1.0_dp/t8
873 t23 = q*t9 + t1*t19*t20
874 t26 = p*x
875 t28 = 1.0_dp/t12/t11
876 t29 = t23**2
877 t36 = t7**2
878 t39 = t3**2
879 t40 = 1.0_dp/t36/t7*t39
880 t42 = -t40*t4 + t17
881 t45 = t19**2
882 t46 = t8**2
883 t47 = 1.0_dp/t46
884 t50 = 2.0_dp*q*t19*t20 + t1*t42*t20 - t1*t45*t47
885 t54 = p*t4
886 t55 = t12**2
887 t71 = t36**2
888 fs(ip, 4) = &
889 -6.0_dp*p*t133*t23 + 12.0_dp*t26*t28*t29 - &
890 6.0_dp*t26*t133*t50 - 6.0_dp*t54/t55*t29*t23 + &
891 6.0_dp*t54*t28*t23*t50 - t54*t133* &
892 (3.0_dp*q*t42*t20 - 3.0_dp*q*t45*t47 + 3.0_dp*t1* &
893 (1.0_dp/t71/t7*t39*t3*t4*x - t40*x)*t20 - &
894 3.0_dp*t1*t42*t47*t19 + 2.0_dp*t1*t45*t19/t46/t8)
895
896 CASE DEFAULT
897 cpabort("Illegal order.")
898 END SELECT
899 END DO
900
901!$OMP END PARALLEL DO
902
903 END SUBROUTINE efactor_llp
904! **************************************************************************************************
905!> \brief ...
906!> \param s ...
907!> \param fs ...
908!> \param m ...
909!> \param f2_lsd ...
910! **************************************************************************************************
911 SUBROUTINE efactor_pw86(s, fs, m, f2_lsd)
912 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: s
913 REAL(kind=dp), DIMENSION(:, :), INTENT(OUT) :: fs
914 INTEGER, INTENT(IN) :: m
915 REAL(dp), OPTIONAL :: f2_lsd
916
917 INTEGER :: ip
918 REAL(kind=dp) :: f15, ff, p0, p1, p15, p2, p3, s1, s2, &
919 s4, s6, t1, t2, t3
920
921 t1 = 1.296_dp
922 t2 = 14.0_dp
923 t3 = 0.2_dp
924 f15 = 1.0_dp/15.0_dp
925 ff = 1.0_dp
926 IF (PRESENT(f2_lsd)) ff = f2_lsd
927
928!$OMP PARALLEL DO DEFAULT(NONE) &
929!$OMP SHARED(s, fs, m, t1, t2, t3, f15, ff) &
930!$OMP PRIVATE(ip, s1, s2, s4, s6, p0, p1, p2, p3, p15)
931
932 DO ip = 1, SIZE(s)
933 s1 = s(ip)*ff
934 s2 = s1*s1
935 s4 = s2*s2
936 s6 = s2*s4
937 SELECT CASE (m)
938 CASE (0)
939 p0 = 1.0_dp + t1*s2 + t2*s4 + t3*s6
940 fs(ip, 1) = p0**f15
941 CASE (1)
942 p0 = 1.0_dp + t1*s2 + t2*s4 + t3*s6
943 p1 = s1*ff*(2.0_dp*t1 + 4.0_dp*t2*s2 + 6.0_dp*t3*s4)
944 p15 = p0**f15
945 fs(ip, 1) = p15
946 fs(ip, 2) = f15*p1*p15/p0
947 CASE (2)
948 p0 = 1.0_dp + t1*s2 + t2*s4 + t3*s6
949 p1 = s1*ff*(2.0_dp*t1 + 4.0_dp*t2*s2 + 6.0_dp*t3*s4)
950 p2 = ff*ff*(2.0_dp*t1 + 12.0_dp*t2*s2 + 30.0_dp*t3*s4)
951 p15 = p0**f15
952 fs(ip, 1) = p15
953 fs(ip, 2) = f15*p1*p15/p0
954 fs(ip, 3) = f15*p15/p0*(p2 - 14.0_dp/15.0_dp*p1*p1/p0)
955 CASE (3)
956 p0 = 1.0_dp + t1*s2 + t2*s4 + t3*s6
957 p1 = s1*ff*(2.0_dp*t1 + 4.0_dp*t2*s2 + 6.0_dp*t3*s4)
958 p2 = ff*ff*(2.0_dp*t1 + 12.0_dp*t2*s2 + 30.0_dp*t3*s4)
959 p3 = s1*ff*ff*ff*(24.0_dp*t2 + 120.0_dp*t3*s2)
960 p15 = p0**f15
961 fs(ip, 1) = p15
962 fs(ip, 2) = f15*p1*p15/p0
963 fs(ip, 3) = f15*p15/p0*(p2 - 14.0_dp/15.0_dp*p1*p1/p0)
964 fs(ip, 4) = f15*p15/p0*(-14.0_dp*f15*p1*p1/p0 + 14.0_dp*14.0_dp*f15*p1*p1*p1/p0/p0 + &
965 p3 - 14.0_dp*p2*p1/p0 + 14.0_dp*p1*p1/p0/p0)
966 CASE DEFAULT
967 cpabort("Illegal order.")
968 END SELECT
969 END DO
970
971!$OMP END PARALLEL DO
972
973 END SUBROUTINE efactor_pw86
974! **************************************************************************************************
975!> \brief ...
976!> \param s ...
977!> \param fs ...
978!> \param m ...
979! **************************************************************************************************
980 SUBROUTINE efactor_t92(s, fs, m)
981 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: s
982 REAL(kind=dp), DIMENSION(:, :), INTENT(OUT) :: fs
983 INTEGER, INTENT(IN) :: m
984
985 INTEGER :: ip
986 REAL(kind=dp) :: a1, a2, as, asp, asp2, asp3, bs, p, q, &
987 s1, s2, sas, sbs, sbs3, sbs5, t0, w1, &
988 x, ys
989
990 p = 0.0055_dp*b*b
991 q = 0.0253_dp*b
992 a1 = 0.072_dp*b
993 a2 = 2.0_dp**f53*b
994
995!$OMP PARALLEL DO DEFAULT(NONE) &
996!$OMP SHARED(s, fs, m, p, q, a1, a2, b) &
997!$OMP PRIVATE(ip, x, bs, sbs, sas, ys, asp, sbs3, asp2, sbs5) &
998!$OMP PRIVATE(asp3, as, s2, s1, t0, w1)
999
1000 DO ip = 1, SIZE(s)
1001 x = s(ip)
1002 bs = b*x
1003 sbs = sqrt(bs*bs + 1.0_dp)
1004 as = log(bs + sbs)
1005 sas = x*as
1006 ys = 1.0_dp/(1.0_dp + q*sas)
1007 SELECT CASE (m)
1008 CASE (0)
1009 fs(ip, 1) = 1.0_dp + p*x*x*ys - a1*x/(1 + a2*x)
1010 CASE (1)
1011 asp = as + bs/sbs
1012 fs(ip, 1) = 1.0_dp + p*x*x*ys - a1*x/(1 + a2*x)
1013 fs(ip, 2) = 2.0_dp*p*x*ys - p*q*x*x*asp*ys*ys - a1/(1 + a2*x)**2
1014 CASE (2)
1015 asp = as + bs/sbs
1016 sbs3 = sbs*sbs*sbs
1017 asp2 = 2.0_dp*b/sbs - b*bs*bs/sbs3
1018 fs(ip, 1) = 1.0_dp + p*x*x*ys - a1*x/(1 + a2*x)
1019 fs(ip, 2) = 2.0_dp*p*x*ys - p*q*x*x*asp*ys*ys - a1/(1 + a2*x)**2
1020 fs(ip, 3) = 2.0_dp*p*ys - p*q*x*(4.0_dp*asp + x*asp2)*ys*ys + &
1021 2.0_dp*p*q*q*x*x*asp*asp*ys*ys*ys + 2.0_dp*a1*a2/(1 + a2*x)**3
1022 CASE (3)
1023 asp = as + bs/sbs
1024 sbs3 = sbs*sbs*sbs
1025 sbs5 = sbs3*sbs*sbs
1026 asp2 = 2.0_dp*b/sbs - b*bs*bs/sbs3
1027 asp3 = -4.0_dp*b*b*bs/sbs3 + 3.0_dp*b*b*bs*bs*bs/sbs5
1028 w1 = (4.0_dp*asp + x*asp2)
1029 fs(ip, 1) = 1.0_dp + p*x*x*ys - a1*x/(1 + a2*x)
1030 fs(ip, 2) = 2.0_dp*p*x*ys - p*q*x*x*asp*ys*ys - a1/(1 + a2*x)**2
1031 fs(ip, 3) = 2.0_dp*p*ys - p*q*x*w1*ys*ys + &
1032 2.0_dp*p*q*q*x*x*asp*asp*ys*ys*ys + 2.0_dp*a1*a2/(1 + a2*x)**3
1033
1034 s2 = -6*p/(1 + q*x*log(b*x + sqrt(1 + b**2*x**2)))**2*(q*log(b*x + sqrt(1 + b**2*x**2)) + &
1035 q*x*(b + 1/sqrt(1 + b**2*x**2)*b**2*x)/(b*x + sqrt(1 + b**2*x**2))) + 12*p*x/ &
1036 (1 + q*x*log(b*x + sqrt(1 + b**2*x**2)))**3*(q*log(b*x + sqrt(1 + b**2*x**2)) + &
1037 q*x*(b + 1/sqrt(1 + b**2*x**2)*b**2*x)/(b*x + sqrt(1 + b**2*x**2)))**2
1038 s1 = s2 - 6*p*x/(1 + q*x*log(b*x + sqrt(1 + b**2*x**2)))**2*(2*q*(b + 1/sqrt(1 + b**2*x**2)*b**2*x)/ &
1039 (b*x + sqrt(1 + b**2*x**2)) + q*x*(-1/sqrt(1 + b**2*x**2)**3*b**4*x**2 + 1/sqrt(1 + b**2*x**2)*b**2)/ &
1040 (b*x + sqrt(1 + b**2*x**2)) - q*x*(b + 1/sqrt(1 + b**2*x**2)*b**2*x)**2/ &
1041 (b*x + sqrt(1 + b**2*x**2))**2) - 6*p*x**2/(1 + q*x*log(b*x + sqrt(1 + b**2*x**2)))**4 &
1042 *(q*log(b*x + sqrt(1 + b**2*x**2)) + q*x*(b + 1/sqrt(1 + b**2*x**2)*b**2*x)/(b*x + sqrt(1 + b**2*x**2)))**3
1043 s2 = s1 + 6*p*x**2/(1 + q*x*log(b*x + sqrt(1 + b**2*x**2)))**3*(q*log(b*x + sqrt(1 + b**2*x**2)) + &
1044 q*x*(b + 1/sqrt(1 + b**2*x**2)*b**2*x)/(b*x + sqrt(1 + b**2*x**2)))*(2*q*(b + 1/sqrt(1 + b**2*x**2)*b**2*x) &
1045 /(b*x + sqrt(1 + b**2*x**2)) + q*x*(-1/sqrt(1 + b**2*x**2)**3*b**4*x**2 + 1/sqrt(1 + b**2*x**2)* &
1046 b**2)/(b*x + sqrt(1 + b**2*x**2)) - q*x*(b + 1/sqrt(1 + b**2*x**2)*b**2*x)**2/(b*x + sqrt(1 + b**2*x**2))**2)
1047 t0 = s2 - p*x**2/(1 + q*x*log(b*x + sqrt(1 + b**2*x**2)))**2*(3*q*(-1/sqrt(1 + b**2*x**2)**3*b**4*x**2 + &
1048 1/sqrt(1 + b**2*x**2)*b**2)/(b*x + sqrt(1 + b**2*x**2)) - 3*q*(b + 1/sqrt(1 + b**2*x**2)*b**2*x)**2/ &
1049 (b*x + sqrt(1 + b**2*x**2))**2 + q*x*(3/sqrt(1 + b**2*x**2)**5*b**6*x**3 - 3/sqrt(1 + b**2*x**2)**3*b**4*x)/ &
1050 (b*x + sqrt(1 + b**2*x**2)) - 3*q*x*(-1/sqrt(1 + b**2*x**2)**3*b**4*x**2 + 1/sqrt(1 + b**2*x**2)*b**2)/ &
1051 (b*x + sqrt(1 + b**2*x**2))**2*(b + 1/sqrt(1 + b**2*x**2)*b**2*x) + 2*q*x*(b + 1/sqrt(1 + b**2*x**2)* &
1052 b**2*x)**3/(b*x + sqrt(1 + b**2*x**2))**3) - 6*a1/(1 + a2*x)**3*a2**2 + 6*a1*x/(1 + a2*x)**4*a2**3
1053
1054 fs(ip, 4) = t0
1055
1056 CASE DEFAULT
1057 cpabort("Illegal order")
1058 END SELECT
1059 END DO
1060
1061!$OMP END PARALLEL DO
1062
1063 END SUBROUTINE efactor_t92
1064! **************************************************************************************************
1065!> \brief ...
1066!> \param s ...
1067!> \param fs ...
1068!> \param m ...
1069!> \param pset ...
1070!> \param f2_lsd ...
1071! **************************************************************************************************
1072 SUBROUTINE efactor_pbex(s, fs, m, pset, f2_lsd)
1073
1074 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: s
1075 REAL(kind=dp), DIMENSION(:, :), INTENT(OUT) :: fs
1076 INTEGER, INTENT(IN) :: m, pset
1077 REAL(dp), OPTIONAL :: f2_lsd
1078
1079 REAL(kind=dp), PARAMETER :: kappa1 = 0.804_dp, kappa2 = 1.245_dp, &
1080 mu = 0.2195149727645171_dp
1081
1082 INTEGER :: ip
1083 REAL(kind=dp) :: f0, mk, x, x2, y
1084
1085 IF (pset == 1) mk = mu/kappa1
1086 IF (pset == 2) mk = mu/kappa2
1087
1088 f0 = 1.0_dp/tact
1089 IF (PRESENT(f2_lsd)) f0 = f2_lsd
1090
1091!$OMP PARALLEL DO DEFAULT(NONE) &
1092!$OMP SHARED(s, m, fs, f0, mk) &
1093!$OMP PRIVATE(ip,x,x2,y)
1094
1095 DO ip = 1, SIZE(s)
1096 x = s(ip)*f0
1097 x2 = x*x
1098 y = 1.0_dp/(1.0_dp + mk*x2)
1099 SELECT CASE (m)
1100 CASE (0)
1101 fs(ip, 1) = 1.0_dp + mu*x2*y
1102 CASE (1)
1103 fs(ip, 1) = 1.0_dp + mu*x2*y
1104 fs(ip, 2) = 2.0_dp*mu*x*y*y*f0
1105 CASE (2)
1106 fs(ip, 1) = 1.0_dp + mu*x2*y
1107 fs(ip, 2) = 2.0_dp*mu*x*y*y*f0
1108 fs(ip, 3) = -2.0_dp*mu*(3.0_dp*mk*x2 - 1.0_dp)*y*y*y*f0*f0
1109 CASE (3)
1110 fs(ip, 1) = 1.0_dp + mu*x2*y
1111 fs(ip, 2) = 2.0_dp*mu*x*y*y*f0
1112 fs(ip, 3) = -2.0_dp*mu*(3.0_dp*mk*x2 - 1.0_dp)*y*y*y*f0*f0
1113 fs(ip, 4) = 24.0_dp*mu*mk*x*(mk*x2 - 1.0_dp)*y*y*y*y*f0*f0*f0
1114 CASE DEFAULT
1115 cpabort("Illegal order.")
1116 END SELECT
1117 END DO
1118
1119!$OMP END PARALLEL DO
1120
1121 END SUBROUTINE efactor_pbex
1122
1123! **************************************************************************************************
1124!> \brief ...
1125!> \param s ...
1126!> \param fs ...
1127!> \param m ...
1128!> \param pset ...
1129!> \param f2_lsd ...
1130! **************************************************************************************************
1131 SUBROUTINE efactor_pw91(s, fs, m, pset, f2_lsd)
1132 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: s
1133 REAL(kind=dp), DIMENSION(:, :), INTENT(OUT) :: fs
1134 INTEGER, INTENT(IN) :: m, pset
1135 REAL(dp), OPTIONAL :: f2_lsd
1136
1137 INTEGER :: ip
1138 REAL(dp) :: ff, t1, t10, t101, t106, t109, t111, t113, t119, t12, t123, t124, t13, t14, t15, &
1139 t16, t17, t18, t19, t2, t20, t21, t22, t23, t25, t26, t27, t28, t29, t3, t30, t31, t33, &
1140 t35, t37, t38, t39, t4, t40, t44, t47, t48, t5, t50, t51, t53, t55, t56, t57, t58, t59, &
1141 t6, t60, t64, t65, t69, t7, t70, t71, t73, t77, t78, t8, t80, t82, t9, t90, t93, t94, &
1142 t96, t98
1143 REAL(kind=dp) :: a1, a2, a3, a4, a5, bb, o, pa(6, 2), x
1144
1145! parameter set 1: Perdew-Wang
1146! parameter set 2: Lembarki-Chermette
1147
1148 pa(1:6, 1) = [0.19645_dp, 0.2743_dp, &
1149 0.1508_dp, 100.0_dp, &
1150 7.7956_dp, 0.004_dp]
1151 pa(1:6, 2) = [0.093907_dp, 0.26608_dp, &
1152 0.0809615_dp, 100.0_dp, &
1153 76.320_dp, 0.57767e-4_dp]
1154 o = 1.0_dp
1155 ff = 1.0_dp
1156 IF (PRESENT(f2_lsd)) ff = f2_lsd
1157 a1 = pa(1, pset)*ff
1158 a2 = pa(2, pset)*ff*ff
1159 a3 = pa(3, pset)*ff*ff
1160 a4 = pa(4, pset)*ff*ff
1161 bb = pa(5, pset)*ff
1162! it should be valid also for lsd
1163 a5 = pa(6, pset)*ff*ff*ff*ff
1164
1165!$OMP PARALLEL DEFAULT(NONE) &
1166!$OMP SHARED(s, fs, m, a1, a2, a3, a4, a5, bb, pa, o, ff) &
1167!$OMP PRIVATE(x,t1,t10,t101,t106,t109,t111,t113,t119,t12,t123) &
1168!$OMP PRIVATE(t124,t13,t14,t15,t16,t17,t18,t19,t2,t20,t21,t22) &
1169!$OMP PRIVATE(t23,t25,t26,t27,t28,t29,t3,t30,t31,t33,t35,t37) &
1170!$OMP PRIVATE(t38,t39,t4,t40,t44,t47,t48,t5,t50,t51,t53,t55) &
1171!$OMP PRIVATE(t56,t57,t58,t59,t6,t60,t64,t65,t69,t7,t70,t71) &
1172!$OMP PRIVATE(t73,t77,t78,t8,t80,t82,t9,t90,t93,t94,t96,t98,ip)
1173
1174 IF (m >= 0) THEN
1175!$OMP DO
1176 DO ip = 1, SIZE(s)
1177 x = s(ip)
1178 t3 = bb**2
1179 t4 = x**2
1180 t7 = sqrt(o + t3*t4)
1181 t9 = log(bb*x + t7)
1182 t10 = a1*x*t9
1183 t12 = exp(-a4*t4)
1184 t17 = t4**2
1185 fs(ip, 1) = (o + t10 + (a2 - a3*t12)*t4)/(o + t10 + a5*t17)
1186 END DO
1187!$OMP END DO
1188 END IF
1189 IF (m >= 1) THEN
1190!$OMP DO
1191 DO ip = 1, SIZE(s)
1192 x = s(ip)
1193 t2 = bb**2
1194 t3 = x**2
1195 t6 = sqrt(o + t2*t3)
1196 t7 = bb*x + t6
1197 t8 = log(t7)
1198 t9 = a1*t8
1199 t10 = a1*x
1200 t17 = t10*(bb + 1/t6*t2*x)/t7
1201 t19 = t3*x
1202 t21 = exp(-a4*t3)
1203 t26 = a2 - a3*t21
1204 t30 = t10*t8
1205 t31 = t3**2
1206 t33 = o + t30 + a5*t31
1207 t38 = t33**2
1208 fs(ip, 2) = &
1209 (t9 + t17 + 2._dp*a3*a4*t19*t21 + 2._dp*t26*x)/ &
1210 t33 - (o + t30 + t26*t3)/t38*(t9 + t17 + 4._dp*a5*t19)
1211 END DO
1212!$OMP END DO
1213 END IF
1214 IF (m >= 2) THEN
1215!$OMP DO
1216 DO ip = 1, SIZE(s)
1217 x = s(ip)
1218 t1 = bb**2
1219 t2 = x**2
1220 t5 = sqrt(o + t1*t2)
1221 t7 = o/t5*t1
1222 t9 = bb + t7*x
1223 t12 = bb*x + t5
1224 t13 = o/t12
1225 t15 = 2._dp*a1*t9*t13
1226 t16 = a1*x
1227 t17 = t5**2
1228 t20 = t1**2
1229 t25 = t16*(-o/t17/t5*t20*t2 + t7)*t13
1230 t26 = t9**2
1231 t27 = t12**2
1232 t30 = t16*t26/t27
1233 t31 = a3*a4
1234 t33 = exp(-a4*t2)
1235 t37 = a4**2
1236 t39 = t2**2
1237 t44 = a3*t33
1238 t47 = log(t12)
1239 t48 = t16*t47
1240 t50 = o + t48 + a5*t39
1241 t53 = a1*t47
1242 t55 = t16*t9*t13
1243 t56 = t2*x
1244 t60 = a2 - t44
1245 t64 = t50**2
1246 t65 = o/t64
1247 t69 = t53 + t55 + 4._dp*a5*t56
1248 t73 = o + t48 + t60*t2
1249 t77 = t69**2
1250 fs(ip, 3) = &
1251 (t15 + t25 - t30 + 10._dp*t31*t2*t33 - 4._dp*a3*t37*t39*t33 + &
1252 2._dp*a2 - 2._dp*t44)/t50 - 2._dp* &
1253 (t53 + t55 + 2._dp*t31*t56*t33 + 2._dp*t60*x)* &
1254 t65*t69 + 2._dp*t73/t64/t50*t77 - t73*t65*(t15 + t25 - t30 + 12._dp*a5*t2)
1255 END DO
1256!$OMP END DO
1257 END IF
1258 IF (m >= 3) THEN
1259!$OMP DO
1260 DO ip = 1, SIZE(s)
1261 x = s(ip)
1262 t1 = bb**2
1263 t2 = x**2
1264 t5 = sqrt(0.1e1_dp + t1*t2)
1265 t6 = t5**2
1266 t9 = t1**2
1267 t10 = 1/t6/t5*t9
1268 t13 = 1/t5*t1
1269 t14 = -t10*t2 + t13
1270 t17 = bb*x + t5
1271 t18 = 1/t17
1272 t20 = 3*a1*t14*t18
1273 t22 = bb + t13*x
1274 t23 = t22**2
1275 t25 = t17**2
1276 t26 = 1/t25
1277 t28 = 3*a1*t23*t26
1278 t29 = a1*x
1279 t30 = t6**2
1280 t35 = t2*x
1281 t40 = 3*t29*(1/t30/t5*t1*t9*t35 - t10*x)*t18
1282 t44 = 3*t29*t14*t26*t22
1283 t50 = 2*t29*t23*t22/t25/t17
1284 t51 = a3*a4
1285 t53 = exp(-a4*t2)
1286 t57 = a4**2
1287 t58 = a3*t57
1288 t59 = t35*t53
1289 t64 = t2**2
1290 t70 = log(t17)
1291 t71 = t29*t70
1292 t73 = 0.1e1_dp + t71 + a5*t64
1293 t78 = 2*a1*t22*t18
1294 t80 = t29*t14*t18
1295 t82 = t29*t23*t26
1296 t90 = a3*t53
1297 t93 = t73**2
1298 t94 = 1/t93
1299 t96 = a1*t70
1300 t98 = t29*t18*t22
1301 t101 = t96 + t98 + 4*a5*t35
1302 t106 = a2 - t90
1303 t109 = t96 + t98 + 2*t51*t59 + 2*t106*x
1304 t111 = 1/t93/t73
1305 t113 = t101**2
1306 t119 = t78 + t80 - t82 + 12*a5*t2
1307 t123 = 0.1e1_dp + t71 + t106*t2
1308 t124 = t93**2
1309 fs(ip, 4) = &
1310 (t20 - t28 + t40 - t44 + t50 + 24*t51*x*t53 - 36._dp*t58*t59 + 8._dp*a3*t57*a4*t64* &
1311 x*t53)/t73 - 3._dp*(t78 + t80 - t82 + 10._dp*t51*t2*t53 - &
1312 4._dp*t58*t64*t53 + 2._dp*a2 - 2._dp*t90)*t94*t101 + &
1313 6._dp*t109*t111*t113 - 3._dp*t109*t94*t119 - 6*t123/t124*t113*t101 + &
1314 6._dp*t123*t111*t101*t119 - t123*t94*(t20 - t28 + t40 - t44 + t50 + 24._dp*a5*x)
1315 END DO
1316!$OMP END DO
1317 END IF
1318
1319!$OMP END PARALLEL
1320
1321 END SUBROUTINE efactor_pw91
1322
1323END MODULE xc_ke_gga
1324
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Module with functions to handle derivative descriptors. derivative description are strings have the f...
integer, parameter, public deriv_norm_drho
integer, parameter, public deriv_norm_drhoa
integer, parameter, public deriv_rhob
integer, parameter, public deriv_rhoa
integer, parameter, public deriv_rho
integer, parameter, public deriv_norm_drhob
represent a group ofunctional derivatives
type(xc_derivative_type) function, pointer, public xc_dset_get_derivative(derivative_set, description, allocate_deriv)
returns the requested xc_derivative
Provides types for the management of the xc-functionals and their derivatives.
subroutine, public xc_derivative_get(deriv, split_desc, order, deriv_data, accept_null_data)
returns various information on the given derivative
Utility routines for the functional calculations.
subroutine, public calc_wave_vector(tag, rho, grho, s)
...
subroutine, public set_util(cutoff)
...
input constants for xc
integer, parameter, public ke_ol1
integer, parameter, public ke_ol2
integer, parameter, public ke_pw91
integer, parameter, public ke_pbe
integer, parameter, public ke_pw86
integer, parameter, public ke_lc
integer, parameter, public ke_llp
integer, parameter, public ke_t92
Calculate the several different kinetic energy functionals with a GGA form.
Definition xc_ke_gga.F:16
subroutine, public ke_gga_lsd_eval(functional, rho_set, deriv_set, order)
...
Definition xc_ke_gga.F:310
subroutine, public ke_gga_info(functional, lsd, reference, shortform, needs, max_deriv)
...
Definition xc_ke_gga.F:97
subroutine, public ke_gga_lda_eval(functional, rho_set, deriv_set, order)
...
Definition xc_ke_gga.F:178
contains the structure
contains the structure
subroutine, public xc_rho_set_get(rho_set, can_return_null, rho, drho, norm_drho, rhoa, rhob, norm_drhoa, norm_drhob, rho_1_3, rhoa_1_3, rhob_1_3, laplace_rho, laplace_rhoa, laplace_rhob, drhoa, drhob, rho_cutoff, drho_cutoff, tau_cutoff, tau, tau_a, tau_b, local_bounds)
returns the various attributes of rho_set
represent a pointer to a contiguous 3d array
A derivative set contains the different derivatives of a xc-functional in form of a linked list.
represent a derivative of a functional
contains a flag for each component of xc_rho_set, so that you can use it to tell which components you...
represent a density, with all the representation and data needed to perform a functional evaluation