10
1
mirror of https://github.com/pfloos/quack synced 2024-12-27 06:43:42 +01:00
QuAcK/src/eDFT/restricted_individual_energy.f90

180 lines
6.3 KiB
Fortran
Raw Normal View History

2020-03-15 16:30:18 +01:00
subroutine restricted_individual_energy(x_rung,x_DFA,c_rung,c_DFA,nEns,wEns,nGrid,weight,nBas,AO,dAO, &
2020-03-30 22:45:05 +02:00
nO,nV,T,V,ERI,ENuc,eps,Pw,rhow,drhow,J,Fx,FxHF,Fc,P,rho,drho,Ew,EwGIC,E,Om)
2020-03-15 16:30:18 +01:00
! Compute individual energies as well as excitation energies
implicit none
include 'parameters.h'
! Input variables
integer,intent(in) :: x_rung,c_rung
character(len=12),intent(in) :: x_DFA,c_DFA
integer,intent(in) :: nEns
double precision,intent(in) :: wEns(nEns)
integer,intent(in) :: nGrid
double precision,intent(in) :: weight(nGrid)
integer,intent(in) :: nBas
double precision,intent(in) :: AO(nBas,nGrid)
double precision,intent(in) :: dAO(ncart,nBas,nGrid)
2020-03-30 22:45:05 +02:00
integer,intent(in) :: nO
integer,intent(in) :: nV
2020-03-15 16:30:18 +01:00
double precision,intent(in) :: T(nBas,nBas)
double precision,intent(in) :: V(nBas,nBas)
double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas)
double precision,intent(in) :: ENuc
2020-03-30 22:45:05 +02:00
double precision,intent(in) :: eps(nBas)
2020-03-15 16:30:18 +01:00
double precision,intent(in) :: Pw(nBas,nBas)
double precision,intent(in) :: rhow(nGrid)
double precision,intent(in) :: drhow(ncart,nGrid)
double precision,intent(in) :: P(nBas,nBas,nEns)
double precision,intent(in) :: rho(nGrid,nEns)
double precision,intent(in) :: drho(ncart,nGrid,nEns)
double precision,intent(in) :: J(nBas,nBas)
double precision,intent(in) :: Fx(nBas,nBas)
double precision,intent(in) :: FxHF(nBas,nBas)
double precision,intent(in) :: Fc(nBas,nBas)
2020-03-18 07:29:54 +01:00
double precision :: Ew
2020-03-15 16:30:18 +01:00
! Local variables
double precision :: ET(nEns)
double precision :: EV(nEns)
double precision :: EJ(nEns)
2020-03-17 11:29:20 +01:00
double precision :: Ex(nEns), Ec(nEns), Exc(nEns)
2020-03-30 22:45:05 +02:00
double precision :: Eaux(nEns)
2020-03-17 11:29:20 +01:00
double precision :: ExDD(nEns), EcDD(nEns), ExcDD(nEns)
double precision :: Omx(nEns), Omc(nEns), Omxc(nEns)
2020-03-30 22:45:05 +02:00
double precision :: Omaux(nEns)
2020-03-17 11:29:20 +01:00
double precision :: OmxDD(nEns),OmcDD(nEns),OmxcDD(nEns)
2020-03-15 16:30:18 +01:00
double precision,external :: trace_matrix
integer :: iEns
! Output variables
2020-03-18 11:10:21 +01:00
double precision,intent(out) :: EwGIC
2020-03-15 16:30:18 +01:00
double precision,intent(out) :: E(nEns)
double precision,intent(out) :: Om(nEns)
!------------------------------------------------------------------------
! Kinetic energy
!------------------------------------------------------------------------
do iEns=1,nEns
ET(iEns) = trace_matrix(nBas,matmul(P(:,:,iEns),T(:,:)))
end do
!------------------------------------------------------------------------
! Potential energy
!------------------------------------------------------------------------
do iEns=1,nEns
EV(iEns) = trace_matrix(nBas,matmul(P(:,:,iEns),V(:,:)))
end do
!------------------------------------------------------------------------
! Hartree energy
!------------------------------------------------------------------------
do iEns=1,nEns
call hartree_coulomb(nBas,P(:,:,iEns),ERI(:,:,:,:),J(:,:))
2020-03-15 16:30:18 +01:00
EJ(iEns) = 0.5d0*trace_matrix(nBas,matmul(P(:,:,iEns),J(:,:)))
end do
!------------------------------------------------------------------------
2020-03-16 22:08:04 +01:00
! Individual exchange energy
2020-03-15 16:30:18 +01:00
!------------------------------------------------------------------------
do iEns=1,nEns
call exchange_individual_energy(x_rung,x_DFA,nEns,wEns(:),nGrid,weight(:),nBas,ERI(:,:,:,:), &
P(:,:,iEns),FxHF(:,:),rhow(:),drhow(:,:),rho(:,iEns),drho(:,:,iEns),Ex(iEns))
2020-03-15 16:30:18 +01:00
end do
!------------------------------------------------------------------------
2020-03-16 22:08:04 +01:00
! Indivudual correlation energy
2020-03-15 16:30:18 +01:00
!------------------------------------------------------------------------
do iEns=1,nEns
2020-03-15 22:37:40 +01:00
call restricted_correlation_individual_energy(c_rung,c_DFA,nEns,wEns(:),nGrid,weight(:),rhow(:),drhow(:,:), &
rho(:,iEns),drho(:,:,iEns),Ec(iEns))
2020-03-15 16:30:18 +01:00
end do
2020-03-30 22:45:05 +02:00
!------------------------------------------------------------------------
! Compute auxiliary energies
!------------------------------------------------------------------------
call restricted_auxiliary_energy(nBas,nEns,nO,eps,Eaux)
2020-03-15 16:30:18 +01:00
!------------------------------------------------------------------------
! Compute derivative discontinuities
!------------------------------------------------------------------------
2020-03-16 22:08:04 +01:00
call exchange_derivative_discontinuity(x_rung,x_DFA,nEns,wEns(:),nGrid,weight(:),rhow(:),drhow(:,:),ExDD(:))
call restricted_correlation_derivative_discontinuity(c_rung,c_DFA,nEns,wEns(:),nGrid,weight(:),rhow(:),drhow(:,:),EcDD(:))
ExcDD(:) = ExDD(:) + EcDD(:)
2020-03-15 16:30:18 +01:00
!------------------------------------------------------------------------
! Total energy
!------------------------------------------------------------------------
do iEns=1,nEns
2020-03-27 20:46:13 +01:00
Exc(iEns) = Ex(iEns) + Ec(iEns)
E(iEns) = ET(iEns) + EV(iEns) + EJ(iEns) &
+ Ex(iEns) + Ec(iEns) + ExcDD(iEns)
2020-03-15 16:30:18 +01:00
end do
2020-03-18 07:29:54 +01:00
!------------------------------------------------------------------------
! Total energy with ghost-interaction correction
!------------------------------------------------------------------------
2020-03-18 11:10:21 +01:00
EwGIC = 0d0
2020-03-18 07:29:54 +01:00
do iEns=1,nEns
2020-03-18 11:10:21 +01:00
EwGIC = EwGIC + wEns(iEns)*E(iEns)
2020-03-18 07:29:54 +01:00
end do
2020-03-15 16:30:18 +01:00
!------------------------------------------------------------------------
! Excitation energies
!------------------------------------------------------------------------
do iEns=1,nEns
2020-03-17 11:29:20 +01:00
Om(iEns) = E(iEns) - E(1)
Omx(iEns) = Ex(iEns) - Ex(1)
Omc(iEns) = Ec(iEns) - Ec(1)
Omxc(iEns) = Exc(iEns) - Exc(1)
2020-03-30 22:45:05 +02:00
Omaux(iEns) = Eaux(iENs) - Eaux(1)
2020-03-17 11:29:20 +01:00
OmxDD(iEns) = ExDD(iEns) - ExDD(1)
OmcDD(iEns) = EcDD(iEns) - EcDD(1)
OmxcDD(iEns) = ExcDD(iEns) - ExcDD(1)
2020-03-15 16:30:18 +01:00
end do
!------------------------------------------------------------------------
! Dump results
!------------------------------------------------------------------------
2020-03-27 20:46:13 +01:00
call print_restricted_individual_energy(nEns,ENuc,Ew,EwGIC,ET(:),EV(:),EJ(:),Ex(:),Ec(:),Exc(:), &
2020-03-30 22:45:05 +02:00
Eaux(:),ExDD(:),EcDD(:),ExcDD(:),E(:), &
Om(:),Omx(:),Omc(:),Omxc(:),Omaux,OmxDD(:),OmcDD(:),OmxcDD(:))
2020-03-15 16:30:18 +01:00
end subroutine restricted_individual_energy