2023-11-11 23:00:00 +01:00
|
|
|
subroutine phURPA(dotest,TDA,doACFDT,exchange_kernel,spin_conserved,spin_flip,nBas,nC,nO,nV,nR,nS,ENuc,EUHF, &
|
|
|
|
ERI_aaaa,ERI_aabb,ERI_bbbb,dipole_int_aa,dipole_int_bb,eHF,c,S)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
|
|
|
! Perform random phase approximation calculation with exchange (aka TDHF) in the unrestricted formalism
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
include 'parameters.h'
|
|
|
|
include 'quadrature.h'
|
|
|
|
|
|
|
|
! Input variables
|
|
|
|
|
2023-11-11 23:00:00 +01:00
|
|
|
logical,intent(in) :: dotest
|
|
|
|
|
2020-09-24 16:39:15 +02:00
|
|
|
logical,intent(in) :: TDA
|
2020-09-23 09:46:44 +02:00
|
|
|
logical,intent(in) :: doACFDT
|
|
|
|
logical,intent(in) :: exchange_kernel
|
|
|
|
logical,intent(in) :: spin_conserved
|
|
|
|
logical,intent(in) :: spin_flip
|
|
|
|
integer,intent(in) :: nBas
|
|
|
|
integer,intent(in) :: nC(nspin)
|
|
|
|
integer,intent(in) :: nO(nspin)
|
|
|
|
integer,intent(in) :: nV(nspin)
|
|
|
|
integer,intent(in) :: nR(nspin)
|
|
|
|
integer,intent(in) :: nS(nspin)
|
|
|
|
double precision,intent(in) :: ENuc
|
|
|
|
double precision,intent(in) :: EUHF
|
2023-11-11 23:00:00 +01:00
|
|
|
double precision,intent(in) :: eHF(nBas,nspin)
|
2020-10-05 16:58:19 +02:00
|
|
|
double precision,intent(in) :: c(nBas,nBas,nspin)
|
|
|
|
double precision,intent(in) :: S(nBas,nBas)
|
2020-09-23 09:46:44 +02:00
|
|
|
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-23 09:46:44 +02:00
|
|
|
|
|
|
|
! Local variables
|
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
logical :: dRPA
|
2020-09-23 09:46:44 +02:00
|
|
|
integer :: ispin
|
2023-11-22 14:54:05 +01:00
|
|
|
double precision :: lambda
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
integer :: nSa,nSb,nSt
|
|
|
|
double precision,allocatable :: Aph(:,:)
|
|
|
|
double precision,allocatable :: Bph(:,:)
|
|
|
|
double precision,allocatable :: Om(:)
|
|
|
|
double precision,allocatable :: XpY(:,:)
|
|
|
|
double precision,allocatable :: XmY(:,:)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
double precision :: rho
|
2020-09-23 09:46:44 +02:00
|
|
|
double precision :: EcRPA(nspin)
|
|
|
|
|
|
|
|
! Hello world
|
2023-11-22 10:07:23 +01:00
|
|
|
|
2020-09-23 09:46:44 +02:00
|
|
|
write(*,*)
|
2023-11-10 14:37:49 +01:00
|
|
|
write(*,*)'***********************************'
|
|
|
|
write(*,*)'* Unrestricted ph-RPA Calculation *'
|
|
|
|
write(*,*)'***********************************'
|
2020-09-23 09:46:44 +02:00
|
|
|
write(*,*)
|
|
|
|
|
2020-09-30 09:59:18 +02:00
|
|
|
! TDA
|
|
|
|
|
|
|
|
if(TDA) then
|
|
|
|
write(*,*) 'Tamm-Dancoff approximation activated!'
|
|
|
|
write(*,*)
|
|
|
|
end if
|
|
|
|
|
2020-09-23 09:46:44 +02:00
|
|
|
! Initialization
|
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
dRPA = .true.
|
2020-09-23 09:46:44 +02:00
|
|
|
EcRPA(:) = 0d0
|
2023-11-22 14:54:05 +01:00
|
|
|
lambda = 1d0
|
2020-09-23 09:46:44 +02:00
|
|
|
|
|
|
|
! Spin-conserved transitions
|
|
|
|
|
|
|
|
if(spin_conserved) then
|
|
|
|
|
|
|
|
ispin = 1
|
|
|
|
|
|
|
|
! Memory allocation
|
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
nSa = nS(1)
|
|
|
|
nSb = nS(2)
|
|
|
|
nSt = nSa + nSb
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
allocate(Aph(nSt,nSt),Bph(nSt,nSt),Om(nSt),XpY(nSt,nSt),XmY(nSt,nSt))
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-11-22 14:54:05 +01:00
|
|
|
call phULR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nSa,nSb,nSt,lambda,eHF,ERI_aaaa,ERI_aabb,ERI_bbbb,Aph)
|
|
|
|
if(.not.TDA) call phULR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nSa,nSb,nSt,lambda,ERI_aaaa,ERI_aabb,ERI_bbbb,Bph)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
call phULR(TDA,nSa,nSb,nSt,Aph,Bph,EcRPA(ispin),Om,XpY,XmY)
|
2023-11-22 14:54:05 +01:00
|
|
|
call print_excitation_energies('phRPA@UHF','spin-conserved',nSt,Om)
|
2023-11-10 14:37:49 +01:00
|
|
|
call phULR_transition_vectors(ispin,nBas,nC,nO,nV,nR,nS,nSa,nSb,nSt,dipole_int_aa,dipole_int_bb,c,S,Om,XpY,XmY)
|
|
|
|
|
|
|
|
deallocate(Aph,Bph,Om,XpY,XmY)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-12-03 18:47:30 +01:00
|
|
|
end if
|
2020-09-23 09:46:44 +02:00
|
|
|
|
|
|
|
! Spin-flip transitions
|
|
|
|
|
|
|
|
if(spin_flip) then
|
|
|
|
|
|
|
|
ispin = 2
|
|
|
|
|
|
|
|
! Memory allocation
|
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
nSa = (nO(1) - nC(1))*(nV(2) - nR(2))
|
|
|
|
nSb = (nO(2) - nC(2))*(nV(1) - nR(1))
|
|
|
|
nSt = nSa + nSb
|
|
|
|
|
2023-11-11 23:00:00 +01:00
|
|
|
allocate(Aph(nSt,nSt),Bph(nSt,nSt),Om(nSt),XpY(nSt,nSt),XmY(nSt,nSt))
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-11-22 14:54:05 +01:00
|
|
|
call phULR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nSa,nSb,nSt,lambda,eHF,ERI_aaaa,ERI_aabb,ERI_bbbb,Aph)
|
|
|
|
if(.not.TDA) call phULR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nSa,nSb,nSt,lambda,ERI_aaaa,ERI_aabb,ERI_bbbb,Bph)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
call phULR(TDA,nSa,nSa,nSt,Aph,Bph,EcRPA(ispin),Om,XpY,XmY)
|
2023-11-22 14:54:05 +01:00
|
|
|
call print_excitation_energies('phRPA@UHF','spin-flip',nSt,Om)
|
2023-11-10 14:37:49 +01:00
|
|
|
call phULR_transition_vectors(ispin,nBas,nC,nO,nV,nR,nS,nSa,nSb,nSt,dipole_int_aa,dipole_int_bb,c,S,Om,XpY,XmY)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-11-10 14:37:49 +01:00
|
|
|
deallocate(Aph,Bph,Om,XpY,XmY)
|
2020-10-07 22:51:30 +02:00
|
|
|
|
2023-12-03 18:47:30 +01:00
|
|
|
end if
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2020-10-07 18:26:24 +02:00
|
|
|
if(exchange_kernel) then
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2020-10-07 18:26:24 +02:00
|
|
|
EcRPA(1) = 0.5d0*EcRPA(1)
|
|
|
|
EcRPA(2) = 1.5d0*EcRPA(2)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2020-10-07 18:26:24 +02:00
|
|
|
end if
|
2020-09-23 09:46:44 +02:00
|
|
|
|
|
|
|
write(*,*)
|
|
|
|
write(*,*)'-------------------------------------------------------------------------------'
|
2023-11-11 23:00:00 +01:00
|
|
|
write(*,'(2X,A50,F20.10,A3)') 'Tr@phURPA correlation energy (spin-conserved) = ',EcRPA(1),' au'
|
|
|
|
write(*,'(2X,A50,F20.10,A3)') 'Tr@phURPA correlation energy (spin-flip) = ',EcRPA(2),' au'
|
|
|
|
write(*,'(2X,A50,F20.10,A3)') 'Tr@phURPA correlation energy = ',sum(EcRPA),' au'
|
|
|
|
write(*,'(2X,A50,F20.10,A3)') 'Tr@phURPA total energy = ',ENuc + EUHF + sum(EcRPA),' au'
|
2020-09-23 09:46:44 +02:00
|
|
|
write(*,*)'-------------------------------------------------------------------------------'
|
|
|
|
write(*,*)
|
|
|
|
|
|
|
|
! Compute the correlation energy via the adiabatic connection
|
|
|
|
|
2020-10-07 18:26:24 +02:00
|
|
|
if(doACFDT) then
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2020-10-07 22:51:30 +02:00
|
|
|
write(*,*) '---------------------------------------------------------'
|
|
|
|
write(*,*) ' Adiabatic connection version of URPA correlation energy '
|
|
|
|
write(*,*) '---------------------------------------------------------'
|
2020-10-07 18:26:24 +02:00
|
|
|
write(*,*)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-07-23 11:16:42 +02:00
|
|
|
call phUACFDT(exchange_kernel,.false.,.true.,.false.,TDA,.false.,spin_conserved,spin_flip, &
|
2023-11-11 23:00:00 +01:00
|
|
|
nBas,nC,nO,nV,nR,nS,ERI_aaaa,ERI_aabb,ERI_bbbb,eHF,eHF,EcRPA)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2021-04-01 22:04:23 +02:00
|
|
|
if(exchange_kernel) then
|
|
|
|
|
2023-07-22 19:41:45 +02:00
|
|
|
EcRPA(1) = 0.5d0*EcRPA(1)
|
|
|
|
EcRPA(2) = 1.5d0*EcRPA(2)
|
2021-04-01 22:04:23 +02:00
|
|
|
|
|
|
|
end if
|
|
|
|
|
2020-10-07 18:26:24 +02:00
|
|
|
write(*,*)
|
|
|
|
write(*,*)'-------------------------------------------------------------------------------'
|
2023-11-11 23:00:00 +01:00
|
|
|
write(*,'(2X,A50,F20.10,A3)') 'AC@phURPA correlation energy (spin-conserved) = ',EcRPA(1),' au'
|
|
|
|
write(*,'(2X,A50,F20.10,A3)') 'AC@phURPA correlation energy (spin-flip) = ',EcRPA(2),' au'
|
|
|
|
write(*,'(2X,A50,F20.10,A3)') 'AC@phURPA correlation energy = ',sum(EcRPA),' au'
|
|
|
|
write(*,'(2X,A50,F20.10,A3)') 'AC@phURPA total energy = ',ENuc + EUHF + sum(EcRPA),' au'
|
2020-10-07 18:26:24 +02:00
|
|
|
write(*,*)'-------------------------------------------------------------------------------'
|
|
|
|
write(*,*)
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2020-10-07 18:26:24 +02:00
|
|
|
end if
|
2020-09-23 09:46:44 +02:00
|
|
|
|
2023-11-11 23:00:00 +01:00
|
|
|
if(dotest) then
|
|
|
|
|
2023-11-14 13:50:53 +01:00
|
|
|
call dump_test_value('U','phRPA correlation energy',sum(EcRPA))
|
2023-11-11 23:00:00 +01:00
|
|
|
|
|
|
|
end if
|
|
|
|
|
2023-07-22 19:41:45 +02:00
|
|
|
end subroutine
|