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)
|
|
|
|
|
2020-06-23 15:59:19 +02:00
|
|
|
! 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
|
|
|
|
|
2020-06-23 15:59:19 +02:00
|
|
|
! (N-1)-electron state: remove spin-down electrons
|
2020-03-15 14:34:18 +01:00
|
|
|
|
|
|
|
iEns = 2
|
2020-06-23 15:59:19 +02:00
|
|
|
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
|
2020-06-23 15:59:19 +02:00
|
|
|
! (N+1)-electron state: remove spin-up electrons
|
2020-03-15 14:34:18 +01:00
|
|
|
|
|
|
|
iEns = 3
|
2020-06-23 15:59:19 +02:00
|
|
|
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
|