10
1
mirror of https://github.com/pfloos/quack synced 2024-12-23 12:55:25 +01:00

openmp in ppbse@gf2

This commit is contained in:
Antoine Marie 2024-09-06 20:54:12 +02:00
parent 4134aadac5
commit b9da29a020

View File

@ -27,9 +27,6 @@ subroutine RGF2_ppBSE_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI,
integer :: a,b,c,d,e integer :: a,b,c,d,e
integer :: a0,aa,ab,cd integer :: a0,aa,ab,cd
double precision :: eta2
double precision, allocatable :: Om_tmp(:,:)
! Output variables ! Output variables
double precision,intent(out) :: KC_sta(nVV,nVV) double precision,intent(out) :: KC_sta(nVV,nVV)
@ -37,22 +34,6 @@ subroutine RGF2_ppBSE_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI,
! Initialization ! Initialization
KC_sta(:,:) = 0d0 KC_sta(:,:) = 0d0
! eta2 = eta * eta
! allocate(Om_tmp(nBas,nBas))
! Om_tmp(:,:) = 0d0
! ! 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 ! Second-order correlation kernel for the block C of the singlet manifold
@ -60,61 +41,17 @@ subroutine RGF2_ppBSE_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI,
! OpenMP implementation ! OpenMP implementation
! --- --- --- ! --- --- ---
! if(ispin == 1) then if(ispin == 1) then
! a0 = nBas - nR - nO a0 = nBas - nR - nO
! !$OMP PARALLEL DEFAULT(NONE) & !$OMP PARALLEL DEFAULT(NONE) &
! !$OMP PRIVATE(a, b, aa, ab, c, d, cd, m, e, num) & !$OMP PRIVATE(a, b, aa, ab, c, d, cd, m, e, num, dem) &
! !$OMP SHARED(nO, nBas, nR, nC, a0, ERI, Om_tmp, KC_sta, lambda) !$OMP SHARED(nO, nBas, nR, nC, a0, ERI, KC_sta, lambda, eGF, eta)
! !$OMP DO !$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 = aa + b
! 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
!
! 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 * Om_tmp(m,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 * Om_tmp(m,e)
!
! 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
! !$OMP END DO
! !$OMP END PARALLEL
! end if
! --- --- ---
! Naive implementation
! --- --- ---
if(ispin == 1) then
ab = 0
do a=nO+1,nBas-nR do a=nO+1,nBas-nR
aa = a0 * (a - nO - 1) - (a - nO - 1) * (a - nO) / 2 - nO
do b=a,nBas-nR do b=a,nBas-nR
ab = ab + 1 ab = aa + b
cd = 0 cd = 0
do c=nO+1,nBas-nR do c=nO+1,nBas-nR
@ -155,8 +92,63 @@ subroutine RGF2_ppBSE_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI,
end do end do
end do end do
!$OMP END DO
!$OMP END PARALLEL
end if 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(e,b,m,d) - ERI(a,m,c,e)*ERI(e,b,d,m) &
! - ERI(a,m,e,c)*ERI(e,b,m,d) - ERI(a,m,e,c)*ERI(e,b,d,m)
! KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
! num = 2d0*ERI(a,e,c,m)*ERI(m,b,e,d) - ERI(a,e,c,m)*ERI(m,b,d,e) &
! - ERI(a,e,m,c)*ERI(m,b,e,d) - ERI(a,e,m,c)*ERI(m,b,d,e)
! KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
! num = 2d0*ERI(b,m,c,e)*ERI(e,a,m,d) - ERI(b,m,c,e)*ERI(e,a,d,m) &
! - ERI(b,m,e,c)*ERI(e,a,m,d) - ERI(b,m,e,c)*ERI(e,a,d,m)
! KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
! num = 2d0*ERI(b,e,c,m)*ERI(m,a,e,d) - ERI(b,e,c,m)*ERI(m,a,d,e) &
! - ERI(b,e,m,c)*ERI(m,a,e,d) - ERI(b,e,m,c)*ERI(m,a,d,e)
! KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
! end do
! end do
! KC_sta(ab,cd) = 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 ! Second-order correlation kernel for the block C of the triplet manifold
@ -164,59 +156,17 @@ subroutine RGF2_ppBSE_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI,
! OpenMP implementation ! OpenMP implementation
! --- --- --- ! --- --- ---
! if(ispin == 2) then if(ispin == 2) then
! a0 = nBas - nR - nO - 1 a0 = nBas - nR - nO - 1
! !$OMP PARALLEL DEFAULT(NONE) & !$OMP PARALLEL DEFAULT(NONE) &
! !$OMP PRIVATE(a, b, aa, ab, c, d, cd, m, e, num) & !$OMP PRIVATE(a, b, aa, ab, c, d, cd, m, e, num, dem) &
! !$OMP SHARED(nO, nBas, nR, nC, a0, ERI, Om_tmp, KC_sta) !$OMP SHARED(nO, nBas, nR, nC, a0, ERI, KC_sta, eGF, eta)
! !$OMP DO !$OMP DO
! do a = nO+1, nBas-nR do a = nO+1, nBas-nR
! aa = a0 * (a - nO - 1) - (a - nO - 1) * (a - nO) / 2 - nO - 1 aa = a0 * (a - nO - 1) - (a - nO - 1) * (a - nO) / 2 - nO - 1
! do b = a+1, nBas-nR do b = a+1, nBas-nR
! ab = aa + b ab = aa + b
! 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
!
! 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 * Om_tmp(m,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 * Om_tmp(m,e)
!
! end do
! end do
! end do
! end do
! 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 cd = 0
do c=nO+1,nBas-nR do c=nO+1,nBas-nR
@ -255,8 +205,61 @@ subroutine RGF2_ppBSE_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI,
end do end do
end do end do
!$OMP END DO
!$OMP END PARALLEL
end if 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(e,b,m,d) - ERI(a,m,c,e)*ERI(e,b,d,m) &
! - ERI(a,m,e,c)*ERI(e,b,m,d) + ERI(a,m,e,c)*ERI(e,b,d,m)
! KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
! num = 2d0*ERI(a,e,c,m)*ERI(m,b,e,d) - ERI(a,e,c,m)*ERI(m,b,d,e) &
! - ERI(a,e,m,c)*ERI(m,b,e,d) + ERI(a,e,m,c)*ERI(m,b,d,e)
! KC_sta(ab,cd) = KC_sta(ab,cd) + num*dem/(dem**2 + eta**2)
! num = 2d0*ERI(b,m,c,e)*ERI(e,a,m,d) - ERI(b,m,c,e)*ERI(e,a,d,m) &
! - ERI(b,m,e,c)*ERI(e,a,m,d) + ERI(b,m,e,c)*ERI(e,a,d,m)
! KC_sta(ab,cd) = KC_sta(ab,cd) - num*dem/(dem**2 + eta**2)
! num = 2d0*ERI(b,e,c,m)*ERI(m,a,e,d) - ERI(b,e,c,m)*ERI(m,a,d,e) &
! - ERI(b,e,m,c)*ERI(m,a,e,d) + ERI(b,e,m,c)*ERI(m,a,d,e)
! KC_sta(ab,cd) = KC_sta(ab,cd) - num*dem/(dem**2 + eta**2)
! end do
! end do
! end do
! end do
! end do
! end do
! end if
if(ispin == 4) then if(ispin == 4) then