function get_hdiag_from_sing_excit(nI, ex, hel_old) result(hel)
! Calculate the by the SlaterCondon Rules when the two
! determinants are the same (so we only need to specify one).
integer, intent(in) :: nI(nel), ex(2)
real(dp), intent(in) :: hel_old
HElement_t(dp) :: hel
integer :: id(nel), id_ex(2), i
! Correct one electron integral contribution
hel = hel_old - GetTMATEl(ex(1), ex(1)) + GetTMATEl(ex(2), ex(2))
! Obtain the spatial rather than spin indices if required
id = gtID(nI)
id_ex = gtID(ex)
do i = 1, nel
if (nI(i) /= ex(1)) then
hel = hel - get_umat_el(id_ex(1), id(i), id_ex(1), id(i)) &
+ get_umat_el(id_ex(2), id(i), id_ex(2), id(i))
if (tReltvy .or. (G1(ex(1))%Ms == G1(nI(i))%Ms)) then
hel = hel + get_umat_el(id_ex(1), id(i), id(i), id_ex(1)) &
- get_umat_el(id_ex(2), id(i), id(i), id_ex(2))
end if
end if
end do
end function get_hdiag_from_sing_excit