2003-01-20 05:58:50 +08:00
|
|
|
!
|
2003-04-08 15:13:30 +08:00
|
|
|
! Copyright (C) 2001-2003 PWSCF 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 zstar_eu
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
! calculate the effective charges Z(E,Us) (E=scf,Us=bare)
|
|
|
|
!
|
|
|
|
! epsil =.true. is needed for this calculation to be meaningful
|
|
|
|
!
|
2004-06-26 01:25:37 +08:00
|
|
|
#include "f_defs.h"
|
2004-06-12 21:44:18 +08:00
|
|
|
!
|
|
|
|
USE ions_base, ONLY : nat, zv, ityp
|
2003-11-06 03:01:20 +08:00
|
|
|
USE io_global, ONLY : stdout
|
2003-11-10 02:30:08 +08:00
|
|
|
USE io_files, ONLY: iunigk
|
2003-02-08 00:04:36 +08:00
|
|
|
use pwcom
|
2003-11-09 18:42:50 +08:00
|
|
|
USE wavefunctions_module, ONLY: evc
|
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
|
|
|
|
|
|
|
integer :: ibnd, ipol, jpol, icart, na, nu, mu, imode0, irr, &
|
|
|
|
imode, nrec, mode, ik
|
2004-03-07 21:47:42 +08:00
|
|
|
! counters
|
2005-08-28 22:09:42 +08:00
|
|
|
real(DP) :: work (3, 3, nat), weight
|
2003-01-20 05:58:50 +08:00
|
|
|
! auxiliary space
|
2005-08-28 22:09:42 +08:00
|
|
|
complex(DP), external :: ZDOTC
|
2003-01-20 05:58:50 +08:00
|
|
|
! scalar product
|
2004-03-07 21:47:42 +08:00
|
|
|
!
|
2003-10-24 23:57:43 +08:00
|
|
|
call start_clock ('zstar_eu')
|
|
|
|
|
2004-03-07 21:47:42 +08:00
|
|
|
zstareu0(:,:) = (0.d0,0.d0)
|
|
|
|
zstareu (:,:,:) = 0.d0
|
2003-01-21 23:25:13 +08:00
|
|
|
|
2004-03-07 21:47:42 +08:00
|
|
|
if (nksq > 1) rewind (iunigk)
|
2003-02-08 00:04:36 +08:00
|
|
|
do ik = 1, nksq
|
2004-03-07 21:47:42 +08:00
|
|
|
if (nksq > 1) read (iunigk) npw, igk
|
2003-02-08 00:04:36 +08:00
|
|
|
npwq = npw
|
|
|
|
weight = wk (ik)
|
2004-03-07 21:47:42 +08:00
|
|
|
if (nksq > 1) call davcio (evc, lrwfc, iuwfc, ik, - 1)
|
2003-02-08 00:04:36 +08:00
|
|
|
call init_us_2 (npw, igk, xk (1, ik), vkb)
|
|
|
|
imode0 = 0
|
|
|
|
do irr = 1, nirr
|
|
|
|
do imode = 1, npert (irr)
|
|
|
|
mode = imode+imode0
|
2003-04-08 15:13:30 +08:00
|
|
|
dvpsi(:,:) = (0.d0, 0.d0)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! recalculate DeltaV*psi(ion) for mode nu
|
|
|
|
!
|
2003-10-16 22:39:25 +08:00
|
|
|
call dvqpsi_us (ik, mode, u (1, mode), .not.okvan)
|
2003-02-08 00:04:36 +08:00
|
|
|
do jpol = 1, 3
|
|
|
|
nrec = (jpol - 1) * nksq + ik
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! read DeltaV*psi(scf) for electric field in jpol direction
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
call davcio (dpsi, lrdwf, iudwf, nrec, - 1)
|
|
|
|
do ibnd = 1, nbnd
|
2003-01-21 23:25:13 +08:00
|
|
|
zstareu0(jpol,mode)=zstareu0(jpol, mode)-2.d0*weight*&
|
|
|
|
ZDOTC(npw,dpsi(1,ibnd),1,dvpsi(1,ibnd),1)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
imode0 = imode0 + npert (irr)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
2003-10-16 22:39:25 +08:00
|
|
|
!
|
|
|
|
! Now we add the terms which are due to the USPP
|
|
|
|
!
|
|
|
|
if (okvan) call zstar_eu_us
|
|
|
|
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2003-02-08 00:04:36 +08:00
|
|
|
call reduce (18 * nat, zstareu0)
|
|
|
|
call poolreduce (18 * nat, zstareu0)
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
|
|
|
!
|
|
|
|
! bring the mode index to cartesian coordinates
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do jpol = 1, 3
|
|
|
|
do mu = 1, 3 * nat
|
|
|
|
na = (mu - 1) / 3 + 1
|
|
|
|
icart = mu - 3 * (na - 1)
|
|
|
|
do nu = 1, 3 * nat
|
2004-03-07 21:47:42 +08:00
|
|
|
zstareu (jpol, icart, na) = zstareu (jpol, icart, na) + &
|
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
|
|
|
CONJG(u (mu, nu) ) * zstareu0 (jpol, nu)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
2004-03-07 21:47:42 +08:00
|
|
|
!
|
|
|
|
work(:,:,:) = 0.d0
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! bring to crystal axis for symmetrization
|
|
|
|
! NOTA BENE: the electric fields are already in crystal axis
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do na = 1, nat
|
|
|
|
do ipol = 1, 3
|
|
|
|
do jpol = 1, 3
|
|
|
|
do icart = 1, 3
|
2003-01-20 05:58:50 +08:00
|
|
|
work (jpol, ipol, na) = work (jpol, ipol, na) + zstareu (jpol, &
|
|
|
|
icart, na) * at (icart, ipol)
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
2003-10-16 22:39:25 +08:00
|
|
|
|
2003-11-06 03:01:20 +08:00
|
|
|
! WRITE( stdout,'(/,10x,"Effective charges E-U in crystal axis ",/)')
|
2003-01-20 05:58:50 +08:00
|
|
|
! do na=1,nat
|
2003-11-06 03:01:20 +08:00
|
|
|
! WRITE( stdout,'(10x," atom ",i6)') na
|
|
|
|
! WRITE( stdout,'(10x,"(",3f15.5," )")') ((work(jpol,ipol,na),
|
2003-01-20 05:58:50 +08:00
|
|
|
! + ipol=1,3),jpol=1,3)
|
|
|
|
! enddo
|
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
call symz (work, nsym, s, nat, irt)
|
|
|
|
do na = 1, nat
|
|
|
|
call trntns (work (1, 1, na), at, bg, 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2004-03-07 21:47:42 +08:00
|
|
|
zstareu(:,:,:) = work(:,:,:)
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! add the diagonal part
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
do ipol = 1, 3
|
|
|
|
do na = 1, nat
|
2003-10-16 22:39:25 +08:00
|
|
|
zstareu (ipol, ipol, na) = zstareu (ipol, ipol, na) + zv (ityp ( na) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
2003-10-24 23:57:43 +08:00
|
|
|
|
2003-11-06 03:01:20 +08:00
|
|
|
WRITE( stdout, '(/,10x,"Effective charges E-U in cartesian axis ",/)')
|
2003-02-08 00:04:36 +08:00
|
|
|
do na = 1, nat
|
2003-11-06 03:01:20 +08:00
|
|
|
WRITE( stdout, '(10x," atom ",i6)') na
|
|
|
|
WRITE( stdout, '(10x,"(",3f15.5," )")') ( (zstareu (ipol, jpol, na) &
|
2004-08-27 17:00:02 +08:00
|
|
|
, jpol = 1, 3) , ipol = 1, 3)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-10-24 23:57:43 +08:00
|
|
|
call stop_clock ('zstar_eu')
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine zstar_eu
|