2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-05-11 16:11:52 +08:00
|
|
|
! Copyright (C) 2001-2004 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 .
|
|
|
|
!
|
2004-05-11 16:11:52 +08:00
|
|
|
#define TEST_NEW_PRECONDITIONING
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
2004-01-20 20:26:22 +08:00
|
|
|
!----------------------------------------------------------------------------
|
|
|
|
SUBROUTINE g_psi( lda, n, m, psi, e )
|
|
|
|
!----------------------------------------------------------------------------
|
2003-04-09 21:58:05 +08:00
|
|
|
!
|
2004-01-20 20:26:22 +08:00
|
|
|
! ... This routine computes an estimate of the inverse Hamiltonian
|
|
|
|
! ... and applies it to m wavefunctions
|
2003-04-09 21:58:05 +08:00
|
|
|
!
|
2004-05-11 16:11:52 +08:00
|
|
|
USE kinds, ONLY : DP
|
|
|
|
USE constants, ONLY : eps4
|
|
|
|
USE g_psi_mod, ONLY : h_diag, s_diag
|
2003-04-09 21:58:05 +08:00
|
|
|
!
|
2004-01-20 20:26:22 +08:00
|
|
|
IMPLICIT NONE
|
2003-04-09 21:58:05 +08:00
|
|
|
!
|
2004-01-20 20:26:22 +08:00
|
|
|
INTEGER :: lda, n, m
|
|
|
|
! input: the leading dimension of psi
|
|
|
|
! input: the real dimension of psi
|
|
|
|
! input: the number of bands
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP) :: e(m)
|
2004-05-11 16:11:52 +08:00
|
|
|
! input: the eigenvalues
|
2005-08-28 22:09:42 +08:00
|
|
|
COMPLEX(DP) :: psi(lda,m)
|
2004-05-11 16:11:52 +08:00
|
|
|
! input/output: the psi vector
|
2003-04-09 21:58:05 +08:00
|
|
|
!
|
2004-01-20 20:26:22 +08:00
|
|
|
! ... Local variables
|
2003-04-09 21:58:05 +08:00
|
|
|
!
|
2005-08-28 22:09:42 +08:00
|
|
|
REAL(DP) :: x, scala, denm
|
2004-01-20 20:26:22 +08:00
|
|
|
INTEGER :: k, i
|
|
|
|
! counter on psi functions
|
|
|
|
! counter on G vectors
|
|
|
|
!
|
|
|
|
!
|
|
|
|
CALL start_clock( 'g_psi' )
|
|
|
|
!
|
2004-05-11 16:11:52 +08:00
|
|
|
#if defined (TEST_NEW_PRECONDITIONING)
|
|
|
|
!
|
|
|
|
scala = 1.D0
|
|
|
|
!
|
|
|
|
DO k = 1, m
|
2004-01-20 20:26:22 +08:00
|
|
|
!
|
2004-05-11 16:11:52 +08:00
|
|
|
DO i = 1, n
|
|
|
|
!
|
|
|
|
x = ( h_diag(i) - e(k) * s_diag(i) ) * scala
|
|
|
|
!
|
|
|
|
denm = ( 1.D0 + x + &
|
|
|
|
SQRT( 1.D0 + ( x - 1.D0 )*( x - 1.D0 ) ) ) / scala
|
|
|
|
!
|
|
|
|
! denm = 1.D0 + 16.D0 * x*x*x*x / &
|
|
|
|
! ( 27.D0 + 18.D0 * x + 12.D0 * x*x + 8.D0 * x*x*x )
|
|
|
|
!
|
|
|
|
psi(i,k) = psi(i,k) / denm
|
|
|
|
!
|
2004-01-20 20:26:22 +08:00
|
|
|
END DO
|
|
|
|
!
|
2004-05-11 16:11:52 +08:00
|
|
|
END DO
|
|
|
|
!
|
|
|
|
#else
|
|
|
|
!
|
|
|
|
DO k = 1, m
|
2004-01-20 20:26:22 +08:00
|
|
|
!
|
2004-05-11 16:11:52 +08:00
|
|
|
DO i = 1, n
|
|
|
|
!
|
|
|
|
! ... denm = g2+v(g=0) - e(k)
|
|
|
|
!
|
|
|
|
denm = h_diag(i) - e(k) * s_diag(i)
|
|
|
|
!
|
|
|
|
denm = SIGN( MAX( ABS( denm ), eps4 ), denm )
|
|
|
|
!
|
|
|
|
psi(i,k) = psi(i,k) / denm
|
|
|
|
!
|
2004-01-20 20:26:22 +08:00
|
|
|
END DO
|
|
|
|
!
|
2004-05-11 16:11:52 +08:00
|
|
|
END DO
|
|
|
|
!
|
|
|
|
#endif
|
2004-01-20 20:26:22 +08:00
|
|
|
!
|
|
|
|
CALL stop_clock( 'g_psi' )
|
|
|
|
!
|
|
|
|
RETURN
|
|
|
|
!
|
|
|
|
END SUBROUTINE g_psi
|