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 adddvscf (ipert, ik)
|
2003-01-20 05:58:50 +08:00
|
|
|
!----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! This routine computes the contribution of the selfconsistent
|
|
|
|
! change of the potential to the known part of the linear
|
|
|
|
! system and adds it to dvpsi.
|
|
|
|
!
|
2004-06-26 01:25:37 +08:00
|
|
|
#include "f_defs.h"
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2004-06-01 00:19:23 +08:00
|
|
|
USE kinds, ONLY : DP
|
2004-06-01 01:55:33 +08:00
|
|
|
USE uspp_param, ONLY : nh, tvanp
|
2005-03-28 21:55:19 +08:00
|
|
|
USE uspp, ONLY : vkb, okvan
|
2004-06-01 00:19:23 +08:00
|
|
|
! modules from pwcom
|
|
|
|
USE lsda_mod, ONLY : lsda, current_spin, isk
|
2004-06-12 21:44:18 +08:00
|
|
|
USE ions_base, ONLY : ntyp => nsp, nat, ityp
|
2004-06-01 00:19:23 +08:00
|
|
|
USE wvfct, ONLY : nbnd
|
|
|
|
! modules from phcom
|
|
|
|
USE control_ph, ONLY : lgamma
|
|
|
|
USE qpoint, ONLY : npwq
|
|
|
|
USE phus, ONLY : int3, becp1
|
|
|
|
USE eqv, ONLY : dvpsi
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! The dummy variables
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: ik, ipert
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the k point
|
|
|
|
! input: the perturbation
|
|
|
|
!
|
|
|
|
! And the local variables
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: na, nt, ibnd, ih, jh, ijkb0, ikk, ikb, jkb
|
2003-01-20 05:58:50 +08:00
|
|
|
! counter on atoms
|
|
|
|
! counter on atomic types
|
|
|
|
! counter on bands
|
|
|
|
! counter on beta functions
|
|
|
|
! counter on beta functions
|
|
|
|
! auxiliary variable for indexing
|
|
|
|
! counter on the k points
|
|
|
|
! counter on vkb
|
|
|
|
! counter on vkb
|
2005-08-28 22:09:42 +08:00
|
|
|
complex(DP) :: sum
|
2003-01-20 05:58:50 +08:00
|
|
|
! auxiliary variable
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
if (.not.okvan) return
|
|
|
|
call start_clock ('adddvscf')
|
|
|
|
if (lgamma) then
|
|
|
|
ikk = ik
|
|
|
|
else
|
|
|
|
ikk = 2 * ik - 1
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
if (lsda) current_spin = isk (ikk)
|
|
|
|
ijkb0 = 0
|
|
|
|
do nt = 1, ntyp
|
|
|
|
if (tvanp (nt) ) then
|
|
|
|
do na = 1, nat
|
|
|
|
if (ityp (na) .eq.nt) then
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! we multiply the integral for the becp term and the beta_n
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do ibnd = 1, nbnd
|
|
|
|
do ih = 1, nh (nt)
|
|
|
|
ikb = ijkb0 + ih
|
|
|
|
sum = (0.d0, 0.d0)
|
|
|
|
do jh = 1, nh (nt)
|
|
|
|
jkb = ijkb0 + jh
|
2003-01-20 05:58:50 +08:00
|
|
|
sum = sum + int3 (ih, jh, ipert, na, current_spin) * &
|
|
|
|
becp1 (jkb, ibnd, ik)
|
|
|
|
enddo
|
|
|
|
! sum=sum*eigqts(na)
|
|
|
|
call ZAXPY (npwq, sum, vkb (1, ikb), 1, dvpsi (1, ibnd),1)
|
|
|
|
enddo
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
ijkb0 = ijkb0 + nh (nt)
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
else
|
|
|
|
do na = 1, nat
|
|
|
|
if (ityp (na) .eq.nt) ijkb0 = ijkb0 + nh (nt)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
call stop_clock ('adddvscf')
|
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine adddvscf
|