clean up AOtoMO transform

This commit is contained in:
Pierre-Francois Loos 2023-11-22 17:02:46 +01:00
parent fc0d471481
commit a37cfb496e
18 changed files with 78 additions and 41 deletions

View File

@ -1,4 +1,4 @@
subroutine AOtoMO_ERI_GHF(nBas,nBas2,c1,c2,c3,c4,ERI_AO_basis,ERI_MO_basis)
subroutine AOtoMO_ERI_GHF(nBas,nBas2,c1,c2,ERI_AO_basis,ERI_MO_basis)
! AO to MO transformation of two-electron integrals via the semi-direct O(N^5) algorithm
! bra and ket are the spin of (bra1 bra2|ket1 ket2)
@ -13,8 +13,6 @@ subroutine AOtoMO_ERI_GHF(nBas,nBas2,c1,c2,c3,c4,ERI_AO_basis,ERI_MO_basis)
double precision,intent(in) :: ERI_AO_basis(nBas,nBas,nBas,nBas)
double precision,intent(in) :: c1(nBas,nBas2)
double precision,intent(in) :: c2(nBas,nBas2)
double precision,intent(in) :: c3(nBas,nBas2)
double precision,intent(in) :: c4(nBas,nBas2)
! Local variables
@ -38,7 +36,7 @@ subroutine AOtoMO_ERI_GHF(nBas,nBas2,c1,c2,c3,c4,ERI_AO_basis,ERI_MO_basis)
do la=1,nBas
do nu=1,nBas
do mu=1,nBas
scr(mu,nu,la,l) = scr(mu,nu,la,l) + ERI_AO_basis(mu,nu,la,si)*c4(si,l)
scr(mu,nu,la,l) = scr(mu,nu,la,l) + ERI_AO_basis(mu,nu,la,si)*c2(si,l)
enddo
enddo
enddo
@ -66,7 +64,7 @@ subroutine AOtoMO_ERI_GHF(nBas,nBas2,c1,c2,c3,c4,ERI_AO_basis,ERI_MO_basis)
do la=1,nBas
do nu=1,nBas
do i=1,nBas2
scr(i,nu,k,l) = scr(i,nu,k,l) + ERI_MO_basis(i,nu,la,l)*c3(la,k)
scr(i,nu,k,l) = scr(i,nu,k,l) + ERI_MO_basis(i,nu,la,l)*c1(la,k)
enddo
enddo
enddo

View File

@ -0,0 +1,38 @@
subroutine AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO)
! AO to MO transformation of two-electron integrals via the semi-direct O(N^5) algorithm
implicit none
include 'parameters.h'
! Input variables
integer,intent(in) :: nBas
double precision,intent(in) :: ERI_AO(nBas,nBas,nBas,nBas)
double precision,intent(in) :: c(nBas,nBas)
! Local variables
double precision,allocatable :: scr(:,:,:,:)
integer :: mu,nu,la,si
integer :: i,j,k,l
! Output variables
double precision,intent(out) :: ERI_MO(nBas,nBas,nBas,nBas)
! Memory allocation
allocate(scr(nBas,nBas,nBas,nBas))
! 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**3,nBas,nBas,1d0,ERI_MO,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)
end subroutine

View File

@ -1,4 +1,4 @@
subroutine AOtoMO_ERI(bra,ket,nBas,c,ERI_AO,ERI_MO)
subroutine AOtoMO_ERI_UHF(bra,ket,nBas,c,ERI_AO,ERI_MO)
! AO to MO transformation of two-electron integrals via the semi-direct O(N^5) algorithm
! bra and ket are the spin of (bra|ket) = (bra bra|ket ket) = <bra ket|bra ket>
@ -11,7 +11,8 @@ subroutine AOtoMO_ERI(bra,ket,nBas,c,ERI_AO,ERI_MO)
integer,intent(in) :: bra
integer,intent(in) :: ket
integer,intent(in) :: nBas
double precision,intent(in) :: ERI_AO(nBas,nBas,nBas,nBas),c(nBas,nBas,nspin)
double precision,intent(in) :: ERI_AO(nBas,nBas,nBas,nBas)
double precision,intent(in) :: c(nBas,nBas,nspin)
! Local variables

View File

@ -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(1,1,nBas,c,ERI_AO,ERI_MO)
call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO)
! Compute self-energy and renormalization factor

View File

