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

86 lines
2.2 KiB
Fortran
Raw Permalink Normal View History

2023-10-25 13:19:21 +02:00
subroutine UGW_QP_graph(eta,nBas,nC,nO,nV,nR,nS,eHF,Om,rho,eGWlin,eOld,eGW,Z)
2020-09-23 14:23:40 +02:00
! Compute the graphical solution of the QP equation
implicit none
include 'parameters.h'
! Input variables
integer,intent(in) :: nBas
integer,intent(in) :: nC
integer,intent(in) :: nO
integer,intent(in) :: nV
integer,intent(in) :: nR
integer,intent(in) :: nS
2023-10-25 13:19:21 +02:00
2020-09-23 14:23:40 +02:00
double precision,intent(in) :: eta
double precision,intent(in) :: eHF(nBas)
2023-07-30 22:01:44 +02:00
double precision,intent(in) :: Om(nS)
2020-09-23 14:23:40 +02:00
double precision,intent(in) :: rho(nBas,nBas,nS,nspin)
double precision,intent(in) :: eGWlin(nBas)
2023-10-25 13:19:21 +02:00
double precision,intent(in) :: eOld(nBas)
2020-09-23 14:23:40 +02:00
! Local variables
integer :: p
integer :: nIt
2023-07-30 22:01:44 +02:00
integer,parameter :: maxIt = 64
2020-09-23 14:23:40 +02:00
double precision,parameter :: thresh = 1d-6
2023-07-30 22:01:44 +02:00
double precision,external :: UGW_SigC,UGW_dSigC
2023-10-25 13:19:21 +02:00
double precision :: SigC,dSigC
2020-09-23 14:23:40 +02:00
double precision :: f,df
double precision :: w
! Output variables
double precision,intent(out) :: eGW(nBas)
2023-07-30 22:01:44 +02:00
double precision,intent(out) :: Z(nBas)
2020-09-23 14:23:40 +02:00
! Run Newton's algorithm to find the root
2023-10-25 13:19:21 +02:00
write(*,*)'-----------------------------------------------------'
write(*,'(A5,1X,A3,1X,A15,1X,A15,1X,A10)') 'Orb.','It.','e_GWlin (eV)','e_GW (eV)','Z'
write(*,*)'-----------------------------------------------------'
2020-09-23 14:23:40 +02:00
2023-10-25 13:19:21 +02:00
do p=nC+1,nBas-nR
2020-09-23 14:23:40 +02:00
w = eGWlin(p)
nIt = 0
f = 1d0
do while (abs(f) > thresh .and. nIt < maxIt)
nIt = nIt + 1
2023-10-25 13:19:21 +02:00
SigC = UGW_SigC(p,w,eta,nBas,nC,nO,nV,nR,nS,eOld,Om,rho)
dSigC = UGW_dSigC(p,w,eta,nBas,nC,nO,nV,nR,nS,eOld,Om,rho)
f = w - eHF(p) - SigC
df = 1d0/(1d0 - dSigC)
2020-09-23 14:23:40 +02:00
2023-07-30 22:01:44 +02:00
w = w - df*f
2020-09-23 14:23:40 +02:00
end do
if(nIt == maxIt) then
eGW(p) = eGWlin(p)
2023-10-25 13:19:21 +02:00
write(*,'(I5,1X,I3,1X,F15.9,1X,F15.9,1X,F10.6,1X,A12)') p,nIt,eGWlin(p)*HaToeV,eGW(p)*HaToeV,Z(p),'Cvg Failed!'
2020-09-23 14:23:40 +02:00
else
eGW(p) = w
2023-07-30 22:01:44 +02:00
Z(p) = df
2020-09-23 14:23:40 +02:00
2023-10-25 13:19:21 +02:00
write(*,'(I5,1X,I3,1X,F15.9,1X,F15.9,1X,F10.6)') p,nIt,eGWlin(p)*HaToeV,eGW(p)*HaToeV,Z(p)
2020-09-23 14:23:40 +02:00
end if
end do
2023-11-27 23:25:10 +01:00
write(*,*)'-----------------------------------------------------'
write(*,*)
2023-07-27 21:59:18 +02:00
end subroutine