10
1
mirror of https://github.com/pfloos/quack synced 2024-12-23 12:55:25 +01:00
QuAcK/src/GT/evRGTeh.f90

312 lines
9.5 KiB
Fortran
Raw Normal View History

2023-11-13 18:36:09 +01:00
subroutine evRGTeh(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dophBSE,dophBSE2,TDA_T,TDA,dBSE,dTDA,doppBSE, &
singlet,triplet,linearize,eta,regularize,nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,dipole_int,eHF)
2023-07-03 23:15:07 +02:00
! Perform self-consistent eigenvalue-only ehGT calculation
implicit none
include 'parameters.h'
! Input variables
2023-11-13 18:36:09 +01:00
logical,intent(in) :: dotest
2023-07-03 23:15:07 +02:00
integer,intent(in) :: maxSCF
integer,intent(in) :: max_diis
double precision,intent(in) :: thresh
double precision,intent(in) :: ENuc
double precision,intent(in) :: ERHF
logical,intent(in) :: doACFDT
logical,intent(in) :: exchange_kernel
logical,intent(in) :: doXBS
2023-07-18 22:17:42 +02:00
logical,intent(in) :: dophBSE
logical,intent(in) :: dophBSE2
2023-07-03 23:15:07 +02:00
logical,intent(in) :: TDA_T
logical,intent(in) :: TDA
logical,intent(in) :: dBSE
logical,intent(in) :: dTDA
2023-07-18 22:17:42 +02:00
logical,intent(in) :: doppBSE
2023-07-03 23:15:07 +02:00
logical,intent(in) :: singlet
logical,intent(in) :: triplet
logical,intent(in) :: linearize
double precision,intent(in) :: eta
logical,intent(in) :: regularize
integer,intent(in) :: nBas
integer,intent(in) :: nC
integer,intent(in) :: nO
integer,intent(in) :: nV
integer,intent(in) :: nR
integer,intent(in) :: nS
double precision,intent(in) :: eHF(nBas)
2023-07-30 22:01:44 +02:00
double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas)
2023-07-03 23:15:07 +02:00
double precision,intent(in) :: dipole_int(nBas,nBas,ncart)
! Local variables
2023-08-23 16:04:00 +02:00
logical :: print_T = .true.
logical :: dRPA = .false.
2023-07-03 23:15:07 +02:00
logical :: linear_mixing
integer :: ispin
integer :: nSCF
integer :: n_diis
double precision :: rcond
double precision :: Conv
double precision :: EcRPA
double precision :: EcBSE(nspin)
double precision :: EcGM
double precision :: alpha
2023-07-18 22:17:42 +02:00
double precision,allocatable :: Aph(:,:)
double precision,allocatable :: Bph(:,:)
2023-07-03 23:15:07 +02:00
double precision,allocatable :: error_diis(:,:)
double precision,allocatable :: e_diis(:,:)
double precision,allocatable :: eGT(:)
double precision,allocatable :: eOld(:)
double precision,allocatable :: Z(:)
2023-07-12 14:13:45 +02:00
double precision,allocatable :: Sig(:)
2023-07-18 22:17:42 +02:00
double precision,allocatable :: Om(:)
double precision,allocatable :: XpY(:,:)
double precision,allocatable :: XmY(:,:)
double precision,allocatable :: rhoL(:,:,:)
double precision,allocatable :: rhoR(:,:,:)
2023-07-03 23:15:07 +02:00
! Hello world
write(*,*)
2023-11-13 18:36:09 +01:00
write(*,*)'**********************************'
write(*,*)'* Restricted evRGTeh Calculation *'
write(*,*)'**********************************'
2023-07-03 23:15:07 +02:00
write(*,*)
! TDA for T
if(TDA_T) then
write(*,*) 'Tamm-Dancoff approximation for eh T-matrix!'
write(*,*)
end if
! TDA
if(TDA) then
write(*,*) 'Tamm-Dancoff approximation activated!'
write(*,*)
end if
! Linear mixing
linear_mixing = .false.
alpha = 0.2d0
! Memory allocation
allocate(Aph(nS,nS),Bph(nS,nS),eGT(nBas),eOld(nBas),Z(nBas),Sig(nBas),Om(nS),XpY(nS,nS),XmY(nS,nS), &
2023-07-23 22:03:42 +02:00
rhoL(nBas,nBas,nS),rhoR(nBas,nBas,nS),error_diis(nBas,max_diis),e_diis(nBas,max_diis))
2023-07-03 23:15:07 +02:00
! Initialization
nSCF = 0
2023-07-04 08:29:16 +02:00
ispin = 2
2023-07-03 23:15:07 +02:00
n_diis = 0
Conv = 1d0
e_diis(:,:) = 0d0
error_diis(:,:) = 0d0
2023-07-17 13:35:24 +02:00
eGT(:) = eHF(:)
2023-07-03 23:15:07 +02:00
eOld(:) = eGT(:)
Z(:) = 1d0
rcond = 0d0
!------------------------------------------------------------------------
! Main loop
!------------------------------------------------------------------------
do while(Conv > thresh .and. nSCF <= maxSCF)
! Compute screening
2023-07-30 22:01:44 +02:00
call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,eGT,ERI,Aph)
if(.not.TDA_T) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph)
2023-07-18 22:17:42 +02:00
call phLR(TDA_T,nS,Aph,Bph,EcRPA,Om,XpY,XmY)
2023-07-03 23:15:07 +02:00
2023-11-22 10:07:23 +01:00
if(print_T) call print_excitation_energies('phRPA@RHF','triplet',nS,Om)
2023-08-23 16:04:00 +02:00
2023-07-03 23:15:07 +02:00
! Compute spectral weights
2023-07-30 22:01:44 +02:00
call GTeh_excitation_density(nBas,nC,nO,nR,nS,ERI,XpY,XmY,rhoL,rhoR)
2023-07-03 23:15:07 +02:00
! Compute correlation part of the self-energy
if(regularize) call GTeh_regularization(nBas,nC,nO,nV,nR,nS,eGT,Om,rhoL,rhoR)
2023-07-03 23:15:07 +02:00
2023-08-01 17:00:03 +02:00
call GTeh_self_energy_diag(eta,nBas,nC,nO,nV,nR,nS,eGT,Om,rhoL,rhoR,EcGM,Sig,Z)
2023-07-03 23:15:07 +02:00
! Solve the quasi-particle equation
2023-07-23 22:03:42 +02:00
eGT(:) = eHF(:) + Sig(:)
2023-07-03 23:15:07 +02:00
2023-07-27 17:43:18 +02:00
if(linearize) then
write(*,*) ' *** Quasiparticle energies obtained by linearization *** '
write(*,*)
eGT(:) = eGT(:)
else
2023-11-27 10:17:14 +01:00
write(*,*) ' *** Quasiparticle energies obtained by root search *** '
2023-07-27 17:43:18 +02:00
write(*,*)
2023-10-02 21:41:37 +02:00
call GTeh_QP_graph(eta,nBas,nC,nO,nV,nR,nS,eHF,Om,rhoL,rhoR,eOld,eOld,eGT,Z)
2023-07-27 17:43:18 +02:00
end if
2023-07-03 23:15:07 +02:00
! Convergence criteria
Conv = maxval(abs(eGT - eOld))
! Print results
2023-11-20 17:42:50 +01:00
call print_evRGTeh(nBas,nO,nSCF,Conv,eHF,ENuc,ERHF,Sig,Z,eGT,EcRPA,EcGM)
2023-07-03 23:15:07 +02:00
! Linear mixing or DIIS extrapolation
if(linear_mixing) then
eGT(:) = alpha*eGT(:) + (1d0 - alpha)*eOld(:)
else
n_diis = min(n_diis+1,max_diis)
if(abs(rcond) > 1d-7) then
call DIIS_extrapolation(rcond,nBas,nBas,n_diis,error_diis,e_diis,eGT-eOld,eGT)
else
n_diis = 0
end if
end if
! Save quasiparticles energy for next cycle
eOld(:) = eGT(:)
! Increment
nSCF = nSCF + 1
end do
!------------------------------------------------------------------------
! End main loop
!------------------------------------------------------------------------
! Did it actually converge?
if(nSCF == maxSCF+1) then
write(*,*)
write(*,*)'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
write(*,*)' Convergence failed '
write(*,*)'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
write(*,*)
stop
end if
! Deallocate memory
2023-07-18 22:17:42 +02:00
deallocate(eOld,Z,Sig,Om,XpY,XmY,rhoL,rhoR,error_diis,e_diis)
2023-07-03 23:15:07 +02:00
! Perform BSE calculation
! if(BSE) then
2023-07-30 22:01:44 +02:00
! call Bethe_Salpeter(BSE2,TDA_T,TDA,dBSE,dTDA,singlet,triplet,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eGW,eGW,EcBSE)
2023-07-03 23:15:07 +02:00
! if(exchange_kernel) then
! EcBSE(1) = 0.5d0*EcBSE(1)
! EcBSE(2) = 1.5d0*EcBSE(2)
! end if
! write(*,*)
! write(*,*)'-------------------------------------------------------------------------------'
! write(*,'(2X,A50,F20.10)') 'Tr@BSE@evGW correlation energy (singlet) =',EcBSE(1)
! write(*,'(2X,A50,F20.10)') 'Tr@BSE@evGW correlation energy (triplet) =',EcBSE(2)
! write(*,'(2X,A50,F20.10)') 'Tr@BSE@evGW correlation energy =',EcBSE(1) + EcBSE(2)
! write(*,'(2X,A50,F20.10)') 'Tr@BSE@evGW 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
2023-07-30 22:01:44 +02:00
! call ACFDT(exchange_kernel,doXBS,.true.,TDA_W,TDA,BSE,singlet,triplet,eta,nBas,nC,nO,nV,nR,nS,ERI,eGW,eGW,EcBSE)
2023-07-03 23:15:07 +02:00
! write(*,*)
! write(*,*)'-------------------------------------------------------------------------------'
2023-07-21 12:30:29 +02:00
! write(*,'(2X,A50,F20.10)') 'AC@BSE@evGW correlation energy (singlet) =',EcBSE(1)
! write(*,'(2X,A50,F20.10)') 'AC@BSE@evGW correlation energy (triplet) =',EcBSE(2)
! write(*,'(2X,A50,F20.10)') 'AC@BSE@evGW correlation energy =',EcBSE(1) + EcBSE(2)
! write(*,'(2X,A50,F20.10)') 'AC@BSE@evGW total energy =',ENuc + ERHF + EcBSE(1) + EcBSE(2)
2023-07-03 23:15:07 +02:00
! write(*,*)'-------------------------------------------------------------------------------'
! write(*,*)
! end if
! end if
! if(ppBSE) then
2023-07-30 22:01:44 +02:00
! call Bethe_Salpeter_pp(TDA_W,TDA,singlet,triplet,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eHF,eGW,EcppBSE)
2023-07-03 23:15:07 +02:00
! write(*,*)
! write(*,*)'-------------------------------------------------------------------------------'
! write(*,'(2X,A50,F20.10)') 'Tr@ppBSE@G0W0 correlation energy (singlet) =',EcppBSE(1)
! write(*,'(2X,A50,F20.10)') 'Tr@ppBSE@G0W0 correlation energy (triplet) =',3d0*EcppBSE(2)
! write(*,'(2X,A50,F20.10)') 'Tr@ppBSE@G0W0 correlation energy =',EcppBSE(1) + 3d0*EcppBSE(2)
! write(*,'(2X,A50,F20.10)') 'Tr@ppBSE@G0W0 total energy =',ENuc + ERHF + EcppBSE(1) + 3d0*EcppBSE(2)
! write(*,*)'-------------------------------------------------------------------------------'
! write(*,*)
! nBas2 = 2*nBas
! nO2 = 2*nO
! nV2 = 2*nV
! nC2 = 2*nC
! nR2 = 2*nR
! nS2 = nO2*nV2
!
! allocate(seHF(nBas2),seGW(nBas2),sERI(nBas2,nBas2,nBas2,nBas2))
!
! call spatial_to_spin_MO_energy(nBas,eHF,nBas2,seHF)
! call spatial_to_spin_MO_energy(nBas,eGW,nBas2,seGW)
2023-07-30 22:01:44 +02:00
! call spatial_to_spin_ERI(nBas,ERI,nBas2,sERI)
2023-07-03 23:15:07 +02:00
!
! call Bethe_Salpeter_pp_so(TDA_W,TDA,singlet,triplet,eta,nBas2,nC2,nO2,nV2,nR2,nS2,sERI,dipole_int,seHF,seGW,EcppBSE)
! end if
2023-11-13 18:36:09 +01:00
! Testing zone
if(dotest) then
2023-11-14 14:31:27 +01:00
call dump_test_value('R','evGTeh correlation energy',EcRPA)
call dump_test_value('R','evGTeh HOMO energy',eGT(nO))
call dump_test_value('R','evGTeh LUMO energy',eGT(nO+1))
2023-11-13 18:36:09 +01:00
end if
2023-07-03 23:15:07 +02:00
end subroutine