From 56db8456b99b2cc8bec0aab29658291ae5bee651 Mon Sep 17 00:00:00 2001 From: Abdallah Ammar Date: Wed, 28 Aug 2024 18:59:55 +0200 Subject: [PATCH] introduce nBas_MOs in AOtoMO_ERI_RHF --- src/AOtoMO/AOtoMO_ERI_RHF.f90 | 50 +++++++++++++++++++++++++---------- src/GF/qsRGF2.f90 | 2 +- src/GT/qsRGTeh.f90 | 2 +- src/GT/qsRGTpp.f90 | 2 +- src/GW/SRG_qsGW.f90 | 4 +-- src/GW/qsRGW.f90 | 2 +- src/HF/RHF_search.f90 | 2 +- src/QuAcK/RQuAcK.f90 | 7 ++--- 8 files changed, 45 insertions(+), 26 deletions(-) diff --git a/src/AOtoMO/AOtoMO_ERI_RHF.f90 b/src/AOtoMO/AOtoMO_ERI_RHF.f90 index c93e111..6b1b95b 100644 --- a/src/AOtoMO/AOtoMO_ERI_RHF.f90 +++ b/src/AOtoMO/AOtoMO_ERI_RHF.f90 @@ -1,4 +1,7 @@ -subroutine AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO) + +! --- + +subroutine AOtoMO_ERI_RHF(nBas_AOs, nBas_MOs, c, ERI_AO, ERI_MO) ! AO to MO transformation of two-electron integrals via the semi-direct O(N^5) algorithm @@ -7,32 +10,51 @@ subroutine AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO) ! Input variables - integer,intent(in) :: nBas - double precision,intent(in) :: ERI_AO(nBas,nBas,nBas,nBas) - double precision,intent(in) :: c(nBas,nBas) + integer,intent(in) :: nBas_AOs, nBas_MOs + double precision,intent(in) :: ERI_AO(nBas_AOs,nBas_AOs,nBas_AOs,nBas_AOs) + double precision,intent(in) :: c(nBas_AOs,nBas_MOs) ! Local variables - double precision,allocatable :: scr(:,:,:,:) - integer :: mu,nu,la,si - integer :: i,j,k,l + double precision,allocatable :: a1(:,:,:,:) + double precision,allocatable :: a2(:,:,:,:) ! Output variables - double precision,intent(out) :: ERI_MO(nBas,nBas,nBas,nBas) + double precision,intent(out) :: ERI_MO(nBas_MOs,nBas_MOs,nBas_MOs,nBas_MOs) ! Memory allocation - allocate(scr(nBas,nBas,nBas,nBas)) + allocate(a2(nBas_AOs,nBas_AOs,nBas_AOs,nBas_MOs)) + allocate(a1(nBas_AOs,nBas_AOs,nBas_MOs,nBas_MOs)) ! Four-index transform via semi-direct O(N^5) algorithm - call dgemm('T','N',nBas**3,nBas,nBas,1d0,ERI_AO,nBas,c(1,1),size(c,1),0d0,scr,nBas**3) - - call dgemm('T','N',nBas**3,nBas,nBas,1d0,scr,nBas,c(1,1),size(c,1),0d0,ERI_MO,nBas**3) + call dgemm( 'T', 'N', nBas_AOs*nBas_AOs*nBas_AOs, nBas_MOs, nBas_AOs, 1.d0 & + , ERI_AO(1,1,1,1), nBas_AOs, c(1,1), nBas_AOs & + , 0.d0, a2(1,1,1,1), nBas_AOs*nBas_AOs*nBas_AOs) - call dgemm('T','N',nBas**3,nBas,nBas,1d0,ERI_MO,nBas,c(1,1),size(c,1),0d0,scr,nBas**3) + call dgemm( 'T', 'N', nBas_AOs*nBas_AOs*nBas_MOs, nBas_MOs, nBas_AOs, 1.d0 & + , a2(1,1,1,1), nBas_AOs, c(1,1), nBas_AOs & + , 0.d0, a1(1,1,1,1), nBas_AOs*nBas_AOs*nBas_MOs) - call dgemm('T','N',nBas**3,nBas,nBas,1d0,scr,nBas,c(1,1),size(c,1),0d0,ERI_MO,nBas**3) + deallocate(a2) + allocate(a2(nBas_AOs,nBas_MOs,nBas_MOs,nBas_MOs)) + + call dgemm( 'T', 'N', nBas_AOs*nBas_MOs*nBas_MOs, nBas_MOs, nBas_AOs, 1.d0 & + , a1(1,1,1,1), nBas_AOs, c(1,1), nBas_AOs & + , 0.d0, a2(1,1,1,1), nBas_AOs*nBas_MOs*nBas_MOs) + + deallocate(a1) + + call dgemm( 'T', 'N', nBas_MOs*nBas_MOs*nBas_MOs, nBas_MOs, nBas_AOs, 1.d0 & + , a2(1,1,1,1), nBas_AOs, c(1,1), nBas_AOs & + , 0.d0, ERI_MO(1,1,1,1), nBas_MOs*nBas_MOs*nBas_MOs) + + deallocate(a2) end subroutine + + + + diff --git a/src/GF/qsRGF2.f90 b/src/GF/qsRGF2.f90 index cb744c9..9a2d71b 100644 --- a/src/GF/qsRGF2.f90 +++ b/src/GF/qsRGF2.f90 @@ -143,7 +143,7 @@ subroutine qsRGF2(dotest,maxSCF,thresh,max_diis,dophBSE,doppBSE,TDA,dBSE,dTDA,si ! AO to MO transformation of two-electron integrals - call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO) + call AOtoMO_ERI_RHF(nBas,nBas,c,ERI_AO,ERI_MO) ! Compute self-energy and renormalization factor diff --git a/src/GT/qsRGTeh.f90 b/src/GT/qsRGTeh.f90 index 60f8d1b..889e752 100644 --- a/src/GT/qsRGTeh.f90 +++ b/src/GT/qsRGTeh.f90 @@ -169,7 +169,7 @@ subroutine qsRGTeh(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,d ! AO to MO transformation of two-electron integrals - call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO) + call AOtoMO_ERI_RHF(nBas,nBas,c,ERI_AO,ERI_MO) ! Compute linear response diff --git a/src/GT/qsRGTpp.f90 b/src/GT/qsRGTpp.f90 index 9cb12da..9f4e78b 100644 --- a/src/GT/qsRGTpp.f90 +++ b/src/GT/qsRGTpp.f90 @@ -182,7 +182,7 @@ subroutine qsRGTpp(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,d ! AO to MO transformation of two-electron integrals - call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO) + call AOtoMO_ERI_RHF(nBas,nBas,c,ERI_AO,ERI_MO) ! Compute linear response diff --git a/src/GW/SRG_qsGW.f90 b/src/GW/SRG_qsGW.f90 index 84c953f..da87210 100644 --- a/src/GW/SRG_qsGW.f90 +++ b/src/GW/SRG_qsGW.f90 @@ -178,11 +178,11 @@ subroutine SRG_qsGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS, call AOtoMO(nBas,nBas,cHF,dipole_int_AO(:,:,ixyz),dipole_int_MO(:,:,ixyz)) end do - call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO) + call AOtoMO_ERI_RHF(nBas,nBas,c,ERI_AO,ERI_MO) call wall_time(tao2) - tao = tao + tao2 -tao1 + tao = tao + tao2 - tao1 ! Compute linear response diff --git a/src/GW/qsRGW.f90 b/src/GW/qsRGW.f90 index a0df0e5..96af23b 100644 --- a/src/GW/qsRGW.f90 +++ b/src/GW/qsRGW.f90 @@ -169,7 +169,7 @@ subroutine qsRGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dop call AOtoMO(nBas,nBas,c,dipole_int_AO(:,:,ixyz),dipole_int_MO(:,:,ixyz)) end do - call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO) + call AOtoMO_ERI_RHF(nBas,nBas,c,ERI_AO,ERI_MO) ! Compute linear response diff --git a/src/HF/RHF_search.f90 b/src/HF/RHF_search.f90 index b28469f..c568fd3 100644 --- a/src/HF/RHF_search.f90 +++ b/src/HF/RHF_search.f90 @@ -111,7 +111,7 @@ subroutine RHF_search(maxSCF,thresh,max_diis,guess_type,level_shift,nNuc,ZNuc,rN do ixyz=1,ncart call AOtoMO(nBas,nBas,c,dipole_int_AO(:,:,ixyz),dipole_int_MO(:,:,ixyz)) end do - call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO) + call AOtoMO_ERI_RHF(nBas,nBas,c,ERI_AO,ERI_MO) call wall_time(end_AOtoMO) t_AOtoMO = end_AOtoMO - start_AOtoMO diff --git a/src/QuAcK/RQuAcK.f90 b/src/QuAcK/RQuAcK.f90 index 980a102..26f817a 100644 --- a/src/QuAcK/RQuAcK.f90 +++ b/src/QuAcK/RQuAcK.f90 @@ -135,7 +135,6 @@ subroutine RQuAcK(dotest,doRHF,doROHF,dostab,dosearch,doMP2,doMP3,doCCD,dopCCD,d if(doROHF) then call wall_time(start_HF) - ! TODO call ROHF(dotest, maxSCF_HF, thresh_HF, max_diis_HF, guess_type, mix, level_shift, nNuc, ZNuc, rNuc, ENuc, & nBas_AOs, nBas_MOs, nO, S, T, V, Hc, ERI_AO, dipole_int_AO, X, ERHF, eHF, cHF, PHF) call wall_time(end_HF) @@ -159,14 +158,12 @@ subroutine RQuAcK(dotest,doRHF,doROHF,dostab,dosearch,doMP2,doMP3,doCCD,dopCCD,d ! Read and transform dipole-related integrals do ixyz = 1, ncart - ! TODO - call AOtoMO(nBas_AOs,nBas_MOs,cHF,dipole_int_AO(:,:,ixyz),dipole_int_MO(:,:,ixyz)) + call AOtoMO(nBas_AOs, nBas_MOs, cHF, dipole_int_AO(1,1,ixyz), dipole_int_MO(1,1,ixyz)) end do ! 4-index transform - ! TODO - call AOtoMO_ERI_RHF(nBas_AOs,cHF,ERI_AO,ERI_MO) + call AOtoMO_ERI_RHF(nBas_AOs, nBas_MOs, cHF, ERI_AO, ERI_MO) call wall_time(end_AOtoMO)