apply_sternheimerop_to_m_wfcs.f90 2.28 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
!
2
! Copyright (C) 2015-2017 M. Govoni
Marco Govoni's avatar
Marco Govoni committed
3
4
5
6
7
8
9
! 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 .
!
! This file is part of WEST.
!
10
! Contributors to this file:
Marco Govoni's avatar
Marco Govoni committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
! Marco Govoni
!
!-----------------------------------------------------------------------
SUBROUTINE apply_sternheimerop_to_m_wfcs(nbndval, psi, hpsi, e, alpha, m)
  !-----------------------------------------------------------------------
  !
  USE kinds,                ONLY : DP
  USE pwcom,                ONLY : npw,npwx
  USE wvfct,                ONLY : nbnd
  USE becmod,               ONLY : bec_type, becp, calbec
  USE uspp,                 ONLY : nkb, vkb
  USE mp_global,            ONLY : intra_pool_comm,intra_bgrp_comm
  USE mp,                   ONLY : mp_sum
  USE wavefunctions_module, ONLY : evc
  USE noncollin_module,     ONLY : npol, noncolin
  USE westcom,              ONLY : l_kinetic_only
  !
  IMPLICIT NONE
  !
  ! I/O
  !
  INTEGER, INTENT(IN) :: nbndval, m
  ! input: the number of val bands
  ! input: the number of bands
  REAL(DP), INTENT(IN) :: e (m)
  COMPLEX(DP), INTENT(IN) :: alpha
  ! input: the eigenvalue
  COMPLEX(DP), INTENT(IN)  :: psi (npwx*npol,m)
  COMPLEX(DP), INTENT(OUT) :: hpsi (npwx*npol,m)
  ! input: the vector
  ! output: the operator applied to the vector
  !
43
  ! Workspace
Marco Govoni's avatar
Marco Govoni committed
44
45
46
47
48
49
50
51
52
  !
  INTEGER :: ibnd, ig
  COMPLEX(DP) :: za
  !
  CALL start_clock ('stern')
  !
  !   compute the product of the hamiltonian with the h vector
  !
  hpsi=(0.0_DP,0.0_DP)
53
  !
Marco Govoni's avatar
Marco Govoni committed
54
55
56
  IF(l_kinetic_only) THEN
     CALL k_psi( npwx, npw, m, psi, hpsi )
  ELSE
57
58
59
60
61
     !
     ! use h_psi_, i.e. h_psi without band parallelization, as wstat
     ! handles band parallelization separately in dfpt_module
     !
     CALL h_psi_( npwx, npw, m, psi, hpsi )
Marco Govoni's avatar
Marco Govoni committed
62
63
64
65
66
67
68
69
  ENDIF
  !
  !   then we compute the operator H-epsilon S
  !
  DO ibnd=1,m
     za = CMPLX( -e(ibnd), 0._DP, KIND=DP )
     CALL ZAXPY(npw,za,psi(1,ibnd),1,hpsi(1,ibnd),1)
  ENDDO
70
  IF(noncolin) THEN
Marco Govoni's avatar
Marco Govoni committed
71
72
73
74
75
76
77
78
79
80
     DO ibnd=1,m
        za = CMPLX( -e(ibnd), 0._DP, KIND=DP )
        CALL ZAXPY(npw,za,psi(npwx+1,ibnd),1,hpsi(npwx+1,ibnd),1)
     ENDDO
  ENDIF
  !
  CALL apply_alpha_pv_to_m_wfcs(nbndval,m,psi,hpsi,alpha)
  !
  CALL stop_clock ('stern')
  !
81
END SUBROUTINE