4
1
mirror of https://github.com/pfloos/quack synced 2024-06-02 11:25:28 +02:00
quack/src/GW/RG0W0.f90

255 lines
7.8 KiB
Fortran
Raw Normal View History

2023-11-13 17:39:30 +01:00
subroutine RG0W0(dotest,doACFDT,exchange_kernel,doXBS,dophBSE,dophBSE2,TDA_W,TDA,dBSE,dTDA,doppBSE,singlet,triplet, &
2023-11-09 09:03:56 +01:00
linearize,eta,regularize,nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,dipole_int,eHF)
2021-03-27 15:04:18 +01:00
! Perform G0W0 calculation
implicit none
include 'parameters.h'
include 'quadrature.h'
! Input variables
2023-11-13 17:39:30 +01:00
logical,intent(in) :: dotest
2021-03-27 15:04:18 +01:00
logical,intent(in) :: doACFDT
logical,intent(in) :: exchange_kernel
logical,intent(in) :: doXBS
logical,intent(in) :: dophBSE
logical,intent(in) :: dophBSE2
logical,intent(in) :: doppBSE
2021-03-27 15:04:18 +01:00
logical,intent(in) :: TDA_W
logical,intent(in) :: TDA
logical,intent(in) :: dBSE
logical,intent(in) :: dTDA
logical,intent(in) :: singlet
logical,intent(in) :: triplet
logical,intent(in) :: linearize
double precision,intent(in) :: eta
2021-12-17 11:41:40 +01:00
logical,intent(in) :: regularize
2021-03-27 15:04:18 +01:00
2021-10-18 10:10:54 +02: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
2021-03-27 15:04:18 +01:00
double precision,intent(in) :: ENuc
double precision,intent(in) :: ERHF
2023-07-23 23:10:57 +02:00
double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas)
2021-03-27 15:04:18 +01:00
double precision,intent(in) :: dipole_int(nBas,nBas,ncart)
double precision,intent(in) :: eHF(nBas)
! Local variables
logical :: print_W = .true.
logical :: dRPA
2021-03-27 15:04:18 +01:00
integer :: ispin
double precision :: EcRPA
double precision :: EcBSE(nspin)
double precision :: EcGM
double precision,allocatable :: Aph(:,:)
double precision,allocatable :: Bph(:,:)
2021-03-27 15:04:18 +01:00
double precision,allocatable :: SigC(:)
double precision,allocatable :: Z(:)
double precision,allocatable :: Om(:)
double precision,allocatable :: XpY(:,:)
double precision,allocatable :: XmY(:,:)
double precision,allocatable :: rho(:,:,:)
2021-03-27 15:04:18 +01:00
2023-09-07 14:01:58 +02:00
double precision,allocatable :: eGWlin(:)
2023-07-17 13:35:24 +02:00
double precision,allocatable :: eGW(:)
2022-09-09 21:48:50 +02:00
2021-03-27 15:04:18 +01:00
! Output variables
! Hello world
write(*,*)
2023-11-09 17:04:15 +01:00
write(*,*)'*******************************'
write(*,*)'* Restricted G0W0 Calculation *'
write(*,*)'*******************************'
2021-03-27 15:04:18 +01:00
write(*,*)
! Initialization
dRPA = .true.
2021-03-27 15:04:18 +01:00
EcRPA = 0d0
! TDA for W
if(TDA_W) then
write(*,*) 'Tamm-Dancoff approximation for dynamic screening!'
write(*,*)
end if
! TDA
if(TDA) then
write(*,*) 'Tamm-Dancoff approximation activated!'
write(*,*)
end if
! Spin manifold
ispin = 1
! Memory allocation
2023-09-07 14:01:58 +02:00
allocate(Aph(nS,nS),Bph(nS,nS),SigC(nBas),Z(nBas),Om(nS),XpY(nS,nS),XmY(nS,nS),rho(nBas,nBas,nS), &
eGW(nBas),eGWlin(nBas))
2021-03-27 15:04:18 +01:00
!-------------------!
! Compute screening !
!-------------------!
2023-07-23 23:10:57 +02:00
call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,eHF,ERI,Aph)
if(.not.TDA_W) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph)
call phLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY)
2021-03-27 15:04:18 +01:00
2023-11-22 10:07:23 +01:00
if(print_W) call print_excitation_energies('phRPA@RHF','singlet',nS,Om)
2021-03-27 15:04:18 +01:00
!--------------------------!
! Compute spectral weights !
!--------------------------!
2023-07-23 23:10:57 +02:00
call GW_excitation_density(nBas,nC,nO,nR,nS,ERI,XpY,rho)
2021-03-27 15:04:18 +01:00
!------------------------!
! Compute GW self-energy !
!------------------------!
if(regularize) call GW_regularization(nBas,nC,nO,nV,nR,nS,eHF,Om,rho)
2021-03-27 15:04:18 +01:00
2023-08-01 16:30:41 +02:00
call GW_self_energy_diag(eta,nBas,nC,nO,nV,nR,nS,eHF,Om,rho,EcGM,SigC,Z)
2021-03-27 15:04:18 +01:00
!-----------------------------------!
! Solve the quasi-particle equation !
!-----------------------------------!
! Linearized or graphical solution?
2023-09-07 14:01:58 +02:00
eGWlin(:) = eHF(:) + Z(:)*SigC(:)
2021-03-27 15:04:18 +01:00
if(linearize) then
write(*,*) ' *** Quasiparticle energies obtained by linearization *** '
write(*,*)
2023-09-07 14:01:58 +02:00
eGW(:) = eGWlin(:)
2021-03-27 15:04:18 +01:00
else
2023-11-27 10:17:14 +01:00
write(*,*) ' *** Quasiparticle energies obtained by root search *** '
2021-03-27 15:04:18 +01:00
write(*,*)
2023-10-02 21:37:25 +02:00
call GW_QP_graph(eta,nBas,nC,nO,nV,nR,nS,eHF,Om,rho,eGWlin,eHF,eGW,Z)
2021-03-27 15:04:18 +01:00
end if
2024-01-29 17:20:57 +01:00
! Plot self-energy, renormalization factor, and spectral function
2024-01-30 12:06:21 +01:00
call GW_plot_self_energy(nBas,eta,nC,nO,nV,nR,nS,eHF,eHF,Om,rho)
2024-01-29 17:20:57 +01:00
2024-01-18 17:38:05 +01:00
!--------------------!
! Cumulant expansion !
!--------------------!
2024-01-18 11:53:02 +01:00
2024-01-31 23:15:13 +01:00
call RGWC(dotest,eta,nBas,nC,nO,nV,nR,nS,Om,rho,eHF,eHF,eGW,Z)
2023-08-24 00:02:23 +02:00
2021-03-27 15:04:18 +01:00
! Compute the RPA correlation energy
2023-07-23 23:10:57 +02:00
call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,eGW,ERI,Aph)
if(.not.TDA_W) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph)
call phLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY)
2021-03-27 15:04:18 +01:00
!--------------!
! Dump results !
!--------------!
2024-01-18 11:53:20 +01:00
call print_RG0W0(nBas,nO,eHF,ENuc,ERHF,SigC,Z,eGW,EcRPA,EcGM)
2024-01-17 18:40:21 +01:00
2021-03-27 15:04:18 +01:00
! Perform BSE calculation
if(dophBSE) then
2021-03-27 15:04:18 +01:00
2023-07-23 23:10:57 +02:00
call GW_phBSE(dophBSE2,TDA_W,TDA,dBSE,dTDA,singlet,triplet,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eHF,eGW,EcBSE)
2021-03-27 15:04:18 +01:00
if(exchange_kernel) then
EcBSE(1) = 0.5d0*EcBSE(1)
EcBSE(2) = 1.5d0*EcBSE(2)
end if
write(*,*)
write(*,*)'-------------------------------------------------------------------------------'
2023-11-27 23:25:10 +01:00
write(*,'(2X,A50,F20.10,A3)') 'Tr@BSE@G0W0@RHF correlation energy (singlet) = ',EcBSE(1),' au'
write(*,'(2X,A50,F20.10,A3)') 'Tr@BSE@G0W0@RHF correlation energy (triplet) = ',EcBSE(2),' au'
write(*,'(2X,A50,F20.10,A3)') 'Tr@BSE@G0W0@RHF correlation energy = ',sum(EcBSE),' au'
write(*,'(2X,A50,F20.10,A3)') 'Tr@BSE@G0W0@RHF total energy = ',ENuc + ERHF + sum(EcBSE),' au'
2021-03-27 15:04:18 +01:00
write(*,*)'-------------------------------------------------------------------------------'
write(*,*)
! Compute the BSE correlation energy via the adiabatic connection
if(doACFDT) then
2021-09-09 15:10:19 +02:00
write(*,*) '-------------------------------------------------------------'
write(*,*) ' Adiabatic connection version of BSE@G0W0 correlation energy '
write(*,*) '-------------------------------------------------------------'
2021-03-27 15:04:18 +01:00
write(*,*)
if(doXBS) then
write(*,*) '*** scaled screening version (XBS) ***'
write(*,*)
end if
2023-07-23 23:10:57 +02:00
call GW_phACFDT(exchange_kernel,doXBS,dRPA,TDA_W,TDA,dophBSE,singlet,triplet,eta,nBas,nC,nO,nV,nR,nS,ERI,eHF,eGW,EcBSE)
2021-03-27 15:04:18 +01:00
write(*,*)
write(*,*)'-------------------------------------------------------------------------------'
2023-11-27 23:25:10 +01:00
write(*,'(2X,A50,F20.10,A3)') 'AC@phBSE@G0W0@RHF correlation energy (singlet) = ',EcBSE(1),' au'
write(*,'(2X,A50,F20.10,A3)') 'AC@phBSE@G0W0@RHF correlation energy (triplet) = ',EcBSE(2),' au'
write(*,'(2X,A50,F20.10,A3)') 'AC@phBSE@G0W0@RHF correlation energy = ',sum(EcBSE),' au'
write(*,'(2X,A50,F20.10,A3)') 'AC@phBSE@G0W0@RHF total energy = ',ENuc + ERHF + sum(EcBSE),' au'
2021-03-27 15:04:18 +01:00
write(*,*)'-------------------------------------------------------------------------------'
write(*,*)
end if
end if
if(doppBSE) then
2022-08-17 14:32:14 +02:00
2023-07-24 22:34:52 +02:00
call GW_ppBSE(TDA_W,TDA,dBSE,dTDA,singlet,triplet,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eHF,eGW,EcBSE)
2022-08-17 14:32:14 +02:00
2023-11-27 23:25:10 +01:00
EcBSE(2) = 3d0*EcBSE(2)
2022-08-17 14:32:14 +02:00
write(*,*)
write(*,*)'-------------------------------------------------------------------------------'
2023-11-27 23:25:10 +01:00
write(*,'(2X,A50,F20.10,A3)') 'Tr@ppBSE@G0W0@RHF correlation energy (singlet) = ',EcBSE(1),' au'
write(*,'(2X,A50,F20.10,A3)') 'Tr@ppBSE@G0W0@RHF correlation energy (triplet) = ',EcBSE(2),' au'
write(*,'(2X,A50,F20.10,A3)') 'Tr@ppBSE@G0W0@RHF correlation energy = ',sum(EcBSE),' au'
write(*,'(2X,A50,F20.10,A3)') 'Tr@ppBSE@G0W0@RHF total energy = ',ENuc + ERHF + sum(EcBSE),' au'
2022-08-17 14:32:14 +02:00
write(*,*)'-------------------------------------------------------------------------------'
write(*,*)
end if
2023-12-03 18:47:30 +01:00
! end if
2023-11-13 17:39:30 +01:00
! Testing zone
if(dotest) then
2023-11-14 14:31:27 +01:00
call dump_test_value('R','G0W0 correlation energy',EcRPA)
call dump_test_value('R','G0W0 HOMO energy',eGW(nO))
call dump_test_value('R','G0W0 LUMO energy',eGW(nO+1))
2023-11-13 17:39:30 +01:00
end if
2023-07-04 10:44:20 +02:00
end subroutine