10
1
mirror of https://github.com/pfloos/quack synced 2024-12-27 14:53:40 +01:00
QuAcK/src/eDFT/unrestricted_density_matrix.f90

48 lines
1.2 KiB
Fortran
Raw Normal View History

2020-03-15 14:34:18 +01:00
subroutine unrestricted_density_matrix(nBas,nEns,nO,c,P)
! Calculate density matrices
implicit none
include 'parameters.h'
! Input variables
integer,intent(in) :: nBas
integer,intent(in) :: nEns
integer,intent(in) :: nO(nspin)
double precision,intent(in) :: c(nBas,nBas,nspin)
! Local variables
integer :: ispin
integer :: iEns
! Output variables
double precision,intent(out) :: P(nBas,nBas,nspin,nEns)
! N-electron ground state
2020-03-15 14:34:18 +01:00
iEns = 1
do ispin=1,nspin
P(:,:,ispin,iEns) = matmul(c(:,1:nO(ispin),ispin),transpose(c(:,1:nO(ispin),ispin)))
end do
! (N-1)-electron state: remove spin-down electrons
2020-03-15 14:34:18 +01:00
iEns = 2
P(:,:,1,iEns) = matmul(c(:,1:nO(1) ,1),transpose(c(:,1:nO(1) ,1)))
2020-07-05 19:04:08 +02:00
if (nO(2) > 1) then
P(:,:,2,iEns) = matmul(c(:,1:nO(2)-1,2),transpose(c(:,1:nO(2)-1,2)))
else
P(:,:,2,iEns) = 0.d0
end if
! (N+1)-electron state: remove spin-up electrons
2020-03-15 14:34:18 +01:00
iEns = 3
P(:,:,1,iEns) = matmul(c(:,1:nO(1)+1,1),transpose(c(:,1:nO(1)+1,1)))
P(:,:,2,iEns) = matmul(c(:,1:nO(2) ,2),transpose(c(:,1:nO(2) ,2)))
2020-03-15 14:34:18 +01:00
end subroutine unrestricted_density_matrix