diff --git a/examples/molecule.H2 b/examples/molecule.H2 index aed0926..81c624a 100644 --- a/examples/molecule.H2 +++ b/examples/molecule.H2 @@ -2,4 +2,4 @@ 2 1 1 0 0 # Znuc x y z H 0. 0. 0. - H 0. 0. 3.7 + H 0. 0. 1.4 diff --git a/examples/molecule.HCl b/examples/molecule.HCl index 27db08a..adca697 100644 --- a/examples/molecule.HCl +++ b/examples/molecule.HCl @@ -1,5 +1,5 @@ # nAt nEla nElb nCore nRyd - 2 9 9 0 0 + 2 9 9 0 0 # Znuc x y z H 0. 0. -0.02489783 Cl 0. 0. 2.38483140 diff --git a/input/basis b/input/basis index bbe0bfe..d31581b 100644 --- a/input/basis +++ b/input/basis @@ -1,71 +1,92 @@ -1 9 +1 14 S 8 - 1 9046.0000000 0.0007000 - 2 1357.0000000 0.0053890 - 3 309.3000000 0.0274060 - 4 87.7300000 0.1032070 - 5 28.5600000 0.2787230 - 6 10.2100000 0.4485400 - 7 3.8380000 0.2782380 - 8 0.7466000 0.0154400 + 1 11420.0000000 0.0005230 + 2 1712.0000000 0.0040450 + 3 389.3000000 0.0207750 + 4 110.0000000 0.0807270 + 5 35.5700000 0.2330740 + 6 12.5400000 0.4335010 + 7 4.6440000 0.3474720 + 8 0.5118000 -0.0085080 S 8 - 1 9046.0000000 -0.0001530 - 2 1357.0000000 -0.0012080 - 3 309.3000000 -0.0059920 - 4 87.7300000 -0.0245440 - 5 28.5600000 -0.0674590 - 6 10.2100000 -0.1580780 - 7 3.8380000 -0.1218310 - 8 0.7466000 0.5490030 + 1 11420.0000000 -0.0001150 + 2 1712.0000000 -0.0008950 + 3 389.3000000 -0.0046240 + 4 110.0000000 -0.0185280 + 5 35.5700000 -0.0573390 + 6 12.5400000 -0.1320760 + 7 4.6440000 -0.1725100 + 8 0.5118000 0.5999440 S 1 - 1 0.2248000 1.0000000 + 1 1.2930000 1.0000000 S 1 - 1 0.0612400 1.0000000 + 1 0.1787000 1.0000000 +S 1 + 1 0.0576000 1.0000000 P 3 - 1 13.5500000 0.0399190 - 2 2.9170000 0.2171690 - 3 0.7973000 0.5103190 + 1 26.6300000 0.0146700 + 2 5.9480000 0.0917640 + 3 1.7420000 0.2986830 P 1 - 1 0.2185000 1.0000000 + 1 0.5550000 1.0000000 P 1 - 1 0.0561100 1.0000000 + 1 0.1725000 1.0000000 +P 1 + 1 0.0491000 1.0000000 D 1 - 1 0.8170000 1.0000000 + 1 1.6540000 1.0000000 D 1 - 1 0.2300000 1.0000000 -2 9 + 1 0.4690000 1.0000000 +D 1 + 1 0.1510000 1.0000000 +F 1 + 1 1.0930000 1.0000000 +F 1 + 1 0.3640000 1.0000000 +2 14 S 8 - 1 9046.0000000 0.0007000 - 2 1357.0000000 0.0053890 - 3 309.3000000 0.0274060 - 4 87.7300000 0.1032070 - 5 28.5600000 0.2787230 - 6 10.2100000 0.4485400 - 7 3.8380000 0.2782380 - 8 0.7466000 0.0154400 + 1 11420.0000000 0.0005230 + 2 1712.0000000 0.0040450 + 3 389.3000000 0.0207750 + 4 110.0000000 0.0807270 + 5 35.5700000 0.2330740 + 6 12.5400000 0.4335010 + 7 4.6440000 0.3474720 + 8 0.5118000 -0.0085080 S 8 - 1 9046.0000000 -0.0001530 - 2 1357.0000000 -0.0012080 - 3 309.3000000 -0.0059920 - 4 87.7300000 -0.0245440 - 5 28.5600000 -0.0674590 - 6 10.2100000 -0.1580780 - 7 3.8380000 -0.1218310 - 8 0.7466000 0.5490030 + 1 11420.0000000 -0.0001150 + 2 1712.0000000 -0.0008950 + 3 389.3000000 -0.0046240 + 4 110.0000000 -0.0185280 + 5 35.5700000 -0.0573390 + 6 12.5400000 -0.1320760 + 7 4.6440000 -0.1725100 + 8 0.5118000 0.5999440 S 1 - 1 0.2248000 1.0000000 + 1 1.2930000 1.0000000 S 1 - 1 0.0612400 1.0000000 + 1 0.1787000 1.0000000 +S 1 + 1 0.0576000 1.0000000 P 3 - 1 13.5500000 0.0399190 - 2 2.9170000 0.2171690 - 3 0.7973000 0.5103190 + 1 26.6300000 0.0146700 + 2 5.9480000 0.0917640 + 3 1.7420000 0.2986830 P 1 - 1 0.2185000 1.0000000 + 1 0.5550000 1.0000000 P 1 - 1 0.0561100 1.0000000 + 1 0.1725000 1.0000000 +P 1 + 1 0.0491000 1.0000000 D 1 - 1 0.8170000 1.0000000 + 1 1.6540000 1.0000000 D 1 - 1 0.2300000 1.0000000 + 1 0.4690000 1.0000000 +D 1 + 1 0.1510000 1.0000000 +F 1 + 1 1.0930000 1.0000000 +F 1 + 1 0.3640000 1.0000000 + diff --git a/input/methods b/input/methods index ed4fbc4..63c03d4 100644 --- a/input/methods +++ b/input/methods @@ -13,7 +13,7 @@ # G0F2 evGF2 G0F3 evGF3 F F F F # G0W0 evGW qsGW - T T F + T F F # G0T0 evGT qsGT F F F # MCMP2 diff --git a/input/options b/input/options index a64c19d..c88bdf9 100644 --- a/input/options +++ b/input/options @@ -9,7 +9,7 @@ # GF: maxSCF thresh DIIS n_diis lin renorm 256 0.00001 T 5 T 3 # GW/GT: maxSCF thresh DIIS n_diis COHSEX SOSEX BSE TDA G0W GW0 lin eta - 256 0.00001 T 5 F F T F F F T 0.00367493 + 256 0.00001 T 10 F F T F F F T 0.00367493 # ACFDT: AC Kx XBS F F T # MCMP2: nMC nEq nWalk dt nPrint iSeed doDrift diff --git a/input/weight b/input/weight index bbe0bfe..d31581b 100644 --- a/input/weight +++ b/input/weight @@ -1,71 +1,92 @@ -1 9 +1 14 S 8 - 1 9046.0000000 0.0007000 - 2 1357.0000000 0.0053890 - 3 309.3000000 0.0274060 - 4 87.7300000 0.1032070 - 5 28.5600000 0.2787230 - 6 10.2100000 0.4485400 - 7 3.8380000 0.2782380 - 8 0.7466000 0.0154400 + 1 11420.0000000 0.0005230 + 2 1712.0000000 0.0040450 + 3 389.3000000 0.0207750 + 4 110.0000000 0.0807270 + 5 35.5700000 0.2330740 + 6 12.5400000 0.4335010 + 7 4.6440000 0.3474720 + 8 0.5118000 -0.0085080 S 8 - 1 9046.0000000 -0.0001530 - 2 1357.0000000 -0.0012080 - 3 309.3000000 -0.0059920 - 4 87.7300000 -0.0245440 - 5 28.5600000 -0.0674590 - 6 10.2100000 -0.1580780 - 7 3.8380000 -0.1218310 - 8 0.7466000 0.5490030 + 1 11420.0000000 -0.0001150 + 2 1712.0000000 -0.0008950 + 3 389.3000000 -0.0046240 + 4 110.0000000 -0.0185280 + 5 35.5700000 -0.0573390 + 6 12.5400000 -0.1320760 + 7 4.6440000 -0.1725100 + 8 0.5118000 0.5999440 S 1 - 1 0.2248000 1.0000000 + 1 1.2930000 1.0000000 S 1 - 1 0.0612400 1.0000000 + 1 0.1787000 1.0000000 +S 1 + 1 0.0576000 1.0000000 P 3 - 1 13.5500000 0.0399190 - 2 2.9170000 0.2171690 - 3 0.7973000 0.5103190 + 1 26.6300000 0.0146700 + 2 5.9480000 0.0917640 + 3 1.7420000 0.2986830 P 1 - 1 0.2185000 1.0000000 + 1 0.5550000 1.0000000 P 1 - 1 0.0561100 1.0000000 + 1 0.1725000 1.0000000 +P 1 + 1 0.0491000 1.0000000 D 1 - 1 0.8170000 1.0000000 + 1 1.6540000 1.0000000 D 1 - 1 0.2300000 1.0000000 -2 9 + 1 0.4690000 1.0000000 +D 1 + 1 0.1510000 1.0000000 +F 1 + 1 1.0930000 1.0000000 +F 1 + 1 0.3640000 1.0000000 +2 14 S 8 - 1 9046.0000000 0.0007000 - 2 1357.0000000 0.0053890 - 3 309.3000000 0.0274060 - 4 87.7300000 0.1032070 - 5 28.5600000 0.2787230 - 6 10.2100000 0.4485400 - 7 3.8380000 0.2782380 - 8 0.7466000 0.0154400 + 1 11420.0000000 0.0005230 + 2 1712.0000000 0.0040450 + 3 389.3000000 0.0207750 + 4 110.0000000 0.0807270 + 5 35.5700000 0.2330740 + 6 12.5400000 0.4335010 + 7 4.6440000 0.3474720 + 8 0.5118000 -0.0085080 S 8 - 1 9046.0000000 -0.0001530 - 2 1357.0000000 -0.0012080 - 3 309.3000000 -0.0059920 - 4 87.7300000 -0.0245440 - 5 28.5600000 -0.0674590 - 6 10.2100000 -0.1580780 - 7 3.8380000 -0.1218310 - 8 0.7466000 0.5490030 + 1 11420.0000000 -0.0001150 + 2 1712.0000000 -0.0008950 + 3 389.3000000 -0.0046240 + 4 110.0000000 -0.0185280 + 5 35.5700000 -0.0573390 + 6 12.5400000 -0.1320760 + 7 4.6440000 -0.1725100 + 8 0.5118000 0.5999440 S 1 - 1 0.2248000 1.0000000 + 1 1.2930000 1.0000000 S 1 - 1 0.0612400 1.0000000 + 1 0.1787000 1.0000000 +S 1 + 1 0.0576000 1.0000000 P 3 - 1 13.5500000 0.0399190 - 2 2.9170000 0.2171690 - 3 0.7973000 0.5103190 + 1 26.6300000 0.0146700 + 2 5.9480000 0.0917640 + 3 1.7420000 0.2986830 P 1 - 1 0.2185000 1.0000000 + 1 0.5550000 1.0000000 P 1 - 1 0.0561100 1.0000000 + 1 0.1725000 1.0000000 +P 1 + 1 0.0491000 1.0000000 D 1 - 1 0.8170000 1.0000000 + 1 1.6540000 1.0000000 D 1 - 1 0.2300000 1.0000000 + 1 0.4690000 1.0000000 +D 1 + 1 0.1510000 1.0000000 +F 1 + 1 1.0930000 1.0000000 +F 1 + 1 0.3640000 1.0000000 + diff --git a/src/QuAcK/Bethe_Salpeter.f90 b/src/QuAcK/Bethe_Salpeter.f90 index 0f2ec9d..b73504d 100644 --- a/src/QuAcK/Bethe_Salpeter.f90 +++ b/src/QuAcK/Bethe_Salpeter.f90 @@ -25,6 +25,7 @@ subroutine Bethe_Salpeter(TDA,singlet_manifold,triplet_manifold,eta, & ! Local variables + logical :: evDyn = .false. integer :: ispin double precision,allocatable :: OmBSE(:,:) double precision,allocatable :: XpY_BSE(:,:,:) @@ -66,9 +67,16 @@ subroutine Bethe_Salpeter(TDA,singlet_manifold,triplet_manifold,eta, & ! Compute dynamic correction for BSE via perturbation theory - call Bethe_Salpeter_dynamic_perturbation(TDA,eta,nBas,nC,nO,nV,nR,nS,eGW(:),OmRPA(:,ispin),OmBSE(:,ispin), & - XpY_BSE(:,:,ispin),XmY_BSE(:,:,ispin),rho_RPA(:,:,:,ispin)) + if(evDyn) then + call Bethe_Salpeter_dynamic_perturbation_iterative(TDA,eta,nBas,nC,nO,nV,nR,nS,eGW(:),OmRPA(:,ispin),OmBSE(:,ispin), & + XpY_BSE(:,:,ispin),XmY_BSE(:,:,ispin),rho_RPA(:,:,:,ispin)) + else + + call Bethe_Salpeter_dynamic_perturbation(TDA,eta,nBas,nC,nO,nV,nR,nS,eGW(:),OmRPA(:,ispin),OmBSE(:,ispin), & + XpY_BSE(:,:,ispin),XmY_BSE(:,:,ispin),rho_RPA(:,:,:,ispin)) + end if + end if !------------------- @@ -97,9 +105,15 @@ subroutine Bethe_Salpeter(TDA,singlet_manifold,triplet_manifold,eta, & ! Compute dynamic correction for BSE via perturbation theory - call Bethe_Salpeter_dynamic_perturbation(TDA,eta,nBas,nC,nO,nV,nR,nS,eGW(:),OmRPA(:,ispin),OmBSE(:,ispin), & - XpY_BSE(:,:,ispin),XmY_BSE(:,:,ispin),rho_RPA(:,:,:,ispin)) + if(evDyn) then + call Bethe_Salpeter_dynamic_perturbation_iterative(TDA,eta,nBas,nC,nO,nV,nR,nS,eGW(:),OmRPA(:,ispin),OmBSE(:,ispin), & + XpY_BSE(:,:,ispin),XmY_BSE(:,:,ispin),rho_RPA(:,:,:,ispin)) + else + + call Bethe_Salpeter_dynamic_perturbation(TDA,eta,nBas,nC,nO,nV,nR,nS,eGW(:),OmRPA(:,ispin),OmBSE(:,ispin), & + XpY_BSE(:,:,ispin),XmY_BSE(:,:,ispin),rho_RPA(:,:,:,ispin)) + end if end if diff --git a/src/QuAcK/Bethe_Salpeter_ZB_matrix_dynamic.f90 b/src/QuAcK/Bethe_Salpeter_ZB_matrix_dynamic.f90 index ea55726..a337b5e 100644 --- a/src/QuAcK/Bethe_Salpeter_ZB_matrix_dynamic.f90 +++ b/src/QuAcK/Bethe_Salpeter_ZB_matrix_dynamic.f90 @@ -48,12 +48,12 @@ subroutine Bethe_Salpeter_ZB_matrix_dynamic(eta,nBas,nC,nO,nV,nR,nS,lambda,eGW,O chi = 0d0 do kc=1,maxS - eps = (OmBSE - OmRPA(kc) - (eGW(a) - eGW(b)))**2 + eta**2 - chi = chi + rho(i,b,kc)*rho(a,j,kc)*((OmBSE - OmRPA(kc) - (eGW(a) - eGW(b)))/eps)**2 - eps = (OmBSE - OmRPA(kc) - (eGW(j) - eGW(i)))**2 + eta**2 chi = chi + rho(i,b,kc)*rho(a,j,kc)*((OmBSE - OmRPA(kc) - (eGW(j) - eGW(i)))/eps)**2 + eps = (OmBSE - OmRPA(kc) - (eGW(a) - eGW(b)))**2 + eta**2 + chi = chi + rho(i,b,kc)*rho(a,j,kc)*((OmBSE - OmRPA(kc) - (eGW(a) - eGW(b)))/eps)**2 + enddo ZB_dyn(ia,jb) = ZB_dyn(ia,jb) + 2d0*lambda*chi diff --git a/src/QuAcK/Bethe_Salpeter_dynamic_perturbation.f90 b/src/QuAcK/Bethe_Salpeter_dynamic_perturbation.f90 index 7256039..b8b396a 100644 --- a/src/QuAcK/Bethe_Salpeter_dynamic_perturbation.f90 +++ b/src/QuAcK/Bethe_Salpeter_dynamic_perturbation.f90 @@ -25,7 +25,7 @@ subroutine Bethe_Salpeter_dynamic_perturbation(TDA,eta,nBas,nC,nO,nV,nR,nS,eGW,O ! Local variables - logical :: TDA_dyn = .false. + logical :: TDA_dyn = .true. integer :: ia integer,parameter :: maxS = 10 double precision :: gapGW diff --git a/src/QuAcK/Bethe_Salpeter_dynamic_perturbation_iterative.f90 b/src/QuAcK/Bethe_Salpeter_dynamic_perturbation_iterative.f90 new file mode 100644 index 0000000..35777c1 --- /dev/null +++ b/src/QuAcK/Bethe_Salpeter_dynamic_perturbation_iterative.f90 @@ -0,0 +1,133 @@ +subroutine Bethe_Salpeter_dynamic_perturbation_iterative(TDA,eta,nBas,nC,nO,nV,nR,nS,eGW,OmRPA,OmBSE,XpY,XmY,rho) + +! Compute self-consistently the dynamical effects via perturbation theory for BSE + + implicit none + include 'parameters.h' + +! Input variables + + logical,intent(in) :: TDA + double precision,intent(in) :: eta + integer,intent(in) :: nBas + integer,intent(in) :: nC + integer,intent(in) :: nO + integer,intent(in) :: nV + integer,intent(in) :: nR + integer,intent(in) :: nS + + double precision,intent(in) :: eGW(nBas) + double precision,intent(in) :: OmRPA(nS) + double precision,intent(in) :: OmBSE(nS) + double precision,intent(in) :: XpY(nS,nS) + double precision,intent(in) :: XmY(nS,nS) + double precision,intent(in) :: rho(nBas,nBas,nS) + +! Local variables + + logical :: TDA_dyn = .true. + integer :: ia + integer,parameter :: maxS = 10 + double precision :: gapGW + + integer :: nSCF + integer :: maxSCF = 10 + double precision :: Conv + double precision :: thresh = 1d-5 + + + double precision,allocatable :: OmDyn(:) + double precision,allocatable :: OmOld(:) + double precision,allocatable :: X(:) + double precision,allocatable :: Y(:) + double precision,allocatable :: A_dyn(:,:) + double precision,allocatable :: B_dyn(:,:) + double precision,allocatable :: ZA_dyn(:,:) + double precision,allocatable :: ZB_dyn(:,:) + +! Memory allocation + + allocate(OmDyn(nS),OmOld(nS),X(nS),Y(nS),A_dyn(nS,nS)) + + if(.not.TDA_dyn) allocate(B_dyn(nS,nS)) + + gapGW = eGW(nO+1) - eGW(nO) + + Conv = 1d0 + nSCF = 0 + OmOld(:) = OmBSE(:) + + write(*,*) '---------------------------------------------------------------------------------------------------' + write(*,*) ' First-order dynamical correction to static Bethe-Salpeter excitation energies ' + write(*,*) '---------------------------------------------------------------------------------------------------' + write(*,*) + + do while(Conv > thresh .and. nSCF < maxSCF) + + nSCF = nSCF + 1 + + write(*,*) '---------------------------------------------------------------------------------------------------' + write(*,'(2X,A15,I3)') 'Iteration n.',nSCF + write(*,*) '---------------------------------------------------------------------------------------------------' + write(*,'(2X,A5,1X,A20,1X,A20,1X,A20)') '#','Static (eV)','Dynamic (eV)','Correction (eV)' + write(*,*) '---------------------------------------------------------------------------------------------------' + + do ia=1,min(nS,maxS) + + + X(:) = 0.5d0*(XpY(ia,:) + XmY(ia,:)) + Y(:) = 0.5d0*(XpY(ia,:) - XmY(ia,:)) + + ! Resonant part of the BSE correction + + call Bethe_Salpeter_A_matrix_dynamic(eta,nBas,nC,nO,nV,nR,nS,1d0,eGW(:),OmRPA(:),OmOld(ia),rho(:,:,:),A_dyn(:,:)) + + ! First-order correction + + if(TDA_dyn) then + + OmDyn(ia) = dot_product(X(:),matmul(A_dyn(:,:),X(:))) + + else + + ! Anti-resonant part of the BSE correction + + call Bethe_Salpeter_B_matrix_dynamic(eta,nBas,nC,nO,nV,nR,nS,1d0,eGW(:),OmRPA(:),OmOld(ia),rho(:,:,:),B_dyn(:,:)) + + OmDyn(ia) = dot_product(X(:),matmul(A_dyn(:,:),X(:))) & + - dot_product(Y(:),matmul(A_dyn(:,:),Y(:))) & + + dot_product(X(:),matmul(B_dyn(:,:),Y(:))) & + - dot_product(Y(:),matmul(B_dyn(:,:),X(:))) + + end if + + write(*,'(2X,I5,5X,F15.6,5X,F15.6,5X,F15.6)') & + ia,OmBSE(ia)*HaToeV,(OmBSE(ia)+OmDyn(ia))*HaToeV,OmDyn(ia)*HaToeV + + if(OmBSE(ia) > gapGW) write(*,*) ' !!! BSE neutral excitation larger than the GW gap !!! ' + + end do + + Conv = maxval(abs(OmBSE(:) + OmDyn(:) - OmOld(:))) + OmOld(:) = OmBSE(:) + OmDyn(:) + + write(*,*) '---------------------------------------------------------------------------------------------------' + write(*,'(2X,A20,1X,F10.6)') ' Convergence = ',Conv + write(*,*) '---------------------------------------------------------------------------------------------------' + write(*,*) + + end do + +! Did it actually converge? + + if(nSCF == maxSCF) then + + write(*,*) + write(*,*)'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' + write(*,*)' Convergence failed ' + write(*,*)'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' + write(*,*) + + endif + +end subroutine Bethe_Salpeter_dynamic_perturbation_iterative diff --git a/src/QuAcK/orthogonalization_matrix.f90 b/src/QuAcK/orthogonalization_matrix.f90 index 84b7f00..e60f253 100644 --- a/src/QuAcK/orthogonalization_matrix.f90 +++ b/src/QuAcK/orthogonalization_matrix.f90 @@ -13,7 +13,7 @@ subroutine orthogonalization_matrix(ortho_type,nBas,S,X) logical :: debug double precision,allocatable :: UVec(:,:),Uval(:) - double precision,parameter :: thresh = 1d-6 + double precision,parameter :: thresh = 1d-8 integer :: i @@ -43,16 +43,14 @@ subroutine orthogonalization_matrix(ortho_type,nBas,S,X) do i=1,nBas - if(Uval(i) > thresh) then + if(Uval(i) < thresh) then - Uval(i) = 1d0/sqrt(Uval(i)) - - else - - write(*,*) 'Eigenvalue',i,'too small for Lowdin orthogonalization' + write(*,*) 'Eigenvalue',i,'is very small in Lowdin orthogonalization = ',Uval(i) endif + Uval(i) = 1d0/sqrt(Uval(i)) + enddo call ADAt(nBas,Uvec,Uval,X) diff --git a/src/utils/read_molecule.f90 b/src/utils/read_molecule.f90 index 5d8886e..3d29227 100644 --- a/src/utils/read_molecule.f90 +++ b/src/utils/read_molecule.f90 @@ -37,7 +37,7 @@ subroutine read_molecule(nNuc,nEl,nO,nC,nR) nO(:) = nEl(:) nC(:) = nCore/2 - nR(:) = nRyd/2 + nR(:) = nRyd ! Print results