10
1
mirror of https://github.com/pfloos/quack synced 2025-01-08 20:33:19 +01:00
QuAcK/src/GW/UGW_phBSE.f90

201 lines
7.0 KiB
Fortran
Raw Normal View History

2024-09-11 18:41:27 +02:00
subroutine UGW_phBSE(exchange_kernel,TDA_W,TDA,dBSE,dTDA,spin_conserved,spin_flip,eta,nBas,nC,nO,nV,nR,nS, &
2023-11-27 23:25:10 +01:00
S,ERI_aaaa,ERI_aabb,ERI_bbbb,dipole_int_aa,dipole_int_bb,cW,eW,eGW,EcBSE)
2020-09-22 22:14:08 +02:00
! Compute the Bethe-Salpeter excitation energies
implicit none
include 'parameters.h'
! Input variables
2024-09-11 18:41:27 +02:00
logical,intent(in) :: exchange_kernel
2020-09-22 22:14:08 +02:00
logical,intent(in) :: TDA_W
logical,intent(in) :: TDA
logical,intent(in) :: dBSE
logical,intent(in) :: dTDA
logical,intent(in) :: spin_conserved
logical,intent(in) :: spin_flip
double precision,intent(in) :: eta
integer,intent(in) :: nBas
integer,intent(in) :: nC(nspin)
integer,intent(in) :: nO(nspin)
integer,intent(in) :: nV(nspin)
integer,intent(in) :: nR(nspin)
2020-09-22 23:08:47 +02:00
integer,intent(in) :: nS(nspin)
2020-10-06 14:24:54 +02:00
double precision,intent(in) :: S(nBas,nBas)
double precision,intent(in) :: cW(nBas,nBas,nspin)
2020-09-22 22:14:08 +02:00
double precision,intent(in) :: eW(nBas,nspin)
double precision,intent(in) :: eGW(nBas,nspin)
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-28 22:58:58 +02:00
double precision,intent(in) :: dipole_int_aa(nBas,nBas,ncart)
double precision,intent(in) :: dipole_int_bb(nBas,nBas,ncart)
2020-09-22 22:14:08 +02:00
! Local variables
integer :: ispin
integer :: isp_W
2024-10-14 20:14:51 +02:00
logical :: dRPA = .false.
logical :: dRPA_W = .true.
double precision,allocatable :: Aph(:,:)
double precision,allocatable :: Bph(:,:)
double precision,allocatable :: KA(:,:)
double precision,allocatable :: KB(:,:)
2020-09-23 22:48:54 +02:00
2020-09-24 14:39:37 +02:00
double precision :: EcRPA
double precision,allocatable :: OmRPA(:)
double precision,allocatable :: XpY_RPA(:,:)
double precision,allocatable :: XmY_RPA(:,:)
double precision,allocatable :: rho_RPA(:,:,:,:)
2024-10-14 04:11:48 +02:00
integer :: nS_aa,nS_bb,nS_sc
2020-09-23 22:48:54 +02:00
integer :: nS_ab,nS_ba,nS_sf
2024-10-14 04:11:48 +02:00
double precision,allocatable :: OmBSE(:)
double precision,allocatable :: XpY_BSE(:,:)
double precision,allocatable :: XmY_BSE(:,:)
2020-09-23 22:48:54 +02:00
2020-09-22 22:14:08 +02:00
! Output variables
2020-09-22 23:08:47 +02:00
double precision,intent(out) :: EcBSE(nspin)
2020-09-22 22:14:08 +02:00
2024-09-11 17:58:36 +02:00
! Memory allocation
2020-09-22 23:08:47 +02:00
2020-09-23 22:48:54 +02:00
nS_aa = nS(1)
nS_bb = nS(2)
nS_sc = nS_aa + nS_bb
2020-10-07 22:51:30 +02:00
nS_ab = (nO(1) - nC(1))*(nV(2) - nR(2))
nS_ba = (nO(2) - nC(2))*(nV(1) - nR(1))
nS_sf = nS_ab + nS_ba
2020-09-22 23:08:47 +02:00
2024-10-14 20:14:51 +02:00
! TDA
2024-09-11 17:58:36 +02:00
if(TDA) then
write(*,*) 'Tamm-Dancoff approximation activated in phBSE!'
write(*,*)
end if
2024-10-14 20:14:51 +02:00
! Initialization
EcBSE(:) = 0d0
2020-09-24 14:39:37 +02:00
!--------------------------!
! Spin-conserved screening !
!--------------------------!
isp_W = 1
2020-09-23 22:48:54 +02:00
! Compute spin-conserved RPA screening
2020-09-22 22:14:08 +02:00
2024-10-14 20:14:51 +02:00
allocate(Aph(nS_sc,nS_sc),Bph(nS_sc,nS_sc))
allocate(OmRPA(nS_sc),XpY_RPA(nS_sc,nS_sc),XmY_RPA(nS_sc,nS_sc),rho_RPA(nBas,nBas,nS_sc,nspin))
call phULR_A(isp_W,dRPA_W,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sc,1d0,eW,ERI_aaaa,ERI_aabb,ERI_bbbb,Aph)
if(.not.TDA_W) call phULR_B(isp_W,dRPA_W,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sc,1d0,ERI_aaaa,ERI_aabb,ERI_bbbb,Bph)
2020-09-24 14:39:37 +02:00
2024-10-14 20:14:51 +02:00
call phULR(TDA_W,nS_aa,nS_bb,nS_sc,Aph,Bph,EcRPA,OmRPA,XpY_RPA,XmY_RPA)
2023-07-27 21:59:18 +02:00
call UGW_excitation_density(nBas,nC,nO,nR,nS_aa,nS_bb,nS_sc,ERI_aaaa,ERI_aabb,ERI_bbbb,XpY_RPA,rho_RPA)
2024-10-14 20:14:51 +02:00
deallocate(Aph,Bph)
2020-09-22 22:14:08 +02:00
2020-09-24 14:39:37 +02:00
!----------------------------!
! Spin-conserved excitations !
!----------------------------!
2020-09-23 14:23:40 +02:00
2020-09-23 22:48:54 +02:00
if(spin_conserved) then
ispin = 1
2024-10-14 20:14:51 +02:00
allocate(Aph(nS_sc,nS_sc),Bph(nS_sc,nS_sc),KA(nS_sc,nS_sc),KB(nS_sc,nS_sc))
2024-10-14 04:11:48 +02:00
allocate(OmBSE(nS_sc),XpY_BSE(nS_sc,nS_sc),XmY_BSE(nS_sc,nS_sc))
2020-09-22 22:14:08 +02:00
2020-09-22 23:08:47 +02:00
! Compute spin-conserved BSE excitation energies
2020-09-22 22:14:08 +02:00
2024-10-14 20:14:51 +02:00
call phULR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sc,1d0,eGW,ERI_aaaa,ERI_aabb,ERI_bbbb,Aph)
if(.not.TDA) call phULR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sc,1d0,ERI_aaaa,ERI_aabb,ERI_bbbb,Bph)
2024-10-30 09:28:39 +01:00
call UGW_phBSE_static_kernel_A(ispin,eta,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sc,nS_sc,1d0,OmRPA,rho_RPA,KA)
2024-10-14 20:14:51 +02:00
if(.not.TDA) call UGW_phBSE_static_kernel_B(ispin,eta,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sc,nS_sc,1d0,OmRPA,rho_RPA,KB)
Aph(:,:) = Aph(:,:) + KA(:,:)
2024-10-30 09:28:39 +01:00
if(.not.TDA) Bph(:,:) = Bph(:,:) + KB(:,:)
2024-10-14 20:14:51 +02:00
call phULR(TDA,nS_aa,nS_bb,nS_sc,Aph,Bph,EcBSE(ispin),OmBSE,XpY_BSE,XmY_BSE)
2024-10-14 04:11:48 +02:00
call print_excitation_energies('phBSE@GW@UHF','spin-conserved',nS_sc,OmBSE)
2023-07-28 14:14:35 +02:00
call phULR_transition_vectors(ispin,nBas,nC,nO,nV,nR,nS,nS_aa,nS_bb,nS_sc,dipole_int_aa,dipole_int_bb, &
2024-10-14 04:11:48 +02:00
cW,S,OmBSE,XpY_BSE,XmY_BSE)
2020-09-22 22:14:08 +02:00
!-------------------------------------------------
! Compute the dynamical screening at the BSE level
!-------------------------------------------------
2020-09-30 00:10:57 +02:00
if(dBSE) &
2023-07-27 22:07:02 +02:00
call UGW_phBSE_dynamic_perturbation(ispin,dTDA,eta,nBas,nC,nO,nV,nR,nS,nS_aa,nS_bb,nS_sc,nS_sc, &
eW,eGW,ERI_aaaa,ERI_aabb,ERI_bbbb,dipole_int_aa,dipole_int_bb, &
2024-10-14 04:11:48 +02:00
OmRPA,rho_RPA,OmBSE,XpY_BSE,XmY_BSE)
2020-09-30 00:10:57 +02:00
2024-10-14 20:14:51 +02:00
deallocate(Aph,Bph,KA,KB)
2024-10-14 04:11:48 +02:00
deallocate(OmBSE,XpY_BSE,XmY_BSE)
2020-09-30 00:10:57 +02:00
2020-09-22 22:14:08 +02:00
end if
!-----------------------!
! Spin-flip excitations !
!-----------------------!
2020-09-23 22:48:54 +02:00
if(spin_flip) then
2020-09-22 22:14:08 +02:00
2020-09-23 22:48:54 +02:00
ispin = 2
2020-09-22 22:14:08 +02:00
2024-10-14 20:14:51 +02:00
allocate(Aph(nS_sf,nS_sf),Bph(nS_sf,nS_sf),KA(nS_sf,nS_sf),KB(nS_sf,nS_sf))
2024-10-14 04:11:48 +02:00
allocate(OmBSE(nS_sf),XpY_BSE(nS_sf,nS_sf),XmY_BSE(nS_sf,nS_sf))
2020-09-22 22:14:08 +02:00
2024-10-14 20:14:51 +02:00
! Compute spin-conserved BSE excitation energies
2024-10-30 09:28:39 +01:00
2024-10-14 20:14:51 +02:00
call phULR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sf,1d0,eGW,ERI_aaaa,ERI_aabb,ERI_bbbb,Aph)
if(.not.TDA) call phULR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sf,1d0,ERI_aaaa,ERI_aabb,ERI_bbbb,Bph)
2024-10-30 09:28:39 +01:00
call UGW_phBSE_static_kernel_A(ispin,eta,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sc,nS_sf,1d0,OmRPA,rho_RPA,KA)
2024-10-14 20:14:51 +02:00
if(.not.TDA) call UGW_phBSE_static_kernel_B(ispin,eta,nBas,nC,nO,nV,nR,nS_aa,nS_bb,nS_sc,nS_sf,1d0,OmRPA,rho_RPA,KB)
2020-10-05 16:58:19 +02:00
2024-10-14 20:14:51 +02:00
Aph(:,:) = Aph(:,:) + KA(:,:)
if(.not.TDA) Bph(:,:) = Bph(:,:) + KB(:,:)
call phULR(TDA,nS_aa,nS_bb,nS_sc,Aph,Bph,EcBSE(ispin),OmBSE,XpY_BSE,XmY_BSE)
2020-09-22 22:14:08 +02:00
2024-10-14 04:11:48 +02:00
call print_excitation_energies('phBSE@GW@UHF','spin-flip',nS_sf,OmBSE)
2023-07-28 14:14:35 +02:00
call phULR_transition_vectors(ispin,nBas,nC,nO,nV,nR,nS,nS_ab,nS_ba,nS_sf,dipole_int_aa,dipole_int_bb, &
2024-10-14 04:11:48 +02:00
cW,S,OmBSE,XpY_BSE,XmY_BSE)
2020-09-22 22:14:08 +02:00
!-------------------------------------------------
! Compute the dynamical screening at the BSE level
!-------------------------------------------------
2020-09-30 00:10:57 +02:00
if(dBSE) &
2023-07-27 22:07:02 +02:00
call UGW_phBSE_dynamic_perturbation(ispin,dTDA,eta,nBas,nC,nO,nV,nR,nS,nS_ab,nS_ba,nS_sf,nS_sc, &
eW,eGW,ERI_aaaa,ERI_aabb,ERI_bbbb,dipole_int_aa,dipole_int_bb, &
2024-10-14 04:11:48 +02:00
OmRPA,rho_RPA,OmBSE,XpY_BSE,XmY_BSE)
2020-09-22 22:14:08 +02:00
2024-10-14 20:14:51 +02:00
deallocate(Aph,Bph,KA,KB)
2024-10-14 04:11:48 +02:00
deallocate(OmBSE,XpY_BSE,XmY_BSE)
2020-09-30 00:10:57 +02:00
2020-09-23 22:48:54 +02:00
end if
2024-09-11 18:41:27 +02:00
! Scale properly correlation energy if exchange is included in interaction kernel
if(exchange_kernel) then
2024-10-14 20:14:51 +02:00
EcBSE(:) = 0.5d0*EcBSE(:)
2024-09-11 18:41:27 +02:00
else
EcBSE(2) = 0.0d0
end if
2023-07-21 13:04:29 +02:00
end subroutine