@ -166,15 +166,15 @@ subroutine qsUGF2(dotest,maxSCF,thresh,max_diis,BSE,TDA,dBSE,dTDA,spin_conserved
! 4-index transform for (aa|aa) block
call AOtoMO_ERI(1,1,nBas,c,ERI_AO,ERI_aaaa)
call AOtoMO_ERI_UHF(1,1,nBas,c,ERI_AO,ERI_aaaa)
! 4-index transform for (aa|bb) block
call AOtoMO_ERI(1,2,nBas,c,ERI_AO,ERI_aabb)
call AOtoMO_ERI_UHF(1,2,nBas,c,ERI_AO,ERI_aabb)
! 4-index transform for (bb|bb) block
call AOtoMO_ERI(2,2,nBas,c,ERI_AO,ERI_bbbb)
call AOtoMO_ERI_UHF(2,2,nBas,c,ERI_AO,ERI_bbbb)
!------------------------------------------------!
! Compute self-energy and renormalization factor !

View File

@ -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(1,1,nBas,c,ERI_AO,ERI_MO)
call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO)
! Compute linear response

View File

@ -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(1,1,nBas,c,ERI_AO,ERI_MO)
call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO)
! Compute linear response

View File

@ -190,15 +190,15 @@ subroutine qsUGTpp(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,B
! 4-index transform for (aa|aa) block
call AOtoMO_ERI(1,1,nBas,c,ERI_AO,ERI_aaaa)
call AOtoMO_ERI_UHF(1,1,nBas,c,ERI_AO,ERI_aaaa)
! 4-index transform for (aa|bb) block
call AOtoMO_ERI(1,2,nBas,c,ERI_AO,ERI_aabb)
call AOtoMO_ERI_UHF(1,2,nBas,c,ERI_AO,ERI_aabb)
! 4-index transform for (bb|bb) block
call AOtoMO_ERI(2,2,nBas,c,ERI_AO,ERI_bbbb)
call AOtoMO_ERI_UHF(2,2,nBas,c,ERI_AO,ERI_bbbb)
!----------------------------------------------
! alpha-beta block

View File

@ -176,7 +176,7 @@ subroutine SRG_qsGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,
call AOtoMO(nBas,cHF,dipole_int_AO(:,:,ixyz),dipole_int_MO(:,:,ixyz))
end do
call AOtoMO_ERI(1,1,nBas,c,ERI_AO,ERI_MO)
call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO)
call wall_time(tao2)

View File

@ -237,16 +237,16 @@ subroutine qsGGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dop
call AOtoMO_GHF(nBas,nBas2,Ca,Cb,dipole_int_AO(:,:,ixyz),dipole_int_MO(:,:,ixyz))
end do
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Ca,Ca,Ca,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Ca,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_tmp(:,:,:,:)
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Cb,Ca,Cb,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Cb,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_MO(:,:,:,:) + ERI_tmp(:,:,:,:)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Ca,Cb,Ca,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Ca,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_MO(:,:,:,:) + ERI_tmp(:,:,:,:)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Cb,Cb,Cb,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Cb,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_MO(:,:,:,:) + ERI_tmp(:,:,:,:)
deallocate(ERI_tmp)

View File

@ -172,7 +172,7 @@ subroutine qsRGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dop
call AOtoMO(nBas,c,dipole_int_AO(:,:,ixyz),dipole_int_MO(:,:,ixyz))
end do
call AOtoMO_ERI(1,1,nBas,c,ERI_AO,ERI_MO)
call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO)
! Compute linear response

View File

@ -191,15 +191,15 @@ subroutine qsUGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,BSE
! 4-index transform for (aa|aa) block
call AOtoMO_ERI(1,1,nBas,c,ERI_AO,ERI_aaaa)
call AOtoMO_ERI_UHF(1,1,nBas,c,ERI_AO,ERI_aaaa)
! 4-index transform for (aa|bb) block
call AOtoMO_ERI(1,2,nBas,c,ERI_AO,ERI_aabb)
call AOtoMO_ERI_UHF(1,2,nBas,c,ERI_AO,ERI_aabb)
! 4-index transform for (bb|bb) block
call AOtoMO_ERI(2,2,nBas,c,ERI_AO,ERI_bbbb)
call AOtoMO_ERI_UHF(2,2,nBas,c,ERI_AO,ERI_bbbb)
! Compute linear response

View File

