4
1
mirror of https://github.com/pfloos/quack synced 2024-09-26 19:41:00 +02:00

openMP implementation of the VV block for ppBSE@GF2

This commit is contained in:
Antoine Marie 2024-09-06 11:26:47 +02:00
parent 2fd6158722
commit 3111666d15
27 changed files with 153 additions and 124 deletions

View File

@ -1,3 +0,0 @@
1
Argon; atom; s
Ar 0.0 0.0 0.0

View File

@ -1,4 +0,0 @@
2
Fluoroborane; experimental structure from HCP92; s
B 0.0000 0.0000 0.0000
F 0.0000 0.0000 1.2626

View File

@ -1,6 +0,0 @@
4
Borane; experimental structure from HCP92; s
B 0.0000 0.0000 0.0000
H 0.0000 0.0000 1.19
H 0.0000 1.0306 -0.595
H 0.0000 -1.0306 -0.595

View File

@ -1,4 +0,0 @@
2
Boron nitride; experimental structure from HCP92; s
B 0.0000 0.0000 0.0000
N 0.0000 0.0000 1.281

View File

@ -1,4 +0,0 @@
2
Beryllium monoxide; experimental structure from HCP92; s
Be 0.0000 0.0000 0.0000
O 0.0000 0.0000 1.3308

View File

@ -1,7 +0,0 @@
5
Methane; experimental structure from HCP92; m
C 0.0000 0.0000 0.0000
H 0.6276 -0.6275 0.6276
H -0.6276 0.6276 0.6276
H -0.6276 -0.6276 -0.6276
H 0.6276 0.6276 -0.6276

View File

@ -1,4 +0,0 @@
2
Carbon monoxide; experimental structure from HCP92; s
C 0.0000 0.0000 0.0000
O 0.0000 0.0000 1.283

View File

@ -1,4 +0,0 @@
2
Copper dimer; experimental structure form HCP92; s
Cu 0.0 0.0 0.0
Cu 0.0 0.0 2.2197

View File

@ -1,4 +0,0 @@
2
Fluorine; experimental structure from HCP92; s
F 0.0000 0.0000 0.0000
F 0.0000 0.0000 1.4119

View File

@ -1,4 +0,0 @@
2
Hydrogen; experimental structure from HCP92; s
H 0.0000 0.0000 0.0000
H 0.0000 0.0000 0.74144

View File

@ -1,5 +0,0 @@
3
Water; experimental structure from HCP92; s
O 0.0000 0.0000 0.0000
H 0.7571 0.0000 0.5861
H -0.7571 0.0000 0.5861

View File

@ -1,4 +0,0 @@
2
Hydrogen chloride; experimental structure from HCP92; s
H 0.0000 0.0000 0.0000
Cl 0.0000 0.0000 1.2746

View File

@ -1,4 +0,0 @@
2
Hydrogen fluoride; experimental structure from HCP92; s
H 0.0000 0.0000 0.0000
F 0.0000 0.0000 0.9169

View File

@ -1,3 +0,0 @@
1
Helium; atom; s
He 0.0 0.0 0.0

View File

@ -1,4 +0,0 @@
2
Lithium dimer; experimental structure from HCP92; s
Li 0.0000 0.0000 0.0000
Li 0.0000 0.0000 2.6729

View File

@ -1,4 +0,0 @@
2
Lithium fluoride; experimental structure from HCP92; s
Li 0.0000 0.0000 0.0000
F 0.0000 0.0000 1.5639

View File

@ -1,4 +0,0 @@
2
Lithium hydride; experimental structure from HCP92; s
Li 0.0000 0.0000 0.0000
H 0.0000 0.0000 1.5949

View File

@ -1,4 +0,0 @@
2
Nitrogen; experimental structure from HCP92; s
N 0.0000 0.0000 0.0000
N 0.0000 0.0000 1.0977

View File

@ -1,6 +0,0 @@
4
Amonia; experimental structure from HCP92; s
N 0.0000 0.0000 0.0000
H 0.0000 -0.9377 -0.3816
H 0.8121 0.4689 -0.3816
H -0.8121 0.4689 -0.3816

View File

@ -1,3 +0,0 @@
1
Neon; atom; s
Ne 0.0 0.0 0.0

