From e68bd1f98a61c214f2a1b1913c3bdd98baa08509 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 3 Jul 2018 15:30:26 +0200 Subject: [PATCH] Added 1/c0^2 weight in selection --- plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f | 6 ++++ src/Determinants/EZFIO.cfg | 8 ++--- src/Determinants/density_matrix.irp.f | 34 ++++++++++++++++++-- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f b/plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f index 95759730..4d92e304 100644 --- a/plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f +++ b/plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f @@ -366,6 +366,12 @@ subroutine pt2_collector(zmq_socket_pull, E, b, tbc, comb, Ncomb, computed, pt2_ end if end do pullLoop + if (zmq_abort(zmq_to_qp_run_socket) == -1) then + call sleep(1) + if (zmq_abort(zmq_to_qp_run_socket) == -1) then + print *, irp_here, ': Error in sending abort signal (2)' + endif + endif if(tooth == comb_teeth+1) then pt2(pt2_stoch_istate) = sum(pt2_detail(pt2_stoch_istate,:)) diff --git a/src/Determinants/EZFIO.cfg b/src/Determinants/EZFIO.cfg index d55dd612..ecf3dd88 100644 --- a/src/Determinants/EZFIO.cfg +++ b/src/Determinants/EZFIO.cfg @@ -40,11 +40,11 @@ doc: Force the wave function to be an eigenfunction of S^2 interface: ezfio,provider,ocaml default: True -[use_l3_weight] -type: logical -doc: If true, set the state-averaged weight to 1/(Norm_L3(Psi)) +[used_weight] +type: integer +doc: 0: 1/(c_0^2), 1: 1/N_states, 2: input state-average weight, 3: 1/(Norm_L3(Psi)) interface: ezfio,provider,ocaml -default: False +default: 0 [threshold_generators] diff --git a/src/Determinants/density_matrix.irp.f b/src/Determinants/density_matrix.irp.f index ea32ece4..c7afebc6 100644 --- a/src/Determinants/density_matrix.irp.f +++ b/src/Determinants/density_matrix.irp.f @@ -365,7 +365,7 @@ end BEGIN_PROVIDER [ double precision, l3_weight, (N_states) ] implicit none BEGIN_DOC - ! Weight of the states in the selection : 1/(sum_i c_i^4) + ! Weight of the states in the selection : 1/(sum_i |c_i|^3) END_DOC integer :: i,k double precision :: c @@ -388,6 +388,30 @@ BEGIN_PROVIDER [ double precision, l3_weight, (N_states) ] END_PROVIDER +BEGIN_PROVIDER [ double precision, c0_weight, (N_states) ] + implicit none + BEGIN_DOC + ! Weight of the states in the selection : 1/c_0^2 + END_DOC + integer :: i,k + double precision :: c + do i=1,N_states + c0_weight(i) = 1.d-31 + c = maxval(psi_coef(:,i) * psi_coef(:,i)) + c0_weight(i) = 1.d0/c + c0_weight(i) = min(c0_weight(i), 100.d0) + enddo + if (mpi_master) then + print *, '' + print *, 'c0 weights' + print *, '----------' + print *, '' + print *, c0_weight(1:N_states) + print *, '' + endif + +END_PROVIDER + BEGIN_PROVIDER [ double precision, state_average_weight, (N_states) ] implicit none @@ -397,8 +421,12 @@ BEGIN_PROVIDER [ double precision, state_average_weight, (N_states) ] logical :: exists state_average_weight(:) = 1.d0 - if (use_l3_weight) then - state_average_weight(:) = l3_weight(:) + if (used_weight == 0) then + state_average_weight(:) = c0_weight(:) + else if (used_weight == 1) then + state_average_weight(:) = 1./N_states + else if (used_weight == 3) then + state_average_weight(:) = l3_weight else call ezfio_has_determinants_state_average_weight(exists) if (exists) then