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 drhodvus (irr, imode0, dvscfin, npe)
|
2003-01-20 05:58:50 +08:00
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! This subroutine calculates the term of the dynamical matrix
|
|
|
|
! which comes from the interaction of the change of the self consiste
|
|
|
|
! potential with the static change of the charge density.
|
|
|
|
! This term is non zero only if the charge is augmented.
|
|
|
|
!
|
|
|
|
!
|
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
|
2003-02-08 00:04:36 +08:00
|
|
|
use pwcom
|
2007-02-08 21:07:07 +08:00
|
|
|
USE io_global, ONLY : stdout
|
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
|
|
|
|
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
|
|
|
|
|
2005-08-28 22:09:42 +08:00
|
|
|
complex(DP) :: dvscfin (nrxx, nspin, npe)
|
2003-01-20 05:58:50 +08:00
|
|
|
! input: the change of V_Hxc
|
|
|
|
|
2007-02-08 21:07:07 +08:00
|
|
|
integer :: ipert, irr1, mode0, mu, is, nu_i, nu_j, nrtot, nspin0
|
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
|
2005-08-28 22:09:42 +08:00
|
|
|
complex(DP), allocatable :: drhous (:,:,:)
|
2003-01-20 05:58:50 +08:00
|
|
|
! the change of the charge
|
2005-08-28 22:09:42 +08:00
|
|
|
complex(DP), external :: ZDOTC
|
2003-02-08 00:04:36 +08:00
|
|
|
|
|
|
|
if (.not.okvan) return
|
2007-02-08 21:07:07 +08:00
|
|
|
nspin0=nspin
|
|
|
|
if (nspin==4.and..not.domag) nspin0=1
|
2003-02-08 00:04:36 +08:00
|
|
|
call start_clock ('drhodvus')
|
2004-03-07 21:47:42 +08:00
|
|
|
allocate (drhous ( nrxx , nspin, npertx))
|
|
|
|
dyn1 (:,:) = (0.d0, 0.d0)
|
2003-02-08 00:04:36 +08:00
|
|
|
nrtot = nr1 * nr2 * nr3
|
|
|
|
mode0 = 0
|
|
|
|
do irr1 = 1, nirr
|
|
|
|
do ipert = 1, npert (irr1)
|
|
|
|
nu_j = mode0 + ipert
|
2004-03-07 21:47:42 +08:00
|
|
|
call davcio (drhous (1, 1, ipert), lrdrhous, iudrhous, nu_j, - 1)
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
do ipert = 1, npert (irr1)
|
|
|
|
nu_j = mode0 + ipert
|
|
|
|
do mu = 1, npert (irr)
|
|
|
|
nu_i = imode0 + mu
|
2007-02-08 21:07:07 +08:00
|
|
|
do is = 1, nspin0
|
2004-03-07 21:47:42 +08:00
|
|
|
dyn1 (nu_i, nu_j) = dyn1 (nu_i, nu_j) + &
|
|
|
|
ZDOTC (nrxx, dvscfin (1,is,mu), 1, drhous (1,is,ipert), 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
|
|
|
|
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-02-21 22:57:00 +08:00
|
|
|
#ifdef __PARA
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! collect contributions from all pools (sum over k-points)
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
call poolreduce (18 * nat * nat, dyn1)
|
|
|
|
call reduce (18 * nat * nat, dyn1)
|
2003-01-20 05:58:50 +08:00
|
|
|
#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 (:,:)
|
2003-02-08 00:04:36 +08:00
|
|
|
call stop_clock ('drhodvus')
|
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
|
|
|
|
end subroutine drhodvus
|