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

73 lines
1.6 KiB
Fortran
Raw Normal View History

2020-09-29 09:43:01 +02:00
subroutine US51_lda_exchange_individual_energy(nGrid,weight,rhow,rho,doNcentered,Ex)
2020-07-02 14:27:38 +02:00
! Compute the restricted version of Slater's LDA exchange individual energy
implicit none
include 'parameters.h'
! Input variables
integer,intent(in) :: nGrid
double precision,intent(in) :: weight(nGrid)
double precision,intent(in) :: rhow(nGrid)
double precision,intent(in) :: rho(nGrid)
2020-09-29 09:43:01 +02:00
integer,intent(in) :: doNcentered
2020-07-02 14:27:38 +02:00
! Local variables
integer :: iG
double precision :: r,rI,alpha
double precision :: e,dedr
2020-09-29 09:43:01 +02:00
double precision :: nEli,nElw
2020-07-02 14:27:38 +02:00
! Output variables
double precision,intent(out) :: Ex
2020-09-29 09:43:01 +02:00
! External variable
double precision,external :: electron_number
nEli = electron_number(nGrid,weight,rho)
nElw = electron_number(nGrid,weight,rhow)
2020-07-02 14:27:38 +02:00
! Compute LDA exchange matrix in the AO basis
alpha = -(3d0/2d0)*(3d0/(4d0*pi))**(1d0/3d0)
Ex = 0d0
do iG=1,nGrid
r = max(0d0,rhow(iG))
rI = max(0d0,rho(iG))
2020-07-06 15:42:21 +02:00
if(r > threshold) then
2020-07-02 14:27:38 +02:00
e = alpha*r**(1d0/3d0)
dedr = 1d0/3d0*alpha*r**(-2d0/3d0)
2020-09-29 09:43:01 +02:00
if (doNcentered == 0) then
Ex = Ex - weight(iG)*dedr*r*r
else
Ex = Ex - weight(iG)*dedr*r*r*(nEli/nElw)
end if
2020-07-06 15:42:21 +02:00
if(rI > threshold) then
2020-09-29 09:43:01 +02:00
if (doNcentered == 0) then
Ex = Ex + weight(iG)*(e*rI + dedr*r*rI)
else
Ex = Ex + weight(iG)*((nEli/nElw)*e*rI + dedr*r*rI)
end if
2020-07-06 15:42:21 +02:00
endif
2020-07-02 14:27:38 +02:00
endif
enddo
end subroutine US51_lda_exchange_individual_energy