34#include "../base/base_uses.f90"
41 REAL(KIND=
dp),
PARAMETER :: f13 = 1.0_dp/3.0_dp, &
48 REAL(KIND=
dp) :: cf, flda, flsd, fvw
49 REAL(KIND=
dp) :: eps_rho
50 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'xc_tfw'
58 SUBROUTINE tfw_init(cutoff)
60 REAL(KIND=
dp),
INTENT(IN) :: cutoff
65 cf = 0.3_dp*(3.0_dp*
pi*
pi)**f23
67 flsd = flda*2.0_dp**f23
70 END SUBROUTINE tfw_init
80 CHARACTER(LEN=*),
INTENT(OUT),
OPTIONAL :: reference, shortform
82 INTEGER,
INTENT(out),
OPTIONAL :: max_deriv
84 IF (
PRESENT(reference))
THEN
85 reference =
"Thomas-Fermi-Weizsaecker kinetic energy functional {LDA version}"
87 IF (
PRESENT(shortform))
THEN
88 shortform =
"TF+vW kinetic energy functional {LDA}"
90 IF (
PRESENT(needs))
THEN
92 needs%rho_1_3 = .true.
93 needs%norm_drho = .true.
95 IF (
PRESENT(max_deriv)) max_deriv = 3
107 CHARACTER(LEN=*),
INTENT(OUT),
OPTIONAL :: reference, shortform
109 INTEGER,
INTENT(out),
OPTIONAL :: max_deriv
111 IF (
PRESENT(reference))
THEN
112 reference =
"Thomas-Fermi-Weizsaecker kinetic energy functional"
114 IF (
PRESENT(shortform))
THEN
115 shortform =
"TF+vW kinetic energy functional"
117 IF (
PRESENT(needs))
THEN
118 needs%rho_spin = .true.
119 needs%rho_spin_1_3 = .true.
120 needs%norm_drho = .true.
122 IF (
PRESENT(max_deriv)) max_deriv = 3
135 INTEGER,
INTENT(in) :: order
137 CHARACTER(len=*),
PARAMETER :: routinen =
'tfw_lda_eval'
139 INTEGER :: handle, npoints
140 INTEGER,
DIMENSION(2, 3) :: bo
141 REAL(kind=
dp) :: epsilon_rho
142 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: s
143 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :, :),
POINTER :: e_0, e_ndrho, e_ndrho_ndrho, &
144 e_rho, e_rho_ndrho, e_rho_ndrho_ndrho, e_rho_rho, e_rho_rho_ndrho, e_rho_rho_rho, grho, &
148 CALL timeset(routinen, handle)
151 norm_drho=grho, local_bounds=bo, rho_cutoff=epsilon_rho)
152 npoints = (bo(2, 1) - bo(1, 1) + 1)*(bo(2, 2) - bo(1, 2) + 1)*(bo(2, 3) - bo(1, 3) + 1)
153 CALL tfw_init(epsilon_rho)
155 ALLOCATE (s(npoints))
156 CALL calc_s(rho, grho, s, npoints)
159 allocate_deriv=.true.)
162 CALL tfw_u_0(rho, r13, s, e_0, npoints)
165 allocate_deriv=.true.)
168 allocate_deriv=.true.)
171 CALL tfw_u_1(rho, grho, r13, s, e_rho, e_ndrho, npoints)
175 allocate_deriv=.true.)
178 allocate_deriv=.true.)
184 CALL tfw_u_2(rho, grho, r13, s, e_rho_rho, e_rho_ndrho, &
185 e_ndrho_ndrho, npoints)
189 allocate_deriv=.true.)
198 CALL tfw_u_3(rho, grho, r13, s, e_rho_rho_rho, e_rho_rho_ndrho, &
199 e_rho_ndrho_ndrho, npoints)
202 cpabort(
"derivatives bigger than 3 not implemented")
206 CALL timestop(handle)
216 SUBROUTINE calc_s(rho, grho, s, npoints)
217 REAL(kind=
dp),
DIMENSION(*),
INTENT(in) :: rho, grho
218 REAL(kind=
dp),
DIMENSION(*),
INTENT(out) :: s
219 INTEGER,
INTENT(in) :: npoints
226 IF (rho(ip) < eps_rho)
THEN
229 s(ip) = grho(ip)*grho(ip)/rho(ip)
232 END SUBROUTINE calc_s
243 INTEGER,
INTENT(in) :: order
245 CHARACTER(len=*),
PARAMETER :: routinen =
'tfw_lsd_eval'
246 INTEGER,
DIMENSION(2),
PARAMETER :: &
250 INTEGER :: handle, i, ispin, npoints
251 INTEGER,
DIMENSION(2, 3) :: bo
252 REAL(kind=
dp) :: epsilon_rho
253 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: s
254 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
255 POINTER :: e_0, e_ndrho, e_ndrho_ndrho, e_rho, &
256 e_rho_ndrho, e_rho_ndrho_ndrho, &
257 e_rho_rho, e_rho_rho_ndrho, &
262 CALL timeset(routinen, handle)
265 NULLIFY (norm_drho(i)%array, rho(i)%array, rho_1_3(i)%array)
269 rhob_1_3=rho_1_3(2)%array, rhoa=rho(1)%array, &
270 rhob=rho(2)%array, norm_drhoa=norm_drho(1)%array, &
271 norm_drhob=norm_drho(2)%array, rho_cutoff=epsilon_rho, &
273 npoints = (bo(2, 1) - bo(1, 1) + 1)*(bo(2, 2) - bo(1, 2) + 1)*(bo(2, 3) - bo(1, 3) + 1)
274 CALL tfw_init(epsilon_rho)
276 ALLOCATE (s(npoints))
279 CALL calc_s(rho(ispin)%array, norm_drho(ispin)%array, s, npoints)
282 allocate_deriv=.true.)
285 CALL tfw_p_0(rho(ispin)%array, &
286 rho_1_3(ispin)%array, s, e_0, npoints)
289 allocate_deriv=.true.)
292 allocate_deriv=.true.)
295 CALL tfw_p_1(rho(ispin)%array, norm_drho(ispin)%array, &
296 rho_1_3(ispin)%array, s, e_rho, e_ndrho, npoints)
300 rho_spin_name(ispin)], allocate_deriv=.true.)
303 norm_drho_spin_name(ispin)], allocate_deriv=.true.)
306 norm_drho_spin_name(ispin)], allocate_deriv=.true.)
309 CALL tfw_p_2(rho(ispin)%array, norm_drho(ispin)%array, &
310 rho_1_3(ispin)%array, s, e_rho_rho, e_rho_ndrho, &
311 e_ndrho_ndrho, npoints)
315 rho_spin_name(ispin), rho_spin_name(ispin)], &
316 allocate_deriv=.true.)
319 rho_spin_name(ispin), norm_drho_spin_name(ispin)], &
320 allocate_deriv=.true.)
323 norm_drho_spin_name(ispin), norm_drho_spin_name(ispin)], &
324 allocate_deriv=.true.)
327 CALL tfw_p_3(rho(ispin)%array, norm_drho(ispin)%array, &
328 rho_1_3(ispin)%array, s, e_rho_rho_rho, e_rho_rho_ndrho, &
329 e_rho_ndrho_ndrho, npoints)
332 cpabort(
"derivatives bigger than 3 not implemented")
337 CALL timestop(handle)
348 SUBROUTINE tfw_u_0(rho, r13, s, e_0, npoints)
350 REAL(kind=
dp),
DIMENSION(*),
INTENT(IN) :: rho, r13, s
351 REAL(kind=
dp),
DIMENSION(*),
INTENT(INOUT) :: e_0
352 INTEGER,
INTENT(in) :: npoints
360 IF (rho(ip) > eps_rho)
THEN
362 e_0(ip) = e_0(ip) + flda*r13(ip)*r13(ip)*rho(ip) + fvw*s(ip)
368 END SUBROUTINE tfw_u_0
380 SUBROUTINE tfw_u_1(rho, grho, r13, s, e_rho, e_ndrho, npoints)
382 REAL(kind=
dp),
DIMENSION(*),
INTENT(IN) :: rho, grho, r13, s
383 REAL(kind=
dp),
DIMENSION(*),
INTENT(INOUT) :: e_rho, e_ndrho
384 INTEGER,
INTENT(in) :: npoints
395 IF (rho(ip) > eps_rho)
THEN
397 e_rho(ip) = e_rho(ip) + f*r13(ip)*r13(ip) - fvw*s(ip)/rho(ip)
398 e_ndrho(ip) = e_ndrho(ip) + 2.0_dp*fvw*grho(ip)/rho(ip)
404 END SUBROUTINE tfw_u_1
417 SUBROUTINE tfw_u_2(rho, grho, r13, s, e_rho_rho, e_rho_ndrho, e_ndrho_ndrho, &
420 REAL(kind=
dp),
DIMENSION(*),
INTENT(IN) :: rho, grho, r13, s
421 REAL(kind=
dp),
DIMENSION(*),
INTENT(INOUT) :: e_rho_rho, e_rho_ndrho, e_ndrho_ndrho
422 INTEGER,
INTENT(in) :: npoints
433 IF (rho(ip) > eps_rho)
THEN
435 e_rho_rho(ip) = e_rho_rho(ip) + f/r13(ip) + 2.0_dp*fvw*s(ip)/(rho(ip)*rho(ip))
436 e_rho_ndrho(ip) = e_rho_ndrho(ip) - 2.0_dp*fvw*grho(ip)/(rho(ip)*rho(ip))
437 e_ndrho_ndrho(ip) = e_ndrho_ndrho(ip) + 2.0_dp*fvw/rho(ip)
443 END SUBROUTINE tfw_u_2
456 SUBROUTINE tfw_u_3(rho, grho, r13, s, e_rho_rho_rho, e_rho_rho_ndrho, &
457 e_rho_ndrho_ndrho, npoints)
459 REAL(kind=
dp),
DIMENSION(*),
INTENT(IN) :: rho, grho, r13, s
460 REAL(kind=
dp),
DIMENSION(*),
INTENT(INOUT) :: e_rho_rho_rho, e_rho_rho_ndrho, &
462 INTEGER,
INTENT(in) :: npoints
467 f = -f13*f23*f53*flda
473 IF (rho(ip) > eps_rho)
THEN
475 e_rho_rho_rho(ip) = e_rho_rho_rho(ip) + f/(r13(ip)*rho(ip)) &
476 - 6.0_dp*fvw*s(ip)/(rho(ip)*rho(ip)*rho(ip))
477 e_rho_rho_ndrho(ip) = e_rho_rho_ndrho(ip) &
478 + 4.0_dp*fvw*grho(ip)/(rho(ip)*rho(ip)*rho(ip))
479 e_rho_ndrho_ndrho(ip) = e_rho_ndrho_ndrho(ip) &
480 - 2.0_dp*fvw/(rho(ip)*rho(ip))
485 END SUBROUTINE tfw_u_3
495 SUBROUTINE tfw_p_0(rhoa, r13a, sa, e_0, npoints)
497 REAL(kind=
dp),
DIMENSION(*),
INTENT(IN) :: rhoa, r13a, sa
498 REAL(kind=
dp),
DIMENSION(*),
INTENT(INOUT) :: e_0
499 INTEGER,
INTENT(in) :: npoints
507 IF (rhoa(ip) > eps_rho)
THEN
508 e_0(ip) = e_0(ip) + flsd*r13a(ip)*r13a(ip)*rhoa(ip) + fvw*sa(ip)
513 END SUBROUTINE tfw_p_0
525 SUBROUTINE tfw_p_1(rhoa, grhoa, r13a, sa, e_rho, e_ndrho, npoints)
527 REAL(kind=
dp),
DIMENSION(*),
INTENT(IN) :: rhoa, grhoa, r13a, sa
528 REAL(kind=
dp),
DIMENSION(*),
INTENT(INOUT) :: e_rho, e_ndrho
529 INTEGER,
INTENT(in) :: npoints
540 IF (rhoa(ip) > eps_rho)
THEN
541 e_rho(ip) = e_rho(ip) + f*r13a(ip)*r13a(ip) - fvw*sa(ip)/rhoa(ip)
542 e_ndrho(ip) = e_ndrho(ip) + 2.0_dp*fvw*grhoa(ip)/rhoa(ip)
547 END SUBROUTINE tfw_p_1
560 SUBROUTINE tfw_p_2(rhoa, grhoa, r13a, sa, e_rho_rho, e_rho_ndrho, &
561 e_ndrho_ndrho, npoints)
563 REAL(kind=
dp),
DIMENSION(*),
INTENT(IN) :: rhoa, grhoa, r13a, sa
564 REAL(kind=
dp),
DIMENSION(*),
INTENT(INOUT) :: e_rho_rho, e_rho_ndrho, e_ndrho_ndrho
565 INTEGER,
INTENT(in) :: npoints
576 IF (rhoa(ip) > eps_rho)
THEN
577 e_rho_rho(ip) = e_rho_rho(ip) &
578 + f/r13a(ip) + 2.0_dp*fvw*sa(ip)/(rhoa(ip)*rhoa(ip))
579 e_rho_ndrho(ip) = e_rho_ndrho(ip) &
580 - 2.0_dp*fvw*grhoa(ip)/(rhoa(ip)*rhoa(ip))
581 e_ndrho_ndrho(ip) = e_ndrho_ndrho(ip) + 2.0_dp*fvw/rhoa(ip)
586 END SUBROUTINE tfw_p_2
599 SUBROUTINE tfw_p_3(rhoa, grhoa, r13a, sa, e_rho_rho_rho, e_rho_rho_ndrho, &
600 e_rho_ndrho_ndrho, npoints)
602 REAL(kind=
dp),
DIMENSION(*),
INTENT(IN) :: rhoa, grhoa, r13a, sa
603 REAL(kind=
dp),
DIMENSION(*),
INTENT(INOUT) :: e_rho_rho_rho, e_rho_rho_ndrho, &
605 INTEGER,
INTENT(in) :: npoints
610 f = -f13*f23*f53*flsd
616 IF (rhoa(ip) > eps_rho)
THEN
617 e_rho_rho_rho(ip) = e_rho_rho_rho(ip) &
618 + f/(r13a(ip)*rhoa(ip)) &
619 - 6.0_dp*fvw*sa(ip)/(rhoa(ip)*rhoa(ip)*rhoa(ip))
620 e_rho_rho_ndrho(ip) = e_rho_rho_ndrho(ip) &
621 + 4.0_dp*fvw*grhoa(ip)/(rhoa(ip)*rhoa(ip)*rhoa(ip))
622 e_rho_ndrho_ndrho(ip) = e_rho_ndrho_ndrho(ip) &
623 - 2.0_dp*fvw/(rhoa(ip)*rhoa(ip))
628 END SUBROUTINE tfw_p_3
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
Defines the basic variable types.
integer, parameter, public dp
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 set_util(cutoff)
...
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
Calculate the Thomas-Fermi kinetic energy functional plus the von Weizsaecker term.
subroutine, public tfw_lda_info(reference, shortform, needs, max_deriv)
...
subroutine, public tfw_lda_eval(rho_set, deriv_set, order)
...
subroutine, public tfw_lsd_info(reference, shortform, needs, max_deriv)
...
subroutine, public tfw_lsd_eval(rho_set, deriv_set, order)
...
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