subroutine gyrotropic_get_NOA_Bnl_orb(eig, del_eig, AA, &
num_occ, occ_list, num_unocc, unocc_list, Bnl)
!====================================================================!
! !
! Calculating the matrix !
! B_{nl,ac}(num_occ,num_unocc,3,3)= !
! -sum_m( (E_m-E_n)A_nma*Amlc +(E_l-E_m)A_nmc*A_mla - !
! -i( del_a (E_n+E_l) A_nlc !
! in units eV*Ang^2 !
!====================================================================!
use w90_constants, only: dp, cmplx_i, cmplx_0
use w90_parameters, only: gyrotropic_num_bands, gyrotropic_band_list
! Arguments
!
integer, intent(in) ::num_occ, num_unocc
integer, dimension(:), intent(in) ::occ_list, unocc_list
real(kind=dp), dimension(:), intent(in) ::eig ! n
real(kind=dp), dimension(:, :), intent(in) ::del_eig ! n
complex(kind=dp), dimension(:, :, :), intent(in) ::AA ! n,l,a
complex(kind=dp), dimension(:, :, :, :), intent(out)::Bnl ! n,l,a,c
integer n, m, l, a, c, n1, m1, l1
Bnl(:, :, :, :) = cmplx_0
do a = 1, 3
do c = 1, 3
do n1 = 1, num_occ
n = occ_list(n1)
do l1 = 1, num_unocc
l = unocc_list(l1)
Bnl(n1, l1, a, c) = -cmplx_i*(del_eig(n, a) + del_eig(l, a))*AA(n, l, c)
do m1 = 1, gyrotropic_num_bands
m = gyrotropic_band_list(m1)
Bnl(n1, l1, a, c) = Bnl(n1, l1, a, c) + &
(eig(n) - eig(m))*AA(n, m, a)*AA(m, l, c) - &
(eig(l) - eig(m))*AA(n, m, c)*AA(m, l, a)
enddo ! m1
enddo !l1
enddo !n1
enddo !c
enddo !a
end subroutine gyrotropic_get_NOA_Bnl_orb