4
1
mirror of https://github.com/pfloos/quack synced 2024-06-23 21:52:20 +02:00
quack/src/RPA/linear_response_C_pp.f90

100 lines
2.1 KiB
Fortran
Raw Normal View History

2019-10-07 22:31:45 +02:00
subroutine linear_response_C_pp(ispin,nBas,nC,nO,nV,nR,nOO,nVV,e,ERI,C_pp)
2019-10-05 22:06:25 +02:00
! Compute the C matrix of the pp channel
implicit none
include 'parameters.h'
! Input variables
integer,intent(in) :: ispin
integer,intent(in) :: nBas,nC,nO,nV,nR,nOO,nVV
double precision,intent(in) :: e(nBas),ERI(nBas,nBas,nBas,nBas)
! Local variables
2019-10-06 20:08:38 +02:00
double precision :: eF
2019-10-05 22:06:25 +02:00
double precision,external :: Kronecker_delta
integer :: a,b,c,d,ab,cd
! Output variables
double precision,intent(out) :: C_pp(nVV,nVV)
2019-10-07 22:31:45 +02:00
! Define the chemical potential
eF = e(nO) + e(nO+1)
2020-04-16 17:02:01 +02:00
! eF = 0d0
2019-10-07 22:31:45 +02:00
! Build C matrix for the singlet manifold
2019-10-05 22:06:25 +02:00
2019-10-07 22:31:45 +02:00
if(ispin == 1) then
2019-10-05 22:06:25 +02:00
2019-10-07 22:31:45 +02:00
ab = 0
do a=nO+1,nBas-nR
2020-03-19 10:21:18 +01:00
do b=a,nBas-nR
2019-10-07 22:31:45 +02:00
ab = ab + 1
cd = 0
do c=nO+1,nBas-nR
2020-03-19 10:21:18 +01:00
do d=c,nBas-nR
2019-10-07 22:31:45 +02:00
cd = cd + 1
C_pp(ab,cd) = + (e(a) + e(b) - eF)*Kronecker_delta(a,c)*Kronecker_delta(b,d) &
+ (ERI(a,b,c,d) + ERI(a,b,d,c))/sqrt((1d0 + Kronecker_delta(a,b))*(1d0 + Kronecker_delta(c,d)))
end do
end do
end do
end do
2019-10-05 22:06:25 +02:00
2019-10-07 22:31:45 +02:00
end if
2019-10-05 22:06:25 +02:00
2020-04-13 11:33:48 +02:00
! Build C matrix for the triplet manifold, or alpha-alpha block, or in the spin-orbital basis
2019-10-07 22:31:45 +02:00
2020-04-13 11:33:48 +02:00
if(ispin == 2 .or. ispin == 4) then
2019-10-07 22:31:45 +02:00
ab = 0
do a=nO+1,nBas-nR
2020-03-19 10:21:18 +01:00
do b=a+1,nBas-nR
2019-10-07 22:31:45 +02:00
ab = ab + 1
cd = 0
do c=nO+1,nBas-nR
2020-03-19 10:21:18 +01:00
do d=c+1,nBas-nR
2019-10-07 22:31:45 +02:00
cd = cd + 1
2019-10-05 22:06:25 +02:00
2019-10-07 22:31:45 +02:00
C_pp(ab,cd) = + (e(a) + e(b) - eF)*Kronecker_delta(a,c)*Kronecker_delta(b,d) &
+ ERI(a,b,c,d) - ERI(a,b,d,c)
end do
end do
end do
end do
2019-10-06 20:08:38 +02:00
2019-10-07 22:31:45 +02:00
end if
2019-10-05 22:06:25 +02:00
2020-04-13 11:33:48 +02:00
! Build the alpha-beta block of the C matrix
2019-10-23 08:22:36 +02:00
if(ispin == 3) then
ab = 0
do a=nO+1,nBas-nR
2020-04-13 11:33:48 +02:00
do b=nO+1,nBas-nR
2019-10-23 08:22:36 +02:00
ab = ab + 1
cd = 0
do c=nO+1,nBas-nR
2020-04-13 11:33:48 +02:00
do d=nO+1,nBas-nR
2019-10-23 08:22:36 +02:00
cd = cd + 1
C_pp(ab,cd) = + (e(a) + e(b) - eF)*Kronecker_delta(a,c)*Kronecker_delta(b,d) &
2020-04-13 11:33:48 +02:00
+ ERI(a,b,c,d)
2019-10-23 08:22:36 +02:00
end do
end do
end do
end do
end if
2019-10-05 22:06:25 +02:00
end subroutine linear_response_C_pp