diffSpinPos Function

public function diffSpinPos(i, j, k, a, b, c) result(pos)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i
integer, intent(in) :: j
integer, intent(in) :: k
integer, intent(in) :: a
integer, intent(in) :: b
integer, intent(in) :: c

Return Value integer


Contents

Source Code


Source Code

    function diffSpinPos(i, j, k, a, b, c) result(pos)
        ! given three excitations (i,a), (j,b), (k,c), find the position of the one with
        ! different spin in the ordering a'<b'<c' where a'=min(a,i) etc.
        ! Input: i,j,k - occupied orbital indices
        !        a,b,c - unoccupied orbital indices
        ! Outpu: pos - 0 if all electrons have the same spin, the position of the one
        !              with different spin else
        implicit none
        integer, intent(in) :: i, j, k, a, b, c
        integer :: pos
        integer :: ap, bp, cp
        integer :: tmp(3)

        ! the minimum of each pair to be sorted
        ap = min(a, i)
        bp = min(b, j)
        cp = min(c, k)
        tmp = (/ap, bp, cp/)

        ! at this point, both indices of a pair have the same spin, so we just use the one
        ! of the primed indices
        if (G1(minval(tmp))%MS /= G1(maxval(tmp))%MS) then
            ! either the first or the last is different
            ! do a check if the first entry has different spin: subtract its spin from the
            ! total spin
            if (abs(G1(ap)%MS + G1(bp)%MS + G1(cp)%MS - G1(minval(tmp))%MS) == 2) then
                ! if this is 2, minval(tmp) has different spin than the other two
                pos = 1
            else
                ! else, maxval(tmp) has the different spin
                pos = 3
            end if
        else
            pos = 2
        end if

    end function diffSpinPos