From 388db3ca6edaba3271e9a6ec6de5e637ff7dd3f0 Mon Sep 17 00:00:00 2001 From: Pierre-Francois Loos Date: Mon, 8 Nov 2021 09:55:39 +0100 Subject: [PATCH] HF individual energy working --- input/dft | 8 ++-- input/methods | 10 ++--- input/options | 2 +- mol/h2.xyz | 2 +- ...stricted_correlation_individual_energy.f90 | 2 +- ...nrestricted_exchange_individual_energy.f90 | 22 ++-------- ...ricted_fock_exchange_individual_energy.f90 | 9 ++-- ...d_hybrid_correlation_individual_energy.f90 | 39 ++++++++++++++++ ...cted_hybrid_exchange_individual_energy.f90 | 44 +++++++++++++++++++ 9 files changed, 104 insertions(+), 34 deletions(-) create mode 100644 src/eDFT/unrestricted_hybrid_correlation_individual_energy.f90 create mode 100644 src/eDFT/unrestricted_hybrid_exchange_individual_energy.f90 diff --git a/input/dft b/input/dft index 415fecc..9419b4c 100644 --- a/input/dft +++ b/input/dft @@ -6,14 +6,14 @@ # GGA = 2: B88,G96,PBE # MGGA = 3: # Hybrid = 4: HF,B3LYP,PBE - 1 S51 + 4 HF # correlation rung: # Hartree = 0: H # LDA = 1: PW92,VWN3,VWN5,eVWN5 # GGA = 2: LYP,PBE # MGGA = 3: # Hybrid = 4: HF,B3LYP,PBE - 1 VWN5 + 4 HF # quadrature grid SG-n 0 # Number of states in ensemble (nEns) @@ -28,10 +28,10 @@ 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # Ensemble weights: wEns(1),...,wEns(nEns-1) - 1.00 0.00 0.00 + 0.00 0.00 1.00 # N-centered? F # Parameters for CC weight-dependent exchange functional diff --git a/input/methods b/input/methods index 67ab225..4879570 100644 --- a/input/methods +++ b/input/methods @@ -1,9 +1,9 @@ # RHF UHF KS MOM - T F F F + F F T F # MP2* MP3 MP2-F12 F F F # CCD DCD CCSD CCSD(T) - F F T F + F F F F # drCCD rCCD lCCD pCCD F F F F # CIS* CIS(D) CID CISD FCI @@ -11,11 +11,11 @@ # RPA* RPAx* ppRPA F F F # G0F2* evGF2* qsGF2* G0F3 evGF3 - T F F F F + F F F F F # G0W0* evGW* qsGW* ufG0W0 ufGW - T F F F F + F F F F F # G0T0 evGT qsGT - T F F + F F F # MCMP2 F # * unrestricted version available diff --git a/input/options b/input/options index a4093ba..88c4acd 100644 --- a/input/options +++ b/input/options @@ -5,7 +5,7 @@ # CC: maxSCF thresh DIIS n_diis 64 0.0000000001 T 5 # spin: TDA singlet triplet spin_conserved spin_flip - F T T T T + F T F T T # GF: maxSCF thresh DIIS n_diis lin eta renorm 256 0.00001 T 5 T 0.00367493 3 # GW/GT: maxSCF thresh DIIS n_diis lin eta COHSEX SOSEX TDA_W G0W GW0 diff --git a/mol/h2.xyz b/mol/h2.xyz index 6b9263f..73b19fa 100644 --- a/mol/h2.xyz +++ b/mol/h2.xyz @@ -1,4 +1,4 @@ 2 H 0. 0. 0. -H 0. 0. 0.740848 +H 0. -0.740848 0.740848 diff --git a/src/eDFT/unrestricted_correlation_individual_energy.f90 b/src/eDFT/unrestricted_correlation_individual_energy.f90 index 5c8210d..4bcc8af 100644 --- a/src/eDFT/unrestricted_correlation_individual_energy.f90 +++ b/src/eDFT/unrestricted_correlation_individual_energy.f90 @@ -62,7 +62,7 @@ subroutine unrestricted_correlation_individual_energy(rung,DFA,LDA_centered,nEns case(4) - call print_warning('!!! Individual energies NYI for hybrids !!!') + call unrestricted_hybrid_correlation_individual_energy(DFA,nEns,wEns,nGrid,weight,rhow,drhow,rho,drho,Ec) end select diff --git a/src/eDFT/unrestricted_exchange_individual_energy.f90 b/src/eDFT/unrestricted_exchange_individual_energy.f90 index e4178dc..d4f0452 100644 --- a/src/eDFT/unrestricted_exchange_individual_energy.f90 +++ b/src/eDFT/unrestricted_exchange_individual_energy.f90 @@ -29,13 +29,6 @@ subroutine unrestricted_exchange_individual_energy(rung,DFA,LDA_centered,nEns,wE logical,intent(in) :: doNcentered double precision,intent(in) :: kappa -! Local variables - - double precision :: ExLDA - double precision :: ExGGA - double precision :: ExMGGA - double precision :: ExHF - ! Output variables double precision,intent(out) :: Ex @@ -53,32 +46,25 @@ subroutine unrestricted_exchange_individual_energy(rung,DFA,LDA_centered,nEns,wE case(1) call unrestricted_lda_exchange_individual_energy(DFA,LDA_centered,nEns,wEns,aCC_w1,aCC_w2,nGrid,weight,& - rhow,rho,Cx_choice,doNcentered,kappa,ExLDA) - - Ex = ExLDA + rhow,rho,Cx_choice,doNcentered,kappa,Ex) ! GGA functionals case(2) - call unrestricted_gga_exchange_individual_energy(DFA,nEns,wEns,nGrid,weight,rhow,drhow,rho,drho,ExGGA) - - Ex = ExGGA + call unrestricted_gga_exchange_individual_energy(DFA,nEns,wEns,nGrid,weight,rhow,drhow,rho,drho,Ex) ! MGGA functionals case(3) - call unrestricted_mgga_exchange_individual_energy(DFA,nEns,wEns,nGrid,weight,rhow,drhow,rho,drho,ExMGGA) - - Ex = ExMGGA + call unrestricted_mgga_exchange_individual_energy(DFA,nEns,wEns,nGrid,weight,rhow,drhow,rho,drho,Ex) ! Hybrid functionals case(4) -! call unrestricted_hybrid_exchange_individual_energy(DFA,nEns,wEns,nGrid,weight,nBas,P,FxHF,rho,drho,Ex) - call print_warning('!!! Individual energies NYI for Hybrids !!!') + call unrestricted_hybrid_exchange_individual_energy(DFA,nEns,wEns,nGrid,weight,nBas,ERI,Pw,P,rhow,drhow,rho,drho,Ex) end select diff --git a/src/eDFT/unrestricted_fock_exchange_individual_energy.f90 b/src/eDFT/unrestricted_fock_exchange_individual_energy.f90 index a91a587..bec1c8a 100644 --- a/src/eDFT/unrestricted_fock_exchange_individual_energy.f90 +++ b/src/eDFT/unrestricted_fock_exchange_individual_energy.f90 @@ -1,6 +1,6 @@ subroutine unrestricted_fock_exchange_individual_energy(nBas,Pw,P,ERI,Ex) -! Compute the Fock exchange potential +! Compute the HF individual energy in the unrestricted formalism implicit none @@ -24,8 +24,9 @@ subroutine unrestricted_fock_exchange_individual_energy(nBas,Pw,P,ERI,Ex) allocate(Fx(nBas,nBas)) - call unrestricted_fock_exchange_potential(nBas,Pw(:,:),ERI(:,:,:,:),Fx(:,:)) - Ex = trace_matrix(nBas,matmul(P(:,:),Fx(:,:))) & - - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:),Fx(:,:))) + call unrestricted_fock_exchange_potential(nBas,Pw,ERI,Fx) + + Ex = trace_matrix(nBas,matmul(P ,Fx)) & + - 0.5d0*trace_matrix(nBas,matmul(Pw,Fx)) end subroutine unrestricted_fock_exchange_individual_energy diff --git a/src/eDFT/unrestricted_hybrid_correlation_individual_energy.f90 b/src/eDFT/unrestricted_hybrid_correlation_individual_energy.f90 new file mode 100644 index 0000000..13de347 --- /dev/null +++ b/src/eDFT/unrestricted_hybrid_correlation_individual_energy.f90 @@ -0,0 +1,39 @@ +subroutine unrestricted_hybrid_correlation_individual_energy(DFA,nEns,wEns,nGrid,weight,rhow,drhow,rho,drho,Ec) + +! Compute the hybrid correlation energy for individual states + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: DFA + integer,intent(in) :: nEns + double precision,intent(in) :: wEns(nEns) + integer,intent(in) :: nGrid + double precision,intent(in) :: weight(nGrid) + double precision,intent(in) :: rhow(nGrid) + double precision,intent(in) :: drhow(ncart,nGrid) + double precision,intent(in) :: rho(nGrid) + double precision,intent(in) :: drho(ncart,nGrid) + +! Output variables + + double precision :: Ec(nsp) + +! Select correlation functional + + select case (DFA) + + case (1) + + Ec(:) = 0d0 + + case default + + call print_warning('!!! Hybrid correlation individual energy not available !!!') + stop + + end select + +end subroutine unrestricted_hybrid_correlation_individual_energy diff --git a/src/eDFT/unrestricted_hybrid_exchange_individual_energy.f90 b/src/eDFT/unrestricted_hybrid_exchange_individual_energy.f90 new file mode 100644 index 0000000..d542993 --- /dev/null +++ b/src/eDFT/unrestricted_hybrid_exchange_individual_energy.f90 @@ -0,0 +1,44 @@ +subroutine unrestricted_hybrid_exchange_individual_energy(DFA,nEns,wEns,nGrid,weight,nBas,ERI,Pw,P,rhow,drhow,rho,drho,Ex) + +! Compute the hybrid exchange energy for individual states + + implicit none + include 'parameters.h' + +! Input variables + + integer,intent(in) :: DFA + integer,intent(in) :: nEns + double precision,intent(in) :: wEns(nEns) + integer,intent(in) :: nGrid + double precision,intent(in) :: weight(nGrid) + double precision,intent(in) :: rhow(nGrid) + double precision,intent(in) :: drhow(ncart,nGrid) + double precision,intent(in) :: rho(nGrid) + double precision,intent(in) :: drho(ncart,nGrid) + + integer,intent(in) :: nBas + double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas) + double precision,intent(in) :: Pw(nBas,nBas) + double precision,intent(in) :: P(nBas,nBas) + +! Output variables + + double precision :: Ex + +! Select correlation functional + + select case (DFA) + + case (1) + + call unrestricted_fock_exchange_individual_energy(nBas,Pw,P,ERI,Ex) + + case default + + call print_warning('!!! Hybrid exchange individual energy not available !!!') + stop + + end select + +end subroutine unrestricted_hybrid_exchange_individual_energy