pick_weighted_hole_Excite_1_t Function

private function pick_weighted_hole_Excite_1_t(this, nI, exc, spin_idx, iGAS, pgen) result(tgt)

Type Bound

GAS_disc_ExcGenerator_t

Arguments

Type IntentOptional Attributes Name
class(GAS_disc_ExcGenerator_t), intent(in) :: this
integer, intent(in) :: nI(nel)
type(Excite_1_t), intent(in) :: exc
integer, intent(in) :: spin_idx
integer, intent(in) :: iGAS
real(kind=dp), intent(inout) :: pgen

Return Value integer


Contents


Source Code

    function pick_weighted_hole_Excite_1_t (this, nI, exc, spin_idx, iGAS, pgen) result(tgt)
        ! pick a hole of nI with spin ms from the active space with index
        ! srcGASInd the random number is to be supplied as r
        ! nI is the source determinant, nJBase the one from which we obtain
        ! the ket of the matrix element by single excitation
        class(GAS_disc_ExcGenerator_t), intent(in) :: this
        integer, intent(in) :: nI(nel)
        type(Excite_1_t), intent(in) :: exc
        integer, intent(in) :: spin_idx, iGAS
        real(dp), intent(inout) :: pgen
        character(*), parameter :: this_routine = 'pick_weighted_hole_Excite_1_t'

        integer :: tgt, nOrbs, GAS_list(this%GAS_size(iGAS))
        real(dp) :: cSum(this%GAS_size(iGAS))

        ! initialize auxiliary variables
        nOrbs = this%GAS_size(iGAS)
        GAS_list = this%GAS_spin_orb_list(1:nOrbs, iGAS, spin_idx)
        ! build the cumulative list of matrix elements <src|H|tgt>
        ASSERT(get_last_tgt(exc) == UNKNOWN)
        cSum = get_cumulative_list(GAS_list, nI, exc)

        ! there might not be such an excitation
        if (cSum(nOrbs) > 0) then
            ! find the index of the target orbital in the gasList
            tgt = binary_search_first_ge(cSum, genrand_real2_dSFMT())

            ! adjust pgen with the probability for picking tgt from the cumulative list
            if (tgt == 1) then
                pgen = pgen * cSum(1)
            else
                pgen = pgen * (cSum(tgt) - cSum(tgt - 1))
            end if

            ! convert to global orbital index
            tgt = GAS_list(tgt)
        else
            tgt = 0
        end if

    end function pick_weighted_hole_Excite_1_t