create_elec_map Function

public pure function create_elec_map(ilut) result(map)

Arguments

Type IntentOptional Attributes Name
integer(kind=n_int), intent(in) :: ilut(0:NifTot)

Return Value integer, (nel)


Contents

Source Code


Source Code

    pure function create_elec_map(ilut) result(map)
        ! Create a map to transfer orbitals between the current det (nI)
        ! and the reference determinant
        ! Input: nI - current determinant
        ! Output: map - list of orbitals where the n-th electron goes to
        implicit none
        integer(n_int), intent(in) :: ilut(0:NifTot)
        integer :: map(nel)
        integer :: i, j
        integer :: ms
        integer(n_int) :: excitedOrbs(0:NifTot)

        ! an ilut of orbitals present in ilut and not in ref
        excitedOrbs = iand(ilut, not(ilutRef(:, 1)))

        do i = 1, nel
            ! occupied orbitals get mapped to themselves
            if (IsOcc(ilut, refDet(i))) then
                map(i) = refDet(i)
            else
                ! unoccupied orbitals get mapped to the next occupied orbital
                ! only look at orbitals with the right spin
                ms = (3 + G1(refDet(i))%MS) / 2
                do j = ms, nBasis, 2
                    ! we check the orbitals in energetical order
                    ! utilize that BRR(j) has the same spin as j
                    if (IsOcc(excitedOrbs, BRR(j))) then
                        map(i) = BRR(j)
                        ! remove the selected orb from the candidates
                        clr_orb(excitedOrbs, BRR(j))
                        exit
                    end if
                end do
            end if
        end do

    end function create_elec_map