2003-01-20 05:58:50 +08:00
|
|
|
!
|
2009-08-02 01:48:59 +08:00
|
|
|
! Copyright (C) 2001-2007 Quantum ESPRESSO group
|
2003-01-20 05:58:50 +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-06-12 21:44:18 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
2003-02-08 00:04:36 +08:00
|
|
|
subroutine force_corr (forcescc)
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
! This routine calculates the force term vanishing at full
|
|
|
|
! self-consistency. It follows the suggestion of Chan-Bohnen-Ho
|
|
|
|
! (PRB 47, 4771 (1993)). The true charge density is approximated
|
|
|
|
! by means of a free atom superposition.
|
|
|
|
! (alessio f.)
|
2003-02-08 00:04:36 +08:00
|
|
|
! Uses superposition of atomic charges contained in the array rho_at
|
2007-10-03 00:54:13 +08:00
|
|
|
! and read from pseudopotential files
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-06-12 21:44:18 +08:00
|
|
|
USE kinds, ONLY : DP
|
|
|
|
USE constants, ONLY : tpi
|
2007-10-24 23:36:52 +08:00
|
|
|
USE atom, ONLY : msh, rgrid
|
|
|
|
USE uspp_param, ONLY : upf
|
2004-06-12 21:44:18 +08:00
|
|
|
USE ions_base, ONLY : nat, ntyp => nsp, ityp, tau
|
|
|
|
USE cell_base, ONLY : tpiba
|
|
|
|
USE gvect, ONLY : ngm, gstart, nr1, nr2, nr3, nrx1, nrx2, &
|
|
|
|
nrx3, nrxx, nl, g, ngl, gl, igtongl
|
|
|
|
USE lsda_mod, ONLY : nspin
|
2007-11-19 04:25:11 +08:00
|
|
|
USE scf, ONLY : vnew
|
2007-11-22 22:23:04 +08:00
|
|
|
USE control_flags, ONLY : gamma_only
|
2004-06-12 21:44:18 +08:00
|
|
|
USE wavefunctions_module, ONLY : psic
|
2008-04-21 05:23:37 +08:00
|
|
|
USE mp_global, ONLY : intra_pool_comm
|
|
|
|
USE mp, ONLY : mp_sum
|
2004-06-12 21:44:18 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
implicit none
|
|
|
|
!
|
2005-08-28 22:09:42 +08:00
|
|
|
real(DP) :: forcescc (3, nat)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2005-08-28 22:09:42 +08:00
|
|
|
real(DP), allocatable :: rhocgnt (:), aux (:)
|
2003-04-04 22:36:00 +08:00
|
|
|
! work space
|
2005-08-28 22:09:42 +08:00
|
|
|
real(DP) :: gx, arg, fact
|
2003-04-04 22:36:00 +08:00
|
|
|
! temp factors
|
2006-12-14 16:53:47 +08:00
|
|
|
integer :: ir, isup, isdw, ig, nt, na, ipol, ndm
|
2003-04-04 22:36:00 +08:00
|
|
|
! counters
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! vnew is V_out - V_in, psic is the temp space
|
|
|
|
!
|
2004-05-10 04:20:00 +08:00
|
|
|
if (nspin == 1 .or. nspin == 4) then
|
2007-11-19 04:25:11 +08:00
|
|
|
psic(:) = vnew%of_r (:, 1)
|
2003-04-04 22:36:00 +08:00
|
|
|
else
|
|
|
|
isup = 1
|
|
|
|
isdw = 2
|
2007-11-19 04:25:11 +08:00
|
|
|
psic(:) = (vnew%of_r (:, isup) + vnew%of_r (:, isdw)) * 0.5d0
|
2003-04-04 22:36:00 +08:00
|
|
|
end if
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-04-24 01:10:44 +08:00
|
|
|
ndm = MAXVAL ( msh(1:ntyp) )
|
2003-01-20 05:58:50 +08:00
|
|
|
allocate ( aux(ndm), rhocgnt(ngl) )
|
|
|
|
|
|
|
|
forcescc(:,:) = 0.d0
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
call cft3 (psic, nr1, nr2, nr3, nrx1, nrx2, nrx3, - 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
if (gamma_only) then
|
|
|
|
fact = 2.d0
|
|
|
|
else
|
|
|
|
fact = 1.d0
|
|
|
|
end if
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
do nt = 1, ntyp
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Here we compute the G.ne.0 term
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do ig = gstart, ngl
|
|
|
|
gx = sqrt (gl (ig) ) * tpiba
|
|
|
|
do ir = 1, msh (nt)
|
2007-08-12 08:08:53 +08:00
|
|
|
if (rgrid(nt)%r(ir) .lt.1.0d-8) then
|
2007-10-24 23:36:52 +08:00
|
|
|
aux (ir) = upf(nt)%rho_at (ir)
|
2003-02-08 00:04:36 +08:00
|
|
|
else
|
2007-10-24 23:36:52 +08:00
|
|
|
aux (ir) = upf(nt)%rho_at (ir) * &
|
|
|
|
sin(gx*rgrid(nt)%r(ir)) / (rgrid(nt)%r(ir)*gx)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
|
|
|
enddo
|
2007-08-12 08:08:53 +08:00
|
|
|
call simpson (msh (nt), aux, rgrid(nt)%rab, rhocgnt (ig) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-04-04 22:36:00 +08:00
|
|
|
do na = 1, nat
|
|
|
|
if (nt.eq.ityp (na) ) then
|
|
|
|
do ig = gstart, ngm
|
2003-01-20 05:58:50 +08:00
|
|
|
arg = (g (1, ig) * tau (1, na) + g (2, ig) * tau (2, na) &
|
|
|
|
+ g (3, ig) * tau (3, na) ) * tpi
|
2003-02-08 00:04:36 +08:00
|
|
|
do ipol = 1, 3
|
2003-01-20 05:58:50 +08:00
|
|
|
forcescc (ipol, na) = forcescc (ipol, na) + fact * &
|
2009-08-02 01:48:59 +08:00
|
|
|
rhocgnt (igtongl(ig) ) * CMPLX(sin(arg),cos(arg),kind=DP) * &
|
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
|
|
|
g(ipol,ig) * tpiba * CONJG(psic(nl(ig)))
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-04-04 22:36:00 +08:00
|
|
|
enddo
|
|
|
|
endif
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2008-04-21 05:23:37 +08:00
|
|
|
call mp_sum( forcescc, intra_pool_comm )
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
|
|
|
deallocate ( aux, rhocgnt )
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine force_corr
|
|
|
|
|