function get_diag_helemen_rs_hub_transcorr_spin(nI) result(hel)
! the spin-dependent transcorr diagonal elements
integer, intent(in) :: nI(nel)
HElement_t(dp) :: hel
integer :: i, j, id(nel), ri(3), rj(3), ind_1(3), ind_2(3)
hel = 0.0_dp
id = get_spatial(nI)
do i = 1, nel
do j = 1, nel
if (.not. same_spin(nI(i), nI(j))) then
ri = lat%get_r_vec(id(i))
rj = lat%get_r_vec(id(j))
if (is_alpha(nI(i))) then
ind_1 = ri - rj
ind_2 = rj - ri
else
ind_1 = rj - ri
ind_2 = ri - rj
end if
hel = hel + 0.5_dp * hop_transcorr_factor_cached_vec(ind_1(1), ind_1(2), ind_1(3)) * &
hop_transcorr_factor_cached_vec_m(ind_2(1), ind_2(2), ind_2(3)) * uhub
end if
end do
end do
end function get_diag_helemen_rs_hub_transcorr_spin