@ -122,16 +122,16 @@ subroutine GHF_search(maxSCF,thresh,max_diis,guess_type,mix,level_shift,nNuc,ZNu
! 4-index transform
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Ca,Ca,Ca,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Ca,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_tmp(:,:,:,:)
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Cb,Ca,Cb,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Cb,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_MO(:,:,:,:) + ERI_tmp(:,:,:,:)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Ca,Cb,Ca,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Ca,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_MO(:,:,:,:) + ERI_tmp(:,:,:,:)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Cb,Cb,Cb,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Cb,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_MO(:,:,:,:) + ERI_tmp(:,:,:,:)
deallocate(Ca,Cb,ERI_tmp)

View File

@ -107,7 +107,7 @@ subroutine RHF_search(maxSCF,thresh,max_diis,guess_type,level_shift,nNuc,ZNuc,rN
write(*,*)
write(*,*) 'AO to MO transformation... Please be patient'
write(*,*)
call AOtoMO_ERI(1,1,nBas,c,ERI_AO,ERI_MO)
call AOtoMO_ERI_RHF(nBas,c,ERI_AO,ERI_MO)
call wall_time(end_AOtoMO)
t_AOtoMO = end_AOtoMO - start_AOtoMO

View File

@ -120,13 +120,13 @@ subroutine UHF_search(maxSCF,thresh,max_diis,guess_type,mix,level_shift,nNuc,ZNu
write(*,*)
! 4-index transform for (aa|aa) block
call AOtoMO_ERI(1,1,nBas,c,ERI_AO,ERI_aaaa)
call AOtoMO_ERI_UHF(1,1,nBas,c,ERI_AO,ERI_aaaa)
! 4-index transform for (aa|bb) block
call AOtoMO_ERI(1,2,nBas,c,ERI_AO,ERI_aabb)
call AOtoMO_ERI_UHF(1,2,nBas,c,ERI_AO,ERI_aabb)
! 4-index transform for (bb|bb) block
call AOtoMO_ERI(2,2,nBas,c,ERI_AO,ERI_bbbb)
call AOtoMO_ERI_UHF(2,2,nBas,c,ERI_AO,ERI_bbbb)
call wall_time(end_AOtoMO)

View File

@ -144,16 +144,16 @@ subroutine GQuAcK(dotest,doGHF,dostab,dosearch,doMP2,doMP3,doCCD,dopCCD,doDCD,do
! 4-index transform
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Ca,Ca,Ca,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Ca,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_tmp(:,:,:,:)
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Cb,Ca,Cb,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Ca,Cb,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_MO(:,:,:,:) + ERI_tmp(:,:,:,:)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Ca,Cb,Ca,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Ca,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_MO(:,:,:,:) + ERI_tmp(:,:,:,:)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Cb,Cb,Cb,ERI_AO,ERI_tmp)
call AOtoMO_ERI_GHF(nBas,nBas2,Cb,Cb,ERI_AO,ERI_tmp)
ERI_MO(:,:,:,:) = ERI_MO(:,:,:,:) + ERI_tmp(:,:,:,:)
deallocate(Ca,Cb,ERI_tmp)

View File

@ -158,7 +158,7 @@ subroutine RQuAcK(dotest,doRHF,doROHF,dostab,dosearch,doMP2,doMP3,doCCD,dopCCD,d
! 4-index transform
call AOtoMO_ERI(1,1,nBas,cHF,ERI_AO,ERI_MO)
call AOtoMO_ERI_RHF(nBas,cHF,ERI_AO,ERI_MO)
call wall_time(end_AOtoMO)

View File

@ -167,15 +167,15 @@ subroutine UQuAcK(dotest,doUHF,dostab,dosearch,doMP2,doMP3,doCCD,dopCCD,doDCD,do
! 4-index transform for (aa|aa) block
call AOtoMO_ERI(1,1,nBas,cHF,ERI_AO,ERI_aaaa)
call AOtoMO_ERI_UHF(1,1,nBas,cHF,ERI_AO,ERI_aaaa)
! 4-index transform for (aa|bb) block
call AOtoMO_ERI(1,2,nBas,cHF,ERI_AO,ERI_aabb)
call AOtoMO_ERI_UHF(1,2,nBas,cHF,ERI_AO,ERI_aabb)
! 4-index transform for (bb|bb) block
call AOtoMO_ERI(2,2,nBas,cHF,ERI_AO,ERI_bbbb)
call AOtoMO_ERI_UHF(2,2,nBas,cHF,ERI_AO,ERI_bbbb)
call wall_time(end_AOtoMO)