2016-04-08 13:25:55 +02:00
|
|
|
|
|
|
|
BEGIN_PROVIDER [ integer, mrmode ]
|
|
|
|
&BEGIN_PROVIDER [ logical, old_lambda ]
|
|
|
|
&BEGIN_PROVIDER [ logical, no_mono_dressing ]
|
|
|
|
implicit none
|
|
|
|
CHARACTER(len=255) :: test
|
|
|
|
CALL get_environment_variable("OLD_LAMBDA", test)
|
|
|
|
old_lambda = trim(test) /= "" .and. trim(test) /= "0"
|
|
|
|
CALL get_environment_variable("NO_MONO_DRESSING", test)
|
|
|
|
no_mono_dressing = trim(test) /= "" .and. trim(test) /= "0"
|
|
|
|
print *, "old", old_lambda, "mono", no_mono_dressing
|
|
|
|
mrmode = 0
|
|
|
|
END_PROVIDER
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_PROVIDER [ double precision, lambda_mrcc_old, (N_states,psi_det_size) ]
|
|
|
|
&BEGIN_PROVIDER [ integer, lambda_mrcc_pt2_old, (0:psi_det_size) ]
|
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
cm/<Psi_0|H|D_m> or perturbative 1/Delta_E(m)
|
|
|
|
END_DOC
|
|
|
|
integer :: i,k
|
|
|
|
double precision :: ihpsi_current(N_states)
|
|
|
|
integer :: i_pert_count
|
|
|
|
double precision :: hii, lambda_pert
|
|
|
|
integer :: N_lambda_mrcc_pt2
|
|
|
|
double precision, parameter :: x = 2.d0
|
|
|
|
|
|
|
|
i_pert_count = 0
|
|
|
|
lambda_mrcc_old = 0.d0
|
|
|
|
N_lambda_mrcc_pt2 = 0
|
|
|
|
lambda_mrcc_pt2_old(0) = 0
|
|
|
|
|
|
|
|
do i=1,N_det_non_ref
|
|
|
|
call i_h_psi(psi_non_ref(1,1,i), psi_ref, psi_ref_coef, N_int, N_det_ref, &
|
|
|
|
size(psi_ref_coef,1), N_states,ihpsi_current)
|
|
|
|
call i_H_j(psi_non_ref(1,1,i),psi_non_ref(1,1,i),N_int,hii)
|
|
|
|
do k=1,N_states
|
|
|
|
if (ihpsi_current(k) == 0.d0) then
|
|
|
|
ihpsi_current(k) = 1.d-32
|
|
|
|
endif
|
|
|
|
lambda_mrcc_old(k,i) = psi_non_ref_coef(i,k)/ihpsi_current(k)
|
|
|
|
if ( dabs(psi_non_ref_coef(i,k)*ihpsi_current(k)) < 1.d-5 ) then
|
|
|
|
i_pert_count += 1
|
|
|
|
lambda_mrcc_old(k,i) = 0.d0
|
|
|
|
if (lambda_mrcc_pt2_old(N_lambda_mrcc_pt2) /= i) then
|
|
|
|
N_lambda_mrcc_pt2 += 1
|
|
|
|
lambda_mrcc_pt2_old(N_lambda_mrcc_pt2) = i
|
|
|
|
endif
|
|
|
|
! lambda_pert = 1.d0 / (psi_ref_energy_diagonalized(k)-hii)
|
|
|
|
! if((ihpsi_current(k) * lambda_pert) < 0.5d0 * psi_non_ref_coef_restart(i,k) ) then
|
|
|
|
! lambda_mrcc_old(k,i) = 0.d0
|
2016-04-07 17:54:13 +02:00
|
|
|
! endif
|
2016-04-08 13:25:55 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
if (lambda_mrcc_old(k,i) > x) then
|
|
|
|
lambda_mrcc_old(k,i) = x
|
|
|
|
else if (lambda_mrcc_old(k,i) < -x) then
|
|
|
|
lambda_mrcc_old(k,i) = -x
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
lambda_mrcc_pt2_old(0) = N_lambda_mrcc_pt2
|
|
|
|
|
|
|
|
print*,'N_det_non_ref = ',N_det_non_ref
|
|
|
|
print*,'Number of ignored determinants = ',i_pert_count
|
|
|
|
print*,'psi_coef_ref_ratio = ',psi_ref_coef(2,1)/psi_ref_coef(1,1)
|
|
|
|
print*,'lambda min/max = ',maxval(dabs(lambda_mrcc_old)), minval(dabs(lambda_mrcc_old))
|
|
|
|
|
|
|
|
END_PROVIDER
|
2016-04-07 17:54:13 +02:00
|
|
|
|
|
|
|
|
2016-04-01 23:33:58 +02:00
|
|
|
BEGIN_PROVIDER [ double precision, lambda_mrcc, (N_states,psi_det_size) ]
|
|
|
|
&BEGIN_PROVIDER [ integer, lambda_mrcc_pt2, (0:psi_det_size) ]
|
2016-03-31 10:51:09 +02:00
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! cm/<Psi_0|H|D_m> or perturbative 1/Delta_E(m)
|
|
|
|
END_DOC
|
2016-03-31 16:48:23 +02:00
|
|
|
integer :: i,k
|
2016-03-30 21:33:38 +02:00
|
|
|
double precision :: ihpsi_current(N_states)
|
2016-04-01 23:33:58 +02:00
|
|
|
integer :: i_pert_count
|
|
|
|
double precision :: hii, lambda_pert
|
|
|
|
integer :: N_lambda_mrcc_pt2
|
2016-04-08 13:25:55 +02:00
|
|
|
|
|
|
|
if(old_lambda) then
|
|
|
|
lambda_mrcc = lambda_mrcc_old
|
|
|
|
lambda_mrcc_pt2 = lambda_mrcc_pt2_old
|
|
|
|
else
|
|
|
|
i_pert_count = 0
|
|
|
|
lambda_mrcc = 0.d0
|
|
|
|
N_lambda_mrcc_pt2 = 0
|
|
|
|
lambda_mrcc_pt2(0) = 0
|
2016-03-31 16:48:23 +02:00
|
|
|
|
|
|
|
do i=1,N_det_non_ref
|
2016-04-07 11:13:14 +02:00
|
|
|
call i_h_psi(psi_non_ref(1,1,i), psi_ref, psi_ref_coef, N_int, N_det_ref,&
|
2016-03-31 16:48:23 +02:00
|
|
|
size(psi_ref_coef,1), N_states,ihpsi_current)
|
|
|
|
call i_H_j(psi_non_ref(1,1,i),psi_non_ref(1,1,i),N_int,hii)
|
|
|
|
do k=1,N_states
|
|
|
|
if (ihpsi_current(k) == 0.d0) then
|
|
|
|
ihpsi_current(k) = 1.d-32
|
|
|
|
endif
|
|
|
|
lambda_mrcc(k,i) = min(0.d0,psi_non_ref_coef(i,k)/ihpsi_current(k) )
|
|
|
|
lambda_pert = 1.d0 / (psi_ref_energy_diagonalized(k)-hii)
|
2016-04-01 01:31:11 +02:00
|
|
|
if (lambda_pert / lambda_mrcc(k,i) < 0.5d0) then
|
2016-03-31 16:48:23 +02:00
|
|
|
i_pert_count += 1
|
|
|
|
lambda_mrcc(k,i) = 0.d0
|
2016-04-01 23:33:58 +02:00
|
|
|
if (lambda_mrcc_pt2(N_lambda_mrcc_pt2) /= i) then
|
|
|
|
N_lambda_mrcc_pt2 += 1
|
|
|
|
lambda_mrcc_pt2(N_lambda_mrcc_pt2) = i
|
|
|
|
endif
|
2016-03-31 16:48:23 +02:00
|
|
|
endif
|
|
|
|
enddo
|
2016-03-31 10:51:09 +02:00
|
|
|
enddo
|
2016-04-01 23:33:58 +02:00
|
|
|
lambda_mrcc_pt2(0) = N_lambda_mrcc_pt2
|
2016-04-08 13:25:55 +02:00
|
|
|
end if
|
2016-03-31 16:48:23 +02:00
|
|
|
|
2016-03-30 21:33:38 +02:00
|
|
|
print*,'N_det_non_ref = ',N_det_non_ref
|
2016-04-08 13:25:55 +02:00
|
|
|
!print*,'Number of ignored determinants = ',i_pert_count
|
2016-03-30 21:33:38 +02:00
|
|
|
print*,'psi_coef_ref_ratio = ',psi_ref_coef(2,1)/psi_ref_coef(1,1)
|
2016-03-31 16:48:23 +02:00
|
|
|
print*,'lambda max = ',maxval(dabs(lambda_mrcc))
|
2015-09-08 15:29:05 +02:00
|
|
|
|
2015-04-01 13:23:02 +02:00
|
|
|
END_PROVIDER
|
|
|
|
|
2015-04-03 14:26:14 +02:00
|
|
|
|
2016-03-31 16:48:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-29 10:35:29 +02:00
|
|
|
|
2016-03-29 23:18:26 +02:00
|
|
|
BEGIN_PROVIDER [ double precision, hij_mrcc, (N_det_non_ref,N_det_ref) ]
|
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! < ref | H | Non-ref > matrix
|
|
|
|
END_DOC
|
|
|
|
integer :: i_I, k_sd
|
|
|
|
do i_I=1,N_det_ref
|
|
|
|
do k_sd=1,N_det_non_ref
|
|
|
|
call i_h_j(psi_ref(1,1,i_I),psi_non_ref(1,1,k_sd),N_int,hij_mrcc(k_sd,i_I))
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
|
|
|
END_PROVIDER
|
|
|
|
|
|
|
|
BEGIN_PROVIDER [ double precision, delta_ij, (N_states,N_det_non_ref,N_det_ref) ]
|
|
|
|
&BEGIN_PROVIDER [ double precision, delta_ii, (N_states,N_det_ref) ]
|
2015-04-03 14:26:14 +02:00
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! Dressing matrix in N_det basis
|
|
|
|
END_DOC
|
|
|
|
integer :: i,j,m
|
|
|
|
delta_ij = 0.d0
|
2015-07-03 18:50:07 +02:00
|
|
|
delta_ii = 0.d0
|
2016-03-29 23:18:26 +02:00
|
|
|
call H_apply_mrcc(delta_ij,delta_ii,N_states,N_det_non_ref,N_det_ref)
|
2015-04-03 14:26:14 +02:00
|
|
|
END_PROVIDER
|
|
|
|
|
2015-07-03 18:50:07 +02:00
|
|
|
BEGIN_PROVIDER [ double precision, h_matrix_dressed, (N_det,N_det,N_states) ]
|
2015-04-03 14:26:14 +02:00
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! Dressed H with Delta_ij
|
|
|
|
END_DOC
|
2015-07-03 18:50:07 +02:00
|
|
|
integer :: i, j,istate,ii,jj
|
|
|
|
do istate = 1,N_states
|
|
|
|
do j=1,N_det
|
|
|
|
do i=1,N_det
|
|
|
|
h_matrix_dressed(i,j,istate) = h_matrix_all_dets(i,j)
|
|
|
|
enddo
|
2015-04-03 14:26:14 +02:00
|
|
|
enddo
|
2015-07-13 18:00:38 +02:00
|
|
|
do ii = 1, N_det_ref
|
|
|
|
i =idx_ref(ii)
|
2016-03-29 23:18:26 +02:00
|
|
|
h_matrix_dressed(i,i,istate) += delta_ii(istate,ii)
|
2015-07-13 18:00:38 +02:00
|
|
|
do jj = 1, N_det_non_ref
|
2015-07-20 13:35:38 +02:00
|
|
|
j =idx_non_ref(jj)
|
2016-03-29 23:18:26 +02:00
|
|
|
h_matrix_dressed(i,j,istate) += delta_ij(istate,jj,ii)
|
|
|
|
h_matrix_dressed(j,i,istate) += delta_ij(istate,jj,ii)
|
2015-07-03 18:50:07 +02:00
|
|
|
enddo
|
|
|
|
enddo
|
2015-04-03 14:26:14 +02:00
|
|
|
enddo
|
|
|
|
END_PROVIDER
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_PROVIDER [ double precision, CI_electronic_energy_dressed, (N_states_diag) ]
|
|
|
|
&BEGIN_PROVIDER [ double precision, CI_eigenvectors_dressed, (N_det,N_states_diag) ]
|
|
|
|
&BEGIN_PROVIDER [ double precision, CI_eigenvectors_s2_dressed, (N_states_diag) ]
|
2015-07-03 14:42:55 +02:00
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! Eigenvectors/values of the CI matrix
|
|
|
|
END_DOC
|
|
|
|
integer :: i,j
|
|
|
|
|
|
|
|
do j=1,N_states_diag
|
|
|
|
do i=1,N_det
|
|
|
|
CI_eigenvectors_dressed(i,j) = psi_coef(i,j)
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
|
|
|
if (diag_algorithm == "Davidson") then
|
|
|
|
|
|
|
|
integer :: istate
|
|
|
|
istate = 1
|
|
|
|
call davidson_diag_mrcc(psi_det,CI_eigenvectors_dressed,CI_electronic_energy_dressed,&
|
|
|
|
size(CI_eigenvectors_dressed,1),N_det,N_states_diag,N_int,output_determinants,istate)
|
|
|
|
|
|
|
|
else if (diag_algorithm == "Lapack") then
|
|
|
|
|
|
|
|
double precision, allocatable :: eigenvectors(:,:), eigenvalues(:)
|
|
|
|
allocate (eigenvectors(size(H_matrix_dressed,1),N_det))
|
|
|
|
allocate (eigenvalues(N_det))
|
|
|
|
call lapack_diag(eigenvalues,eigenvectors, &
|
|
|
|
H_matrix_dressed,size(H_matrix_dressed,1),N_det)
|
|
|
|
CI_electronic_energy_dressed(:) = 0.d0
|
|
|
|
do i=1,N_det
|
2015-04-03 14:26:14 +02:00
|
|
|
CI_eigenvectors_dressed(i,1) = eigenvectors(i,1)
|
2015-07-03 14:42:55 +02:00
|
|
|
enddo
|
|
|
|
integer :: i_state
|
|
|
|
double precision :: s2
|
|
|
|
i_state = 0
|
|
|
|
if (s2_eig) then
|
|
|
|
do j=1,N_det
|
|
|
|
call get_s2_u0(psi_det,eigenvectors(1,j),N_det,N_det,s2)
|
|
|
|
if(dabs(s2-expected_s2).le.0.3d0)then
|
|
|
|
i_state += 1
|
|
|
|
do i=1,N_det
|
|
|
|
CI_eigenvectors_dressed(i,i_state) = eigenvectors(i,j)
|
|
|
|
enddo
|
|
|
|
CI_electronic_energy_dressed(i_state) = eigenvalues(j)
|
|
|
|
CI_eigenvectors_s2_dressed(i_state) = s2
|
|
|
|
endif
|
|
|
|
if (i_state.ge.N_states_diag) then
|
|
|
|
exit
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
else
|
|
|
|
do j=1,N_states_diag
|
|
|
|
call get_s2_u0(psi_det,eigenvectors(1,j),N_det,N_det,s2)
|
|
|
|
i_state += 1
|
|
|
|
do i=1,N_det
|
|
|
|
CI_eigenvectors_dressed(i,i_state) = eigenvectors(i,j)
|
|
|
|
enddo
|
|
|
|
CI_electronic_energy_dressed(i_state) = eigenvalues(j)
|
|
|
|
CI_eigenvectors_s2_dressed(i_state) = s2
|
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
deallocate(eigenvectors,eigenvalues)
|
|
|
|
endif
|
|
|
|
|
2015-04-03 14:26:14 +02:00
|
|
|
END_PROVIDER
|
|
|
|
|
|
|
|
BEGIN_PROVIDER [ double precision, CI_energy_dressed, (N_states_diag) ]
|
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! N_states lowest eigenvalues of the dressed CI matrix
|
|
|
|
END_DOC
|
|
|
|
|
|
|
|
integer :: j
|
|
|
|
character*(8) :: st
|
2015-04-20 10:12:08 +02:00
|
|
|
call write_time(output_determinants)
|
2015-04-03 14:26:14 +02:00
|
|
|
do j=1,N_states_diag
|
|
|
|
CI_energy_dressed(j) = CI_electronic_energy_dressed(j) + nuclear_repulsion
|
|
|
|
enddo
|
|
|
|
|
|
|
|
END_PROVIDER
|
|
|
|
|
2016-03-30 21:33:38 +02:00
|
|
|
subroutine diagonalize_CI_dressed(lambda)
|
2015-04-09 21:46:37 +02:00
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! Replace the coefficients of the CI states by the coefficients of the
|
|
|
|
! eigenstates of the CI matrix
|
|
|
|
END_DOC
|
2016-03-30 21:33:38 +02:00
|
|
|
double precision, intent(in) :: lambda
|
2015-04-09 21:46:37 +02:00
|
|
|
integer :: i,j
|
|
|
|
do j=1,N_states_diag
|
|
|
|
do i=1,N_det
|
2016-03-30 21:33:38 +02:00
|
|
|
psi_coef(i,j) = lambda * CI_eigenvectors_dressed(i,j) + (1.d0 - lambda) * psi_coef(i,j)
|
2015-04-09 21:46:37 +02:00
|
|
|
enddo
|
2016-03-30 21:33:38 +02:00
|
|
|
call normalize(psi_coef(1,j), N_det)
|
2015-04-09 21:46:37 +02:00
|
|
|
enddo
|
|
|
|
SOFT_TOUCH psi_coef
|
|
|
|
|
|
|
|
end
|