4
1
mirror of https://github.com/pfloos/quack synced 2024-10-30 02:38:27 +01:00
quack/src/LR/phULR_B.f90

169 lines
3.5 KiB
Fortran
Raw Normal View History

2023-07-21 13:04:29 +02:00
subroutine phULR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nSa,nSb,nSt,lambda,ERI_aaaa,ERI_aabb,ERI_bbbb,Bph)
2020-09-22 15:32:26 +02:00
! Compute linear response
implicit none
include 'parameters.h'
! Input variables
logical,intent(in) :: dRPA
integer,intent(in) :: ispin
integer,intent(in) :: nBas
integer,intent(in) :: nC(nspin)
integer,intent(in) :: nO(nspin)
integer,intent(in) :: nV(nspin)
integer,intent(in) :: nR(nspin)
integer,intent(in) :: nSa
integer,intent(in) :: nSb
integer,intent(in) :: nSt
double precision,intent(in) :: lambda
2020-09-22 22:13:51 +02:00
double precision,intent(in) :: ERI_aaaa(nBas,nBas,nBas,nBas)
double precision,intent(in) :: ERI_aabb(nBas,nBas,nBas,nBas)
double precision,intent(in) :: ERI_bbbb(nBas,nBas,nBas,nBas)
2020-09-22 15:32:26 +02:00
! Local variables
double precision :: delta_dRPA
double precision,external :: Kronecker_delta
integer :: i,j,a,b,ia,jb
! Output variables
2023-07-21 13:04:29 +02:00
double precision,intent(out) :: Bph(nSt,nSt)
2020-09-22 15:32:26 +02:00
! Direct RPA
delta_dRPA = 0d0
if(dRPA) delta_dRPA = 1d0
!-----------------------------------------------
2020-09-22 23:46:33 +02:00
! Build B matrix for spin-conserving transitions
2020-09-22 15:32:26 +02:00
!-----------------------------------------------
if(ispin == 1) then
2020-09-22 23:46:33 +02:00
! aaaa block
2020-09-22 15:32:26 +02:00
ia = 0
do i=nC(1)+1,nO(1)
do a=nO(1)+1,nBas-nR(1)
ia = ia + 1
jb = 0
do j=nC(1)+1,nO(1)
do b=nO(1)+1,nBas-nR(1)
jb = jb + 1
2023-07-21 13:04:29 +02:00
Bph(ia,jb) = lambda*ERI_aaaa(i,j,a,b) - (1d0 - delta_dRPA)*lambda*ERI_aaaa(i,j,b,a)
2020-09-22 15:32:26 +02:00
end do
end do
end do
end do
2020-09-22 23:46:33 +02:00
! aabb block
2020-09-22 15:32:26 +02:00
ia = 0
do i=nC(1)+1,nO(1)
do a=nO(1)+1,nBas-nR(1)
ia = ia + 1
jb = 0
do j=nC(2)+1,nO(2)
do b=nO(2)+1,nBas-nR(2)
jb = jb + 1
2023-07-21 13:04:29 +02:00
Bph(ia,nSa+jb) = lambda*ERI_aabb(i,j,a,b)
2020-09-22 15:32:26 +02:00
end do
end do
end do
end do
2020-09-22 23:46:33 +02:00
! bbaa block
2020-09-22 15:32:26 +02:00
ia = 0
do i=nC(2)+1,nO(2)
do a=nO(2)+1,nBas-nR(2)
ia = ia + 1
jb = 0
do j=nC(1)+1,nO(1)
do b=nO(1)+1,nBas-nR(1)
jb = jb + 1
2023-07-21 13:04:29 +02:00
Bph(nSa+ia,jb) = lambda*ERI_aabb(j,i,b,a)
2020-09-22 15:32:26 +02:00
end do
end do
end do
end do
2020-09-22 23:46:33 +02:00
! bbbb block
2020-09-22 15:32:26 +02:00
ia = 0
do i=nC(2)+1,nO(2)
do a=nO(2)+1,nBas-nR(2)
ia = ia + 1
jb = 0
do j=nC(2)+1,nO(2)
do b=nO(2)+1,nBas-nR(2)
jb = jb + 1
2023-07-21 13:04:29 +02:00
Bph(nSa+ia,nSa+jb) = lambda*ERI_bbbb(i,j,a,b) - (1d0 - delta_dRPA)*lambda*ERI_bbbb(i,j,b,a)
2020-09-22 15:32:26 +02:00
end do
end do
end do
end do
end if
2020-09-22 22:13:51 +02:00
!-----------------------------------------------
2020-09-22 23:46:33 +02:00
! Build B matrix for spin-flip transitions
2020-09-22 22:13:51 +02:00
!-----------------------------------------------
if(ispin == 2) then
2023-07-21 13:04:29 +02:00
Bph(:,:) = 0d0
2020-09-22 23:46:33 +02:00
2020-09-23 22:48:54 +02:00
! abba block
2020-09-22 23:46:33 +02:00
ia = 0
do i=nC(1)+1,nO(1)
do a=nO(2)+1,nBas-nR(2)
ia = ia + 1
jb = 0
do j=nC(2)+1,nO(2)
2020-09-23 22:48:54 +02:00
do b=nO(1)+1,nBas-nR(1)
2020-09-22 23:46:33 +02:00
jb = jb + 1
2023-07-21 13:04:29 +02:00
Bph(ia,nSa+jb) = - (1d0 - delta_dRPA)*lambda*ERI_aabb(i,j,b,a)
2020-09-22 23:46:33 +02:00
end do
end do
end do
end do
2020-09-23 22:48:54 +02:00
! baab block
2020-09-22 23:46:33 +02:00
ia = 0
do i=nC(2)+1,nO(2)
do a=nO(1)+1,nBas-nR(1)
ia = ia + 1
jb = 0
2020-09-23 22:48:54 +02:00
do j=nC(1)+1,nO(1)
do b=nO(2)+1,nBas-nR(2)
2020-09-22 23:46:33 +02:00
jb = jb + 1
2023-07-21 13:04:29 +02:00
Bph(nSa+ia,jb) = - (1d0 - delta_dRPA)*lambda*ERI_aabb(j,i,a,b)
2020-09-22 23:46:33 +02:00
end do
end do
end do
end do
2020-09-22 22:13:51 +02:00
end if
2020-09-22 15:32:26 +02:00
2023-07-21 13:04:29 +02:00
end subroutine