4
1
mirror of https://github.com/pfloos/quack synced 2024-12-23 04:43:53 +01:00

add hartree energy and potential

This commit is contained in:
Pierre-Francois Loos 2021-11-30 09:29:50 +01:00
parent 329209cf9c
commit 9078568db5
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,29 @@
subroutine unrestricted_hartree_energy(nBas,P,J,EH)
! Compute the unrestricted version of the Hartree energy
implicit none
include 'parameters.h'
! Input variables
integer,intent(in) :: nBas
double precision,intent(in) :: P(nBas,nBas,nspin)
double precision,intent(in) :: J(nBas,nBas,nspin)
! Local variables
double precision,external :: trace_matrix
! Output variables
double precision,intent(out) :: EH(nsp)
! Compute the components of the Hartree energy
EH(1) = 0.5d0*trace_matrix(nBas,matmul(P(:,:,1),J(:,:,1)))
EH(2) = 0.5d0*trace_matrix(nBas,matmul(P(:,:,1),J(:,:,2))) &
+ 0.5d0*trace_matrix(nBas,matmul(P(:,:,2),J(:,:,1)))
EH(3) = 0.5d0*trace_matrix(nBas,matmul(P(:,:,2),J(:,:,2)))
end subroutine unrestricted_hartree_energy

View File

@ -0,0 +1,33 @@
subroutine unrestricted_hartree_potential(nBas,P,ERI,J)
! Compute the unrestricted version of the Hartree potential
implicit none
! Input variables
integer,intent(in) :: nBas
double precision,intent(in) :: P(nBas,nBas)
double precision,intent(in) :: ERI(nBas,nBas,nBas,nBas)
! Local variables
integer :: mu,nu,la,si
! Output variables
double precision,intent(out) :: J(nBas,nBas)
J(:,:) = 0d0
do si=1,nBas
do la=1,nBas
do nu=1,nBas
do mu=1,nBas
J(mu,nu) = J(mu,nu) + P(la,si)*ERI(mu,la,nu,si)
enddo
enddo
enddo
enddo
end subroutine unrestricted_hartree_potential