4
1
mirror of https://github.com/pfloos/quack synced 2024-07-07 20:05:58 +02:00
quack/src/eDFT/US51_lda_exchange_energy.f90

55 lines
1.1 KiB
Fortran
Raw Normal View History

2020-10-14 16:02:09 +02:00
subroutine US51_lda_exchange_energy(nGrid,weight,rho,ExLDA)
2019-03-13 11:07:31 +01:00
2020-10-14 15:07:35 +02:00
use xc_f90_lib_m
2019-03-13 11:07:31 +01:00
! Compute Slater's LDA exchange energy
implicit none
include 'parameters.h'
! Input variables
integer,intent(in) :: nGrid
double precision,intent(in) :: weight(nGrid)
double precision,intent(in) :: rho(nGrid)
! Local variables
2020-10-14 16:02:09 +02:00
integer(8) :: nGri8
2019-03-13 11:07:31 +01:00
integer :: iG
2020-10-14 16:02:09 +02:00
double precision :: r
double precision,allocatable :: Ex(:)
2019-03-13 11:07:31 +01:00
2020-10-14 16:02:09 +02:00
TYPE(xc_f90_func_t) :: xc_func
TYPE(xc_f90_func_info_t) :: xc_info
integer :: func_id = 1
2019-03-13 11:07:31 +01:00
2020-10-14 16:02:09 +02:00
! Output variables
2020-07-02 14:27:38 +02:00
2020-10-14 16:02:09 +02:00
double precision :: ExLDA
2020-07-02 14:27:38 +02:00
2020-10-14 16:02:09 +02:00
! Memory allocation
nGri8 = int(nGrid,8)
print*,nGri8
allocate(Ex(nGrid))
2019-03-13 11:07:31 +01:00
2020-10-14 16:02:09 +02:00
call xc_f90_func_init(xc_func, func_id, XC_POLARIZED)
xc_info = xc_f90_func_get_info(xc_func)
call xc_f90_lda_exc(xc_func, nGri8, rho(1), Ex(1))
2019-03-13 11:07:31 +01:00
2020-10-14 16:02:09 +02:00
ExLDA = 0d0
2019-03-13 11:07:31 +01:00
2020-10-14 16:02:09 +02:00
! do iG=1,nGrid
2019-03-13 11:07:31 +01:00
2020-10-14 16:02:09 +02:00
! write(*,"(F8.6,1X,F9.6)") rho(iG), Ex(iG)
2019-03-13 11:07:31 +01:00
2020-10-14 16:02:09 +02:00
! ExLDA = ExLDA + weight(iG)*Ex(iG)
2019-03-13 11:07:31 +01:00
2020-10-14 16:02:09 +02:00
! enddo
2019-03-13 11:07:31 +01:00
2020-10-14 16:02:09 +02:00
call xc_f90_func_end(xc_func)
2019-03-13 11:07:31 +01:00
2020-07-02 14:27:38 +02:00
end subroutine US51_lda_exchange_energy