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

fixed conf

This commit is contained in:
Abdallah Ammar 2023-11-16 13:24:24 +01:00
parent 8f6243e34e
commit d168ef88f4

View File

@ -41,10 +41,10 @@ subroutine print_GHF(nBas,nBas2,nO,eHF,C,P,S,ENuc,ET,EV,EJ,EK,EGHF,dipole)
double precision,allocatable :: Ca(:,:) double precision,allocatable :: Ca(:,:)
double precision,allocatable :: Cb(:,:) double precision,allocatable :: Cb(:,:)
double precision,allocatable :: Paa(:,:), Saa(:,:) double precision,allocatable :: Paa(:,:)
double precision,allocatable :: Pab(:,:), Sab(:,:) double precision,allocatable :: Pab(:,:)
double precision,allocatable :: Pba(:,:), Sba(:,:) double precision,allocatable :: Pba(:,:)
double precision,allocatable :: Pbb(:,:), Sbb(:,:) double precision,allocatable :: Pbb(:,:)
double precision,allocatable :: tmp(:,:) double precision,allocatable :: tmp(:,:)
double precision,allocatable :: Mx(:,:) double precision,allocatable :: Mx(:,:)
@ -80,6 +80,7 @@ subroutine print_GHF(nBas,nBas2,nO,eHF,C,P,S,ENuc,ET,EV,EJ,EK,EGHF,dipole)
Pba = matmul(transpose(Cb),matmul(S,Ca)) Pba = matmul(transpose(Cb),matmul(S,Ca))
Pbb = matmul(transpose(Cb),matmul(S,Cb)) Pbb = matmul(transpose(Cb),matmul(S,Cb))
! Compute components of S = (Sx,Sy,Sz) ! Compute components of S = (Sx,Sy,Sz)
Sx = 0.5d0*(trace_matrix(nO,Pab) + trace_matrix(nO,Pba)) Sx = 0.5d0*(trace_matrix(nO,Pab) + trace_matrix(nO,Pba))
@ -88,100 +89,51 @@ subroutine print_GHF(nBas,nBas2,nO,eHF,C,P,S,ENuc,ET,EV,EJ,EK,EGHF,dipole)
! Compute <S^2> = <Sx^2> + <Sy^2> + <Sz^2> ! Compute <S^2> = <Sx^2> + <Sy^2> + <Sz^2>
! Sx2 = 0.25d0*trace_matrix(nO,Paa+Pbb) + 0.25d0*trace_matrix(nO,Pab+Pba)**2 & Sx2 = 0.25d0*trace_matrix(nO,Paa+Pbb) + 0.25d0*trace_matrix(nO,Pab+Pba)**2 &
! - 0.5d0*trace_matrix(nO,matmul(Paa,Pbb) + matmul(Pab,Pab)) - 0.5d0*trace_matrix(nO,matmul(Paa,Pbb) + matmul(Pab,Pab))
! Sx2 = trace_matrix( Sy2 = 0.25d0*trace_matrix(nO,Paa+Pbb) - 0.25d0*trace_matrix(nO,Pab-Pba)**2 &
- 0.5d0*trace_matrix(nO,matmul(Paa,Pbb) - matmul(Pab,Pab))
! Sy2 = 0.25d0*trace_matrix(nO,Paa+Pbb) - 0.25d0*trace_matrix(nO,Pab-Pba)**2 & Sz2 = 0.25d0*trace_matrix(nO,Paa+Pbb) + 0.25d0*trace_matrix(nO,Paa-Pbb)**2 &
! - 0.5d0*trace_matrix(nO,matmul(Paa,Pbb) - matmul(Pab,Pab)) - 0.25d0*trace_matrix(nO,matmul(Paa,Paa) + matmul(Pbb,Pbb)) &
+ 0.25d0*trace_matrix(nO,matmul(Pab,Pba) + matmul(Pba,Pab))
S2 = Sz*(Sz+1d0) + trace_matrix(nO,Pbb) + 0.25d0*trace_matrix(nO,Paa+Pbb)
! Sz2 = 0.25d0*trace_matrix(nO,Paa+Pbb) + 0.25d0*trace_matrix(nO,Paa-Pbb)**2 & do i=1,nO
! - 0.25d0*trace_matrix(nO,matmul(Paa,Paa) + matmul(Pbb,Pbb)) & do j=1,nO
! + 0.25d0*trace_matrix(nO,matmul(Pab,Pba) + matmul(Pba,Pab)) S2 = S2 - 0.25d0*(Paa(i,j) - Pbb(i,j))**2 &
+ (Pba(i,i)*Pab(j,j) - Pba(i,j)*Pab(j,i))
end do
end do
print*,'<S^2> = ',S2
! S2 = Sz*(Sz+1d0) + trace_matrix(nO,Pbb) + 0.25d0*trace_matrix(nO,Paa+Pbb) ! na = 0.d0
! nb = 0.d0
! do i=1,nO ! do i = 1, nO
! do j=1,nO ! na = na + Paa(i,i)
! S2 = S2 - 0.25d0*(Paa(i,j) - Pbb(i,j))**2 & ! nb = nb + Pbb(i,i)
! + (Pba(i,i)*Pab(j,j) - Pba(i,j)*Pab(j,i)) ! enddo
! end do ! Sz = 0.5d0 * (na - nb)
! end do !
! print*,'<S^2> = ',S2 ! nonco_z = dble(nO)
! do j = 1, nO
! TODO ! do i = 1, nO
! check C size ! nonco_z = nonco_z - (Paa(i,j) - Pbb(i,j))**2
allocate(Ca(nBas,nBas), Cb(nBas,nBas)) ! enddo
do i = 1, nBas ! enddo
do j = 1, nBas ! nonco_z = 0.25d0 * nonco_z
Ca(j,i) = C(j, i) !
Cb(j,i) = C(j,nBas+i) ! Sz2 = Sz*Sz + nonco_z
enddo !
enddo ! contam_ghf = 0.d0
! do j = 1, nO
allocate(Saa(nBas,nBas),Sab(nBas,nBas),Sba(nBas,nBas),Sbb(nBas,nBas)) ! do i = 1, nO
allocate(tmp(nBas,nBas)) ! contam_ghf = contam_ghf - (Pab(i,i)*Pba(j,j) - Pab(i,j)*Pba(j,i))
! enddo
! Saa = Ca x Sao x Ca.T ! enddo
call dgemm("N", "N", nBas, nBas, nBas, 1.d0, Ca, size(Ca, 1), Sao, size(Sao, 1), 0.d0, tmp, size(tmp, 1)) ! S2 = Sz * (Sz + 1.d0) + nonco_z + contam_ghf
call dgemm("N", "T", nBas, nBas, nBas, 1.d0, tmp, size(tmp, 1), Ca, size(Ca, 1), 0.d0, Saa, size(Saa, 1))
! Sab = Ca x Sao x Cb.T
call dgemm("N", "N", nBas, nBas, nBas, 1.d0, Ca, size(Ca, 1), Sao, size(Sao, 1), 0.d0, tmp, size(tmp, 1))
call dgemm("N", "T", nBas, nBas, nBas, 1.d0, tmp, size(tmp, 1), Cb, size(Cb, 1), 0.d0, Sab, size(Sab, 1))
! Sba = Cb x Sao x Ca.T
! = Sab.T
Sba = transpose(Sab)
! Sbb = Cb x Sao x Cb.T
call dgemm("N", "N", nBas, nBas, nBas, 1.d0, Cb, size(Cb, 1), Sao, size(Sao, 1), 0.d0, tmp, size(tmp, 1))
call dgemm("N", "T", nBas, nBas, nBas, 1.d0, tmp, size(tmp, 1), Cb, size(Cb, 1), 0.d0, Sbb, size(Sbb, 1))
deallocate(tmp)
! TODO
! nO = nb of electrons ?
na = 0.d0
nb = 0.d0
do i = 1, nO
na = na + Saa(i,i)
nb = nb + Sbb(i,i)
enddo
nonco_z = dble(nO)
do j = 1, nO
do i = 1, nO
nonco_z = nonco_z - (Saa(i,j) - Sbb(i,j))**2
enddo
enddo
nonco_z = 0.25d0 * nonco_z
Sz = 0.5d0 * (na - nb)
Sz2 = Sz*Sz + nonco_z
! If Na > Nb
!contam_uhf = nb
!do j = 1, nO
! do i = 1, nO
! contam_uhf = contam_uhf - (Sab(i,j) - Sba(j,i))
! enddo
!enddo
!xy_perp = 0.d0
!do i = 1, nO
! xy_perp = xy_perp + (Sba(i,i))**2
!enddo
!S2 = Sz * (Sz + 1.d0) + nonco_z + contam_uhf + xy_perp
contam_ghf = 0.d0
do j = 1, nO
do i = 1, nO
contam_ghf = contam_ghf - (Sab(i,i)*Sba(j,j) - Sab(i,j)*Sba(j,i))
enddo
enddo
S2 = Sz * (Sz + 1.d0) + nonco_z + contam_ghf