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

79 lines
2.0 KiB
Fortran
Raw Permalink Normal View History

2023-10-02 21:45:02 +02:00
subroutine GF2_QP_graph(eta,nBas,nC,nO,nV,nR,eHF,ERI,eGFlin,eOld,eGF,Z)
2023-06-30 19:17:35 +02:00
! Compute the graphical solution of the GF2 QP equation
implicit none
include 'parameters.h'
! Input variables
double precision,intent(in) :: eta
2023-09-07 15:37:19 +02:00
integer,intent(in) :: nBas
integer,intent(in) :: nC
integer,intent(in) :: nO
integer,intent(in) :: nV
integer,intent(in) :: nR
2023-06-30 19:17:35 +02:00
double precision,intent(in) :: eHF(nBas)
2023-09-07 15:37:19 +02:00
double precision,intent(in) :: eGFlin(nBas)
2023-10-02 21:45:02 +02:00
double precision,intent(in) :: eOld(nBas)
2023-06-30 19:17:35 +02:00
double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas)
! Local variables
integer :: p
integer :: nIt
integer,parameter :: maxIt = 64
double precision,parameter :: thresh = 1d-6
2023-07-27 17:43:18 +02:00
double precision,external :: GF2_SigC,GF2_dSigC
2023-08-24 11:18:12 +02:00
double precision :: SigC,dSigC
2023-06-30 19:17:35 +02:00
double precision :: f,df
double precision :: w
! Output variables
2023-07-27 17:43:18 +02:00
double precision,intent(out) :: eGF(nBas)
2023-07-27 21:23:40 +02:00
double precision,intent(out) :: Z(nBas)
2023-06-30 19:17:35 +02:00
! Run Newton's algorithm to find the root
2023-09-07 15:37:19 +02:00
write(*,*)'-----------------------------------------------------'
write(*,'(A5,1X,A3,1X,A15,1X,A15,1X,A10)') 'Orb.','It.','e_GFlin (eV)','e_GF (eV)','Z'
write(*,*)'-----------------------------------------------------'
2023-06-30 19:17:35 +02:00
2023-09-07 15:37:19 +02:00
do p=nC+1,nBas-nR
2023-06-30 19:17:35 +02:00
2023-09-07 15:37:19 +02:00
w = eGFlin(p)
2023-06-30 19:17:35 +02:00
nIt = 0
f = 1d0
do while (abs(f) > thresh .and. nIt < maxIt)
nIt = nIt + 1
2023-10-02 21:45:02 +02:00
SigC = GF2_SigC(p,w,eta,nBas,nC,nO,nV,nR,eOld,ERI)
dSigC = GF2_dSigC(p,w,eta,nBas,nC,nO,nV,nR,eOld,ERI)
2023-08-24 11:18:12 +02:00
f = w - eHF(p) - SigC
df = 1d0/(1d0 - dSigC)
2023-06-30 19:17:35 +02:00
2023-07-27 21:23:40 +02:00
w = w - df*f
2023-06-30 19:17:35 +02:00
end do
if(nIt == maxIt) then
2023-09-07 15:37:19 +02:00
eGF(p) = eGFlin(p)
write(*,'(I5,1X,I3,1X,F15.9,1X,F15.9,1X,F10.6,1X,A12)') p,nIt,eGFlin(p)*HaToeV,eGF(p)*HaToeV,Z(p),'Cvg Failed!'
2023-06-30 19:17:35 +02:00
else
2023-07-27 17:43:18 +02:00
eGF(p) = w
2023-07-27 21:23:40 +02:00
Z(p) = df
2023-06-30 19:17:35 +02:00
2023-09-07 15:37:19 +02:00
write(*,'(I5,1X,I3,1X,F15.9,1X,F15.9,1X,F10.6)') p,nIt,eGFlin(p)*HaToeV,eGF(p)*HaToeV,Z(p)
2023-06-30 19:17:35 +02:00
2023-09-07 15:37:19 +02:00
end if
2023-06-30 19:17:35 +02:00
2023-09-07 15:37:19 +02:00
end do
2023-06-30 19:17:35 +02:00
end subroutine