find_minority_spin Function

public function find_minority_spin(spins) result(opp)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: spins(:)

Return Value integer


Contents

Source Code


Source Code

    function find_minority_spin(spins) result(opp)
        ! for now, given 3 spin orbitals, where 2 share a spin, this function
        ! returns the opposite spin
        integer, intent(in) :: spins(:)
        integer :: opp
#ifdef DEBUG_
        character(*), parameter :: this_routine = "find_minority_spin"
#endif
        integer :: i

        ! for now, do it only for 3 inputted spins:
        ASSERT(size(spins) == 3)
        ASSERT(sum(get_spin_pn(spins)) == -1 .or. sum(get_spin_pn(spins)) == 1)

        opp = -1

        if (sum(get_spin_pn(spins)) == -1) then
            ! then we have 2 beta and 1 alpha
            do i = 1, size(spins)
                if (is_alpha(spins(i))) opp = spins(i)
            end do
        else
            ! we have 2 alpha and 1 beta
            do i = 1, size(spins)
                if (is_beta(spins(i))) opp = spins(i)
            end do
        end if
    end function find_minority_spin