View File

@ -1,5 +0,0 @@
3
Ozon; experimental structure from HCP92; s
O 0.0000 0.0000 0.0000
O 1.0869 0.0000 0.6600
O -1.0869 0.0000 0.6600

View File

@ -1,5 +0,0 @@
3
Hydrogen sulfide; experimental structure from HCP92; s
S 0.0000 0.0000 0.0000
H 0.9617 0.0000 0.9268
H -0.9617 0.0000 0.9268

View File

@ -25,8 +25,11 @@ subroutine RGF2_ppBSE2_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI
double precision :: dem,num
integer :: m
integer :: a,b,c,d,e
integer :: ab,cd
integer :: a0,aa,ab,cd
double precision :: eta2
double precision, allocatable :: Om_tmp(:,:)
! Output variables
double precision,intent(out) :: KC_sta(nVV,nVV)
@ -34,15 +37,39 @@ subroutine RGF2_ppBSE2_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI
! Initialization
KC_sta(:,:) = 0d0
eta2 = eta * eta
allocate(Om_tmp(nO,nV))
! Compute the energy differences and denominator once and store them in a temporary array
!$OMP PARALLEL DEFAULT(NONE) PRIVATE(m,e,dem) SHARED(nC,nO,nBas,nR, eta2, eGF, Om_tmp)
!$OMP DO
do m=nC+1,nO
do e=nO+1,nBas-nR
dem = eGF(m) - eGF(e)
Om_tmp(m,e) = dem / (dem*dem + eta2)
enddo
enddo
!$OMP END DO
!$OMP END PARALLEL
! Second-order correlation kernel for the block C of the singlet manifold
! --- --- ---
! OpenMP implementation
! --- --- ---
if(ispin == 1) then
ab = 0
a0 = nBas - nR - nO
!$OMP PARALLEL DEFAULT(NONE) &
!$OMP PRIVATE(a, b, aa, ab, c, d, cd, m, e, num) &
!$OMP SHARED(nO, nBas, nR, nC, a0, ERI, Om_tmp, KC_sta, lambda)
!$OMP DO
do a=nO+1,nBas-nR
aa = a0 * (a - nO - 1) - (a - nO - 1) * (a - nO) / 2 - nO
do b=a,nBas-nR
ab = ab + 1
ab = aa + b
cd = 0
do c=nO+1,nBas-nR
@ -52,39 +79,91 @@ subroutine RGF2_ppBSE2_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI
do m=nC+1,nO
do e=nO+1,nBas-nR
dem = eGF(m) - eGF(e)
num = 2d0*ERI(a,m,c,e)*ERI(b,e,d,m) - ERI(a,m,c,e)*ERI(b,e,m,d) &
- ERI(a,m,e,c)*ERI(b,e,d,m) - ERI(a,m,e,c)*ERI(b,e,m,d)
KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
KC_sta(ab,cd) = KC_sta(ab,cd) + num * Om_tmp(m,e)
dem = eGF(m) - eGF(e)
num = 2d0*ERI(b,m,c,e)*ERI(a,e,d,m) - ERI(b,m,c,e)*ERI(a,e,m,d) &
- ERI(b,m,e,c)*ERI(a,e,d,m) - ERI(b,m,e,c)*ERI(a,e,m,d)
KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
KC_sta(ab,cd) = KC_sta(ab,cd) + num * Om_tmp(m,e)
end do
end do
end do
KC_sta(ab,cd) = 2d0*lambda*KC_sta(ab,cd)/sqrt((1d0 + Kronecker_delta(a,b))*(1d0 + Kronecker_delta(c,d)))
KC_sta(ab,cd) = 2d0*lambda*KC_sta(ab,cd)/sqrt((1d0 + Kronecker_delta(a,b))*(1d0 + Kronecker_delta(c,d)))
end do
end do
end do
end do
end do
end do
!$OMP END DO
!$OMP END PARALLEL
end if
! --- --- ---
! Naive implementation
! --- --- ---
! if(ispin == 1) then
! ab = 0
! do a=nO+1,nBas-nR
! do b=a,nBas-nR
! ab = ab + 1
! cd = 0
! do c=nO+1,nBas-nR
! do d=c,nBas-nR
! cd = cd + 1
! do m=nC+1,nO
! do e=nO+1,nBas-nR
! dem = eGF(m) - eGF(e)
! num = 2d0*ERI(a,m,c,e)*ERI(b,e,d,m) - ERI(a,m,c,e)*ERI(b,e,m,d) &
! - ERI(a,m,e,c)*ERI(b,e,d,m) - ERI(a,m,e,c)*ERI(b,e,m,d)
! KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
! dem = eGF(m) - eGF(e)
! num = 2d0*ERI(b,m,c,e)*ERI(a,e,d,m) - ERI(b,m,c,e)*ERI(a,e,m,d) &
! - ERI(b,m,e,c)*ERI(a,e,d,m) - ERI(b,m,e,c)*ERI(a,e,m,d)
! KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
! end do
! end do
! KC_sta(ab,cd) = 2d0*lambda*KC_sta(ab,cd)/sqrt((1d0 + Kronecker_delta(a,b))*(1d0 + Kronecker_delta(c,d)))
! end do
! end do
! end do
! end do
! end if
! Second-order correlation kernel for the block C of the triplet manifold
! --- --- ---
! OpenMP implementation
! --- --- ---
if(ispin == 2) then
ab = 0
do a=nO+1,nBas-nR
do b=a+1,nBas-nR
ab = ab + 1
a0 = nBas - nR - nO - 1
!$OMP PARALLEL DEFAULT(NONE) &
!$OMP PRIVATE(a, b, aa, ab, c, d, cd, m, e, num) &
!$OMP SHARED(nO, nBas, nR, nC, a0, ERI, Om_tmp, KC_sta)
!$OMP DO
do a = nO+1, nBas-nR
aa = a0 * (a - nO - 1) - (a - nO - 1) * (a - nO) / 2 - nO - 1
do b = a+1, nBas-nR
ab = aa + b
cd = 0
do c=nO+1,nBas-nR
@ -94,17 +173,15 @@ subroutine RGF2_ppBSE2_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI
do m=nC+1,nO
do e=nO+1,nBas-nR
dem = eGF(m) - eGF(e)
num = 2d0*ERI(a,m,c,e)*ERI(b,e,d,m) - ERI(a,m,c,e)*ERI(b,e,m,d) &
- ERI(a,m,e,c)*ERI(b,e,d,m) + ERI(a,m,e,c)*ERI(b,e,m,d)
KC_sta(ab,cd) = KC_sta(ab,cd) + 2d0*num*dem/(dem**2 + eta**2)
KC_sta(ab,cd) = KC_sta(ab,cd) + 2d0 * num * Om_tmp(m,e)
dem = eGF(m) - eGF(e)
num = 2d0*ERI(b,m,c,e)*ERI(a,e,d,m) - ERI(b,m,c,e)*ERI(a,e,m,d) &
- ERI(b,m,e,c)*ERI(a,e,d,m) + ERI(b,m,e,c)*ERI(a,e,m,d)
KC_sta(ab,cd) = KC_sta(ab,cd) - 2d0*num*dem/(dem**2 + eta**2)
KC_sta(ab,cd) = KC_sta(ab,cd) - 2d0 * num * Om_tmp(m,e)
end do
end do
@ -114,7 +191,54 @@ subroutine RGF2_ppBSE2_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI
end do
end do
!$OMP END DO
!$OMP END PARALLEL
end if
! --- --- ---
! Naive implementation
! --- --- ---
! if(ispin == 2) then
! ab = 0
! do a=nO+1,nBas-nR
! do b=a+1,nBas-nR
! ab = ab + 1
! cd = 0
! do c=nO+1,nBas-nR
! do d=c+1,nBas-nR
! cd = cd + 1
! do m=nC+1,nO
! do e=nO+1,nBas-nR
! dem = eGF(m) - eGF(e)
! num = 2d0*ERI(a,m,c,e)*ERI(b,e,d,m) - ERI(a,m,c,e)*ERI(b,e,m,d) &
! - ERI(a,m,e,c)*ERI(b,e,d,m) + ERI(a,m,e,c)*ERI(b,e,m,d)
! KC_sta(ab,cd) = KC_sta(ab,cd) + 2d0*num*dem/(dem**2 + eta**2)
! dem = eGF(m) - eGF(e)
! num = 2d0*ERI(b,m,c,e)*ERI(a,e,d,m) - ERI(b,m,c,e)*ERI(a,e,m,d) &
! - ERI(b,m,e,c)*ERI(a,e,d,m) + ERI(b,m,e,c)*ERI(a,e,m,d)
! KC_sta(ab,cd) = KC_sta(ab,cd) - 2d0*num*dem/(dem**2 + eta**2)
! end do
! end do
! end do
! end do
! end do
! end do
! end if
deallocate(Om_tmp)
end subroutine

