2004-11-25 22:51:47 +08:00
|
|
|
!
|
2005-05-17 03:19:04 +08:00
|
|
|
! Copyright (C) 2002-2005 FPMD-CPV groups
|
2004-11-25 22:51:47 +08:00
|
|
|
! 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 .
|
|
|
|
!
|
2004-12-31 19:14:32 +08:00
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
MODULE exchange_correlation
|
|
|
|
!=----------------------------------------------------------------------------=!
|
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
|
|
|
#include "f_defs.h"
|
2004-11-25 22:51:47 +08:00
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
USE kinds, ONLY: DP
|
2004-11-25 22:51:47 +08:00
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
SAVE
|
|
|
|
|
|
|
|
PRIVATE
|
|
|
|
|
2004-12-31 19:14:32 +08:00
|
|
|
! ... Gradient Correction & exchange and correlation
|
2004-11-25 22:51:47 +08:00
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP), PARAMETER :: small_rho = 1.0d-10
|
2004-12-31 19:14:32 +08:00
|
|
|
|
2005-01-15 18:53:46 +08:00
|
|
|
PUBLIC :: v2gc, exch_corr_energy, stress_xc
|
2004-12-31 19:14:32 +08:00
|
|
|
|
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
CONTAINS
|
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
|
2005-04-22 23:23:19 +08:00
|
|
|
SUBROUTINE v2gc(v2xc, grho, rhoer, vpot)
|
2004-12-31 19:14:32 +08:00
|
|
|
|
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
|
|
|
USE kinds, ONLY: DP
|
2004-12-31 19:14:32 +08:00
|
|
|
USE fft
|
2005-04-15 05:08:53 +08:00
|
|
|
USE fft_base, ONLY: dfftp
|
2004-12-31 19:14:32 +08:00
|
|
|
USE cell_base, ONLY: tpiba
|
|
|
|
USE mp_global
|
2005-04-22 23:23:19 +08:00
|
|
|
USE reciprocal_vectors, ONLY: gstart, gx
|
|
|
|
USE gvecp, ONLY: ngm
|
2004-12-31 19:14:32 +08:00
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
!
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP) :: vpot(:,:,:,:)
|
|
|
|
REAL(DP), intent(in) :: v2xc(:,:,:,:,:)
|
|
|
|
REAL(DP), intent(in) :: grho(:,:,:,:,:)
|
|
|
|
REAL(DP), intent(in) :: rhoer(:,:,:,:)
|
2004-12-31 19:14:32 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
integer :: ig, ipol, nxl, nyl, nzl, i, j, k, is, js, nspin
|
|
|
|
integer :: ldx, ldy, ldz
|
2005-08-28 22:09:42 +08:00
|
|
|
COMPLEX(DP), allocatable :: psi(:,:,:)
|
|
|
|
COMPLEX(DP), allocatable :: vtemp(:)
|
|
|
|
COMPLEX(DP), allocatable :: vtemp_pol(:)
|
|
|
|
REAL(DP), ALLOCATABLE :: v(:,:,:)
|
|
|
|
REAL(DP) :: fac
|
2004-12-31 19:14:32 +08:00
|
|
|
! ...
|
2005-03-02 18:03:55 +08:00
|
|
|
ldx = dfftp%nr1x
|
|
|
|
ldy = dfftp%nr2x
|
2005-01-15 18:53:46 +08:00
|
|
|
ldz = dfftp%npl
|
2005-03-02 18:03:55 +08:00
|
|
|
nxl = MIN( dfftp%nr1, SIZE( grho, 1 ) )
|
|
|
|
nyl = MIN( dfftp%nr2, SIZE( grho, 2 ) )
|
|
|
|
nzl = MIN( dfftp%npl, SIZE( grho, 3 ) )
|
2004-12-31 19:14:32 +08:00
|
|
|
nspin = SIZE(rhoer,4)
|
|
|
|
|
2005-04-15 05:08:53 +08:00
|
|
|
!fac = REAL(nspin)
|
|
|
|
fac = 1.0d0
|
2005-01-15 18:53:46 +08:00
|
|
|
|
2005-04-22 23:23:19 +08:00
|
|
|
ALLOCATE( vtemp( ngm ) )
|
|
|
|
ALLOCATE( vtemp_pol( ngm ) )
|
2005-01-15 18:53:46 +08:00
|
|
|
|
2004-12-31 19:14:32 +08:00
|
|
|
DO js = 1, nspin
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
|
|
|
ALLOCATE( psi( ldx, ldy, ldz ) )
|
|
|
|
!
|
|
|
|
vtemp = 0.0d0
|
2004-12-31 19:14:32 +08:00
|
|
|
|
|
|
|
DO ipol = 1, 3
|
|
|
|
DO is = 1, nspin
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
2004-12-31 19:14:32 +08:00
|
|
|
DO k = 1, nzl
|
|
|
|
DO j = 1, nyl
|
|
|
|
DO i = 1, nxl
|
|
|
|
psi(i,j,k) = fac * v2xc(i,j,k,js,is) * grho(i,j,k,ipol,is)
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
END DO
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
|
|
|
CALL pfwfft( vtemp_pol, psi )
|
|
|
|
!
|
2005-04-22 23:23:19 +08:00
|
|
|
DO ig = gstart, ngm
|
|
|
|
vtemp(ig) = vtemp(ig) + vtemp_pol(ig) * CMPLX( 0.d0, tpiba * gx( ipol, ig ) )
|
2004-12-31 19:14:32 +08:00
|
|
|
END DO
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
2004-12-31 19:14:32 +08:00
|
|
|
END DO
|
|
|
|
END DO
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
|
|
|
DEALLOCATE( psi )
|
2004-12-31 19:14:32 +08:00
|
|
|
|
2005-01-15 18:53:46 +08:00
|
|
|
ALLOCATE( v( ldx, ldy, ldz ) )
|
|
|
|
!
|
|
|
|
CALL pinvfft( v, vtemp )
|
2004-12-31 19:14:32 +08:00
|
|
|
|
|
|
|
DO k = 1, nzl
|
|
|
|
DO j = 1, nyl
|
|
|
|
DO i = 1, nxl
|
|
|
|
vpot(i,j,k,js) = vpot(i,j,k,js) - v(i,j,k)
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
END DO
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
DEALLOCATE( v )
|
|
|
|
|
2004-12-31 19:14:32 +08:00
|
|
|
END DO
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
DEALLOCATE(vtemp_pol)
|
|
|
|
DEALLOCATE(vtemp)
|
|
|
|
|
2004-11-25 22:51:47 +08:00
|
|
|
RETURN
|
2005-05-18 16:49:38 +08:00
|
|
|
END SUBROUTINE v2gc
|
2004-12-31 19:14:32 +08:00
|
|
|
|
|
|
|
!=----------------------------------------------------------------------------=!
|
2004-11-25 22:51:47 +08:00
|
|
|
|
2005-01-15 18:53:46 +08:00
|
|
|
SUBROUTINE stress_gc(grho, v2xc, gcpail, omega)
|
|
|
|
!
|
|
|
|
use grid_dimensions, only: nr1, nr2, nr3
|
2005-04-15 05:08:53 +08:00
|
|
|
USE fft_base, ONLY: dfftp
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
!
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP) :: v2xc(:,:,:,:,:)
|
|
|
|
REAL(DP) :: grho(:,:,:,:,:)
|
|
|
|
REAL(DP) :: gcpail(6)
|
|
|
|
REAL(DP) :: omega
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP) :: stre, grhoi, grhoj
|
2005-01-15 18:53:46 +08:00
|
|
|
INTEGER :: i, j, k, ipol, jpol, ic, nxl, nyl, nzl, is, js, nspin
|
|
|
|
INTEGER, DIMENSION(6), PARAMETER :: alpha = (/ 1,2,3,2,3,3 /)
|
|
|
|
INTEGER, DIMENSION(6), PARAMETER :: beta = (/ 1,1,1,2,2,3 /)
|
|
|
|
! ...
|
|
|
|
nxl = MIN( dfftp%nr1, SIZE( grho, 1 ) )
|
|
|
|
nyl = MIN( dfftp%nr2, SIZE( grho, 2 ) )
|
|
|
|
nzl = MIN( dfftp%npl, SIZE( grho, 3 ) )
|
|
|
|
nspin = SIZE(grho,5)
|
|
|
|
|
|
|
|
DO ic = 1, 6
|
|
|
|
ipol = alpha(ic)
|
|
|
|
jpol = beta(ic)
|
|
|
|
stre = 0.0d0
|
|
|
|
DO is = 1, nspin
|
|
|
|
DO js = 1, nspin
|
|
|
|
DO k = 1, nzl
|
|
|
|
DO j = 1, nyl
|
|
|
|
DO i = 1, nxl
|
|
|
|
stre = stre + v2xc(i,j,k,is,js) * grho(i,j,k,ipol,js) * grho(i,j,k,jpol,is)
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
END DO
|
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
|
|
|
gcpail(ic) = - DBLE(nspin) * stre * omega / DBLE(nr1*nr2*nr3)
|
2005-01-15 18:53:46 +08:00
|
|
|
END DO
|
|
|
|
|
|
|
|
RETURN
|
|
|
|
END SUBROUTINE stress_gc
|
|
|
|
|
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
|
2005-03-26 23:29:07 +08:00
|
|
|
SUBROUTINE stress_xc( dexc, strvxc, sfac, vxc, grho, v2xc, &
|
2005-04-22 23:23:19 +08:00
|
|
|
gagx_l, tnlcc, rhocp, box)
|
2005-01-15 18:53:46 +08:00
|
|
|
|
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
|
|
|
USE kinds, ONLY: DP
|
|
|
|
USE ions_base, ONLY: nsp
|
|
|
|
USE cell_module, ONLY: boxdimensions
|
2005-04-22 23:23:19 +08:00
|
|
|
USE cell_base, ONLY: tpiba
|
|
|
|
USE funct, ONLY: igcx, igcc
|
|
|
|
USE reciprocal_vectors, ONLY: gstart, g
|
|
|
|
USE gvecp, ONLY: ngm
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
|
|
|
|
! -- ARGUMENT
|
|
|
|
|
|
|
|
type (boxdimensions), intent(in) :: box
|
2005-03-26 23:29:07 +08:00
|
|
|
LOGICAL :: tnlcc(:)
|
2005-08-28 22:09:42 +08:00
|
|
|
COMPLEX(DP) :: vxc(:,:)
|
|
|
|
COMPLEX(DP), INTENT(IN) :: sfac(:,:)
|
|
|
|
REAL(DP) :: dexc(:), strvxc
|
|
|
|
REAL(DP) :: grho(:,:,:,:,:)
|
|
|
|
REAL(DP) :: v2xc(:,:,:,:,:)
|
|
|
|
REAL(DP) :: GAgx_L(:,:)
|
|
|
|
REAL(DP) :: rhocp(:,:)
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
INTEGER, DIMENSION(6), PARAMETER :: alpha = (/ 1,2,3,2,3,3 /)
|
|
|
|
INTEGER, DIMENSION(6), PARAMETER :: beta = (/ 1,1,1,2,2,3 /)
|
|
|
|
! ... dalbe(:) = delta(alpha(:),beta(:))
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP), DIMENSION(6), PARAMETER :: dalbe = &
|
|
|
|
(/ 1.0_DP, 0.0_DP, 0.0_DP, 1.0_DP, 0.0_DP, 1.0_DP /)
|
2005-01-15 18:53:46 +08:00
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
COMPLEX(DP) :: tex1, tex2, tex3
|
|
|
|
REAL(DP) :: gcpail(6), omega
|
2005-01-15 18:53:46 +08:00
|
|
|
INTEGER :: ig, k, is, ispin, nspin
|
|
|
|
|
|
|
|
omega = box%deth
|
|
|
|
nspin = SIZE(vxc, 2)
|
|
|
|
|
|
|
|
DEXC = 0.0d0
|
|
|
|
|
|
|
|
! ... computes omega * \sum_{G}[ S(G)*rhopr(G)* G_{alpha} G_{beta}/|G|]
|
|
|
|
! ... (252) Phd thesis Dal Corso. Opposite sign.
|
|
|
|
|
|
|
|
IF ( ANY( tnlcc ) ) THEN
|
|
|
|
|
2005-04-22 23:23:19 +08:00
|
|
|
DO ig = gstart, ngm
|
2005-08-28 22:09:42 +08:00
|
|
|
tex1 = (0.0_DP , 0.0_DP)
|
2005-01-15 18:53:46 +08:00
|
|
|
DO is=1,nsp
|
|
|
|
IF ( tnlcc(is) ) THEN
|
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
|
|
|
tex1 = tex1 + sfac( ig, is ) * CMPLX(rhocp(ig,is), 0.d0)
|
2005-01-15 18:53:46 +08:00
|
|
|
END IF
|
|
|
|
END DO
|
2005-08-28 22:09:42 +08:00
|
|
|
tex2 = 0.0_DP
|
2005-01-15 18:53:46 +08:00
|
|
|
DO ispin = 1, nspin
|
|
|
|
tex2 = tex2 + CONJG( vxc(ig, ispin) )
|
|
|
|
END DO
|
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
|
|
|
tex3 = DBLE(tex1 * tex2) / SQRT( g( ig ) ) / tpiba
|
2005-01-15 18:53:46 +08:00
|
|
|
dexc = dexc + tex3 * gagx_l(:,ig)
|
|
|
|
END DO
|
2005-08-28 22:09:42 +08:00
|
|
|
dexc = dexc * 2.0_DP * omega
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
END IF
|
|
|
|
|
|
|
|
! ... (E_{xc} - \int dr v_{xc}(n) n(r))/omega part of the stress
|
|
|
|
! ... this part of the stress is diagonal.
|
|
|
|
|
|
|
|
dexc = dexc + strvxc * dalbe
|
|
|
|
|
2005-03-26 23:29:07 +08:00
|
|
|
IF ( ( igcx > 0 ) .OR. ( igcc > 0 ) ) THEN
|
2005-01-15 18:53:46 +08:00
|
|
|
CALL stress_gc(grho, v2xc, gcpail, omega)
|
|
|
|
dexc = dexc + gcpail
|
|
|
|
END IF
|
|
|
|
|
|
|
|
RETURN
|
2005-05-18 16:49:38 +08:00
|
|
|
END SUBROUTINE stress_xc
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
|
|
|
|
|
2005-04-22 23:23:19 +08:00
|
|
|
SUBROUTINE exch_corr_energy(rhoetr, rhoetg, grho, vpot, sxc, vxc, v2xc)
|
2005-01-15 18:53:46 +08:00
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
USE kinds, ONLY: DP
|
2005-03-07 22:13:00 +08:00
|
|
|
USE grid_dimensions, ONLY: nr1l, nr2l, nr3l
|
2005-03-26 23:29:07 +08:00
|
|
|
USE funct, ONLY: igcx, igcc
|
2004-11-25 22:51:47 +08:00
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL (DP) :: rhoetr(:,:,:,:)
|
|
|
|
COMPLEX(DP) :: rhoetg(:,:)
|
|
|
|
REAL (DP) :: grho(:,:,:,:,:)
|
|
|
|
REAL (DP) :: vpot(:,:,:,:)
|
|
|
|
REAL (DP) :: sxc ! E_xc energy
|
|
|
|
REAL (DP) :: vxc ! SUM ( v(r) * rho(r) )
|
|
|
|
REAL (DP) :: v2xc(:,:,:,:,:)
|
|
|
|
REAL (DP) :: ddot
|
2004-12-31 19:14:32 +08:00
|
|
|
|
2005-05-19 05:01:05 +08:00
|
|
|
INTEGER :: nspin, nnr, ispin, j, k, i
|
2004-12-31 19:14:32 +08:00
|
|
|
|
2005-01-15 18:53:46 +08:00
|
|
|
! vpot = vxc(rhoetr); vpot(r) <-- u(r)
|
2004-12-31 19:14:32 +08:00
|
|
|
|
2005-01-15 18:53:46 +08:00
|
|
|
nnr = SIZE( rhoetr, 1 ) * SIZE( rhoetr, 2 ) * SIZE( rhoetr, 3 )
|
|
|
|
nspin = SIZE( rhoetr, 4 )
|
- FPMD: pseudopotential variable wsg, wnl, fnl substituted with
dion, beta, bec everyware.
- subroutines formfn, compute_beta, nlsm1, nlsm2, ecc ... now are common
between FPMD and CPV, a lot of clean ups!
- Changes in stdout: relevant physical quantities ( positions velocities an cell )
are now printed with the seme format of the corresponding input card,
like in PW, as was suggested by SdG.
- exemple23 updated to reflect the new input namelist "wannier"
- Subroutine init_run now is used in FPMD too.
- WARNING in the stress computed with CP, for a pseudo with core-corrections,
a contribution is missing! Not yet fixed, I need to talk with PG for the
box staff.
- WARNING the examples reference are not updated, I'm on the IBM sp, and
I prefer to update them from a linux machine.
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2110 c92efa57-630b-4861-b058-cf58834340f0
2005-08-22 22:14:13 +08:00
|
|
|
|
2004-12-31 19:14:32 +08:00
|
|
|
!
|
2005-05-19 05:01:05 +08:00
|
|
|
IF( nnr /= nr3l * nr2l * nr1l ) THEN
|
|
|
|
DO ispin = 1, nspin
|
|
|
|
DO k = 1, SIZE( rhoetr, 3 )
|
|
|
|
DO j = 1, SIZE( rhoetr, 2 )
|
|
|
|
DO i = 1, SIZE( rhoetr, 1 )
|
|
|
|
IF( i > nr1l .OR. j > nr2l .OR. k > nr3l ) THEN
|
|
|
|
rhoetr( i, j, k, ispin ) = 0.0d0
|
- FPMD: pseudopotential variable wsg, wnl, fnl substituted with
dion, beta, bec everyware.
- subroutines formfn, compute_beta, nlsm1, nlsm2, ecc ... now are common
between FPMD and CPV, a lot of clean ups!
- Changes in stdout: relevant physical quantities ( positions velocities an cell )
are now printed with the seme format of the corresponding input card,
like in PW, as was suggested by SdG.
- exemple23 updated to reflect the new input namelist "wannier"
- Subroutine init_run now is used in FPMD too.
- WARNING in the stress computed with CP, for a pseudo with core-corrections,
a contribution is missing! Not yet fixed, I need to talk with PG for the
box staff.
- WARNING the examples reference are not updated, I'm on the IBM sp, and
I prefer to update them from a linux machine.
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2110 c92efa57-630b-4861-b058-cf58834340f0
2005-08-22 22:14:13 +08:00
|
|
|
IF( ( igcx > 0 ) .OR. ( igcc > 0 ) ) THEN
|
|
|
|
grho ( i, j, k, :, ispin ) = 0.0d0
|
|
|
|
END IF
|
2005-05-19 05:01:05 +08:00
|
|
|
END IF
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
END IF
|
- FPMD: pseudopotential variable wsg, wnl, fnl substituted with
dion, beta, bec everyware.
- subroutines formfn, compute_beta, nlsm1, nlsm2, ecc ... now are common
between FPMD and CPV, a lot of clean ups!
- Changes in stdout: relevant physical quantities ( positions velocities an cell )
are now printed with the seme format of the corresponding input card,
like in PW, as was suggested by SdG.
- exemple23 updated to reflect the new input namelist "wannier"
- Subroutine init_run now is used in FPMD too.
- WARNING in the stress computed with CP, for a pseudo with core-corrections,
a contribution is missing! Not yet fixed, I need to talk with PG for the
box staff.
- WARNING the examples reference are not updated, I'm on the IBM sp, and
I prefer to update them from a linux machine.
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2110 c92efa57-630b-4861-b058-cf58834340f0
2005-08-22 22:14:13 +08:00
|
|
|
|
2005-05-19 05:01:05 +08:00
|
|
|
!
|
2005-01-16 04:07:08 +08:00
|
|
|
CALL exch_corr_wrapper( nnr, nspin, grho(1,1,1,1,1), rhoetr(1,1,1,1), &
|
|
|
|
sxc, vpot(1,1,1,1), v2xc(1,1,1,1,1) )
|
2005-03-07 22:13:00 +08:00
|
|
|
|
2004-12-31 19:14:32 +08:00
|
|
|
!
|
2005-03-26 23:29:07 +08:00
|
|
|
IF( ( igcx > 0 ) .OR. ( igcc > 0 ) ) THEN
|
2004-12-31 19:14:32 +08:00
|
|
|
! ... vpot additional term for gradient correction
|
2005-04-22 23:23:19 +08:00
|
|
|
CALL v2gc( v2xc, grho, rhoetr, vpot )
|
2004-11-25 22:51:47 +08:00
|
|
|
END If
|
2005-01-15 18:53:46 +08:00
|
|
|
|
2005-03-07 22:13:00 +08:00
|
|
|
!
|
|
|
|
! vxc = SUM( vpot * rhoetr )
|
|
|
|
!
|
|
|
|
vxc = 0.0d0
|
|
|
|
DO ispin = 1, nspin
|
|
|
|
DO k = 1, nr3l
|
|
|
|
DO j = 1, nr2l
|
|
|
|
vxc = vxc + &
|
|
|
|
DDOT ( nr1l, vpot(1,j,k,ispin), 1, rhoetr(1,j,k,ispin), 1 )
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
END DO
|
|
|
|
|
- FPMD: pseudopotential variable wsg, wnl, fnl substituted with
dion, beta, bec everyware.
- subroutines formfn, compute_beta, nlsm1, nlsm2, ecc ... now are common
between FPMD and CPV, a lot of clean ups!
- Changes in stdout: relevant physical quantities ( positions velocities an cell )
are now printed with the seme format of the corresponding input card,
like in PW, as was suggested by SdG.
- exemple23 updated to reflect the new input namelist "wannier"
- Subroutine init_run now is used in FPMD too.
- WARNING in the stress computed with CP, for a pseudo with core-corrections,
a contribution is missing! Not yet fixed, I need to talk with PG for the
box staff.
- WARNING the examples reference are not updated, I'm on the IBM sp, and
I prefer to update them from a linux machine.
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2110 c92efa57-630b-4861-b058-cf58834340f0
2005-08-22 22:14:13 +08:00
|
|
|
|
2005-01-15 18:53:46 +08:00
|
|
|
RETURN
|
2005-05-18 16:49:38 +08:00
|
|
|
END SUBROUTINE exch_corr_energy
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
END MODULE exchange_correlation
|
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
|
|
|
|
|
2004-11-25 22:51:47 +08:00
|
|
|
|
2004-12-31 19:14:32 +08:00
|
|
|
!=----------------------------------------------------------------------------=!
|
2005-01-15 18:53:46 +08:00
|
|
|
! CP subroutines
|
2004-12-31 19:14:32 +08:00
|
|
|
!=----------------------------------------------------------------------------=!
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
subroutine exch_corr_h(nspin,rhog,rhor,exc,dxc)
|
|
|
|
!
|
|
|
|
! calculate exch-corr potential, energy, and derivatives dxc(i,j)
|
|
|
|
! of e(xc) with respect to to cell parameter h(i,j)
|
|
|
|
!
|
2005-07-14 02:22:42 +08:00
|
|
|
use funct, only : iexch, icorr, igcx, igcc
|
|
|
|
use gvecp, only : ng => ngm
|
|
|
|
use grid_dimensions, only : nr1, nr2, nr3, nnr => nnrx
|
|
|
|
use cell_base, only : ainv, omega
|
|
|
|
use control_flags, only : tpre
|
|
|
|
use derho, only : drhor
|
|
|
|
use mp, only : mp_sum
|
|
|
|
use metagga, ONLY : ismeta, kedtaur
|
2005-09-19 07:49:24 +08:00
|
|
|
use kinds, ONLY : DP
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
|
|
|
implicit none
|
2005-09-19 07:49:24 +08:00
|
|
|
|
|
|
|
! input
|
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
integer nspin
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
|
|
|
! rhog contains the charge density in G space
|
|
|
|
! rhor contains the charge density in R space
|
|
|
|
!
|
|
|
|
complex(DP) :: rhog( ng, nspin )
|
|
|
|
!
|
|
|
|
! output
|
|
|
|
! rhor contains the exchange-correlation potential
|
|
|
|
!
|
|
|
|
real(DP) :: rhor( nnr, nspin ), dxc( 3, 3 ), exc
|
|
|
|
!
|
|
|
|
! local
|
|
|
|
!
|
|
|
|
integer :: i, j, ir, iss
|
|
|
|
real(DP) :: dexc(3,3)
|
|
|
|
real(DP), allocatable :: gradr(:,:,:)
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
|
|
|
! filling of gradr with the gradient of rho using fft's
|
|
|
|
!
|
|
|
|
if (igcx /= 0 .or. igcc /= 0) then
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
|
|
|
allocate( gradr( nnr, 3, nspin ) )
|
|
|
|
call fillgrad( nspin, rhog, gradr )
|
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
end if
|
2005-09-19 07:49:24 +08:00
|
|
|
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
2005-07-14 02:22:42 +08:00
|
|
|
if(ismeta) then
|
|
|
|
call tpssmeta(nnr,nspin,gradr,rhor,kedtaur,exc)
|
|
|
|
else
|
|
|
|
CALL exch_corr_cp(nnr,nspin,gradr,rhor,exc)
|
|
|
|
end if
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
call mp_sum( exc )
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
exc=exc*omega/DBLE(nr1*nr2*nr3)
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
|
|
|
! exchange-correlation contribution to pressure
|
|
|
|
!
|
2005-09-19 07:49:24 +08:00
|
|
|
dxc = 0.0d0
|
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
if (tpre) then
|
|
|
|
!
|
2005-09-19 07:49:24 +08:00
|
|
|
do iss = 1, nspin
|
|
|
|
do j=1,3
|
|
|
|
do i=1,3
|
|
|
|
do ir=1,nnr
|
|
|
|
dxc(i,j) = dxc(i,j) + rhor( ir, iss ) * drhor( ir, iss, i, j )
|
|
|
|
end do
|
2005-01-15 18:53:46 +08:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
|
|
|
dxc = dxc * omega / ( nr1*nr2*nr3 )
|
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
call mp_sum ( dxc )
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
do j=1,3
|
|
|
|
do i=1,3
|
|
|
|
dxc(i,j) = dxc(i,j) + exc*ainv(j,i)
|
|
|
|
end do
|
|
|
|
end do
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
end if
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
|
|
|
! second part of the xc-potential
|
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
if (igcx /= 0 .or. igcc /= 0) then
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
call gradh( nspin, gradr, rhog, rhor, dexc)
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
if (tpre) then
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
call mp_sum ( dexc )
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
dxc = dxc + dexc
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
end if
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
deallocate(gradr)
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
end if
|
|
|
|
!
|
|
|
|
return
|
2005-05-12 23:19:08 +08:00
|
|
|
end subroutine exch_corr_h
|
2005-01-15 18:53:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
!=----------------------------------------------------------------------------=!
|
|
|
|
|
2005-09-19 07:49:24 +08:00
|
|
|
subroutine gradh( nspin, gradr, rhog, rhor, dexc )
|
2005-01-15 18:53:46 +08:00
|
|
|
! _________________________________________________________________
|
|
|
|
!
|
|
|
|
! calculate the second part of gradient corrected xc potential
|
|
|
|
! plus the gradient-correction contribution to pressure
|
|
|
|
!
|
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
|
|
|
USE kinds, ONLY: DP
|
2005-01-15 18:53:46 +08:00
|
|
|
use control_flags, only: iprint, tpre
|
|
|
|
use reciprocal_vectors, only: gx
|
|
|
|
use recvecs_indexes, only: np, nm
|
|
|
|
use gvecp, only: ng => ngm
|
|
|
|
use grid_dimensions, only: nr1, nr2, nr3, nnr => nnrx, nr1x, nr2x, nr3x
|
|
|
|
use cell_base, only: ainv, tpiba, omega
|
|
|
|
use derho, only: drhog
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
! input
|
|
|
|
integer nspin
|
2005-09-19 07:49:24 +08:00
|
|
|
real(DP) :: gradr( nnr, 3, nspin ), rhor( nnr, nspin ), dexc( 3, 3 )
|
|
|
|
complex(DP) :: rhog( ng, nspin )
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
2005-09-19 07:49:24 +08:00
|
|
|
complex(DP), allocatable:: v(:)
|
|
|
|
complex(DP), allocatable:: x(:), vtemp(:)
|
|
|
|
complex(DP) :: ci, fp, fm
|
|
|
|
integer :: iss, ig, ir, i,j
|
2005-01-15 18:53:46 +08:00
|
|
|
!
|
|
|
|
allocate(v(nnr))
|
|
|
|
allocate(x(ng))
|
|
|
|
allocate(vtemp(ng))
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
ci=(0.0,1.0)
|
2005-09-19 07:49:24 +08:00
|
|
|
!
|
|
|
|
dexc = 0.0d0
|
|
|
|
!
|
2005-01-15 18:53:46 +08:00
|
|
|
do iss=1, nspin
|
|
|
|
! _________________________________________________________________
|
|
|
|
! second part xc-potential: 3 forward ffts
|
|
|
|
!
|
|
|
|
do ir=1,nnr
|
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
|
|
|
v(ir)=CMPLX(gradr(ir,1,iss),0.d0)
|
2005-01-15 18:53:46 +08:00
|
|
|
end do
|
|
|
|
call fwfft(v,nr1,nr2,nr3,nr1x,nr2x,nr3x)
|
|
|
|
do ig=1,ng
|
|
|
|
x(ig)=ci*tpiba*gx(1,ig)*v(np(ig))
|
|
|
|
end do
|
|
|
|
!
|
|
|
|
if(tpre) then
|
|
|
|
do i=1,3
|
|
|
|
do j=1,3
|
|
|
|
do ig=1,ng
|
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
|
|
|
vtemp(ig) = omega*ci*CONJG(v(np(ig)))* &
|
2005-01-15 18:53:46 +08:00
|
|
|
& tpiba*(-rhog(ig,iss)*gx(i,ig)*ainv(j,1)+ &
|
|
|
|
& gx(1,ig)*drhog(ig,iss,i,j))
|
|
|
|
end do
|
2005-09-19 07:49:24 +08:00
|
|
|
dexc(i,j) = dexc(i,j) + DBLE(SUM(vtemp))*2.0
|
2005-01-15 18:53:46 +08:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
endif
|
|
|
|
!
|
|
|
|
do ir=1,nnr
|
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
|
|
|
v(ir)=CMPLX(gradr(ir,2,iss),gradr(ir,3,iss))
|
2005-01-15 18:53:46 +08:00
|
|
|
end do
|
|
|
|
call fwfft(v,nr1,nr2,nr3,nr1x,nr2x,nr3x)
|
|
|
|
!
|
|
|
|
do ig=1,ng
|
|
|
|
fp=v(np(ig))+v(nm(ig))
|
|
|
|
fm=v(np(ig))-v(nm(ig))
|
|
|
|
x(ig) = x(ig) + &
|
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
|
|
|
& ci*tpiba*gx(2,ig)*0.5*CMPLX( DBLE(fp),AIMAG(fm))
|
2005-01-15 18:53:46 +08:00
|
|
|
x(ig) = x(ig) + &
|
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
|
|
|
& ci*tpiba*gx(3,ig)*0.5*CMPLX(AIMAG(fp),-DBLE(fm))
|
2005-01-15 18:53:46 +08:00
|
|
|
end do
|
|
|
|
!
|
|
|
|
if(tpre) then
|
|
|
|
do i=1,3
|
|
|
|
do j=1,3
|
|
|
|
do ig=1,ng
|
|
|
|
fp=v(np(ig))+v(nm(ig))
|
|
|
|
fm=v(np(ig))-v(nm(ig))
|
|
|
|
vtemp(ig) = omega*ci* &
|
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
|
|
|
& (0.5*CMPLX(DBLE(fp),-AIMAG(fm))* &
|
2005-01-15 18:53:46 +08:00
|
|
|
& tpiba*(-rhog(ig,iss)*gx(i,ig)*ainv(j,2)+ &
|
|
|
|
& gx(2,ig)*drhog(ig,iss,i,j))+ &
|
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
|
|
|
& 0.5*CMPLX(AIMAG(fp),DBLE(fm))*tpiba* &
|
2005-01-15 18:53:46 +08:00
|
|
|
& (-rhog(ig,iss)*gx(i,ig)*ainv(j,3)+ &
|
|
|
|
& gx(3,ig)*drhog(ig,iss,i,j)))
|
|
|
|
end do
|
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
|
|
|
dexc(i,j) = dexc(i,j) + 2.0*DBLE(SUM(vtemp))
|
2005-01-15 18:53:46 +08:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
endif
|
|
|
|
! _________________________________________________________________
|
|
|
|
! second part xc-potential: 1 inverse fft
|
|
|
|
!
|
|
|
|
do ig=1,nnr
|
|
|
|
v(ig)=(0.0,0.0)
|
|
|
|
end do
|
|
|
|
do ig=1,ng
|
|
|
|
v(np(ig))=x(ig)
|
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
|
|
|
v(nm(ig))=CONJG(x(ig))
|
2005-01-15 18:53:46 +08:00
|
|
|
end do
|
|
|
|
call invfft(v,nr1,nr2,nr3,nr1x,nr2x,nr3x)
|
|
|
|
do ir=1,nnr
|
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
|
|
|
rhor(ir,iss)=rhor(ir,iss)-DBLE(v(ir))
|
2005-01-15 18:53:46 +08:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
!
|
|
|
|
deallocate(vtemp)
|
|
|
|
deallocate(x)
|
|
|
|
deallocate(v)
|
|
|
|
!
|
|
|
|
return
|
2005-05-12 23:19:08 +08:00
|
|
|
end subroutine gradh
|
2005-01-15 18:53:46 +08:00
|
|
|
|