checkCompatibility_single Function

public function checkCompatibility_single(csf_i, excitInfo) result(flag)

Uses

Arguments

Type IntentOptional Attributes Name
type(CSF_Info_t), intent(in) :: csf_i
type(ExcitationInformation_t), intent(in) :: excitInfo

Return Value logical


Contents


Source Code

    function checkCompatibility_single(csf_i, excitInfo) result(flag)
        use guga_types, only: WeightObj_t

        type(CSF_Info_t), intent(in) :: csf_i
        type(ExcitationInformation_t), intent(in) :: excitInfo
        logical :: flag

        debug_function_name("checkCompatibility_single")

        real(dp) :: pw, mw, posSwitches(nSpatOrbs), negSwitches(nSpatOrbs)
        integer ::  st, en
        type(WeightObj_t) :: weights

        ASSERT(excitInfo%typ == excit_type%single)
        ASSERT(excitInfo%gen1 == gen_type%R .or. excitInfo%gen1 == gen_type%L)

        call calcRemainingSwitches_excitInfo_single(csf_i, excitInfo, posSwitches, negSwitches)

        st = excitInfo%fullStart
        en = excitInfo%fullEnd
        flag = .true.

        if (excitInfo%gen1 == gen_type%R) then
            ! raising
            if (csf_i%stepvector(st) == 3 .or. csf_i%stepvector(en) == 0) then
                flag = .false.
                return
            end if

            weights = init_singleWeight(csf_i, en)
            mw = weights%proc%minus(negSwitches(st), csf_i%B_real(st), weights%dat)
            pw = weights%proc%plus(posSwitches(st), csf_i%B_real(st), weights%dat)

            if ((near_zero(pw) .and. near_zero(mw)) &
                .or. (csf_i%stepvector(st) == 1 .and. near_zero(pw)) &
                .or. (csf_i%stepvector(st) == 2 .and. near_zero(mw))) then
                flag = .false.
                return
            end if

        else if (excitInfo%gen1 == gen_type%L) then
            ! lowering

            if (csf_i%stepvector(en) == 3 .or. csf_i%stepvector(st) == 0) then
                flag = .false.
                return
            end if

            weights = init_singleWeight(csf_i, en)
            mw = weights%proc%minus(negSwitches(st), csf_i%B_real(st), weights%dat)
            pw = weights%proc%plus(posSwitches(st), csf_i%B_real(st), weights%dat)


            if ((csf_i%stepvector(st) == 1 .and. near_zero(pw)) &
                .or. (csf_i%stepvector(st) == 2 .and. near_zero(mw)) &
                .or. (near_zero(pw + mw))) then
                flag = .false.
                return
            end if
        end if
    end function checkCompatibility_single