Returns the b-vectors for a given shell and kpoint.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | multi | |||
integer, | intent(in) | :: | kpt | |||
real(kind=dp), | intent(in) | :: | shell_dist | |||
real(kind=dp), | intent(out) | :: | bvector(3,multi) |
subroutine kmesh_get_bvectors(multi, kpt, shell_dist, bvector)
!=============================================================
!
!! Returns the b-vectors for a given shell and kpoint.
!
!=============================================================
use w90_io, only: io_error, io_stopwatch
implicit none
integer, intent(in) :: multi ! the number of kpoints in the shell
integer, intent(in) :: kpt ! which kpt is our 'origin'
real(kind=dp), intent(in) :: shell_dist ! the bvectors
real(kind=dp), intent(out) :: bvector(3, multi) ! the bvectors
integer :: loop, nkp2, num_bvec
real(kind=dp) :: dist, vkpp2(3), vkpp(3)
if (timing_level > 1) call io_stopwatch('kmesh: get_bvectors', 1)
bvector = 0.0_dp
num_bvec = 0
ok: do loop = 1, (2*nsupcell + 1)**3
vkpp2 = matmul(lmn(:, loop), recip_lattice)
do nkp2 = 1, num_kpts
vkpp = vkpp2 + kpt_cart(:, nkp2)
dist = sqrt((kpt_cart(1, kpt) - vkpp(1))**2 &
+ (kpt_cart(2, kpt) - vkpp(2))**2 + (kpt_cart(3, kpt) - vkpp(3))**2)
if ((dist .ge. shell_dist*(1.0_dp - kmesh_tol)) .and. dist .le. shell_dist*(1.0_dp + kmesh_tol)) then
num_bvec = num_bvec + 1
bvector(:, num_bvec) = vkpp(:) - kpt_cart(:, kpt)
endif
!if we have the right number of neighbours we can exit
if (num_bvec == multi) cycle ok
enddo
enddo ok
if (num_bvec < multi) call io_error('kmesh_get_bvector: Not enough bvectors found')
if (timing_level > 1) call io_stopwatch('kmesh: get_bvectors', 2)
return
end subroutine kmesh_get_bvectors