From de2ace91fcde3fb14ab7c9e20d204b3f5f018d0e Mon Sep 17 00:00:00 2001 From: pfloos Date: Thu, 9 Nov 2023 22:24:57 +0100 Subject: [PATCH] bit of cleanup in qsUGW but still bug --- input/options | 2 +- src/AOtoMO/MOtoAO_transform.f90 | 1 + src/GW/print_qsUGW.f90 | 3 +-- src/GW/qsRGW.f90 | 34 ++++++++++++++++----------------- src/GW/qsUGW.f90 | 16 ++++++++++------ 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/input/options b/input/options index e381a6f..11eb331 100644 --- a/input/options +++ b/input/options @@ -9,7 +9,7 @@ # GF: maxSCF thresh DIIS lin eta renorm reg 256 0.00001 5 F 0.0 0 F # GW: maxSCF thresh DIIS lin eta TDA_W reg - 256 0.00001 5 F 0.0 F F + 10 0.00001 5 F 0.0 F F # GT: maxSCF thresh DIIS lin eta TDA_T reg 256 0.00001 5 F 0.0 F F # ACFDT: AC Kx XBS diff --git a/src/AOtoMO/MOtoAO_transform.f90 b/src/AOtoMO/MOtoAO_transform.f90 index 923f55e..177b231 100644 --- a/src/AOtoMO/MOtoAO_transform.f90 +++ b/src/AOtoMO/MOtoAO_transform.f90 @@ -21,6 +21,7 @@ subroutine MOtoAO_transform(nBas,S,c,B,A) double precision,intent(out) :: A(nBas,nBas) ! Memory allocation + allocate(Sc(nBas,nBas)) Sc = matmul(S,c) diff --git a/src/GW/print_qsUGW.f90 b/src/GW/print_qsUGW.f90 index 11a85c8..36f9edc 100644 --- a/src/GW/print_qsUGW.f90 +++ b/src/GW/print_qsUGW.f90 @@ -1,5 +1,4 @@ -subroutine print_qsUGW(nBas,nO,nSCF,Conv,thresh,eHF,eGW,cGW,Ov, & - ENuc,ET,EV,EJ,Ex,EcGM,EcRPA,EqsGW,SigC,Z,dipole) +subroutine print_qsUGW(nBas,nO,nSCF,Conv,thresh,eHF,eGW,cGW,Ov,ENuc,ET,EV,EJ,Ex,EcGM,EcRPA,EqsGW,SigC,Z,dipole) ! Print one-electron energies and other stuff for qsUGW diff --git a/src/GW/qsRGW.f90 b/src/GW/qsRGW.f90 index 99bf0c0..c480fcd 100644 --- a/src/GW/qsRGW.f90 +++ b/src/GW/qsRGW.f90 @@ -74,7 +74,7 @@ subroutine qsRGW(maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dophBSE,do logical :: dRPA = .true. logical :: print_W = .false. - double precision,allocatable :: error_diis(:,:) + double precision,allocatable :: err_diis(:,:) double precision,allocatable :: F_diis(:,:) double precision,allocatable :: Aph(:,:) double precision,allocatable :: Bph(:,:) @@ -93,7 +93,7 @@ subroutine qsRGW(maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dophBSE,do double precision,allocatable :: SigC(:,:) double precision,allocatable :: SigCp(:,:) double precision,allocatable :: Z(:) - double precision,allocatable :: error(:,:) + double precision,allocatable :: err(:,:) ! Hello world @@ -131,20 +131,20 @@ subroutine qsRGW(maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dophBSE,do allocate(eGW(nBas),c(nBas,nBas),cp(nBas,nBas),P(nBas,nBas),F(nBas,nBas),Fp(nBas,nBas), & J(nBas,nBas),K(nBas,nBas),SigC(nBas,nBas),SigCp(nBas,nBas),Z(nBas), & Aph(nS,nS),Bph(nS,nS),Om(nS),XpY(nS,nS),XmY(nS,nS),rho(nBas,nBas,nS), & - error(nBas,nBas),error_diis(nBasSq,max_diis),F_diis(nBasSq,max_diis)) + err(nBas,nBas),err_diis(nBasSq,max_diis),F_diis(nBasSq,max_diis)) ! Initialization - nSCF = -1 - n_diis = 0 - ispin = 1 - Conv = 1d0 - P(:,:) = PHF(:,:) - eGW(:) = eHF(:) - c(:,:) = cHF(:,:) - F_diis(:,:) = 0d0 - error_diis(:,:) = 0d0 - rcond = 0d0 + nSCF = -1 + n_diis = 0 + ispin = 1 + Conv = 1d0 + P(:,:) = PHF(:,:) + eGW(:) = eHF(:) + c(:,:) = cHF(:,:) + F_diis(:,:) = 0d0 + err_diis(:,:) = 0d0 + rcond = 0d0 !------------------------------------------------------------------------ ! Main loop @@ -200,15 +200,15 @@ subroutine qsRGW(maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dophBSE,do ! Compute commutator and convergence criteria - error = matmul(F,matmul(P,S)) - matmul(matmul(S,P),F) + err = matmul(F,matmul(P,S)) - matmul(matmul(S,P),F) - if(nSCF > 1) Conv = maxval(abs(error)) + if(nSCF > 1) Conv = maxval(abs(err)) ! DIIS extrapolation if(max_diis > 1) then n_diis = min(n_diis+1,max_diis) - call DIIS_extrapolation(rcond,nBasSq,nBasSq,n_diis,error_diis,F_diis,error,F) + call DIIS_extrapolation(rcond,nBasSq,nBasSq,n_diis,err_diis,F_diis,err,F) end if ! Diagonalize Hamiltonian in AO basis @@ -273,7 +273,7 @@ subroutine qsRGW(maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dophBSE,do ! Deallocate memory - deallocate(c,cp,P,F,Fp,J,K,SigC,SigCp,Z,Om,XpY,XmY,rho,error,error_diis,F_diis) + deallocate(c,cp,P,F,Fp,J,K,SigC,SigCp,Z,Om,XpY,XmY,rho,err,err_diis,F_diis) ! Perform BSE calculation diff --git a/src/GW/qsUGW.f90 b/src/GW/qsUGW.f90 index 4c62060..ee91ec2 100644 --- a/src/GW/qsUGW.f90 +++ b/src/GW/qsUGW.f90 @@ -241,15 +241,19 @@ subroutine qsUGW(maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,BSE,TDA_W, err(:,:,is) = matmul(F(:,:,is),matmul(P(:,:,is),S(:,:))) - matmul(matmul(S(:,:),P(:,:,is)),F(:,:,is)) end do - if(nSCF > 1) Conv = maxval(abs(err(:,:,:))) + if(nSCF > 1) Conv = maxval(abs(err)) ! DIIS extrapolation - n_diis = min(n_diis+1,max_diis) - do is=1,nspin - if(nO(is) > 1) call DIIS_extrapolation(rcond(is),nBasSq,nBasSq,n_diis,err_diis(:,1:n_diis,is), & - F_diis(:,1:n_diis,is),err(:,:,is),F(:,:,is)) - end do + if(max_diis > 1) then + + n_diis = min(n_diis+1,max_diis) + do is=1,nspin + if(nO(is) > 1) call DIIS_extrapolation(rcond(is),nBasSq,nBasSq,n_diis,err_diis(:,1:n_diis,is), & + F_diis(:,1:n_diis,is),err(:,:,is),F(:,:,is)) + end do + + end if ! Transform Fock matrix in orthogonal basis