From a82cbdb22e50ce6a3d04ad1b5f9953048f2075c4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 8 Jan 2019 19:02:04 +0100 Subject: [PATCH] Fixed fci --- src/cipsi/pt2_stoch_routines.irp.f | 2 -- src/cipsi/stochastic_cipsi.irp.f | 19 +++++++++---------- src/iterations/print_summary.irp.f | 14 +++++++------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index 8fc780a7..1e1d895d 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -257,8 +257,6 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) call make_selection_buffer_s2(b) endif call fill_H_apply_buffer_no_selection(b%cur,b%det,N_int,0) - call copy_H_apply_buffer_to_wf() - call save_wavefunction endif call delete_selection_buffer(b) diff --git a/src/cipsi/stochastic_cipsi.irp.f b/src/cipsi/stochastic_cipsi.irp.f index 7913e7fc..64822dcd 100644 --- a/src/cipsi/stochastic_cipsi.irp.f +++ b/src/cipsi/stochastic_cipsi.irp.f @@ -5,7 +5,7 @@ subroutine run_stochastic_cipsi END_DOC integer :: i,j,k double precision, allocatable :: pt2(:), variance(:), norm(:), rpt2(:) - integer :: N_det_before, N_occ_pattern_before, to_select + integer :: to_select double precision :: rss double precision, external :: memory_of_double @@ -52,9 +52,6 @@ subroutine run_stochastic_cipsi call save_wavefunction endif - N_det_before = 0 - N_occ_pattern_before = 0 - double precision :: correlation_energy_ratio double precision :: error(N_states) @@ -68,8 +65,6 @@ subroutine run_stochastic_cipsi write(*,'(A)') '--------------------------------------------------------------------------------' - N_det_before = N_det - N_occ_pattern_before = N_occ_pattern to_select = N_det to_select = max(N_states_diag, to_select) @@ -77,7 +72,7 @@ subroutine run_stochastic_cipsi variance = 0.d0 norm = 0.d0 call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, & - norm, to_select) ! Stochastic PT2 + norm, to_select) ! Stochastic PT2 and selection correlation_energy_ratio = (psi_energy_with_nucl_rep(1) - hf_energy_ref) / & (psi_energy_with_nucl_rep(1) + pt2(1) - hf_energy_ref) @@ -85,16 +80,20 @@ subroutine run_stochastic_cipsi call save_energy(psi_energy_with_nucl_rep, pt2) call write_double(6,correlation_energy_ratio, 'Correlation ratio') - call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det_before,N_occ_pattern_before) + call print_summary(psi_energy_with_nucl_rep,pt2,error,variance,norm,N_det,N_occ_pattern,N_states) do k=1,N_states rpt2(:) = pt2(:)/(1.d0 + norm(k)) enddo - call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det_before) + call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det) call print_extrapolated_energy() N_iter += 1 + ! Add selected determinants + call copy_H_apply_buffer_to_wf() + call save_wavefunction + PROVIDE psi_coef PROVIDE psi_det PROVIDE psi_det_sorted @@ -123,7 +122,7 @@ subroutine run_stochastic_cipsi rpt2(:) = pt2(:)/(1.d0 + norm(k)) enddo - call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern) + call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern,N_states) call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det) call print_extrapolated_energy() diff --git a/src/iterations/print_summary.irp.f b/src/iterations/print_summary.irp.f index 0467b4a3..a524cfa8 100644 --- a/src/iterations/print_summary.irp.f +++ b/src/iterations/print_summary.irp.f @@ -1,16 +1,16 @@ -subroutine print_summary(e_,pt2_,error_,variance_,norm_,n_det_,n_occ_pattern_) +subroutine print_summary(e_,pt2_,error_,variance_,norm_,n_det_,n_occ_pattern_,n_st) implicit none BEGIN_DOC ! Print the extrapolated energy in the output END_DOC - double precision, intent(in) :: e_(N_states), pt2_(N_states), variance_(N_states), norm_(N_states), error_(N_states) - integer, intent(in) :: n_det_, n_occ_pattern_ + integer, intent(in) :: n_det_, n_occ_pattern_, n_st + double precision, intent(in) :: e_(n_st), pt2_(n_st), variance_(n_st), norm_(n_st), error_(n_st) integer :: i, k integer :: N_states_p character*(9) :: pt2_string character*(512) :: fmt - double precision :: f(N_states) + double precision :: f(n_st) if (do_pt2) then pt2_string = ' ' @@ -18,7 +18,7 @@ subroutine print_summary(e_,pt2_,error_,variance_,norm_,n_det_,n_occ_pattern_) pt2_string = '(approx)' endif - N_states_p = min(N_det_,N_states) + N_states_p = min(N_det_,n_st) do i=1,N_states_p f(i) = 1.d0/(1.d0+norm_(i)) @@ -57,7 +57,7 @@ subroutine print_summary(e_,pt2_,error_,variance_,norm_,n_det_,n_occ_pattern_) print *, '' print *, 'N_det = ', N_det_ - print *, 'N_states = ', N_states + print *, 'N_states = ', n_st if (s2_eig) then print *, 'N_sop = ', N_occ_pattern_ endif @@ -76,7 +76,7 @@ subroutine print_summary(e_,pt2_,error_,variance_,norm_,n_det_,n_occ_pattern_) enddo print *, '-----' - if(N_states.gt.1)then + if(n_st.gt.1)then print *, 'Variational Energy difference (au | eV)' do i=2, N_states_p print*,'Delta E = ', (e_(i) - e_(1)), &