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 newdq (dvscf, npe)
|
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.
|
|
|
|
!
|
|
|
|
#include "machine.h"
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
use pwcom
|
2004-01-23 23:08:03 +08:00
|
|
|
USE kinds, only : DP
|
2003-02-08 00:04:36 +08:00
|
|
|
use phcom
|
|
|
|
implicit none
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! The dummy variables
|
|
|
|
!
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: npe
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the number of perturbations
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
complex(kind=DP) :: dvscf (nrxx, nspin, npe)
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the change of the self
|
2003-01-21 23:25:13 +08:00
|
|
|
! consistent pot.
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! And the local variables
|
|
|
|
!
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: na, ig, nt, ir, ipert, is, ih, jh
|
2003-01-20 05:58:50 +08:00
|
|
|
! counter on atoms
|
|
|
|
! counter on G vectors
|
|
|
|
! counter on atomic types
|
|
|
|
! counter on real mesh
|
|
|
|
! counter on perturbations
|
|
|
|
! counter on spin
|
|
|
|
! counter on beta functions
|
|
|
|
! counter on beta functions
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
real(kind=DP), allocatable :: qmod (:), qg (:,:), ylmk0 (:,:)
|
2003-01-20 05:58:50 +08:00
|
|
|
! the modulus of q+G
|
|
|
|
! the values of q+G
|
|
|
|
! the spherical harmonics
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
complex(kind=DP) :: ZDOTC
|
2003-01-20 05:58:50 +08:00
|
|
|
! the scalar product function
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
complex(kind=DP), allocatable :: aux1 (:), aux2 (:,:), veff (:)
|
2003-01-20 05:58:50 +08:00
|
|
|
! space for several quantities
|
|
|
|
! space for veff
|
|
|
|
! a mesh space for the FFT of the V_eff
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
if (.not.okvan) return
|
|
|
|
call setv (2 * nhm * nhm * 3 * nat * nspin, 0.0d0, int3, 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
call start_clock ('newdq')
|
|
|
|
allocate (aux1 ( ngm))
|
|
|
|
allocate (aux2 ( ngm , nspin))
|
|
|
|
allocate (veff ( nrxx))
|
|
|
|
allocate (ylmk0 ( ngm , lqx * lqx))
|
|
|
|
allocate (qmod ( ngm))
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
if (.not.lgamma) allocate (qg (3, ngm))
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! first compute the spherical harmonics
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
if (.not.lgamma) then
|
|
|
|
call setqmod (ngm, xq, g, qmod, qg)
|
|
|
|
call ylmr2 (lqx * lqx, ngm, qg, qmod, ylmk0)
|
|
|
|
do ig = 1, ngm
|
|
|
|
qmod (ig) = sqrt (qmod (ig) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
else
|
|
|
|
call ylmr2 (lqx * lqx, ngm, g, gg, ylmk0)
|
|
|
|
do ig = 1, ngm
|
|
|
|
qmod (ig) = sqrt (gg (ig) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
!
|
|
|
|
! and for each perturbation of this irreducible representation
|
|
|
|
! integrate the change of the self consistent potential and
|
|
|
|
! the Q functions
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do ipert = 1, npe
|
2003-04-29 19:20:28 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
do is = 1, nspin
|
|
|
|
do ir = 1, nrxx
|
|
|
|
veff (ir) = dvscf (ir, is, ipert)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
call cft3 (veff, nr1, nr2, nr3, nrx1, nrx2, nrx3, - 1)
|
|
|
|
do ig = 1, ngm
|
|
|
|
aux2 (ig, is) = veff (nl (ig) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
2003-04-29 19:20:28 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
do nt = 1, ntyp
|
|
|
|
if (tvanp (nt) ) then
|
|
|
|
do ih = 1, nh (nt)
|
|
|
|
do jh = ih, nh (nt)
|
|
|
|
call qvan2 (ngm, ih, jh, nt, qmod, qgm, ylmk0)
|
|
|
|
do na = 1, nat
|
|
|
|
if (ityp (na) .eq.nt) then
|
|
|
|
do ig = 1, ngm
|
2003-04-29 19:20:28 +08:00
|
|
|
aux1(ig) = qgm(ig) * eigts1(ig1(ig),na) * &
|
|
|
|
eigts2(ig2(ig),na) * &
|
|
|
|
eigts3(ig3(ig),na) * &
|
|
|
|
eigqts(na)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
do is = 1, nspin
|
2003-04-29 19:20:28 +08:00
|
|
|
int3(ih,jh,ipert,na,is) = omega * &
|
|
|
|
ZDOTC(ngm,aux1,1,aux2(1,is),1)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
do na = 1, nat
|
2003-04-29 19:20:28 +08:00
|
|
|
if (ityp(na) .eq.nt) then
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! We use the symmetry properties of the ps factor
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do ih = 1, nh (nt)
|
|
|
|
do jh = ih, nh (nt)
|
|
|
|
do is = 1, nspin
|
2003-04-29 19:20:28 +08:00
|
|
|
int3(jh,ih,ipert,na,is) = int3(ih,jh,ipert,na,is)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
enddo
|
2003-04-29 19:20:28 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2003-02-08 00:04:36 +08:00
|
|
|
call reduce (2 * nhm * nhm * 3 * nat * nspin, int3)
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
2003-02-08 00:04:36 +08:00
|
|
|
if (.not.lgamma) deallocate (qg)
|
|
|
|
deallocate (qmod)
|
|
|
|
deallocate (ylmk0)
|
|
|
|
deallocate (veff)
|
|
|
|
deallocate (aux2)
|
|
|
|
deallocate (aux1)
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
call stop_clock ('newdq')
|
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine newdq
|