From d93fbcb591bef66c97c4a4b69ed1c2bd0a234345 Mon Sep 17 00:00:00 2001 From: EnzoMonino Date: Mon, 10 Jul 2023 11:36:45 +0200 Subject: [PATCH] add optimization in BSE@GW --- input/methods | 6 +++--- src/GW/BSE2_static_kernel_KA.f90 | 19 +++++++++++-------- src/GW/BSE2_static_kernel_KB.f90 | 19 +++++++++++-------- src/GW/Bethe_Salpeter_A_matrix_dynamic.f90 | 20 ++++++++++++-------- src/utils/read_geometry.f90 | 2 +- 5 files changed, 38 insertions(+), 28 deletions(-) diff --git a/input/methods b/input/methods index bb503e1..33c74d4 100644 --- a/input/methods +++ b/input/methods @@ -11,9 +11,9 @@ # RPA* RPAx* crRPA ppRPA F F F F # G0F2* evGF2* qsGF2* G0F3 evGF3 - T F F F F + F F F F F # G0W0* evGW* qsGW* SRG-qsGW ufG0W0 ufGW - T F F F F F + F F F F F F # G0T0pp evGTpp qsGTpp G0T0eh evGTeh qsGTeh - F F F F F T + F F F F F F # * unrestricted version available diff --git a/src/GW/BSE2_static_kernel_KA.f90 b/src/GW/BSE2_static_kernel_KA.f90 index 2f8fec5..5780c68 100644 --- a/src/GW/BSE2_static_kernel_KA.f90 +++ b/src/GW/BSE2_static_kernel_KA.f90 @@ -34,15 +34,16 @@ subroutine BSE2_static_kernel_KA(eta,nBas,nC,nO,nV,nR,nS,lambda,eW,W,KA2_sta) ! Compute BSE2 kernel !------------------------------------------------ - ia = 0 - do i=nC+1,nO - do a=nO+1,nBas-nR - ia = ia + 1 + jb = 0 +!$omp parallel do default(private) shared(KA2_sta,W,num,dem,eW,nO,nBas,eta,nC,nR) + do j=nC+1,nO + do b=nO+1,nBas-nR + jb = (b-nO) + (j-1)*(nBas-nO) - jb = 0 - do j=nC+1,nO - do b=nO+1,nBas-nR - jb = jb + 1 + ia = 0 + do i=nC+1,nO + do a=nO+1,nBas-nR + ia = (a-nO) + (i-1)*(nBas-nO) do k=nC+1,nO do c=nO+1,nBas-nR @@ -88,4 +89,6 @@ subroutine BSE2_static_kernel_KA(eta,nBas,nC,nO,nV,nR,nS,lambda,eW,W,KA2_sta) end do end do +!$omp end parallel do + end subroutine BSE2_static_kernel_KA diff --git a/src/GW/BSE2_static_kernel_KB.f90 b/src/GW/BSE2_static_kernel_KB.f90 index 207c079..04a4e54 100644 --- a/src/GW/BSE2_static_kernel_KB.f90 +++ b/src/GW/BSE2_static_kernel_KB.f90 @@ -34,15 +34,16 @@ subroutine BSE2_static_kernel_KB(eta,nBas,nC,nO,nV,nR,nS,lambda,eW,W,KB2_sta) ! Compute BSE2 kernel !------------------------------------------------ - ia = 0 - do i=nC+1,nO - do a=nO+1,nBas-nR - ia = ia + 1 + jb = 0 +!$omp parallel do default(private) shared(KB2_sta,W,num,dem,eW,nO,nBas,eta,nC,nR) + do j=nC+1,nO + do b=nO+1,nBas-nR + jb = (b-nO) + (j-1)*(nBas-nO) - jb = 0 - do j=nC+1,nO - do b=nO+1,nBas-nR - jb = jb + 1 + ia = 0 + do i=nC+1,nO + do a=nO+1,nBas-nR + ia = (a-nO) + (i-1)*(nBas-nO) do k=nC+1,nO do c=nO+1,nBas-nR @@ -88,4 +89,6 @@ subroutine BSE2_static_kernel_KB(eta,nBas,nC,nO,nV,nR,nS,lambda,eW,W,KB2_sta) end do end do +!$omp end parallel do + end subroutine BSE2_static_kernel_KB diff --git a/src/GW/Bethe_Salpeter_A_matrix_dynamic.f90 b/src/GW/Bethe_Salpeter_A_matrix_dynamic.f90 index 89a616d..a804a13 100644 --- a/src/GW/Bethe_Salpeter_A_matrix_dynamic.f90 +++ b/src/GW/Bethe_Salpeter_A_matrix_dynamic.f90 @@ -38,14 +38,16 @@ subroutine Bethe_Salpeter_A_matrix_dynamic(eta,nBas,nC,nO,nV,nR,nS,lambda,eGW,Om ! Build dynamic A matrix - ia = 0 - do i=nC+1,nO - do a=nO+1,nBas-nR - ia = ia + 1 - jb = 0 - do j=nC+1,nO - do b=nO+1,nBas-nR - jb = jb + 1 + jb = 0 +!$omp parallel do default(private) shared(A_dyn,ZA_dyn,OmRPA,OmBSE,eGW,rho_RPA,nO,nBas,maxS,chi,eps,eta,nC,nR,lambda) + do j=nC+1,nO + do b=nO+1,nBas-nR + jb = (b-nO) + (j-1)*(nBas-nO) + + ia = 0 + do i=nC+1,nO + do a=nO+1,nBas-nR + ia = (a-nO) + (i-1)*(nBas-nO) chi = 0d0 @@ -88,4 +90,6 @@ subroutine Bethe_Salpeter_A_matrix_dynamic(eta,nBas,nC,nO,nV,nR,nS,lambda,eGW,Om enddo enddo +!$omp end parallel do + end subroutine Bethe_Salpeter_A_matrix_dynamic diff --git a/src/utils/read_geometry.f90 b/src/utils/read_geometry.f90 index ea5e083..d2f27bd 100644 --- a/src/utils/read_geometry.f90 +++ b/src/utils/read_geometry.f90 @@ -47,7 +47,7 @@ subroutine read_geometry(nNuc,ZNuc,rNuc,ENuc) do i=1,nNuc-1 do j=i+1,nNuc RAB = (rNuc(i,1)-rNuc(j,1))**2 + (rNuc(i,2)-rNuc(j,2))**2 + (rNuc(i,3)-rNuc(j,3))**2 - ENuc = ENuc + ZNuc(i)*ZNuc(j)/(AnToBo*sqrt(RAB)) + ENuc = ENuc + ZNuc(i)*ZNuc(j)/(AntoBo*sqrt(RAB)) enddo enddo