2007-02-08 21:17:38 +08:00
|
|
|
!
|
2009-10-23 19:11:36 +08:00
|
|
|
! Copyright (C) 2001-2009 Quantum ESPRESSO group
|
2007-02-08 21:17:38 +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 .
|
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
2010-09-14 22:07:21 +08:00
|
|
|
subroutine incdrhoscf_nc (drhoscf, weight, ik, dbecsum, dpsi)
|
2007-02-08 21:17:38 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! This routine computes the change of the charge density due to the
|
|
|
|
! perturbation. It is called at the end of the computation of the
|
|
|
|
! change of the wavefunction for a given k point.
|
|
|
|
!
|
|
|
|
!
|
2008-09-24 19:50:31 +08:00
|
|
|
USE kinds, only : DP
|
2007-02-08 21:17:38 +08:00
|
|
|
USE ions_base, ONLY : nat
|
2008-09-24 19:50:31 +08:00
|
|
|
USE cell_base, ONLY : omega
|
|
|
|
USE gvect, ONLY : nrxx
|
2010-08-28 21:48:36 +08:00
|
|
|
USE fft_base, ONLY : dffts
|
|
|
|
USE fft_interfaces, ONLY: invfft
|
2010-10-24 16:05:12 +08:00
|
|
|
USE gsmooth, ONLY : nls
|
2008-09-24 19:50:31 +08:00
|
|
|
USE lsda_mod, ONLY : nspin
|
|
|
|
USE spin_orb, ONLY : domag
|
2009-10-23 19:11:36 +08:00
|
|
|
USE noncollin_module, ONLY : npol, nspin_mag
|
2008-09-24 19:50:31 +08:00
|
|
|
USE uspp_param,ONLY : nhm
|
2010-09-14 22:07:21 +08:00
|
|
|
USE wvfct, ONLY : npw, npwx, igk, nbnd
|
2007-02-08 21:17:38 +08:00
|
|
|
USE wavefunctions_module, ONLY: evc
|
2009-02-04 18:25:03 +08:00
|
|
|
USE qpoint, ONLY : npwq, igkq, ikks
|
|
|
|
USE control_ph, ONLY : nbnd_occ
|
2009-02-04 16:28:27 +08:00
|
|
|
|
2007-02-08 21:17:38 +08:00
|
|
|
implicit none
|
|
|
|
|
2010-09-14 22:07:21 +08:00
|
|
|
! I/O variables
|
|
|
|
INTEGER, INTENT(IN) :: ik
|
2007-02-08 21:17:38 +08:00
|
|
|
! input: the k point
|
2010-09-14 22:07:21 +08:00
|
|
|
REAL(DP), INTENT(IN) :: weight
|
2007-02-08 21:17:38 +08:00
|
|
|
! input: the weight of the k point
|
2010-09-14 22:07:21 +08:00
|
|
|
COMPLEX(DP), INTENT(IN) :: dpsi(npwx*npol,nbnd)
|
|
|
|
! input: the perturbed wfcs at the given k point
|
|
|
|
COMPLEX(DP), INTENT(INOUT) :: drhoscf (nrxx,nspin_mag), dbecsum (nhm,nhm,nat,nspin)
|
|
|
|
! input/output: the accumulated change of the charge density and dbecsum
|
|
|
|
!
|
2007-02-08 21:17:38 +08:00
|
|
|
!
|
|
|
|
! here the local variable
|
|
|
|
!
|
|
|
|
|
|
|
|
real(DP) :: wgt
|
|
|
|
! the effective weight of the k point
|
|
|
|
|
|
|
|
complex(DP), allocatable :: psi (:,:), dpsic (:,:)
|
|
|
|
! the wavefunctions in real space
|
|
|
|
! the change of wavefunctions in real space
|
|
|
|
|
|
|
|
integer :: ibnd, jbnd, ikk, ir, ig
|
|
|
|
! counters
|
|
|
|
|
|
|
|
call start_clock ('incdrhoscf')
|
2010-10-24 16:05:12 +08:00
|
|
|
allocate (dpsic(dffts%nnr, npol))
|
|
|
|
allocate (psi (dffts%nnr, npol))
|
2007-02-08 21:17:38 +08:00
|
|
|
wgt = 2.d0 * weight / omega
|
2009-02-04 18:25:03 +08:00
|
|
|
ikk = ikks(ik)
|
2007-02-08 21:17:38 +08:00
|
|
|
!
|
|
|
|
! dpsi contains the perturbed wavefunctions of this k point
|
|
|
|
! evc contains the unperturbed wavefunctions of this k point
|
|
|
|
!
|
|
|
|
do ibnd = 1, nbnd_occ (ikk)
|
|
|
|
psi = (0.d0, 0.d0)
|
|
|
|
do ig = 1, npw
|
|
|
|
psi (nls (igk (ig) ), 1) = evc (ig, ibnd)
|
|
|
|
psi (nls (igk (ig) ), 2) = evc (ig+npwx, ibnd)
|
|
|
|
enddo
|
2010-08-28 21:48:36 +08:00
|
|
|
CALL invfft ('Wave', psi(:,1), dffts)
|
|
|
|
CALL invfft ('Wave', psi(:,2), dffts)
|
2007-02-08 21:17:38 +08:00
|
|
|
|
|
|
|
dpsic = (0.d0, 0.d0)
|
|
|
|
do ig = 1, npwq
|
|
|
|
dpsic (nls (igkq (ig)), 1 ) = dpsi (ig, ibnd)
|
|
|
|
dpsic (nls (igkq (ig)), 2 ) = dpsi (ig+npwx, ibnd)
|
|
|
|
enddo
|
|
|
|
|
2010-08-28 21:48:36 +08:00
|
|
|
CALL invfft ('Wave', dpsic(:,1), dffts)
|
|
|
|
CALL invfft ('Wave', dpsic(:,2), dffts)
|
2010-10-24 16:05:12 +08:00
|
|
|
do ir = 1, dffts%nnr
|
2007-02-08 21:17:38 +08:00
|
|
|
drhoscf(ir,1)=drhoscf(ir,1)+wgt*(CONJG(psi(ir,1))*dpsic(ir,1) + &
|
2010-08-28 21:48:36 +08:00
|
|
|
CONJG(psi(ir,2))*dpsic(ir,2) )
|
|
|
|
|
2007-02-08 21:17:38 +08:00
|
|
|
enddo
|
|
|
|
IF (domag) THEN
|
2010-10-24 16:05:12 +08:00
|
|
|
do ir = 1, dffts%nnr
|
2007-02-08 21:17:38 +08:00
|
|
|
drhoscf(ir,2)=drhoscf (ir,2) + wgt *(CONJG(psi(ir,1))*dpsic(ir,2)+ &
|
|
|
|
CONJG(psi(ir,2))*dpsic(ir,1) )
|
|
|
|
drhoscf(ir,3)=drhoscf (ir,3) + wgt *(CONJG(psi(ir,1))*dpsic(ir,2)- &
|
|
|
|
CONJG(psi(ir,2))*dpsic(ir,1) ) * (0.d0,-1.d0)
|
|
|
|
drhoscf(ir,4)=drhoscf (ir,4) + wgt *(CONJG(psi(ir,1))*dpsic(ir,1)- &
|
|
|
|
CONJG(psi(ir,2))*dpsic(ir,2) )
|
|
|
|
enddo
|
|
|
|
END IF
|
|
|
|
enddo
|
|
|
|
|
|
|
|
|
2008-08-28 00:45:56 +08:00
|
|
|
call addusdbec_nc (ik, weight, dpsi, dbecsum)
|
2007-02-08 21:17:38 +08:00
|
|
|
deallocate (psi)
|
|
|
|
deallocate (dpsic)
|
|
|
|
|
|
|
|
call stop_clock ('incdrhoscf')
|
|
|
|
return
|
|
|
|
end subroutine incdrhoscf_nc
|