2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Copyright (C) 2001 PWSCF group
|
|
|
|
! This file is distributed under the terms of the
|
|
|
|
! GNU General Public License. See the file `License'
|
|
|
|
! in the root directory of the present distribution,
|
|
|
|
! or http://www.gnu.org/copyleft/gpl.txt .
|
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
2003-02-08 00:04:36 +08:00
|
|
|
subroutine setup_dgc
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
! Allocate and setup all variable needed in the gradient correction case
|
|
|
|
!
|
|
|
|
! GGA+LSDA is allowed. AdC (September 1999).
|
|
|
|
! GGA+LSDA+NLCC is allowed. AdC (November 1999).
|
|
|
|
!
|
2004-06-26 01:25:37 +08:00
|
|
|
#include "f_defs.h"
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
use pwcom
|
2004-01-23 23:08:03 +08:00
|
|
|
USE kinds, only : DP
|
2003-01-20 05:58:50 +08:00
|
|
|
use phcom
|
2005-11-04 19:47:42 +08:00
|
|
|
use funct, only : dft_is_gradient, gcxc, gcx_spin, gcc_spin
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
|
|
|
integer :: k, is
|
2005-08-28 22:09:42 +08:00
|
|
|
real(DP) :: grho2 (2), rh, zeta, grh2, fac, sx, sc, &
|
2003-01-20 05:58:50 +08:00
|
|
|
v1x, v2x, v1c, v2c, vrrx, vsrx, vssx, vrrc, vsrc, vssc, v1xup, &
|
|
|
|
v1xdw, v2xup, v2xdw, v1cup, v1cdw, vrrxup, vrrxdw, vrsxup, vrsxdw, &
|
|
|
|
vssxup, vssxdw, vrrcup, vrrcdw, vrscup, vrscdw, vrzcup, vrzcdw
|
2005-08-28 22:09:42 +08:00
|
|
|
real (DP), parameter :: epsr = 1.0d-6, epsg = 1.0d-10
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2005-11-04 19:47:42 +08:00
|
|
|
if ( .not. dft_is_gradient() ) return
|
2003-02-08 00:04:36 +08:00
|
|
|
allocate (dvxc_rr( nrxx , nspin , nspin))
|
|
|
|
allocate (dvxc_sr( nrxx , nspin , nspin))
|
|
|
|
allocate (dvxc_ss( nrxx , nspin , nspin))
|
|
|
|
allocate (dvxc_s ( nrxx , nspin , nspin))
|
|
|
|
allocate (grho ( 3 , nrxx , nspin))
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2004-03-07 21:47:42 +08:00
|
|
|
dvxc_rr(:,:,:) = 0.d0
|
|
|
|
dvxc_sr(:,:,:) = 0.d0
|
|
|
|
dvxc_ss(:,:,:) = 0.d0
|
|
|
|
dvxc_s (:,:,:) = 0.d0
|
|
|
|
grho (:,:,:) = 0.d0
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! add rho_core
|
|
|
|
!
|
General cleanup of intrinsic functions:
conversion to real => DBLE
(including real part of a complex number)
conversion to complex => CMPLX
complex conjugate => CONJG
imaginary part => AIMAG
All functions are uppercase.
CMPLX is preprocessed by f_defs.h and performs an explicit cast:
#define CMPLX(a,b) cmplx(a,b,kind=DP)
This implies that 1) f_defs.h must be included whenever a CMPLX is present,
2) CMPLX should stay in a single line, 3) DP must be defined.
All occurrences of real, float, dreal, dfloat, dconjg, dimag, dcmplx
removed - please do not reintroduce any of them.
Tested only with ifc7 and g95 - beware unintended side effects
Maybe not the best solution (explicit casts everywhere would be better)
but it can be easily changed with a script if the need arises.
The following code might be used to test for possible trouble:
program test_intrinsic
implicit none
integer, parameter :: dp = selected_real_kind(14,200)
real (kind=dp) :: a = 0.123456789012345_dp
real (kind=dp) :: b = 0.987654321098765_dp
complex (kind=dp) :: c = ( 0.123456789012345_dp, 0.987654321098765_dp)
print *, ' A = ', a
print *, ' DBLE(A)= ', DBLE(a)
print *, ' C = ', c
print *, 'CONJG(C)= ', CONJG(c)
print *, 'DBLE(c),AIMAG(C) = ', DBLE(c), AIMAG(c)
print *, 'CMPLX(A,B,kind=dp)= ', CMPLX( a, b, kind=dp)
end program test_intrinsic
Note that CMPLX and REAL without a cast yield single precision numbers on
ifc7 and g95 !!!
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2133 c92efa57-630b-4861-b058-cf58834340f0
2005-08-27 01:44:42 +08:00
|
|
|
fac = 1.d0 / DBLE (nspin)
|
2003-02-08 00:04:36 +08:00
|
|
|
if (nlcc_any) then
|
|
|
|
do is = 1, nspin
|
2006-07-08 04:16:45 +08:00
|
|
|
rho(:,is) = fac * rho_core(:) + rho(:,is)
|
|
|
|
rhog(:,is) = fac * rhog_core(:) + rhog(:,is)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
do is = 1, nspin
|
2006-07-08 04:16:45 +08:00
|
|
|
call gradrho (nrx1, nrx2, nrx3, nr1, nr2, nr3, nrxx, rhog (1, is), &
|
|
|
|
ngm, g, nl, grho (1, 1, is) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
do k = 1, nrxx
|
2004-03-07 21:47:42 +08:00
|
|
|
grho2 (1) = grho (1, k, 1) **2 + grho (2, k, 1) **2 + grho (3, k, 1) **2
|
|
|
|
if (nspin == 1) then
|
|
|
|
if (abs (rho (k, 1) ) > epsr .and. grho2 (1) > epsg) then
|
2005-11-02 23:42:06 +08:00
|
|
|
call gcxc (rho (k, nspin), grho2(1), sx, sc, v1x, v2x, v1c, v2c)
|
2003-01-20 05:58:50 +08:00
|
|
|
call dgcxc (rho (k, nspin), grho2, vrrx, vsrx, vssx, vrrc, &
|
|
|
|
vsrc, vssc)
|
2003-02-08 00:04:36 +08:00
|
|
|
dvxc_rr (k, 1, 1) = e2 * (vrrx + vrrc)
|
|
|
|
dvxc_sr (k, 1, 1) = e2 * (vsrx + vsrc)
|
|
|
|
dvxc_ss (k, 1, 1) = e2 * (vssx + vssc)
|
|
|
|
dvxc_s (k, 1, 1) = e2 * (v2x + v2c)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
else
|
2003-01-20 05:58:50 +08:00
|
|
|
grho2 (2) = grho (1, k, 2) **2 + grho (2, k, 2) **2 + grho (3, &
|
|
|
|
k, 2) **2
|
2003-02-08 00:04:36 +08:00
|
|
|
rh = rho (k, 1) + rho (k, 2)
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
grh2 = (grho (1, k, 1) + grho (1, k, 2) ) **2 + (grho (2, k, 1) &
|
2004-03-07 21:47:42 +08:00
|
|
|
+ grho (2, k, 2) ) **2 + (grho (3, k, 1) + grho (3, k, 2) ) ** 2
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
call gcx_spin (rho (k, 1), rho (k, 2), grho2 (1), grho2 (2), &
|
|
|
|
sx, v1xup, v1xdw, v2xup, v2xdw)
|
|
|
|
|
|
|
|
call dgcxc_spin (rho (k, 1), rho (k, 2), grho (1, k, 1), &
|
|
|
|
grho (1, k, 2), vrrxup, vrrxdw, vrsxup, vrsxdw, vssxup, vssxdw, &
|
|
|
|
vrrcup, vrrcdw, vrscup, vrscdw, vssc, vrzcup, vrzcdw)
|
2004-03-07 21:47:42 +08:00
|
|
|
if (rh > epsr) then
|
2003-02-08 00:04:36 +08:00
|
|
|
zeta = (rho (k, 1) - rho (k, 2) ) / rh
|
|
|
|
call gcc_spin (rh, zeta, grh2, sc, v1cup, v1cdw, v2c)
|
2003-01-20 05:58:50 +08:00
|
|
|
dvxc_rr (k, 1, 1) = e2 * (vrrxup + vrrcup + vrzcup * &
|
|
|
|
(1.d0 - zeta) / rh)
|
2004-03-07 21:47:42 +08:00
|
|
|
dvxc_rr (k, 1, 2) = e2 * (vrrcup - vrzcup * (1.d0 + zeta) / rh)
|
|
|
|
dvxc_rr (k, 2, 1) = e2 * (vrrcdw + vrzcdw * (1.d0 - zeta) / rh)
|
2003-01-20 05:58:50 +08:00
|
|
|
dvxc_rr (k, 2, 2) = e2 * (vrrxdw + vrrcdw - vrzcdw * &
|
|
|
|
(1.d0 + zeta) / rh)
|
2003-02-08 00:04:36 +08:00
|
|
|
dvxc_s (k, 1, 1) = e2 * (v2xup + v2c)
|
|
|
|
dvxc_s (k, 1, 2) = e2 * v2c
|
|
|
|
dvxc_s (k, 2, 1) = e2 * v2c
|
|
|
|
dvxc_s (k, 2, 2) = e2 * (v2xdw + v2c)
|
|
|
|
else
|
|
|
|
dvxc_rr (k, 1, 1) = 0.d0
|
|
|
|
dvxc_rr (k, 1, 2) = 0.d0
|
|
|
|
dvxc_rr (k, 2, 1) = 0.d0
|
|
|
|
dvxc_rr (k, 2, 2) = 0.d0
|
|
|
|
dvxc_s (k, 1, 1) = 0.d0
|
|
|
|
dvxc_s (k, 1, 2) = 0.d0
|
|
|
|
dvxc_s (k, 2, 1) = 0.d0
|
|
|
|
dvxc_s (k, 2, 2) = 0.d0
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
dvxc_sr (k, 1, 1) = e2 * (vrsxup + vrscup)
|
|
|
|
dvxc_sr (k, 1, 2) = e2 * vrscup
|
|
|
|
dvxc_sr (k, 2, 1) = e2 * vrscdw
|
|
|
|
dvxc_sr (k, 2, 2) = e2 * (vrsxdw + vrscdw)
|
|
|
|
dvxc_ss (k, 1, 1) = e2 * (vssxup + vssc)
|
|
|
|
dvxc_ss (k, 1, 2) = e2 * vssc
|
|
|
|
dvxc_ss (k, 2, 1) = e2 * vssc
|
|
|
|
dvxc_ss (k, 2, 2) = e2 * (vssxdw + vssc)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
if (nlcc_any) then
|
|
|
|
do is = 1, nspin
|
2006-07-08 04:16:45 +08:00
|
|
|
rho(:,is) = rho(:,is) - fac * rho_core(:)
|
|
|
|
rhog(:,is) = rhog(:,is) - fac * rhog_core(:)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
endif
|
2004-03-07 21:47:42 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine setup_dgc
|