2020-08-01 11:45:17 +02:00
|
|
|
subroutine unrestricted_density_matrix(nBas,nEns,nO,c,P,occnum)
|
2020-03-15 14:34:18 +01:00
|
|
|
|
|
|
|
! 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)
|
2020-08-04 12:30:52 +02:00
|
|
|
double precision,intent(in) :: occnum(nspin,2,nEns)
|
2020-08-01 11:45:17 +02:00
|
|
|
|
2020-03-15 14:34:18 +01:00
|
|
|
|
|
|
|
! Local variables
|
|
|
|
|
|
|
|
integer :: ispin
|
|
|
|
integer :: iEns
|
|
|
|
|
|
|
|
! Output variables
|
|
|
|
|
|
|
|
double precision,intent(out) :: P(nBas,nBas,nspin,nEns)
|
|
|
|
|
2020-08-01 11:45:17 +02:00
|
|
|
!-------------------------------------------------------
|
|
|
|
!------------------------ GOK-UKS ----------------------
|
|
|
|
!-------------------------------------------------------
|
2020-03-15 14:34:18 +01:00
|
|
|
iEns = 1
|
|
|
|
do ispin=1,nspin
|
2020-08-01 11:45:17 +02:00
|
|
|
P(:,:,ispin,iEns) = matmul(c(:,1:nO(ispin),ispin),transpose(c(:,1:nO(ispin),ispin)))
|
2020-03-15 14:34:18 +01:00
|
|
|
end do
|
|
|
|
|
|
|
|
iEns = 2
|
2020-08-01 11:45:17 +02:00
|
|
|
|
|
|
|
if(nO(1) > 1) then
|
|
|
|
P(:,:,1,iEns) = matmul(c(:,1:nO(1)-1,1),transpose(c(:,1:nO(1)-1,1)))
|
|
|
|
else
|
|
|
|
P(:,:,1,iEns)=0.d0
|
|
|
|
end if
|
|
|
|
P(:,:,1,iEns) = P(:,:,1,iEns) + occnum(1,1,iEns)* matmul(c(:,nO(1):nO(1),1),transpose(c(:,nO(1):nO(1),1))) &
|
|
|
|
+ occnum(1,2,iEns)* matmul(c(:,nO(1)+1:nO(1)+1,1),transpose(c(:,nO(1)+1:nO(1)+1,1)))
|
|
|
|
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
|
|
|
|
|
|
|
|
P(:,:,2,iEns) = P(:,:,2,iEns) + occnum(2,1,iEns)* matmul(c(:,1:nO(2),2),transpose(c(:,1:nO(2),2))) &
|
|
|
|
+ occnum(2,2,iEns)*matmul(c(:,1:nO(2)+1,2),transpose(c(:,1:nO(2)+1,2)))
|
|
|
|
|
|
|
|
|
|
|
|
iEns = 3
|
|
|
|
|
|
|
|
if(nO(1) > 1) then
|
2020-07-26 17:56:25 +02:00
|
|
|
P(:,:,1,iEns) = matmul(c(:,1:nO(1)-1,1),transpose(c(:,1:nO(1)-1,1)))
|
2020-07-05 19:04:08 +02:00
|
|
|
else
|
2020-08-01 11:45:17 +02:00
|
|
|
P(:,:,1,iEns)=0.d0
|
|
|
|
end if
|
|
|
|
P(:,:,1,iEns) = P(:,:,1,iEns) + occnum(1,1,iEns)* matmul(c(:,nO(1):nO(1),1),transpose(c(:,nO(1):nO(1),1))) &
|
|
|
|
+ occnum(1,2,iEns)* matmul(c(:,nO(1)+1:nO(1)+1,1),transpose(c(:,nO(1)+1:nO(1)+1,1)))
|
|
|
|
|
|
|
|
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
|
2020-07-05 19:04:08 +02:00
|
|
|
end if
|
2020-08-01 11:45:17 +02:00
|
|
|
P(:,:,2,iEns) = P(:,:,2,iEns) + occnum(2,1,iEns)* matmul(c(:,nO(2):nO(2),2),transpose(c(:,nO(2):nO(2),2))) &
|
|
|
|
+ occnum(2,2,iEns)*matmul(c(:,nO(2)+1:nO(2)+1,2),transpose(c(:,nO(2)+1:nO(2)+1,2)))
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------
|
|
|
|
!--------------- For eDFT_UKS (fundamental gap)---------------------
|
|
|
|
!-------------------------------------------------------------------
|
|
|
|
|
|
|
|
! N-electron ground state
|
|
|
|
|
|
|
|
! 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-up electrons
|
|
|
|
|
|
|
|
! iEns = 2
|
|
|
|
! P(:,:,2,iEns) = matmul(c(:,1:nO(2),2),transpose(c(:,1:nO(2),2)))
|
|
|
|
! if (nO(1) > 1) then
|
|
|
|
! P(:,:,1,iEns) = matmul(c(:,1:nO(1)-1,1),transpose(c(:,1:nO(1)-1,1)))
|
|
|
|
! else
|
|
|
|
! P(:,:,1,iEns) = 0.d0
|
|
|
|
! end if
|
2020-07-26 17:56:25 +02:00
|
|
|
! (N+1)-electron state: remove spin-down electrons
|
2020-03-15 14:34:18 +01:00
|
|
|
|
2020-08-01 11:45:17 +02:00
|
|
|
! iEns = 3
|
|
|
|
! P(:,:,2,iEns) = matmul(c(:,1:nO(2)+1,2),transpose(c(:,1:nO(2)+1,2)))
|
|
|
|
! P(:,:,1,iEns) = matmul(c(:,1:nO(1),1),transpose(c(:,1:nO(1),1)))
|
2020-03-15 14:34:18 +01:00
|
|
|
|
|
|
|
end subroutine unrestricted_density_matrix
|