10
1
mirror of https://github.com/pfloos/quack synced 2024-11-04 05:03:49 +01:00

looking for bug

This commit is contained in:
Pierre-Francois Loos 2021-11-30 13:43:37 +01:00
parent f1bb7b3d86
commit 1b6e7e9e0f
6 changed files with 183 additions and 160 deletions

View File

@ -22,8 +22,8 @@
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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

View File

@ -247,7 +247,11 @@ subroutine eDFT_UKS(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns,nCC,aCC,nGrid,weight,max
end if end if
! Build Coulomb repulsion !------------------------------------------------------------------------
! Compute Hxc potential and Fock operator
!------------------------------------------------------------------------
! Compute Hartree potential
do ispin=1,nspin do ispin=1,nspin
call unrestricted_hartree_potential(nBas,Pw(:,:,ispin),ERI(:,:,:,:),J(:,:,ispin)) call unrestricted_hartree_potential(nBas,Pw(:,:,ispin),ERI(:,:,:,:),J(:,:,ispin))
@ -266,6 +270,7 @@ subroutine eDFT_UKS(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns,nCC,aCC,nGrid,weight,max
call unrestricted_correlation_potential(c_rung,c_DFA,nEns,wEns,nGrid,weight,nBas,AO,dAO,rhow,drhow,Fc) call unrestricted_correlation_potential(c_rung,c_DFA,nEns,wEns,nGrid,weight,nBas,AO,dAO,rhow,drhow,Fc)
! Build Fock operator ! Build Fock operator
do ispin=1,nspin do ispin=1,nspin
F(:,:,ispin) = Hc(:,:) + J(:,:,ispin) + J(:,:,mod(ispin,2)+1) + Fx(:,:,ispin) + Fc(:,:,ispin) F(:,:,ispin) = Hc(:,:) + J(:,:,ispin) + J(:,:,mod(ispin,2)+1) + Fx(:,:,ispin) + Fc(:,:,ispin)
end do end do
@ -325,7 +330,7 @@ subroutine eDFT_UKS(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns,nCC,aCC,nGrid,weight,max
EV(ispin) = trace_matrix(nBas,matmul(Pw(:,:,ispin),V(:,:))) EV(ispin) = trace_matrix(nBas,matmul(Pw(:,:,ispin),V(:,:)))
end do end do
! Coulomb energy ! Hartree energy
call unrestricted_hartree_energy(nBas,Pw,J,EH) call unrestricted_hartree_energy(nBas,Pw,J,EH)
@ -333,8 +338,8 @@ subroutine eDFT_UKS(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns,nCC,aCC,nGrid,weight,max
do ispin=1,nspin do ispin=1,nspin
call unrestricted_exchange_energy(x_rung,x_DFA,LDA_centered,nEns,wEns,nCC,aCC,nGrid,weight,nBas, & call unrestricted_exchange_energy(x_rung,x_DFA,LDA_centered,nEns,wEns,nCC,aCC,nGrid,weight,nBas, &
Pw(:,:,ispin),FxHF(:,:,ispin),rhow(:,ispin),drhow(:,:,ispin),Ex(ispin)& Pw(:,:,ispin),FxHF(:,:,ispin),rhow(:,ispin),drhow(:,:,ispin),Ex(ispin), &
,Cx_choice,doNcentered) Cx_choice,doNcentered)
end do end do
! Correlation energy ! Correlation energy
@ -358,6 +363,7 @@ subroutine eDFT_UKS(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns,nCC,aCC,nGrid,weight,max
end do end do
write(*,*)'------------------------------------------------------------------------------------------' write(*,*)'------------------------------------------------------------------------------------------'
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! End of SCF loop ! End of SCF loop
!------------------------------------------------------------------------ !------------------------------------------------------------------------

View File

@ -1,5 +1,5 @@
subroutine print_unrestricted_individual_energy(nEns,ENuc,Ew,ET,EV,EJ,Ex,Ec,Exc,Eaux,ExDD,EcDD,ExcDD,E, & subroutine print_unrestricted_individual_energy(nEns,ENuc,Ew,ET,EV,EH,Ex,Ec,Eaux,ExDD,EcDD,E, &
Om,Omx,Omc,Omxc,Omaux,OmxDD,OmcDD,OmxcDD) Om,Omx,Omc,Omaux,OmxDD,OmcDD)
! Print individual energies for eDFT calculation ! Print individual energies for eDFT calculation
@ -13,14 +13,19 @@ subroutine print_unrestricted_individual_energy(nEns,ENuc,Ew,ET,EV,EJ,Ex,Ec,Exc,
double precision,intent(in) :: Ew double precision,intent(in) :: Ew
double precision,intent(in) :: ET(nspin,nEns) double precision,intent(in) :: ET(nspin,nEns)
double precision,intent(in) :: EV(nspin,nEns) double precision,intent(in) :: EV(nspin,nEns)
double precision,intent(in) :: EJ(nsp,nEns) double precision,intent(in) :: EH(nsp,nEns)
double precision,intent(in) :: Ex(nspin,nEns), Ec(nsp,nEns), Exc(nEns) double precision,intent(in) :: Ex(nspin,nEns)
double precision,intent(in) :: Ec(nsp,nEns)
double precision,intent(in) :: Eaux(nspin,nEns) double precision,intent(in) :: Eaux(nspin,nEns)
double precision,intent(in) :: ExDD(nspin,nEns), EcDD(nsp,nEns), ExcDD(nsp,nEns) double precision,intent(in) :: ExDD(nspin,nEns)
double precision,intent(in) :: Omx(nEns), Omc(nEns), Omxc(nEns) double precision,intent(in) :: EcDD(nsp,nEns)
double precision,intent(in) :: Omaux(nEns)
double precision,intent(in) :: OmxDD(nEns),OmcDD(nEns),OmxcDD(nEns)
double precision,intent(in) :: E(nEns) double precision,intent(in) :: E(nEns)
double precision,intent(in) :: Omx(nEns)
double precision,intent(in) :: Omc(nEns)
double precision,intent(in) :: Omaux(nEns)
double precision,intent(in) :: OmxDD(nEns)
double precision,intent(in) :: OmcDD(nEns)
double precision,intent(in) :: Om(nEns) double precision,intent(in) :: Om(nEns)
! Local variables ! Local variables
@ -55,66 +60,66 @@ subroutine print_unrestricted_individual_energy(nEns,ENuc,Ew,ET,EV,EJ,Ex,Ec,Exc,
! Kinetic energy ! Kinetic energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,'(A60)') ' INDIVIDUAL KINETIC ENERGIES' write(*,'(A60)') ' INDIVIDUAL KINETIC ENERGIES'
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! do iEns=1,nEns do iEns=1,nEns
! write(*,'(A40,I2,A2,F16.10,A3)') ' Kinetic energy state ',iEns,': ',sum(ET(:,iEns)),' au' write(*,'(A40,I2,A2,F16.10,A3)') ' Kinetic energy state ',iEns,': ',sum(ET(:,iEns)),' au'
! end do end do
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,*) write(*,*)
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Potential energy ! Potential energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,'(A60)') ' INDIVIDUAL POTENTIAL ENERGIES' write(*,'(A60)') ' INDIVIDUAL POTENTIAL ENERGIES'
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! do iEns=1,nEns do iEns=1,nEns
! write(*,'(A40,I2,A2,F16.10,A3)') ' Potential energy state ',iEns,': ',sum(EV(:,iEns)),' au' write(*,'(A40,I2,A2,F16.10,A3)') ' Potential energy state ',iEns,': ',sum(EV(:,iEns)),' au'
! end do end do
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,*) write(*,*)
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Hartree energy ! Hartree energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,'(A60)') ' INDIVIDUAL HARTREE ENERGIES' write(*,'(A60)') ' INDIVIDUAL HARTREE ENERGIES'
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! do iEns=1,nEns do iEns=1,nEns
! write(*,'(A40,I2,A2,F16.10,A3)') ' Hartree energy state ',iEns,': ',sum(EJ(:,iEns)),' au' write(*,'(A40,I2,A2,F16.10,A3)') ' Hartree energy state ',iEns,': ',sum(EH(:,iEns)),' au'
! end do end do
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,*) write(*,*)
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Exchange energy ! Exchange energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,'(A60)') ' INDIVIDUAL EXCHANGE ENERGIES' write(*,'(A60)') ' INDIVIDUAL EXCHANGE ENERGIES'
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! do iEns=1,nEns do iEns=1,nEns
! write(*,'(A40,I2,A2,F16.10,A3)') ' Exchange energy state ',iEns,': ',sum(Ex(:,iEns)),' au' write(*,'(A40,I2,A2,F16.10,A3)') ' Exchange energy state ',iEns,': ',sum(Ex(:,iEns)),' au'
! end do end do
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,*) write(*,*)
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Correlation energy ! Correlation energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,'(A60)') ' INDIVIDUAL CORRELATION ENERGIES' write(*,'(A60)') ' INDIVIDUAL CORRELATION ENERGIES'
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! do iEns=1,nEns do iEns=1,nEns
! write(*,'(A40,I2,A2,F16.10,A3)') ' Correlation energy state ',iEns,': ',sum(Ec(:,iEns)),' au' write(*,'(A40,I2,A2,F16.10,A3)') ' Correlation energy state ',iEns,': ',sum(Ec(:,iEns)),' au'
! end do end do
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! write(*,*) write(*,*)
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Auxiliary energies ! Auxiliary energies
@ -140,7 +145,7 @@ subroutine print_unrestricted_individual_energy(nEns,ENuc,Ew,ET,EV,EJ,Ex,Ec,Exc,
write(*,*) write(*,*)
write(*,'(A40,I2,A2,F16.10,A3)') ' x ensemble derivative state ',iEns,': ',sum(ExDD(:,iEns)), ' au' write(*,'(A40,I2,A2,F16.10,A3)') ' x ensemble derivative state ',iEns,': ',sum(ExDD(:,iEns)), ' au'
write(*,'(A40,I2,A2,F16.10,A3)') ' c ensemble derivative state ',iEns,': ',sum(EcDD(:,iEns)), ' au' write(*,'(A40,I2,A2,F16.10,A3)') ' c ensemble derivative state ',iEns,': ',sum(EcDD(:,iEns)), ' au'
write(*,'(A40,I2,A2,F16.10,A3)') ' xc ensemble derivative state ',iEns,': ',sum(ExcDD(:,iEns)),' au' write(*,'(A40,I2,A2,F16.10,A3)') ' xc ensemble derivative state ',iEns,': ',sum(ExDD(:,iEns))+sum(EcDD(:,iEns)),' au'
end do end do
write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
write(*,*) write(*,*)
@ -154,22 +159,22 @@ subroutine print_unrestricted_individual_energy(nEns,ENuc,Ew,ET,EV,EJ,Ex,Ec,Exc,
write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
do iEns=2,nEns do iEns=2,nEns
write(*,'(A40,I2,A1,F16.10,A3)') ' Energy difference 1 -> ',iEns,':',Omaux(iEns)+OmxcDD(iEns),' au' write(*,'(A40,I2,A1,F16.10,A3)') ' Energy difference 1 -> ',iEns,':',Omaux(iEns)+OmxDD(iEns)+OmcDD(iEns),' au'
write(*,*) write(*,*)
write(*,'(A44, F16.10,A3)') ' auxiliary energy contribution : ',Omaux(iEns), ' au' write(*,'(A44, F16.10,A3)') ' auxiliary energy contribution : ',Omaux(iEns), ' au'
write(*,'(A44, F16.10,A3)') ' x ensemble derivative : ',OmxDD(iEns), ' au' write(*,'(A44, F16.10,A3)') ' x ensemble derivative : ',OmxDD(iEns), ' au'
write(*,'(A44, F16.10,A3)') ' c ensemble derivative : ',OmcDD(iEns), ' au' write(*,'(A44, F16.10,A3)') ' c ensemble derivative : ',OmcDD(iEns), ' au'
write(*,'(A44, F16.10,A3)') ' xc ensemble derivative : ',OmxcDD(iEns),' au' write(*,'(A44, F16.10,A3)') ' xc ensemble derivative : ',OmxDD(iEns)+OmcDD(iEns), ' au'
write(*,*) write(*,*)
write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,I2,A1,F16.10,A3)') ' Energy difference 1 -> ',iEns,':',(Omaux(iEns)+OmxcDD(iEns))*HaToeV,' eV' write(*,'(A40,I2,A1,F16.10,A3)') ' Energy difference 1 -> ',iEns,':',(Omaux(iEns)+OmxDD(iEns)+OmcDD(iEns))*HaToeV,' eV'
write(*,*) write(*,*)
write(*,'(A44, F16.10,A3)') ' auxiliary energy contribution : ',Omaux(iEns)*HaToeV, ' eV' write(*,'(A44, F16.10,A3)') ' auxiliary energy contribution : ',Omaux(iEns)*HaToeV, ' eV'
write(*,'(A44, F16.10,A3)') ' x ensemble derivative : ',OmxDD(iEns)*HaToeV, ' eV' write(*,'(A44, F16.10,A3)') ' x ensemble derivative : ',OmxDD(iEns)*HaToeV, ' eV'
write(*,'(A44, F16.10,A3)') ' c ensemble derivative : ',OmcDD(iEns)*HaToeV, ' eV' write(*,'(A44, F16.10,A3)') ' c ensemble derivative : ',OmcDD(iEns)*HaToeV, ' eV'
write(*,'(A44, F16.10,A3)') ' xc ensemble derivative : ',OmxcDD(iEns)*HaToeV,' eV' write(*,'(A44, F16.10,A3)') ' xc ensemble derivative : ',(OmxDD(iEns)+OmcDD(iEns))*HaToeV,' eV'
write(*,*) write(*,*)
end do end do
@ -179,34 +184,34 @@ subroutine print_unrestricted_individual_energy(nEns,ENuc,Ew,ET,EV,EJ,Ex,Ec,Exc,
write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
write(*,'(A60)') ' ENERGY DIFFERENCES FROM INDIVIDUAL ENERGIES ' write(*,'(A60)') ' ENERGY DIFFERENCES FROM INDIVIDUAL ENERGIES '
write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
! do iEns=1,nEns do iEns=1,nEns
! write(*,'(A40,I2,A2,F16.10,A3)') ' Individual energy state ',iEns,': ',E(iEns) + ENuc,' au' write(*,'(A40,I2,A2,F16.10,A3)') ' Individual energy state ',iEns,': ',E(iEns) + ENuc,' au'
! end do end do
! write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
do iEns=2,nEns do iEns=2,nEns
write(*,'(A40,I2,A1,F16.10,A3)') ' Energy difference 1 -> ',iEns,':',Om(iEns), ' au' write(*,'(A40,I2,A1,F16.10,A3)') ' Energy difference 1 -> ',iEns,':',Om(iEns), ' au'
write(*,*) write(*,*)
! write(*,'(A44, F16.10,A3)') ' x energy contribution : ',Omx(iEns), ' au' write(*,'(A44, F16.10,A3)') ' x energy contribution : ',Omx(iEns), ' au'
! write(*,'(A44, F16.10,A3)') ' c energy contribution : ',Omc(iEns), ' au' write(*,'(A44, F16.10,A3)') ' c energy contribution : ',Omc(iEns), ' au'
! write(*,'(A44, F16.10,A3)') ' xc energy contribution : ',Omxc(iEns), ' au' write(*,'(A44, F16.10,A3)') ' xc energy contribution : ',Omx(iEns)+Omc(iEns), ' au'
! write(*,*) write(*,*)
write(*,'(A44, F16.10,A3)') ' x ensemble derivative : ',OmxDD(iEns), ' au' write(*,'(A44, F16.10,A3)') ' x ensemble derivative : ',OmxDD(iEns), ' au'
write(*,'(A44, F16.10,A3)') ' c ensemble derivative : ',OmcDD(iEns), ' au' write(*,'(A44, F16.10,A3)') ' c ensemble derivative : ',OmcDD(iEns), ' au'
write(*,'(A44, F16.10,A3)') ' xc ensemble derivative : ',OmxcDD(iENs),' au' write(*,'(A44, F16.10,A3)') ' xc ensemble derivative : ',OmxDD(iEns)+OmcDD(iEns),' au'
write(*,*) write(*,*)
write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,I2,A1,F16.10,A3)') ' Energy difference 1 -> ',iEns,':',Om(iEns)*HaToeV, ' eV' write(*,'(A40,I2,A1,F16.10,A3)') ' Energy difference 1 -> ',iEns,':',Om(iEns)*HaToeV, ' eV'
write(*,*) write(*,*)
! write(*,'(A44, F16.10,A3)') ' x energy contribution : ',Omx(iEns)*HaToeV, ' eV' write(*,'(A44, F16.10,A3)') ' x energy contribution : ',Omx(iEns)*HaToeV, ' eV'
! write(*,'(A44, F16.10,A3)') ' c energy contribution : ',Omc(iEns)*HaToeV, ' eV' write(*,'(A44, F16.10,A3)') ' c energy contribution : ',Omc(iEns)*HaToeV, ' eV'
! write(*,'(A44, F16.10,A3)') ' xc energy contribution : ',Omxc(iEns)*HaToeV, ' eV' write(*,'(A44, F16.10,A3)') ' xc energy contribution : ',(Omx(iEns)+Omc(iEns))*HaToeV, ' eV'
! write(*,*) write(*,*)
write(*,'(A44, F16.10,A3)') ' x ensemble derivative : ',OmxDD(iEns)*HaToeV, ' eV' write(*,'(A44, F16.10,A3)') ' x ensemble derivative : ',OmxDD(iEns)*HaToeV, ' eV'
write(*,'(A44, F16.10,A3)') ' c ensemble derivative : ',OmcDD(iEns)*HaToeV, ' eV' write(*,'(A44, F16.10,A3)') ' c ensemble derivative : ',OmcDD(iEns)*HaToeV, ' eV'
write(*,'(A44, F16.10,A3)') ' xc ensemble derivative : ',OmxcDD(iEns)*HaToeV,' eV' write(*,'(A44, F16.10,A3)') ' xc ensemble derivative : ',(OmxDD(iEns)+OmcDD(iEns))*HaToeV,' eV'
write(*,*) write(*,*)
end do end do
write(*,'(A60)') '-------------------------------------------------' write(*,'(A60)') '-------------------------------------------------'

View File

@ -19,8 +19,6 @@ subroutine unrestricted_correlation_derivative_discontinuity(rung,DFA,nEns,wEns,
! Local variables ! Local variables
double precision :: aC
! Output variables ! Output variables
double precision,intent(out) :: Ec(nsp,nEns) double precision,intent(out) :: Ec(nsp,nEns)

View File

@ -16,8 +16,6 @@ subroutine unrestricted_hybrid_correlation_derivative_discontinuity(DFA,nEns,wEn
! Local variables ! Local variables
double precision :: aC
! Output variables ! Output variables
double precision,intent(out) :: Ec(nsp,nEns) double precision,intent(out) :: Ec(nsp,nEns)

View File

@ -36,10 +36,10 @@ subroutine unrestricted_individual_energy(x_rung,x_DFA,c_rung,c_DFA,LDA_centered
double precision,intent(in) :: rho(nGrid,nspin,nEns) double precision,intent(in) :: rho(nGrid,nspin,nEns)
double precision,intent(in) :: drho(ncart,nGrid,nspin,nEns) double precision,intent(in) :: drho(ncart,nGrid,nspin,nEns)
double precision,intent(in) :: J(nBas,nBas,nspin) double precision,intent(inout):: J(nBas,nBas,nspin)
double precision,intent(in) :: Fx(nBas,nBas,nspin) double precision,intent(inout):: Fx(nBas,nBas,nspin)
double precision,intent(in) :: FxHF(nBas,nBas,nspin) double precision,intent(inout):: FxHF(nBas,nBas,nspin)
double precision,intent(in) :: Fc(nBas,nBas,nspin) double precision,intent(inout):: Fc(nBas,nBas,nspin)
double precision,intent(in) :: Ew double precision,intent(in) :: Ew
double precision,intent(in) :: occnum(nBas,nspin,nEns) double precision,intent(in) :: occnum(nBas,nspin,nEns)
integer,intent(in) :: Cx_choice integer,intent(in) :: Cx_choice
@ -50,23 +50,23 @@ subroutine unrestricted_individual_energy(x_rung,x_DFA,c_rung,c_DFA,LDA_centered
double precision :: ET(nspin,nEns) double precision :: ET(nspin,nEns)
double precision :: EV(nspin,nEns) double precision :: EV(nspin,nEns)
double precision :: EJ(nsp,nEns) double precision :: EH(nsp,nEns)
double precision :: Ex(nspin,nEns) double precision :: Ex(nspin,nEns)
double precision :: Ec(nsp,nEns) double precision :: Ec(nsp,nEns)
double precision :: Exc(nEns) double precision :: LZH(nsp)
double precision :: LZH(nspin)
double precision :: LZx(nspin) double precision :: LZx(nspin)
double precision :: LZc(nspin) double precision :: LZc(nsp)
double precision :: LZHxc(nspin)
double precision :: Eaux(nspin,nEns) double precision :: Eaux(nspin,nEns)
double precision :: ExDD(nspin,nEns) double precision :: ExDD(nspin,nEns)
double precision :: EcDD(nsp,nEns) double precision :: EcDD(nsp,nEns)
double precision :: ExcDD(nsp,nEns)
double precision :: Omx(nEns),Omc(nEns),Omxc(nEns) double precision :: OmH(nEns)
double precision :: Omx(nEns)
double precision :: Omc(nEns)
double precision :: Omaux(nEns) double precision :: Omaux(nEns)
double precision :: OmxDD(nEns),OmcDD(nEns),OmxcDD(nEns) double precision :: OmxDD(nEns)
double precision :: OmcDD(nEns)
double precision,external :: trace_matrix double precision,external :: trace_matrix
@ -97,21 +97,21 @@ subroutine unrestricted_individual_energy(x_rung,x_DFA,c_rung,c_DFA,LDA_centered
! Kinetic energy ! Kinetic energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! do ispin=1,nspin do ispin=1,nspin
! do iEns=1,nEns do iEns=1,nEns
! ET(ispin,iEns) = trace_matrix(nBas,matmul(P(:,:,ispin,iEns),T(:,:))) ET(ispin,iEns) = trace_matrix(nBas,matmul(P(:,:,ispin,iEns),T(:,:)))
! end do end do
! end do end do
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Potential energy ! Potential energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! do iEns=1,nEns do iEns=1,nEns
! do ispin=1,nspin do ispin=1,nspin
! EV(ispin,iEns) = trace_matrix(nBas,matmul(P(:,:,ispin,iEns),V(:,:))) EV(ispin,iEns) = trace_matrix(nBas,matmul(P(:,:,ispin,iEns),V(:,:)))
! end do end do
! end do end do
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Individual Hartree energy ! Individual Hartree energy
@ -121,50 +121,67 @@ subroutine unrestricted_individual_energy(x_rung,x_DFA,c_rung,c_DFA,LDA_centered
call unrestricted_hartree_potential(nBas,Pw(:,:,ispin),ERI,J(:,:,ispin)) call unrestricted_hartree_potential(nBas,Pw(:,:,ispin),ERI,J(:,:,ispin))
end do end do
! do iEns=1,nEns do iEns=1,nEns
if(doNcentered) then
! if(doNcentered) then EH(1,iEns) = kappa(iEns)*trace_matrix(nBas,matmul(P(:,:,1,iEns),J(:,:,1)))
! EH(2,iEns) = kappa(iEns)*trace_matrix(nBas,matmul(P(:,:,1,iEns),J(:,:,2))) &
! EJ(1,iEns) = kappa(iEns)*trace_matrix(nBas,matmul(P(:,:,1,iEns),J(:,:,1))) & + kappa(iEns)*trace_matrix(nBas,matmul(P(:,:,2,iEns),J(:,:,1)))
! - 0.5d0*kappa(iEns)*kappa(iEns)*trace_matrix(nBas,matmul(Pw(:,:,1),J(:,:,1))) EH(3,iEns) = kappa(iEns)*trace_matrix(nBas,matmul(P(:,:,2,iEns),J(:,:,2)))
!
! EJ(2,iEns) = kappa(iEns)*trace_matrix(nBas,matmul(P(:,:,1,iEns),J(:,:,2))) &
! + kappa(iEns)*trace_matrix(nBas,matmul(P(:,:,2,iEns),J(:,:,1))) &
! - 0.5d0*kappa(iEns)*kappa(iEns)*trace_matrix(nBas,matmul(Pw(:,:,1),J(:,:,2))) &
! - 0.5d0*kappa(iEns)*kappa(iEns)*trace_matrix(nBas,matmul(Pw(:,:,2),J(:,:,1)))
!
! EJ(3,iEns) = kappa(iEns)*trace_matrix(nBas,matmul(P(:,:,2,iEns),J(:,:,2))) &
! - 0.5d0*kappa(iEns)*kappa(iEns)*trace_matrix(nBas,matmul(Pw(:,:,2),J(:,:,2)))
! else
else
! EJ(1,iEns) = trace_matrix(nBas,matmul(P(:,:,1,iEns),J(:,:,1))) & EH(1,iEns) = trace_matrix(nBas,matmul(P(:,:,1,iEns),J(:,:,1)))
! LZH(ispin) - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,1),J(:,:,1))) EH(2,iEns) = trace_matrix(nBas,matmul(P(:,:,1,iEns),J(:,:,2))) &
+ trace_matrix(nBas,matmul(P(:,:,2,iEns),J(:,:,1)))
EH(3,iEns) = trace_matrix(nBas,matmul(P(:,:,2,iEns),J(:,:,2)))
! EJ(2,iEns) = trace_matrix(nBas,matmul(P(:,:,1,iEns),J(:,:,2))) & end if
! + trace_matrix(nBas,matmul(P(:,:,2,iEns),J(:,:,1))) &
! - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,1),J(:,:,2))) &
! - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,2),J(:,:,1)))
! EJ(3,iEns) = trace_matrix(nBas,matmul(P(:,:,2,iEns),J(:,:,2))) &
! - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,2),J(:,:,2)))
! end if
! end do
!------------------------------------------------------------------------
! Individual Hartree energy
!------------------------------------------------------------------------
do ispin=1,nspin
LZH(ispin) = -0.5d0*trace_matrix(nBas,matmul(Pw(:,:,1)+Pw(:,:,2),J(:,:,ispin)))
end do end do
! Levy-Zahariev shif for Hartree
if(doNcentered) then
! Do I need to scale this term?
! LZH(:) = 0d0
else
! LZH(1) = - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,1),J(:,:,1)))
! LZH(2) = - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,1),J(:,:,2))) &
! - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,2),J(:,:,1)))
! LZH(3) = - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,2),J(:,:,2)))
LZH(1) = - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,1),J(:,:,1))) &
- 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,2),J(:,:,1)))
LZH(2) = 0d0
! print*,- 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,1)+Pw(:,:,2),J(:,:,2)))
print*,- 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,1),J(:,:,2)))
print*,- 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,2),J(:,:,2)))
LZH(3) = - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,1),J(:,:,2))) - 0.5d0*trace_matrix(nBas,matmul(Pw(:,:,2),J(:,:,2)))
print*,LZH(3)
end if
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Individual exchange energy ! Individual exchange energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
do iEns=1,nEns
do ispin=1,nspin
call unrestricted_exchange_energy(x_rung,x_DFA,LDA_centered,nEns,wEns,nCC,aCC,nGrid,weight,nBas, &
P(:,:,ispin,iEns),FxHF(:,:,ispin),rho(:,ispin,iEns),drho(:,:,ispin,iEns), &
Ex(ispin,iEns),Cx_choice,doNcentered)
end do
end do
! Levy-Zahariev shif for exchange
do ispin=1,nspin do ispin=1,nspin
call unrestricted_exchange_individual_energy(x_rung,x_DFA,LDA_centered,nEns,wEns,nCC,aCC,nGrid,weight,nBas,ERI, & call unrestricted_exchange_individual_energy(x_rung,x_DFA,LDA_centered,nEns,wEns,nCC,aCC,nGrid,weight,nBas,ERI, &
Pw(:,:,ispin),rhow(:,ispin),drhow(:,:,ispin),Cx_choice,doNcentered, & Pw(:,:,ispin),rhow(:,ispin),drhow(:,:,ispin),Cx_choice,doNcentered, &
@ -175,14 +192,14 @@ subroutine unrestricted_individual_energy(x_rung,x_DFA,c_rung,c_DFA,LDA_centered
! Individual correlation energy ! Individual correlation energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
do iEns=1,nEns
call unrestricted_correlation_energy(c_rung,c_DFA,nEns,wEns,nGrid,weight,rho(:,:,iEns),drho(:,:,:,iEns),Ec(:,iEns))
end do
! Levy-Zahariev shif for correlation
call unrestricted_correlation_individual_energy(c_rung,c_DFA,LDA_centered,nEns,wEns,nGrid,weight,rhow,drhow,doNcentered,LZc) call unrestricted_correlation_individual_energy(c_rung,c_DFA,LDA_centered,nEns,wEns,nGrid,weight,rhow,drhow,doNcentered,LZc)
!------------------------------------------------------------------------
! Individual exchange-correlation energy
!------------------------------------------------------------------------
LZHxc(:) = LZH(:) + LZx(:) + LZc(:)
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Compute auxiliary energies ! Compute auxiliary energies
!------------------------------------------------------------------------ !------------------------------------------------------------------------
@ -194,31 +211,33 @@ subroutine unrestricted_individual_energy(x_rung,x_DFA,c_rung,c_DFA,LDA_centered
!------------------------------------------------------------------------ !------------------------------------------------------------------------
do ispin=1,nspin do ispin=1,nspin
call unrestricted_exchange_derivative_discontinuity(x_rung,x_DFA,nEns,wEns,nCC,aCC,nGrid,weight, & call unrestricted_exchange_derivative_discontinuity(x_rung,x_DFA,nEns,wEns,nCC,aCC,nGrid,weight, &
rhow(:,ispin),drhow(:,:,ispin),Cx_choice,doNcentered,kappa,ExDD(ispin,:)) rhow(:,ispin),drhow(:,:,ispin),Cx_choice,doNcentered,kappa,ExDD(ispin,:))
end do end do
call unrestricted_correlation_derivative_discontinuity(c_rung,c_DFA,nEns,wEns,nGrid,weight,rhow,drhow,kappa,EcDD) call unrestricted_correlation_derivative_discontinuity(c_rung,c_DFA,nEns,wEns,nGrid,weight,rhow,drhow,kappa,EcDD)
ExcDD(1,:) = ExDD(1,:) + EcDD(1,:)
ExcDD(2,:) = EcDD(2,:)
ExcDD(3,:) = ExDD(2,:) + EcDD(3,:)
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Total energy ! Total energy
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! do iEns=1,nEns do iEns=1,nEns
! Exc(iEns) = sum(Ex(:,iEns)) + sum(Ec(:,iEns)) E(iEns) = sum(ET(:,iEns)) + sum(EV(:,iEns)) &
! E(iEns) = sum(ET(:,iEns)) + sum(EV(:,iEns)) + sum(EJ(:,iEns)) & + sum(EH(:,iEns)) + sum(Ex(:,iEns)) + sum(Ec(:,iEns)) &
! + sum(Ex(:,iEns)) + sum(Ec(:,iEns)) + sum(ExcDD(:,iEns)) + sum(LZH(:)) + sum(LZx(:)) + sum(LZc(:)) &
! end do + sum(ExDD(:,iEns)) + sum(EcDD(:,iEns))
end do
print*,E
do iEns=1,nEns do iEns=1,nEns
E(iEns) = sum(Eaux(:,iEns)) + sum(LZHxc(:)) + sum(ExcDD(:,iEns)) E(iEns) = sum(Eaux(:,iEns)) &
+ sum(LZH(:)) + sum(LZx(:)) + sum(LZc(:)) &
+ sum(ExDD(:,iEns)) + sum(EcDD(:,iEns))
end do end do
print*,E
!------------------------------------------------------------------------ !------------------------------------------------------------------------
! Excitation energies ! Excitation energies
!------------------------------------------------------------------------ !------------------------------------------------------------------------
@ -226,16 +245,14 @@ subroutine unrestricted_individual_energy(x_rung,x_DFA,c_rung,c_DFA,LDA_centered
do iEns=1,nEns do iEns=1,nEns
Om(iEns) = E(iEns) - E(1) Om(iEns) = E(iEns) - E(1)
! Omx(iEns) = sum(Ex(:,iEns)) - sum(Ex(:,1)) OmH(iEns) = sum(EH(:,iEns)) - sum(EH(:,1))
! Omc(iEns) = sum(Ec(:,iEns)) - sum(Ec(:,1)) Omx(iEns) = sum(Ex(:,iEns)) - sum(Ex(:,1))
! Omxc(iEns) = Exc(iEns) - Exc(1) Omc(iEns) = sum(Ec(:,iEns)) - sum(Ec(:,1))
Omaux(iEns) = sum(Eaux(:,iEns)) - sum(Eaux(:,1)) Omaux(iEns) = sum(Eaux(:,iEns)) - sum(Eaux(:,1))
OmxDD(iEns) = sum(ExDD(:,iEns)) - sum(ExDD(:,1)) OmxDD(iEns) = sum(ExDD(:,iEns)) - sum(ExDD(:,1))
OmcDD(iEns) = sum(EcDD(:,iEns)) - sum(EcDD(:,1)) OmcDD(iEns) = sum(EcDD(:,iEns)) - sum(EcDD(:,1))
OmxcDD(iEns) = sum(ExcDD(:,iEns)) - sum(ExcDD(:,1))
end do end do
@ -243,7 +260,6 @@ subroutine unrestricted_individual_energy(x_rung,x_DFA,c_rung,c_DFA,LDA_centered
! Dump results ! Dump results
!------------------------------------------------------------------------ !------------------------------------------------------------------------
call print_unrestricted_individual_energy(nEns,ENuc,Ew,ET,EV,EJ,Ex,Ec,Exc,Eaux,ExDD,EcDD,ExcDD,E, & call print_unrestricted_individual_energy(nEns,ENuc,Ew,ET,EV,EH,Ex,Ec,Eaux,ExDD,EcDD,E,Om,Omx,Omc,Omaux,OmxDD,OmcDD)
Om,Omx,Omc,Omxc,Omaux,OmxDD,OmcDD,OmxcDD)
end subroutine unrestricted_individual_energy end subroutine unrestricted_individual_energy