4
1
mirror of https://github.com/pfloos/quack synced 2024-11-08 07:03:59 +01:00
quack/src/RPA/ppURPA.f90

158 lines
5.5 KiB
Fortran
Raw Normal View History

2021-12-13 14:28:05 +01:00
subroutine ppURPA(TDA,doACFDT,spin_conserved,spin_flip,nBas,nC,nO,nV,nR,ENuc,EUHF,ERI_aaaa,ERI_aabb,ERI_bbbb,e)
! Perform unrestricted pp-RPA calculations
implicit none
include 'parameters.h'
! Input variables
logical,intent(in) :: TDA
logical,intent(in) :: doACFDT
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)
double precision,intent(in) :: ENuc
double precision,intent(in) :: EUHF
double precision,intent(in) :: e(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)
! Local variables
2021-12-16 12:28:28 +01:00
integer :: ispin
integer :: nPaa,nPbb,nPab,nP_sc,nP_sf
integer :: nHaa,nHbb,nHab,nH_sc,nH_sf
double precision,allocatable :: Omega1sc(:),Omega1sf(:)
double precision,allocatable :: X1sc(:,:),X1sf(:,:)
double precision,allocatable :: Y1sc(:,:),Y1sf(:,:)
double precision,allocatable :: Omega2sc(:),Omega2sf(:)
double precision,allocatable :: X2sc(:,:),X2sf(:,:)
double precision,allocatable :: Y2sc(:,:),Y2sf(:,:)
double precision :: Ec_ppURPA(nspin)
2021-12-13 14:28:05 +01:00
double precision :: EcAC(nspin)
! Hello world
write(*,*)
write(*,*)'****************************************'
write(*,*)'| particle-particle URPA calculation |'
write(*,*)'****************************************'
write(*,*)
! Initialization
2021-12-16 12:28:28 +01:00
Ec_ppURPA(:) = 0d0
2021-12-13 14:28:05 +01:00
EcAC(:) = 0d0
2021-12-31 12:49:13 +01:00
! Spin-conserved manifold
2021-12-16 12:28:28 +01:00
2021-12-31 12:49:13 +01:00
if(spin_conserved) then
2021-12-16 12:28:28 +01:00
2021-12-31 12:49:13 +01:00
ispin = 1
2021-12-16 12:28:28 +01:00
2022-01-29 11:47:35 +01:00
!Spin-conserved quantities
2021-12-16 12:28:28 +01:00
2022-01-29 11:47:35 +01:00
nPab = nV(1)*nV(2)
nHab = nO(1)*nO(2)
2021-12-13 14:28:05 +01:00
2022-01-29 11:47:35 +01:00
nP_sc = nPab
nH_sc = nHab
2021-12-13 14:28:05 +01:00
2021-12-31 12:49:13 +01:00
! Memory allocation
2021-12-13 14:28:05 +01:00
2022-01-29 11:47:35 +01:00
allocate(Omega1sc(nP_sc),X1sc(nP_sc,nP_sc),Y1sc(nH_sc,nP_sc), &
Omega2sc(nH_sc),X2sc(nP_sc,nH_sc),Y2sc(nH_sc,nH_sc))
2021-12-13 14:28:05 +01:00
2022-01-29 11:47:35 +01:00
call unrestricted_linear_response_pp(ispin,TDA,nBas,nC,nO,nV,nR,nPaa,nPab,nPbb,&
nP_sc,nHaa,nHab,nHbb,nH_sc,1d0,e,ERI_aaaa,& ERI_aabb,ERI_bbbb,Omega1sc,X1sc,Y1sc,&
Omega2sc,X2sc,Y2sc,Ec_ppURPA(ispin))
2021-12-31 12:49:13 +01:00
2022-01-29 11:47:35 +01:00
call print_excitation('pp-RPA (N+2)',5,nP_sc,Omega1sc)
call print_excitation('pp-RPA (N-2)',5,nH_sc,Omega2sc)
2021-12-13 14:28:05 +01:00
endif
! Spin-flip manifold
if(spin_flip) then
ispin = 2
2022-01-29 11:47:35 +01:00
!Spin-flip quantities
2021-12-31 12:49:13 +01:00
2022-01-29 11:47:35 +01:00
nPaa = nV(1)*(nV(1)-1)/2
nPbb = nV(2)*(nV(2)-1)/2
2021-12-31 12:49:13 +01:00
2022-01-29 11:47:35 +01:00
nP_sf = nPaa
2021-12-31 12:49:13 +01:00
2022-01-29 11:47:35 +01:00
nHaa = nO(1)*(nO(1)-1)/2
nHbb = nO(2)*(nO(2)-1)/2
2021-12-31 12:49:13 +01:00
2022-01-29 11:47:35 +01:00
nH_sf = nHaa
2021-12-31 12:49:13 +01:00
2022-01-29 11:47:35 +01:00
allocate(Omega1sf(nP_sf),X1sf(nP_sf,nP_sf),Y1sf(nH_sf,nP_sf), &
Omega2sf(nH_sf),X2sf(nP_sf,nH_sf),Y2sf(nH_sf,nH_sf))
2021-12-31 12:49:13 +01:00
2022-01-29 11:47:35 +01:00
call unrestricted_linear_response_pp(ispin,TDA,nBas,nC,nO,nV,nR,nPaa,nPab,nPbb,&
nP_sf,nHaa,nHab,nHbb,nH_sf,1d0,e,ERI_aaaa,& ERI_aabb,ERI_bbbb,Omega1sf,X1sf,Y1sf,&
Omega2sf,X2sf,Y2sf,Ec_ppURPA(ispin))
2021-12-31 12:49:13 +01:00
2022-01-29 11:47:35 +01:00
ispin = 3
2021-12-31 12:49:13 +01:00
2022-01-29 11:47:35 +01:00
nP_sf = nPbb
nH_sf = nHbb
2021-12-31 12:49:13 +01:00
!allocate(Omega1sf(nP_sf),X1sf(nP_sf,nP_sf),Y1sf(nH_sf,nP_sf), &
! Omega2sf(nH_sf),X2sf(nP_sf,nH_sf),Y2sf(nH_sf,nH_sf))
2022-01-29 11:47:35 +01:00
call unrestricted_linear_response_pp(ispin,TDA,nBas,nC,nO,nV,nR,nPaa,nPab,nPbb,&
nP_sf,nHaa,nHab,nHbb,nH_sf,1d0,e,ERI_aaaa,&
ERI_aabb,ERI_bbbb,Omega1sf,X1sf,Y1sf,&
Omega2sf,X2sf,Y2sf,Ec_ppURPA(ispin))
2021-12-13 14:28:05 +01:00
2022-01-29 11:47:35 +01:00
call print_excitation('pp-RPA (N+2)',6,nP_sf,Omega1sf)
call print_excitation('pp-RPA (N-2)',6,nH_sf,Omega2sf)
2021-12-13 14:28:05 +01:00
endif
write(*,*)
write(*,*)'-------------------------------------------------------------------------------'
2021-12-16 12:28:28 +01:00
write(*,'(2X,A50,F20.10)') 'Tr@ppRPA correlation energy (spin-conserved) =',Ec_ppURPA(1)
write(*,'(2X,A50,F20.10)') 'Tr@ppRPA correlation energy (spin-flip) =',3d0*Ec_ppURPA(2)
write(*,'(2X,A50,F20.10)') 'Tr@ppRPA correlation energy =',Ec_ppURPA(1) + 3d0*Ec_ppURPA(2)
write(*,'(2X,A50,F20.10)') 'Tr@ppRPA total energy =',ENuc + EUHF + Ec_ppURPA(1) + 3d0*Ec_ppURPA(2)
2021-12-13 14:28:05 +01:00
write(*,*)'-------------------------------------------------------------------------------'
write(*,*)
! Compute the correlation energy via the adiabatic connection
! if(doACFDT) then
! write(*,*) '---------------------------------------------------------'
! write(*,*) 'Adiabatic connection version of pp-RPA correlation energy'
! write(*,*) '---------------------------------------------------------'
! write(*,*)
! call ACFDT_pp(TDA,singlet,triplet,nBas,nC,nO,nV,nR,nS,ERI,e,EcAC)
! write(*,*)
! write(*,*)'-------------------------------------------------------------------------------'
! write(*,'(2X,A50,F20.10,A3)') 'AC@ppRPA correlation energy (singlet) =',EcAC(1),' au'
! write(*,'(2X,A50,F20.10,A3)') 'AC@ppRPA correlation energy (triplet) =',EcAC(2),' au'
! write(*,'(2X,A50,F20.10,A3)') 'AC@ppRPA correlation energy =',EcAC(1) + EcAC(2),' au'
! write(*,'(2X,A50,F20.10,A3)') 'AC@ppRPA total energy =',ENuc + ERHF + EcAC(1) + EcAC(2),' au'
! write(*,*)'-------------------------------------------------------------------------------'
! write(*,*)
! end if
end subroutine ppURPA