# exchange_contrib_ksym Function

## private function exchange_contrib_ksym(nI, J, p, q, a, spin)

### Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nI(:)
real(kind=dp), intent(in) :: J
type(Symmetry), intent(in) :: p
type(Symmetry), intent(in) :: q
type(Symmetry), intent(in) :: a
integer, intent(in) :: spin

## Source Code

    HElement_t(dp) function exchange_contrib_ksym(nI, J, p, q, a, spin)
! sym-symbol version of above!
! BUT here: p and q are the symbols of the electrons and q is the
! symbol of 1 hole! so i have to call this function also for the
! exchanged version!
integer, intent(in) :: nI(:), spin
real(dp), intent(in) :: J
type(symmetry), intent(in) :: p, q, a
#ifdef DEBUG_
character(*), parameter :: this_routine = "exchange_contrib_ksym"
#endif
type(symmetry) :: k1, k2

ASSERT(spin == -1 .or. spin == 1)

k1 = SymTable(p%s, q%s)
! the subtraction has something to do with the inputted spin!!
! todo
! spin is chosen from p momentum! so a is the p-k = a hole
! and we need the dipersion of p-k - q = a - q
k2 = SymTable(a%s, SymConjTab(q%s))

exchange_contrib_ksym = 2.0_dp * real(bhub, dp) * (cosh(J) - 1.0_dp) / real(omega, dp) &
* (get_one_body_diag(nI, -spin, k1, .true.) + get_one_body_diag(nI, -spin, k2))

end function exchange_contrib_ksym