get_orb_from_k_vec Function

private function get_orb_from_k_vec(this, k_in, spin) result(orb)

Type Bound

lattice

Arguments

Type IntentOptional Attributes Name
class(lattice) :: this
integer, intent(in) :: k_in(3)
integer, intent(in), optional :: spin

Return Value integer


Contents

Source Code


Source Code

    function get_orb_from_k_vec(this, k_in, spin) result(orb)
        class(lattice) :: this
        integer, intent(in) :: k_in(3)
        integer, intent(in), optional :: spin
        integer :: orb
#ifdef DEBUG_
        character(*), parameter :: this_routine = "get_orb_from_k_vec"
#endif
        integer :: i

        ! checking if it is in the first is not necessary anymore
        ! as the lookup table captures more than just the BZ

        ! the naive way would be to loop over all sites and check if the
        ! k-vector fits..
        ! but that would be too effortive, so we use the lookup table

        i = this%lu_table(k_in(1), k_in(2), k_in(3))

        ! and, if required, include the spin in the index
        if (present(spin)) then
            ASSERT(spin == 1 .or. spin == 2)
            if (spin == 1) then
                orb = 2 * i - 1
            else if (spin == 2) then
                orb = 2 * i
            end if
        else
            orb = i
        end if

    end function get_orb_from_k_vec