2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! Copyright (C) 2001 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-08 00:04:36 +08:00
|
|
|
subroutine set_efsh (drhoscf, imode0, irr, npe)
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
! This routine calculates the FermiEnergy shift
|
|
|
|
! and stores it in the variable ef_sh
|
|
|
|
!
|
2004-06-26 01:25:37 +08:00
|
|
|
#include "f_defs.h"
|
2004-02-04 19:06:45 +08:00
|
|
|
USE kinds, only : DP
|
2003-11-06 21:06:49 +08:00
|
|
|
USE io_global, ONLY : stdout
|
2003-01-20 05:58:50 +08:00
|
|
|
use pwcom
|
|
|
|
use phcom
|
|
|
|
use d3com
|
|
|
|
implicit none
|
2004-03-07 21:47:42 +08:00
|
|
|
integer :: npe, imode0, irr
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the number of perturbation
|
|
|
|
! input: the position of the current mode
|
|
|
|
! input: index of the current irr. rep.
|
2005-08-28 22:09:42 +08:00
|
|
|
complex (DP) :: drhoscf (nrxx, npe)
|
2004-03-13 02:38:54 +08:00
|
|
|
! input: variation of the charge density
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2004-03-07 21:47:42 +08:00
|
|
|
integer :: ipert, ik, ikk, ibnd
|
|
|
|
! counters
|
2005-08-28 22:09:42 +08:00
|
|
|
complex (DP) :: delta_n, def (npertx)
|
2003-01-20 05:58:50 +08:00
|
|
|
! the change in electron number
|
2004-03-07 21:47:42 +08:00
|
|
|
! the change of the Fermi energy for each perturbation
|
2005-08-28 22:09:42 +08:00
|
|
|
real (DP) :: weight, wdelta
|
2003-01-20 05:58:50 +08:00
|
|
|
! kpoint weight
|
|
|
|
! delta function weight
|
2005-08-28 22:09:42 +08:00
|
|
|
real (DP), save :: dos_ef
|
2004-03-07 21:47:42 +08:00
|
|
|
! density of states at Ef
|
2005-08-28 22:09:42 +08:00
|
|
|
real (DP), external :: w0gauss
|
2004-03-07 21:47:42 +08:00
|
|
|
logical, save :: first = .true.
|
2003-01-20 05:58:50 +08:00
|
|
|
! Used for initialization
|
|
|
|
!
|
|
|
|
! first call: calculates density of states at Ef
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
if (first) then
|
|
|
|
first = .false.
|
|
|
|
dos_ef = 0.d0
|
|
|
|
do ik = 1, nksq
|
|
|
|
if (lgamma) then
|
|
|
|
ikk = ik
|
|
|
|
else
|
|
|
|
ikk = 2 * ik - 1
|
2003-01-20 05:58:50 +08:00
|
|
|
endif
|
2003-02-08 00:04:36 +08:00
|
|
|
weight = wk (ikk)
|
|
|
|
do ibnd = 1, nbnd
|
2003-01-20 05:58:50 +08:00
|
|
|
wdelta = w0gauss ( (ef - et (ibnd, ikk) ) / degauss, ngauss) &
|
|
|
|
/ degauss
|
2003-02-08 00:04:36 +08:00
|
|
|
dos_ef = dos_ef + weight * wdelta
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
enddo
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2003-02-08 00:04:36 +08:00
|
|
|
call poolreduce (1, dos_ef)
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
|
|
|
endif
|
|
|
|
!
|
|
|
|
! determines Fermi energy shift (such that each pertubation is neutral)
|
|
|
|
!
|
2003-11-06 21:06:49 +08:00
|
|
|
WRITE( stdout, * )
|
2003-02-08 00:04:36 +08:00
|
|
|
do ipert = 1, npe
|
2004-03-07 21:47:42 +08:00
|
|
|
call cft3 (drhoscf (1, ipert), nr1, nr2, nr3, nrx1, nrx2, nrx3, - 1)
|
2003-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2003-02-08 00:04:36 +08:00
|
|
|
delta_n = (0.d0, 0.d0)
|
2004-03-07 21:47:42 +08:00
|
|
|
if (gg (1) < 1.0d-8) delta_n = omega * drhoscf (nl (1), ipert)
|
2003-02-08 00:04:36 +08:00
|
|
|
call reduce (2, delta_n)
|
2003-01-20 05:58:50 +08:00
|
|
|
#else
|
2003-02-08 00:04:36 +08:00
|
|
|
delta_n = omega * drhoscf (nl (1), ipert)
|
2003-01-20 05:58:50 +08:00
|
|
|
#endif
|
2003-02-08 00:04:36 +08:00
|
|
|
def (ipert) = - delta_n / dos_ef
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
!
|
|
|
|
! symmetrizes the Fermi energy shift
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
call sym_def1 (def, irr)
|
|
|
|
do ipert = 1, npe
|
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
|
|
|
ef_sh (imode0 + ipert) = DBLE (def (ipert) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
|
2003-11-06 21:06:49 +08:00
|
|
|
WRITE( stdout, '(5x,"Pert. #",i3,": Fermi energy shift (Ryd) =", &
|
2003-01-20 05:58:50 +08:00
|
|
|
& 2f10.4)') (ipert, def (ipert) , ipert = 1, npe)
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine set_efsh
|