2004-02-14 16:39:34 +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 .
|
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
subroutine ns_adj
|
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
! This routine tries to suggest to the code the right atomic orbital to
|
|
|
|
! localize the charge on.
|
|
|
|
!
|
2004-06-12 21:44:18 +08:00
|
|
|
USE kinds, ONLY : DP
|
|
|
|
USE ions_base, ONLY : nat, ntyp => nsp, ityp
|
2007-11-10 23:07:51 +08:00
|
|
|
USE ldaU, ONLY : Hubbard_lmax, Hubbard_l, Hubbard_U, starting_ns
|
|
|
|
USE scf, ONLY : rho
|
2006-06-23 23:47:59 +08:00
|
|
|
USE lsda_mod, ONLY : nspin
|
|
|
|
USE io_global, ONLY : stdout
|
2004-02-14 16:39:34 +08:00
|
|
|
|
|
|
|
implicit none
|
2004-06-12 21:44:18 +08:00
|
|
|
!
|
2004-02-14 16:39:34 +08:00
|
|
|
integer, parameter:: ldim=7
|
|
|
|
integer :: na,nt,is,m1,m2,majs,mins,adjs,mol(ldim),nel,i,j,l,index(ldim)
|
2005-08-28 22:09:42 +08:00
|
|
|
real(DP) :: totoc, delta,lambda(ldim)
|
|
|
|
complex(DP) :: vet(ldim,ldim), f(ldim,ldim), temp
|
2004-02-14 16:39:34 +08:00
|
|
|
logical :: adjust
|
|
|
|
|
|
|
|
if (ALL(starting_ns == -1.d0)) return
|
|
|
|
write (stdout,*) "Modify starting ns matrices according to input values "
|
|
|
|
|
|
|
|
if (2*Hubbard_lmax+1>ldim) call errore('ns_adj',' ldim too small',ldim)
|
|
|
|
|
|
|
|
do na = 1,nat
|
|
|
|
nt = ityp(na)
|
|
|
|
if (Hubbard_U(nt).ne.0.d0) then
|
|
|
|
do is=1,nspin
|
|
|
|
do m1 = 1, 2 * Hubbard_l(nt) + 1
|
|
|
|
do m2 = 1, 2 * Hubbard_l(nt) + 1
|
2007-11-10 23:07:51 +08:00
|
|
|
f(m1,m2) = rho%ns(m1,m2,is,na)
|
2004-02-14 16:39:34 +08:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
call cdiagh(2*Hubbard_l(nt)+1, f, ldim, lambda, vet)
|
|
|
|
do i = 1, 2 * Hubbard_l(nt) + 1
|
|
|
|
if (starting_ns(i,is,nt) >= 0.d0) lambda(i) = starting_ns(i,is,nt)
|
|
|
|
end do
|
|
|
|
do m1 = 1,2 * Hubbard_l(nt) + 1
|
|
|
|
do m2 = m1, 2 * Hubbard_l(nt) + 1
|
|
|
|
temp = 0.d0
|
|
|
|
do i = 1,2 * Hubbard_l(nt) + 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
|
|
|
temp = temp + CONJG(vet(m1,i))*lambda(i)*vet(m2,i)
|
2004-02-14 16:39:34 +08:00
|
|
|
end do
|
2007-11-10 23:07:51 +08:00
|
|
|
rho%ns(m1,m2,is,na) = DBLE(temp)
|
|
|
|
rho%ns(m2,m1,is,na) = rho%ns(m1,m2,is,na)
|
2004-02-14 16:39:34 +08:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end if
|
2007-11-10 23:07:51 +08:00
|
|
|
end do ! on na
|
2004-02-14 16:39:34 +08:00
|
|
|
CALL write_ns
|
|
|
|
return
|
|
|
|
end subroutine ns_adj
|