! ! Copyright (C) 2003 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 . ! ! !----------------------------------------------------------------------- SUBROUTINE A_h(e,h,ah) !----------------------------------------------------------------------- USE kinds, ONLY: DP USE cell_base,ONLY : alat, omega, tpiba2 USE uspp, ONLY : vkb, nkb USE lsda_mod, ONLY : current_spin, nspin USE wvfct, ONLY: nbnd, npwx, npw, g2kin USE wavefunctions_module, ONLY: evc, psic USE scf, ONLY : vrs, rho USE fft_base, ONLY : dffts, dfftp USE fft_interfaces, ONLY : fwfft, invfft USE gvect, ONLY : gstart, nl, nlm, ngm, g, gg USE constants, ONLY: degspin, e2, fpi USE becmod, ONLY: bec_type, becp, calbec USE cgcom USE funct, ONLY: dft_is_gradient ! IMPLICIT NONE INTEGER :: j, jkb, ibnd, na,nt,ih real(DP) :: e(nbnd) COMPLEX(DP) :: h(npwx,nbnd), ah(npwx,nbnd) ! COMPLEX(DP) :: fp, fm COMPLEX(DP), POINTER :: dpsic(:), drhoc(:), dvxc(:) real(DP), POINTER :: dv(:), drho(:) ! CALL start_clock('a_h') ! drho => auxr dpsic => aux2 drhoc => aux3 ! drho(:) = 0.d0 ! ! [(k+G)^2 - e ]psi DO ibnd = 1,nbnd ! set to zero the imaginary part of h at G=0 ! needed for numerical stability IF (gstart==2) h(1,ibnd) = cmplx( dble(h(1,ibnd)),0.d0,kind=DP) DO j = 1,npw ah(j,ibnd) = (g2kin(j)-e(ibnd)) * h(j,ibnd) ENDDO ENDDO ! V_Loc psi DO ibnd = 1,nbnd, 2 dpsic(:)= (0.d0, 0.d0) psic(:) = (0.d0, 0.d0) IF (ibnd 0) CALL add_vuspsi (npwx, npw, nbnd, ah) ! DO j = 1,dfftp%nnr drhoc(j) = cmplx(drho(j),0.d0,kind=DP) ENDDO CALL fwfft ('Dense', drhoc, dfftp) ! ! drho is deltarho(r), drhoc is deltarho(g) ! ! mu'(n(r)) psi(r) delta psi(r) ! dvxc => aux2 DO j = 1,dfftp%nnr dvxc(j) = drho(j)*dmuxc(j) ENDDO ! ! add gradient correction contribution (if any) ! CALL start_clock('dgradcorr') IF (dft_is_gradient() ) CALL dgradcor1 & (rho%of_r, grho, dvxc_rr, dvxc_sr, dvxc_ss, dvxc_s, & drho, drhoc, dfftp%nnr, nspin, nl, nlm, ngm, g, alat, omega, dvxc) CALL stop_clock('dgradcorr') NULLIFY (drho) ! ! 1/|r-r'| * psi(r') delta psi(r') ! ! gstart is the first nonzero G vector (needed for parallel execution) ! IF (gstart==2) drhoc(nl(1)) = 0.d0 ! DO j = gstart,ngm drhoc(nl (j)) = e2*fpi*drhoc(nl(j))/ (tpiba2*gg(j)) drhoc(nlm(j)) = conjg(drhoc(nl (j))) ENDDO CALL invfft ('Dense', drhoc, dfftp) ! ! drhoc now contains deltaV_hartree ! dv => auxr DO j = 1,dfftp%nnr dv(j) = - dble(dvxc(j)) - dble(drhoc(j)) ENDDO ! CALL vloc_psi_gamma(npwx, npw, nbnd, evc, dv, ah) ! ! set to zero the imaginary part of ah at G=0 ! needed for numerical stability IF (gstart==2) THEN DO ibnd = 1, nbnd ah(1,ibnd) = cmplx( dble(ah(1,ibnd)),0.d0,kind=DP) ENDDO ENDIF ! CALL stop_clock('a_h') ! RETURN END SUBROUTINE A_h