4
1
mirror of https://github.com/pfloos/quack synced 2024-06-26 15:12:17 +02:00
quack/src/QuAcK/G0T0.f90

276 lines
9.6 KiB
Fortran
Raw Normal View History

2020-06-14 21:20:01 +02:00
subroutine G0T0(doACFDT,exchange_kernel,doXBS,BSE,TDA_W,TDA,dBSE,dTDA,evDyn,singlet_manifold,triplet_manifold, &
2020-04-16 17:02:01 +02:00
linearize,eta,nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,eHF,eG0T0)
2019-10-16 18:14:47 +02:00
2020-03-14 23:00:44 +01:00
! Perform one-shot calculation with a T-matrix self-energy (G0T0)
2019-10-16 18:14:47 +02:00
implicit none
include 'parameters.h'
! Input variables
2020-03-21 21:09:48 +01:00
logical,intent(in) :: doACFDT
logical,intent(in) :: exchange_kernel
logical,intent(in) :: doXBS
logical,intent(in) :: BSE
2020-06-09 21:24:37 +02:00
logical,intent(in) :: TDA_W
2020-03-21 21:09:48 +01:00
logical,intent(in) :: TDA
2020-06-14 21:20:01 +02:00
logical,intent(in) :: dBSE
2020-06-14 13:04:16 +02:00
logical,intent(in) :: dTDA
2020-06-14 21:20:01 +02:00
logical,intent(in) :: evDyn
2020-03-21 21:09:48 +01:00
logical,intent(in) :: singlet_manifold
logical,intent(in) :: triplet_manifold
logical,intent(in) :: linearize
2019-10-16 18:14:47 +02:00
double precision,intent(in) :: eta
2020-03-21 21:09:48 +01:00
integer,intent(in) :: nBas
integer,intent(in) :: nC
integer,intent(in) :: nO
integer,intent(in) :: nV
integer,intent(in) :: nR
integer,intent(in) :: nS
2019-10-16 18:14:47 +02:00
double precision,intent(in) :: ENuc
double precision,intent(in) :: ERHF
double precision,intent(in) :: eHF(nBas)
double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas)
! Local variables
2019-10-18 23:16:37 +02:00
integer :: ispin
2020-04-13 11:33:48 +02:00
integer :: iblock
2019-10-20 08:18:58 +02:00
integer :: nOOs,nOOt
integer :: nVVs,nVVt
2020-04-09 14:31:50 +02:00
double precision :: dERI
double precision :: xERI
2020-04-13 11:33:48 +02:00
double precision :: alpha
2019-10-16 18:14:47 +02:00
double precision :: EcRPA(nspin)
double precision :: EcBSE(nspin)
2020-03-21 21:09:48 +01:00
double precision :: EcAC(nspin)
2019-10-20 08:18:58 +02:00
double precision,allocatable :: Omega1s(:),Omega1t(:)
double precision,allocatable :: X1s(:,:),X1t(:,:)
double precision,allocatable :: Y1s(:,:),Y1t(:,:)
double precision,allocatable :: rho1s(:,:,:),rho1t(:,:,:)
double precision,allocatable :: Omega2s(:),Omega2t(:)
double precision,allocatable :: X2s(:,:),X2t(:,:)
double precision,allocatable :: Y2s(:,:),Y2t(:,:)
double precision,allocatable :: rho2s(:,:,:),rho2t(:,:,:)
2019-10-18 23:16:37 +02:00
double precision,allocatable :: SigT(:)
double precision,allocatable :: Z(:)
2019-10-16 18:14:47 +02:00
2020-03-21 21:09:48 +01:00
double precision,allocatable :: Omega(:,:)
double precision,allocatable :: XpY(:,:,:)
double precision,allocatable :: XmY(:,:,:)
double precision,allocatable :: rho(:,:,:,:)
2020-03-11 16:41:20 +01:00
! Output variables
2019-10-16 18:14:47 +02:00
2020-04-16 17:02:01 +02:00
double precision,intent(out) :: eG0T0(nBas)
2019-10-16 18:14:47 +02:00
! Hello world
write(*,*)
write(*,*)'************************************************'
write(*,*)'| One-shot G0T0 calculation |'
write(*,*)'************************************************'
write(*,*)
2020-04-09 14:31:50 +02:00
! Dimensions of the pp-RPA linear reponse matrices
2019-10-16 18:14:47 +02:00
2020-04-13 11:33:48 +02:00
nOOs = nO*nO
nVVs = nV*nV
! nOOs = nO*(nO + 1)/2
! nVVs = nV*(nV + 1)/2
2019-10-16 18:14:47 +02:00
2019-10-28 16:34:09 +01:00
nOOt = nO*(nO - 1)/2
nVVt = nV*(nV - 1)/2
2019-10-18 23:16:37 +02:00
2019-10-16 18:14:47 +02:00
! Memory allocation
2019-10-20 08:18:58 +02:00
allocate(Omega1s(nVVs),X1s(nVVs,nVVs),Y1s(nOOs,nVVs), &
Omega2s(nOOs),X2s(nVVs,nOOs),Y2s(nOOs,nOOs), &
2020-03-14 23:00:44 +01:00
rho1s(nBas,nO,nVVs),rho2s(nBas,nV,nOOs), &
2019-10-20 08:18:58 +02:00
Omega1t(nVVt),X1t(nVVt,nVVt),Y1t(nOOt,nVVt), &
2019-10-28 16:34:09 +01:00
Omega2t(nOOt),X2t(nVVt,nOOt),Y2t(nOOt,nOOt), &
2020-03-14 23:00:44 +01:00
rho1t(nBas,nO,nVVt),rho2t(nBas,nV,nOOt), &
2020-04-16 17:02:01 +02:00
SigT(nBas),Z(nBas))
2019-10-16 18:14:47 +02:00
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2020-04-13 11:33:48 +02:00
! alpha-beta block
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2020-04-13 11:33:48 +02:00
ispin = 1
iblock = 3
2019-10-20 08:18:58 +02:00
2019-10-16 18:14:47 +02:00
! Compute linear response
2020-04-13 11:33:48 +02:00
call linear_response_pp(iblock,.true.,.false.,nBas,nC,nO,nV,nR,nOOs,nVVs,eHF(:),ERI(:,:,:,:), &
Omega1s(:),X1s(:,:),Y1s(:,:),Omega2s(:),X2s(:,:),Y2s(:,:),EcRPA(ispin))
2019-10-16 18:14:47 +02:00
2020-04-13 23:05:19 +02:00
! EcRPA(ispin) = 1d0*EcRPA(ispin)
2020-03-19 10:21:18 +01:00
2020-04-13 23:05:19 +02:00
! call print_excitation('pp-RPA (N+2)',iblock,nVVs,Omega1s(:))
! call print_excitation('pp-RPA (N-2)',iblock,nOOs,Omega2s(:))
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2020-04-13 11:33:48 +02:00
! alpha-alpha block
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2020-04-13 11:33:48 +02:00
ispin = 2
iblock = 4
2019-10-20 08:18:58 +02:00
2019-10-28 16:34:09 +01:00
! Compute linear response
2019-10-16 18:14:47 +02:00
2020-04-13 11:33:48 +02:00
call linear_response_pp(iblock,.true.,.false.,nBas,nC,nO,nV,nR,nOOt,nVVt,eHF(:),ERI(:,:,:,:), &
Omega1t(:),X1t(:,:),Y1t(:,:),Omega2t(:),X2t(:,:),Y2t(:,:),EcRPA(ispin))
2019-10-20 08:18:58 +02:00
2020-04-13 23:05:19 +02:00
! EcRPA(ispin) = 2d0*EcRPA(ispin)
2020-04-13 11:33:48 +02:00
! EcRPA(ispin) = 3d0*EcRPA(ispin)
2020-03-19 10:21:18 +01:00
2020-04-13 23:05:19 +02:00
! call print_excitation('pp-RPA (N+2)',iblock,nVVt,Omega1t(:))
! call print_excitation('pp-RPA (N-2)',iblock,nOOt,Omega2t(:))
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2019-10-16 18:14:47 +02:00
! Compute T-matrix version of the self-energy
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2019-10-16 18:14:47 +02:00
2020-04-09 14:31:50 +02:00
SigT(:) = 0d0
2020-04-13 11:33:48 +02:00
Z(:) = 0d0
2020-04-09 14:31:50 +02:00
2020-04-13 11:33:48 +02:00
iblock = 3
dERI = +1d0
xERI = +0d0
alpha = +1d0
2020-04-09 14:31:50 +02:00
2020-04-13 11:33:48 +02:00
call excitation_density_Tmatrix(iblock,dERI,xERI,nBas,nC,nO,nV,nR,nOOs,nVVs,ERI(:,:,:,:), &
X1s(:,:),Y1s(:,:),rho1s(:,:,:),X2s(:,:),Y2s(:,:),rho2s(:,:,:))
2020-04-09 14:31:50 +02:00
2020-04-13 11:33:48 +02:00
call self_energy_Tmatrix_diag(alpha,eta,nBas,nC,nO,nV,nR,nOOs,nVVs,eHF(:), &
Omega1s(:),rho1s(:,:,:),Omega2s(:),rho2s(:,:,:),SigT(:))
2020-04-09 14:31:50 +02:00
2020-04-13 11:33:48 +02:00
call renormalization_factor_Tmatrix(alpha,eta,nBas,nC,nO,nV,nR,nOOs,nVVs,eHF(:), &
Omega1s(:),rho1s(:,:,:),Omega2s(:),rho2s(:,:,:),Z(:))
2020-04-09 14:31:50 +02:00
2020-04-13 11:33:48 +02:00
iblock = 4
dERI = +1d0
xERI = -1d0
alpha = +1d0
2020-04-09 14:31:50 +02:00
2020-04-13 11:33:48 +02:00
call excitation_density_Tmatrix(iblock,dERI,xERI,nBas,nC,nO,nV,nR,nOOt,nVVt,ERI(:,:,:,:), &
2020-04-09 14:31:50 +02:00
X1t(:,:),Y1t(:,:),rho1t(:,:,:),X2t(:,:),Y2t(:,:),rho2t(:,:,:))
2020-04-13 11:33:48 +02:00
call self_energy_Tmatrix_diag(alpha,eta,nBas,nC,nO,nV,nR,nOOt,nVVt,eHF(:), &
2020-04-09 14:31:50 +02:00
Omega1t(:),rho1t(:,:,:),Omega2t(:),rho2t(:,:,:),SigT(:))
2020-04-13 11:33:48 +02:00
call renormalization_factor_Tmatrix(alpha,eta,nBas,nC,nO,nV,nR,nOOt,nVVt,eHF(:), &
Omega1t(:),rho1t(:,:,:),Omega2t(:),rho2t(:,:,:),Z(:))
2019-10-16 18:14:47 +02:00
2020-04-13 11:33:48 +02:00
Z(:) = 1d0/(1d0 - Z(:))
2019-10-16 18:14:47 +02:00
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2019-10-16 18:14:47 +02:00
! Solve the quasi-particle equation
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2019-10-16 18:14:47 +02:00
2020-03-21 21:09:48 +01:00
if(linearize) then
eG0T0(:) = eHF(:) + Z(:)*SigT(:)
else
eG0T0(:) = eHF(:) + SigT(:)
end if
2019-10-16 18:14:47 +02:00
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2019-10-16 18:14:47 +02:00
! Dump results
2019-10-20 08:18:58 +02:00
!----------------------------------------------
2019-10-16 18:14:47 +02:00
2019-10-20 08:18:58 +02:00
call print_G0T0(nBas,nO,eHF(:),ENuc,ERHF,SigT(:),Z(:),eG0T0(:),EcRPA(:))
2019-10-16 18:14:47 +02:00
2020-04-13 14:19:14 +02:00
! Compute the ppRPA correlation energy
2020-04-13 23:05:19 +02:00
ispin = 1
iblock = 3
call linear_response_pp(iblock,.false.,.false.,nBas,nC,nO,nV,nR,nOOs,nVVs,eG0T0(:),ERI(:,:,:,:), &
Omega1s(:),X1s(:,:),Y1s(:,:),Omega2s(:),X2s(:,:),Y2s(:,:),EcRPA(ispin))
ispin = 2
iblock = 4
call linear_response_pp(iblock,.false.,.false.,nBas,nC,nO,nV,nR,nOOt,nVVt,eG0T0(:),ERI(:,:,:,:), &
Omega1t(:),X1t(:,:),Y1t(:,:),Omega2t(:),X2t(:,:),Y2t(:,:),EcRPA(ispin))
EcRPA(1) = EcRPA(1) - EcRPA(2)
EcRPA(2) = 3d0*EcRPA(2)
2020-04-13 14:19:14 +02:00
write(*,*)
write(*,*)'-------------------------------------------------------------------------------'
2020-04-13 22:56:49 +02:00
write(*,'(2X,A50,F20.10)') 'Tr@RPA@G0T0 correlation energy (singlet) =',EcRPA(1)
write(*,'(2X,A50,F20.10)') 'Tr@RPA@G0T0 correlation energy (triplet) =',EcRPA(2)
write(*,'(2X,A50,F20.10)') 'Tr@RPA@G0T0 correlation energy =',EcRPA(1) + EcRPA(2)
write(*,'(2X,A50,F20.10)') 'Tr@RPA@G0T0 total energy =',ENuc + ERHF + EcRPA(1) + EcRPA(2)
2020-04-13 14:19:14 +02:00
write(*,*)'-------------------------------------------------------------------------------'
write(*,*)
2020-03-21 21:09:48 +01:00
! Perform BSE calculation
if(BSE) then
allocate(Omega(nS,nspin),XpY(nS,nS,nspin),XmY(nS,nS,nspin),rho(nBas,nBas,nS,nspin))
2020-06-14 21:20:01 +02:00
call Bethe_Salpeter(TDA_W,TDA,dBSE,dTDA,evDyn,singlet_manifold,triplet_manifold,eta, &
2020-03-21 21:09:48 +01:00
nBas,nC,nO,nV,nR,nS,ERI,eHF,eG0T0,Omega,XpY,XmY,rho,EcRPA,EcBSE)
if(exchange_kernel) then
EcRPA(1) = 0.5d0*EcRPA(1)
EcRPA(2) = 1.5d0*EcRPA(1)
end if
write(*,*)
write(*,*)'-------------------------------------------------------------------------------'
write(*,'(2X,A50,F20.10)') 'Tr@BSE@G0T0 correlation energy (singlet) =',EcBSE(1)
write(*,'(2X,A50,F20.10)') 'Tr@BSE@G0T0 correlation energy (triplet) =',EcBSE(2)
write(*,'(2X,A50,F20.10)') 'Tr@BSE@G0T0 correlation energy =',EcBSE(1) + EcBSE(2)
write(*,'(2X,A50,F20.10)') 'Tr@BSE@G0T0 total energy =',ENuc + ERHF + EcBSE(1) + EcBSE(2)
write(*,*)'-------------------------------------------------------------------------------'
write(*,*)
! Compute the BSE correlation energy via the adiabatic connection
if(doACFDT) then
write(*,*) '------------------------------------------------------'
write(*,*) 'Adiabatic connection version of BSE correlation energy'
write(*,*) '------------------------------------------------------'
write(*,*)
if(doXBS) then
write(*,*) '*** scaled screening version (XBS) ***'
write(*,*)
end if
2020-06-09 21:24:37 +02:00
call ACFDT(exchange_kernel,doXBS,.true.,TDA_W,TDA,BSE,singlet_manifold,triplet_manifold,eta, &
2020-03-21 21:09:48 +01:00
nBas,nC,nO,nV,nR,nS,ERI,eHF,eG0T0,Omega,XpY,XmY,rho,EcAC)
if(exchange_kernel) then
EcAC(1) = 0.5d0*EcAC(1)
EcAC(2) = 1.5d0*EcAC(1)
end if
write(*,*)
write(*,*)'-------------------------------------------------------------------------------'
write(*,'(2X,A50,F20.10)') 'AC@BSE@G0T0 correlation energy (singlet) =',EcAC(1)
write(*,'(2X,A50,F20.10)') 'AC@BSE@G0T0 correlation energy (triplet) =',EcAC(2)
write(*,'(2X,A50,F20.10)') 'AC@BSE@G0T0 correlation energy =',EcAC(1) + EcAC(2)
write(*,'(2X,A50,F20.10)') 'AC@BSE@G0T0 total energy =',ENuc + ERHF + EcAC(1) + EcAC(2)
write(*,*)'-------------------------------------------------------------------------------'
write(*,*)
end if
end if
2019-10-16 18:14:47 +02:00
end subroutine G0T0