kmesh_get_bvectors Subroutine

private subroutine kmesh_get_bvectors(kmesh_input, print_output, bvector, kpt_cart, recip_lattice, shell_dist, lmn, kpt, multi, num_kpts, timer, error, comm)

Uses

  • proc~~kmesh_get_bvectors~~UsesGraph proc~kmesh_get_bvectors kmesh_get_bvectors module~w90_io w90_io proc~kmesh_get_bvectors->module~w90_io module~w90_types w90_types proc~kmesh_get_bvectors->module~w90_types module~w90_constants w90_constants module~w90_io->module~w90_constants module~w90_types->module~w90_constants

Returns the b-vectors for a given shell and kpoint.

Arguments

Type IntentOptional Attributes Name
type(kmesh_input_type), intent(in) :: kmesh_input
type(print_output_type), intent(in) :: print_output
real(kind=dp), intent(out) :: bvector(3,multi)
real(kind=dp), intent(in) :: kpt_cart(:,:)
real(kind=dp), intent(in) :: recip_lattice(3,3)
real(kind=dp), intent(in) :: shell_dist
integer, intent(in) :: lmn(:,:)
integer, intent(in) :: kpt
integer, intent(in) :: multi
integer, intent(in) :: num_kpts
type(timer_list_type), intent(inout) :: timer
type(w90_error_type), intent(out), allocatable :: error
type(w90_comm_type), intent(in) :: comm

Calls

proc~~kmesh_get_bvectors~~CallsGraph proc~kmesh_get_bvectors kmesh_get_bvectors proc~io_stopwatch_start io_stopwatch_start proc~kmesh_get_bvectors->proc~io_stopwatch_start proc~io_stopwatch_stop io_stopwatch_stop proc~kmesh_get_bvectors->proc~io_stopwatch_stop proc~set_error_fatal set_error_fatal proc~kmesh_get_bvectors->proc~set_error_fatal proc~comms_sync_error comms_sync_error proc~set_error_fatal->proc~comms_sync_error proc~set_base_error set_base_error proc~set_error_fatal->proc~set_base_error

Called by

proc~~kmesh_get_bvectors~~CalledByGraph proc~kmesh_get_bvectors kmesh_get_bvectors proc~kmesh_get kmesh_get proc~kmesh_get->proc~kmesh_get_bvectors proc~kmesh_shell_automatic kmesh_shell_automatic proc~kmesh_get->proc~kmesh_shell_automatic proc~kmesh_shell_fixed kmesh_shell_fixed proc~kmesh_get->proc~kmesh_shell_fixed proc~kmesh_shell_from_file kmesh_shell_from_file proc~kmesh_get->proc~kmesh_shell_from_file proc~kmesh_shell_automatic->proc~kmesh_get_bvectors proc~kmesh_shell_fixed->proc~kmesh_get_bvectors proc~kmesh_shell_from_file->proc~kmesh_get_bvectors proc~w90_create_kmesh w90_create_kmesh proc~w90_create_kmesh->proc~kmesh_get program~postw90 postw90 program~postw90->proc~kmesh_get proc~w90_get_gkpb~2 w90_get_gkpb proc~w90_get_gkpb~2->proc~w90_create_kmesh proc~w90_get_nnkp~2 w90_get_nnkp proc~w90_get_nnkp~2->proc~w90_create_kmesh proc~w90_get_nn~2 w90_get_nn proc~w90_get_nn~2->proc~w90_create_kmesh proc~write_kmesh write_kmesh proc~write_kmesh->proc~w90_create_kmesh proc~w90_get_gkpb w90_get_gkpb proc~w90_get_gkpb->proc~w90_get_gkpb~2 proc~w90_get_nn w90_get_nn proc~w90_get_nn->proc~w90_get_nn~2 proc~w90_get_nnkp w90_get_nnkp proc~w90_get_nnkp->proc~w90_get_nnkp~2 program~wannier wannier program~wannier->proc~w90_get_nn~2 program~wannier->proc~write_kmesh

Source Code

  subroutine kmesh_get_bvectors(kmesh_input, print_output, bvector, kpt_cart, recip_lattice, &
                                shell_dist, lmn, kpt, multi, num_kpts, timer, error, comm)
    !================================================
    !
    !! Returns the b-vectors for a given shell and kpoint.
    !
    !================================================

    use w90_io, only: io_stopwatch_start, io_stopwatch_stop
    use w90_types, only: kmesh_input_type, print_output_type, timer_list_type

    implicit none

    ! arguments
    type(print_output_type), intent(in) :: print_output
    type(kmesh_input_type), intent(in)  :: kmesh_input
    type(timer_list_type), intent(inout) :: timer
    type(w90_error_type), allocatable, intent(out) :: error
    type(w90_comm_type), intent(in) :: comm

    integer, intent(in) :: num_kpts
    integer, intent(in) :: lmn(:, :)
    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) :: recip_lattice(3, 3)
    real(kind=dp), intent(in) ::kpt_cart(:, :)
    real(kind=dp), intent(in) :: shell_dist ! the bvectors
    real(kind=dp), intent(out) :: bvector(3, multi) ! the bvectors

    ! local variables
    integer :: loop, nkp2, num_bvec
    real(kind=dp) :: dist, vkpp2(3), vkpp(3)

    if (print_output%timing_level > 1) call io_stopwatch_start('kmesh: get_bvectors', timer)

    bvector = 0.0_dp

    num_bvec = 0
    ok: do loop = 1, (2*kmesh_input%search_supcell_size + 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 - kmesh_input%tol) .and. (dist .le. shell_dist + kmesh_input%tol)) then
          num_bvec = num_bvec + 1
          bvector(:, num_bvec) = vkpp(:) - kpt_cart(:, kpt)
        end if
        !if we have the right number of neighbours we can exit
        if (num_bvec == multi) cycle ok
      end do
    end do ok

    if (num_bvec < multi) then
      call set_error_fatal(error, 'kmesh_get_bvector: Not enough bvectors found', comm)
      return
    end if

    if (print_output%timing_level > 1) call io_stopwatch_stop('kmesh: get_bvectors', timer)

    return

  end subroutine kmesh_get_bvectors