addProjEContrib Subroutine

public subroutine addProjEContrib(nI, nJ, sgn)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nI(nel)
integer, intent(in) :: nJ(nel)
real(kind=dp), intent(in) :: sgn(lenof_sign)

Contents

Source Code


Source Code

    subroutine addProjEContrib(nI, nJ, sgn)
        implicit none
        integer, intent(in) :: nI(nel), nJ(nel)
        real(dp), intent(in) :: sgn(lenof_sign)

        integer :: ex(2, 2)
        logical :: tPar
        integer :: id(2, 2)
        integer(int64) :: ind

        ! kMat reference energy contributions are coming from double excitations
        ex(1, 1) = 2

        ! get the excitation from nI to nJ
        call GetExcitation(nI, nJ, nel, ex, tPar)
        id = gtID(ex)
        ! the k-matrix only couples same-spin orbitals
        if (tReltvy .or. ((G1(ex(1, 1))%Ms == G1(ex(2, 1))%Ms) .and. &
                          (G1(ex(1, 2))%Ms == G1(ex(2, 2))%Ms))) then
            ind = UMatInd(id(1, 1), id(1, 2), id(2, 1), id(2, 2))
            ! add the average of the two spawn matrix elements (as this is what is used
            ! in the energy calculation + dynamics)
            kmatProjEContrib(ind) = &
                kMatProjEContrib(ind) + sum(sgn) / inum_runs * &
                0.5 * (kMat(ind) + kMat(UMatInd(id(1, 2), id(1, 1), id(2, 2), id(2, 1))))
        end if
        ! check the spin, do we have an exchange contribution?
        if (tReltvy .or. ((G1(ex(1, 1))%Ms == G1(ex(2, 2))%Ms) .and. &
                          (G1(ex(1, 2))%Ms == G1(Ex(2, 1))%Ms))) then
            ind = UMatInd(id(1, 1), id(1, 2), id(2, 2), id(2, 1))
            kmatProjEContrib(ind) = &
                kMatProjEContrib(ind) - sum(sgn) / inum_runs * &
                0.5 * (kMat(ind) + kMat(UMatInd(id(1, 2), id(1, 1), id(2, 1), id(2, 2))))
        end if
    end subroutine addProjEContrib