2004-11-03 18:58:17 +08:00
|
|
|
!
|
|
|
|
! Copyright (C) 2001-2004 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 .
|
|
|
|
!
|
|
|
|
#include "f_defs.h"
|
|
|
|
!
|
2003-10-16 22:39:25 +08:00
|
|
|
!------------------------------------------------
|
2004-11-03 18:58:17 +08:00
|
|
|
SUBROUTINE addnlcc_zstar_eu_us( drhoscf )
|
2003-10-16 22:39:25 +08:00
|
|
|
!----------===================-------------------
|
|
|
|
|
2005-11-04 19:47:42 +08:00
|
|
|
USE funct, only : dft_is_gradient
|
2004-11-03 18:58:17 +08:00
|
|
|
USE pwcom
|
|
|
|
USE kinds, ONLY : DP
|
|
|
|
USE phcom
|
|
|
|
USE mp_global, ONLY : my_pool_id
|
|
|
|
|
2003-10-16 22:39:25 +08:00
|
|
|
|
2004-11-03 18:58:17 +08:00
|
|
|
IMPLICIT NONE
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
COMPLEX(DP) :: drhoscf (nrxx,nspin,3)
|
2003-10-16 22:39:25 +08:00
|
|
|
|
|
|
|
|
2004-11-03 18:58:17 +08:00
|
|
|
INTEGER :: nrtot, ipert, jpert, is, is1, irr, ir, mode, mode1
|
|
|
|
INTEGER :: imode0, npe, ipol
|
2003-10-16 22:39:25 +08:00
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP) :: fac
|
2003-10-16 22:39:25 +08:00
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
COMPLEX(DP), DIMENSION(nrxx) :: drhoc
|
|
|
|
COMPLEX(DP), DIMENSION(nrxx,nspin) :: dvaux
|
2004-11-03 18:58:17 +08:00
|
|
|
|
|
|
|
IF (.NOT.nlcc_any) RETURN
|
|
|
|
|
|
|
|
IF ( my_pool_id /= 0 ) RETURN
|
2003-10-16 22:39:25 +08:00
|
|
|
|
|
|
|
|
2004-11-03 18:58:17 +08:00
|
|
|
DO ipol = 1, 3
|
2003-10-16 22:39:25 +08:00
|
|
|
imode0 = 0
|
2004-11-03 18:58:17 +08:00
|
|
|
DO irr = 1, nirr
|
2003-10-16 22:39:25 +08:00
|
|
|
npe = npert(irr)
|
|
|
|
!
|
|
|
|
! compute the exchange and correlation potential for this mode
|
|
|
|
!
|
|
|
|
nrtot = nr1 * nr2 * nr3
|
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)
|
2004-11-03 18:58:17 +08:00
|
|
|
DO ipert = 1, npe
|
2003-10-16 22:39:25 +08:00
|
|
|
mode = imode0 + ipert
|
|
|
|
|
|
|
|
dvaux = (0.0_dp,0.0_dp)
|
2004-11-03 18:58:17 +08:00
|
|
|
CALL addcore (mode, drhoc)
|
2003-10-16 22:39:25 +08:00
|
|
|
|
2004-11-03 18:58:17 +08:00
|
|
|
DO is = 1, nspin
|
2003-10-16 22:39:25 +08:00
|
|
|
rho(:,is) = rho(:,is) + fac * rho_core
|
2004-11-03 18:58:17 +08:00
|
|
|
END DO
|
2003-10-16 22:39:25 +08:00
|
|
|
|
2004-11-03 18:58:17 +08:00
|
|
|
DO is = 1, nspin
|
|
|
|
DO is1 = 1, nspin
|
|
|
|
DO ir = 1, nrxx
|
2003-10-16 22:39:25 +08:00
|
|
|
dvaux (ir, is) = dvaux (ir, is) + &
|
|
|
|
dmuxc (ir, is, is1) * &
|
|
|
|
drhoscf (ir, is1, ipol)
|
2004-11-03 18:58:17 +08:00
|
|
|
ENDDO
|
|
|
|
ENDDO
|
|
|
|
END DO
|
2003-10-16 22:39:25 +08:00
|
|
|
!
|
|
|
|
! add gradient correction to xc, NB: if nlcc is true we need to add here
|
|
|
|
! its contribution. grho contains already the core charge
|
|
|
|
!
|
|
|
|
|
2005-11-04 19:47:42 +08:00
|
|
|
IF ( dft_is_gradient() ) &
|
2004-11-03 18:58:17 +08:00
|
|
|
CALL dgradcorr (rho, grho, dvxc_rr, dvxc_sr, dvxc_ss, dvxc_s, xq, &
|
2003-10-16 22:39:25 +08:00
|
|
|
drhoscf (1, 1, ipert), nr1, nr2, nr3, nrx1, nrx2, nrx3, nrxx, &
|
|
|
|
nspin, nl, ngm, g, alat, omega, dvaux)
|
|
|
|
|
2004-11-03 18:58:17 +08:00
|
|
|
DO is = 1, nspin
|
2003-10-16 22:39:25 +08:00
|
|
|
rho(:,is) = rho(:,is) - fac * rho_core
|
2004-11-03 18:58:17 +08:00
|
|
|
END DO
|
2003-10-16 22:39:25 +08:00
|
|
|
|
2004-11-03 18:58:17 +08:00
|
|
|
DO is = 1, nspin
|
2003-10-16 22:39:25 +08:00
|
|
|
zstareu0(ipol,mode) = zstareu0(ipol,mode) - &
|
2005-08-28 22:09:42 +08:00
|
|
|
omega * fac / REAL(nrtot, DP) * &
|
2004-11-03 18:58:17 +08:00
|
|
|
DOT_PRODUCT(dvaux(1:nrxx,is),drhoc(1:nrxx))
|
|
|
|
END DO
|
|
|
|
END DO
|
2003-10-16 22:39:25 +08:00
|
|
|
imode0 = imode0 + npe
|
2004-11-03 18:58:17 +08:00
|
|
|
END DO
|
|
|
|
END DO
|
2003-10-16 22:39:25 +08:00
|
|
|
|
2004-11-03 18:58:17 +08:00
|
|
|
RETURN
|
|
|
|
END SUBROUTINE addnlcc_zstar_eu_us
|