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 .
|
|
|
|
!
|
|
|
|
!
|
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
subroutine n_plane_waves (ecutwfc, tpiba2, nks, nkstot, xk, g, ngm, &
|
|
|
|
npwx, ngk)
|
|
|
|
!-----------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! Find number of plane waves for each k-point
|
|
|
|
!
|
2004-01-23 23:08:03 +08:00
|
|
|
USE kinds
|
2003-02-08 00:04:36 +08:00
|
|
|
implicit none
|
2003-01-20 05:58:50 +08:00
|
|
|
! input
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: nks, nkstot, ngm
|
|
|
|
real(kind=DP) :: ecutwfc, tpiba2, xk (3, nks), g (3, ngm)
|
2003-01-20 05:58:50 +08:00
|
|
|
! output
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: npwx, ngk (nkstot)
|
2003-01-20 05:58:50 +08:00
|
|
|
! local
|
2003-02-08 00:04:36 +08:00
|
|
|
integer :: nk, ng
|
2003-01-20 05:58:50 +08:00
|
|
|
|
2003-02-08 00:04:36 +08:00
|
|
|
real(kind=DP) :: q2
|
|
|
|
npwx = 0
|
|
|
|
do nk = 1, nks
|
|
|
|
ngk (nk) = 0
|
|
|
|
do ng = 1, ngm
|
2003-01-20 05:58:50 +08:00
|
|
|
q2 = (xk (1, nk) + g (1, ng) ) **2 + (xk (2, nk) + g (2, ng) ) ** &
|
|
|
|
2 + (xk (3, nk) + g (3, ng) ) **2
|
2003-02-08 00:04:36 +08:00
|
|
|
if (q2.le.ecutwfc / tpiba2) then
|
2003-01-20 05:58:50 +08:00
|
|
|
!
|
|
|
|
! here if |k+G|^2 <= Ecut increase the number of G inside the sphere
|
|
|
|
!
|
2003-02-08 00:04:36 +08:00
|
|
|
ngk (nk) = ngk (nk) + 1
|
|
|
|
else
|
2003-01-20 05:58:50 +08:00
|
|
|
if (sqrt (g (1, ng) **2 + g (2, ng) **2 + g (3, ng) **2) &
|
|
|
|
.gt.sqrt (xk (1, nk) **2 + xk (2, nk) **2 + xk (3, nk) **2) &
|
|
|
|
+ sqrt (ecutwfc / tpiba2) ) goto 100
|
|
|
|
!
|
|
|
|
! if |G| > |k| + sqrt(Ecut) stop search
|
|
|
|
!
|
|
|
|
endif
|
|
|
|
enddo
|
2003-02-08 00:04:36 +08:00
|
|
|
100 npwx = max (npwx, ngk (nk) )
|
2003-01-20 05:58:50 +08:00
|
|
|
enddo
|
|
|
|
|
2003-02-21 22:57:00 +08:00
|
|
|
if (npwx.eq.0) call errore ('n_plane_waves', 'No PWs !', 1)
|
2003-02-08 00:04:36 +08:00
|
|
|
return
|
2003-01-20 05:58:50 +08:00
|
|
|
end subroutine n_plane_waves
|