4
1
mirror of https://github.com/pfloos/quack synced 2024-12-22 20:35:36 +01:00

S components for UHF

This commit is contained in:
Pierre-Francois Loos 2023-11-15 21:58:32 +01:00
parent bf1eeb0b8e
commit 7a7f3888a2
3 changed files with 82 additions and 79 deletions

View File

@ -190,7 +190,7 @@ subroutine print_GHF(nBas,nBas2,nO,eHF,C,P,S,ENuc,ET,EV,EJ,EK,EGHF,dipole)
write(*,'(A50)') '---------------------------------------'
write(*,'(A50)') ' GHF orbital energies (au) '
write(*,'(A50)') '---------------------------------------'
call matout(nBas2,1,eHF)
call vecout(nBas2,eHF)
write(*,*)
end subroutine

View File

@ -1,4 +1,4 @@
subroutine print_ROHF(nBas,nO,e,c,ENuc,ET,EV,EJ,Ex,EHF,dipole)
subroutine print_ROHF(nBas,nO,eHF,c,ENuc,ET,EV,EJ,Ex,EROHF,dipole)
! Print one- and two-electron energies and other stuff for RoHF calculation
@ -7,14 +7,14 @@ subroutine print_ROHF(nBas,nO,e,c,ENuc,ET,EV,EJ,Ex,EHF,dipole)
integer,intent(in) :: nBas
integer,intent(in) :: nO(nspin)
double precision,intent(in) :: e(nBas)
double precision,intent(in) :: eHF(nBas)
double precision,intent(in) :: c(nBas,nBas)
double precision,intent(in) :: ENuc
double precision,intent(in) :: ET(nspin)
double precision,intent(in) :: EV(nspin)
double precision,intent(in) :: EJ(nsp)
double precision,intent(in) :: Ex(nspin)
double precision,intent(in) :: EHF
double precision,intent(in) :: EROHF
double precision,intent(in) :: dipole(ncart)
integer :: ixyz
@ -28,16 +28,16 @@ subroutine print_ROHF(nBas,nO,e,c,ENuc,ET,EV,EJ,Ex,EHF,dipole)
do ispin=1,nspin
if(nO(ispin) > 0) then
HOMO(ispin) = e(nO(ispin))
HOMO(ispin) = eHF(nO(ispin))
if(nO(ispin) < nBas) then
LUMO(ispin) = e(nO(ispin)+1)
LUMO(ispin) = eHF(nO(ispin)+1)
else
LUMO(ispin) = 0d0
end if
Gap(ispin) = LUMO(ispin) - HOMO(ispin)
else
HOMO(ispin) = 0d0
LUMO(ispin) = e(1)
LUMO(ispin) = eHF(1)
Gap(ispin) = 0d0
end if
end do
@ -73,9 +73,9 @@ subroutine print_ROHF(nBas,nO,e,c,ENuc,ET,EV,EJ,Ex,EHF,dipole)
write(*,'(A40,1X,F16.10,A3)') ' Exchange a energy: ',Ex(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Exchange b energy: ',Ex(2),' au'
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,1X,F16.10,A3)') ' Electronic energy: ',EHF,' au'
write(*,'(A40,1X,F16.10,A3)') ' Electronic energy: ',EROHF,' au'
write(*,'(A40,1X,F16.10,A3)') ' Nuclear repulsion: ',ENuc,' au'
write(*,'(A40,1X,F16.10,A3)') ' ROHF energy: ',EHF + ENuc,' au'
write(*,'(A40,1X,F16.10,A3)') ' ROHF energy: ',EROHF + ENuc,' au'
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,1X,F16.6,A3)') ' ROHF HOMO a energy:',HOMO(1)*HatoeV,' eV'
write(*,'(A40,1X,F16.6,A3)') ' ROHF LUMO a energy:',LUMO(1)*HatoeV,' eV'
@ -104,7 +104,7 @@ subroutine print_ROHF(nBas,nO,e,c,ENuc,ET,EV,EJ,Ex,EHF,dipole)
write(*,'(A50)') '---------------------------------------'
write(*,'(A50)') ' ROHF orbital energies (au) '
write(*,'(A50)') '---------------------------------------'
call matout(nBas,1,e)
call vecout(nBas,eHF)
write(*,*)
end subroutine