View File

@ -71,7 +71,7 @@ subroutine ufRG0F02(dotest,nBas,nC,nO,nV,nR,nS,ENuc,ERHF,ERI,eHF)
! Main loop over orbitals !
!-------------------------!
do p=nO-1,nO
do p=nO-3,nO
H(:,:) = 0d0
Reigv(:,:) = 0d0

View File

@ -61,7 +61,7 @@ subroutine RGW_ppBSE(TDA_W,TDA,dBSE,dTDA,singlet,triplet,eta,nBas,nC,nO,nV,nR,nS
double precision,allocatable :: KB_sta(:,:)
double precision,allocatable :: KC_sta(:,:)
double precision,allocatable :: KD_sta(:,:)
! Output variables
double precision,intent(out) :: EcBSE(nspin)
@ -114,7 +114,7 @@ subroutine RGW_ppBSE(TDA_W,TDA,dBSE,dTDA,singlet,triplet,eta,nBas,nC,nO,nV,nR,nS
call RGW_ppBSE_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nS,nVV,1d0,ERI,OmRPA,rho_RPA,KC_sta)
call RGW_ppBSE_static_kernel_D(ispin,eta,nBas,nC,nO,nV,nR,nS,nOO,1d0,ERI,OmRPA,rho_RPA,KD_sta)
if(.not.TDA) call RGW_ppBSE_static_kernel_B(ispin,eta,nBas,nC,nO,nV,nR,nS,nOO,nVV,1d0,ERI,OmRPA,rho_RPA,KB_sta)
call ppLR_C(ispin,nBas,nC,nO,nV,nR,nVV,1d0,eGW,ERI,Cpp)
call ppLR_D(ispin,nBas,nC,nO,nV,nR,nOO,1d0,eGW,ERI,Dpp)
if(.not.TDA) call ppLR_B(ispin,nBas,nC,nO,nV,nR,nOO,nVV,1d0,ERI,Bpp)

View File

@ -117,8 +117,8 @@ subroutine ppLR_transition_vectors(spin_allowed,nBas,nC,nO,nV,nR,nOO,nVV,dipole_
! Thomas-Reiche-Kuhn sum rule
if(nVV > 0) write(*,'(A50,F10.6)') 'Thomas-Reiche-Kuhn sum rule for p-p sector = ',sum(os1(:))
write(*,*)
! if(nVV > 0) write(*,'(A50,F10.6)') 'Thomas-Reiche-Kuhn sum rule for p-p sector = ',sum(os1(:))
! write(*,*)
!-----------------------------------------------!
! Print details about excitations for hh sector !
@ -188,7 +188,7 @@ subroutine ppLR_transition_vectors(spin_allowed,nBas,nC,nO,nV,nR,nOO,nVV,dipole_
! Thomas-Reiche-Kuhn sum rule
if(nOO > 0) write(*,'(A50,F10.6)') 'Thomas-Reiche-Kuhn sum rule for h-h sector = ',sum(os2(:))
write(*,*)
! if(nOO > 0) write(*,'(A50,F10.6)') 'Thomas-Reiche-Kuhn sum rule for h-h sector = ',sum(os2(:))
! write(*,*)
end subroutine

View File

@ -88,9 +88,9 @@ FIX_ORDER_OF_LIBS=-Wl,--start-group
"""
if sys.platform in ["linux", "linux2"]:
# compiler = compile_gfortran_linux
compiler = compile_ifort_linux
# compiler = compile_olympe
# compiler = compile_gfortran_linux
# compiler = compile_ifort_linux
compiler = compile_olympe
elif sys.platform == "darwin":
compiler = compile_gfortran_mac
else: