From fb07e986c9b251eac32dda63cdc87260f7f14e0b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 11 Feb 2021 01:03:24 +0100 Subject: [PATCH 1/5] Improving weights --- src/cipsi/pt2_stoch_routines.irp.f | 2 +- src/cipsi/selection.irp.f | 4 +-- src/cipsi/selection_weight.irp.f | 58 +++++++++++++++++++----------- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index 428285c2..489ffaaf 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -352,9 +352,9 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) state_average_weight(:) = state_average_weight_save(:) TOUCH state_average_weight + call update_pt2_and_variance_weights(pt2_data, N_states) endif - call update_pt2_and_variance_weights(pt2_data, N_states) end subroutine diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index 5f331fef..5afb514e 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -648,7 +648,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d do_cycle = .True. do k=1,N_dominant_dets_of_cfgs call get_excitation_degree(dominant_dets_of_cfgs(1,1,k),det(1,1),degree,N_int) - do_cycle = do_cycle .and. (degree > excitation_alpha_max) + do_cycle = do_cycle .and. (degree > excitation_alpha_max) enddo if (do_cycle) cycle endif @@ -658,7 +658,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d do_cycle = .True. do k=1,N_dominant_dets_of_cfgs call get_excitation_degree(dominant_dets_of_cfgs(1,1,k),det(1,1),degree,N_int) - do_cycle = do_cycle .and. (degree > excitation_beta_max) + do_cycle = do_cycle .and. (degree > excitation_beta_max) enddo if (do_cycle) cycle endif diff --git a/src/cipsi/selection_weight.irp.f b/src/cipsi/selection_weight.irp.f index 24e2ace0..fb317f9b 100644 --- a/src/cipsi/selection_weight.irp.f +++ b/src/cipsi/selection_weight.irp.f @@ -33,43 +33,59 @@ subroutine update_pt2_and_variance_weights(pt2_data, N_st) double precision :: avg, element, dt, x integer :: k - integer, save :: i_iter=0 - integer, parameter :: i_itermax = 1 - double precision, allocatable, save :: memo_variance(:,:), memo_pt2(:,:) +! integer, save :: i_iter=0 +! integer, parameter :: i_itermax = 1 +! double precision, allocatable, save :: memo_variance(:,:), memo_pt2(:,:) pt2(:) = pt2_data % pt2(:) variance(:) = pt2_data % variance(:) - if (i_iter == 0) then - allocate(memo_variance(N_st,i_itermax), memo_pt2(N_st,i_itermax)) - memo_pt2(:,:) = 1.d0 - memo_variance(:,:) = 1.d0 - endif +! if (i_iter == 0) then +! allocate(memo_variance(N_st,i_itermax), memo_pt2(N_st,i_itermax)) +! memo_pt2(:,:) = 1.d0 +! memo_variance(:,:) = 1.d0 +! endif +! +! i_iter = i_iter+1 +! if (i_iter > i_itermax) then +! i_iter = 1 +! endif +! +! dt = 2.0d0 - i_iter = i_iter+1 - if (i_iter > i_itermax) then - i_iter = 1 - endif + avg = sum(pt2(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero +! do k=1,N_st +! element = exp(dt*(pt2(k)/avg -1.d0)) +! element = min(2.0d0 , element) +! element = max(0.5d0 , element) +! memo_pt2(k,i_iter) = element +! pt2_match_weight(k) *= product(memo_pt2(k,:)) + !enddo - dt = 2.0d0 - - avg = sum(pt2(1:N_st)) / dble(N_st) - 1.d-32 ! Avoid future division by zero + dt = 1.0d0 * selection_factor do k=1,N_st - element = exp(dt*(pt2(k)/avg -1.d0)) + element = exp(dt*(pt2(k)/avg - 1.d0)) element = min(2.0d0 , element) element = max(0.5d0 , element) - memo_pt2(k,i_iter) = element - pt2_match_weight(k) *= product(memo_pt2(k,:)) + print *, k, element + pt2_match_weight(k) *= element enddo avg = sum(variance(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero +! do k=1,N_st +! element = exp(dt*(variance(k)/avg -1.d0)) +! element = min(2.0d0 , element) +! element = max(0.5d0 , element) +! memo_variance(k,i_iter) = element +! variance_match_weight(k) *= product(memo_variance(k,:)) +! enddo + do k=1,N_st element = exp(dt*(variance(k)/avg -1.d0)) element = min(2.0d0 , element) element = max(0.5d0 , element) - memo_variance(k,i_iter) = element - variance_match_weight(k) *= product(memo_variance(k,:)) + variance_match_weight(k) *= element enddo if (N_det < 100) then @@ -78,6 +94,8 @@ subroutine update_pt2_and_variance_weights(pt2_data, N_st) variance_match_weight(:) = 1.d0 endif +print *, 'XXX', n_det, pt2_match_weight(1), pt2_match_weight(2) + threshold_davidson_pt2 = min(1.d-6, & max(threshold_davidson, 1.e-1 * PT2_relative_error * minval(abs(pt2(1:N_states)))) ) From 13fa8d19b61ddaf2a10f992d3c4dfcf3fe795065 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 13 Feb 2021 16:19:36 +0100 Subject: [PATCH 2/5] Improved weights in selection --- src/cipsi/selection_weight.irp.f | 36 +------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/src/cipsi/selection_weight.irp.f b/src/cipsi/selection_weight.irp.f index fb317f9b..fb05263a 100644 --- a/src/cipsi/selection_weight.irp.f +++ b/src/cipsi/selection_weight.irp.f @@ -33,53 +33,21 @@ subroutine update_pt2_and_variance_weights(pt2_data, N_st) double precision :: avg, element, dt, x integer :: k -! integer, save :: i_iter=0 -! integer, parameter :: i_itermax = 1 -! double precision, allocatable, save :: memo_variance(:,:), memo_pt2(:,:) - pt2(:) = pt2_data % pt2(:) variance(:) = pt2_data % variance(:) -! if (i_iter == 0) then -! allocate(memo_variance(N_st,i_itermax), memo_pt2(N_st,i_itermax)) -! memo_pt2(:,:) = 1.d0 -! memo_variance(:,:) = 1.d0 -! endif -! -! i_iter = i_iter+1 -! if (i_iter > i_itermax) then -! i_iter = 1 -! endif -! -! dt = 2.0d0 - avg = sum(pt2(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero -! do k=1,N_st -! element = exp(dt*(pt2(k)/avg -1.d0)) -! element = min(2.0d0 , element) -! element = max(0.5d0 , element) -! memo_pt2(k,i_iter) = element -! pt2_match_weight(k) *= product(memo_pt2(k,:)) - !enddo - dt = 1.0d0 * selection_factor + dt = 2.d0 !* selection_factor do k=1,N_st element = exp(dt*(pt2(k)/avg - 1.d0)) element = min(2.0d0 , element) element = max(0.5d0 , element) - print *, k, element pt2_match_weight(k) *= element enddo avg = sum(variance(1:N_st)) / dble(N_st) + 1.d-32 ! Avoid future division by zero -! do k=1,N_st -! element = exp(dt*(variance(k)/avg -1.d0)) -! element = min(2.0d0 , element) -! element = max(0.5d0 , element) -! memo_variance(k,i_iter) = element -! variance_match_weight(k) *= product(memo_variance(k,:)) -! enddo do k=1,N_st element = exp(dt*(variance(k)/avg -1.d0)) @@ -94,8 +62,6 @@ subroutine update_pt2_and_variance_weights(pt2_data, N_st) variance_match_weight(:) = 1.d0 endif -print *, 'XXX', n_det, pt2_match_weight(1), pt2_match_weight(2) - threshold_davidson_pt2 = min(1.d-6, & max(threshold_davidson, 1.e-1 * PT2_relative_error * minval(abs(pt2(1:N_states)))) ) From 7fba8972782c8f8f476cec178c1b60308496315b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 13 Feb 2021 16:19:48 +0100 Subject: [PATCH 3/5] Modernize openmp --- src/cipsi/slave_cipsi.irp.f | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cipsi/slave_cipsi.irp.f b/src/cipsi/slave_cipsi.irp.f index 4c5d8fca..b2abe356 100644 --- a/src/cipsi/slave_cipsi.irp.f +++ b/src/cipsi/slave_cipsi.irp.f @@ -4,7 +4,7 @@ subroutine run_slave_cipsi ! Helper program for distributed parallelism END_DOC - call omp_set_nested(.false.) + call omp_set_max_active_levels(1) distributed_davidson = .False. read_wf = .False. SOFT_TOUCH read_wf distributed_davidson @@ -171,9 +171,9 @@ subroutine run_slave_main call write_double(6,(t1-t0),'Broadcast time') !--- - call omp_set_nested(.True.) + call omp_set_max_active_levels(8) call davidson_slave_tcp(0) - call omp_set_nested(.False.) + call omp_set_max_active_levels(1) print *, mpi_rank, ': Davidson done' !--- From 7560e2762dd01ddab2f150484f6522d73b9cf1c1 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 13 Feb 2021 16:20:03 +0100 Subject: [PATCH 4/5] Fix bug with dominant_cfg --- src/determinants/configurations.irp.f | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/determinants/configurations.irp.f b/src/determinants/configurations.irp.f index 0171adf4..7e2881b4 100644 --- a/src/determinants/configurations.irp.f +++ b/src/determinants/configurations.irp.f @@ -547,9 +547,14 @@ BEGIN_PROVIDER [ integer, dominant_cfg, (N_states) ] ! Configuration of the determinants with the largest weight, for each state END_DOC integer :: k - do k=1,N_states - dominant_cfg(k) = det_to_configuration(dominant_det(k)) - enddo + dominant_cfg(1) = det_to_configuration(dominant_det(1)) + if (N_det < N_states) then + dominant_cfg(:) = dominant_cfg(1) + else + do k=1,N_states + dominant_cfg(k) = det_to_configuration(dominant_det(k)) + enddo + endif END_PROVIDER From 9cce1a98e732e111e9ed6e5df158ce4aa99949cf Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 15 Feb 2021 13:37:33 +0100 Subject: [PATCH 5/5] bump ocaml version --- configure | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 63a041fa..391f5384 100755 --- a/configure +++ b/configure @@ -319,8 +319,8 @@ EOF rm ${QP_ROOT}/external/opam_installer.sh # source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true # -# opam switch create ocaml-base-compiler.4.10.0 - opam init --verbose --yes --compiler=4.10.0 --disable-sandboxing +# opam switch create ocaml-base-compiler.4.11.1 + opam init --verbose --yes --compiler=4.11.1 --disable-sandboxing eval $(opam env) opam install -y ${OCAML_PACKAGES} || exit 1 @@ -339,9 +339,9 @@ EOF EOF rm ${QP_ROOT}/external/opam_installer.sh # source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true -# opam switch create ocaml-base-compiler.4.10.0 || exit 1 +# opam switch create ocaml-base-compiler.4.11.1 || exit 1 - opam init --verbose --yes --compiler=4.10.0 --disable-sandboxing + opam init --verbose --yes --compiler=4.11.1 --disable-sandboxing eval $(opam env) execute << EOF opam install -y \${OCAML_PACKAGES} || exit 1