diff --git a/src/GF/GGF2_phBSE.f90 b/src/GF/GGF2_phBSE.f90 index f8a75b3..a705ecf 100644 --- a/src/GF/GGF2_phBSE.f90 +++ b/src/GF/GGF2_phBSE.f90 @@ -25,7 +25,6 @@ subroutine GGF2_phBSE(TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eGF,E ! Local variables logical :: dRPA = .false. - integer :: ispin double precision,allocatable :: OmBSE(:) double precision,allocatable :: XpY(:,:) double precision,allocatable :: XmY(:,:) @@ -43,16 +42,15 @@ subroutine GGF2_phBSE(TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eGF,E allocate(OmBSE(nS),XpY(nS,nS),XmY(nS,nS),A_sta(nS,nS),KA_sta(nS,nS)) allocate(B_sta(nS,nS),KB_sta(nS,nS)) - ispin = 3 EcBSE = 0d0 - call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,eGF,ERI,A_sta) - if(.not.TDA) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,B_sta) + call phGLR_A(dRPA,nBas,nC,nO,nV,nR,nS,1d0,eGF,ERI,A_sta) + if(.not.TDA) call phGLR_B(dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,B_sta) ! Compute static kernel - call RGF2_phBSE_static_kernel_A(ispin,eta,nBas,nC,nO,nV,nR,nS,1d0,ERI,eGF,KA_sta) - if(.not.TDA) call RGF2_phBSE_static_kernel_B(ispin,eta,nBas,nC,nO,nV,nR,nS,1d0,ERI,eGF,KB_sta) + call GGF2_phBSE_static_kernel_A(eta,nBas,nC,nO,nV,nR,nS,1d0,ERI,eGF,KA_sta) + if(.not.TDA) call GGF2_phBSE_static_kernel_B(eta,nBas,nC,nO,nV,nR,nS,1d0,ERI,eGF,KB_sta) A_sta(:,:) = A_sta(:,:) + KA_sta(:,:) if(.not.TDA) B_sta(:,:) = B_sta(:,:) + KB_sta(:,:) @@ -60,12 +58,12 @@ subroutine GGF2_phBSE(TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eGF,E ! Compute phBSE@GF2 excitation energies call phLR(TDA,nS,A_sta,B_sta,EcBSE,OmBSE,XpY,XmY) - call print_excitation_energies('phBSE@GGF2','spinorbital',nS,OmBSE) + call print_excitation_energies('phBSE@GGF2','generalized',nS,OmBSE) call phLR_transition_vectors(.true.,nBas,nC,nO,nV,nR,nS,dipole_int,OmBSE,XpY,XmY) ! Compute dynamic correction for BSE via perturbation theory ! if(dBSE) & -! call GF2_phBSE_dynamic_perturbation(dTDA,ispin,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eGF,KA_sta,KB_sta,OmBSE,XpY,XmY) +! call GGF2_phBSE_dynamic_perturbation(dTDA,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eGF,KA_sta,KB_sta,OmBSE,XpY,XmY) end subroutine diff --git a/src/GF/GGF2_phBSE_static_kernel_A.f90 b/src/GF/GGF2_phBSE_static_kernel_A.f90 new file mode 100644 index 0000000..91bf2d5 --- /dev/null +++ b/src/GF/GGF2_phBSE_static_kernel_A.f90 @@ -0,0 +1,94 @@ +subroutine GGF2_phBSE_static_kernel_A(eta,nBas,nC,nO,nV,nR,nS,lambda,ERI,eGF,KA_sta) + +! Compute the resonant part of the static BSE@GF2 matrix + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas,nC,nO,nV,nR,nS + double precision,intent(in) :: eta + double precision,intent(in) :: lambda + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: eGF(nBas) + +! Local variables + + double precision :: dem,num + integer :: i,j,k,l + integer :: a,b,c,d + integer :: ia,jb + +! Output variables + + double precision,intent(out) :: KA_sta(nS,nS) + +! Initialization + + KA_sta(:,:) = 0d0 + +! Second-order correlation kernel for the block A of the spinorbital manifold + + jb = 0 + +!$omp parallel do default(private) shared(KA_sta,ERI,num,dem,eGF,nO,nBas,eta,nC,nR) + 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) + + do k=nC+1,nO + do c=nO+1,nBas-nR + + dem = - (eGF(c) - eGF(k)) + num = ERI(j,k,i,c)*ERI(a,c,b,k) - ERI(j,k,i,c)*ERI(a,c,k,b) & + - ERI(j,k,c,i)*ERI(a,c,b,k) + ERI(j,k,c,i)*ERI(a,c,k,b) + + KA_sta(ia,jb) = KA_sta(ia,jb) - num*dem/(dem**2 + eta**2) + + dem = + (eGF(c) - eGF(k)) + num = ERI(j,c,i,k)*ERI(a,k,b,c) - ERI(j,c,i,k)*ERI(a,k,c,b) & + - ERI(j,c,k,i)*ERI(a,k,b,c) + ERI(j,c,k,i)*ERI(a,k,c,b) + + KA_sta(ia,jb) = KA_sta(ia,jb) + num*dem/(dem**2 + eta**2) + + end do + end do + + do c=nO+1,nBas-nR + do d=nO+1,nBas-nR + + dem = - (eGF(c) + eGF(d)) + num = ERI(a,j,c,d)*ERI(c,d,i,b) - ERI(a,j,c,d)*ERI(c,d,b,i) & + - ERI(a,j,d,c)*ERI(c,d,i,b) + ERI(a,j,d,c)*ERI(c,d,b,i) + + KA_sta(ia,jb) = KA_sta(ia,jb) + 0.5d0*num*dem/(dem**2 + eta**2) + + end do + end do + + do k=nC+1,nO + do l=nC+1,nO + + dem = - (eGF(k) + eGF(l)) + num = ERI(a,j,k,l)*ERI(k,l,i,b) - ERI(a,j,k,l)*ERI(k,l,b,i) & + - ERI(a,j,l,k)*ERI(k,l,i,b) + ERI(a,j,l,k)*ERI(k,l,b,i) + + KA_sta(ia,jb) = KA_sta(ia,jb) - 0.5d0*num*dem/(dem**2 + eta**2) + + end do + end do + + end do + end do + + end do + end do +!$omp end parallel do + +end subroutine diff --git a/src/GF/GGF2_phBSE_static_kernel_B.f90 b/src/GF/GGF2_phBSE_static_kernel_B.f90 new file mode 100644 index 0000000..6980268 --- /dev/null +++ b/src/GF/GGF2_phBSE_static_kernel_B.f90 @@ -0,0 +1,94 @@ +subroutine GGF2_phBSE_static_kernel_B(eta,nBas,nC,nO,nV,nR,nS,lambda,ERI,eGF,KB_sta) + +! Compute the anti-resonant part of the static BSE@GF2 matrix + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas,nC,nO,nV,nR,nS + double precision,intent(in) :: eta + double precision,intent(in) :: lambda + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: eGF(nBas) + +! Local variables + + double precision :: dem,num + integer :: i,j,k,l + integer :: a,b,c,d + integer :: ia,jb + +! Output variables + + double precision,intent(out) :: KB_sta(nS,nS) + +! Initialization + + KB_sta(:,:) = 0d0 + +! Second-order correlation kernel for the block A of the spinorbital manifold + + jb = 0 + +!$omp parallel do default(private) shared(KB_sta,ERI,num,dem,eGF,nO,nBas,eta,nC,nR) + 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) + + do k=nC+1,nO + do c=nO+1,nBas-nR + + dem = + eGF(k) - eGF(c) + num = ERI(b,k,i,c)*ERI(a,c,j,k) - ERI(b,k,i,c)*ERI(a,c,k,j) & + - ERI(b,k,c,i)*ERI(a,c,j,k) + ERI(b,k,c,i)*ERI(a,c,k,j) + + KB_sta(ia,jb) = KB_sta(ia,jb) - num*dem/(dem**2 + eta**2) + + dem = - eGF(c) + eGF(k) + num = ERI(b,c,i,k)*ERI(a,k,j,c) - ERI(b,c,i,k)*ERI(a,k,c,j) & + - ERI(b,c,k,i)*ERI(a,k,j,c) + ERI(b,c,k,i)*ERI(a,k,c,j) + + KB_sta(ia,jb) = KB_sta(ia,jb) - num*dem/(dem**2 + eta**2) + + end do + end do + + do c=nO+1,nBas-nR + do d=nO+1,nBas-nR + + dem = - eGF(c) - eGF(d) + num = ERI(a,b,c,d)*ERI(c,d,i,j) - ERI(a,b,c,d)*ERI(c,d,j,i) & + - ERI(a,b,d,c)*ERI(c,d,i,j) + ERI(a,b,d,c)*ERI(c,d,j,i) + + KB_sta(ia,jb) = KB_sta(ia,jb) + 0.5d0*num*dem/(dem**2 + eta**2) + + end do + end do + + do k=nC+1,nO + do l=nC+1,nO + + dem = + eGF(k) + eGF(l) + num = ERI(a,b,k,l)*ERI(k,l,i,j) - ERI(a,b,k,l)*ERI(k,l,j,i) & + - ERI(a,b,l,k)*ERI(k,l,i,j) + ERI(a,b,l,k)*ERI(k,l,j,i) + + KB_sta(ia,jb) = KB_sta(ia,jb) + 0.5d0*num*dem/(dem**2 + eta**2) + + end do + end do + + end do + end do + + end do + end do +!$omp end parallel do + +end subroutine diff --git a/src/GF/GGF2_ppBSE.f90 b/src/GF/GGF2_ppBSE.f90 index aa89da3..d38f45c 100644 --- a/src/GF/GGF2_ppBSE.f90 +++ b/src/GF/GGF2_ppBSE.f90 @@ -23,8 +23,6 @@ subroutine GGF2_ppBSE(TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,ERI,dipole_int,eGF,EcBS ! Local variables - integer :: ispin - integer :: nOO integer :: nVV @@ -48,7 +46,8 @@ subroutine GGF2_ppBSE(TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,ERI,dipole_int,eGF,EcBS double precision,intent(out) :: EcBSE - ispin = 4 +! Initialization + EcBSE = 0d0 nOO = nO*(nO-1)/2 @@ -61,13 +60,13 @@ subroutine GGF2_ppBSE(TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,ERI,dipole_int,eGF,EcBS ! Compute BSE excitation energies - if(.not.TDA) call RGF2_ppBSE_static_kernel_B(ispin,eta,nBas,nC,nO,nV,nR,nOO,nVV,1d0,ERI,eGF,KB_sta) - call RGF2_ppBSE_static_kernel_C(ispin,eta,nBas,nC,nO,nV,nR,nVV,1d0,ERI,eGF,KC_sta) - call RGF2_ppBSE_static_kernel_D(ispin,eta,nBas,nC,nO,nV,nR,nOO,1d0,ERI,eGF,KD_sta) + if(.not.TDA) call GGF2_ppBSE_static_kernel_B(eta,nBas,nC,nO,nV,nR,nOO,nVV,1d0,ERI,eGF,KB_sta) + call GGF2_ppBSE_static_kernel_C(eta,nBas,nC,nO,nV,nR,nVV,1d0,ERI,eGF,KC_sta) + call GGF2_ppBSE_static_kernel_D(eta,nBas,nC,nO,nV,nR,nOO,1d0,ERI,eGF,KD_sta) - if(.not.TDA) call ppLR_B(ispin,nBas,nC,nO,nV,nR,nOO,nVV,1d0,ERI,Bpp) - call ppLR_C(ispin,nBas,nC,nO,nV,nR,nVV,1d0,eGF,ERI,Cpp) - call ppLR_D(ispin,nBas,nC,nO,nV,nR,nOO,1d0,eGF,ERI,Dpp) + if(.not.TDA) call ppGLR_B(nBas,nC,nO,nV,nR,nOO,nVV,1d0,ERI,Bpp) + call ppGLR_C(nBas,nC,nO,nV,nR,nVV,1d0,eGF,ERI,Cpp) + call ppGLR_D(nBas,nC,nO,nV,nR,nOO,1d0,eGF,ERI,Dpp) Bpp(:,:) = Bpp(:,:) + KB_sta(:,:) Cpp(:,:) = Cpp(:,:) + KC_sta(:,:) @@ -82,7 +81,7 @@ subroutine GGF2_ppBSE(TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,ERI,dipole_int,eGF,EcBS !----------------------------------------------------! ! if(dBSE) & -! call RGF2_ppBSE_dynamic_perturbation(ispin,dTDA,eta,nBas,nC,nO,nV,nR,nOO,nVV,eGF,ERI,dipole_int, & +! call GGF2_ppBSE_dynamic_perturbation(dTDA,eta,nBas,nC,nO,nV,nR,nOO,nVV,eGF,ERI,dipole_int, & ! Om1,X1,Y1,Om2,X2,Y2,KB_sta,KC_sta,KD_sta) deallocate(Om1,X1,Y1,Om2,X2,Y2,Bpp,Cpp,Dpp,KB_sta,KC_sta,KD_sta) diff --git a/src/GF/GGF2_ppBSE_static_kernel_B.f90 b/src/GF/GGF2_ppBSE_static_kernel_B.f90 new file mode 100644 index 0000000..3c8c10d --- /dev/null +++ b/src/GF/GGF2_ppBSE_static_kernel_B.f90 @@ -0,0 +1,68 @@ +subroutine GGF2_ppBSE_static_kernel_B(eta,nBas,nC,nO,nV,nR,nOO,nVV,lambda,ERI,eGF,KB_sta) + +! Compute the resonant part of the dynamic BSE@GF2 matrix + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nOO + integer,intent(in) :: nVV + double precision,intent(in) :: eta + double precision,intent(in) :: lambda + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: eGF(nBas) + +! Local variables + + double precision,external :: Kronecker_delta + double precision :: dem,num + integer :: i,j,a,b,m,e + integer :: ab,ij + +! Output variables + + double precision,intent(out) :: KB_sta(nVV,nOO) + +! Initialization + + KB_sta(:,:) = 0d0 + +! Second-order correlation kernel for the block B of the spinorbital manifold + + ab = 0 + do a=nO+1,nBas-nR + do b=a+1,nBas-nR + ab = ab + 1 + + ij = 0 + do i=nC+1,nO + do j=i+1,nO + ij = ij + 1 + + do m=nC+1,nO + do e=nO+1,nBas-nR + + dem = eGF(m) - eGF(e) + num = (ERI(a,m,i,e) - ERI(a,m,e,i)) * (ERI(e,b,m,j) - ERI(e,b,j,m)) + num = num + (ERI(a,e,i,m) - ERI(a,e,m,i)) * (ERI(m,b,e,j) - ERI(m,b,j,e)) + num = num - (ERI(b,m,i,e) - ERI(b,m,e,i)) * (ERI(e,a,m,j) - ERI(e,a,j,m)) + num = num - (ERI(b,e,i,m) - ERI(b,e,m,i)) * (ERI(m,a,e,j) - ERI(m,a,j,e)) + KB_sta(ab,ij) = KB_sta(ab,ij) + num*dem/(dem**2 + eta**2) + + end do + end do + + end do + end do + + end do + end do + +end subroutine diff --git a/src/GF/GGF2_ppBSE_static_kernel_C.f90 b/src/GF/GGF2_ppBSE_static_kernel_C.f90 new file mode 100644 index 0000000..25badb9 --- /dev/null +++ b/src/GF/GGF2_ppBSE_static_kernel_C.f90 @@ -0,0 +1,69 @@ +subroutine GGF2_ppBSE_static_kernel_C(eta,nBas,nC,nO,nV,nR,nVV,lambda,ERI,eGF,KC_sta) + +! Compute the resonant part of the static BSE@GF2 matrix + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nVV + double precision,intent(in) :: eta + double precision,intent(in) :: lambda + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: eGF(nBas) + +! Local variables + + double precision,external :: Kronecker_delta + double precision :: dem,num + integer :: m + integer :: a,b,c,d,e + integer :: a0,aa,ab,cd + +! Output variables + + double precision,intent(out) :: KC_sta(nVV,nVV) + +! Initialization + + KC_sta(:,:) = 0d0 + +! Second-order correlation kernel for the block C of the singlet manifold + + 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 = (ERI(a,m,c,e) - ERI(a,m,e,c)) * (ERI(e,b,m,d) - ERI(e,b,d,m)) + num = num + (ERI(a,e,c,m) - ERI(a,e,m,c)) * (ERI(m,b,e,d) - ERI(m,b,d,e)) + num = num - (ERI(b,m,c,e) - ERI(b,m,e,c)) * (ERI(e,a,m,d) - ERI(e,a,d,m)) + num = num - (ERI(b,e,c,m) - ERI(b,e,m,c)) * (ERI(m,a,e,d) - 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 subroutine diff --git a/src/GF/GGF2_ppBSE_static_kernel_D.f90 b/src/GF/GGF2_ppBSE_static_kernel_D.f90 new file mode 100644 index 0000000..cddc221 --- /dev/null +++ b/src/GF/GGF2_ppBSE_static_kernel_D.f90 @@ -0,0 +1,68 @@ +subroutine GGF2_ppBSE_static_kernel_D(eta,nBas,nC,nO,nV,nR,nOO,lambda,ERI,eGF,KD_sta) + +! Compute the resonant part of the static BSE@GF2 matrix + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nOO + double precision,intent(in) :: eta + double precision,intent(in) :: lambda + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: eGF(nBas) + +! Local variables + + double precision,external :: Kronecker_delta + double precision :: dem,num + integer :: i,j,k,l,m + integer :: e + integer :: ij,kl + +! Output variables + + double precision,intent(out) :: KD_sta(nOO,nOO) + +! Initialization + + KD_sta(:,:) = 0d0 + +! Second-order correlation kernel for the block D of the spinorbital manifold + + ij = 0 + do i=nC+1,nO + do j=i+1,nO + ij = ij + 1 + + kl = 0 + do k=nC+1,nO + do l=k+1,nO + kl = kl + 1 + + do m=nC+1,nO + do e=nO+1,nBas-nR + + dem = eGF(m) - eGF(e) + num = (ERI(i,m,k,e) - ERI(i,m,e,k)) * (ERI(e,j,m,l) - ERI(e,j,l,m)) + num = num + (ERI(i,e,k,m) - ERI(i,e,m,k)) * (ERI(m,j,e,l) - ERI(m,j,l,e)) + num = num - (ERI(j,m,k,e) - ERI(j,m,e,k)) * (ERI(e,i,m,l) - ERI(e,i,l,m)) + num = num - (ERI(j,e,k,m) - ERI(j,e,m,k)) * (ERI(m,i,e,l) - ERI(m,i,l,e)) + + KD_sta(ij,kl) = KD_sta(ij,kl) + num*dem/(dem**2 + eta**2) + end do + end do + + end do + end do + + end do + end do + +end subroutine diff --git a/src/GW/GG0W0.f90 b/src/GW/GG0W0.f90 index c313619..9b1e30f 100644 --- a/src/GW/GG0W0.f90 +++ b/src/GW/GG0W0.f90 @@ -40,7 +40,6 @@ subroutine GG0W0(dotest,doACFDT,exchange_kernel,doXBS,dophBSE,dophBSE2,TDA_W,TDA logical :: print_W = .true. logical :: dRPA - integer :: ispin double precision :: EcRPA double precision :: EcBSE double precision :: EcGM @@ -85,10 +84,6 @@ subroutine GG0W0(dotest,doACFDT,exchange_kernel,doXBS,dophBSE,dophBSE2,TDA_W,TDA write(*,*) end if -! Spin manifold - - ispin = 3 - ! Memory allocation allocate(Aph(nS,nS),Bph(nS,nS),SigC(nBas),Z(nBas),Om(nS),XpY(nS,nS),XmY(nS,nS),rho(nBas,nBas,nS), & @@ -98,12 +93,12 @@ subroutine GG0W0(dotest,doACFDT,exchange_kernel,doXBS,dophBSE,dophBSE2,TDA_W,TDA ! Compute screening ! !-------------------! - call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,eHF,ERI,Aph) - if(.not.TDA_W) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph) + call phGLR_A(dRPA,nBas,nC,nO,nV,nR,nS,1d0,eHF,ERI,Aph) + if(.not.TDA_W) call phGLR_B(dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph) - call phLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY) + call phGLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY) - if(print_W) call print_excitation_energies('phRPA@GHF','spinorbital',nS,Om) + if(print_W) call print_excitation_energies('phRPA@GHF','generalized',nS,Om) !--------------------------! ! Compute spectral weights ! @@ -147,10 +142,10 @@ subroutine GG0W0(dotest,doACFDT,exchange_kernel,doXBS,dophBSE,dophBSE2,TDA_W,TDA ! Compute the RPA correlation energy - call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,eGW,ERI,Aph) - if(.not.TDA_W) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph) + call phGLR_A(dRPA,nBas,nC,nO,nV,nR,nS,1d0,eGW,ERI,Aph) + if(.not.TDA_W) call phGLR_B(dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph) - call phLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY) + call phGLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY) !--------------! ! Dump results ! diff --git a/src/GW/GGW_ppBSE.f90 b/src/GW/GGW_ppBSE.f90 index 6decd48..e88cd78 100644 --- a/src/GW/GGW_ppBSE.f90 +++ b/src/GW/GGW_ppBSE.f90 @@ -1,4 +1,4 @@ -subroutine GGW_ppBSE(TDA_W,TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int,eW,eGW,EcBSE) +subroutine GGW_ppBSE(TDA_W,TDA,dBSE,dTDA,eta,nOrb,nC,nO,nV,nR,nS,ERI,dipole_int,eW,eGW,EcBSE) ! Compute the Bethe-Salpeter excitation energies at the pp level based on a GHF reference @@ -13,20 +13,19 @@ subroutine GGW_ppBSE(TDA_W,TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int, logical,intent(in) :: dTDA double precision,intent(in) :: eta - integer,intent(in) :: nBas + integer,intent(in) :: nOrb integer,intent(in) :: nC integer,intent(in) :: nO integer,intent(in) :: nV integer,intent(in) :: nR integer,intent(in) :: nS - double precision,intent(in) :: eW(nBas) - double precision,intent(in) :: eGW(nBas) - double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) - double precision,intent(in) :: dipole_int(nBas,nBas,ncart) + double precision,intent(in) :: eW(nOrb) + double precision,intent(in) :: eGW(nOrb) + double precision,intent(in) :: ERI(nOrb,nOrb,nOrb,nOrb) + double precision,intent(in) :: dipole_int(nOrb,nOrb,ncart) ! Local variables - integer :: ispin integer :: isp_W logical :: dRPA = .false. @@ -71,20 +70,19 @@ subroutine GGW_ppBSE(TDA_W,TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int, isp_W = 3 EcRPA = 0d0 - allocate(OmRPA(nS),XpY_RPA(nS,nS),XmY_RPA(nS,nS),rho_RPA(nBas,nBas,nS), & + allocate(OmRPA(nS),XpY_RPA(nS,nS),XmY_RPA(nS,nS),rho_RPA(nOrb,nOrb,nS), & Aph(nS,nS),Bph(nS,nS)) - call phLR_A(isp_W,dRPA_W,nBas,nC,nO,nV,nR,nS,1d0,eW,ERI,Aph) + call phLR_A(isp_W,dRPA_W,nOrb,nC,nO,nV,nR,nS,1d0,eW,ERI,Aph) - if(.not.TDA_W) call phLR_B(isp_W,dRPA_W,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph) + if(.not.TDA_W) call phLR_B(isp_W,dRPA_W,nOrb,nC,nO,nV,nR,nS,1d0,ERI,Bph) call phLR(TDA_W,nS,Aph,Bph,EcRPA,OmRPA,XpY_RPA,XmY_RPA) - call RGW_excitation_density(nBas,nC,nO,nR,nS,ERI,XpY_RPA,rho_RPA) + call RGW_excitation_density(nOrb,nC,nO,nR,nS,ERI,XpY_RPA,rho_RPA) deallocate(XpY_RPA,XmY_RPA,Aph,Bph) - ispin = 4 EcBSE = 0d0 nOO = nO*(nO-1)/2 @@ -97,13 +95,13 @@ subroutine GGW_ppBSE(TDA_W,TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int, ! Compute BSE excitation energies - 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 GGW_ppBSE_static_kernel_C(eta,nOrb,nC,nO,nV,nR,nS,nVV,1d0,ERI,OmRPA,rho_RPA,KC_sta) + call GGW_ppBSE_static_kernel_D(eta,nOrb,nC,nO,nV,nR,nS,nOO,1d0,ERI,OmRPA,rho_RPA,KD_sta) + if(.not.TDA) call GGW_ppBSE_static_kernel_B(eta,nOrb,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) + call ppGLR_C(nOrb,nC,nO,nV,nR,nVV,1d0,eGW,ERI,Cpp) + call ppGLR_D(nOrb,nC,nO,nV,nR,nOO,1d0,eGW,ERI,Dpp) + if(.not.TDA) call ppGLR_B(nOrb,nC,nO,nV,nR,nOO,nVV,1d0,ERI,Bpp) Bpp(:,:) = Bpp(:,:) + KB_sta(:,:) Cpp(:,:) = Cpp(:,:) + KC_sta(:,:) @@ -111,14 +109,14 @@ subroutine GGW_ppBSE(TDA_W,TDA,dBSE,dTDA,eta,nBas,nC,nO,nV,nR,nS,ERI,dipole_int, call ppLR(TDA,nOO,nVV,Bpp,Cpp,Dpp,Om1,X1,Y1,Om2,X2,Y2,EcBSE) - call ppLR_transition_vectors(.true.,nBas,nC,nO,nV,nR,nOO,nVV,dipole_int,Om1,X1,Y1,Om2,X2,Y2) + call ppLR_transition_vectors(.true.,nOrb,nC,nO,nV,nR,nOO,nVV,dipole_int,Om1,X1,Y1,Om2,X2,Y2) !----------------------------------------------------! ! Compute the dynamical screening at the ppBSE level ! !----------------------------------------------------! ! if(dBSE) & -! call GGW_ppBSE_dynamic_perturbation(ispin,dTDA,eta,nBas,nC,nO,nV,nR,nS,nOO,nVV,eW,eGW,ERI,dipole_int,OmRPA,rho_RPA, & +! call GGW_ppBSE_dynamic_perturbation(dTDA,eta,nOrb,nC,nO,nV,nR,nS,nOO,nVV,eW,eGW,ERI,dipole_int,OmRPA,rho_RPA, & ! Om1,X1,Y1,Om2,X2,Y2,KB_sta,KC_sta,KD_sta) diff --git a/src/GW/GGW_ppBSE_static_kernel_B.f90 b/src/GW/GGW_ppBSE_static_kernel_B.f90 new file mode 100644 index 0000000..ac74f26 --- /dev/null +++ b/src/GW/GGW_ppBSE_static_kernel_B.f90 @@ -0,0 +1,66 @@ +subroutine GGW_ppBSE_static_kernel_B(eta,nBas,nC,nO,nV,nR,nS,nOO,nVV,lambda,ERI,Om,rho,KB) + +! Compute the VVOO block of the static screening W for the pp-BSE + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nS + integer,intent(in) :: nOO + integer,intent(in) :: nVV + double precision,intent(in) :: eta + double precision,intent(in) :: lambda + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: Om(nS) + double precision,intent(in) :: rho(nBas,nBas,nS) + +! Local variables + + double precision,external :: Kronecker_delta + double precision :: chi + double precision :: eps + integer :: a,b,i,j,ab,ij,m + +! Output variables + + double precision,intent(out) :: KB(nVV,nOO) + +! Initialization + + KB(:,:) = 0d0 + +!---------------! +! SpinOrb block ! +!---------------! + + ab = 0 + do a=nO+1,nBas-nR + do b=a+1,nBas-nR + ab = ab + 1 + ij = 0 + do i=nC+1,nO + do j=i+1,nO + ij = ij + 1 + + chi = 0d0 + do m=1,nS + eps = Om(m)**2 + eta**2 + chi = chi - rho(i,a,m)*rho(j,b,m)*Om(m)/eps & + + rho(i,b,m)*rho(a,j,m)*Om(m)/eps + end do + + KB(ab,ij) = 2d0*lambda*chi + + end do + end do + end do + end do + +end subroutine diff --git a/src/GW/GGW_ppBSE_static_kernel_C.f90 b/src/GW/GGW_ppBSE_static_kernel_C.f90 new file mode 100644 index 0000000..0e8cd05 --- /dev/null +++ b/src/GW/GGW_ppBSE_static_kernel_C.f90 @@ -0,0 +1,67 @@ +subroutine GGW_ppBSE_static_kernel_C(eta,nBas,nC,nO,nV,nR,nS,nVV,lambda,ERI,Om,rho,KC) + +! Compute the VVVV block of the static screening W for the pp-BSE + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nS + integer,intent(in) :: nVV + double precision,intent(in) :: eta + double precision,intent(in) :: lambda + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: Om(nS) + double precision,intent(in) :: rho(nBas,nBas,nS) + +! Local variables + + double precision,external :: Kronecker_delta + double precision :: chi + double precision :: eps + double precision :: tmp_ab, lambda4, eta2 + integer :: a,b,c,d,ab,cd,m + integer :: a0, aa + + double precision, allocatable :: Om_tmp(:) + double precision, allocatable :: tmp_m(:,:,:) + double precision, allocatable :: tmp(:,:,:,:) + +! Output variables + + double precision,intent(out) :: KC(nVV,nVV) + +!---------------! +! SpinOrb block ! +!---------------! + + 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 + + chi = 0d0 + do m=1,nS + eps = Om(m)**2 + eta**2 + chi = chi - rho(a,c,m)*rho(b,d,m)*Om(m)/eps & + + rho(a,d,m)*rho(b,c,m)*Om(m)/eps + end do + + KC(ab,cd) = 2d0*lambda*chi + + end do + end do + end do + end do + +end subroutine diff --git a/src/GW/GGW_ppBSE_static_kernel_D.f90 b/src/GW/GGW_ppBSE_static_kernel_D.f90 new file mode 100644 index 0000000..37c0672 --- /dev/null +++ b/src/GW/GGW_ppBSE_static_kernel_D.f90 @@ -0,0 +1,65 @@ +subroutine GGW_ppBSE_static_kernel_D(eta,nBas,nC,nO,nV,nR,nS,nOO,lambda,ERI,Om,rho,KD) + +! Compute the OOOO block of the static screening W for the pp-BSE + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nS + integer,intent(in) :: nOO + double precision,intent(in) :: eta + double precision,intent(in) :: lambda + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: Om(nS) + double precision,intent(in) :: rho(nBas,nBas,nS) + +! Local variables + + double precision,external :: Kronecker_delta + double precision :: chi + double precision :: eps + integer :: i,j,k,l,ij,kl,m + +! Output variables + + double precision,intent(out) :: KD(nOO,nOO) + +! Initialization + + KD(:,:) = 0d0 + +!---------------! +! SpinOrb block ! +!---------------! + + ij = 0 + do i=nC+1,nO + do j=i+1,nO + ij = ij + 1 + kl = 0 + do k=nC+1,nO + do l=k+1,nO + kl = kl + 1 + + chi = 0d0 + do m=1,nS + eps = Om(m)**2 + eta**2 + chi = chi - rho(i,k,m)*rho(j,l,m)*Om(m)/eps & + + rho(i,l,m)*rho(j,k,m)*Om(m)/eps + end do + + KD(ij,kl) = 2d0*lambda*chi + + end do + end do + end do + end do + +end subroutine diff --git a/src/GW/evGGW.f90 b/src/GW/evGGW.f90 index b8f18ec..7c862e9 100644 --- a/src/GW/evGGW.f90 +++ b/src/GW/evGGW.f90 @@ -43,7 +43,6 @@ subroutine evGGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dop logical :: linear_mixing logical :: dRPA = .true. - integer :: ispin integer :: nSCF integer :: n_diis double precision :: rcond @@ -100,7 +99,6 @@ subroutine evGGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dop ! Initialization nSCF = 0 - ispin = 3 n_diis = 0 Conv = 1d0 e_diis(:,:) = 0d0 @@ -118,10 +116,10 @@ subroutine evGGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dop ! Compute screening - call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,eGW,ERI,Aph) - if(.not.TDA_W) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph) + call phGLR_A(dRPA,nBas,nC,nO,nV,nR,nS,1d0,eGW,ERI,Aph) + if(.not.TDA_W) call phGLR_B(dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph) - call phLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY) + call phGLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY) ! Compute spectral weights diff --git a/src/GW/qsGGW.f90 b/src/GW/qsGGW.f90 index c98542a..ce6a64a 100644 --- a/src/GW/qsGGW.f90 +++ b/src/GW/qsGGW.f90 @@ -58,7 +58,6 @@ subroutine qsGGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dop integer :: nSCF integer :: nBasSq integer :: nBas2Sq - integer :: ispin integer :: ixyz integer :: n_diis double precision :: ET,ETaa,ETbb @@ -154,7 +153,6 @@ subroutine qsGGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dop nSCF = -1 n_diis = 0 - ispin = 3 Conv = 1d0 P(:,:) = PHF(:,:) eGW(:) = eHF(:) @@ -253,11 +251,11 @@ subroutine qsGGW(dotest,maxSCF,thresh,max_diis,doACFDT,exchange_kernel,doXBS,dop ! Compute linear response - call phLR_A(ispin,dRPA,nBas2,nC,nO,nV,nR,nS,1d0,eGW,ERI_MO,Aph) - if(.not.TDA_W) call phLR_B(ispin,dRPA,nBas2,nC,nO,nV,nR,nS,1d0,ERI_MO,Bph) + call phGLR_A(dRPA,nBas2,nC,nO,nV,nR,nS,1d0,eGW,ERI_MO,Aph) + if(.not.TDA_W) call phGLR_B(dRPA,nBas2,nC,nO,nV,nR,nS,1d0,ERI_MO,Bph) - call phLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY) - if(print_W) call print_excitation_energies('phRPA@GW@GHF','spinorbital',nS,Om) + call phGLR(TDA_W,nS,Aph,Bph,EcRPA,Om,XpY,XmY) + if(print_W) call print_excitation_energies('phRPA@GW@GHF','generalized',nS,Om) ! Compute correlation part of the self-energy diff --git a/src/LR/phGLR_A.f90 b/src/LR/phGLR_A.f90 index 29ae8a8..d23a6b8 100644 --- a/src/LR/phGLR_A.f90 +++ b/src/LR/phGLR_A.f90 @@ -1,4 +1,4 @@ -subroutine phRLR_A(dRPA,nOrb,nC,nO,nV,nR,nS,lambda,e,ERI,Aph) +subroutine phGLR_A(dRPA,nOrb,nC,nO,nV,nR,nS,lambda,e,ERI,Aph) ! Compute resonant block of the ph channel diff --git a/src/LR/phLR_oscillator_strength.f90 b/src/LR/phLR_oscillator_strength.f90 index f8cb55d..796a6a2 100644 --- a/src/LR/phLR_oscillator_strength.f90 +++ b/src/LR/phLR_oscillator_strength.f90 @@ -1,4 +1,4 @@ -subroutine phLR_oscillator_strength(nBas,nC,nO,nV,nR,nS,maxS,dipole_int,Om,XpY,XmY,os) +subroutine phLR_oscillator_strength(nOrb,nC,nO,nV,nR,nS,maxS,dipole_int,Om,XpY,XmY,os) ! Compute linear response @@ -7,14 +7,14 @@ subroutine phLR_oscillator_strength(nBas,nC,nO,nV,nR,nS,maxS,dipole_int,Om,XpY,X ! Input variables - integer,intent(in) :: nBas + integer,intent(in) :: nOrb integer,intent(in) :: nC integer,intent(in) :: nO integer,intent(in) :: nV integer,intent(in) :: nR integer,intent(in) :: nS integer,intent(in) :: maxS - double precision :: dipole_int(nBas,nBas,ncart) + double precision :: dipole_int(nOrb,nOrb,ncart) double precision,intent(in) :: Om(nS) double precision,intent(in) :: XpY(nS,nS) double precision,intent(in) :: XmY(nS,nS) @@ -44,7 +44,7 @@ subroutine phLR_oscillator_strength(nBas,nC,nO,nV,nR,nS,maxS,dipole_int,Om,XpY,X do ixyz=1,ncart jb = 0 do j=nC+1,nO - do b=nO+1,nBas-nR + do b=nO+1,nOrb-nR jb = jb + 1 f(m,ixyz) = f(m,ixyz) + dipole_int(j,b,ixyz)*XpY(m,jb) end do @@ -68,8 +68,4 @@ subroutine phLR_oscillator_strength(nBas,nC,nO,nV,nR,nS,maxS,dipole_int,Om,XpY,X write(*,*) '---------------------------------------------------------------' write(*,*) -! do m=1,maxS -! write(*,'(I3,3F12.6)') m,Om(m),os(m) -! end do - end subroutine diff --git a/src/LR/ppGLR.f90 b/src/LR/ppGLR.f90 new file mode 100644 index 0000000..536015b --- /dev/null +++ b/src/LR/ppGLR.f90 @@ -0,0 +1,125 @@ +subroutine ppGLR(TDA,nOO,nVV,Bpp,Cpp,Dpp,Om1,X1,Y1,Om2,X2,Y2,EcRPA) + + ! + ! Solve the pp-RPA linear eigenvalue problem + ! + ! right eigen-problem: H R = R w + ! left eigen-problem: H.T L = L w + ! + ! where L.T R = 1 + ! + ! + ! (+C +B) + ! H = ( ) where C = C.T and D = D.T + ! (-B.T -D) + ! + ! (w1 0) (X1 X2) (+X1 +X2) + ! w = ( ), R = ( ) and L = ( ) + ! (0 w2) (Y1 Y2) (-Y1 -Y2) + ! + ! + ! the normalisation condition reduces to + ! + ! X1.T X2 - Y1.T Y2 = 0 + ! X1.T X1 - Y1.T Y1 = 1 + ! X2.T X2 - Y2.T Y2 = 1 + ! + + implicit none + include 'parameters.h' + + logical, intent(in) :: TDA + integer, intent(in) :: nOO, nVV + double precision, intent(in) :: Bpp(nVV,nOO), Cpp(nVV,nVV), Dpp(nOO,nOO) + double precision, intent(out) :: Om1(nVV), X1(nVV,nVV), Y1(nOO,nVV) + double precision, intent(out) :: Om2(nOO), X2(nVV,nOO), Y2(nOO,nOO) + double precision, intent(out) :: EcRPA + + logical :: imp_bio, verbose + integer :: i, j, N + double precision :: EcRPA1, EcRPA2 + double precision :: thr_d, thr_nd, thr_deg + double precision,allocatable :: M(:,:), Z(:,:), Om(:) + + double precision, external :: trace_matrix + + + + N = nOO + nVV + + allocate(M(N,N), Z(N,N), Om(N)) + + if(TDA) then + + X1(:,:) = +Cpp(:,:) + Y1(:,:) = 0d0 + if(nVV > 0) call diagonalize_matrix(nVV, X1, Om1) + + X2(:,:) = 0d0 + Y2(:,:) = -Dpp(:,:) + if(nOO > 0) call diagonalize_matrix(nOO, Y2, Om2) + + else + + ! Diagonal blocks + M( 1:nVV , 1:nVV) = + Cpp(1:nVV,1:nVV) + M(nVV+1:nVV+nOO,nVV+1:nVV+nOO) = - Dpp(1:nOO,1:nOO) + + ! Off-diagonal blocks + M( 1:nVV ,nVV+1:nOO+nVV) = - Bpp(1:nVV,1:nOO) + M(nVV+1:nOO+nVV, 1:nVV) = + transpose(Bpp(1:nVV,1:nOO)) + + if((nOO .eq. 0) .or. (nVV .eq. 0)) then + + ! Diagonalize the p-p matrix + if(nOO+nVV > 0) call diagonalize_general_matrix(nOO+nVV, M, Om, Z) + ! Split the various quantities in p-p and h-h parts + call sort_ppRPA(nOO, nVV, Om, Z, Om1, X1, Y1, Om2, X2, Y2) + + else + + thr_d = 1d-6 ! to determine if diagonal elements of L.T x R are close enouph to 1 + thr_nd = 1d-6 ! to determine if non-diagonal elements of L.T x R are close enouph to 1 + thr_deg = 1d-8 ! to determine if two eigenvectors are degenerate or not + imp_bio = .True. ! impose bi-orthogonality + verbose = .False. + call diagonalize_nonsym_matrix(N, M, Z, Om, thr_d, thr_nd, thr_deg, imp_bio, verbose) + + do i = 1, nOO + Om2(i) = Om(i) + do j = 1, nVV + X2(j,i) = Z(j,i) + enddo + do j = 1, nOO + Y2(j,i) = Z(nVV+j,i) + enddo + enddo + + do i = 1, nVV + Om1(i) = Om(nOO+i) + do j = 1, nVV + X1(j,i) = M(j,nOO+i) + enddo + do j = 1, nOO + Y1(j,i) = M(nVV+j,nOO+i) + enddo + enddo + + endif + + end if + + ! Compute the RPA correlation energy + EcRPA = 0.5d0 * (sum(Om1) - sum(Om2) - trace_matrix(nVV, Cpp) - trace_matrix(nOO, Dpp)) + EcRPA1 = +sum(Om1) - trace_matrix(nVV, Cpp) + EcRPA2 = -sum(Om2) - trace_matrix(nOO, Dpp) + + if(abs(EcRPA - EcRPA1) > 1d-6 .or. abs(EcRPA - EcRPA2) > 1d-6) then + print*,'!!! Issue in pp-RPA linear reponse calculation RPA1 != RPA2 !!!' + endif + + deallocate(M, Z, Om) + +end subroutine + + diff --git a/src/LR/ppGLR_B.f90 b/src/LR/ppGLR_B.f90 new file mode 100644 index 0000000..10b5107 --- /dev/null +++ b/src/LR/ppGLR_B.f90 @@ -0,0 +1,47 @@ +subroutine ppGLR_B(nBas,nC,nO,nV,nR,nOO,nVV,lambda,ERI,Bpp) + +! Compute the B matrix of the pp channel + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nOO + integer,intent(in) :: nVV + double precision,intent(in) :: lambda + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + +! Local variables + + double precision,external :: Kronecker_delta + integer :: a,b,i,j,ab,ij + +! Output variables + + double precision,intent(out) :: Bpp(nVV,nOO) + +! Build the B matrix for the spin-orbital basis + + ab = 0 + do a=nO+1,nBas-nR + do b=a+1,nBas-nR + ab = ab + 1 + ij = 0 + do i=nC+1,nO + do j=i+1,nO + ij = ij + 1 + + Bpp(ab,ij) = lambda*(ERI(a,b,i,j) - ERI(a,b,j,i)) + + end do + end do + end do + end do + +end subroutine diff --git a/src/LR/ppGLR_C.f90 b/src/LR/ppGLR_C.f90 new file mode 100644 index 0000000..583443a --- /dev/null +++ b/src/LR/ppGLR_C.f90 @@ -0,0 +1,61 @@ +subroutine ppGLR_C(nBas,nC,nO,nV,nR,nVV,lambda,e,ERI,Cpp) + +! Compute the C matrix of the pp channel + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nVV + double precision,intent(in) :: lambda + double precision,intent(in) :: e(nBas),ERI(nBas,nBas,nBas,nBas) + +! Local variables + + double precision :: eF + double precision,external :: Kronecker_delta + + integer :: a,b,c,d,ab,cd + integer :: a0, aa + double precision :: e_ab, tmp_ab, delta_ac, tmp_cd + +! Output variables + + double precision,intent(out) :: Cpp(nVV,nVV) + +! Define the chemical potential + +! eF = e(nO) + e(nO+1) + eF = 0d0 + +! Build C matrix for the singlet manifold + + !$OMP PARALLEL & + !$OMP SHARED(Cpp,lambda,ERI,e,eF,nC,nO,nBas,nR) & + !$OMP PRIVATE(c,d,a,b,ab,cd) & + !$OMP DEFAULT(NONE) + !$OMP DO + do c=nO+1,nBas-nR + do d=c+1,nBas-nR + cd = (c-(nO+1))*(nBas-nR-(nO+1)) - (c-1-(nO+1))*(c-(nO+1))/2 + d - c + do a=nO+1,nBas-nR + do b=a+1,nBas-nR + ab = (a-(nO+1))*(nBas-nR-(nO+1)) - (a-1-(nO+1))*(a-(nO+1))/2 + b - a + + Cpp(ab,cd) = + (e(a) + e(b) - eF)*Kronecker_delta(a,c)*Kronecker_delta(b,d) & + + lambda*(ERI(a,b,c,d) - ERI(a,b,d,c)) + + end do + end do + end do + end do + !$OMP END DO + !$OMP END PARALLEL + +end subroutine diff --git a/src/LR/ppGLR_D.f90 b/src/LR/ppGLR_D.f90 new file mode 100644 index 0000000..b5ecf0b --- /dev/null +++ b/src/LR/ppGLR_D.f90 @@ -0,0 +1,54 @@ +subroutine ppGLR_D(nBas,nC,nO,nV,nR,nOO,lambda,e,ERI,Dpp) + +! Compute the D matrix of the pp channel + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nOO + double precision,intent(in) :: lambda + double precision,intent(in) :: e(nBas),ERI(nBas,nBas,nBas,nBas) + +! Local variables + + double precision :: eF + double precision,external :: Kronecker_delta + + integer :: i,j,k,l,ij,kl + +! Output variables + + double precision,intent(out) :: Dpp(nOO,nOO) + +! Define the chemical potential + +! eF = e(nO) + e(nO+1) + eF = 0d0 + +! Build the D matrix for the spin-orbital basis + + ij = 0 + do i=nC+1,nO + do j=i+1,nO + ij = ij + 1 + kl = 0 + do k=nC+1,nO + do l=k+1,nO + kl = kl + 1 + + Dpp(ij,kl) = - (e(i) + e(j) - eF)*Kronecker_delta(i,k)*Kronecker_delta(j,l) & + + lambda*(ERI(i,j,k,l) - ERI(i,j,l,k)) + + end do + end do + end do + end do + +end subroutine diff --git a/src/LR/ppLR.f90 b/src/LR/ppLR.f90 index 582e28f..d5b4146 100644 --- a/src/LR/ppLR.f90 +++ b/src/LR/ppLR.f90 @@ -1,7 +1,4 @@ - -! --- - -subroutine ppLR(TDA, nOO, nVV, Bpp, Cpp, Dpp, Om1, X1, Y1, Om2, X2, Y2, EcRPA) +subroutine ppLR(TDA,nOO,nVV,Bpp,Cpp,Dpp,Om1,X1,Y1,Om2,X2,Y2,EcRPA) ! ! Solve the pp-RPA linear eigenvalue problem diff --git a/src/RPA/crGRPA.f90 b/src/RPA/crGRPA.f90 index 2f0a481..33db3a8 100644 --- a/src/RPA/crGRPA.f90 +++ b/src/RPA/crGRPA.f90 @@ -1,4 +1,4 @@ -subroutine crGRPA(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) +subroutine crGRPA(dotest,TDA,nOrb,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) ! Crossed-ring channel of the random phase approximation @@ -11,7 +11,7 @@ subroutine crGRPA(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) logical,intent(in) :: dotest logical,intent(in) :: TDA - integer,intent(in) :: nBas + integer,intent(in) :: nOrb integer,intent(in) :: nC integer,intent(in) :: nO integer,intent(in) :: nV @@ -19,13 +19,12 @@ subroutine crGRPA(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) integer,intent(in) :: nS double precision,intent(in) :: ENuc double precision,intent(in) :: EGHF - double precision,intent(in) :: eHF(nBas) - double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) - double precision,intent(in) :: dipole_int(nBas,nBas,ncart) + double precision,intent(in) :: eHF(nOrb) + double precision,intent(in) :: ERI(nOrb,nOrb,nOrb,nOrb) + double precision,intent(in) :: dipole_int(nOrb,nOrb,ncart) ! Local variables - integer :: ispin logical :: dRPA double precision,allocatable :: Aph(:,:) double precision,allocatable :: Bph(:,:) @@ -59,14 +58,12 @@ subroutine crGRPA(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) allocate(Om(nS),XpY(nS,nS),XmY(nS,nS),Aph(nS,nS),Bph(nS,nS)) - ispin = 3 + call phLR_A(dRPA,nOrb,nC,nO,nV,nR,nS,-1d0,eHF,ERI,Aph) + if(.not.TDA) call phLR_B(dRPA,nOrb,nC,nO,nV,nR,nS,-1d0,ERI,Bph) - call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,-1d0,eHF,ERI,Aph) - if(.not.TDA) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,-1d0,ERI,Bph) - - call phLR(TDA,nS,Aph,Bph,EcRPA,Om,XpY,XmY) + call phGLR(TDA,nS,Aph,Bph,EcRPA,Om,XpY,XmY) call print_excitation_energies('crRPA@GHF','spinorbital',nS,Om) - call phLR_transition_vectors(.true.,nBas,nC,nO,nV,nR,nS,dipole_int,Om,XpY,XmY) + call phLR_transition_vectors(.true.,nOrb,nC,nO,nV,nR,nS,dipole_int,Om,XpY,XmY) write(*,*) write(*,*)'-------------------------------------------------------------------------------' diff --git a/src/RPA/phGRPA.f90 b/src/RPA/phGRPA.f90 index 3907920..5f67e8c 100644 --- a/src/RPA/phGRPA.f90 +++ b/src/RPA/phGRPA.f90 @@ -1,4 +1,4 @@ -subroutine phGRPA(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) +subroutine phGRPA(dotest,TDA,nOrb,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) ! Perform a direct random phase approximation calculation @@ -11,7 +11,7 @@ subroutine phGRPA(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) logical,intent(in) :: dotest logical,intent(in) :: TDA - integer,intent(in) :: nBas + integer,intent(in) :: nOrb integer,intent(in) :: nC integer,intent(in) :: nO integer,intent(in) :: nV @@ -19,13 +19,12 @@ subroutine phGRPA(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) integer,intent(in) :: nS double precision,intent(in) :: ENuc double precision,intent(in) :: EGHF - double precision,intent(in) :: eHF(nBas) - double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) - double precision,intent(in) :: dipole_int(nBas,nBas,ncart) + double precision,intent(in) :: eHF(nOrb) + double precision,intent(in) :: ERI(nOrb,nOrb,nOrb,nOrb) + double precision,intent(in) :: dipole_int(nOrb,nOrb,ncart) ! Local variables - integer :: ispin logical :: dRPA double precision :: lambda @@ -62,14 +61,12 @@ subroutine phGRPA(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) allocate(Om(nS),XpY(nS,nS),XmY(nS,nS),Aph(nS,nS),Bph(nS,nS)) - ispin = 3 + call phGLR_A(dRPA,nOrb,nC,nO,nV,nR,nS,lambda,eHF,ERI,Aph) + if(.not.TDA) call phGLR_B(dRPA,nOrb,nC,nO,nV,nR,nS,lambda,ERI,Bph) - call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,lambda,eHF,ERI,Aph) - if(.not.TDA) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,lambda,ERI,Bph) - - call phLR(TDA,nS,Aph,Bph,EcRPA,Om,XpY,XmY) + call phGLR(TDA,nS,Aph,Bph,EcRPA,Om,XpY,XmY) call print_excitation_energies('phRPA@GHF','spinorbital',nS,Om) - call phLR_transition_vectors(.true.,nBas,nC,nO,nV,nR,nS,dipole_int,Om,XpY,XmY) + call phLR_transition_vectors(.true.,nOrb,nC,nO,nV,nR,nS,dipole_int,Om,XpY,XmY) write(*,*) write(*,*)'-------------------------------------------------------------------------------' diff --git a/src/RPA/phGRPAx.f90 b/src/RPA/phGRPAx.f90 index 1137322..acf4b0c 100644 --- a/src/RPA/phGRPAx.f90 +++ b/src/RPA/phGRPAx.f90 @@ -1,4 +1,4 @@ -subroutine phGRPAx(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) +subroutine phGRPAx(dotest,TDA,nOrb,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) ! Perform random phase approximation calculation with exchange (aka TDHF) @@ -11,7 +11,7 @@ subroutine phGRPAx(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) logical,intent(in) :: dotest logical,intent(in) :: TDA - integer,intent(in) :: nBas + integer,intent(in) :: nOrb integer,intent(in) :: nC integer,intent(in) :: nO integer,intent(in) :: nV @@ -19,13 +19,12 @@ subroutine phGRPAx(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) integer,intent(in) :: nS double precision,intent(in) :: ENuc double precision,intent(in) :: EGHF - double precision,intent(in) :: eHF(nBas) - double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) - double precision,intent(in) :: dipole_int(nBas,nBas,ncart) + double precision,intent(in) :: eHF(nOrb) + double precision,intent(in) :: ERI(nOrb,nOrb,nOrb,nOrb) + double precision,intent(in) :: dipole_int(nOrb,nOrb,ncart) ! Local variables - integer :: ispin logical :: dRPA double precision,allocatable :: Aph(:,:) double precision,allocatable :: Bph(:,:) @@ -59,14 +58,12 @@ subroutine phGRPAx(dotest,TDA,nBas,nC,nO,nV,nR,nS,ENuc,EGHF,ERI,dipole_int,eHF) allocate(Om(nS),XpY(nS,nS),XmY(nS,nS),Aph(nS,nS),Bph(nS,nS)) - ispin = 3 + call phGLR_A(dRPA,nOrb,nC,nO,nV,nR,nS,1d0,eHF,ERI,Aph) + if(.not.TDA) call phLR_B(dRPA,nOrb,nC,nO,nV,nR,nS,1d0,ERI,Bph) - call phLR_A(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,eHF,ERI,Aph) - if(.not.TDA) call phLR_B(ispin,dRPA,nBas,nC,nO,nV,nR,nS,1d0,ERI,Bph) - - call phLR(TDA,nS,Aph,Bph,EcRPA,Om,XpY,XmY) + call phGLR(TDA,nS,Aph,Bph,EcRPA,Om,XpY,XmY) call print_excitation_energies('phRPAx@GHF','spinorbital',nS,Om) - call phLR_transition_vectors(.true.,nBas,nC,nO,nV,nR,nS,dipole_int,Om,XpY,XmY) + call phLR_transition_vectors(.true.,nOrb,nC,nO,nV,nR,nS,dipole_int,Om,XpY,XmY) write(*,*) write(*,*)'-------------------------------------------------------------------------------' diff --git a/src/RPA/ppGRPA.f90 b/src/RPA/ppGRPA.f90 index 6a9c62a..2747d0c 100644 --- a/src/RPA/ppGRPA.f90 +++ b/src/RPA/ppGRPA.f90 @@ -23,7 +23,6 @@ subroutine ppGRPA(dotest,TDA,nBas,nC,nO,nV,nR,ENuc,EGHF,ERI,dipole_int,eHF) ! Local variables - integer :: ispin integer :: nOO integer :: nVV double precision,allocatable :: Bpp(:,:) @@ -50,19 +49,17 @@ subroutine ppGRPA(dotest,TDA,nBas,nC,nO,nV,nR,ENuc,EGHF,ERI,dipole_int,eHF) EcRPA = 0d0 - ispin = 4 - nOO = nO*(nO-1)/2 nVV = nV*(nV-1)/2 allocate(Om1(nVV),X1(nVV,nVV),Y1(nOO,nVV),Om2(nOO),X2(nVV,nOO),Y2(nOO,nOO), & Bpp(nVV,nOO),Cpp(nVV,nVV),Dpp(nOO,nOO)) - if(.not.TDA) call ppLR_B(ispin,nBas,nC,nO,nV,nR,nOO,nVV,1d0,ERI,Bpp) - call ppLR_C(ispin,nBas,nC,nO,nV,nR,nVV,1d0,eHF,ERI,Cpp) - call ppLR_D(ispin,nBas,nC,nO,nV,nR,nOO,1d0,eHF,ERI,Dpp) + if(.not.TDA) call ppGLR_B(nBas,nC,nO,nV,nR,nOO,nVV,1d0,ERI,Bpp) + call ppGLR_C(nBas,nC,nO,nV,nR,nVV,1d0,eHF,ERI,Cpp) + call ppGLR_D(nBas,nC,nO,nV,nR,nOO,1d0,eHF,ERI,Dpp) - call ppLR(TDA,nOO,nVV,Bpp,Cpp,Dpp,Om1,X1,Y1,Om2,X2,Y2,EcRPA) + call ppGLR(TDA,nOO,nVV,Bpp,Cpp,Dpp,Om1,X1,Y1,Om2,X2,Y2,EcRPA) ! call print_transition_vectors_pp(.true.,nBas,nC,nO,nV,nR,nOO,nVV,dipole_int,Om1,X1,Y1,Om2,X2,Y2)