2003-01-20 05:58:50 +08:00
|
|
|
!
|
2009-08-03 17:19:02 +08:00
|
|
|
! Copyright (C) 2001-2008 Quantum ESPRESSO group
|
2003-01-20 05:58:50 +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 .
|
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
subroutine drhodvus (irr, imode0, dvscfin, npe)
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! This subroutine calculates the term of the dynamical matrix
|
2010-08-28 21:48:36 +08:00
|
|
|
! which comes from the interaction of the change of the self
|
2009-11-12 01:23:54 +08:00
|
|
|
! consistent potential with the change of the charge density
|
|
|
|
! at fixed wavefunctions.
|
|
|
|
! See Eq.B36 of PRB 64, 235118 (2001).
|
|
|
|
! In the PAW case this part of the dynamical matrix has an additional
|
2010-08-28 21:48:36 +08:00
|
|
|
! contribution.
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-06-12 21:44:18 +08:00
|
|
|
!
|
2008-09-24 19:50:31 +08:00
|
|
|
USE kinds, ONLY : DP
|
2008-12-03 01:47:55 +08:00
|
|
|
USE ions_base, ONLY : nat, ntyp=>nsp, ityp
|
2008-09-24 19:50:31 +08:00
|
|
|
USE cell_base, ONLY : omega
|
2004-06-12 21:44:18 +08:00
|
|
|
USE ions_base, ONLY : nat
|
2010-12-31 21:18:20 +08:00
|
|
|
USE fft_base, ONLY : dfftp
|
2008-09-24 19:50:31 +08:00
|
|
|
USE uspp, ONLY : okvan
|
2007-02-08 21:07:07 +08:00
|
|
|
USE io_global, ONLY : stdout
|
2013-04-19 21:41:37 +08:00
|
|
|
USE buffers, ONLY : get_buffer
|
2008-12-03 01:47:55 +08:00
|
|
|
USE uspp_param, ONLY : upf, nh
|
|
|
|
USE paw_variables, ONLY : okpaw
|
2009-02-05 01:18:31 +08:00
|
|
|
USE noncollin_module, ONLY : nspin_mag
|
2009-02-04 16:28:27 +08:00
|
|
|
|
2009-10-23 19:11:36 +08:00
|
|
|
USE modes, ONLY : npert, nirr, u
|
2009-02-04 16:28:27 +08:00
|
|
|
USE dynmat, ONLY : dyn, dyn_rec
|
2016-01-21 08:57:35 +08:00
|
|
|
USE phus, ONLY : becsumort
|
2009-02-04 16:28:27 +08:00
|
|
|
USE units_ph, ONLY : iudrhous, lrdrhous
|
|
|
|
|
2014-01-07 23:46:06 +08:00
|
|
|
USE mp_pools, ONLY : inter_pool_comm
|
|
|
|
USE mp_bands, ONLY : intra_bgrp_comm
|
2008-01-25 07:43:05 +08:00
|
|
|
USE mp, ONLY : mp_sum
|
2016-01-21 08:57:35 +08:00
|
|
|
|
|
|
|
USE lrus, ONLY : int3_paw
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: irr, imode0, npe
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the irreducible representation
|
|
|
|
! input: starting position of this represe
|
|
|
|
! input: the number of perturbations
|
|
|
|
|
2010-12-31 21:18:20 +08:00
|
|
|
complex(DP) :: dvscfin (dfftp%nnr, nspin_mag, npe)
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the change of V_Hxc
|
|
|
|
|
2009-02-05 01:18:31 +08:00
|
|
|
integer :: ipert, irr1, mode0, mu, is, nu_i, nu_j, nrtot, &
|
2009-11-12 01:23:54 +08:00
|
|
|
ih, jh, ijh, na, nt
|
2004-03-07 21:47:42 +08:00
|
|
|
! counters
|
|
|
|
! mode0: starting position of the represention
|
|
|
|
! nrtot: the total number of mesh points
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
complex(DP) :: dyn1 (3 * nat, 3 * nat)
|
2003-01-20 05:58:50 +08:00
|
|
|
! the dynamical matrix
|
2009-10-23 19:11:36 +08:00
|
|
|
complex(DP), allocatable :: drhous (:,:)
|
2003-01-20 05:58:50 +08:00
|
|
|
! the change of the charge
|
2009-08-03 17:19:02 +08:00
|
|
|
complex(DP), external :: zdotc
|
2003-02-08 00:04:36 +08:00
|
|
|
|
2008-07-23 16:46:48 +08:00
|
|
|
if (.not.okvan) then
|
2010-08-28 21:48:36 +08:00
|
|
|
dyn_rec=(0.0_DP,0.0_DP)
|
2008-07-23 16:46:48 +08:00
|
|
|
return
|
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
call start_clock ('drhodvus')
|
2010-12-31 21:18:20 +08:00
|
|
|
allocate (drhous ( dfftp%nnr, nspin_mag))
|
2004-03-07 21:47:42 +08:00
|
|
|
dyn1 (:,:) = (0.d0, 0.d0)
|
2011-07-15 06:14:15 +08:00
|
|
|
nrtot = dfftp%nr1 * dfftp%nr2 * dfftp%nr3
|
2003-02-08 00:04:36 +08:00
|
|
|
mode0 = 0
|
|
|
|
do irr1 = 1, nirr
|
|
|
|
do ipert = 1, npert (irr1)
|
|
|
|
nu_j = mode0 + ipert
|
2013-04-19 21:41:37 +08:00
|
|
|
call get_buffer (drhous, lrdrhous, iudrhous, nu_j)
|
2003-02-08 00:04:36 +08:00
|
|
|
do mu = 1, npert (irr)
|
|
|
|
nu_i = imode0 + mu
|
2009-10-23 19:11:36 +08:00
|
|
|
dyn1 (nu_i, nu_j) = dyn1 (nu_i, nu_j) + &
|
2010-12-31 21:18:20 +08:00
|
|
|
zdotc (dfftp%nnr*nspin_mag,dvscfin(1,1,mu),1,drhous, 1) &
|
General cleanup of intrinsic functions:
conversion to real => DBLE
(including real part of a complex number)
conversion to complex => CMPLX
complex conjugate => CONJG
imaginary part => AIMAG
All functions are uppercase.
CMPLX is preprocessed by f_defs.h and performs an explicit cast:
#define CMPLX(a,b) cmplx(a,b,kind=DP)
This implies that 1) f_defs.h must be included whenever a CMPLX is present,
2) CMPLX should stay in a single line, 3) DP must be defined.
All occurrences of real, float, dreal, dfloat, dconjg, dimag, dcmplx
removed - please do not reintroduce any of them.
Tested only with ifc7 and g95 - beware unintended side effects
Maybe not the best solution (explicit casts everywhere would be better)
but it can be easily changed with a script if the need arises.
The following code might be used to test for possible trouble:
program test_intrinsic
implicit none
integer, parameter :: dp = selected_real_kind(14,200)
real (kind=dp) :: a = 0.123456789012345_dp
real (kind=dp) :: b = 0.987654321098765_dp
complex (kind=dp) :: c = ( 0.123456789012345_dp, 0.987654321098765_dp)
print *, ' A = ', a
print *, ' DBLE(A)= ', DBLE(a)
print *, ' C = ', c
print *, 'CONJG(C)= ', CONJG(c)
print *, 'DBLE(c),AIMAG(C) = ', DBLE(c), AIMAG(c)
print *, 'CMPLX(A,B,kind=dp)= ', CMPLX( a, b, kind=dp)
end program test_intrinsic
Note that CMPLX and REAL without a cast yield single precision numbers on
ifc7 and g95 !!!
git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@2133 c92efa57-630b-4861-b058-cf58834340f0
2005-08-27 01:44:42 +08:00
|
|
|
* omega / DBLE (nrtot)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
mode0 = mode0 + npert (irr1)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
deallocate (drhous)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! collect contributions from all pools (sum over k-points)
|
|
|
|
!
|
2008-01-25 07:43:05 +08:00
|
|
|
call mp_sum ( dyn1, inter_pool_comm )
|
2013-01-19 00:06:49 +08:00
|
|
|
call mp_sum ( dyn1, intra_bgrp_comm )
|
2008-12-03 01:47:55 +08:00
|
|
|
!
|
2010-08-28 21:48:36 +08:00
|
|
|
! PAW contribution: this part of the dynamical matrix is present only
|
2008-12-03 01:47:55 +08:00
|
|
|
! with PAW. PAW and US dynamical matrices differ only at this point.
|
|
|
|
!
|
|
|
|
IF (okpaw) THEN
|
|
|
|
mode0 = 0
|
|
|
|
do irr1 = 1, nirr
|
|
|
|
do ipert = 1, npert (irr1)
|
|
|
|
nu_j = mode0 + ipert
|
|
|
|
do mu = 1, npert (irr)
|
|
|
|
nu_i = imode0 + mu
|
|
|
|
do nt=1,ntyp
|
|
|
|
if (upf(nt)%tpawp) then
|
|
|
|
ijh=0
|
|
|
|
do ih=1,nh(nt)
|
|
|
|
do jh=ih,nh(nt)
|
|
|
|
ijh=ijh+1
|
|
|
|
do na=1,nat
|
|
|
|
if (ityp(na)==nt) then
|
2009-02-05 01:18:31 +08:00
|
|
|
do is = 1, nspin_mag
|
2008-12-03 01:47:55 +08:00
|
|
|
dyn1(nu_i,nu_j)=dyn1(nu_i,nu_j)+ &
|
2016-01-21 07:42:39 +08:00
|
|
|
CONJG(int3_paw(ih,jh,na,is,mu))* &
|
2008-12-03 01:47:55 +08:00
|
|
|
becsumort(ijh,na,is,nu_j)
|
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
mode0 = mode0 + npert (irr1)
|
|
|
|
enddo
|
|
|
|
endif
|
2003-11-06 03:01:20 +08:00
|
|
|
! WRITE( stdout,*) 'drhodvus dyn1, dyn'
|
2003-01-20 05:58:50 +08:00
|
|
|
! call tra_write_matrix('drhodvus dyn1',dyn1,u,nat)
|
|
|
|
! call tra_write_matrix('drhodvus dyn',dyn,u,nat)
|
|
|
|
! call stop_ph(.true.)
|
2004-03-07 21:47:42 +08:00
|
|
|
dyn (:,:) = dyn (:,:) + dyn1 (:,:)
|
2008-07-23 16:46:48 +08:00
|
|
|
dyn_rec(:,:) = dyn1(:,:)
|
2003-02-08 00:04:36 +08:00
|
|
|
call stop_clock ('drhodvus')
|
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
end subroutine drhodvus
|