View File

@ -1,4 +1,4 @@
subroutine print_UHF(nBas,nO,Ov,e,c,ENuc,ET,EV,EJ,Ex,EUHF,dipole)
subroutine print_UHF(nBas,nO,Ov,eHF,c,ENuc,ET,EV,EJ,Ex,EUHF,dipole)
! Print one- and two-electron energies and other stuff for UHF calculation
@ -10,7 +10,7 @@ subroutine print_UHF(nBas,nO,Ov,e,c,ENuc,ET,EV,EJ,Ex,EUHF,dipole)
integer,intent(in) :: nBas
integer,intent(in) :: nO(nspin)
double precision,intent(in) :: Ov(nBas,nBas)
double precision,intent(in) :: e(nBas,nspin)
double precision,intent(in) :: eHF(nBas,nspin)
double precision,intent(in) :: c(nBas,nBas,nspin)
double precision,intent(in) :: ENuc
double precision,intent(in) :: ET(nspin)
@ -27,8 +27,8 @@ subroutine print_UHF(nBas,nO,Ov,e,c,ENuc,ET,EV,EJ,Ex,EUHF,dipole)
double precision :: HOMO(nspin)
double precision :: LUMO(nspin)
double precision :: Gap(nspin)
double precision :: S_exact,S2_exact
double precision :: S,S2
double precision :: Sx,Sy,Sz
double precision :: Sx2,Sy2,Sz2
logical :: dump_orb = .false.
@ -36,100 +36,103 @@ subroutine print_UHF(nBas,nO,Ov,e,c,ENuc,ET,EV,EJ,Ex,EUHF,dipole)
do ispin=1,nspin
if(nO(ispin) > 0) then
HOMO(ispin) = e(nO(ispin),ispin)
HOMO(ispin) = eHF(nO(ispin),ispin)
if(nO(ispin) < nBas) then
LUMO(ispin) = e(nO(ispin)+1,ispin)
LUMO(ispin) = eHF(nO(ispin)+1,ispin)
else
LUMO(ispin) = 0d0
end if
Gap(ispin) = LUMO(ispin) - HOMO(ispin)
else
HOMO(ispin) = 0d0
LUMO(ispin) = e(1,ispin)
LUMO(ispin) = eHF(1,ispin)
Gap(ispin) = 0d0
end if
end do
S2_exact = dble(nO(1) - nO(2))/2d0*(dble(nO(1) - nO(2))/2d0 + 1d0)
S2 = S2_exact + nO(2) - sum(matmul(transpose(c(:,1:nO(1),1)),matmul(Ov,c(:,1:nO(2),2)))**2)
S_exact = 0.5d0*dble(nO(1) - nO(2))
S = -0.5d0 + 0.5d0*sqrt(1d0 + 4d0*S2)
Sz = 0.5d0*dble(nO(1) - nO(2))
! print*,Sz*(Sz+1d0) + nO(2) - sum(matmul(transpose(c(:,1:nO(1),1)),matmul(Ov,c(:,1:nO(2),2)))**2)
Sx2 = 0.25d0*dble(nO(1) - nO(2)) + 0.5d0*nO(2) - 0.5d0*sum(matmul(transpose(c(:,1:nO(1),1)),matmul(Ov,c(:,1:nO(2),2)))**2)
Sy2 = 0.25d0*dble(nO(1) - nO(2)) + 0.5d0*nO(2) - 0.5d0*sum(matmul(transpose(c(:,1:nO(1),1)),matmul(Ov,c(:,1:nO(2),2)))**2)
Sz2 = 0.25d0*dble(nO(1) - nO(2))**2
! Dump results
write(*,*)
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A60)') '---------------------------------------------'
write(*,'(A40)') ' Summary '
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,1X,F16.10,A3)') ' One-electron energy: ',sum(ET(:)) + sum(EV(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' One-electron a energy: ',ET(1) + EV(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' One-electron b energy: ',ET(2) + EV(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Kinetic energy: ',sum(ET(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Kinetic a energy: ',ET(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Kinetic b energy: ',ET(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Potential energy: ',sum(EV(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Potential a energy: ',EV(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Potential b energy: ',EV(2),' au'
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,1X,F16.10,A3)') ' Two-electron energy: ',sum(EJ(:)) + sum(Ex(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Two-electron aa energy: ',EJ(1) + Ex(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Two-electron ab energy: ',EJ(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Two-electron bb energy: ',EJ(3) + Ex(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Hartree energy: ',sum(EJ(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Hartree aa energy: ',EJ(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Hartree ab energy: ',EJ(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Hartree bb energy: ',EJ(3),' au'
write(*,'(A40,1X,F16.10,A3)') ' Exchange energy: ',sum(Ex(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Exchange a energy: ',Ex(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Exchange b energy: ',Ex(2),' au'
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,1X,F16.10,A3)') ' Electronic energy: ',EUHF,' au'
write(*,'(A40,1X,F16.10,A3)') ' Nuclear repulsion: ',ENuc,' au'
write(*,'(A40,1X,F16.10,A3)') ' UHF energy: ',EUHF + ENuc,' au'
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,1X,F16.6,A3)') ' UHF HOMO a energy:',HOMO(1)*HatoeV,' eV'
write(*,'(A40,1X,F16.6,A3)') ' UHF LUMO a energy:',LUMO(1)*HatoeV,' eV'
write(*,'(A40,1X,F16.6,A3)') ' UHF HOMOa-LUMOa gap:',Gap(1)*HatoeV,' eV'
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,1X,F16.6,A3)') ' UHF HOMO b energy:',HOMO(2)*HatoeV,' eV'
write(*,'(A40,1X,F16.6,A3)') ' UHF LUMO b energy:',LUMO(2)*HatoeV,' eV'
write(*,'(A40,1X,F16.6,A3)') ' UHF HOMOb-LUMOb gap:',Gap(2)*HatoeV,' eV'
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A40,1X,F16.6)') ' S (exact) :',2d0*S_exact + 1d0
write(*,'(A40,1X,F16.6)') ' S :',2d0*S + 1d0
write(*,'(A40,1X,F16.6)') ' <S**2> (exact) :',S2_exact
write(*,'(A40,1X,F16.6)') ' <S**2> :',S2
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A60)') '---------------------------------------------'
write(*,'(A40,1X,F16.10,A3)') ' One-electron energy = ',sum(ET(:)) + sum(EV(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' One-electron a energy = ',ET(1) + EV(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' One-electron b energy = ',ET(2) + EV(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Kinetic energy = ',sum(ET(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Kinetic a energy = ',ET(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Kinetic b energy = ',ET(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Potential energy = ',sum(EV(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Potential a energy = ',EV(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Potential b energy = ',EV(2),' au'
write(*,'(A60)') '---------------------------------------------'
write(*,'(A40,1X,F16.10,A3)') ' Two-electron energy = ',sum(EJ(:)) + sum(Ex(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Two-electron aa energy = ',EJ(1) + Ex(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Two-electron ab energy = ',EJ(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Two-electron bb energy = ',EJ(3) + Ex(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Hartree energy = ',sum(EJ(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Hartree aa energy = ',EJ(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Hartree ab energy = ',EJ(2),' au'
write(*,'(A40,1X,F16.10,A3)') ' Hartree bb energy = ',EJ(3),' au'
write(*,'(A40,1X,F16.10,A3)') ' Exchange energy = ',sum(Ex(:)),' au'
write(*,'(A40,1X,F16.10,A3)') ' Exchange a energy = ',Ex(1),' au'
write(*,'(A40,1X,F16.10,A3)') ' Exchange b energy = ',Ex(2),' au'
write(*,'(A60)') '---------------------------------------------'
write(*,'(A40,1X,F16.10,A3)') ' Electronic energy = ',EUHF,' au'
write(*,'(A40,1X,F16.10,A3)') ' Nuclear repulsion = ',ENuc,' au'
write(*,'(A40,1X,F16.10,A3)') ' UHF energy = ',EUHF + ENuc,' au'
write(*,'(A60)') '---------------------------------------------'
write(*,'(A40,1X,F16.6,A3)') ' UHF HOMO a energy = ' ,HOMO(1)*HatoeV,' eV'
write(*,'(A40,1X,F16.6,A3)') ' UHF LUMO a energy = ' ,LUMO(1)*HatoeV,' eV'
write(*,'(A40,1X,F16.6,A3)') ' UHF HOMOa-LUMOa gap = ' ,Gap(1)*HatoeV,' eV'
write(*,'(A60)') '---------------------------------------------'
write(*,'(A40,1X,F16.6,A3)') ' UHF HOMO b energy = ',HOMO(2)*HatoeV,' eV'
write(*,'(A40,1X,F16.6,A3)') ' UHF LUMO b energy = ',LUMO(2)*HatoeV,' eV'
write(*,'(A40,1X,F16.6,A3)') ' UHF HOMOb-LUMOb gap = ',Gap(2)*HatoeV,' eV'
write(*,'(A60)') '---------------------------------------------'
write(*,'(A40,1X,F10.6)') ' <Sx> = ',Sx
write(*,'(A40,1X,F10.6)') ' <Sy> = ',Sy
write(*,'(A40,1X,F10.6)') ' <Sz> = ',Sz
write(*,'(A40,1X,F10.6)') ' <Sx^2> = ',Sx2
write(*,'(A40,1X,F10.6)') ' <Sy^2> = ',Sy2
write(*,'(A40,1X,F10.6)') ' <Sz^2> = ',Sz2
write(*,'(A40,1X,F10.6)') ' <S^2> = ',Sx2+Sy2+Sz2
write(*,'(A60)') '---------------------------------------------'
write(*,'(A45)') ' Dipole moment (Debye) '
write(*,'(19X,4A10)') 'X','Y','Z','Tot.'
write(*,'(19X,4F10.4)') (dipole(ixyz)*auToD,ixyz=1,ncart),norm2(dipole)*auToD
write(*,'(A60)') '-------------------------------------------------'
write(*,'(A60)') '---------------------------------------------'
write(*,*)
! Print results
if(dump_orb) then
write(*,'(A50)') '-----------------------------------------'
write(*,'(A50)') 'UHF spin-up orbital coefficients '
write(*,'(A50)') '-----------------------------------------'
write(*,'(A40)') '-----------------------------------------'
write(*,'(A40)') 'UHF spin-up orbital coefficients '
write(*,'(A40)') '-----------------------------------------'
call matout(nBas,nBas,c(:,:,1))
write(*,*)
write(*,'(A50)') '-----------------------------------------'
write(*,'(A50)') 'UHF spin-down orbital coefficients '
write(*,'(A50)') '-----------------------------------------'
write(*,'(A40)') '-----------------------------------------'
write(*,'(A40)') 'UHF spin-down orbital coefficients '
write(*,'(A40)') '-----------------------------------------'
call matout(nBas,nBas,c(:,:,2))
write(*,*)
end if
write(*,'(A50)') '---------------------------------------'
write(*,'(A50)') ' UHF spin-up orbital energies '
write(*,'(A50)') '---------------------------------------'
call matout(nBas,1,e(:,1))
write(*,'(A40)') '---------------------------------------'
write(*,'(A40)') ' UHF spin-up orbital energies '
write(*,'(A40)') '---------------------------------------'
call vecout(nBas,eHF(:,1))
write(*,*)
write(*,'(A50)') '---------------------------------------'
write(*,'(A50)') ' UHF spin-down orbital energies '
write(*,'(A50)') '---------------------------------------'
call matout(nBas,1,e(:,2))
write(*,'(A40)') '---------------------------------------'
write(*,'(A40)') ' UHF spin-down orbital energies '
write(*,'(A40)') '---------------------------------------'
call vecout(nBas,eHF(:,2))
write(*,*)
end subroutine