From 03b8f353bd94b837c02e570a8d3fb68689003135 Mon Sep 17 00:00:00 2001 From: Yann Garniron Date: Tue, 4 Sep 2018 14:41:46 +0200 Subject: [PATCH] teeth building check for pt2_stoch --- plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f | 51 ++++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f b/plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f index d5291a80..16ca17b6 100644 --- a/plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f +++ b/plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f @@ -12,20 +12,61 @@ END_PROVIDER &BEGIN_PROVIDER [ integer, pt2_n_tasks_max ] &BEGIN_PROVIDER [ integer, pt2_F, (N_det_generators) ] implicit none + logical, external :: testTeethBuilding pt2_F(:) = 1 - pt2_F(:N_det_generators/100 + 1) = 1 - pt2_n_tasks_max = N_det_generators/100 + 1 + !pt2_F(:N_det_generators/1000*0+50) = 1 + pt2_n_tasks_max = 16 ! N_det_generators/100 + 1 - if(N_det_generators < 256) then + if(N_det_generators < 1024) then pt2_minDetInFirstTeeth = 1 pt2_N_teeth = 1 else - pt2_minDetInFirstTeeth = 5 - pt2_N_teeth = 16 + do pt2_N_teeth=32,1,-1 + pt2_minDetInFirstTeeth = min(5, N_det_generators) + if(testTeethBuilding(pt2_minDetInFirstTeeth, pt2_N_teeth)) exit + end do end if END_PROVIDER +logical function testTeethBuilding(minF, N) + implicit none + integer, intent(in) :: minF, N + integer :: n0, i + double precision :: u0, Wt, r + + double precision, allocatable :: tilde_w(:), tilde_cW(:) + integer, external :: dress_find_sample + + allocate(tilde_w(N_det_generators), tilde_cW(0:N_det_generators)) + + tilde_cW(0) = 0d0 + do i=1,N_det_generators + tilde_w(i) = psi_coef_generators(i,pt2_stoch_istate)**2 + tilde_cW(i) = tilde_cW(i-1) + tilde_w(i) + enddo + tilde_cW(N_det_generators) = 1d0 + + n0 = 0 + do + u0 = tilde_cW(n0) + r = tilde_cW(n0 + minF) + Wt = (1d0 - u0) / dble(N) + if(Wt >= r - u0) then + testTeethBuilding = .true. + return + end if + n0 += 1 + if(N_det_generators - n0 < minF * N) then + testTeethBuilding = .false. + return + end if + end do + stop "exited testTeethBuilding" +end function + + + subroutine ZMQ_pt2(E, pt2,relative_error, absolute_error, error) use f77_zmq use selection_types