10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-19 20:42:41 +01:00
quantum_package/plugins/Hartree_Fock/diagonalize_fock.irp.f

116 lines
3.4 KiB
Fortran
Raw Normal View History

2017-06-07 23:31:41 +02:00
BEGIN_PROVIDER [ double precision, diagonal_Fock_matrix_mo, (mo_tot_num) ]
2015-06-17 18:22:08 +02:00
&BEGIN_PROVIDER [ double precision, eigenvectors_Fock_matrix_mo, (ao_num_align,mo_tot_num) ]
implicit none
BEGIN_DOC
! Diagonal Fock matrix in the MO basis
END_DOC
2017-06-07 23:31:41 +02:00
integer :: i,j, m
2015-06-17 18:22:08 +02:00
integer :: liwork, lwork, n, info
2017-06-07 23:31:41 +02:00
integer, allocatable :: iwork(:), isuppz(:)
double precision, allocatable :: work(:), F(:,:), F2(:,:)
integer :: iorb,jorb
2015-06-17 18:22:08 +02:00
2017-06-07 21:56:46 +02:00
2017-06-07 23:31:41 +02:00
allocate( F(mo_tot_num,mo_tot_num),F2(mo_tot_num,mo_tot_num), isuppz(2*mo_tot_num) )
2017-06-07 21:56:46 +02:00
do j=1,mo_tot_num
do i=1,mo_tot_num
F(i,j) = Fock_matrix_mo(i,j)
enddo
enddo
if(no_oa_or_av_opt)then
do i = 1, n_act_orb
iorb = list_act(i)
2017-06-07 23:31:41 +02:00
ASSERT (iorb > 0)
ASSERT (iorb <= mo_tot_num)
2017-06-07 21:56:46 +02:00
do j = 1, n_inact_orb
jorb = list_inact(j)
2017-06-07 23:31:41 +02:00
ASSERT (jorb > 0)
ASSERT (jorb <= mo_tot_num)
2017-06-07 21:56:46 +02:00
F(iorb,jorb) = 0.d0
F(jorb,iorb) = 0.d0
2015-11-27 19:14:36 +01:00
enddo
2017-06-07 21:56:46 +02:00
do j = 1, n_virt_orb
jorb = list_virt(j)
2017-06-07 23:31:41 +02:00
ASSERT (jorb > 0)
ASSERT (jorb <= mo_tot_num)
2017-06-07 21:56:46 +02:00
F(iorb,jorb) = 0.d0
F(jorb,iorb) = 0.d0
2016-01-18 23:11:55 +01:00
enddo
2017-06-07 21:56:46 +02:00
do j = 1, n_core_orb
jorb = list_core(j)
2017-06-07 23:31:41 +02:00
ASSERT (jorb > 0)
ASSERT (jorb <= mo_tot_num)
2017-06-07 21:56:46 +02:00
F(iorb,jorb) = 0.d0
F(jorb,iorb) = 0.d0
2016-01-02 21:45:28 +01:00
enddo
2017-06-07 21:56:46 +02:00
enddo
2017-06-07 23:05:00 +02:00
endif
! Insert level shift here
do i = elec_beta_num+1, elec_alpha_num
F(i,i) += 0.5d0*level_shift
2015-06-17 18:22:08 +02:00
enddo
2017-06-07 23:05:00 +02:00
do i = elec_alpha_num+1, mo_tot_num
F(i,i) += level_shift
2015-06-17 18:22:08 +02:00
enddo
2017-06-07 23:05:00 +02:00
n = mo_tot_num
lwork = 1+6*n + 2*n*n
2017-06-07 23:31:41 +02:00
liwork = 10*n
2017-06-07 23:05:00 +02:00
allocate(work(lwork))
allocate(iwork(liwork) )
2017-06-07 23:31:41 +02:00
call dsyevr('V', 'A', 'U', mo_tot_num, F, size(F,1), &
-100.d0, 100.d0, 1, mo_tot_num, 0.d0, &
m, diagonal_Fock_matrix_mo, &
F2, size(F2,1), &
2017-06-07 23:05:00 +02:00
isuppz, work, lwork, iwork, liwork, info)
if (info /= 0) then
print *, irp_here//' DSYEV failed : ', info
stop 1
endif
2017-06-07 23:31:41 +02:00
call dgemm('N','N',ao_num,mo_tot_num,mo_tot_num, 1.d0, &
mo_coef, size(mo_coef,1), F2, size(F2,1), &
2017-06-07 23:05:00 +02:00
0.d0, eigenvectors_Fock_matrix_mo, size(eigenvectors_Fock_matrix_mo,1))
2017-06-07 23:31:41 +02:00
deallocate(work, F2, F)
deallocate(iwork, isuppz)
2017-06-07 23:05:00 +02:00
END_PROVIDER
BEGIN_PROVIDER [double precision, diagonal_Fock_matrix_mo_sum, (mo_tot_num)]
implicit none
BEGIN_DOC
! diagonal element of the fock matrix calculated as the sum over all the interactions
! with all the electrons in the RHF determinant
! diagonal_Fock_matrix_mo_sum(i) = sum_{j=1, N_elec} 2 J_ij -K_ij
END_DOC
integer :: i,j
double precision :: accu
do j = 1,elec_alpha_num
accu = 0.d0
do i = 1, elec_alpha_num
accu += 2.d0 * mo_bielec_integral_jj_from_ao(i,j) - mo_bielec_integral_jj_exchange_from_ao(i,j)
enddo
diagonal_Fock_matrix_mo_sum(j) = accu + mo_mono_elec_integral(j,j)
enddo
do j = elec_alpha_num+1,mo_tot_num
accu = 0.d0
do i = 1, elec_alpha_num
accu += 2.d0 * mo_bielec_integral_jj_from_ao(i,j) - mo_bielec_integral_jj_exchange_from_ao(i,j)
enddo
diagonal_Fock_matrix_mo_sum(j) = accu + mo_mono_elec_integral(j,j)
enddo
2015-06-17 18:22:08 +02:00
END_PROVIDER