From 6515773839790871769c2aba98e199ecae6674f1 Mon Sep 17 00:00:00 2001 From: Pierre-Francois Loos Date: Wed, 12 Apr 2023 21:41:30 +0200 Subject: [PATCH 1/4] bug in ufGW and ufG0W0 --- int/ERI.Hu.dat | 4 ++-- src/GW/ufG0W0.f90 | 2 +- src/GW/ufGW.f90 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/int/ERI.Hu.dat b/int/ERI.Hu.dat index 95ec6f7..e7b1d13 100644 --- a/int/ERI.Hu.dat +++ b/int/ERI.Hu.dat @@ -1,2 +1,2 @@ -1 1 1 1 5. -2 2 2 2 5. +1 1 1 1 1. +2 2 2 2 1. diff --git a/src/GW/ufG0W0.f90 b/src/GW/ufG0W0.f90 index 239665f..0d8a53d 100644 --- a/src/GW/ufG0W0.f90 +++ b/src/GW/ufG0W0.f90 @@ -54,7 +54,7 @@ subroutine ufG0W0(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,eHF) ! Dimension of the supermatrix - n2h1p = nO*nO*nS + n2h1p = nO*nO*nV n2p1h = nV*nV*nO nH = 1 + n2h1p + n2p1h diff --git a/src/GW/ufGW.f90 b/src/GW/ufGW.f90 index d64807e..fe877e5 100644 --- a/src/GW/ufGW.f90 +++ b/src/GW/ufGW.f90 @@ -49,7 +49,7 @@ subroutine ufGW(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,eHF) ! Dimension of the supermatrix - n2h1p = nO*nO*nS + n2h1p = nO*nO*nV n2p1h = nV*nV*nO nH = nBas + n2h1p + n2p1h From f998fb3a1374a2e8b91d8a6f3ac9b7b933f10e7c Mon Sep 17 00:00:00 2001 From: Pierre-Francois Loos Date: Wed, 12 Apr 2023 22:29:10 +0200 Subject: [PATCH 2/4] remove self-screening correction --- input/methods | 4 +- input/options | 6 +- src/GW/ufG0W0.f90 | 4 +- src/GW/ufG0W0_corrected.f90 | 275 ++++++++++++++++++++++++++++++++++++ src/QuAcK/QuAcK.f90 | 1 + 5 files changed, 283 insertions(+), 7 deletions(-) create mode 100644 src/GW/ufG0W0_corrected.f90 diff --git a/input/methods b/input/methods index 37e4a5b..4523991 100644 --- a/input/methods +++ b/input/methods @@ -11,9 +11,9 @@ # RPA* RPAx* crRPA ppRPA F F F F # G0F2* evGF2* qsGF2* G0F3 evGF3 - F F T F F + F F F F F # G0W0* evGW* qsGW* SRG-qsGW ufG0W0 ufGW - F F F F F F + T F F F T F # G0T0 evGT qsGT F F F # * unrestricted version available diff --git a/input/options b/input/options index 010ddf5..a766382 100644 --- a/input/options +++ b/input/options @@ -5,14 +5,14 @@ # CC: maxSCF thresh DIIS n_diis 64 0.0000001 T 5 # spin: TDA singlet triplet spin_conserved spin_flip - T T T T T + F T T T T # GF: maxSCF thresh DIIS n_diis lin eta renorm reg 256 0.00001 T 5 T 0.0 0 F # GW: maxSCF thresh DIIS n_diis lin eta COHSEX SOSEX TDA_W reg - 256 0.00001 T 5 T 0.01 F F F F + 256 0.00001 T 5 T 0.01 F F T F # GT: maxSCF thresh DIIS n_diis lin eta TDA_T reg 10 0.00001 T 5 T 0.0 F F # ACFDT: AC Kx XBS F T T # BSE: BSE dBSE dTDA evDyn ppBSE BSE2 - T F T F F F + F F T F F F diff --git a/src/GW/ufG0W0.f90 b/src/GW/ufG0W0.f90 index 0d8a53d..45322ee 100644 --- a/src/GW/ufG0W0.f90 +++ b/src/GW/ufG0W0.f90 @@ -238,7 +238,7 @@ subroutine ufG0W0(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,eHF) klc = klc + 1 -! if(abs(cGW(1+klc,s)) > cutoff2) & + if(abs(cGW(1+klc,s)) > cutoff2) & write(*,'(1X,A3,I3,A1,I3,A6,I3,A7,1X,F15.6,1X,F15.6)') & ' (',k,',',l,') -> (',c,') ',cGW(1+klc,s),cGW(1+klc,s)**2 @@ -252,7 +252,7 @@ subroutine ufG0W0(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,eHF) do d=nO+1,nBas-nR kcd = kcd + 1 -! if(abs(cGW(1+n2h1p+kcd,s)) > cutoff2) & + if(abs(cGW(1+n2h1p+kcd,s)) > cutoff2) & write(*,'(1X,A7,I3,A6,I3,A1,I3,A3,1X,F15.6,1X,F15.6)') & ' (',k,') -> (',c,',',d,') ',cGW(1+n2h1p+kcd,s),cGW(1+n2h1p+kcd,s)**2 diff --git a/src/GW/ufG0W0_corrected.f90 b/src/GW/ufG0W0_corrected.f90 new file mode 100644 index 0000000..0f89215 --- /dev/null +++ b/src/GW/ufG0W0_corrected.f90 @@ -0,0 +1,275 @@ +subroutine ufG0W0_corrected(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,eHF) + +! Unfold G0W0 equations + + 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 + double precision,intent(in) :: ENuc + double precision,intent(in) :: ERHF + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: eHF(nBas) + +! Local variables + + integer :: p + integer :: s + integer :: i,j,k,l + integer :: a,b,c,d + integer :: klc,kcd,ija,iab + + integer :: n2h1p,n2p1h,nH + double precision,external :: Kronecker_delta + double precision,allocatable :: H(:,:) + double precision,allocatable :: cGW(:,:) + double precision,allocatable :: eGW(:) + double precision,allocatable :: Z(:) + + logical :: verbose = .true. + double precision,parameter :: cutoff1 = 0.0d0 + double precision,parameter :: cutoff2 = 0.01d0 + +! Output variables + +! Hello world + + write(*,*) + write(*,*)'**********************************************' + write(*,*)'| Unfolded G0W0 calculation |' + write(*,*)'| with self-screening correction |' + write(*,*)'**********************************************' + write(*,*) + +! TDA for W + + write(*,*) 'Tamm-Dancoff approximation for dynamic screening by default!' + write(*,*) + +! Dimension of the supermatrix + + n2h1p = nO*(nO+1)/2*nV + n2p1h = nV*(nV+1)/2*nO + nH = 1 + n2h1p + n2p1h + +! Memory allocation + + allocate(H(nH,nH),cGW(nH,nH),eGW(nH),Z(nH)) + +! Initialization + + H(:,:) = 0d0 + +!---------------------------! +! Compute GW supermatrix ! +!---------------------------! +! ! +! | F V2h1p V2p1h | ! +! | | ! +! H = | V2h1p C2h1p 0 | ! +! | | ! +! | V2p1h 0 C2p1h | ! +! ! +!---------------------------! + + !-------------! + ! Block C2h1p ! + !-------------! + + ija = 0 + do i=nC+1,nO + do j=i,nO + do a=nO+1,nBas-nR + ija = ija + 1 + + klc = 0 + do k=nC+1,nO + do l=k,nO + do c=nO+1,nBas-nR + klc = klc + 1 + + H(1+ija,1+klc) & + = ((eHF(i) + eHF(j) - eHF(a))*Kronecker_delta(j,l)*Kronecker_delta(a,c) & + - 2d0*ERI(j,c,a,l))*Kronecker_delta(i,k) + + end do + end do + end do + + end do + end do + end do + + !-------------! + ! Block C2p1h ! + !-------------! + + iab = 0 + do i=nC+1,nO + do a=nO+1,nBas-nR + do b=a,nBas-nR + iab = iab + 1 + + kcd = 0 + do k=nC+1,nO + do c=nO+1,nBas-nR + do d=c,nBas-nR + kcd = kcd + 1 + + H(1+n2h1p+iab,1+n2h1p+kcd) & + = ((eHF(a) + eHF(b) - eHF(i))*Kronecker_delta(i,k)*Kronecker_delta(a,c) & + + 2d0*ERI(a,k,i,c))*Kronecker_delta(b,d) + + end do + end do + end do + + end do + end do + end do + + do p=nC+1,nBas + + !---------! + ! Block F ! + !---------! + + H(1,1) = eHF(p) + + !-------------! + ! Block V2h1p ! + !-------------! + + klc = 0 + do k=nC+1,nO + do l=k,nO + do c=nO+1,nBas-nR + klc = klc + 1 + + H(1 ,1+klc) = sqrt(2d0)*ERI(p,c,k,l) + H(1+klc,1 ) = sqrt(2d0)*ERI(p,c,k,l) + + end do + end do + end do + + !-------------! + ! Block V2p1h ! + !-------------! + + kcd = 0 + do k=nC+1,nO + do c=nO+1,nBas-nR + do d=c,nBas-nR + kcd = kcd + 1 + + H(1 ,1+n2h1p+kcd) = sqrt(2d0)*ERI(p,k,d,c) + H(1+n2h1p+kcd,1 ) = sqrt(2d0)*ERI(p,k,d,c) + + end do + end do + end do + + !-------------------------! + ! Diagonalize supermatrix ! + !-------------------------! + + cGW(:,:) = H(:,:) + call diagonalize_matrix(nH,cGW,eGW) + + !-----------------! + ! Compute weights ! + !-----------------! + + do s=1,nH + Z(s) = cGW(1,s)**2 + end do + + !--------------! + ! Dump results ! + !--------------! + + write(*,*)'-------------------------------------------' + write(*,'(A35,I3)')' G0W0 energies (eV) for orbital ',p + write(*,*)'-------------------------------------------' + write(*,'(1X,A1,1X,A3,1X,A1,1X,A15,1X,A1,1X,A15,1X,A1,1X,A15,1X)') & + '|','#','|','e_QP (eV)','|','Z','|' + write(*,*)'-------------------------------------------' + + do s=1,nH + write(*,'(1X,A1,1X,I3,1X,A1,1X,F15.6,1X,A1,1X,F15.6,1X,A1,1X)') & + '|',s,'|',eGW(s)*HaToeV,'|',Z(s),'|' + enddo + + write(*,*)'-------------------------------------------' + write(*,*) + + if(verbose) then + + do s=1,nH + + if(Z(s) > cutoff1) then + + write(*,*)'*************************************************************' + write(*,'(1X,A20,I3,A6,I3)')'Vector for orbital ',p,' and #',s + write(*,'(1X,A7,F10.6,A13,F10.6,1X)')' e_QP = ',eGW(s)*HaToeV,' eV and Z = ',Z(s) + write(*,*)'*************************************************************' + write(*,'(1X,A20,1X,A20,1X,A15,1X)') & + ' Configuration ',' Coefficient ',' Weight ' + write(*,*)'*************************************************************' + + if(p <= nO) & + write(*,'(1X,A7,I3,A16,1X,F15.6,1X,F15.6)') & + ' (',p,') ',cGW(1,s),cGW(1,s)**2 + if(p > nO) & + write(*,'(1X,A16,I3,A7,1X,F15.6,1X,F15.6)') & + ' (',p,') ',cGW(1,s),cGW(1,s)**2 + + klc = 0 + do k=nC+1,nO + do l=nC+1,nO + do c=nO+1,nBas-nR + + klc = klc + 1 + + if(abs(cGW(1+klc,s)) > cutoff2) & + write(*,'(1X,A3,I3,A1,I3,A6,I3,A7,1X,F15.6,1X,F15.6)') & + ' (',k,',',l,') -> (',c,') ',cGW(1+klc,s),cGW(1+klc,s)**2 + + end do + end do + end do + + kcd = 0 + do k=nC+1,nO + do c=nO+1,nBas-nR + do d=nO+1,nBas-nR + + kcd = kcd + 1 + if(abs(cGW(1+n2h1p+kcd,s)) > cutoff2) & + write(*,'(1X,A7,I3,A6,I3,A1,I3,A3,1X,F15.6,1X,F15.6)') & + ' (',k,') -> (',c,',',d,') ',cGW(1+n2h1p+kcd,s),cGW(1+n2h1p+kcd,s)**2 + + end do + end do + end do + + write(*,*)'*************************************************************' + write(*,*) + + end if + + end do + + end if + + end do + +end subroutine ufG0W0_corrected diff --git a/src/QuAcK/QuAcK.f90 b/src/QuAcK/QuAcK.f90 index 756d59c..38deb70 100644 --- a/src/QuAcK/QuAcK.f90 +++ b/src/QuAcK/QuAcK.f90 @@ -1093,6 +1093,7 @@ program QuAcK call cpu_time(start_ufGW) call ufG0W0(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI_MO,eHF) +! call ufG0W0_corrected(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI_MO,eHF) call cpu_time(end_ufGW) t_ufGW = end_ufGW - start_ufGW From 0746f2110a8ae1876aad0e6138b208a5172ba532 Mon Sep 17 00:00:00 2001 From: Pierre-Francois Loos Date: Wed, 12 Apr 2023 22:30:06 +0200 Subject: [PATCH 3/4] corrected --- src/GW/ufG0W0_corrected.f90 | 275 ------------------------------------ 1 file changed, 275 deletions(-) delete mode 100644 src/GW/ufG0W0_corrected.f90 diff --git a/src/GW/ufG0W0_corrected.f90 b/src/GW/ufG0W0_corrected.f90 deleted file mode 100644 index 0f89215..0000000 --- a/src/GW/ufG0W0_corrected.f90 +++ /dev/null @@ -1,275 +0,0 @@ -subroutine ufG0W0_corrected(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,eHF) - -! Unfold G0W0 equations - - 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 - double precision,intent(in) :: ENuc - double precision,intent(in) :: ERHF - double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) - double precision,intent(in) :: eHF(nBas) - -! Local variables - - integer :: p - integer :: s - integer :: i,j,k,l - integer :: a,b,c,d - integer :: klc,kcd,ija,iab - - integer :: n2h1p,n2p1h,nH - double precision,external :: Kronecker_delta - double precision,allocatable :: H(:,:) - double precision,allocatable :: cGW(:,:) - double precision,allocatable :: eGW(:) - double precision,allocatable :: Z(:) - - logical :: verbose = .true. - double precision,parameter :: cutoff1 = 0.0d0 - double precision,parameter :: cutoff2 = 0.01d0 - -! Output variables - -! Hello world - - write(*,*) - write(*,*)'**********************************************' - write(*,*)'| Unfolded G0W0 calculation |' - write(*,*)'| with self-screening correction |' - write(*,*)'**********************************************' - write(*,*) - -! TDA for W - - write(*,*) 'Tamm-Dancoff approximation for dynamic screening by default!' - write(*,*) - -! Dimension of the supermatrix - - n2h1p = nO*(nO+1)/2*nV - n2p1h = nV*(nV+1)/2*nO - nH = 1 + n2h1p + n2p1h - -! Memory allocation - - allocate(H(nH,nH),cGW(nH,nH),eGW(nH),Z(nH)) - -! Initialization - - H(:,:) = 0d0 - -!---------------------------! -! Compute GW supermatrix ! -!---------------------------! -! ! -! | F V2h1p V2p1h | ! -! | | ! -! H = | V2h1p C2h1p 0 | ! -! | | ! -! | V2p1h 0 C2p1h | ! -! ! -!---------------------------! - - !-------------! - ! Block C2h1p ! - !-------------! - - ija = 0 - do i=nC+1,nO - do j=i,nO - do a=nO+1,nBas-nR - ija = ija + 1 - - klc = 0 - do k=nC+1,nO - do l=k,nO - do c=nO+1,nBas-nR - klc = klc + 1 - - H(1+ija,1+klc) & - = ((eHF(i) + eHF(j) - eHF(a))*Kronecker_delta(j,l)*Kronecker_delta(a,c) & - - 2d0*ERI(j,c,a,l))*Kronecker_delta(i,k) - - end do - end do - end do - - end do - end do - end do - - !-------------! - ! Block C2p1h ! - !-------------! - - iab = 0 - do i=nC+1,nO - do a=nO+1,nBas-nR - do b=a,nBas-nR - iab = iab + 1 - - kcd = 0 - do k=nC+1,nO - do c=nO+1,nBas-nR - do d=c,nBas-nR - kcd = kcd + 1 - - H(1+n2h1p+iab,1+n2h1p+kcd) & - = ((eHF(a) + eHF(b) - eHF(i))*Kronecker_delta(i,k)*Kronecker_delta(a,c) & - + 2d0*ERI(a,k,i,c))*Kronecker_delta(b,d) - - end do - end do - end do - - end do - end do - end do - - do p=nC+1,nBas - - !---------! - ! Block F ! - !---------! - - H(1,1) = eHF(p) - - !-------------! - ! Block V2h1p ! - !-------------! - - klc = 0 - do k=nC+1,nO - do l=k,nO - do c=nO+1,nBas-nR - klc = klc + 1 - - H(1 ,1+klc) = sqrt(2d0)*ERI(p,c,k,l) - H(1+klc,1 ) = sqrt(2d0)*ERI(p,c,k,l) - - end do - end do - end do - - !-------------! - ! Block V2p1h ! - !-------------! - - kcd = 0 - do k=nC+1,nO - do c=nO+1,nBas-nR - do d=c,nBas-nR - kcd = kcd + 1 - - H(1 ,1+n2h1p+kcd) = sqrt(2d0)*ERI(p,k,d,c) - H(1+n2h1p+kcd,1 ) = sqrt(2d0)*ERI(p,k,d,c) - - end do - end do - end do - - !-------------------------! - ! Diagonalize supermatrix ! - !-------------------------! - - cGW(:,:) = H(:,:) - call diagonalize_matrix(nH,cGW,eGW) - - !-----------------! - ! Compute weights ! - !-----------------! - - do s=1,nH - Z(s) = cGW(1,s)**2 - end do - - !--------------! - ! Dump results ! - !--------------! - - write(*,*)'-------------------------------------------' - write(*,'(A35,I3)')' G0W0 energies (eV) for orbital ',p - write(*,*)'-------------------------------------------' - write(*,'(1X,A1,1X,A3,1X,A1,1X,A15,1X,A1,1X,A15,1X,A1,1X,A15,1X)') & - '|','#','|','e_QP (eV)','|','Z','|' - write(*,*)'-------------------------------------------' - - do s=1,nH - write(*,'(1X,A1,1X,I3,1X,A1,1X,F15.6,1X,A1,1X,F15.6,1X,A1,1X)') & - '|',s,'|',eGW(s)*HaToeV,'|',Z(s),'|' - enddo - - write(*,*)'-------------------------------------------' - write(*,*) - - if(verbose) then - - do s=1,nH - - if(Z(s) > cutoff1) then - - write(*,*)'*************************************************************' - write(*,'(1X,A20,I3,A6,I3)')'Vector for orbital ',p,' and #',s - write(*,'(1X,A7,F10.6,A13,F10.6,1X)')' e_QP = ',eGW(s)*HaToeV,' eV and Z = ',Z(s) - write(*,*)'*************************************************************' - write(*,'(1X,A20,1X,A20,1X,A15,1X)') & - ' Configuration ',' Coefficient ',' Weight ' - write(*,*)'*************************************************************' - - if(p <= nO) & - write(*,'(1X,A7,I3,A16,1X,F15.6,1X,F15.6)') & - ' (',p,') ',cGW(1,s),cGW(1,s)**2 - if(p > nO) & - write(*,'(1X,A16,I3,A7,1X,F15.6,1X,F15.6)') & - ' (',p,') ',cGW(1,s),cGW(1,s)**2 - - klc = 0 - do k=nC+1,nO - do l=nC+1,nO - do c=nO+1,nBas-nR - - klc = klc + 1 - - if(abs(cGW(1+klc,s)) > cutoff2) & - write(*,'(1X,A3,I3,A1,I3,A6,I3,A7,1X,F15.6,1X,F15.6)') & - ' (',k,',',l,') -> (',c,') ',cGW(1+klc,s),cGW(1+klc,s)**2 - - end do - end do - end do - - kcd = 0 - do k=nC+1,nO - do c=nO+1,nBas-nR - do d=nO+1,nBas-nR - - kcd = kcd + 1 - if(abs(cGW(1+n2h1p+kcd,s)) > cutoff2) & - write(*,'(1X,A7,I3,A6,I3,A1,I3,A3,1X,F15.6,1X,F15.6)') & - ' (',k,') -> (',c,',',d,') ',cGW(1+n2h1p+kcd,s),cGW(1+n2h1p+kcd,s)**2 - - end do - end do - end do - - write(*,*)'*************************************************************' - write(*,*) - - end if - - end do - - end if - - end do - -end subroutine ufG0W0_corrected From fe8768470d28c1d281f1cb7cb0a1ad9d23ff1ac9 Mon Sep 17 00:00:00 2001 From: Pierre-Francois Loos Date: Wed, 12 Apr 2023 22:30:28 +0200 Subject: [PATCH 4/4] remove in QuAcK --- src/QuAcK/QuAcK.f90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/QuAcK/QuAcK.f90 b/src/QuAcK/QuAcK.f90 index 38deb70..756d59c 100644 --- a/src/QuAcK/QuAcK.f90 +++ b/src/QuAcK/QuAcK.f90 @@ -1093,7 +1093,6 @@ program QuAcK call cpu_time(start_ufGW) call ufG0W0(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI_MO,eHF) -! call ufG0W0_corrected(nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI_MO,eHF) call cpu_time(end_ufGW) t_ufGW = end_ufGW - start_ufGW