2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Copyright (C) 2002 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-10 16:58:33 +08:00
|
|
|
subroutine dndepsilon ( dns,ldim,ipol,jpol )
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
! This routine computes the derivative of the ns atomic occupations with
|
|
|
|
! respect to the strain epsilon(ipol,jpol) used to obtain the hubbard
|
|
|
|
! contribution to the internal stres tensor.
|
|
|
|
!
|
|
|
|
#include "machine.h"
|
|
|
|
use pwcom
|
|
|
|
use becmod
|
2003-02-08 00:04:36 +08:00
|
|
|
use io
|
2003-01-20 05:58:50 +08:00
|
|
|
#ifdef PARA
|
|
|
|
use para
|
|
|
|
#endif
|
|
|
|
implicit none
|
2003-02-08 00:04:36 +08:00
|
|
|
!
|
2003-01-20 05:58:50 +08:00
|
|
|
! I/O variables first
|
|
|
|
!
|
2003-02-10 16:58:33 +08:00
|
|
|
integer :: ipol, jpol, ldim
|
|
|
|
real (kind=DP) :: dns(nat,nspin,ldim,ldim)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! local variable
|
|
|
|
!
|
|
|
|
integer :: ik, & ! counter on k points
|
|
|
|
ibnd, & ! " " bands
|
|
|
|
is, & ! " " spins
|
|
|
|
i, na, nt, n, counter, m1, m2, l
|
|
|
|
complex (kind=DP) :: ZDOTC
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer, allocatable :: offset(:)
|
2003-01-20 05:58:50 +08:00
|
|
|
! offset(nat) ! offset of d electrons of atom d in the natomwfc ordering
|
|
|
|
complex (kind=DP), allocatable :: &
|
|
|
|
proj(:,:), wfcatom(:,:), spsi(:,:), dproj(:,:)
|
2003-02-08 00:04:36 +08:00
|
|
|
! proj(natomwfc,nbnd), wfcatom(npwx,natomwfc),
|
2003-01-20 05:58:50 +08:00
|
|
|
! spsi(npwx,nbnd), dproj(natomwfc,nbnd)
|
|
|
|
|
|
|
|
allocate (offset(nat), proj(natomwfc,nbnd), wfcatom(npwx,natomwfc), &
|
|
|
|
spsi(npwx,nbnd), dproj(natomwfc,nbnd) )
|
|
|
|
|
|
|
|
|
|
|
|
!
|
|
|
|
! D_Sl for l=1 and l=2 are already initialized, for l=0 D_S0 is 1
|
|
|
|
!
|
|
|
|
counter = 0
|
|
|
|
do na=1,nat
|
|
|
|
offset(na) = 0
|
|
|
|
nt=ityp(na)
|
|
|
|
do n=1,nchi(nt)
|
|
|
|
if (oc(n,nt).gt.0.d0.or..not.newpseudo(nt)) then
|
|
|
|
l=lchi(n,nt)
|
2003-02-10 16:58:33 +08:00
|
|
|
if (l.eq.Hubbard_l(nt)) offset(na) = counter
|
2003-01-20 05:58:50 +08:00
|
|
|
counter = counter + 2 * l + 1
|
|
|
|
end if
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
if(counter.ne.natomwfc) call error('new_ns','nstart<>counter',1)
|
2003-02-08 00:04:36 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
dns(:,:,:,:) = 0.d0
|
|
|
|
!
|
|
|
|
! we start a loop on k points
|
|
|
|
!
|
|
|
|
if (nks.gt.1) rewind (iunigk)
|
2003-02-08 00:04:36 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
do ik = 1, nks
|
|
|
|
|
|
|
|
if (nks.gt.1) read (iunigk) npw, igk
|
|
|
|
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
! now we need the first derivative of proj with respect to
|
2003-01-20 05:58:50 +08:00
|
|
|
! epsilon(ipol,jpol)
|
|
|
|
!
|
|
|
|
call davcio(evc,nwordwfc,iunwfc,ik,-1)
|
|
|
|
call init_us_2 (npw,igk,xk(1,ik),vkb)
|
|
|
|
call ccalbec(nkb, npwx, npw, nbnd, becp, vkb, evc)
|
2003-02-08 00:04:36 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
call s_psi (npwx, npw, nbnd, evc, spsi )
|
|
|
|
call atomic_wfc( ik, wfcatom )
|
|
|
|
|
|
|
|
dproj(:,:) = (0.d0,0.d0)
|
2003-02-08 00:04:36 +08:00
|
|
|
|
|
|
|
call dprojdepsilon(ik,dproj,wfcatom,spsi,ipol,jpol)
|
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
call davcio(swfcatom,nwordatwfc,iunat,ik,-1)
|
2003-02-08 00:04:36 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
do ibnd = 1, nbnd
|
|
|
|
do i=1,natomwfc
|
|
|
|
proj(i,ibnd) = ZDOTC(npw,swfcatom(1,i),1,evc(1,ibnd),1)
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
|
|
|
#ifdef PARA
|
|
|
|
call reduce(2*natomwfc*nbnd,proj)
|
|
|
|
#endif
|
|
|
|
!
|
|
|
|
! compute the derivative of the occupation numbers (quantities dn(m1,m2))
|
|
|
|
! of the atomic orbitals. They are real quantities as well as n(m1,m2)
|
|
|
|
!
|
|
|
|
do na = 1,nat
|
|
|
|
nt = ityp(na)
|
2003-02-10 16:58:33 +08:00
|
|
|
if (Hubbard_U(nt).ne.0.d0.or.Hubbard_alpha(nt).ne.0.d0) then
|
|
|
|
do m1 = 1, 2 * Hubbard_l(nt) + 1
|
|
|
|
do m2 = m1, 2 * Hubbard_l(nt) + 1
|
2003-01-20 05:58:50 +08:00
|
|
|
do ibnd = 1,nbnd
|
|
|
|
dns(na,isk(ik),m1,m2) = dns(na,isk(ik),m1,m2) + &
|
|
|
|
wg(ibnd,ik) * &
|
|
|
|
DREAL( proj(offset(na)+m1,ibnd) * &
|
|
|
|
conjg(dproj(offset(na)+m2,ibnd) ) + &
|
|
|
|
dproj(offset(na)+m1,ibnd)* &
|
2003-02-08 00:04:36 +08:00
|
|
|
conjg( proj(offset(na)+m2,ibnd) ) )
|
2003-01-20 05:58:50 +08:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end if
|
|
|
|
end do
|
2003-02-08 00:04:36 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
end do ! on k-points
|
2003-02-08 00:04:36 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
#ifdef PARA
|
2003-02-10 16:58:33 +08:00
|
|
|
call poolreduce(nat*nspin*ldim*ldim,dns)
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
|
|
|
!
|
|
|
|
! impose hermeticity of dn_{m1,m2}
|
|
|
|
!
|
|
|
|
do na = 1,nat
|
2003-02-10 16:58:33 +08:00
|
|
|
nt = ityp(na)
|
2003-01-20 05:58:50 +08:00
|
|
|
do is = 1,nspin
|
2003-02-10 16:58:33 +08:00
|
|
|
do m1 = 1, 2 * Hubbard_l(nt) + 1
|
|
|
|
do m2 = m1+1, 2 * Hubbard_l(nt) + 1
|
2003-01-20 05:58:50 +08:00
|
|
|
dns(na,is,m2,m1) = dns(na,is,m1,m2)
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
2003-02-08 00:04:36 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
deallocate (offset, proj, wfcatom, spsi, dproj )
|
2003-02-08 00:04:36 +08:00
|
|
|
|
2003-01-20 05:58:50 +08:00
|
|
|
return
|
|
|
|
end subroutine dndepsilon
|