From 5e7978304d5a258aa49905813c3205d08e2f2d88 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 11 Jan 2022 11:25:48 +0100 Subject: [PATCH 01/79] Documentation --- src/two_body_rdm/two_e_dm_mo.irp.f | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/two_body_rdm/two_e_dm_mo.irp.f b/src/two_body_rdm/two_e_dm_mo.irp.f index 4dadd2e6..a4dea15f 100644 --- a/src/two_body_rdm/two_e_dm_mo.irp.f +++ b/src/two_body_rdm/two_e_dm_mo.irp.f @@ -1,9 +1,8 @@ BEGIN_PROVIDER [double precision, two_e_dm_mo, (mo_num,mo_num,mo_num,mo_num)] implicit none BEGIN_DOC - ! two_e_dm_bb_mo(i,j,k,l,istate) = STATE SPECIFIC physicist notation for 2RDM of beta/beta electrons - ! - ! + ! \sum_{\sigma \sigma'} + ! ! ! where the indices (i,j,k,l) belong to all MOs. ! @@ -12,7 +11,7 @@ BEGIN_PROVIDER [double precision, two_e_dm_mo, (mo_num,mo_num,mo_num,mo_num)] ! !!!!! WARNING !!!!! IF "no_core_density" then all elements involving at least one CORE MO are set to zero ! The state-averaged two-electron energy : ! - ! \sum_{i,j,k,l = 1, mo_num} two_e_dm_mo(i,j,k,l) * < ii jj | kk ll > + ! \sum_{i,j,k,l = 1, mo_num} two_e_dm_mo(i,j,k,l) * < kk ll | ii jj > END_DOC two_e_dm_mo = 0.d0 integer :: i,j,k,l,iorb,jorb,korb,lorb,istate From 188ccf0d06579319346ca7f20cf2f7b969fe36a7 Mon Sep 17 00:00:00 2001 From: Emmanuel Giner Date: Thu, 20 Jan 2022 20:10:50 +0100 Subject: [PATCH 02/79] removed bug in subroutine of dav_general_mat --- src/csf/configurations.irp.f | 24 ++++++++++++++ .../dav_diag_dressed_ext_rout.irp.f | 32 +------------------ src/determinants/s2.irp.f | 6 +++- src/mo_guess/h_core_guess_routine.irp.f | 2 +- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/csf/configurations.irp.f b/src/csf/configurations.irp.f index 8e2a513c..ce5d48ab 100644 --- a/src/csf/configurations.irp.f +++ b/src/csf/configurations.irp.f @@ -779,6 +779,7 @@ subroutine binary_search_cfg(cfgInp,addcfg) end subroutine BEGIN_PROVIDER [ integer, psi_configuration_to_psi_det, (2,N_configuration) ] +&BEGIN_PROVIDER [ integer, psi_configuration_n_det, (N_configuration) ] &BEGIN_PROVIDER [ integer, psi_configuration_to_psi_det_data, (N_det) ] implicit none @@ -867,6 +868,29 @@ end subroutine enddo deallocate(dets, old_order) + integer :: ndet_conf + do i = 1, N_configuration + ndet_conf = psi_configuration_to_psi_det(2,i) - psi_configuration_to_psi_det(1,i) + 1 + psi_configuration_n_det(i) = ndet_conf + enddo END_PROVIDER + +BEGIN_PROVIDER [ integer, n_elec_alpha_for_psi_configuration, (N_configuration)] + implicit none + integer :: i,j,k,l + integer(bit_kind) :: det_tmp(N_int,2),det_alpha(N_int) + n_elec_alpha_for_psi_configuration = 0 + do i = 1, N_configuration + j = psi_configuration_to_psi_det(2,i) + det_tmp(:,:) = psi_det(:,:,j) + k = 0 + do l = 1, N_int + det_alpha(N_int) = iand(det_tmp(l,1),psi_configuration(l,1,i)) + k += popcnt(det_alpha(l)) + enddo + n_elec_alpha_for_psi_configuration(i) = k + enddo + +END_PROVIDER diff --git a/src/dav_general_mat/dav_diag_dressed_ext_rout.irp.f b/src/dav_general_mat/dav_diag_dressed_ext_rout.irp.f index 2f3d7f80..243e9995 100644 --- a/src/dav_general_mat/dav_diag_dressed_ext_rout.irp.f +++ b/src/dav_general_mat/dav_diag_dressed_ext_rout.irp.f @@ -1,5 +1,5 @@ -subroutine davidson_general_ext_rout(u_in,H_jj,Dress_jj,energies,sze,N_st,N_st_diag_in,converged,hcalc) +subroutine davidson_general_ext_rout_diag_dressed(u_in,H_jj,Dress_jj,energies,sze,N_st,N_st_diag_in,converged,hcalc) use mmap_module implicit none BEGIN_DOC @@ -412,36 +412,6 @@ subroutine davidson_general_ext_rout(u_in,H_jj,Dress_jj,energies,sze,N_st,N_st_d FREE nthreads_davidson end -subroutine hcalc_template(v,u,N_st,sze) - use bitmasks - implicit none - BEGIN_DOC - ! Template of routine for the application of H - ! - ! Here, it is done with the Hamiltonian matrix - ! - ! on the set of determinants of psi_det - ! - ! Computes $v = H | u \rangle$ - ! - END_DOC - integer, intent(in) :: N_st,sze - double precision, intent(in) :: u(sze,N_st) - double precision, intent(inout) :: v(sze,N_st) - integer :: i,j,istate - v = 0.d0 - do istate = 1, N_st - do i = 1, sze - do j = 1, sze - v(i,istate) += H_matrix_all_dets(j,i) * u(j,istate) - enddo - enddo - do i = 1, sze - v(i,istate) += u(i,istate) * nuclear_repulsion - enddo - enddo -end - subroutine dressing_diag_uv(v,u,dress_diag,N_st,sze) implicit none BEGIN_DOC diff --git a/src/determinants/s2.irp.f b/src/determinants/s2.irp.f index d73b2dbf..2c1a8757 100644 --- a/src/determinants/s2.irp.f +++ b/src/determinants/s2.irp.f @@ -103,13 +103,17 @@ BEGIN_PROVIDER [ double precision, expected_s2] END_PROVIDER -BEGIN_PROVIDER [ double precision, s2_values, (N_states) ] + BEGIN_PROVIDER [ double precision, s2_values, (N_states) ] +&BEGIN_PROVIDER [ double precision, s_values, (N_states) ] implicit none BEGIN_DOC ! array of the averaged values of the S^2 operator on the various states END_DOC integer :: i call u_0_S2_u_0(s2_values,psi_coef,n_det,psi_det,N_int,N_states,psi_det_size) + do i = 1, N_states + s_values(i) = 0.5d0 *(-1.d0 + dsqrt(1.d0 + 4 * s2_values(i))) + enddo END_PROVIDER diff --git a/src/mo_guess/h_core_guess_routine.irp.f b/src/mo_guess/h_core_guess_routine.irp.f index cbf23a9a..fcbdde49 100644 --- a/src/mo_guess/h_core_guess_routine.irp.f +++ b/src/mo_guess/h_core_guess_routine.irp.f @@ -7,7 +7,7 @@ subroutine hcore_guess label = 'Guess' call mo_as_eigvectors_of_mo_matrix(mo_one_e_integrals, & size(mo_one_e_integrals,1), & - size(mo_one_e_integrals,2),label,1,.false.) + size(mo_one_e_integrals,2),label,1,.true.) call nullify_small_elements(ao_num, mo_num, mo_coef, size(mo_coef,1), 1.d-12 ) call save_mos TOUCH mo_coef mo_label From a65902aa33da727fa48ce69c81a0fd4caad7d75d Mon Sep 17 00:00:00 2001 From: Emmanuel Giner Date: Tue, 25 Jan 2022 18:20:03 +0100 Subject: [PATCH 03/79] fixed bug in Laplacians --- src/dft_utils_in_r/ao_in_r.irp.f | 34 +++++++++++++++++++++----------- src/dft_utils_in_r/mo_in_r.irp.f | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/dft_utils_in_r/ao_in_r.irp.f b/src/dft_utils_in_r/ao_in_r.irp.f index 6fa6a4c7..38478d21 100644 --- a/src/dft_utils_in_r/ao_in_r.irp.f +++ b/src/dft_utils_in_r/ao_in_r.irp.f @@ -91,7 +91,19 @@ enddo END_PROVIDER - BEGIN_PROVIDER[double precision, aos_lapl_in_r_array, (ao_num,n_points_final_grid,3)] + BEGIN_PROVIDER [double precision, aos_lapl_in_r_array_transp, (ao_num, n_points_final_grid,3)] + implicit none + integer :: i,j,m + do i = 1, n_points_final_grid + do j = 1, ao_num + do m = 1, 3 + aos_lapl_in_r_array_transp(j,i,m) = aos_lapl_in_r_array(m,j,i) + enddo + enddo + enddo + END_PROVIDER + + BEGIN_PROVIDER [double precision, aos_lapl_in_r_array, (3,ao_num,n_points_final_grid)] implicit none BEGIN_DOC ! aos_lapl_in_r_array(i,j,k) = value of the kth component of the laplacian of jth ao on the ith grid point @@ -100,20 +112,20 @@ END_DOC integer :: i,j,m double precision :: aos_array(ao_num), r(3) - double precision :: aos_grad_array(ao_num,3) - double precision :: aos_lapl_array(ao_num,3) + double precision :: aos_grad_array(3,ao_num) + double precision :: aos_lapl_array(3,ao_num) !$OMP PARALLEL DO & !$OMP DEFAULT (NONE) & !$OMP PRIVATE (i,r,aos_array,aos_grad_array,aos_lapl_array,j,m) & !$OMP SHARED(aos_lapl_in_r_array,n_points_final_grid,ao_num,final_grid_points) - do m = 1, 3 - do i = 1, n_points_final_grid - r(1) = final_grid_points(1,i) - r(2) = final_grid_points(2,i) - r(3) = final_grid_points(3,i) - call give_all_aos_and_grad_and_lapl_at_r(r,aos_array,aos_grad_array,aos_lapl_array) - do j = 1, ao_num - aos_lapl_in_r_array(j,i,m) = aos_lapl_array(j,m) + do i = 1, n_points_final_grid + r(1) = final_grid_points(1,i) + r(2) = final_grid_points(2,i) + r(3) = final_grid_points(3,i) + call give_all_aos_and_grad_and_lapl_at_r(r,aos_array,aos_grad_array,aos_lapl_array) + do j = 1, ao_num + do m = 1, 3 + aos_lapl_in_r_array(m,j,i) = aos_lapl_array(m,j) enddo enddo enddo diff --git a/src/dft_utils_in_r/mo_in_r.irp.f b/src/dft_utils_in_r/mo_in_r.irp.f index 0a8b4d52..192cb25a 100644 --- a/src/dft_utils_in_r/mo_in_r.irp.f +++ b/src/dft_utils_in_r/mo_in_r.irp.f @@ -138,7 +138,7 @@ integer :: m mos_lapl_in_r_array = 0.d0 do m=1,3 - call dgemm('N','N',mo_num,n_points_final_grid,ao_num,1.d0,mo_coef_transp,mo_num,aos_lapl_in_r_array(1,1,m),ao_num,0.d0,mos_lapl_in_r_array(1,1,m),mo_num) + call dgemm('N','N',mo_num,n_points_final_grid,ao_num,1.d0,mo_coef_transp,mo_num,aos_lapl_in_r_array_transp(1,1,m),ao_num,0.d0,mos_lapl_in_r_array(1,1,m),mo_num) enddo END_PROVIDER From 930d03bf1a1457a0b30de5f7dd6f5cf14c14fde7 Mon Sep 17 00:00:00 2001 From: "M. Chandler Bennett" Date: Mon, 31 Jan 2022 11:11:48 -0500 Subject: [PATCH 04/79] Update dependencies --- external/qp2-dependencies | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index bc856147..90ee61f5 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 +Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 From 32b8663fa1d0bb6127833d089a8fd6b8a79b1a6f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 31 Jan 2022 17:23:08 +0100 Subject: [PATCH 05/79] Update submodules --- external/qp2-dependencies | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index bc856147..90ee61f5 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 +Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 From 753399f40c329a8764a859bd8f5ae39fd6390fdb Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 7 Feb 2022 10:58:57 +0100 Subject: [PATCH 06/79] Fix CSF --- src/csf/conversion.irp.f | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/csf/conversion.irp.f b/src/csf/conversion.irp.f index 9f7f4442..7d6a9ca8 100644 --- a/src/csf/conversion.irp.f +++ b/src/csf/conversion.irp.f @@ -63,13 +63,14 @@ subroutine convertWFfromDETtoCSF(N_st,psi_coef_det_in, psi_coef_cfg_out) if (psi_configuration(k,1,i) == 0_bit_kind) cycle s = s + popcnt(psi_configuration(k,1,i)) enddo - - ! Test 1 - if(iand(MS,1) .EQ. 0) then - bfIcfg = max(1,nint((binom(s,s/2)-binom(s,s/2+1)))) - else bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) - endif + +! ! Test 1 +! if(iand(MS,1) .EQ. 0) then +! bfIcfg = max(1,nint((binom(s,s/2)-binom(s,s/2+1)))) +! else +! bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) +! endif ! perhaps blocking with CFGs of same seniority ! can be more efficient From 64d80fd2737b6995723b1583ca2ebfac16a59ec3 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 7 Feb 2022 11:02:54 +0100 Subject: [PATCH 07/79] Fix CSF --- src/csf/conversion.irp.f | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/csf/conversion.irp.f b/src/csf/conversion.irp.f index 7d6a9ca8..f6f12ba9 100644 --- a/src/csf/conversion.irp.f +++ b/src/csf/conversion.irp.f @@ -58,19 +58,19 @@ subroutine convertWFfromDETtoCSF(N_st,psi_coef_det_in, psi_coef_cfg_out) enddo enddo - s = 0 + s = 0 ! s == total number of SOMOs do k=1,N_int if (psi_configuration(k,1,i) == 0_bit_kind) cycle s = s + popcnt(psi_configuration(k,1,i)) enddo - bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) -! ! Test 1 -! if(iand(MS,1) .EQ. 0) then -! bfIcfg = max(1,nint((binom(s,s/2)-binom(s,s/2+1)))) -! else -! bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) -! endif + bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) + + if(iand(s,1) .EQ. 0) then + bfIcfg = max(1,nint((binom(s,s/2)-binom(s,(s/2)+1)))) + else + bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) + endif ! perhaps blocking with CFGs of same seniority ! can be more efficient From 7770e4df588168f339dba89b5396e7a9e50a26ed Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 7 Feb 2022 23:34:09 +0100 Subject: [PATCH 08/79] Fixing CSF --- src/csf/conversion.irp.f | 10 +++++----- src/utils/set_multiple_levels_omp.irp.f | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/csf/conversion.irp.f b/src/csf/conversion.irp.f index f6f12ba9..1ab5ccaa 100644 --- a/src/csf/conversion.irp.f +++ b/src/csf/conversion.irp.f @@ -66,11 +66,11 @@ subroutine convertWFfromDETtoCSF(N_st,psi_coef_det_in, psi_coef_cfg_out) bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) - if(iand(s,1) .EQ. 0) then - bfIcfg = max(1,nint((binom(s,s/2)-binom(s,(s/2)+1)))) - else - bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) - endif +! if(iand(s,1) .EQ. 0) then +! bfIcfg = max(1,nint((binom(s,s/2)-binom(s,(s/2)+1)))) +! else +! bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) +! endif ! perhaps blocking with CFGs of same seniority ! can be more efficient diff --git a/src/utils/set_multiple_levels_omp.irp.f b/src/utils/set_multiple_levels_omp.irp.f index b4764e4a..572a13f4 100644 --- a/src/utils/set_multiple_levels_omp.irp.f +++ b/src/utils/set_multiple_levels_omp.irp.f @@ -8,7 +8,7 @@ subroutine set_multiple_levels_omp(activate) logical, intent(in) :: activate if (activate) then - call omp_set_max_active_levels(5) + call omp_set_max_active_levels(3) IRP_IF SET_NESTED call omp_set_nested(.True.) From c6acad0b0a6665ae5820d8f966d7565ea59a2000 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Tue, 8 Feb 2022 00:01:08 +0100 Subject: [PATCH 09/79] Trying to fix csf. --- external/qp2-dependencies | 2 +- src/csf/conversion.irp.f | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index bc856147..90ee61f5 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 +Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 diff --git a/src/csf/conversion.irp.f b/src/csf/conversion.irp.f index 1ab5ccaa..75f6e539 100644 --- a/src/csf/conversion.irp.f +++ b/src/csf/conversion.irp.f @@ -64,13 +64,11 @@ subroutine convertWFfromDETtoCSF(N_st,psi_coef_det_in, psi_coef_cfg_out) s = s + popcnt(psi_configuration(k,1,i)) enddo - bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) - -! if(iand(s,1) .EQ. 0) then -! bfIcfg = max(1,nint((binom(s,s/2)-binom(s,(s/2)+1)))) -! else -! bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) -! endif + if(iand(s,1) .EQ. 0) then + bfIcfg = max(1,nint((binom(s,s/2)-binom(s,(s/2)+1)))) + else + bfIcfg = max(1,nint((binom(s,(s+1)/2)-binom(s,((s+1)/2)+1)))) + endif ! perhaps blocking with CFGs of same seniority ! can be more efficient From 173ea9eab1c461b38ac50b6efc1ff715645b805a Mon Sep 17 00:00:00 2001 From: Emmanuel Giner Date: Tue, 15 Feb 2022 11:02:39 +0100 Subject: [PATCH 10/79] minor modifs in print_wf.irp.f --- src/tools/print_wf.irp.f | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools/print_wf.irp.f b/src/tools/print_wf.irp.f index 7e51caaf..64eb1a1f 100644 --- a/src/tools/print_wf.irp.f +++ b/src/tools/print_wf.irp.f @@ -32,8 +32,9 @@ subroutine routine double precision :: norm_mono_a,norm_mono_b double precision :: norm_mono_a_2,norm_mono_b_2 double precision :: norm_mono_a_pert_2,norm_mono_b_pert_2 - double precision :: norm_mono_a_pert,norm_mono_b_pert + double precision :: norm_mono_a_pert,norm_mono_b_pert,norm_double_1 double precision :: delta_e,coef_2_2 + norm_mono_a = 0.d0 norm_mono_b = 0.d0 norm_mono_a_2 = 0.d0 @@ -42,6 +43,7 @@ subroutine routine norm_mono_b_pert = 0.d0 norm_mono_a_pert_2 = 0.d0 norm_mono_b_pert_2 = 0.d0 + norm_double_1 = 0.d0 do i = 1, min(N_det_print_wf,N_det) print*,'' print*,'i = ',i @@ -93,6 +95,7 @@ subroutine routine print*,'h1,p1 = ',h1,p1 print*,'s2',s2 print*,'h2,p2 = ',h2,p2 + norm_double_1 += dabs(psi_coef_sorted(i,1)/psi_coef_sorted(1,1)) endif print*,' = ',hij @@ -109,6 +112,7 @@ subroutine routine print*,'' print*,'L1 norm of mono alpha = ',norm_mono_a print*,'L1 norm of mono beta = ',norm_mono_b + print*,'L1 norm of double exc = ',norm_double_1 print*, '---' print*,'L2 norm of mono alpha = ',norm_mono_a_2 print*,'L2 norm of mono beta = ',norm_mono_b_2 From 39c00dd990b359dd3b17d7048a1b03633bd87d14 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 5 Mar 2022 15:31:16 +0100 Subject: [PATCH 11/79] Better sorting in spindeterminants --- external/qp2-dependencies | 2 +- src/determinants/spindeterminants.irp.f | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index bc856147..90ee61f5 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 +Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 diff --git a/src/determinants/spindeterminants.irp.f b/src/determinants/spindeterminants.irp.f index dea4a566..dd55e112 100644 --- a/src/determinants/spindeterminants.irp.f +++ b/src/determinants/spindeterminants.irp.f @@ -585,7 +585,7 @@ END_PROVIDER enddo !$OMP ENDDO !$OMP END PARALLEL - call i8radix_sort(to_sort, psi_bilinear_matrix_transp_order, N_det,-1) + call i8sort(to_sort, psi_bilinear_matrix_transp_order, N_det) call iset_order(psi_bilinear_matrix_transp_rows,psi_bilinear_matrix_transp_order,N_det) call iset_order(psi_bilinear_matrix_transp_columns,psi_bilinear_matrix_transp_order,N_det) !$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(l) From 980b48d9061c9ac74cf11e95df166f3740124d65 Mon Sep 17 00:00:00 2001 From: eginer Date: Mon, 7 Mar 2022 16:36:35 +0100 Subject: [PATCH 12/79] added the possibility to unset frozen core orbitals --- bin/qp_set_frozen_core | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/qp_set_frozen_core b/bin/qp_set_frozen_core index 879c71de..bc6f6834 100755 --- a/bin/qp_set_frozen_core +++ b/bin/qp_set_frozen_core @@ -7,12 +7,13 @@ setting all MOs as Active, except the n/2 first ones which are set as Core. If pseudo-potentials are used, all the MOs are set as Active. Usage: - qp_set_frozen_core [-q|--query] [(-l|-s|--large|--small)] EZFIO_DIR + qp_set_frozen_core [-q|--query] [(-l|-s|-u|--large|--small|--unset)] EZFIO_DIR Options: -q --query Prints in the standard output the number of frozen MOs -l --large Use a small core -s --small Use a large core + -u --unset Unset frozen core Default numbers of frozen electrons: @@ -88,7 +89,9 @@ def main(arguments): elif charge <= 54: n_frozen += 9 elif charge <= 86: n_frozen += 18 elif charge <= 118: n_frozen += 27 + elif arguments["--unset"]: + n_frozen = 0 else: # default for charge in ezfio.nuclei_nucl_charge: if charge <= 4: pass From cef2ab8a91effadc642f08f80807802a9a90152f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 8 Mar 2022 11:24:17 +0100 Subject: [PATCH 13/79] Accelerated PT2 --- external/qp2-dependencies | 2 +- src/cipsi/run_pt2_slave.irp.f | 8 ++++---- src/davidson/u0_hs2_u0.irp.f | 16 +++++++++------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 90ee61f5..bc856147 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 +Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 diff --git a/src/cipsi/run_pt2_slave.irp.f b/src/cipsi/run_pt2_slave.irp.f index f1001f89..731e40ac 100644 --- a/src/cipsi/run_pt2_slave.irp.f +++ b/src/cipsi/run_pt2_slave.irp.f @@ -31,11 +31,11 @@ subroutine run_pt2_slave(thread,iproc,energy) double precision, intent(in) :: energy(N_states_diag) integer, intent(in) :: thread, iproc - if (N_det > 100000 ) then - call run_pt2_slave_large(thread,iproc,energy) - else +! if (N_det > 100000 ) then +! call run_pt2_slave_large(thread,iproc,energy) +! else call run_pt2_slave_small(thread,iproc,energy) - endif +! endif end subroutine run_pt2_slave_small(thread,iproc,energy) diff --git a/src/davidson/u0_hs2_u0.irp.f b/src/davidson/u0_hs2_u0.irp.f index 8f7bf06b..38fb56bd 100644 --- a/src/davidson/u0_hs2_u0.irp.f +++ b/src/davidson/u0_hs2_u0.irp.f @@ -203,7 +203,7 @@ subroutine H_S2_u_0_nstates_openmp_work_$N_int(v_t,s_t,u_t,N_st,sze,istart,iend, integer, allocatable :: doubles(:) integer, allocatable :: singles_a(:) integer, allocatable :: singles_b(:) - integer, allocatable :: idx(:), idx0(:) + integer, allocatable :: idx(:), buffer_lrow(:), idx0(:) integer :: maxab, n_singles_a, n_singles_b, kcol_prev integer*8 :: k8 logical :: compute_singles @@ -253,7 +253,7 @@ compute_singles=.True. !$OMP PRIVATE(krow, kcol, tmp_det, spindet, k_a, k_b, i, & !$OMP lcol, lrow, l_a, l_b, utl, kk, u_is_sparse, & !$OMP buffer, doubles, n_doubles, umax, & - !$OMP tmp_det2, hij, sij, idx, l, kcol_prev, & + !$OMP tmp_det2, hij, sij, idx, buffer_lrow, l, kcol_prev, & !$OMP singles_a, n_singles_a, singles_b, ratio, & !$OMP n_singles_b, k8, last_found,left,right,right_max) @@ -264,7 +264,7 @@ compute_singles=.True. singles_a(maxab), & singles_b(maxab), & doubles(maxab), & - idx(maxab), utl(N_st,block_size)) + idx(maxab), buffer_lrow(maxab), utl(N_st,block_size)) kcol_prev=-1 @@ -332,18 +332,20 @@ compute_singles=.True. l_a = psi_bilinear_matrix_columns_loc(lcol) ASSERT (l_a <= N_det) - !DIR$ UNROLL(8) - !DIR$ LOOP COUNT avg(50000) do j=1,psi_bilinear_matrix_columns_loc(lcol+1) - psi_bilinear_matrix_columns_loc(lcol) lrow = psi_bilinear_matrix_rows(l_a) ASSERT (lrow <= N_det_alpha_unique) - buffer(1:$N_int,j) = psi_det_alpha_unique(1:$N_int, lrow) ! hot spot + buffer_lrow(j) = lrow ASSERT (l_a <= N_det) idx(j) = l_a l_a = l_a+1 enddo + + do j=1,psi_bilinear_matrix_columns_loc(lcol+1) - psi_bilinear_matrix_columns_loc(lcol) + buffer(1:$N_int,j) = psi_det_alpha_unique(1:$N_int, buffer_lrow(j)) ! hot spot + enddo j = j-1 call get_all_spin_singles_$N_int( & @@ -789,7 +791,7 @@ compute_singles=.True. end do !$OMP END DO - deallocate(buffer, singles_a, singles_b, doubles, idx, utl) + deallocate(buffer, singles_a, singles_b, doubles, idx, buffer_lrow, utl) !$OMP END PARALLEL end From 6b118362df31a7ed647274d2864e737b171bcef2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 8 Mar 2022 23:30:13 +0100 Subject: [PATCH 14/79] Accelerating PT2 again --- src/cipsi/run_pt2_slave.irp.f | 57 +++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/cipsi/run_pt2_slave.irp.f b/src/cipsi/run_pt2_slave.irp.f index 731e40ac..f9171a42 100644 --- a/src/cipsi/run_pt2_slave.irp.f +++ b/src/cipsi/run_pt2_slave.irp.f @@ -31,11 +31,11 @@ subroutine run_pt2_slave(thread,iproc,energy) double precision, intent(in) :: energy(N_states_diag) integer, intent(in) :: thread, iproc -! if (N_det > 100000 ) then -! call run_pt2_slave_large(thread,iproc,energy) -! else + if (N_det > 100000 ) then + call run_pt2_slave_large(thread,iproc,energy) + else call run_pt2_slave_small(thread,iproc,energy) -! endif + endif end subroutine run_pt2_slave_small(thread,iproc,energy) @@ -116,10 +116,10 @@ subroutine run_pt2_slave_small(thread,iproc,energy) do k=1,n_tasks call pt2_alloc(pt2_data(k),N_states) b%cur = 0 - double precision :: time2 - call wall_time(time2) +! double precision :: time2 +! call wall_time(time2) call select_connected(i_generator(k),energy,pt2_data(k),b,subset(k),pt2_F(i_generator(k))) - call wall_time(time1) +! call wall_time(time1) ! print *, i_generator(1), time1-time2, n_tasks, pt2_F(i_generator(1)) enddo call wall_time(time1) @@ -172,8 +172,8 @@ subroutine run_pt2_slave_large(thread,iproc,energy) integer :: rc, i integer :: worker_id, ctask, ltask - character*(512) :: task - integer :: task_id(1) + character*(512), allocatable :: task(:) + integer, allocatable :: task_id(:) integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket integer(ZMQ_PTR) :: zmq_to_qp_run_socket @@ -184,15 +184,16 @@ subroutine run_pt2_slave_large(thread,iproc,energy) type(selection_buffer) :: b logical :: done, buffer_ready - type(pt2_type) :: pt2_data + type(pt2_type), allocatable :: pt2_data(:) integer :: n_tasks, k, N - integer :: i_generator, subset - + integer, allocatable :: i_generator(:), subset(:) integer :: bsize ! Size of selection buffers logical :: sending PROVIDE global_selection_buffer global_selection_buffer_lock + allocate(task_id(pt2_n_tasks_max), task(pt2_n_tasks_max)) + allocate(pt2_data(pt2_n_tasks_max), i_generator(pt2_n_tasks_max), subset(pt2_n_tasks_max)) zmq_to_qp_run_socket = new_zmq_to_qp_run_socket() integer, external :: connect_to_taskserver @@ -211,6 +212,9 @@ subroutine run_pt2_slave_large(thread,iproc,energy) done = .False. do while (.not.done) + n_tasks = max(1,n_tasks) + n_tasks = min(pt2_n_tasks_max,n_tasks) + integer, external :: get_tasks_from_taskserver if (get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, task, n_tasks) == -1) then exit @@ -221,11 +225,9 @@ subroutine run_pt2_slave_large(thread,iproc,energy) endif if (n_tasks == 0) exit - call sscanf_ddd(task, subset, i_generator, N) - if( pt2_F(i_generator) <= 0 .or. pt2_F(i_generator) > N_det ) then - print *, irp_here - stop 'bug in selection' - endif + do k=1,n_tasks + call sscanf_ddd(task(k), subset(k), i_generator(k), N) + enddo if (b%N == 0) then ! Only first time bsize = min(N, (elec_alpha_num * (mo_num-elec_alpha_num))**2) @@ -235,9 +237,14 @@ subroutine run_pt2_slave_large(thread,iproc,energy) ASSERT (b%N == bsize) endif - call pt2_alloc(pt2_data,N_states) - b%cur = 0 - call select_connected(i_generator,energy,pt2_data,b,subset,pt2_F(i_generator)) + double precision :: time0, time1 + call wall_time(time0) + do k=1,n_tasks + call pt2_alloc(pt2_data(k),N_states) + b%cur = 0 + call select_connected(i_generator(k),energy,pt2_data(k),b,subset(k),pt2_F(i_generator(k))) + enddo + call wall_time(time1) integer, external :: tasks_done_to_taskserver if (tasks_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id,n_tasks) == -1) then @@ -249,7 +256,7 @@ subroutine run_pt2_slave_large(thread,iproc,energy) call merge_selection_buffers(b,global_selection_buffer) b%cur=0 call omp_unset_lock(global_selection_buffer_lock) - if ( iproc == 1 .or. i_generator < 100 .or. done) then + if ( iproc == 1 .or. i_generator(1) < 100 .or. done) then call omp_set_lock(global_selection_buffer_lock) call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), global_selection_buffer, (/task_id/), 1,sending) @@ -260,7 +267,13 @@ subroutine run_pt2_slave_large(thread,iproc,energy) call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), b, (/task_id/), 1,sending) endif - call pt2_dealloc(pt2_data) + do k=1,n_tasks + call pt2_dealloc(pt2_data(k)) + enddo + b%cur=0 +! ! Try to adjust n_tasks at least 5 seconds per task + n_tasks = min(2*n_tasks,int( dble(5*n_tasks) / (time1 - time0 + 1.d0))) + n_tasks = min(n_tasks, pt2_n_tasks_max) end do call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) From 0c8f5e5f0b8537a3aa01e692ba21cbbd07509a42 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 8 Mar 2022 23:43:29 +0100 Subject: [PATCH 15/79] Accelerating PT2 again --- src/cipsi/run_pt2_slave.irp.f | 43 ++++++++++++----------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/src/cipsi/run_pt2_slave.irp.f b/src/cipsi/run_pt2_slave.irp.f index f9171a42..083865f3 100644 --- a/src/cipsi/run_pt2_slave.irp.f +++ b/src/cipsi/run_pt2_slave.irp.f @@ -172,8 +172,8 @@ subroutine run_pt2_slave_large(thread,iproc,energy) integer :: rc, i integer :: worker_id, ctask, ltask - character*(512), allocatable :: task(:) - integer, allocatable :: task_id(:) + character*(512) :: task + integer :: task_id(1) integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket integer(ZMQ_PTR) :: zmq_to_qp_run_socket @@ -184,16 +184,15 @@ subroutine run_pt2_slave_large(thread,iproc,energy) type(selection_buffer) :: b logical :: done, buffer_ready - type(pt2_type), allocatable :: pt2_data(:) + type(pt2_type) :: pt2_data integer :: n_tasks, k, N - integer, allocatable :: i_generator(:), subset(:) + integer :: i_generator, subset + integer :: bsize ! Size of selection buffers logical :: sending PROVIDE global_selection_buffer global_selection_buffer_lock - allocate(task_id(pt2_n_tasks_max), task(pt2_n_tasks_max)) - allocate(pt2_data(pt2_n_tasks_max), i_generator(pt2_n_tasks_max), subset(pt2_n_tasks_max)) zmq_to_qp_run_socket = new_zmq_to_qp_run_socket() integer, external :: connect_to_taskserver @@ -212,9 +211,6 @@ subroutine run_pt2_slave_large(thread,iproc,energy) done = .False. do while (.not.done) - n_tasks = max(1,n_tasks) - n_tasks = min(pt2_n_tasks_max,n_tasks) - integer, external :: get_tasks_from_taskserver if (get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, task, n_tasks) == -1) then exit @@ -225,9 +221,11 @@ subroutine run_pt2_slave_large(thread,iproc,energy) endif if (n_tasks == 0) exit - do k=1,n_tasks - call sscanf_ddd(task(k), subset(k), i_generator(k), N) - enddo + call sscanf_ddd(task, subset, i_generator, N) + if( pt2_F(i_generator) <= 0 .or. pt2_F(i_generator) > N_det ) then + print *, irp_here + stop 'bug in selection' + endif if (b%N == 0) then ! Only first time bsize = min(N, (elec_alpha_num * (mo_num-elec_alpha_num))**2) @@ -237,14 +235,9 @@ subroutine run_pt2_slave_large(thread,iproc,energy) ASSERT (b%N == bsize) endif - double precision :: time0, time1 - call wall_time(time0) - do k=1,n_tasks - call pt2_alloc(pt2_data(k),N_states) - b%cur = 0 - call select_connected(i_generator(k),energy,pt2_data(k),b,subset(k),pt2_F(i_generator(k))) - enddo - call wall_time(time1) + call pt2_alloc(pt2_data,N_states) + b%cur = 0 + call select_connected(i_generator,energy,pt2_data,b,subset,pt2_F(i_generator)) integer, external :: tasks_done_to_taskserver if (tasks_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id,n_tasks) == -1) then @@ -256,7 +249,7 @@ subroutine run_pt2_slave_large(thread,iproc,energy) call merge_selection_buffers(b,global_selection_buffer) b%cur=0 call omp_unset_lock(global_selection_buffer_lock) - if ( iproc == 1 .or. i_generator(1) < 100 .or. done) then + if ( iproc == 1 .or. i_generator < 100 .or. done) then call omp_set_lock(global_selection_buffer_lock) call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), global_selection_buffer, (/task_id/), 1,sending) @@ -267,13 +260,7 @@ subroutine run_pt2_slave_large(thread,iproc,energy) call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), b, (/task_id/), 1,sending) endif - do k=1,n_tasks - call pt2_dealloc(pt2_data(k)) - enddo - b%cur=0 -! ! Try to adjust n_tasks at least 5 seconds per task - n_tasks = min(2*n_tasks,int( dble(5*n_tasks) / (time1 - time0 + 1.d0))) - n_tasks = min(n_tasks, pt2_n_tasks_max) + call pt2_dealloc(pt2_data) end do call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) From 25c50aab59aebe83ed2ad2b110eb1e943526ba16 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Mar 2022 10:23:27 +0100 Subject: [PATCH 16/79] Improving PT2 --- src/cipsi/pt2_stoch_routines.irp.f | 4 ++-- src/cipsi/run_pt2_slave.irp.f | 36 ++++++++++++++++++++---------- src/cipsi/selection.irp.f | 10 ++------- src/ezfio_files/output.irp.f | 2 +- src/utils/memory.irp.f | 2 +- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index 14b1d060..5019c957 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -291,7 +291,7 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) print '(A)', '========== ======================= ===================== ===================== ===========' - print '(A)', ' Samples Energy Variance Norm^2 Seconds' + print '(A)', ' Samples Energy Variance Norm^2 Seconds' print '(A)', '========== ======================= ===================== ===================== ===========' PROVIDE global_selection_buffer @@ -537,7 +537,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2_data, pt2_data_ if ((time - time1 > 1.d0) .or. (n==N_det_generators)) then time1 = time - print '(I10, X, F12.6, X, G10.3, X, F10.6, X, G10.3, X, F10.6, X, G10.3, X, F10.4)', c, & + print '(I10, X, F12.6, X, G10.3, X, F10.6, X, G10.3, X, F10.6, X, G10.3, X, F10.1)', c, & pt2_data % pt2(pt2_stoch_istate) +E, & pt2_data_err % pt2(pt2_stoch_istate), & pt2_data % variance(pt2_stoch_istate), & diff --git a/src/cipsi/run_pt2_slave.irp.f b/src/cipsi/run_pt2_slave.irp.f index 083865f3..a8215a98 100644 --- a/src/cipsi/run_pt2_slave.irp.f +++ b/src/cipsi/run_pt2_slave.irp.f @@ -190,8 +190,12 @@ subroutine run_pt2_slave_large(thread,iproc,energy) integer :: bsize ! Size of selection buffers logical :: sending + double precision :: time_shift + PROVIDE global_selection_buffer global_selection_buffer_lock + call random_number(time_shift) + time_shift = time_shift*15.d0 zmq_to_qp_run_socket = new_zmq_to_qp_run_socket() @@ -209,6 +213,9 @@ subroutine run_pt2_slave_large(thread,iproc,energy) sending = .False. done = .False. + double precision :: time0, time1 + call wall_time(time0) + time0 = time0+time_shift do while (.not.done) integer, external :: get_tasks_from_taskserver @@ -244,20 +251,25 @@ subroutine run_pt2_slave_large(thread,iproc,energy) done = .true. endif call sort_selection_buffer(b) - call omp_set_lock(global_selection_buffer_lock) - global_selection_buffer%mini = b%mini - call merge_selection_buffers(b,global_selection_buffer) - b%cur=0 - call omp_unset_lock(global_selection_buffer_lock) - if ( iproc == 1 .or. i_generator < 100 .or. done) then + + call wall_time(time1) + if (time1-time0 > 15.d0) then call omp_set_lock(global_selection_buffer_lock) - call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) - call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), global_selection_buffer, (/task_id/), 1,sending) - global_selection_buffer%cur = 0 + global_selection_buffer%mini = b%mini + call merge_selection_buffers(b,global_selection_buffer) + b%cur=0 call omp_unset_lock(global_selection_buffer_lock) - else - call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) - call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), b, (/task_id/), 1,sending) + call wall_time(time0) + if ( iproc == 1 .or. i_generator < 100 .or. done) then + call omp_set_lock(global_selection_buffer_lock) + call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) + call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), global_selection_buffer, (/task_id/), 1,sending) + global_selection_buffer%cur = 0 + call omp_unset_lock(global_selection_buffer_lock) + else + call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) + call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), b, (/task_id/), 1,sending) + endif endif call pt2_dealloc(pt2_data) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index f1ec6ff6..acb91fb5 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -474,17 +474,11 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d ! endif do i=1,fullinteresting(0) - do k=1,N_int - fullminilist(k,1,i) = psi_det_sorted(k,1,fullinteresting(i)) - fullminilist(k,2,i) = psi_det_sorted(k,2,fullinteresting(i)) - enddo + fullminilist(:,:,i) = psi_det_sorted(:,:,fullinteresting(i)) enddo do i=1,interesting(0) - do k=1,N_int - minilist(k,1,i) = psi_det_sorted(k,1,interesting(i)) - minilist(k,2,i) = psi_det_sorted(k,2,interesting(i)) - enddo + minilist(:,:,i) = psi_det_sorted(:,:,interesting(i)) enddo do s2=s1,2 diff --git a/src/ezfio_files/output.irp.f b/src/ezfio_files/output.irp.f index 48512f92..7b2663a0 100644 --- a/src/ezfio_files/output.irp.f +++ b/src/ezfio_files/output.irp.f @@ -25,7 +25,7 @@ subroutine write_time(iunit) ct = ct - output_cpu_time_0 call wall_time(wt) wt = wt - output_wall_time_0 - write(6,'(A,F14.6,A,F14.6,A)') & + write(6,'(A,F14.2,A,F14.2,A)') & '.. >>>>> [ WALL TIME: ', wt, ' s ] [ CPU TIME: ', ct, ' s ] <<<<< ..' write(6,*) end diff --git a/src/utils/memory.irp.f b/src/utils/memory.irp.f index 3ea242b0..d5a066a1 100644 --- a/src/utils/memory.irp.f +++ b/src/utils/memory.irp.f @@ -114,7 +114,7 @@ subroutine print_memory_usage() call resident_memory(rss) call total_memory(mem) - write(*,'(A,F14.6,A,F14.6,A)') & + write(*,'(A,F14.3,A,F14.3,A)') & '.. >>>>> [ RES MEM : ', rss , & ' GB ] [ VIRT MEM : ', mem, ' GB ] <<<<< ..' end From 416ff24ff44cbb7dd5fabea1c3415ea720432146 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Mar 2022 10:40:30 +0100 Subject: [PATCH 17/79] Fixed previous commit --- src/cipsi/run_pt2_slave.irp.f | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cipsi/run_pt2_slave.irp.f b/src/cipsi/run_pt2_slave.irp.f index a8215a98..9e046877 100644 --- a/src/cipsi/run_pt2_slave.irp.f +++ b/src/cipsi/run_pt2_slave.irp.f @@ -266,10 +266,10 @@ subroutine run_pt2_slave_large(thread,iproc,energy) call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), global_selection_buffer, (/task_id/), 1,sending) global_selection_buffer%cur = 0 call omp_unset_lock(global_selection_buffer_lock) - else - call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) - call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), b, (/task_id/), 1,sending) endif + else + call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) + call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), b, (/task_id/), 1,sending) endif call pt2_dealloc(pt2_data) From 27dc0c06aea0ae63ed55621106df40353201e3a2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 10 Mar 2022 00:55:23 +0100 Subject: [PATCH 18/79] Optimize PT2 --- src/cipsi/run_pt2_slave.irp.f | 18 ++++---- src/cipsi/selection_buffer.irp.f | 71 +++++++++++++++++++------------- 2 files changed, 51 insertions(+), 38 deletions(-) diff --git a/src/cipsi/run_pt2_slave.irp.f b/src/cipsi/run_pt2_slave.irp.f index 9e046877..30fc7ce0 100644 --- a/src/cipsi/run_pt2_slave.irp.f +++ b/src/cipsi/run_pt2_slave.irp.f @@ -253,22 +253,22 @@ subroutine run_pt2_slave_large(thread,iproc,energy) call sort_selection_buffer(b) call wall_time(time1) - if (time1-time0 > 15.d0) then +! if (time1-time0 > 15.d0) then call omp_set_lock(global_selection_buffer_lock) global_selection_buffer%mini = b%mini call merge_selection_buffers(b,global_selection_buffer) b%cur=0 call omp_unset_lock(global_selection_buffer_lock) call wall_time(time0) - if ( iproc == 1 .or. i_generator < 100 .or. done) then - call omp_set_lock(global_selection_buffer_lock) - call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) - call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), global_selection_buffer, (/task_id/), 1,sending) - global_selection_buffer%cur = 0 - call omp_unset_lock(global_selection_buffer_lock) - endif +! endif + + call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) + if ( iproc == 1 .or. i_generator < 100 .or. done) then + call omp_set_lock(global_selection_buffer_lock) + call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), global_selection_buffer, (/task_id/), 1,sending) + global_selection_buffer%cur = 0 + call omp_unset_lock(global_selection_buffer_lock) else - call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) call push_pt2_results_async_send(zmq_socket_push, (/i_generator/), (/pt2_data/), b, (/task_id/), 1,sending) endif diff --git a/src/cipsi/selection_buffer.irp.f b/src/cipsi/selection_buffer.irp.f index 79899139..1f743e0e 100644 --- a/src/cipsi/selection_buffer.irp.f +++ b/src/cipsi/selection_buffer.irp.f @@ -92,38 +92,51 @@ subroutine merge_selection_buffers(b1, b2) allocate(val(sze), detmp(N_int, 2, sze)) i1=1 i2=1 - do i=1,nmwen - if ( (i1 > b1%cur).and.(i2 > b2%cur) ) then - exit - else if (i1 > b1%cur) then - val(i) = b2%val(i2) - detmp(1:N_int,1,i) = b2%det(1:N_int,1,i2) - detmp(1:N_int,2,i) = b2%det(1:N_int,2,i2) - i2=i2+1 - else if (i2 > b2%cur) then - val(i) = b1%val(i1) - detmp(1:N_int,1,i) = b1%det(1:N_int,1,i1) - detmp(1:N_int,2,i) = b1%det(1:N_int,2,i1) - i1=i1+1 - else - if (b1%val(i1) <= b2%val(i2)) then - val(i) = b1%val(i1) - detmp(1:N_int,1,i) = b1%det(1:N_int,1,i1) - detmp(1:N_int,2,i) = b1%det(1:N_int,2,i1) - i1=i1+1 + + select case (N_int) +BEGIN_TEMPLATE + case $case + do i=1,nmwen + if ( (i1 > b1%cur).and.(i2 > b2%cur) ) then + exit + else if (i1 > b1%cur) then + val(i) = b2%val(i2) + detmp(1:$N_int,1,i) = b2%det(1:$N_int,1,i2) + detmp(1:$N_int,2,i) = b2%det(1:$N_int,2,i2) + i2=i2+1 + else if (i2 > b2%cur) then + val(i) = b1%val(i1) + detmp(1:$N_int,1,i) = b1%det(1:$N_int,1,i1) + detmp(1:$N_int,2,i) = b1%det(1:$N_int,2,i1) + i1=i1+1 else - val(i) = b2%val(i2) - detmp(1:N_int,1,i) = b2%det(1:N_int,1,i2) - detmp(1:N_int,2,i) = b2%det(1:N_int,2,i2) - i2=i2+1 + if (b1%val(i1) <= b2%val(i2)) then + val(i) = b1%val(i1) + detmp(1:$N_int,1,i) = b1%det(1:$N_int,1,i1) + detmp(1:$N_int,2,i) = b1%det(1:$N_int,2,i1) + i1=i1+1 + else + val(i) = b2%val(i2) + detmp(1:$N_int,1,i) = b2%det(1:$N_int,1,i2) + detmp(1:$N_int,2,i) = b2%det(1:$N_int,2,i2) + i2=i2+1 + endif endif - endif - enddo + enddo + do i=nmwen+1,b2%N + val(i) = 0.d0 +! detmp(1:$N_int,1,i) = 0_bit_kind +! detmp(1:$N_int,2,i) = 0_bit_kind + enddo +SUBST [ case, N_int ] +(1); 1;; +(2); 2;; +(3); 3;; +(4); 4;; +default; N_int;; +END_TEMPLATE + end select deallocate(b2%det, b2%val) - do i=nmwen+1,b2%N - val(i) = 0.d0 - detmp(1:N_int,1:2,i) = 0_bit_kind - enddo b2%det => detmp b2%val => val b2%mini = min(b2%mini,b2%val(b2%N)) From 6b0162e22991717d21cab150b952b9fdb006d824 Mon Sep 17 00:00:00 2001 From: ydamour Date: Tue, 15 Mar 2022 16:25:21 +0100 Subject: [PATCH 19/79] dipole moments x,y,z --- src/determinants/dipole_moments.irp.f | 4 +++- src/tools/print_dipole.irp.f | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/determinants/dipole_moments.irp.f b/src/determinants/dipole_moments.irp.f index 8a5f1a2d..c3675e7d 100644 --- a/src/determinants/dipole_moments.irp.f +++ b/src/determinants/dipole_moments.irp.f @@ -55,11 +55,13 @@ END_PROVIDER - subroutine print_z_dipole_moment_only + subroutine print_dipole_moments implicit none print*, '' print*, '' print*, '****************************************' + print*, 'x_dipole_moment = ',x_dipole_moment + print*, 'y_dipole_moment = ',y_dipole_moment print*, 'z_dipole_moment = ',z_dipole_moment print*, '****************************************' end diff --git a/src/tools/print_dipole.irp.f b/src/tools/print_dipole.irp.f index 8351308e..1d095af9 100644 --- a/src/tools/print_dipole.irp.f +++ b/src/tools/print_dipole.irp.f @@ -1,5 +1,5 @@ program print_dipole implicit none - call print_z_dipole_moment_only + call print_dipole_moments end From cf96b74b52443e63d20c8d414315299ce26591ad Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 16 Mar 2022 10:26:18 +0100 Subject: [PATCH 20/79] Remove debug --- external/qp2-dependencies | 2 +- src/ao_basis/spherical_to_cartesian.irp.f | 2 +- src/determinants/dipole_moments.irp.f | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index bc856147..90ee61f5 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 +Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 diff --git a/src/ao_basis/spherical_to_cartesian.irp.f b/src/ao_basis/spherical_to_cartesian.irp.f index 33a3bc89..336161f8 100644 --- a/src/ao_basis/spherical_to_cartesian.irp.f +++ b/src/ao_basis/spherical_to_cartesian.irp.f @@ -1,7 +1,7 @@ ! Spherical to cartesian transformation matrix obtained with ! Horton (http://theochem.github.com/horton/, 2015) -! First index is the index of the carteisan AO, obtained by ao_power_index +! First index is the index of the cartesian AO, obtained by ao_power_index ! Second index is the index of the spherical AO BEGIN_PROVIDER [ double precision, cart_to_sphe_0, (1,1) ] diff --git a/src/determinants/dipole_moments.irp.f b/src/determinants/dipole_moments.irp.f index 8a5f1a2d..733dd535 100644 --- a/src/determinants/dipole_moments.irp.f +++ b/src/determinants/dipole_moments.irp.f @@ -9,7 +9,7 @@ double precision :: weight, r(3) double precision :: cpu0,cpu1,nuclei_part_z,nuclei_part_y,nuclei_part_x - call cpu_time(cpu0) +! call cpu_time(cpu0) z_dipole_moment = 0.d0 y_dipole_moment = 0.d0 x_dipole_moment = 0.d0 @@ -26,10 +26,10 @@ enddo enddo - print*,'electron part for z_dipole = ',z_dipole_moment - print*,'electron part for y_dipole = ',y_dipole_moment - print*,'electron part for x_dipole = ',x_dipole_moment - +! print*,'electron part for z_dipole = ',z_dipole_moment +! print*,'electron part for y_dipole = ',y_dipole_moment +! print*,'electron part for x_dipole = ',x_dipole_moment +! nuclei_part_z = 0.d0 nuclei_part_y = 0.d0 nuclei_part_x = 0.d0 @@ -38,18 +38,18 @@ nuclei_part_y += nucl_charge(i) * nucl_coord(i,2) nuclei_part_x += nucl_charge(i) * nucl_coord(i,1) enddo - print*,'nuclei part for z_dipole = ',nuclei_part_z - print*,'nuclei part for y_dipole = ',nuclei_part_y - print*,'nuclei part for x_dipole = ',nuclei_part_x - +! print*,'nuclei part for z_dipole = ',nuclei_part_z +! print*,'nuclei part for y_dipole = ',nuclei_part_y +! print*,'nuclei part for x_dipole = ',nuclei_part_x +! do istate = 1, N_states z_dipole_moment(istate) += nuclei_part_z y_dipole_moment(istate) += nuclei_part_y x_dipole_moment(istate) += nuclei_part_x enddo - call cpu_time(cpu1) - print*,'Time to provide the dipole moment :',cpu1-cpu0 +! call cpu_time(cpu1) +! print*,'Time to provide the dipole moment :',cpu1-cpu0 END_PROVIDER From 7da10a66cfb6c6bba3913f669e3bd79b79fdcf3e Mon Sep 17 00:00:00 2001 From: ydamour Date: Wed, 16 Mar 2022 11:42:26 +0100 Subject: [PATCH 21/79] output print dipole for n_states >= 1 + read_wf true --- src/determinants/dipole_moments.irp.f | 15 ++++++++++++--- src/tools/print_dipole.irp.f | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/determinants/dipole_moments.irp.f b/src/determinants/dipole_moments.irp.f index 932c1c51..06fca0cd 100644 --- a/src/determinants/dipole_moments.irp.f +++ b/src/determinants/dipole_moments.irp.f @@ -57,11 +57,20 @@ END_PROVIDER subroutine print_dipole_moments implicit none + integer :: i print*, '' print*, '' print*, '****************************************' - print*, 'x_dipole_moment = ',x_dipole_moment - print*, 'y_dipole_moment = ',y_dipole_moment - print*, 'z_dipole_moment = ',z_dipole_moment + write(*,'(A10)',advance='no') ' State : ' + do i = 1,N_states + write(*,'(i16)',advance='no') i + end do + write(*,*) '' + write(*,'(A17,100(1pE16.8))') 'x_dipole_moment = ',x_dipole_moment + write(*,'(A17,100(1pE16.8))') 'y_dipole_moment = ',y_dipole_moment + write(*,'(A17,100(1pE16.8))') 'z_dipole_moment = ',z_dipole_moment + !print*, 'x_dipole_moment = ',x_dipole_moment + !print*, 'y_dipole_moment = ',y_dipole_moment + !print*, 'z_dipole_moment = ',z_dipole_moment print*, '****************************************' end diff --git a/src/tools/print_dipole.irp.f b/src/tools/print_dipole.irp.f index 1d095af9..8db9aa09 100644 --- a/src/tools/print_dipole.irp.f +++ b/src/tools/print_dipole.irp.f @@ -1,5 +1,7 @@ program print_dipole implicit none + read_wf = .True. + TOUCH read_wf call print_dipole_moments end From 22b28fc77435dc74268a952a3c1e30e016601d66 Mon Sep 17 00:00:00 2001 From: ydamour Date: Tue, 22 Mar 2022 10:49:39 +0100 Subject: [PATCH 22/79] csf fix segfault --- src/csf/sigma_vector.irp.f | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/csf/sigma_vector.irp.f b/src/csf/sigma_vector.irp.f index 4d409f50..beb827ba 100644 --- a/src/csf/sigma_vector.irp.f +++ b/src/csf/sigma_vector.irp.f @@ -52,10 +52,15 @@ ncfgpersomo = cfg_seniority_index(i+2) else k = 0 - do while(cfg_seniority_index(i+2+k) < ncfgpersomo) - k = k + 2 - ncfgpersomo = cfg_seniority_index(i+2+k) - enddo + if ((i+2+k) < size(cfg_seniority_index,1)) then + do while(cfg_seniority_index(i+2+k) < ncfgpersomo) + k = k + 2 + if ((i+2+k) >= size(cfg_seniority_index,1)) then + exit + endif + ncfgpersomo = cfg_seniority_index(i+2+k) + enddo + endif endif endif ncfg = ncfgpersomo - ncfgprev @@ -75,10 +80,15 @@ ncfgprev = cfg_seniority_index(i+2) else k = 0 - do while(cfg_seniority_index(i+2+k) < ncfgprev) - k = k + 2 - ncfgprev = cfg_seniority_index(i+2+k) - enddo + if ((i+2+k) < size(cfg_seniority_index,1)) then + do while(cfg_seniority_index(i+2+k) < ncfgprev) + k = k + 2 + if ((i+2+k) >= size(cfg_seniority_index,1)) then + exit + endif + ncfgprev = cfg_seniority_index(i+2+k) + enddo + endif endif enddo END_PROVIDER From 8a759e6a943ae3604dc0d7636c4a2bf9da6af03c Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 24 Mar 2022 16:14:31 +0100 Subject: [PATCH 23/79] csf remove do while loops --- src/csf/sigma_vector.irp.f | 58 +++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/src/csf/sigma_vector.irp.f b/src/csf/sigma_vector.irp.f index beb827ba..026dd839 100644 --- a/src/csf/sigma_vector.irp.f +++ b/src/csf/sigma_vector.irp.f @@ -51,16 +51,24 @@ if(cfg_seniority_index(i+2) > ncfgpersomo) then ncfgpersomo = cfg_seniority_index(i+2) else - k = 0 - if ((i+2+k) < size(cfg_seniority_index,1)) then - do while(cfg_seniority_index(i+2+k) < ncfgpersomo) - k = k + 2 - if ((i+2+k) >= size(cfg_seniority_index,1)) then - exit - endif - ncfgpersomo = cfg_seniority_index(i+2+k) - enddo - endif + ! l = i+k+2 + ! Loop over l with a constraint to ensure that l <= size(cfg_seniority_index,1)-1 + ! Old version commented just below + do l = min(size(cfg_seniority_index,1)-1, i+2), size(cfg_seniority_index,1)-1, 2 + if (cfg_seniority_index(l) >= ncfgpersomo) then + ncfgpersomo = cfg_seniority_index(l) + endif + enddo + !k = 0 + !if ((i+2+k) < size(cfg_seniority_index,1)) then + ! do while(cfg_seniority_index(i+2+k) < ncfgpersomo) + ! k = k + 2 + ! if ((i+2+k) >= size(cfg_seniority_index,1)) then + ! exit + ! endif + ! ncfgpersomo = cfg_seniority_index(i+2+k) + ! enddo + !endif endif endif ncfg = ncfgpersomo - ncfgprev @@ -79,16 +87,26 @@ if(cfg_seniority_index(i+2) > ncfgprev) then ncfgprev = cfg_seniority_index(i+2) else - k = 0 - if ((i+2+k) < size(cfg_seniority_index,1)) then - do while(cfg_seniority_index(i+2+k) < ncfgprev) - k = k + 2 - if ((i+2+k) >= size(cfg_seniority_index,1)) then - exit - endif - ncfgprev = cfg_seniority_index(i+2+k) - enddo - endif + ! l = i+k+2 + ! Loop over l with a constraint to ensure that l <= size(cfg_seniority_index,1)-1 + ! Old version commented just below + do l = min(size(cfg_seniority_index,1)-1, i+2), size(cfg_seniority_index,1)-1, 2 + print*,'l' + if (cfg_seniority_index(l) >= ncfgprev) then + ncfgprev = cfg_seniority_index(l) + endif + print*,'ncfgprev', ncfgprev + enddo + !k = 0 + !if ((i+2+k) < size(cfg_seniority_index,1)) then + ! do while(cfg_seniority_index(i+2+k) < ncfgprev) + ! k = k + 2 + ! if ((i+2+k) >= size(cfg_seniority_index,1)) then + ! exit + ! endif + ! ncfgprev = cfg_seniority_index(i+2+k) + ! enddo + !endif endif enddo END_PROVIDER From bda895104242464d927be55e4b6a8426e23975c0 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 24 Mar 2022 16:18:51 +0100 Subject: [PATCH 24/79] remove print --- src/csf/sigma_vector.irp.f | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/csf/sigma_vector.irp.f b/src/csf/sigma_vector.irp.f index 026dd839..5aaba9a3 100644 --- a/src/csf/sigma_vector.irp.f +++ b/src/csf/sigma_vector.irp.f @@ -91,11 +91,9 @@ ! Loop over l with a constraint to ensure that l <= size(cfg_seniority_index,1)-1 ! Old version commented just below do l = min(size(cfg_seniority_index,1)-1, i+2), size(cfg_seniority_index,1)-1, 2 - print*,'l' if (cfg_seniority_index(l) >= ncfgprev) then ncfgprev = cfg_seniority_index(l) endif - print*,'ncfgprev', ncfgprev enddo !k = 0 !if ((i+2+k) < size(cfg_seniority_index,1)) then From e63fa3fdd5f9c1770fccad32d93bdd045b7ccf6f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 25 Mar 2022 09:30:43 +0100 Subject: [PATCH 25/79] Fixed tooth_width=0.0 --- src/cipsi/pt2_stoch_routines.irp.f | 3 +-- src/cipsi/selection.irp.f | 2 +- src/dressing/alpha_factory.irp.f | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index 5019c957..db0b1527 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -842,9 +842,8 @@ END_PROVIDER do t=1, pt2_N_teeth tooth_width = tilde_cW(pt2_n_0(t+1)) - tilde_cW(pt2_n_0(t)) if (tooth_width == 0.d0) then - tooth_width = sum(tilde_w(pt2_n_0(t):pt2_n_0(t+1))) + tooth_width = max(1.d-15,sum(tilde_w(pt2_n_0(t):pt2_n_0(t+1)))) endif - ASSERT(tooth_width > 0.d0) do i=pt2_n_0(t)+1, pt2_n_0(t+1) pt2_w(i) = tilde_w(i) * pt2_W_T / tooth_width end do diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index acb91fb5..d4d44c2d 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -1550,7 +1550,7 @@ subroutine bitstring_to_list_in_selection( string, list, n_elements, Nint) use bitmasks implicit none BEGIN_DOC - ! Gives the inidices(+1) of the bits set to 1 in the bit string + ! Gives the indices(+1) of the bits set to 1 in the bit string END_DOC integer, intent(in) :: Nint integer(bit_kind), intent(in) :: string(Nint) diff --git a/src/dressing/alpha_factory.irp.f b/src/dressing/alpha_factory.irp.f index 5eeeb1a6..c7adffe3 100644 --- a/src/dressing/alpha_factory.irp.f +++ b/src/dressing/alpha_factory.irp.f @@ -1179,7 +1179,7 @@ subroutine bitstring_to_list_in_selection( string, list, n_elements, Nint) use bitmasks implicit none BEGIN_DOC - ! Gives the inidices(+1) of the bits set to 1 in the bit string + ! Gives the indices(+1) of the bits set to 1 in the bit string END_DOC integer, intent(in) :: Nint integer(bit_kind), intent(in) :: string(Nint) From 1a890a78df6d90d73a633cccc1c0b9cc35e373be Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 25 Mar 2022 09:32:56 +0100 Subject: [PATCH 26/79] dsqrt --- src/cipsi/pt2_stoch_routines.irp.f | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index db0b1527..c7cee1ac 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -523,15 +523,15 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2_data, pt2_data_ ! 1/(N-1.5) : see Brugger, The American Statistician (23) 4 p. 32 (1969) if(c > 2) then eqt = dabs((pt2_data_S2(t) % pt2(pt2_stoch_istate) / c) - (pt2_data_S(t) % pt2(pt2_stoch_istate)/c)**2) ! dabs for numerical stability - eqt = sqrt(eqt / (dble(c) - 1.5d0)) + eqt = dsqrt(eqt / (dble(c) - 1.5d0)) pt2_data_err % pt2(pt2_stoch_istate) = eqt eqt = dabs((pt2_data_S2(t) % variance(pt2_stoch_istate) / c) - (pt2_data_S(t) % variance(pt2_stoch_istate)/c)**2) ! dabs for numerical stability - eqt = sqrt(eqt / (dble(c) - 1.5d0)) + eqt = dsqrt(eqt / (dble(c) - 1.5d0)) pt2_data_err % variance(pt2_stoch_istate) = eqt eqta(:) = dabs((pt2_data_S2(t) % overlap(:,pt2_stoch_istate) / c) - (pt2_data_S(t) % overlap(:,pt2_stoch_istate)/c)**2) ! dabs for numerical stability - eqta(:) = sqrt(eqta(:) / (dble(c) - 1.5d0)) + eqta(:) = dsqrt(eqta(:) / (dble(c) - 1.5d0)) pt2_data_err % overlap(:,pt2_stoch_istate) = eqta(:) From 10446b66bd75e906a37a2af35905abaaf068dda5 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 25 Mar 2022 15:29:28 +0100 Subject: [PATCH 27/79] Minor change --- src/cipsi/selection.irp.f | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index f1ec6ff6..e62d5c8a 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -783,7 +783,9 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d alpha_h_psi = mat(istate, p1, p2) - pt2_data % overlap(:,istate) = pt2_data % overlap(:,istate) + coef(:) * coef(istate) + do k=1,N_states + pt2_data % overlap(k,istate) = pt2_data % overlap(k,istate) + coef(k) * coef(istate) + end do pt2_data % variance(istate) = pt2_data % variance(istate) + alpha_h_psi * alpha_h_psi pt2_data % pt2(istate) = pt2_data % pt2(istate) + e_pert(istate) From 511a80e062213a76d2bc7aa7cf7179c74786de24 Mon Sep 17 00:00:00 2001 From: ydamour Date: Mon, 28 Mar 2022 20:08:35 +0200 Subject: [PATCH 28/79] add excitation energies in eV --- src/cis/cis.irp.f | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cis/cis.irp.f b/src/cis/cis.irp.f index ab2294ad..f72197c2 100644 --- a/src/cis/cis.irp.f +++ b/src/cis/cis.irp.f @@ -62,6 +62,7 @@ subroutine run else call H_apply_cis endif + print*,'' print *, 'N_det = ', N_det print*,'******************************' print *, 'Energies of the states:' @@ -69,11 +70,13 @@ subroutine run print *, i, CI_energy(i) enddo if (N_states > 1) then - print*,'******************************' - print*,'Excitation energies ' + print*,'' + print*,'******************************************************' + print*,'Excitation energies (au) (eV)' do i = 2, N_states - print*, i ,CI_energy(i) - CI_energy(1) + print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1))/0.0367502d0 enddo + print*,'' endif call ezfio_set_cis_energy(CI_energy) From e3e403692195d04e2c1e15546d9eea738eab909e Mon Sep 17 00:00:00 2001 From: ydamour Date: Tue, 5 Apr 2022 16:12:47 +0200 Subject: [PATCH 29/79] Fix psi_det_size --- src/determinants/determinants.irp.f | 43 +++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index b8c8658f..eeadf779 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -77,28 +77,31 @@ BEGIN_PROVIDER [ integer, psi_det_size ] END_DOC PROVIDE ezfio_filename logical :: exists - if (mpi_master) then - call ezfio_has_determinants_n_det(exists) - if (exists) then - call ezfio_get_determinants_n_det(psi_det_size) - else - psi_det_size = 1 + psi_det_size = 1 + PROVIDE mpi_master + if (read_wf) then + if (mpi_master) then + call ezfio_has_determinants_n_det(exists) + if (exists) then + call ezfio_get_determinants_n_det(psi_det_size) + else + psi_det_size = 1 + endif + call write_int(6,psi_det_size,'Dimension of the psi arrays') endif - call write_int(6,psi_det_size,'Dimension of the psi arrays') + IRP_IF MPI_DEBUG + print *, irp_here, mpi_rank + call MPI_BARRIER(MPI_COMM_WORLD, ierr) + IRP_ENDIF + IRP_IF MPI + include 'mpif.h' + integer :: ierr + call MPI_BCAST( psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) + if (ierr /= MPI_SUCCESS) then + stop 'Unable to read psi_det_size with MPI' + endif + IRP_ENDIF endif - IRP_IF MPI_DEBUG - print *, irp_here, mpi_rank - call MPI_BARRIER(MPI_COMM_WORLD, ierr) - IRP_ENDIF - IRP_IF MPI - include 'mpif.h' - integer :: ierr - call MPI_BCAST( psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) - if (ierr /= MPI_SUCCESS) then - stop 'Unable to read psi_det_size with MPI' - endif - IRP_ENDIF - END_PROVIDER From e6d08356577968e79a81faa56dbbca83a4d62855 Mon Sep 17 00:00:00 2001 From: ydamour Date: Fri, 8 Apr 2022 17:21:03 +0200 Subject: [PATCH 30/79] fix error pt2 from det already in the wf --- src/cipsi/selection.irp.f | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index d4d44c2d..2d8d34d5 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -195,7 +195,10 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d integer :: l_a, nmax, idx integer, allocatable :: indices(:), exc_degree(:), iorder(:) - double precision, parameter :: norm_thr = 1.d-16 + + ! Removed to avoid introducing determinants already presents in the wf + !double precision, parameter :: norm_thr = 1.d-16 + allocate (indices(N_det), & exc_degree(max(N_det_alpha_unique,N_det_beta_unique))) @@ -215,10 +218,11 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d i = psi_bilinear_matrix_rows(l_a) if (nt + exc_degree(i) <= 4) then idx = psi_det_sorted_order(psi_bilinear_matrix_order(l_a)) - if (psi_average_norm_contrib_sorted(idx) > norm_thr) then + ! Removed to avoid introducing determinants already presents in the wf + !if (psi_average_norm_contrib_sorted(idx) > norm_thr) then indices(k) = idx k=k+1 - endif + !endif endif enddo enddo @@ -242,10 +246,11 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d idx = psi_det_sorted_order( & psi_bilinear_matrix_order( & psi_bilinear_matrix_transp_order(l_a))) - if (psi_average_norm_contrib_sorted(idx) > norm_thr) then + ! Removed to avoid introducing determinants already presents in the wf + !if (psi_average_norm_contrib_sorted(idx) > norm_thr) then indices(k) = idx k=k+1 - endif + !endif endif enddo enddo @@ -566,6 +571,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d double precision, external :: diag_H_mat_elem_fock double precision :: E_shift double precision :: s_weight(N_states,N_states) + logical, external :: is_in_wavefunction PROVIDE dominant_dets_of_cfgs N_dominant_dets_of_cfgs do jstate=1,N_states do istate=1,N_states @@ -830,6 +836,24 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d end select end do + ! To force the inclusion of determinants with a positive pt2 contribution + if (e_pert(istate) > 1d-8) then + w = -huge(1.0) + endif + +!!!BEGIN_DEBUG +! ! To check if the pt2 is taking determinants already in the wf +! if (is_in_wavefunction(det(N_int,1),N_int)) then +! print*, 'A determinant contributing to the pt2 is already in' +! print*, 'the wave function:' +! call print_det(det(N_int,1),N_int) +! print*,'contribution to the pt2 for the states:', e_pert(:) +! print*,'error in the filtering in' +! print*, 'cipsi/selection.irp.f sub: selecte_singles_and_doubles' +! print*, 'abort' +! call abort +! endif +!!!END_DEBUG integer(bit_kind) :: occ(N_int,2), n if (h0_type == 'CFG') then From 52c460367de1ba0e584d4668aca79fa9ec6549a1 Mon Sep 17 00:00:00 2001 From: ydamour Date: Mon, 11 Apr 2022 13:55:00 +0200 Subject: [PATCH 31/79] fix error pt2 --- src/cipsi/selection.irp.f | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index 2d8d34d5..1317fcf3 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -834,12 +834,13 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d endif end select - end do - ! To force the inclusion of determinants with a positive pt2 contribution - if (e_pert(istate) > 1d-8) then - w = -huge(1.0) - endif + ! To force the inclusion of determinants with a positive pt2 contribution + if (e_pert(istate) > 1d-8) then + w = -huge(1.0) + endif + + end do !!!BEGIN_DEBUG ! ! To check if the pt2 is taking determinants already in the wf From 19185c06f4c39bbba3dd50d029f4acb8b52f1075 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 11 Apr 2022 23:55:17 +0200 Subject: [PATCH 32/79] Add cipsi_save.sh --- scripts/cipsi_save.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/cipsi_save.sh diff --git a/scripts/cipsi_save.sh b/scripts/cipsi_save.sh new file mode 100644 index 00000000..a4d9b65e --- /dev/null +++ b/scripts/cipsi_save.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# This script runs a CIPSI calculation as a sequence of single CIPSI iterations. +# After each iteration, the EZFIO directory is saved. +# +# Usage: cipsi_save [EZFIO_FILE] [NDET] +# +# Example: cipsi_save file.ezfio 10000 + +EZ=$1 +NDETMAX=$2 + +qp set_file ${EZ} +qp reset -d +qp set determinants read_wf true +declare -i NDET +NDET=1 +while [[ ${NDET} -lt ${NDETMAX} ]] +do + NDET=$(($NDET + $NDET)) + qp set determinants n_det_max $NDET + qp run fci > ${EZ}.out + NDET=$(qp get determinants n_det) + mv ${EZ}.out ${EZ}.${NDET}.out + cp -r ${EZ} ${EZ}.${NDET} +done + From 82409d3e737ba3481523051248065c3fd9d1fab1 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 15:49:20 +0200 Subject: [PATCH 33/79] Added drone CI config --- .drone.yml | 36 ++++++++++++++++++++++++++++++ drone/Docker/README.md | 8 +++++++ drone/Docker/Ubuntu/Dockerfile | 27 ++++++++++++++++++++++ {travis => drone}/compilation.sh | 0 {travis => drone}/configuration.sh | 0 {travis => drone}/testing.sh | 0 6 files changed, 71 insertions(+) create mode 100644 .drone.yml create mode 100644 drone/Docker/README.md create mode 100644 drone/Docker/Ubuntu/Dockerfile rename {travis => drone}/compilation.sh (100%) rename {travis => drone}/configuration.sh (100%) rename {travis => drone}/testing.sh (100%) diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000..39d035db --- /dev/null +++ b/.drone.yml @@ -0,0 +1,36 @@ +--- +kind: pipeline +type: ssh +name: default + +clone: + depth: 10 + +server: + host: 130.120.229.139 + user: test + password: + from_secret: ssh_pass + +steps: +- name: configure + pull: never + image: ubuntu/qp2_env + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama + - source quantum_package.rc ; qp plugins install champ + +- name: compile + pull: never + image: ubuntu/qp2_env + commands: + - ninja + +- name: testing + pull: never + image: ubuntu/qp2_env + commands: + - qp test + + diff --git a/drone/Docker/README.md b/drone/Docker/README.md new file mode 100644 index 00000000..eb569777 --- /dev/null +++ b/drone/Docker/README.md @@ -0,0 +1,8 @@ +Docker files to build the containers used with DroneCI. + +Example: +``` +docker build -t ubuntu/qp2_env . + +``` + diff --git a/drone/Docker/Ubuntu/Dockerfile b/drone/Docker/Ubuntu/Dockerfile new file mode 100644 index 00000000..05d87ad8 --- /dev/null +++ b/drone/Docker/Ubuntu/Dockerfile @@ -0,0 +1,27 @@ +ARG UBUNTU_VERSION=20.04 +FROM ubuntu:${UBUNTU_VERSION} AS builder + +# Timezone for tzdata +ARG tz=Etc/UTC +RUN echo $tz > /etc/timezone && rm -rf /etc/localtime + +# Install +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + git \ + curl \ + wget \ + python3 \ + gfortran \ + gcc \ + g++ \ + make \ + build-essential \ + rsync \ + unzip \ + libopenblas-dev \ + pkg-config \ + m4 + +RUN ln -s /usr/bin/python3 /usr/bin/python + + diff --git a/travis/compilation.sh b/drone/compilation.sh similarity index 100% rename from travis/compilation.sh rename to drone/compilation.sh diff --git a/travis/configuration.sh b/drone/configuration.sh similarity index 100% rename from travis/configuration.sh rename to drone/configuration.sh diff --git a/travis/testing.sh b/drone/testing.sh similarity index 100% rename from travis/testing.sh rename to drone/testing.sh From 554af892ff1568491475033a5d4201e81551d54a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 15:55:51 +0200 Subject: [PATCH 34/79] Update drone --- .drone.yml | 37 +------------------------------------ drone/drone_docker | 30 ++++++++++++++++++++++++++++++ drone/drone_ssh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 36 deletions(-) mode change 100644 => 120000 .drone.yml create mode 100644 drone/drone_docker create mode 100644 drone/drone_ssh diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 39d035db..00000000 --- a/.drone.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -kind: pipeline -type: ssh -name: default - -clone: - depth: 10 - -server: - host: 130.120.229.139 - user: test - password: - from_secret: ssh_pass - -steps: -- name: configure - pull: never - image: ubuntu/qp2_env - commands: - - ./configure -i all -c ./config/gfortran_debug.cfg - - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - - source quantum_package.rc ; qp plugins install champ - -- name: compile - pull: never - image: ubuntu/qp2_env - commands: - - ninja - -- name: testing - pull: never - image: ubuntu/qp2_env - commands: - - qp test - - diff --git a/.drone.yml b/.drone.yml new file mode 120000 index 00000000..b44fc76b --- /dev/null +++ b/.drone.yml @@ -0,0 +1 @@ +drone/drone_ssh \ No newline at end of file diff --git a/drone/drone_docker b/drone/drone_docker new file mode 100644 index 00000000..0cbeb613 --- /dev/null +++ b/drone/drone_docker @@ -0,0 +1,30 @@ +--- +kind: pipeline +type: ssh +name: default + +clone: + depth: 10 + +steps: +- name: configure + pull: never + image: ubuntu/qp2_env + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama + - source quantum_package.rc ; qp plugins install champ + +- name: compile + pull: never + image: ubuntu/qp2_env + commands: + - ninja + +- name: testing + pull: never + image: ubuntu/qp2_env + commands: + - qp test + + diff --git a/drone/drone_ssh b/drone/drone_ssh new file mode 100644 index 00000000..e15b3fd5 --- /dev/null +++ b/drone/drone_ssh @@ -0,0 +1,30 @@ +--- +kind: pipeline +type: ssh +name: default + +clone: + depth: 10 + +server: + host: 130.120.229.139 + user: test + password: + from_secret: ssh_pass + +steps: +- name: configure + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama + - source quantum_package.rc ; qp plugins install champ + +- name: compile + commands: + - ninja + +- name: testing + commands: + - qp test + + From c3d95a8562cf128c56d598a644e9900831ced72c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 16:00:33 +0200 Subject: [PATCH 35/79] Drone --- drone/{drone_docker => drone_docker.yml} | 0 drone/{drone_ssh => drone_ssh.yml} | 1 - 2 files changed, 1 deletion(-) rename drone/{drone_docker => drone_docker.yml} (100%) rename drone/{drone_ssh => drone_ssh.yml} (99%) diff --git a/drone/drone_docker b/drone/drone_docker.yml similarity index 100% rename from drone/drone_docker rename to drone/drone_docker.yml diff --git a/drone/drone_ssh b/drone/drone_ssh.yml similarity index 99% rename from drone/drone_ssh rename to drone/drone_ssh.yml index e15b3fd5..99397f11 100644 --- a/drone/drone_ssh +++ b/drone/drone_ssh.yml @@ -1,4 +1,3 @@ ---- kind: pipeline type: ssh name: default From 57bf2e2739873d83fc93138fa27dfa53cc52d803 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 17:25:48 +0200 Subject: [PATCH 36/79] Drone --- .drone.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) mode change 120000 => 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 120000 index b44fc76b..00000000 --- a/.drone.yml +++ /dev/null @@ -1 +0,0 @@ -drone/drone_ssh \ No newline at end of file diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000..99397f11 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,29 @@ +kind: pipeline +type: ssh +name: default + +clone: + depth: 10 + +server: + host: 130.120.229.139 + user: test + password: + from_secret: ssh_pass + +steps: +- name: configure + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama + - source quantum_package.rc ; qp plugins install champ + +- name: compile + commands: + - ninja + +- name: testing + commands: + - qp test + + From e813fd04f92d0ceabd39b526db86c68dcfec8b6f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Apr 2022 17:29:29 +0200 Subject: [PATCH 37/79] Drone --- .drone.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 99397f11..0cbeb613 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,3 +1,4 @@ +--- kind: pipeline type: ssh name: default @@ -5,24 +6,24 @@ name: default clone: depth: 10 -server: - host: 130.120.229.139 - user: test - password: - from_secret: ssh_pass - steps: - name: configure + pull: never + image: ubuntu/qp2_env commands: - ./configure -i all -c ./config/gfortran_debug.cfg - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - source quantum_package.rc ; qp plugins install champ - name: compile + pull: never + image: ubuntu/qp2_env commands: - ninja - name: testing + pull: never + image: ubuntu/qp2_env commands: - qp test From 69138a2d25e5ed6e5924f6b9c28bc5846a86c06e Mon Sep 17 00:00:00 2001 From: kossoski Date: Wed, 13 Apr 2022 13:25:39 +0200 Subject: [PATCH 38/79] Hierarchy CI --- src/cipsi/EZFIO.cfg | 6 ++++++ src/cipsi/selection.irp.f | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/cipsi/EZFIO.cfg b/src/cipsi/EZFIO.cfg index 7fcf19eb..e01359c5 100644 --- a/src/cipsi/EZFIO.cfg +++ b/src/cipsi/EZFIO.cfg @@ -34,3 +34,9 @@ doc: Maximum number of excitation for beta determinants with respect to the Hart interface: ezfio,ocaml,provider default: -1 +[twice_hierarchy_max] +type: integer +doc: Twice the maximum hierarchy parameter (excitation degree plus half the seniority number). Using -1 selects all determinants +interface: ezfio,ocaml,provider +default: -1 + diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index 1317fcf3..c8bc75d3 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -713,6 +713,25 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d if (do_cycle) cycle endif + if (twice_hierarchy_max >= 0) then + s = 0 + do k=1,N_int + s = s + popcnt(ieor(det(k,1),det(k,2))) + enddo + if ( mod(s,2)>0 ) stop 'For now, hierarchy CI is defined only for an even number of electrons' + if (excitation_ref == 1) then + call get_excitation_degree(HF_bitmask,det(1,1),degree,N_int) + else if (excitation_ref == 2) then + stop 'For now, hierarchy CI is defined only for a single reference determinant' +! 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) +! enddo + endif + integer :: twice_hierarchy + twice_hierarchy = degree + s/2 + if (twice_hierarchy_max > twice_hierarchy_max) cycle + endif + Hii = diag_H_mat_elem_fock(psi_det_generators(1,1,i_generator),det,fock_diag_tmp,N_int) w = 0d0 From 62c28db6da5887e3198e4491ce7671f74dc003f0 Mon Sep 17 00:00:00 2001 From: kossoski Date: Wed, 13 Apr 2022 13:32:14 +0200 Subject: [PATCH 39/79] correction --- src/cipsi/selection.irp.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index c8bc75d3..d4f184f3 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -729,7 +729,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d endif integer :: twice_hierarchy twice_hierarchy = degree + s/2 - if (twice_hierarchy_max > twice_hierarchy_max) cycle + if (twice_hierarchy > twice_hierarchy_max) cycle endif Hii = diag_H_mat_elem_fock(psi_det_generators(1,1,i_generator),det,fock_diag_tmp,N_int) From 8cbabc64943194c17543bc5c72d61dce3597e655 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 Apr 2022 13:40:04 +0200 Subject: [PATCH 40/79] Fixed ref values for tests --- src/fci/40.fci.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index f2c78067..864a9d59 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -59,13 +59,13 @@ function run_stoch() { @test "HCO" { # 12.2868s qp set_file hco.ezfio - run -113.389297812482 6.e-4 100000 + run -113.393356604085 6.e-4 100000 } @test "H2O2" { # 12.9214s qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run -151.00467 1.e-4 100000 + run -151.005848404095 1.e-4 100000 } @test "HBO" { # 13.3144s From 3762409767713d1df7f7f99dbc034372d86a599b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 Apr 2022 17:58:24 +0200 Subject: [PATCH 41/79] Fixed ref values for tests --- src/fci/40.fci.bats | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 864a9d59..3139ebb8 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -59,43 +59,43 @@ function run_stoch() { @test "HCO" { # 12.2868s qp set_file hco.ezfio - run -113.393356604085 6.e-4 100000 + run -113.393356604085 1.e-3 100000 } @test "H2O2" { # 12.9214s qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run -151.005848404095 1.e-4 100000 + run -151.005848404095 1.e-3 100000 } @test "HBO" { # 13.3144s [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run -100.212560384678 1.e-3 100000 + run -100.214099486337 1.e-3 100000 } @test "H2O" { # 11.3727s [[ -n $TRAVIS ]] && skip qp set_file h2o.ezfio - run -76.2361605151999 3.e-4 100000 + run -76.2361605151999 5.e-4 100000 } @test "ClO" { # 13.3755s [[ -n $TRAVIS ]] && skip qp set_file clo.ezfio - run -534.545616787223 3.e-4 100000 + run -534.546453546852 1.e-3 100000 } @test "SO" { # 13.4952s [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.0096209515081 1.e-3 100000 + run -26.0176563764039 1.e-3 100000 } @test "H2S" { # 13.6745s [[ -n $TRAVIS ]] && skip qp set_file h2s.ezfio - run -398.859168655255 3.e-4 100000 + run -398.859577605891 5.e-4 100000 } @test "OH" { # 13.865s @@ -113,13 +113,13 @@ function run_stoch() { @test "H3COH" { # 14.7299s [[ -n $TRAVIS ]] && skip qp set_file h3coh.ezfio - run -115.205191406072 3.e-4 100000 + run -115.205632960026 1.e-3 100000 } @test "SiH3" { # 15.99s [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run -5.57241217753818 3.e-4 100000 + run -5.57241217753818 5.e-4 100000 } @test "CH4" { # 16.1612s @@ -132,7 +132,7 @@ function run_stoch() { @test "ClF" { # 16.8864s [[ -n $TRAVIS ]] && skip qp set_file clf.ezfio - run -559.169313755572 3.e-4 100000 + run -559.169748890031 1.e-3 100000 } @test "SO2" { # 17.5645s @@ -146,14 +146,14 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 3.e-4 100000 + run -12.3685464085969 1.e-3 100000 } @test "N2" { # 18.0198s [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.28681540699360 3.e-4 100000 + run -109.287917088107 1.e-3 100000 } @test "N2H4" { # 18.5006s @@ -167,7 +167,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file co2.ezfio qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" - run -187.968547952413 3.e-4 100000 + run -187.970184372047 1.e-3 100000 } @@ -182,6 +182,6 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run -93.0771143355433 3.e-4 100000 + run -93.0777619629755 1.e-3 100000 } From a1ed2282faa2e78fee014197f1da167603988c8a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 Apr 2022 19:54:14 +0200 Subject: [PATCH 42/79] Adjust tests --- src/fci/40.fci.bats | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 3139ebb8..1a0c5507 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -132,28 +132,28 @@ function run_stoch() { @test "ClF" { # 16.8864s [[ -n $TRAVIS ]] && skip qp set_file clf.ezfio - run -559.169748890031 1.e-3 100000 + run -559.169748890031 1.5e-3 100000 } @test "SO2" { # 17.5645s [[ -n $TRAVIS ]] && skip qp set_file so2.ezfio qp set_mo_class --core="[1-8]" --act="[9-87]" - run -41.5746738713298 3.e-4 100000 + run -41.5746738713298 1.5e-3 100000 } @test "C2H2" { # 17.6827s [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 1.e-3 100000 + run -12.3685464085969 2.e-3 100000 } @test "N2" { # 18.0198s [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.287917088107 1.e-3 100000 + run -109.287917088107 1.5e-3 100000 } @test "N2H4" { # 18.5006s @@ -167,7 +167,7 @@ function run_stoch() { [[ -n $TRAVIS ]] && skip qp set_file co2.ezfio qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" - run -187.970184372047 1.e-3 100000 + run -187.970184372047 1.5e-3 100000 } From d692391b6b644dec09f468fc082552b382a02044 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 Apr 2022 23:58:55 +0200 Subject: [PATCH 43/79] Drone CI file --- .drone.yml | 38 +++++++++++++++++++++++++++++--------- drone/drone_docker.yml | 2 +- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.drone.yml b/.drone.yml index 0cbeb613..4d20225b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,30 +1,50 @@ --- kind: pipeline -type: ssh +type: docker name: default clone: depth: 10 steps: +- name: setup + image: ubuntu + commands: + - apt-get update + - DEBIAN_FRONTEND=noninteractive apt-get install -y \ + git \ + curl \ + wget \ + python3 \ + gfortran \ + gcc \ + g++ \ + make \ + build-essential \ + rsync \ + unzip \ + libopenblas-dev \ + pkg-config \ + m4 \ + python3 + - ln -s /usr/bin/python3 /usr/bin/python + + - name: configure - pull: never - image: ubuntu/qp2_env + image: ubuntu commands: - ./configure -i all -c ./config/gfortran_debug.cfg - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - source quantum_package.rc ; qp plugins install champ - name: compile - pull: never - image: ubuntu/qp2_env + image: ubuntu commands: - - ninja + - source quantum_package.rc ; ninja - name: testing - pull: never - image: ubuntu/qp2_env + image: ubuntu commands: - - qp test + - source quantum_package.rc ; qp test -a diff --git a/drone/drone_docker.yml b/drone/drone_docker.yml index 0cbeb613..d1eb7175 100644 --- a/drone/drone_docker.yml +++ b/drone/drone_docker.yml @@ -1,6 +1,6 @@ --- kind: pipeline -type: ssh +type: docker name: default clone: From 75dca5f9b5d79681729f713366a120a5e26d6e3f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 14 Apr 2022 01:15:21 +0200 Subject: [PATCH 44/79] Update droneCI --- .drone.yml | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4d20225b..b213de7b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,44 +7,22 @@ clone: depth: 10 steps: -- name: setup - image: ubuntu - commands: - - apt-get update - - DEBIAN_FRONTEND=noninteractive apt-get install -y \ - git \ - curl \ - wget \ - python3 \ - gfortran \ - gcc \ - g++ \ - make \ - build-essential \ - rsync \ - unzip \ - libopenblas-dev \ - pkg-config \ - m4 \ - python3 - - ln -s /usr/bin/python3 /usr/bin/python - - name: configure - image: ubuntu + image: scemama666/qp2_env commands: - ./configure -i all -c ./config/gfortran_debug.cfg - - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - - source quantum_package.rc ; qp plugins install champ + - bash -c "source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama" + - bash -c "source quantum_package.rc ; qp plugins install champ" - name: compile - image: ubuntu + image: scemama666/qp2_env commands: - - source quantum_package.rc ; ninja + - bash -c "source quantum_package.rc ; exec ninja" - name: testing - image: ubuntu + image: scemama666/qp2_env commands: - - source quantum_package.rc ; qp test -a + - bash -c "source quantum_package.rc ; qp test -a" From 1c4e1e1eeb2958f144f9ac1bc65a66a7393304cd Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 19 Apr 2022 10:04:39 +0200 Subject: [PATCH 45/79] Drone CI --- .drone.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4d20225b..ad677e3a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -45,6 +45,21 @@ steps: - name: testing image: ubuntu commands: - - source quantum_package.rc ; qp test -a + - source quantum_package.rc ; TRAVIS=1 qp_test -a +- name: re-configure + image: ubuntu + commands: + - ./configure -i all -c ./config/gfortran_avx.cfg + +- name: compile + image: ubuntu + commands: + - source quantum_package.rc ; ninja + +- name: testing + image: ubuntu + commands: + - source quantum_package.rc ; qp_test -a + From 057fe8185b597eeee40ffc9568701246e21b513c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 19 Apr 2022 10:09:22 +0200 Subject: [PATCH 46/79] Drone CI --- .drone.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 799b6dc2..b4683b73 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,8 +12,8 @@ steps: image: scemama666/qp2_env commands: - ./configure -i all -c ./config/gfortran_debug.cfg - - bash -c "source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama" - - bash -c "source quantum_package.rc ; qp plugins install champ" + - bash -c "source quantum_package.rc ; exec qp_plugins download https://gitlab.com/scemama/qp_plugins_scemama" + - bash -c "source quantum_package.rc ; exec qp_plugins install champ" - name: compile image: scemama666/qp2_env @@ -23,7 +23,7 @@ steps: - name: testing image: scemama666/qp2_env commands: - - bash -c "source quantum_package.rc ; TRAVIS=1 qp_test -a" + - bash -c "source quantum_package.rc ; TRAVIS=1 exec qp_test -a" - name: re-configure @@ -34,10 +34,10 @@ steps: - name: compile image: ubuntu commands: - - bash -c "source quantum_package.rc ; ninja" + - bash -c "source quantum_package.rc ; exec ninja" - name: testing image: ubuntu commands: - - bash -c "source quantum_package.rc ; qp_test -a" + - bash -c "source quantum_package.rc ; exec qp_test -a" From 790b2d5f3fd874a33e0c5b6a8caedbe07dab2ebd Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 19 Apr 2022 10:13:38 +0200 Subject: [PATCH 47/79] Drone CI --- .drone.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index b4683b73..256b8e9b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,7 +1,7 @@ --- kind: pipeline type: docker -name: default +name: gfortran-debug clone: depth: 10 @@ -25,19 +25,28 @@ steps: commands: - bash -c "source quantum_package.rc ; TRAVIS=1 exec qp_test -a" +--- +kind: pipeline +type: docker +name: gfortran-avx -- name: re-configure - image: ubuntu +clone: + depth: 10 + +steps: + +- name: configure + image: scemama666/qp2_env commands: - ./configure -i all -c ./config/gfortran_avx.cfg - name: compile - image: ubuntu + image: scemama666/qp2_env commands: - bash -c "source quantum_package.rc ; exec ninja" - name: testing - image: ubuntu + image: scemama666/qp2_env commands: - bash -c "source quantum_package.rc ; exec qp_test -a" From 57b47807fa1b7265345d877ca4902e87f39935ba Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 21 Apr 2022 14:25:29 +0200 Subject: [PATCH 48/79] Added CIS_read --- src/cis_read/EZFIO.cfg | 7 +++ src/cis_read/NEED | 3 ++ src/cis_read/README.rst | 5 +++ src/cis_read/cis_read.irp.f | 88 +++++++++++++++++++++++++++++++++++++ src/cis_read/h_apply.irp.f | 14 ++++++ 5 files changed, 117 insertions(+) create mode 100644 src/cis_read/EZFIO.cfg create mode 100644 src/cis_read/NEED create mode 100644 src/cis_read/README.rst create mode 100644 src/cis_read/cis_read.irp.f create mode 100644 src/cis_read/h_apply.irp.f diff --git a/src/cis_read/EZFIO.cfg b/src/cis_read/EZFIO.cfg new file mode 100644 index 00000000..955d1bef --- /dev/null +++ b/src/cis_read/EZFIO.cfg @@ -0,0 +1,7 @@ +[energy] +type: double precision +doc: Variational |CIS| energy +interface: ezfio +size: (determinants.n_states) + + diff --git a/src/cis_read/NEED b/src/cis_read/NEED new file mode 100644 index 00000000..42992ac6 --- /dev/null +++ b/src/cis_read/NEED @@ -0,0 +1,3 @@ +selectors_full +generators_full +davidson_undressed diff --git a/src/cis_read/README.rst b/src/cis_read/README.rst new file mode 100644 index 00000000..31648636 --- /dev/null +++ b/src/cis_read/README.rst @@ -0,0 +1,5 @@ +=== +cis_read +=== + +Reads the input WF and performs all singles on top of it. diff --git a/src/cis_read/cis_read.irp.f b/src/cis_read/cis_read.irp.f new file mode 100644 index 00000000..055b5e15 --- /dev/null +++ b/src/cis_read/cis_read.irp.f @@ -0,0 +1,88 @@ +program cis + implicit none + BEGIN_DOC +! +! Configuration Interaction with Single excitations. +! +! This program takes a reference Slater determinant of ROHF-like +! occupancy, and performs all single excitations on top of it. +! Disregarding spatial symmetry, it computes the `n_states` lowest +! eigenstates of that CI matrix. (see :option:`determinants n_states`) +! +! This program can be useful in many cases: +! +! +! 1. Ground state calculation +! +! To be sure to have the lowest |SCF| solution, perform an :ref:`scf` +! (see the :ref:`module_hartree_fock` module), then a :ref:`cis`, save the +! natural orbitals (see :ref:`save_natorb`) and re-run an :ref:`scf` +! optimization from this |MO| guess. +! +! +! 2. Excited states calculations +! +! The lowest excited states are much likely to be dominated by +! single-excitations. Therefore, running a :ref:`cis` will save the +! `n_states` lowest states within the |CIS| space in the |EZFIO| +! directory, which can afterwards be used as guess wave functions for +! a further multi-state |FCI| calculation if :option:`determinants +! read_wf` is set to |true| before running the :ref:`fci` executable. +! +! +! If :option:`determinants s2_eig` is set to |true|, the |CIS| +! will only retain states having the expected |S^2| value (see +! :option:`determinants expected_s2`). Otherwise, the |CIS| will take +! the lowest :option:`determinants n_states`, whatever multiplicity +! they are. +! +! .. note:: +! +! To discard some orbitals, use the :ref:`qp_set_mo_class` +! command to specify: +! +! * *core* orbitals which will be always doubly occupied +! +! * *act* orbitals where an electron can be either excited from or to +! +! * *del* orbitals which will be never occupied +! + END_DOC + read_wf = .True. + TOUCH read_wf + call run +end + +subroutine run + implicit none + integer :: i + + + if(pseudo_sym)then + call H_apply_cis_sym + else + call H_apply_cis + endif + print*,'' + print *, 'N_det = ', N_det + print*,'******************************' + print *, 'Energies of the states:' + do i = 1,N_states + print *, i, CI_energy(i) + enddo + if (N_states > 1) then + print*,'' + print*,'******************************************************' + print*,'Excitation energies (au) (eV)' + do i = 2, N_states + print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1))/0.0367502d0 + enddo + print*,'' + endif + + call ezfio_set_cis_energy(CI_energy) + psi_coef = ci_eigenvectors + SOFT_TOUCH psi_coef + call save_wavefunction_truncated(save_threshold) + +end diff --git a/src/cis_read/h_apply.irp.f b/src/cis_read/h_apply.irp.f new file mode 100644 index 00000000..14389bed --- /dev/null +++ b/src/cis_read/h_apply.irp.f @@ -0,0 +1,14 @@ +! Generates subroutine H_apply_cis +! -------------------------------- + +BEGIN_SHELL [ /usr/bin/env python3 ] +from generate_h_apply import H_apply +H = H_apply("cis",do_double_exc=False) +print(H) + +H = H_apply("cis_sym",do_double_exc=False) +H.filter_only_connected_to_hf() +print(H) + +END_SHELL + From 7cd6b13805b9a9e59bb027181c6176182ad81ccb Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 1 May 2022 14:12:28 +0200 Subject: [PATCH 49/79] C quicksort --- src/utils/map_module.f90 | 6 +- src/utils/qsort.c | 373 ++++++++++++++++++++ src/utils/qsort.org | 169 +++++++++ src/utils/qsort_module.f90 | 347 ++++++++++++++++++ src/utils/sort.irp.f | 695 ------------------------------------- 5 files changed, 892 insertions(+), 698 deletions(-) create mode 100644 src/utils/qsort.c create mode 100644 src/utils/qsort.org create mode 100644 src/utils/qsort_module.f90 diff --git a/src/utils/map_module.f90 b/src/utils/map_module.f90 index 98e73470..ceaec874 100644 --- a/src/utils/map_module.f90 +++ b/src/utils/map_module.f90 @@ -238,11 +238,11 @@ subroutine cache_map_sort(map) iorder(i) = i enddo if (cache_key_kind == 2) then - call i2radix_sort(map%key,iorder,map%n_elements,-1) + call i2sort(map%key,iorder,map%n_elements,-1) else if (cache_key_kind == 4) then - call iradix_sort(map%key,iorder,map%n_elements,-1) + call isort(map%key,iorder,map%n_elements,-1) else if (cache_key_kind == 8) then - call i8radix_sort(map%key,iorder,map%n_elements,-1) + call i8sort(map%key,iorder,map%n_elements,-1) endif if (integral_kind == 4) then call set_order(map%value,iorder,map%n_elements) diff --git a/src/utils/qsort.c b/src/utils/qsort.c new file mode 100644 index 00000000..5d685741 --- /dev/null +++ b/src/utils/qsort.c @@ -0,0 +1,373 @@ +/* [[file:~/qp2/src/utils/qsort.org::*Generated%20C%20file][Generated C file:1]] */ +#include +#include + +struct int16_t_comp { + int16_t x; + int32_t i; +}; + +int compare_int16_t( const void * l, const void * r ) +{ + const struct int16_t_comp * restrict _l= l; + const struct int16_t_comp * restrict _r= r; + if( _l->x > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int16_t(int16_t* A_in, int32_t* iorder, int32_t isize) { + struct int16_t_comp* A = malloc(isize * sizeof(struct int16_t_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int16_t_big(int16_t* A_in, int64_t* iorder, int64_t isize) { + struct int16_t_comp_big* A = malloc(isize * sizeof(struct int16_t_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int32_t(int32_t* A_in, int32_t* iorder, int32_t isize) { + struct int32_t_comp* A = malloc(isize * sizeof(struct int32_t_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int32_t_big(int32_t* A_in, int64_t* iorder, int64_t isize) { + struct int32_t_comp_big* A = malloc(isize * sizeof(struct int32_t_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int64_t(int64_t* A_in, int32_t* iorder, int32_t isize) { + struct int64_t_comp* A = malloc(isize * sizeof(struct int64_t_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_int64_t_big(int64_t* A_in, int64_t* iorder, int64_t isize) { + struct int64_t_comp_big* A = malloc(isize * sizeof(struct int64_t_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_double(double* A_in, int32_t* iorder, int32_t isize) { + struct double_comp* A = malloc(isize * sizeof(struct double_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_double_big(double* A_in, int64_t* iorder, int64_t isize) { + struct double_comp_big* A = malloc(isize * sizeof(struct double_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_float(float* A_in, int32_t* iorder, int32_t isize) { + struct float_comp* A = malloc(isize * sizeof(struct float_comp)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_float_big(float* A_in, int64_t* iorder, int64_t isize) { + struct float_comp_big* A = malloc(isize * sizeof(struct float_comp_big)); + if (A == NULL) return; + + for (int i=0 ; ix > _r->x ) return 1; + if( _l->x < _r->x ) return -1; + return 0; +} + +void qsort_TYPE_big(TYPE* A_in, int32_t* iorder, int32_t isize) { + struct TYPE_comp_big* A = malloc(isize * sizeof(struct TYPE_comp_big)); + if (A == NULL) return; + + for (int i=0 ; i> +""" +for typ in ["int16_t", "int32_t", "int64_t", "double", "float"]: + print( data.replace("TYPE", typ).replace("_big", "") ) + print( data.replace("int32_t", "int64_t").replace("TYPE", typ) ) +#+end_src + +#+NAME: replaced_f +#+begin_src python :results output :noweb yes +data = """ +<> +""" +c1 = { + "int16_t": "i2", + "int32_t": "i", + "int64_t": "i8", + "double": "d", + "float": "" +} +c2 = { + "int16_t": "integer", + "int32_t": "integer", + "int64_t": "integer", + "double": "real", + "float": "real" +} + +for typ in ["int16_t", "int32_t", "int64_t", "double", "float"]: + print( data.replace("real",c2[typ]).replace("L",c1[typ]).replace("TYPE", typ).replace("_big", "") ) + print( data.replace("real",c2[typ]).replace("L",c1[typ]).replace("int32_t", "int64_t").replace("TYPE", typ) ) +#+end_src + +#+NAME: replaced_f2 +#+begin_src python :results output :noweb yes +data = """ +<> +""" +c1 = { + "int16_t": "i2", + "int32_t": "i", + "int64_t": "i8", + "double": "d", + "float": "" +} +c2 = { + "int16_t": "integer", + "int32_t": "integer", + "int64_t": "integer", + "double": "real", + "float": "real" +} + +for typ in ["int16_t", "int32_t", "int64_t", "double", "float"]: + print( data.replace("real",c2[typ]).replace("L",c1[typ]).replace("TYPE", typ).replace("_big", "") ) + print( data.replace("real",c2[typ]).replace("L",c1[typ]).replace("int32_t", "int64_t").replace("TYPE", typ) ) +#+end_src + +* Generated C file + +#+BEGIN_SRC c :comments link :tangle qsort.c :noweb yes +#include +#include +<> +#+END_SRC + +* Generated Fortran file + +#+BEGIN_SRC f90 :tangle qsort_module.f90 :noweb yes +module qsort_module + use iso_c_binding + + interface + <> + end interface + +end module qsort_module + +<> + +#+END_SRC + diff --git a/src/utils/qsort_module.f90 b/src/utils/qsort_module.f90 new file mode 100644 index 00000000..a72a4f9e --- /dev/null +++ b/src/utils/qsort_module.f90 @@ -0,0 +1,347 @@ +module qsort_module + use iso_c_binding + + interface + + subroutine i2sort_c(A, iorder, isize) bind(C, name="qsort_int16_t") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int16_t) :: A(isize) + end subroutine i2sort_c + + subroutine i2sort_noidx_c(A, isize) bind(C, name="qsort_int16_t_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + integer (c_int16_t) :: A(isize) + end subroutine i2sort_noidx_c + + + + subroutine i2sort_big_c(A, iorder, isize) bind(C, name="qsort_int16_t_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int16_t) :: A(isize) + end subroutine i2sort_big_c + + subroutine i2sort_noidx_big_c(A, isize) bind(C, name="qsort_int16_t_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer (c_int16_t) :: A(isize) + end subroutine i2sort_noidx_big_c + + + + subroutine isort_c(A, iorder, isize) bind(C, name="qsort_int32_t") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int32_t) :: A(isize) + end subroutine isort_c + + subroutine isort_noidx_c(A, isize) bind(C, name="qsort_int32_t_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + integer (c_int32_t) :: A(isize) + end subroutine isort_noidx_c + + + + subroutine isort_big_c(A, iorder, isize) bind(C, name="qsort_int32_t_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int32_t) :: A(isize) + end subroutine isort_big_c + + subroutine isort_noidx_big_c(A, isize) bind(C, name="qsort_int32_t_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer (c_int32_t) :: A(isize) + end subroutine isort_noidx_big_c + + + + subroutine i8sort_c(A, iorder, isize) bind(C, name="qsort_int64_t") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int64_t) :: A(isize) + end subroutine i8sort_c + + subroutine i8sort_noidx_c(A, isize) bind(C, name="qsort_int64_t_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + integer (c_int64_t) :: A(isize) + end subroutine i8sort_noidx_c + + + + subroutine i8sort_big_c(A, iorder, isize) bind(C, name="qsort_int64_t_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int64_t) :: A(isize) + end subroutine i8sort_big_c + + subroutine i8sort_noidx_big_c(A, isize) bind(C, name="qsort_int64_t_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer (c_int64_t) :: A(isize) + end subroutine i8sort_noidx_big_c + + + + subroutine dsort_c(A, iorder, isize) bind(C, name="qsort_double") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + real (c_double) :: A(isize) + end subroutine dsort_c + + subroutine dsort_noidx_c(A, isize) bind(C, name="qsort_double_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + real (c_double) :: A(isize) + end subroutine dsort_noidx_c + + + + subroutine dsort_big_c(A, iorder, isize) bind(C, name="qsort_double_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + real (c_double) :: A(isize) + end subroutine dsort_big_c + + subroutine dsort_noidx_big_c(A, isize) bind(C, name="qsort_double_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + real (c_double) :: A(isize) + end subroutine dsort_noidx_big_c + + + + subroutine sort_c(A, iorder, isize) bind(C, name="qsort_float") + use iso_c_binding + integer(c_int32_t), value :: isize + integer(c_int32_t) :: iorder(isize) + real (c_float) :: A(isize) + end subroutine sort_c + + subroutine sort_noidx_c(A, isize) bind(C, name="qsort_float_noidx") + use iso_c_binding + integer(c_int32_t), value :: isize + real (c_float) :: A(isize) + end subroutine sort_noidx_c + + + + subroutine sort_big_c(A, iorder, isize) bind(C, name="qsort_float_big") + use iso_c_binding + integer(c_int64_t), value :: isize + integer(c_int64_t) :: iorder(isize) + real (c_float) :: A(isize) + end subroutine sort_big_c + + subroutine sort_noidx_big_c(A, isize) bind(C, name="qsort_float_noidx_big") + use iso_c_binding + integer(c_int64_t), value :: isize + real (c_float) :: A(isize) + end subroutine sort_noidx_big_c + + + + end interface + +end module qsort_module + + +subroutine i2sort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int16_t) :: A(isize) + call i2sort_c(A, iorder, isize) +end subroutine i2sort + +subroutine i2sort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + integer (c_int16_t) :: A(isize) + call i2sort_noidx_c(A, isize) +end subroutine i2sort_noidx + + + +subroutine i2sort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int16_t) :: A(isize) + call i2sort_big_c(A, iorder, isize) +end subroutine i2sort_big + +subroutine i2sort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + integer (c_int16_t) :: A(isize) + call i2sort_noidx_big_c(A, isize) +end subroutine i2sort_noidx_big + + + +subroutine isort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int32_t) :: A(isize) + call isort_c(A, iorder, isize) +end subroutine isort + +subroutine isort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + integer (c_int32_t) :: A(isize) + call isort_noidx_c(A, isize) +end subroutine isort_noidx + + + +subroutine isort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int32_t) :: A(isize) + call isort_big_c(A, iorder, isize) +end subroutine isort_big + +subroutine isort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + integer (c_int32_t) :: A(isize) + call isort_noidx_big_c(A, isize) +end subroutine isort_noidx_big + + + +subroutine i8sort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + integer (c_int64_t) :: A(isize) + call i8sort_c(A, iorder, isize) +end subroutine i8sort + +subroutine i8sort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + integer (c_int64_t) :: A(isize) + call i8sort_noidx_c(A, isize) +end subroutine i8sort_noidx + + + +subroutine i8sort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + integer (c_int64_t) :: A(isize) + call i8sort_big_c(A, iorder, isize) +end subroutine i8sort_big + +subroutine i8sort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + integer (c_int64_t) :: A(isize) + call i8sort_noidx_big_c(A, isize) +end subroutine i8sort_noidx_big + + + +subroutine dsort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + real (c_double) :: A(isize) + call dsort_c(A, iorder, isize) +end subroutine dsort + +subroutine dsort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + real (c_double) :: A(isize) + call dsort_noidx_c(A, isize) +end subroutine dsort_noidx + + + +subroutine dsort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + real (c_double) :: A(isize) + call dsort_big_c(A, iorder, isize) +end subroutine dsort_big + +subroutine dsort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + real (c_double) :: A(isize) + call dsort_noidx_big_c(A, isize) +end subroutine dsort_noidx_big + + + +subroutine sort(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int32_t) :: isize + integer(c_int32_t) :: iorder(isize) + real (c_float) :: A(isize) + call sort_c(A, iorder, isize) +end subroutine sort + +subroutine sort_noidx(A, isize) + use iso_c_binding + use qsort_module + integer(c_int32_t) :: isize + real (c_float) :: A(isize) + call sort_noidx_c(A, isize) +end subroutine sort_noidx + + + +subroutine sort_big(A, iorder, isize) + use qsort_module + use iso_c_binding + integer(c_int64_t) :: isize + integer(c_int64_t) :: iorder(isize) + real (c_float) :: A(isize) + call sort_big_c(A, iorder, isize) +end subroutine sort_big + +subroutine sort_noidx_big(A, isize) + use iso_c_binding + use qsort_module + integer(c_int64_t) :: isize + real (c_float) :: A(isize) + call sort_noidx_big_c(A, isize) +end subroutine sort_noidx_big diff --git a/src/utils/sort.irp.f b/src/utils/sort.irp.f index ff40263c..089c3871 100644 --- a/src/utils/sort.irp.f +++ b/src/utils/sort.irp.f @@ -1,222 +1,4 @@ BEGIN_TEMPLATE - subroutine insertion_$Xsort (x,iorder,isize) - implicit none - BEGIN_DOC - ! Sort array x(isize) using the insertion sort algorithm. - ! iorder in input should be (1,2,3,...,isize), and in output - ! contains the new order of the elements. - END_DOC - integer,intent(in) :: isize - $type,intent(inout) :: x(isize) - integer,intent(inout) :: iorder(isize) - $type :: xtmp - integer :: i, i0, j, jmax - - do i=2,isize - xtmp = x(i) - i0 = iorder(i) - j=i-1 - do while (j>0) - if ((x(j) <= xtmp)) exit - x(j+1) = x(j) - iorder(j+1) = iorder(j) - j=j-1 - enddo - x(j+1) = xtmp - iorder(j+1) = i0 - enddo - end subroutine insertion_$Xsort - - subroutine quick_$Xsort(x, iorder, isize) - implicit none - BEGIN_DOC - ! Sort array x(isize) using the quicksort algorithm. - ! iorder in input should be (1,2,3,...,isize), and in output - ! contains the new order of the elements. - END_DOC - integer,intent(in) :: isize - $type,intent(inout) :: x(isize) - integer,intent(inout) :: iorder(isize) - integer, external :: omp_get_num_threads - call rec_$X_quicksort(x,iorder,isize,1,isize,nproc) - end - - recursive subroutine rec_$X_quicksort(x, iorder, isize, first, last, level) - implicit none - integer, intent(in) :: isize, first, last, level - integer,intent(inout) :: iorder(isize) - $type, intent(inout) :: x(isize) - $type :: c, tmp - integer :: itmp - integer :: i, j - - if(isize<2)return - - c = x( shiftr(first+last,1) ) - i = first - j = last - do - do while (x(i) < c) - i=i+1 - end do - do while (c < x(j)) - j=j-1 - end do - if (i >= j) exit - tmp = x(i) - x(i) = x(j) - x(j) = tmp - itmp = iorder(i) - iorder(i) = iorder(j) - iorder(j) = itmp - i=i+1 - j=j-1 - enddo - if ( ((i-first <= 10000).and.(last-j <= 10000)).or.(level<=0) ) then - if (first < i-1) then - call rec_$X_quicksort(x, iorder, isize, first, i-1,level/2) - endif - if (j+1 < last) then - call rec_$X_quicksort(x, iorder, isize, j+1, last,level/2) - endif - else - if (first < i-1) then - call rec_$X_quicksort(x, iorder, isize, first, i-1,level/2) - endif - if (j+1 < last) then - call rec_$X_quicksort(x, iorder, isize, j+1, last,level/2) - endif - endif - end - - subroutine heap_$Xsort(x,iorder,isize) - implicit none - BEGIN_DOC - ! Sort array x(isize) using the heap sort algorithm. - ! iorder in input should be (1,2,3,...,isize), and in output - ! contains the new order of the elements. - END_DOC - integer,intent(in) :: isize - $type,intent(inout) :: x(isize) - integer,intent(inout) :: iorder(isize) - - integer :: i, k, j, l, i0 - $type :: xtemp - - l = isize/2+1 - k = isize - do while (.True.) - if (l>1) then - l=l-1 - xtemp = x(l) - i0 = iorder(l) - else - xtemp = x(k) - i0 = iorder(k) - x(k) = x(1) - iorder(k) = iorder(1) - k = k-1 - if (k == 1) then - x(1) = xtemp - iorder(1) = i0 - exit - endif - endif - i=l - j = shiftl(l,1) - do while (j1) then - l=l-1 - xtemp = x(l) - i0 = iorder(l) - else - xtemp = x(k) - i0 = iorder(k) - x(k) = x(1) - iorder(k) = iorder(1) - k = k-1 - if (k == 1) then - x(1) = xtemp - iorder(1) = i0 - exit - endif - endif - i=l - j = shiftl(l,1) - do while (j0_8) - if (x(j)<=xtmp) exit - x(j+1_8) = x(j) - iorder(j+1_8) = iorder(j) - j = j-1_8 - enddo - x(j+1_8) = xtmp - iorder(j+1_8) = i0 - enddo - - end subroutine insertion_$Xsort_big - subroutine $Xset_order_big(x,iorder,isize) implicit none BEGIN_DOC @@ -565,223 +90,3 @@ SUBST [ X, type ] END_TEMPLATE -BEGIN_TEMPLATE - -recursive subroutine $Xradix_sort$big(x,iorder,isize,iradix) - implicit none - - BEGIN_DOC - ! Sort integer array x(isize) using the radix sort algorithm. - ! iorder in input should be (1,2,3,...,isize), and in output - ! contains the new order of the elements. - ! iradix should be -1 in input. - END_DOC - integer*$int_type, intent(in) :: isize - integer*$int_type, intent(inout) :: iorder(isize) - integer*$type, intent(inout) :: x(isize) - integer, intent(in) :: iradix - integer :: iradix_new - integer*$type, allocatable :: x2(:), x1(:) - integer*$type :: i4 ! data type - integer*$int_type, allocatable :: iorder1(:),iorder2(:) - integer*$int_type :: i0, i1, i2, i3, i ! index type - integer*$type :: mask - integer :: err - !DIR$ ATTRIBUTES ALIGN : 128 :: iorder1,iorder2, x2, x1 - - if (isize < 2) then - return - endif - - if (iradix == -1) then ! Sort Positive and negative - - allocate(x1(isize),iorder1(isize), x2(isize),iorder2(isize),stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to allocate arrays' - stop - endif - - i1=1_$int_type - i2=1_$int_type - do i=1_$int_type,isize - if (x(i) < 0_$type) then - iorder1(i1) = iorder(i) - x1(i1) = -x(i) - i1 = i1+1_$int_type - else - iorder2(i2) = iorder(i) - x2(i2) = x(i) - i2 = i2+1_$int_type - endif - enddo - i1=i1-1_$int_type - i2=i2-1_$int_type - - do i=1_$int_type,i2 - iorder(i1+i) = iorder2(i) - x(i1+i) = x2(i) - enddo - deallocate(x2,iorder2,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to deallocate arrays x2, iorder2' - stop - endif - - - if (i1 > 1_$int_type) then - call $Xradix_sort$big(x1,iorder1,i1,-2) - do i=1_$int_type,i1 - x(i) = -x1(1_$int_type+i1-i) - iorder(i) = iorder1(1_$int_type+i1-i) - enddo - endif - - if (i2>1_$int_type) then - call $Xradix_sort$big(x(i1+1_$int_type),iorder(i1+1_$int_type),i2,-2) - endif - - deallocate(x1,iorder1,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to deallocate arrays x1, iorder1' - stop - endif - return - - else if (iradix == -2) then ! Positive - - ! Find most significant bit - - i0 = 0_$int_type - i4 = maxval(x) - - iradix_new = max($integer_size-1-leadz(i4),1) - mask = ibset(0_$type,iradix_new) - - allocate(x1(isize),iorder1(isize), x2(isize),iorder2(isize),stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to allocate arrays' - stop - endif - - i1=1_$int_type - i2=1_$int_type - - do i=1_$int_type,isize - if (iand(mask,x(i)) == 0_$type) then - iorder1(i1) = iorder(i) - x1(i1) = x(i) - i1 = i1+1_$int_type - else - iorder2(i2) = iorder(i) - x2(i2) = x(i) - i2 = i2+1_$int_type - endif - enddo - i1=i1-1_$int_type - i2=i2-1_$int_type - - do i=1_$int_type,i1 - iorder(i0+i) = iorder1(i) - x(i0+i) = x1(i) - enddo - i0 = i0+i1 - i3 = i0 - deallocate(x1,iorder1,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to deallocate arrays x1, iorder1' - stop - endif - - - do i=1_$int_type,i2 - iorder(i0+i) = iorder2(i) - x(i0+i) = x2(i) - enddo - i0 = i0+i2 - deallocate(x2,iorder2,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to deallocate arrays x2, iorder2' - stop - endif - - - if (i3>1_$int_type) then - call $Xradix_sort$big(x,iorder,i3,iradix_new-1) - endif - - if (isize-i3>1_$int_type) then - call $Xradix_sort$big(x(i3+1_$int_type),iorder(i3+1_$int_type),isize-i3,iradix_new-1) - endif - - return - endif - - ASSERT (iradix >= 0) - - if (isize < 48) then - call insertion_$Xsort$big(x,iorder,isize) - return - endif - - - allocate(x2(isize),iorder2(isize),stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to allocate arrays x1, iorder1' - stop - endif - - - mask = ibset(0_$type,iradix) - i0=1_$int_type - i1=1_$int_type - - do i=1_$int_type,isize - if (iand(mask,x(i)) == 0_$type) then - iorder(i0) = iorder(i) - x(i0) = x(i) - i0 = i0+1_$int_type - else - iorder2(i1) = iorder(i) - x2(i1) = x(i) - i1 = i1+1_$int_type - endif - enddo - i0=i0-1_$int_type - i1=i1-1_$int_type - - do i=1_$int_type,i1 - iorder(i0+i) = iorder2(i) - x(i0+i) = x2(i) - enddo - - deallocate(x2,iorder2,stat=err) - if (err /= 0) then - print *, irp_here, ': Unable to allocate arrays x2, iorder2' - stop - endif - - - if (iradix == 0) then - return - endif - - - if (i1>1_$int_type) then - call $Xradix_sort$big(x(i0+1_$int_type),iorder(i0+1_$int_type),i1,iradix-1) - endif - if (i0>1) then - call $Xradix_sort$big(x,iorder,i0,iradix-1) - endif - - end - -SUBST [ X, type, integer_size, is_big, big, int_type ] - i ; 4 ; 32 ; .False. ; ; 4 ;; - i8 ; 8 ; 64 ; .False. ; ; 4 ;; - i2 ; 2 ; 16 ; .False. ; ; 4 ;; - i ; 4 ; 32 ; .True. ; _big ; 8 ;; - i8 ; 8 ; 64 ; .True. ; _big ; 8 ;; -END_TEMPLATE - - - From f168b885db26c1121486c5f4d219968f4474e0c1 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 1 May 2022 14:32:30 +0200 Subject: [PATCH 50/79] Removed IPP dependency with intel using C quicksort --- config/ifort_2019_avx.cfg | 2 +- config/ifort_2019_avx_mpi.cfg | 2 +- config/ifort_2019_mpi_rome.cfg | 2 +- config/ifort_2019_rome.cfg | 2 +- config/ifort_2019_sse4.cfg | 2 +- config/ifort_2019_sse4_mpi.cfg | 2 +- config/ifort_2019_xHost.cfg | 2 +- config/ifort_2021_avx.cfg | 2 +- config/ifort_2021_avx_mpi.cfg | 2 +- config/ifort_2021_mpi_rome.cfg | 2 +- config/ifort_2021_rome.cfg | 2 +- config/ifort_2021_sse4.cfg | 2 +- config/ifort_2021_sse4_mpi.cfg | 2 +- config/ifort_2021_xHost.cfg | 2 +- src/fci/40.fci.bats | 2 +- src/utils/qsort.c | 100 ++++++++++++++++----------------- src/utils/qsort.org | 10 ++-- 17 files changed, 70 insertions(+), 70 deletions(-) diff --git a/config/ifort_2019_avx.cfg b/config/ifort_2019_avx.cfg index 661a0e8f..c5bed0d8 100644 --- a/config/ifort_2019_avx.cfg +++ b/config/ifort_2019_avx.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_avx_mpi.cfg b/config/ifort_2019_avx_mpi.cfg index 2d212db5..5b4d2922 100644 --- a/config/ifort_2019_avx_mpi.cfg +++ b/config/ifort_2019_avx_mpi.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DMPI -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_mpi_rome.cfg b/config/ifort_2019_mpi_rome.cfg index 171219e6..054d4d7d 100644 --- a/config/ifort_2019_mpi_rome.cfg +++ b/config/ifort_2019_mpi_rome.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_rome.cfg b/config/ifort_2019_rome.cfg index e923a1dd..a18a0acb 100644 --- a/config/ifort_2019_rome.cfg +++ b/config/ifort_2019_rome.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_sse4.cfg b/config/ifort_2019_sse4.cfg index a3aa7cbd..2cdbc2c5 100644 --- a/config/ifort_2019_sse4.cfg +++ b/config/ifort_2019_sse4.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_sse4_mpi.cfg b/config/ifort_2019_sse4_mpi.cfg index 6959d176..d20cd2a2 100644 --- a/config/ifort_2019_sse4_mpi.cfg +++ b/config/ifort_2019_sse4_mpi.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DMPI -DINTEL -DSET_NESTED diff --git a/config/ifort_2019_xHost.cfg b/config/ifort_2019_xHost.cfg index 22d28803..59c6146b 100644 --- a/config/ifort_2019_xHost.cfg +++ b/config/ifort_2019_xHost.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=64 -DINTEL -DSET_NESTED diff --git a/config/ifort_2021_avx.cfg b/config/ifort_2021_avx.cfg index 6f657052..6c34cf47 100644 --- a/config/ifort_2021_avx.cfg +++ b/config/ifort_2021_avx.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL diff --git a/config/ifort_2021_avx_mpi.cfg b/config/ifort_2021_avx_mpi.cfg index c991a4a9..4c893c73 100644 --- a/config/ifort_2021_avx_mpi.cfg +++ b/config/ifort_2021_avx_mpi.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DMPI -DINTEL diff --git a/config/ifort_2021_mpi_rome.cfg b/config/ifort_2021_mpi_rome.cfg index 8413d23d..e47a466e 100644 --- a/config/ifort_2021_mpi_rome.cfg +++ b/config/ifort_2021_mpi_rome.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL diff --git a/config/ifort_2021_rome.cfg b/config/ifort_2021_rome.cfg index b3023186..504438c9 100644 --- a/config/ifort_2021_rome.cfg +++ b/config/ifort_2021_rome.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL diff --git a/config/ifort_2021_sse4.cfg b/config/ifort_2021_sse4.cfg index a6299665..07c3ebb8 100644 --- a/config/ifort_2021_sse4.cfg +++ b/config/ifort_2021_sse4.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DINTEL diff --git a/config/ifort_2021_sse4_mpi.cfg b/config/ifort_2021_sse4_mpi.cfg index 6ae56d2a..f3fa0eaa 100644 --- a/config/ifort_2021_sse4_mpi.cfg +++ b/config/ifort_2021_sse4_mpi.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : mpiifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=32 -DMPI -DINTEL diff --git a/config/ifort_2021_xHost.cfg b/config/ifort_2021_xHost.cfg index 1e76a69d..1161833b 100644 --- a/config/ifort_2021_xHost.cfg +++ b/config/ifort_2021_xHost.cfg @@ -7,7 +7,7 @@ # [COMMON] FC : ifort -fpic -LAPACK_LIB : -mkl=parallel -lirc -lsvml -limf -lipps +LAPACK_LIB : -mkl=parallel IRPF90 : irpf90 IRPF90_FLAGS : --ninja --align=64 -DINTEL diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 1a0c5507..23818f44 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -65,7 +65,7 @@ function run_stoch() { @test "H2O2" { # 12.9214s qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run -151.005848404095 1.e-3 100000 + run -151.005848404095 2.e-3 100000 } @test "HBO" { # 13.3144s diff --git a/src/utils/qsort.c b/src/utils/qsort.c index 5d685741..c011b35a 100644 --- a/src/utils/qsort.c +++ b/src/utils/qsort.c @@ -9,14 +9,14 @@ struct int16_t_comp { int compare_int16_t( const void * l, const void * r ) { - const struct int16_t_comp * restrict _l= l; - const struct int16_t_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int16_t * restrict _l= l; + const int16_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int16_t(int16_t* A_in, int32_t* iorder, int32_t isize) { +void qsort_int16_t(int16_t* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct int16_t_comp* A = malloc(isize * sizeof(struct int16_t_comp)); if (A == NULL) return; @@ -46,14 +46,14 @@ struct int16_t_comp_big { int compare_int16_t_big( const void * l, const void * r ) { - const struct int16_t_comp_big * restrict _l= l; - const struct int16_t_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int16_t * restrict _l= l; + const int16_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int16_t_big(int16_t* A_in, int64_t* iorder, int64_t isize) { +void qsort_int16_t_big(int16_t* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct int16_t_comp_big* A = malloc(isize * sizeof(struct int16_t_comp_big)); if (A == NULL) return; @@ -83,14 +83,14 @@ struct int32_t_comp { int compare_int32_t( const void * l, const void * r ) { - const struct int32_t_comp * restrict _l= l; - const struct int32_t_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int32_t * restrict _l= l; + const int32_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int32_t(int32_t* A_in, int32_t* iorder, int32_t isize) { +void qsort_int32_t(int32_t* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct int32_t_comp* A = malloc(isize * sizeof(struct int32_t_comp)); if (A == NULL) return; @@ -120,14 +120,14 @@ struct int32_t_comp_big { int compare_int32_t_big( const void * l, const void * r ) { - const struct int32_t_comp_big * restrict _l= l; - const struct int32_t_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int32_t * restrict _l= l; + const int32_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int32_t_big(int32_t* A_in, int64_t* iorder, int64_t isize) { +void qsort_int32_t_big(int32_t* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct int32_t_comp_big* A = malloc(isize * sizeof(struct int32_t_comp_big)); if (A == NULL) return; @@ -157,14 +157,14 @@ struct int64_t_comp { int compare_int64_t( const void * l, const void * r ) { - const struct int64_t_comp * restrict _l= l; - const struct int64_t_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int64_t * restrict _l= l; + const int64_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int64_t(int64_t* A_in, int32_t* iorder, int32_t isize) { +void qsort_int64_t(int64_t* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct int64_t_comp* A = malloc(isize * sizeof(struct int64_t_comp)); if (A == NULL) return; @@ -194,14 +194,14 @@ struct int64_t_comp_big { int compare_int64_t_big( const void * l, const void * r ) { - const struct int64_t_comp_big * restrict _l= l; - const struct int64_t_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const int64_t * restrict _l= l; + const int64_t * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_int64_t_big(int64_t* A_in, int64_t* iorder, int64_t isize) { +void qsort_int64_t_big(int64_t* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct int64_t_comp_big* A = malloc(isize * sizeof(struct int64_t_comp_big)); if (A == NULL) return; @@ -231,14 +231,14 @@ struct double_comp { int compare_double( const void * l, const void * r ) { - const struct double_comp * restrict _l= l; - const struct double_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const double * restrict _l= l; + const double * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_double(double* A_in, int32_t* iorder, int32_t isize) { +void qsort_double(double* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct double_comp* A = malloc(isize * sizeof(struct double_comp)); if (A == NULL) return; @@ -268,14 +268,14 @@ struct double_comp_big { int compare_double_big( const void * l, const void * r ) { - const struct double_comp_big * restrict _l= l; - const struct double_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const double * restrict _l= l; + const double * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_double_big(double* A_in, int64_t* iorder, int64_t isize) { +void qsort_double_big(double* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct double_comp_big* A = malloc(isize * sizeof(struct double_comp_big)); if (A == NULL) return; @@ -305,14 +305,14 @@ struct float_comp { int compare_float( const void * l, const void * r ) { - const struct float_comp * restrict _l= l; - const struct float_comp * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const float * restrict _l= l; + const float * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_float(float* A_in, int32_t* iorder, int32_t isize) { +void qsort_float(float* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct float_comp* A = malloc(isize * sizeof(struct float_comp)); if (A == NULL) return; @@ -342,14 +342,14 @@ struct float_comp_big { int compare_float_big( const void * l, const void * r ) { - const struct float_comp_big * restrict _l= l; - const struct float_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const float * restrict _l= l; + const float * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_float_big(float* A_in, int64_t* iorder, int64_t isize) { +void qsort_float_big(float* restrict A_in, int64_t* restrict iorder, int64_t isize) { struct float_comp_big* A = malloc(isize * sizeof(struct float_comp_big)); if (A == NULL) return; diff --git a/src/utils/qsort.org b/src/utils/qsort.org index 0c344207..abf0d54a 100644 --- a/src/utils/qsort.org +++ b/src/utils/qsort.org @@ -11,14 +11,14 @@ struct TYPE_comp_big { int compare_TYPE_big( const void * l, const void * r ) { - const struct TYPE_comp_big * restrict _l= l; - const struct TYPE_comp_big * restrict _r= r; - if( _l->x > _r->x ) return 1; - if( _l->x < _r->x ) return -1; + const TYPE * restrict _l= l; + const TYPE * restrict _r= r; + if( *_l > *_r ) return 1; + if( *_l < *_r ) return -1; return 0; } -void qsort_TYPE_big(TYPE* A_in, int32_t* iorder, int32_t isize) { +void qsort_TYPE_big(TYPE* restrict A_in, int32_t* restrict iorder, int32_t isize) { struct TYPE_comp_big* A = malloc(isize * sizeof(struct TYPE_comp_big)); if (A == NULL) return; From be6c230f52641631f26ad15f6793efb8feaaab89 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 1 May 2022 15:01:37 +0200 Subject: [PATCH 51/79] Accelerated PT2 by removing sort --- src/cipsi/selection.irp.f | 2 -- src/fci/40.fci.bats | 2 +- src/mo_two_e_erf_ints/map_integrals_erf.irp.f | 12 ++++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index 7417dd05..ec60c606 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -258,8 +258,6 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d deallocate(exc_degree) nmax=k-1 - call isort_noidx(indices,nmax) - ! Start with 32 elements. Size will double along with the filtering. allocate(preinteresting(0:32), prefullinteresting(0:32), & interesting(0:32), fullinteresting(0:32)) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 23818f44..89c65c94 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -77,7 +77,7 @@ function run_stoch() { @test "H2O" { # 11.3727s [[ -n $TRAVIS ]] && skip qp set_file h2o.ezfio - run -76.2361605151999 5.e-4 100000 + run -76.2361605151999 2.e-3 100000 } @test "ClO" { # 13.3755s diff --git a/src/mo_two_e_erf_ints/map_integrals_erf.irp.f b/src/mo_two_e_erf_ints/map_integrals_erf.irp.f index 73050ec5..3405ec2b 100644 --- a/src/mo_two_e_erf_ints/map_integrals_erf.irp.f +++ b/src/mo_two_e_erf_ints/map_integrals_erf.irp.f @@ -235,11 +235,11 @@ subroutine get_mo_two_e_integrals_erf_ij(k,l,sze,out_array,map) logical :: integral_is_in_map if (key_kind == 8) then - call i8radix_sort(hash,iorder,kk,-1) + call i8sort(hash,iorder,kk) else if (key_kind == 4) then - call iradix_sort(hash,iorder,kk,-1) + call isort(hash,iorder,kk) else if (key_kind == 2) then - call i2radix_sort(hash,iorder,kk,-1) + call i2sort(hash,iorder,kk) endif call map_get_many(mo_integrals_erf_map, hash, tmp_val, kk) @@ -290,11 +290,11 @@ subroutine get_mo_two_e_integrals_erf_i1j1(k,l,sze,out_array,map) logical :: integral_is_in_map if (key_kind == 8) then - call i8radix_sort(hash,iorder,kk,-1) + call i8sort(hash,iorder,kk) else if (key_kind == 4) then - call iradix_sort(hash,iorder,kk,-1) + call isort(hash,iorder,kk) else if (key_kind == 2) then - call i2radix_sort(hash,iorder,kk,-1) + call i2sort(hash,iorder,kk) endif call map_get_many(mo_integrals_erf_map, hash, tmp_val, kk) From abac06299cd965d304b1aad4b4fc4b8de4f7d136 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 5 May 2022 16:22:44 +0200 Subject: [PATCH 52/79] update i_H_j --- src/determinants/slater_rules.irp.f | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/determinants/slater_rules.irp.f b/src/determinants/slater_rules.irp.f index 3a33a37d..897607a9 100644 --- a/src/determinants/slater_rules.irp.f +++ b/src/determinants/slater_rules.irp.f @@ -623,7 +623,8 @@ subroutine i_H_j(key_i,key_j,Nint,hij) integer :: occ(Nint*bit_kind_size,2) double precision :: diag_H_mat_elem, phase integer :: n_occ_ab(2) - PROVIDE mo_two_e_integrals_in_map mo_integrals_map big_array_exchange_integrals + PROVIDE mo_two_e_integrals_in_map mo_integrals_map big_array_exchange_integrals + PROVIDE ao_one_e_integrals mo_one_e_integrals ASSERT (Nint > 0) ASSERT (Nint == N_int) @@ -681,7 +682,6 @@ subroutine i_H_j(key_i,key_j,Nint,hij) case (1) call get_single_excitation(key_i,key_j,exc,phase,Nint) !DIR$ FORCEINLINE - call bitstring_to_list_ab(key_i, occ, n_occ_ab, Nint) if (exc(0,1,1) == 1) then ! Single alpha m = exc(1,1,1) @@ -700,10 +700,6 @@ subroutine i_H_j(key_i,key_j,Nint,hij) end select end - - - - subroutine i_H_j_verbose(key_i,key_j,Nint,hij,hmono,hdouble,phase) use bitmasks implicit none @@ -1038,7 +1034,6 @@ subroutine i_H_psi(key,keys,coef,Nint,Ndet,Ndet_max,Nstate,i_H_psi_array) end - subroutine i_H_psi_minilist(key,keys,idx_key,N_minilist,coef,Nint,Ndet,Ndet_max,Nstate,i_H_psi_array) use bitmasks implicit none From 57527c94a27491107e49d9623c0124c516976d34 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 5 May 2022 17:26:41 +0200 Subject: [PATCH 53/79] update binom_func to avoid .999... --- src/utils/util.irp.f | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/util.irp.f b/src/utils/util.irp.f index ef846bdb..127d5433 100644 --- a/src/utils/util.irp.f +++ b/src/utils/util.irp.f @@ -37,6 +37,10 @@ double precision function binom_func(i,j) else binom_func = dexp( logfact(i)-logfact(j)-logfact(i-j) ) endif + + ! To avoid .999999 numbers + binom_func = binom_func + 0.5d0 + end From e15dceaa10c0abbfdda434b89429c6be87214815 Mon Sep 17 00:00:00 2001 From: ydamour Date: Wed, 11 May 2022 12:59:58 +0200 Subject: [PATCH 54/79] new format for pt2 --- src/cipsi/pt2_stoch_routines.irp.f | 88 ++++++++++++++++++++++++++---- src/utils/format_w_error.irp.f | 71 ++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 12 deletions(-) create mode 100644 src/utils/format_w_error.irp.f diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index c7cee1ac..1328e7a0 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -290,9 +290,13 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) call set_multiple_levels_omp(.False.) - print '(A)', '========== ======================= ===================== ===================== ===========' - print '(A)', ' Samples Energy Variance Norm^2 Seconds' - print '(A)', '========== ======================= ===================== ===================== ===========' + ! old + !print '(A)', '========== ======================= ===================== ===================== ===========' + !print '(A)', ' Samples Energy Variance Norm^2 Seconds' + !print '(A)', '========== ======================= ===================== ===================== ===========' + print '(A)', '========== ==================== ================ ================ ================ ============= ===========' + print '(A)', ' Samples Energy PT2 Variance Norm^2 Convergence Seconds' + print '(A)', '========== ==================== ================ ================ ================ ============= ===========' PROVIDE global_selection_buffer @@ -316,7 +320,10 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in) call end_parallel_job(zmq_to_qp_run_socket, zmq_socket_pull, 'pt2') call set_multiple_levels_omp(.True.) - print '(A)', '========== ======================= ===================== ===================== ===========' + ! old + !print '(A)', '========== ======================= ===================== ===================== ===========' + print '(A)', '========== ==================== ================ ================ ================ ============= ===========' + do k=1,N_states pt2_overlap(pt2_stoch_istate,k) = pt2_data % overlap(k,pt2_stoch_istate) @@ -414,6 +421,17 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2_data, pt2_data_ double precision :: rss double precision, external :: memory_of_double, memory_of_int + character(len=20) :: format_str1, str_error1, format_str2, str_error2 + character(len=20) :: format_str3, str_error3, format_str4, str_error4 + character(len=20) :: format_value1, format_value2, format_value3, format_value4 + character(len=20) :: str_value1, str_value2, str_value3, str_value4 + character(len=20) :: str_conv + double precision :: value1, value2, value3, value4 + double precision :: error1, error2, error3, error4 + integer :: size1,size2,size3,size4 + + double precision :: conv_crit + sending =.False. rss = memory_of_int(pt2_n_tasks_max*2+N_det_generators*2) @@ -537,14 +555,60 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2_data, pt2_data_ if ((time - time1 > 1.d0) .or. (n==N_det_generators)) then time1 = time - print '(I10, X, F12.6, X, G10.3, X, F10.6, X, G10.3, X, F10.6, X, G10.3, X, F10.1)', c, & - pt2_data % pt2(pt2_stoch_istate) +E, & - pt2_data_err % pt2(pt2_stoch_istate), & - pt2_data % variance(pt2_stoch_istate), & - pt2_data_err % variance(pt2_stoch_istate), & - pt2_data % overlap(pt2_stoch_istate,pt2_stoch_istate), & - pt2_data_err % overlap(pt2_stoch_istate,pt2_stoch_istate), & - time-time0 + + value1 = pt2_data % pt2(pt2_stoch_istate) + E + error1 = pt2_data_err % pt2(pt2_stoch_istate) + value2 = pt2_data % pt2(pt2_stoch_istate) + error2 = pt2_data_err % pt2(pt2_stoch_istate) + value3 = pt2_data % variance(pt2_stoch_istate) + error3 = pt2_data_err % variance(pt2_stoch_istate) + value4 = pt2_data % overlap(pt2_stoch_istate,pt2_stoch_istate) + error4 = pt2_data_err % overlap(pt2_stoch_istate,pt2_stoch_istate) + + ! Max size of the values (FX.Y) with X=size + size1 = 15 + size2 = 12 + size3 = 12 + size4 = 12 + + ! To generate the format: number(error) + call format_w_error(value1,error1,size1,8,format_value1,str_error1) + call format_w_error(value2,error2,size2,8,format_value2,str_error2) + call format_w_error(value3,error3,size3,8,format_value3,str_error3) + call format_w_error(value4,error4,size4,8,format_value4,str_error4) + + ! value > string with the right format + write(str_value1,'('//format_value1//')') value1 + write(str_value2,'('//format_value2//')') value2 + write(str_value3,'('//format_value3//')') value3 + write(str_value4,'('//format_value4//')') value4 + + ! Convergence criterion + conv_crit = dabs(pt2_data_err % pt2(pt2_stoch_istate)) / & + (1.d-20 + dabs(pt2_data % pt2(pt2_stoch_istate)) ) + write(str_conv,'(G10.3)') conv_crit + + write(*,'(I10,X,X,A20,X,A16,X,A16,X,A16,X,A12,X,F10.1)') c,& + adjustl(adjustr(str_value1)//'('//str_error1(1:1)//')'),& + adjustl(adjustr(str_value2)//'('//str_error2(1:1)//')'),& + adjustl(adjustr(str_value3)//'('//str_error3(1:1)//')'),& + adjustl(adjustr(str_value4)//'('//str_error4(1:1)//')'),& + adjustl(str_conv),& + time-time0 + + ! Old print + !print '(I10, X, F12.6, X, G10.3, X, F10.6, X, G10.3, X, F10.6, X, G10.3, X, F10.1,1pE16.6,1pE16.6)', c, & + ! pt2_data % pt2(pt2_stoch_istate) +E, & + ! pt2_data_err % pt2(pt2_stoch_istate), & + ! pt2_data % variance(pt2_stoch_istate), & + ! pt2_data_err % variance(pt2_stoch_istate), & + ! pt2_data % overlap(pt2_stoch_istate,pt2_stoch_istate), & + ! pt2_data_err % overlap(pt2_stoch_istate,pt2_stoch_istate), & + ! time-time0, & + ! pt2_data % pt2(pt2_stoch_istate), & + ! dabs(pt2_data_err % pt2(pt2_stoch_istate)) / & + ! (1.d-20 + dabs(pt2_data % pt2(pt2_stoch_istate)) ) + if (stop_now .or. ( & (do_exit .and. (dabs(pt2_data_err % pt2(pt2_stoch_istate)) / & (1.d-20 + dabs(pt2_data % pt2(pt2_stoch_istate)) ) <= relative_error))) ) then diff --git a/src/utils/format_w_error.irp.f b/src/utils/format_w_error.irp.f new file mode 100644 index 00000000..1378d367 --- /dev/null +++ b/src/utils/format_w_error.irp.f @@ -0,0 +1,71 @@ +subroutine format_w_error(value,error,size_nb,max_nb_digits,format_value,str_error) + + implicit none + + BEGIN_DOC + ! Format for double precision, value(error) + END_DOC + + ! in + ! | value | double precision | value... | + ! | error | double precision | error... | + ! | size_nb | integer | X in FX.Y | + ! | max_nb_digits | integer | Max Y in FX.Y | + + ! out + ! | format_value | character | string FX.Y for the format | + ! | str_error | character | string of the error | + + ! internal + ! | str_size | character | size in string format | + ! | nb_digits | integer | number of digits Y in FX.Y depending of the error | + ! | str_nb_digits | character | nb_digits in string format | + ! | str_exp | character | string of the value in exponential format | + + ! in + double precision, intent(in) :: error, value + integer, intent(in) :: size_nb, max_nb_digits + + ! out + character(len=20), intent(out) :: str_error, format_value + + ! internal + character(len=20) :: str_size, str_nb_digits, str_exp + integer :: nb_digits + + ! max_nb_digit: Y max + ! size_nb = Size of the double: X (FX.Y) + write(str_size,'(I3)') size_nb + + ! Error + write(str_exp,'(1pE20.0)') error + str_error = trim(adjustl(str_exp)) + + ! Number of digit: Y (FX.Y) from the exponent + str_nb_digits = str_exp(19:20) + read(str_nb_digits,*) nb_digits + + ! If the error is 0d0 + if (error <= 1d-16) then + write(str_nb_digits,*) max_nb_digits + endif + + ! If the error is too small + if (nb_digits > max_nb_digits) then + write(str_nb_digits,*) max_nb_digits + str_error(1:1) = '0' + endif + + ! If the error is too big (>= 0.5) + if (error >= 0.5d0) then + str_nb_digits = '1' + str_error(1:1) = '*' + endif + + ! FX.Y,A1,A1,A1 for value(str_error) + !string = 'F'//trim(adjustl(str_size))//'.'//trim(adjustl(str_nb_digits))//',A1,A1,A1' + + ! FX.Y just for the value + format_value = 'F'//trim(adjustl(str_size))//'.'//trim(adjustl(str_nb_digits)) + +end From 7df328724152480842fde2a183b08cb0a81c116b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 10:12:36 +0200 Subject: [PATCH 55/79] Fix bug introduced by 57527c94a27491107e --- src/utils/util.irp.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/util.irp.f b/src/utils/util.irp.f index 127d5433..84593031 100644 --- a/src/utils/util.irp.f +++ b/src/utils/util.irp.f @@ -39,7 +39,7 @@ double precision function binom_func(i,j) endif ! To avoid .999999 numbers - binom_func = binom_func + 0.5d0 + binom_func = floor(binom_func + 0.5d0) end From 185f3a500ca8d3bdb49d59902266caa2910190af Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 11:48:40 +0200 Subject: [PATCH 56/79] Fixed tests for Drone CI --- src/fci/40.fci.bats | 105 ++++++++++++----------- src/fci/EZFIO.cfg | 6 ++ src/iterations/print_extrapolation.irp.f | 1 + 3 files changed, 60 insertions(+), 52 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 89c65c94..9b99d865 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -8,12 +8,12 @@ function run() { test_exe fci || skip qp edit --check qp set perturbation do_pt2 False - qp set determinants n_det_max 8000 + qp set determinants n_det_max $3 qp set determinants n_states 1 qp set davidson threshold_davidson 1.e-10 qp set davidson n_states_diag 8 qp run fci - energy1="$(ezfio get fci energy | tr '[]' ' ' | cut -d ',' -f 1)" + energy1="$(qp get fci energy | tr '[]' ' ' | cut -d ',' -f 1)" eq $energy1 $1 $thresh } @@ -22,166 +22,167 @@ function run_stoch() { thresh=$2 test_exe fci || skip qp set perturbation do_pt2 True + qp set perturbation pt2_relative_error 0.005 qp set determinants n_det_max $3 qp set determinants n_states 1 qp set davidson threshold_davidson 1.e-10 qp set davidson n_states_diag 1 qp run fci - energy1="$(ezfio get fci energy_pt2 | tr '[]' ' ' | cut -d ',' -f 1)" + energy1="$(qp get fci energy_extrapolated | tr '[]' ' ' | cut -d ',' -f 1)" eq $energy1 $1 $thresh } -@test "B-B" { + +@test "B-B" { # 0:00:10 qp set_file b2_stretched.ezfio qp set determinants n_det_max 10000 qp set_frozen_core - run_stoch -49.14103054419 3.e-4 10000 + run_stoch -49.14104086 0.0001 10000 } -@test "F2" { # 4.07m +@test "F2" { # 0:03:34 [[ -n $TRAVIS ]] && skip qp set_file f2.ezfio qp set_frozen_core - run_stoch -199.304922384814 3.e-4 100000 + run_stoch -199.30821487 0.002 100000 } -@test "NH3" { # 10.6657s +@test "NH3" { # 0:00:11 qp set_file nh3.ezfio qp set_mo_class --core="[1-4]" --act="[5-72]" - run -56.244753429144986 3.e-4 100000 + run -56.24474790 1.e-5 10000 } -@test "DHNO" { # 11.4721s +@test "DHNO" { # 0:00:10 qp set_file dhno.ezfio qp set_mo_class --core="[1-7]" --act="[8-64]" - run -130.459020029816 3.e-4 100000 + run -130.45901042 1.e-4 10000 } -@test "HCO" { # 12.2868s +@test "HCO" { # 0:01:16 qp set_file hco.ezfio - run -113.393356604085 1.e-3 100000 + run_stoch -113.41658256 1.e-3 50000 } -@test "H2O2" { # 12.9214s +@test "H2O2" { # 0:01:48 qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run -151.005848404095 2.e-3 100000 + run_stoch -151.02317880 2.e-3 100000 } -@test "HBO" { # 13.3144s +@test "HBO" { # 0:00:46 [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run -100.214099486337 1.e-3 100000 + run_stoch -100.22361288 1.e-4 50000 } -@test "H2O" { # 11.3727s +@test "H2O" { # 0:01:05 [[ -n $TRAVIS ]] && skip qp set_file h2o.ezfio - run -76.2361605151999 2.e-3 100000 + run_stoch -76.24347962 1.e-4 100000 } -@test "ClO" { # 13.3755s +@test "ClO" { # 0:03:07 [[ -n $TRAVIS ]] && skip qp set_file clo.ezfio - run -534.546453546852 1.e-3 100000 + run_stoch -534.58202840 1.e-3 100000 } -@test "SO" { # 13.4952s +@test "SO" { # 0:01:49 [[ -n $TRAVIS ]] && skip qp set_file so.ezfio - run -26.0176563764039 1.e-3 100000 + run_stoch -26.04335528 5.e-3 100000 } -@test "H2S" { # 13.6745s +@test "H2S" { # 0:01:12 [[ -n $TRAVIS ]] && skip qp set_file h2s.ezfio - run -398.859577605891 5.e-4 100000 + run_stoch -398.87187312 1.e-3 50000 } -@test "OH" { # 13.865s +@test "OH" { # 0:00:41 [[ -n $TRAVIS ]] && skip qp set_file oh.ezfio - run -75.6121856748294 3.e-4 100000 + run_stoch -75.62393829 1.e-3 50000 } -@test "SiH2_3B1" { # 13.938ss +@test "SiH2_3B1" { # 0:00:50 [[ -n $TRAVIS ]] && skip qp set_file sih2_3b1.ezfio - run -290.0175411299477 3.e-4 100000 + run_stoch -290.02083172 3.e-5 50000 } -@test "H3COH" { # 14.7299s +@test "H3COH" { # 0:01:05 [[ -n $TRAVIS ]] && skip qp set_file h3coh.ezfio - run -115.205632960026 1.e-3 100000 + run_stoch -115.22625460 2.e-3 50000 } -@test "SiH3" { # 15.99s +@test "SiH3" { # 0:01:09 [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run -5.57241217753818 5.e-4 100000 + run_stoch -5.57818759 1.e-3 50000 } -@test "CH4" { # 16.1612s +@test "CH4" { # 0:02:06 [[ -n $TRAVIS ]] && skip qp set_file ch4.ezfio qp set_mo_class --core="[1]" --act="[2-30]" --del="[31-59]" - run -40.2409678239136 3.e-4 100000 + run_stoch -40.24195947 1.e-4 100000 } -@test "ClF" { # 16.8864s +@test "ClF" { # 0:01:55 [[ -n $TRAVIS ]] && skip qp set_file clf.ezfio - run -559.169748890031 1.5e-3 100000 + run_stoch -559.20157348 1.e-3 50000 } -@test "SO2" { # 17.5645s +@test "SO2" { # 0:00:24 [[ -n $TRAVIS ]] && skip qp set_file so2.ezfio qp set_mo_class --core="[1-8]" --act="[9-87]" - run -41.5746738713298 1.5e-3 100000 + run_stoch -41.57468087 1.e-4 50000 } -@test "C2H2" { # 17.6827s +@test "C2H2" { # 0:00:57 [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run -12.3685464085969 2.e-3 100000 + run_stoch -12.38655876 1.e-3 50000 } -@test "N2" { # 18.0198s +@test "N2" { # 0:01:15 [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run -109.287917088107 1.5e-3 100000 + run_stoch -109.31133266 2.e-3 50000 } -@test "N2H4" { # 18.5006s +@test "N2H4" { # 0:00:51 [[ -n $TRAVIS ]] && skip qp set_file n2h4.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-48]" - run -111.367332681559 3.e-4 100000 + run_stoch -111.38161063 1.e-3 50000 } -@test "CO2" { # 21.1748s +@test "CO2" { # 0:01:00 [[ -n $TRAVIS ]] && skip qp set_file co2.ezfio qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" - run -187.970184372047 1.5e-3 100000 + run_stoch -188.00154729 2.e-3 50000 } - -@test "[Cu(NH3)4]2+" { # 25.0417s +@test "[Cu(NH3)4]2+" { # 0:01:53 [[ -n $TRAVIS ]] && skip qp set_file cu_nh3_4_2plus.ezfio qp set_mo_class --core="[1-24]" --act="[25-45]" --del="[46-87]" - run -1862.9869374387192 3.e-04 100000 + run_stoch -1862.98705091 1.e-05 50000 } -@test "HCN" { # 20.3273s +@test "HCN" { # 0:01:26 [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run -93.0777619629755 1.e-3 100000 + run_stoch -93.09855896 5.e-4 50000 } diff --git a/src/fci/EZFIO.cfg b/src/fci/EZFIO.cfg index d897428a..6b46a85f 100644 --- a/src/fci/EZFIO.cfg +++ b/src/fci/EZFIO.cfg @@ -10,3 +10,9 @@ doc: Calculated |FCI| energy + |PT2| interface: ezfio size: (determinants.n_states) +[energy_extrapolated] +type: double precision +doc: Calculated |FCI| energy + |PT2| +interface: ezfio +size: (determinants.n_states) + diff --git a/src/iterations/print_extrapolation.irp.f b/src/iterations/print_extrapolation.irp.f index cb46fb67..e07cc1ed 100644 --- a/src/iterations/print_extrapolation.irp.f +++ b/src/iterations/print_extrapolation.irp.f @@ -41,6 +41,7 @@ subroutine print_extrapolated_energy enddo print *, '' + call ezfio_set_fci_energy_extrapolated(extrapolated_energy(2,1:N_states)) end subroutine From 687fa9472a707157ae4f4d58d9cc65c2ab803bba Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 12:03:22 +0200 Subject: [PATCH 57/79] Update drone config --- .drone.yml | 74 ++++++++++++++--------------- bin/qp_convert_output_to_ezfio | 2 +- src/determinants/determinants.irp.f | 3 +- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/.drone.yml b/.drone.yml index 256b8e9b..52b48829 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,46 +7,46 @@ clone: depth: 10 steps: + - name: configure debug + image: scemama666/qp2_env + commands: + - ./configure -i all -c ./config/gfortran_debug.cfg + - bash -c "source quantum_package.rc ; exec qp_plugins download https://gitlab.com/scemama/qp_plugins_scemama" + - bash -c "source quantum_package.rc ; exec qp_plugins install champ" -- name: configure - image: scemama666/qp2_env - commands: - - ./configure -i all -c ./config/gfortran_debug.cfg - - bash -c "source quantum_package.rc ; exec qp_plugins download https://gitlab.com/scemama/qp_plugins_scemama" - - bash -c "source quantum_package.rc ; exec qp_plugins install champ" + - name: compile debug + image: scemama666/qp2_env + commands: + - bash -c "source quantum_package.rc ; exec ninja" -- name: compile - image: scemama666/qp2_env - commands: - - bash -c "source quantum_package.rc ; exec ninja" + - name: testing debug + image: scemama666/qp2_env + commands: + - bash -c "source quantum_package.rc ; TRAVIS=1 exec qp_test -a" -- name: testing - image: scemama666/qp2_env - commands: - - bash -c "source quantum_package.rc ; TRAVIS=1 exec qp_test -a" + - name: configure fast + image: scemama666/qp2_env + commands: + - ./configure -i all -c ./config/gfortran_avx.cfg ---- -kind: pipeline -type: docker -name: gfortran-avx + - name: compile fast + image: scemama666/qp2_env + commands: + - bash -c "source quantum_package.rc ; exec ninja" -clone: - depth: 10 - -steps: - -- name: configure - image: scemama666/qp2_env - commands: - - ./configure -i all -c ./config/gfortran_avx.cfg - -- name: compile - image: scemama666/qp2_env - commands: - - bash -c "source quantum_package.rc ; exec ninja" - -- name: testing - image: scemama666/qp2_env - commands: - - bash -c "source quantum_package.rc ; exec qp_test -a" + - name: testing fast + image: scemama666/qp2_env + commands: + - bash -c "source quantum_package.rc ; exec qp_test -a" + - name: notify + image: drillster/drone-email + settings: + host: + from_secret: hostname # irsamc.ups-tlse.fr + from: + from_secret: from # drone@irssv7.ups-tlse.fr + recipients: + from_secret: recipients # scemama@irsamc.ups-tlse.fr + when: + status: [changed, failure] diff --git a/bin/qp_convert_output_to_ezfio b/bin/qp_convert_output_to_ezfio index 091423e4..07ad2236 100755 --- a/bin/qp_convert_output_to_ezfio +++ b/bin/qp_convert_output_to_ezfio @@ -224,7 +224,7 @@ def write_ezfio(res, filename): exponent += [p.expo for p in b.prim] ang_mom.append(str.count(s, "z")) shell_prim_num.append(len(b.prim)) - shell_index += [nshell_tot+1] * len(b.prim) + shell_index += [nshell_tot] * len(b.prim) # ~#~#~#~#~ # # W r i t e # diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index eeadf779..12ad912f 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -542,12 +542,11 @@ subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef) integer :: i,j,k, ndet_qp_edit if (mpi_master) then - ndet_qp_edit = min(ndet,N_det_qp_edit) call ezfio_set_determinants_N_int(N_int) call ezfio_set_determinants_bit_kind(bit_kind) call ezfio_set_determinants_N_det(ndet) - call ezfio_set_determinants_N_det_qp_edit(ndet_qp_edit) + call ezfio_set_determinants_N_det_qp_edit(min(ndet,10000)) call ezfio_set_determinants_n_states(nstates) call ezfio_set_determinants_mo_label(mo_label) From 8a7854de574ebb0679f849ba14f5b3d42651b2f4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 12:08:18 +0200 Subject: [PATCH 58/79] Update drone.yml --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 52b48829..d3d3ef92 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,7 +27,7 @@ steps: - name: configure fast image: scemama666/qp2_env commands: - - ./configure -i all -c ./config/gfortran_avx.cfg + - ./configure -c ./config/gfortran_avx.cfg - name: compile fast image: scemama666/qp2_env From 6224e449ca2f1850152e2fdc46f838806e1b5907 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 14:28:25 +0200 Subject: [PATCH 59/79] Replaces psi_det_size by N_det --- src/csf/configurations.irp.f | 2 +- src/davidson/davidson_parallel.irp.f | 2 +- src/davidson/davidson_parallel_csf.irp.f | 2 +- src/davidson/davidson_parallel_nos2.irp.f | 2 +- src/davidson/u0_hs2_u0.irp.f | 2 +- src/davidson/u0_wee_u0.irp.f | 2 +- src/determinants/determinants.irp.f | 69 +++++------------------ src/determinants/h_apply.irp.f | 7 +-- src/determinants/psi_cas.irp.f | 20 +++---- src/determinants/s2.irp.f | 2 +- src/determinants/spindeterminants.irp.f | 6 +- src/determinants/zmq.irp.f | 23 ++------ src/generators_cas/generators.irp.f | 10 ++-- src/generators_full/generators.irp.f | 10 ++-- src/perturbation/selection.irp.f | 4 +- src/psiref_cas/psi_ref.irp.f | 12 ++-- src/psiref_utils/psi_ref_utils.irp.f | 26 ++++----- src/selectors_utils/selectors.irp.f | 2 +- src/single_ref_method/generators.irp.f | 4 +- 19 files changed, 77 insertions(+), 130 deletions(-) diff --git a/src/csf/configurations.irp.f b/src/csf/configurations.irp.f index ce5d48ab..3ecaa517 100644 --- a/src/csf/configurations.irp.f +++ b/src/csf/configurations.irp.f @@ -332,7 +332,7 @@ subroutine configuration_to_dets_tree_addressing(o,d,sze,n_alpha,Nint) end - BEGIN_PROVIDER [ integer(bit_kind), psi_configuration, (N_int,2,psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_configuration, (N_int,2,N_det) ] &BEGIN_PROVIDER [ integer, N_configuration ] implicit none BEGIN_DOC diff --git a/src/davidson/davidson_parallel.irp.f b/src/davidson/davidson_parallel.irp.f index e627dfc9..b642d7a4 100644 --- a/src/davidson/davidson_parallel.irp.f +++ b/src/davidson/davidson_parallel.irp.f @@ -99,7 +99,7 @@ subroutine davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read, psi_det_size_read + integer :: N_states_read, N_det_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/davidson_parallel_csf.irp.f b/src/davidson/davidson_parallel_csf.irp.f index d8e9bffa..8a8fcc4a 100644 --- a/src/davidson/davidson_parallel_csf.irp.f +++ b/src/davidson/davidson_parallel_csf.irp.f @@ -99,7 +99,7 @@ subroutine davidson_csf_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read, psi_det_size_read + integer :: N_states_read, N_det_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/davidson_parallel_nos2.irp.f b/src/davidson/davidson_parallel_nos2.irp.f index 597b001f..dcc9687d 100644 --- a/src/davidson/davidson_parallel_nos2.irp.f +++ b/src/davidson/davidson_parallel_nos2.irp.f @@ -99,7 +99,7 @@ subroutine davidson_nos2_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read, psi_det_size_read + integer :: N_states_read, N_det_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/u0_hs2_u0.irp.f b/src/davidson/u0_hs2_u0.irp.f index 38fb56bd..e67777e7 100644 --- a/src/davidson/u0_hs2_u0.irp.f +++ b/src/davidson/u0_hs2_u0.irp.f @@ -6,7 +6,7 @@ ! ! psi_s2(i) = $\langle \Psi_i | S^2 | \Psi_i \rangle$ END_DOC - call u_0_HS2_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) + call u_0_HS2_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,N_det) integer :: i do i=N_det+1,N_states psi_energy(i) = 0.d0 diff --git a/src/davidson/u0_wee_u0.irp.f b/src/davidson/u0_wee_u0.irp.f index 0c543aca..e53d76ea 100644 --- a/src/davidson/u0_wee_u0.irp.f +++ b/src/davidson/u0_wee_u0.irp.f @@ -4,7 +4,7 @@ BEGIN_PROVIDER [ double precision, psi_energy_two_e, (N_states) ] ! Energy of the current wave function END_DOC integer :: i,j - call u_0_H_u_0_two_e(psi_energy_two_e,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) + call u_0_H_u_0_two_e(psi_energy_two_e,psi_coef,N_det,psi_det,N_int,N_states,N_det) do i=N_det+1,N_states psi_energy_two_e(i) = 0.d0 enddo diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index eeadf779..16f3bedb 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -70,42 +70,7 @@ BEGIN_PROVIDER [integer, max_degree_exc] enddo END_PROVIDER -BEGIN_PROVIDER [ integer, psi_det_size ] - implicit none - BEGIN_DOC - ! Size of the psi_det and psi_coef arrays - END_DOC - PROVIDE ezfio_filename - logical :: exists - psi_det_size = 1 - PROVIDE mpi_master - if (read_wf) then - if (mpi_master) then - call ezfio_has_determinants_n_det(exists) - if (exists) then - call ezfio_get_determinants_n_det(psi_det_size) - else - psi_det_size = 1 - endif - call write_int(6,psi_det_size,'Dimension of the psi arrays') - endif - IRP_IF MPI_DEBUG - print *, irp_here, mpi_rank - call MPI_BARRIER(MPI_COMM_WORLD, ierr) - IRP_ENDIF - IRP_IF MPI - include 'mpif.h' - integer :: ierr - call MPI_BCAST( psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) - if (ierr /= MPI_SUCCESS) then - stop 'Unable to read psi_det_size with MPI' - endif - IRP_ENDIF - endif - -END_PROVIDER - -BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,psi_det_size) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,N_det) ] implicit none BEGIN_DOC ! The determinants of the wave function. Initialized with Hartree-Fock if the |EZFIO| file @@ -176,7 +141,7 @@ END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ] +BEGIN_PROVIDER [ double precision, psi_coef, (N_det,N_states) ] implicit none BEGIN_DOC ! The wave function coefficients. Initialized with Hartree-Fock if the |EZFIO| file @@ -189,7 +154,7 @@ BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ] PROVIDE read_wf N_det mo_label ezfio_filename psi_coef = 0.d0 - do i=1,min(N_states,psi_det_size) + do i=1,min(N_states,N_det) psi_coef(i,i) = 1.d0 enddo @@ -237,7 +202,7 @@ BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ] END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (psi_det_size) ] +BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (N_det) ] implicit none BEGIN_DOC ! Contribution of determinants to the state-averaged density. @@ -287,10 +252,10 @@ END_PROVIDER !==============================================================================! - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted, (psi_det_size,N_states) ] -&BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted, (psi_det_size) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_order, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted, (N_det,N_states) ] +&BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted, (N_det) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_order, (N_det) ] implicit none BEGIN_DOC ! Wave function sorted by determinants contribution to the norm (state-averaged) @@ -319,17 +284,12 @@ END_PROVIDER psi_det_sorted_order(iorder(i)) = i enddo - psi_det_sorted(:,:,N_det+1:psi_det_size) = 0_bit_kind - psi_coef_sorted(N_det+1:psi_det_size,:) = 0.d0 - psi_average_norm_contrib_sorted(N_det+1:psi_det_size) = 0.d0 - psi_det_sorted_order(N_det+1:psi_det_size) = 0 - deallocate(iorder) END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! Determinants on which we apply $\langle i|H|psi \rangle$ for perturbation. @@ -355,9 +315,6 @@ subroutine sort_dets_by_det_search_key(Ndet, det_in, coef_in, sze, det_out, coef ! Determinants are sorted according to their :c:func:`det_search_key`. ! Useful to accelerate the search of a random determinant in the wave ! function. - ! - ! /!\ The first dimension of coef_out and coef_in need to be psi_det_size - ! END_DOC integer :: i,j,k integer, allocatable :: iorder(:) @@ -491,7 +448,11 @@ subroutine save_wavefunction_truncated(thr) endif enddo if (mpi_master) then - call save_wavefunction_general(N_det_save,min(N_states,N_det_save),psi_det_sorted,size(psi_coef_sorted,1),psi_coef_sorted) + call save_wavefunction_general(N_det_save, & + min(N_states,N_det_save), & + psi_det_sorted, & + size(psi_coef_sorted,1), & + psi_coef_sorted) endif end diff --git a/src/determinants/h_apply.irp.f b/src/determinants/h_apply.irp.f index d01ad1c7..246ff209 100644 --- a/src/determinants/h_apply.irp.f +++ b/src/determinants/h_apply.irp.f @@ -159,10 +159,7 @@ subroutine copy_H_apply_buffer_to_wf enddo ! Update array sizes - if (psi_det_size < N_det) then - psi_det_size = N_det - TOUCH psi_det_size - endif + TOUCH N_det ! Restore backup in resized array do i=1,N_det_old @@ -180,7 +177,7 @@ subroutine copy_H_apply_buffer_to_wf !$OMP PARALLEL DEFAULT(SHARED) & !$OMP PRIVATE(j,k,i) FIRSTPRIVATE(N_det_old) & - !$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,psi_det_size) + !$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,N_det) j=0 !$ j=omp_get_thread_num() do k=0,j-1 diff --git a/src/determinants/psi_cas.irp.f b/src/determinants/psi_cas.irp.f index 19a1c260..125ec1e1 100644 --- a/src/determinants/psi_cas.irp.f +++ b/src/determinants/psi_cas.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_cas, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_cas_coef, (psi_det_size,n_states) ] -&BEGIN_PROVIDER [ integer, idx_cas, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_cas, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_cas_coef, (N_det,n_states) ] +&BEGIN_PROVIDER [ integer, idx_cas, (N_det) ] &BEGIN_PROVIDER [ integer, N_det_cas ] implicit none BEGIN_DOC @@ -44,8 +44,8 @@ use bitmasks END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_cas_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_cas_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_cas_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_cas_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! |CAS| determinants sorted to accelerate the search of a random determinant in the wave @@ -58,9 +58,9 @@ END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_cas_coef, (psi_det_size,n_states) ] -&BEGIN_PROVIDER [ integer, idx_non_cas, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_cas_coef, (N_det,n_states) ] +&BEGIN_PROVIDER [ integer, idx_non_cas, (N_det) ] &BEGIN_PROVIDER [ integer, N_det_non_cas ] implicit none BEGIN_DOC @@ -97,8 +97,8 @@ END_PROVIDER N_det_non_cas = i_non_cas END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_cas_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_cas_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! |CAS| determinants sorted to accelerate the search of a random determinant in the wave diff --git a/src/determinants/s2.irp.f b/src/determinants/s2.irp.f index 2c1a8757..abae212f 100644 --- a/src/determinants/s2.irp.f +++ b/src/determinants/s2.irp.f @@ -110,7 +110,7 @@ END_PROVIDER ! array of the averaged values of the S^2 operator on the various states END_DOC integer :: i - call u_0_S2_u_0(s2_values,psi_coef,n_det,psi_det,N_int,N_states,psi_det_size) + call u_0_S2_u_0(s2_values,psi_coef,n_det,psi_det,N_int,N_states,N_det) do i = 1, N_states s_values(i) = 0.5d0 *(-1.d0 + dsqrt(1.d0 + 4 * s2_values(i))) enddo diff --git a/src/determinants/spindeterminants.irp.f b/src/determinants/spindeterminants.irp.f index dd55e112..e4a857a9 100644 --- a/src/determinants/spindeterminants.irp.f +++ b/src/determinants/spindeterminants.irp.f @@ -24,7 +24,7 @@ integer*8 function spin_det_search_key(det,Nint) end -BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,psi_det_size) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,N_det) ] implicit none BEGIN_DOC ! List of $\alpha$ determinants of psi_det @@ -39,7 +39,7 @@ BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,psi_det_size) ] END_PROVIDER -BEGIN_PROVIDER [ integer(bit_kind), psi_det_beta, (N_int,psi_det_size) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det_beta, (N_int,N_det) ] implicit none BEGIN_DOC ! List of $\beta$ determinants of psi_det @@ -56,7 +56,7 @@ END_PROVIDER BEGIN_TEMPLATE - BEGIN_PROVIDER [ integer(bit_kind), psi_det_$alpha_unique, (N_int,psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_$alpha_unique, (N_int,N_det) ] &BEGIN_PROVIDER [ integer, N_det_$alpha_unique ] implicit none BEGIN_DOC diff --git a/src/determinants/zmq.irp.f b/src/determinants/zmq.irp.f index 5a114533..7288de05 100644 --- a/src/determinants/zmq.irp.f +++ b/src/determinants/zmq.irp.f @@ -10,7 +10,6 @@ integer function zmq_put_psi(zmq_to_qp_run_socket,worker_id) integer, external :: zmq_put_N_states integer, external :: zmq_put_N_det - integer, external :: zmq_put_psi_det_size integer*8, external :: zmq_put_psi_det integer*8, external :: zmq_put_psi_coef @@ -23,10 +22,6 @@ integer function zmq_put_psi(zmq_to_qp_run_socket,worker_id) zmq_put_psi = -1 return endif - if (zmq_put_psi_det_size(zmq_to_qp_run_socket, worker_id) == -1) then - zmq_put_psi = -1 - return - endif if (zmq_put_psi_det(zmq_to_qp_run_socket, worker_id) == -1) then zmq_put_psi = -1 return @@ -51,7 +46,6 @@ integer function zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) integer, external :: zmq_get_N_states integer, external :: zmq_get_N_det - integer, external :: zmq_get_psi_det_size integer*8, external :: zmq_get_psi_det integer*8, external :: zmq_get_psi_coef @@ -65,19 +59,15 @@ integer function zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) zmq_get_psi_notouch = -1 return endif - if (zmq_get_psi_det_size(zmq_to_qp_run_socket, worker_id) == -1) then - zmq_get_psi_notouch = -1 - return - endif - if (size(psi_det,kind=8) /= N_int*2_8*psi_det_size*bit_kind) then + if (size(psi_det,kind=8) /= N_int*2_8*N_det*bit_kind) then deallocate(psi_det) - allocate(psi_det(N_int,2,psi_det_size)) + allocate(psi_det(N_int,2,N_det)) endif - if (size(psi_coef,kind=8) /= psi_det_size*N_states) then + if (size(psi_coef,kind=8) /= N_det*N_states) then deallocate(psi_coef) - allocate(psi_coef(psi_det_size,N_states)) + allocate(psi_coef(N_det,N_states)) endif if (zmq_get_psi_det(zmq_to_qp_run_socket, worker_id) == -1_8) then @@ -102,7 +92,7 @@ integer function zmq_get_psi(zmq_to_qp_run_socket, worker_id) integer, intent(in) :: worker_id integer, external :: zmq_get_psi_notouch zmq_get_psi = zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) - SOFT_TOUCH psi_det psi_coef psi_det_size N_det N_states + SOFT_TOUCH psi_det psi_coef N_det N_states end @@ -266,7 +256,7 @@ integer function zmq_get_psi_bilinear(zmq_to_qp_run_socket, worker_id) return endif - SOFT_TOUCH psi_bilinear_matrix_values psi_bilinear_matrix_rows psi_bilinear_matrix_columns psi_bilinear_matrix_order psi_det psi_coef psi_det_size N_det N_states psi_det_beta_unique psi_det_alpha_unique N_det_beta_unique N_det_alpha_unique + SOFT_TOUCH psi_bilinear_matrix_values psi_bilinear_matrix_rows psi_bilinear_matrix_columns psi_bilinear_matrix_order psi_det psi_coef N_det N_states psi_det_beta_unique psi_det_alpha_unique N_det_beta_unique N_det_alpha_unique end @@ -374,7 +364,6 @@ N_states ;; N_det ;; N_det_alpha_unique ;; N_det_beta_unique ;; -psi_det_size ;; END_TEMPLATE diff --git a/src/generators_cas/generators.irp.f b/src/generators_cas/generators.irp.f index b2f58202..e499f703 100644 --- a/src/generators_cas/generators.irp.f +++ b/src/generators_cas/generators.irp.f @@ -20,11 +20,11 @@ BEGIN_PROVIDER [ integer, N_det_generators ] call write_int(6,N_det_generators,'Number of generators') END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] -&BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (psi_det_size,N_states) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] +&BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (N_det,N_states) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (N_det) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the diff --git a/src/generators_full/generators.irp.f b/src/generators_full/generators.irp.f index 7f18947f..376e5e3e 100644 --- a/src/generators_full/generators.irp.f +++ b/src/generators_full/generators.irp.f @@ -22,8 +22,8 @@ BEGIN_PROVIDER [ integer, N_det_generators ] call write_int(6,N_det_generators,'Number of generators') END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the @@ -34,9 +34,9 @@ END_PROVIDER END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (psi_det_size,N_states) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (N_det,N_states) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (N_det) ] implicit none BEGIN_DOC diff --git a/src/perturbation/selection.irp.f b/src/perturbation/selection.irp.f index f3f03673..67422226 100644 --- a/src/perturbation/selection.irp.f +++ b/src/perturbation/selection.irp.f @@ -90,12 +90,12 @@ subroutine remove_small_contributions enddo !$OMP PARALLEL DEFAULT(NONE) & !$OMP PRIVATE(i,j,i_H_psi_array) & - !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,psi_det_size,N_states, & + !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,N_det,N_states, & !$OMP selection_criterion_min,keep,N_det_generators) & !$OMP REDUCTION(+:N_removed) !$OMP DO do i=2*N_det_generators+1, N_det - call i_H_psi(psi_det_sorted(1,1,i),psi_det_sorted,psi_coef_sorted,N_int,min(N_det,2*N_det_generators),psi_det_size,N_states,i_H_psi_array) + call i_H_psi(psi_det_sorted(1,1,i),psi_det_sorted,psi_coef_sorted,N_int,min(N_det,2*N_det_generators),N_det,N_states,i_H_psi_array) keep(i) = .False. do j=1,N_states keep(i) = keep(i) .or. (-(psi_coef_sorted(i,j)*i_H_psi_array(j)) > selection_criterion_min) diff --git a/src/psiref_cas/psi_ref.irp.f b/src/psiref_cas/psi_ref.irp.f index 78dd2239..0e1df986 100644 --- a/src/psiref_cas/psi_ref.irp.f +++ b/src/psiref_cas/psi_ref.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef, (psi_det_size,n_states) ] -&BEGIN_PROVIDER [ integer, idx_ref, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef, (N_det,n_states) ] +&BEGIN_PROVIDER [ integer, idx_ref, (N_det) ] &BEGIN_PROVIDER [ integer, N_det_ref ] implicit none BEGIN_DOC @@ -26,7 +26,7 @@ use bitmasks END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (psi_det_size,n_states) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (N_det,n_states) ] implicit none BEGIN_DOC ! 1/psi_ref_coef @@ -41,8 +41,8 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (psi_det_size,n_states) ] END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_ref_restart, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef_restart, (psi_det_size,n_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref_restart, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef_restart, (N_det,n_states) ] implicit none BEGIN_DOC ! Projection of the CAS wave function on the restart wave function. diff --git a/src/psiref_utils/psi_ref_utils.irp.f b/src/psiref_utils/psi_ref_utils.irp.f index 19e42283..185d9778 100644 --- a/src/psiref_utils/psi_ref_utils.irp.f +++ b/src/psiref_utils/psi_ref_utils.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_ref_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! Reference determinants sorted to accelerate the search of a random determinant in the wave @@ -14,7 +14,7 @@ use bitmasks END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,psi_det_size) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,N_det) ] implicit none BEGIN_DOC ! Transposed psi_ref_coef @@ -27,7 +27,7 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,psi_det_size) enddo END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (psi_det_size,n_states) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (N_det,n_states) ] implicit none BEGIN_DOC ! Normalized coefficients of the reference @@ -43,7 +43,7 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (psi_det_size,n_sta END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,psi_det_size) ] +BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,N_det) ] implicit none BEGIN_DOC ! Transposed psi_non_ref_coef @@ -56,10 +56,10 @@ BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,psi_det_si enddo END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef, (psi_det_size,n_states) ] -&BEGIN_PROVIDER [ integer, idx_non_ref, (psi_det_size) ] -&BEGIN_PROVIDER [ integer, idx_non_ref_rev, (psi_det_size) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef, (N_det,n_states) ] +&BEGIN_PROVIDER [ integer, idx_non_ref, (N_det) ] +&BEGIN_PROVIDER [ integer, idx_non_ref_rev, (N_det) ] &BEGIN_PROVIDER [ integer, N_det_non_ref ] implicit none BEGIN_DOC @@ -102,8 +102,8 @@ END_PROVIDER endif END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_restart, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_restart, (psi_det_size,n_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_restart, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_restart, (N_det,n_states) ] implicit none BEGIN_DOC ! Set of determinants which are not part of the reference, defined from the application @@ -144,8 +144,8 @@ END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_sorted_bit, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_sorted_bit, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_sorted_bit, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_sorted_bit, (N_det,N_states) ] implicit none BEGIN_DOC ! Reference determinants sorted to accelerate the search of a random determinant in the wave diff --git a/src/selectors_utils/selectors.irp.f b/src/selectors_utils/selectors.irp.f index 92366d1d..765bd5e8 100644 --- a/src/selectors_utils/selectors.irp.f +++ b/src/selectors_utils/selectors.irp.f @@ -2,7 +2,7 @@ use bitmasks BEGIN_PROVIDER [ integer, psi_selectors_size ] implicit none - psi_selectors_size = psi_det_size + psi_selectors_size = N_det END_PROVIDER BEGIN_PROVIDER [ double precision, psi_selectors_coef_transp, (N_states,psi_selectors_size) ] diff --git a/src/single_ref_method/generators.irp.f b/src/single_ref_method/generators.irp.f index ce71f996..dd6985a5 100644 --- a/src/single_ref_method/generators.irp.f +++ b/src/single_ref_method/generators.irp.f @@ -9,8 +9,8 @@ BEGIN_PROVIDER [ integer, N_det_generators ] N_det_generators = 1 END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the From eaf34675c2336151b124e61bac738712f13e0048 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 12 May 2022 19:58:23 +0200 Subject: [PATCH 60/79] another useless bitstring_to_list --- src/determinants/slater_rules_wee_mono.irp.f | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/determinants/slater_rules_wee_mono.irp.f b/src/determinants/slater_rules_wee_mono.irp.f index 4c1c9330..7c2ad148 100644 --- a/src/determinants/slater_rules_wee_mono.irp.f +++ b/src/determinants/slater_rules_wee_mono.irp.f @@ -282,9 +282,7 @@ subroutine i_H_j_two_e(key_i,key_j,Nint,hij) double precision :: get_two_e_integral integer :: m,n,p,q integer :: i,j,k - integer :: occ(Nint*bit_kind_size,2) double precision :: diag_H_mat_elem, phase,phase_2 - integer :: n_occ_ab(2) PROVIDE mo_two_e_integrals_in_map mo_integrals_map big_array_exchange_integrals ref_bitmask_two_e_energy ASSERT (Nint > 0) @@ -342,7 +340,6 @@ subroutine i_H_j_two_e(key_i,key_j,Nint,hij) case (1) call get_single_excitation(key_i,key_j,exc,phase,Nint) !DIR$ FORCEINLINE - call bitstring_to_list_ab(key_i, occ, n_occ_ab, Nint) if (exc(0,1,1) == 1) then ! Mono alpha m = exc(1,1,1) From bcb334afd295aea112ab46b3e17247df7c929d2c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 12 May 2022 12:32:28 +0200 Subject: [PATCH 61/79] Changed order of tests --- src/fci/40.fci.bats | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 9b99d865..c303ea87 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -40,13 +40,6 @@ function run_stoch() { run_stoch -49.14104086 0.0001 10000 } -@test "F2" { # 0:03:34 - [[ -n $TRAVIS ]] && skip - qp set_file f2.ezfio - qp set_frozen_core - run_stoch -199.30821487 0.002 100000 -} - @test "NH3" { # 0:00:11 qp set_file nh3.ezfio qp set_mo_class --core="[1-4]" --act="[5-72]" @@ -186,3 +179,10 @@ function run_stoch() { run_stoch -93.09855896 5.e-4 50000 } +@test "F2" { # 0:03:34 + [[ -n $TRAVIS ]] && skip + qp set_file f2.ezfio + qp set_frozen_core + run_stoch -199.30821487 0.002 100000 +} + From 1f81de5bd4c2788dfdec8193feb3c9fa8631fdd5 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 13 May 2022 10:11:17 +0200 Subject: [PATCH 62/79] Additional check in run_selection_slave --- src/cipsi/run_selection_slave.irp.f | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cipsi/run_selection_slave.irp.f b/src/cipsi/run_selection_slave.irp.f index 91bd3a38..de7c209c 100644 --- a/src/cipsi/run_selection_slave.irp.f +++ b/src/cipsi/run_selection_slave.irp.f @@ -61,10 +61,14 @@ subroutine run_selection_slave(thread,iproc,energy) if (N /= buf%N) then print *, 'N=', N print *, 'buf%N=', buf%N - print *, 'bug in ', irp_here - stop '-1' + print *, 'In ', irp_here, ': N /= buf%N' + stop -1 end if end if + if (i_generator > N_det_generators) then + print *, 'In ', irp_here, ': i_generator > N_det_generators' + stop -1 + endif call select_connected(i_generator,energy,pt2_data,buf,subset,pt2_F(i_generator)) endif From 135082dd7d72d44c4724ac121f090ee3b2e7661d Mon Sep 17 00:00:00 2001 From: ydamour Date: Fri, 13 May 2022 18:07:40 +0200 Subject: [PATCH 63/79] duplication if N_det in OMP section --- src/perturbation/selection.irp.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/perturbation/selection.irp.f b/src/perturbation/selection.irp.f index 67422226..d5947d25 100644 --- a/src/perturbation/selection.irp.f +++ b/src/perturbation/selection.irp.f @@ -90,7 +90,7 @@ subroutine remove_small_contributions enddo !$OMP PARALLEL DEFAULT(NONE) & !$OMP PRIVATE(i,j,i_H_psi_array) & - !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,N_det,N_states, & + !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,N_states, & !$OMP selection_criterion_min,keep,N_det_generators) & !$OMP REDUCTION(+:N_removed) !$OMP DO From 29c0dc2e2fdcb029dd6e04f2cc3288d46db162aa Mon Sep 17 00:00:00 2001 From: ydamour Date: Fri, 13 May 2022 18:50:54 +0200 Subject: [PATCH 64/79] fix bug save_wavefunction_general --- src/determinants/determinants.irp.f | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index d9e1303e..36da8c07 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -503,11 +503,12 @@ subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef) integer :: i,j,k, ndet_qp_edit if (mpi_master) then + ndet_qp_edit = min(ndet,10000) call ezfio_set_determinants_N_int(N_int) call ezfio_set_determinants_bit_kind(bit_kind) call ezfio_set_determinants_N_det(ndet) - call ezfio_set_determinants_N_det_qp_edit(min(ndet,10000)) + call ezfio_set_determinants_N_det_qp_edit(ndet_qp_edit) call ezfio_set_determinants_n_states(nstates) call ezfio_set_determinants_mo_label(mo_label) From eda7ea74407cb600e033c289ecd285a5b60b73aa Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 16 May 2022 13:47:55 +0200 Subject: [PATCH 65/79] Removed docker files --- drone/Docker/README.md | 8 -------- drone/Docker/Ubuntu/Dockerfile | 27 --------------------------- drone/compilation.sh | 16 ---------------- drone/configuration.sh | 10 ---------- drone/drone_docker.yml | 30 ------------------------------ drone/drone_ssh.yml | 29 ----------------------------- drone/testing.sh | 16 ---------------- src/cisd/30.cisd.bats | 2 +- 8 files changed, 1 insertion(+), 137 deletions(-) delete mode 100644 drone/Docker/README.md delete mode 100644 drone/Docker/Ubuntu/Dockerfile delete mode 100755 drone/compilation.sh delete mode 100755 drone/configuration.sh delete mode 100644 drone/drone_docker.yml delete mode 100644 drone/drone_ssh.yml delete mode 100755 drone/testing.sh diff --git a/drone/Docker/README.md b/drone/Docker/README.md deleted file mode 100644 index eb569777..00000000 --- a/drone/Docker/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Docker files to build the containers used with DroneCI. - -Example: -``` -docker build -t ubuntu/qp2_env . - -``` - diff --git a/drone/Docker/Ubuntu/Dockerfile b/drone/Docker/Ubuntu/Dockerfile deleted file mode 100644 index 05d87ad8..00000000 --- a/drone/Docker/Ubuntu/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -ARG UBUNTU_VERSION=20.04 -FROM ubuntu:${UBUNTU_VERSION} AS builder - -# Timezone for tzdata -ARG tz=Etc/UTC -RUN echo $tz > /etc/timezone && rm -rf /etc/localtime - -# Install -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - git \ - curl \ - wget \ - python3 \ - gfortran \ - gcc \ - g++ \ - make \ - build-essential \ - rsync \ - unzip \ - libopenblas-dev \ - pkg-config \ - m4 - -RUN ln -s /usr/bin/python3 /usr/bin/python - - diff --git a/drone/compilation.sh b/drone/compilation.sh deleted file mode 100755 index 071b4872..00000000 --- a/drone/compilation.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# Stage 2 - -# Extract cache from config stage -cd ../ -tar -zxf $HOME/cache/config.tgz - -# Configure QP2 -cd qp2 -source ./quantum_package.rc -ninja -j 1 -v || exit -1 - -# Create cache -cd .. -tar -zcf $HOME/cache/compil.tgz qp2 && rm $HOME/cache/config.tgz - diff --git a/drone/configuration.sh b/drone/configuration.sh deleted file mode 100755 index f925107d..00000000 --- a/drone/configuration.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# Stage 1 - -# Configure QP2 -./configure --download all --install all --config ./config/travis.cfg || exit -1 - -# Create cache -cd ../ -tar -zcf $HOME/cache/config.tgz qp2 - diff --git a/drone/drone_docker.yml b/drone/drone_docker.yml deleted file mode 100644 index d1eb7175..00000000 --- a/drone/drone_docker.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -kind: pipeline -type: docker -name: default - -clone: - depth: 10 - -steps: -- name: configure - pull: never - image: ubuntu/qp2_env - commands: - - ./configure -i all -c ./config/gfortran_debug.cfg - - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - - source quantum_package.rc ; qp plugins install champ - -- name: compile - pull: never - image: ubuntu/qp2_env - commands: - - ninja - -- name: testing - pull: never - image: ubuntu/qp2_env - commands: - - qp test - - diff --git a/drone/drone_ssh.yml b/drone/drone_ssh.yml deleted file mode 100644 index 99397f11..00000000 --- a/drone/drone_ssh.yml +++ /dev/null @@ -1,29 +0,0 @@ -kind: pipeline -type: ssh -name: default - -clone: - depth: 10 - -server: - host: 130.120.229.139 - user: test - password: - from_secret: ssh_pass - -steps: -- name: configure - commands: - - ./configure -i all -c ./config/gfortran_debug.cfg - - source quantum_package.rc ; qp plugins download https://gitlab.com/scemama/qp_plugins_scemama - - source quantum_package.rc ; qp plugins install champ - -- name: compile - commands: - - ninja - -- name: testing - commands: - - qp test - - diff --git a/drone/testing.sh b/drone/testing.sh deleted file mode 100755 index f67bd106..00000000 --- a/drone/testing.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# Stage 3 - -# Extract cache from compile stage -cd ../ -tar -zxf $HOME/cache/compil.tgz - -# Configure QP2 -cd qp2 -source ./quantum_package.rc -exec qp_test -a && rm $HOME/cache/compil.tgz - - - - - diff --git a/src/cisd/30.cisd.bats b/src/cisd/30.cisd.bats index 58d996f8..6e110aa3 100644 --- a/src/cisd/30.cisd.bats +++ b/src/cisd/30.cisd.bats @@ -77,7 +77,7 @@ function run() { [[ -n $TRAVIS ]] && skip qp set_file ch4.ezfio qp set_mo_class --core="[1]" --act="[2-30]" --del="[31-59]" - run -40.2403962667047 -39.8433221754964 + run -40.2403962667047 -39.843315 } @test "SiH3" { # 20.2202s 1.38648m From 62dbf1194249cde77526aea436d83897299c408c Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 19 May 2022 10:28:05 +0200 Subject: [PATCH 66/79] update au to eV --- src/cis/cis.irp.f | 2 +- src/cisd/cisd.irp.f | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cis/cis.irp.f b/src/cis/cis.irp.f index f72197c2..57bf7789 100644 --- a/src/cis/cis.irp.f +++ b/src/cis/cis.irp.f @@ -74,7 +74,7 @@ subroutine run print*,'******************************************************' print*,'Excitation energies (au) (eV)' do i = 2, N_states - print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1))/0.0367502d0 + print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1)) * 27.211396641308d0 enddo print*,'' endif diff --git a/src/cisd/cisd.irp.f b/src/cisd/cisd.irp.f index fca3b10e..a6211d20 100644 --- a/src/cisd/cisd.irp.f +++ b/src/cisd/cisd.irp.f @@ -95,8 +95,8 @@ subroutine run print*,'******************************' print*,'Excitation energies (eV) (CISD+Q)' do i = 2, N_states - print*, i ,(CI_energy(i) - CI_energy(1))/0.0367502d0, & - (cisdq(i) - cisdq(1)) / 0.0367502d0 + print*, i ,(CI_energy(i) - CI_energy(1))*27.211396641308d0, & + (cisdq(i) - cisdq(1)) * 27.211396641308d0 enddo endif From f4512851bfc354144ad696e677cbf5d8fe135396 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 19 May 2022 10:42:29 +0200 Subject: [PATCH 67/79] provder for Ha to eV --- src/cis/cis.irp.f | 2 +- src/cisd/cisd.irp.f | 4 ++-- src/iterations/print_extrapolation.irp.f | 2 +- src/iterations/print_summary.irp.f | 12 ++++++------ src/utils/units.irp.f | 10 ++++++++++ 5 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 src/utils/units.irp.f diff --git a/src/cis/cis.irp.f b/src/cis/cis.irp.f index 57bf7789..2b16a5f7 100644 --- a/src/cis/cis.irp.f +++ b/src/cis/cis.irp.f @@ -74,7 +74,7 @@ subroutine run print*,'******************************************************' print*,'Excitation energies (au) (eV)' do i = 2, N_states - print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1)) * 27.211396641308d0 + print*, i ,CI_energy(i) - CI_energy(1), (CI_energy(i) - CI_energy(1)) * ha_to_ev enddo print*,'' endif diff --git a/src/cisd/cisd.irp.f b/src/cisd/cisd.irp.f index a6211d20..6137643c 100644 --- a/src/cisd/cisd.irp.f +++ b/src/cisd/cisd.irp.f @@ -95,8 +95,8 @@ subroutine run print*,'******************************' print*,'Excitation energies (eV) (CISD+Q)' do i = 2, N_states - print*, i ,(CI_energy(i) - CI_energy(1))*27.211396641308d0, & - (cisdq(i) - cisdq(1)) * 27.211396641308d0 + print*, i ,(CI_energy(i) - CI_energy(1)) * ha_to_ev, & + (cisdq(i) - cisdq(1)) * ha_to_ev enddo endif diff --git a/src/iterations/print_extrapolation.irp.f b/src/iterations/print_extrapolation.irp.f index e07cc1ed..7f602ffb 100644 --- a/src/iterations/print_extrapolation.irp.f +++ b/src/iterations/print_extrapolation.irp.f @@ -35,7 +35,7 @@ subroutine print_extrapolated_energy do k=2,min(N_iter,8) write(*,'(F11.4,X,3(X,F18.8))') pt2_iterations(i,N_iter+1-k), extrapolated_energy(k,i), & extrapolated_energy(k,i) - extrapolated_energy(k,1), & - (extrapolated_energy(k,i) - extrapolated_energy(k,1) ) * 27.211396641308d0 + (extrapolated_energy(k,i) - extrapolated_energy(k,1) ) * ha_to_ev enddo write(*,*) '=========== ', '=================== ', '=================== ', '===================' enddo diff --git a/src/iterations/print_summary.irp.f b/src/iterations/print_summary.irp.f index 8e6285e2..a0db3534 100644 --- a/src/iterations/print_summary.irp.f +++ b/src/iterations/print_summary.irp.f @@ -36,7 +36,7 @@ subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_configuration_,n_st,s write(*,fmt) '# E ', e_(1:N_states_p) if (N_states_p > 1) then write(*,fmt) '# Excit. (au)', e_(1:N_states_p)-e_(1) - write(*,fmt) '# Excit. (eV)', (e_(1:N_states_p)-e_(1))*27.211396641308d0 + write(*,fmt) '# Excit. (eV)', (e_(1:N_states_p)-e_(1))*ha_to_ev endif write(fmt,*) '(A13,', 2*N_states_p, '(1X,F14.8))' write(*,fmt) '# PT2 '//pt2_string, (pt2_data % pt2(k), pt2_data_err % pt2(k), k=1,N_states_p) @@ -47,8 +47,8 @@ subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_configuration_,n_st,s if (N_states_p > 1) then write(*,fmt) '# Excit. (au)', ( (e_(k)+pt2_data % pt2(k)-e_(1)-pt2_data % pt2(1)), & dsqrt(pt2_data_err % pt2(k)*pt2_data_err % pt2(k)+pt2_data_err % pt2(1)*pt2_data_err % pt2(1)), k=1,N_states_p) - write(*,fmt) '# Excit. (eV)', ( (e_(k)+pt2_data % pt2(k)-e_(1)-pt2_data % pt2(1))*27.211396641308d0, & - dsqrt(pt2_data_err % pt2(k)*pt2_data_err % pt2(k)+pt2_data_err % pt2(1)*pt2_data_err % pt2(1))*27.211396641308d0, k=1,N_states_p) + write(*,fmt) '# Excit. (eV)', ( (e_(k)+pt2_data % pt2(k)-e_(1)-pt2_data % pt2(1))*ha_to_ev, & + dsqrt(pt2_data_err % pt2(k)*pt2_data_err % pt2(k)+pt2_data_err % pt2(1)*pt2_data_err % pt2(1))*ha_to_ev, k=1,N_states_p) endif write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))' write(*,fmt) @@ -82,19 +82,19 @@ subroutine print_summary(e_,pt2_data,pt2_data_err,n_det_,n_configuration_,n_st,s print *, 'Variational Energy difference (au | eV)' do i=2, N_states_p print*,'Delta E = ', (e_(i) - e_(1)), & - (e_(i) - e_(1)) * 27.211396641308d0 + (e_(i) - e_(1)) * ha_to_ev enddo print *, '-----' print*, 'Variational + perturbative Energy difference (au | eV)' do i=2, N_states_p print*,'Delta E = ', (e_(i)+ pt2_data % pt2(i) - (e_(1) + pt2_data % pt2(1))), & - (e_(i)+ pt2_data % pt2(i) - (e_(1) + pt2_data % pt2(1))) * 27.211396641308d0 + (e_(i)+ pt2_data % pt2(i) - (e_(1) + pt2_data % pt2(1))) * ha_to_ev enddo print *, '-----' print*, 'Variational + renormalized perturbative Energy difference (au | eV)' do i=2, N_states_p print*,'Delta E = ', (e_(i)+ pt2_data % rpt2(i) - (e_(1) + pt2_data % rpt2(1))), & - (e_(i)+ pt2_data % rpt2(i) - (e_(1) + pt2_data % rpt2(1))) * 27.211396641308d0 + (e_(i)+ pt2_data % rpt2(i) - (e_(1) + pt2_data % rpt2(1))) * ha_to_ev enddo endif diff --git a/src/utils/units.irp.f b/src/utils/units.irp.f new file mode 100644 index 00000000..914fd041 --- /dev/null +++ b/src/utils/units.irp.f @@ -0,0 +1,10 @@ +BEGIN_PROVIDER [double precision, ha_to_ev] + + implicit none + BEGIN_DOC + ! Converstion from Hartree to eV + END_DOC + + ha_to_ev = 27.211396641308d0 + +END_PROVIDER From 7a67d69c0a794bbb0e6cbe24a5b9a62142479f44 Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 19 May 2022 11:12:20 +0200 Subject: [PATCH 68/79] au to Debye --- src/determinants/dipole_moments.irp.f | 10 +++++++--- src/utils/units.irp.f | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/determinants/dipole_moments.irp.f b/src/determinants/dipole_moments.irp.f index 06fca0cd..b411dda4 100644 --- a/src/determinants/dipole_moments.irp.f +++ b/src/determinants/dipole_moments.irp.f @@ -66,9 +66,13 @@ END_PROVIDER write(*,'(i16)',advance='no') i end do write(*,*) '' - write(*,'(A17,100(1pE16.8))') 'x_dipole_moment = ',x_dipole_moment - write(*,'(A17,100(1pE16.8))') 'y_dipole_moment = ',y_dipole_moment - write(*,'(A17,100(1pE16.8))') 'z_dipole_moment = ',z_dipole_moment + write(*,'(A23,100(1pE16.8))') 'x_dipole_moment (au) = ',x_dipole_moment + write(*,'(A23,100(1pE16.8))') 'y_dipole_moment (au) = ',y_dipole_moment + write(*,'(A23,100(1pE16.8))') 'z_dipole_moment (au) = ',z_dipole_moment + write(*,*) '' + write(*,'(A23,100(1pE16.8))') 'x_dipole_moment (D) = ',x_dipole_moment * au_to_D + write(*,'(A23,100(1pE16.8))') 'y_dipole_moment (D) = ',y_dipole_moment * au_to_D + write(*,'(A23,100(1pE16.8))') 'z_dipole_moment (D) = ',z_dipole_moment * au_to_D !print*, 'x_dipole_moment = ',x_dipole_moment !print*, 'y_dipole_moment = ',y_dipole_moment !print*, 'z_dipole_moment = ',z_dipole_moment diff --git a/src/utils/units.irp.f b/src/utils/units.irp.f index 914fd041..1850b28b 100644 --- a/src/utils/units.irp.f +++ b/src/utils/units.irp.f @@ -8,3 +8,15 @@ BEGIN_PROVIDER [double precision, ha_to_ev] ha_to_ev = 27.211396641308d0 END_PROVIDER + +BEGIN_PROVIDER [double precision, au_to_D] + + implicit none + BEGIN_DOC + ! Converstion from au to Debye + END_DOC + + au_to_D = 2.5415802529d0 + +END_PROVIDER + From ec39cad837eb5deea739b96ad63e63a11b2aba7b Mon Sep 17 00:00:00 2001 From: ydamour Date: Thu, 19 May 2022 11:12:39 +0200 Subject: [PATCH 69/79] cisd(q) only if n_elec >= 4 --- src/cisd/cisd.irp.f | 59 ++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/src/cisd/cisd.irp.f b/src/cisd/cisd.irp.f index 6137643c..5f167686 100644 --- a/src/cisd/cisd.irp.f +++ b/src/cisd/cisd.irp.f @@ -69,7 +69,9 @@ subroutine run do i = 1,N_states k = maxloc(dabs(psi_coef_sorted(1:N_det,i)),dim=1) delta_E = CI_electronic_energy(i) - diag_h_mat_elem(psi_det_sorted(1,1,k),N_int) - cisdq(i) = CI_energy(i) + delta_E * (1.d0 - psi_coef_sorted(k,i)**2) + if (elec_alpha_num + elec_beta_num >= 4) then + cisdq(i) = CI_energy(i) + delta_E * (1.d0 - psi_coef_sorted(k,i)**2) + endif enddo print *, 'N_det = ', N_det print*,'' @@ -78,26 +80,43 @@ subroutine run do i = 1,N_states print *, i, CI_energy(i) enddo - print*,'' - print*,'******************************' - print *, 'CISD+Q Energies' - do i = 1,N_states - print *, i, cisdq(i) - enddo + if (elec_alpha_num + elec_beta_num >= 4) then + print*,'' + print*,'******************************' + print *, 'CISD+Q Energies' + do i = 1,N_states + print *, i, cisdq(i) + enddo + endif if (N_states > 1) then - print*,'' - print*,'******************************' - print*,'Excitation energies (au) (CISD+Q)' - do i = 2, N_states - print*, i ,CI_energy(i) - CI_energy(1), cisdq(i) - cisdq(1) - enddo - print*,'' - print*,'******************************' - print*,'Excitation energies (eV) (CISD+Q)' - do i = 2, N_states - print*, i ,(CI_energy(i) - CI_energy(1)) * ha_to_ev, & - (cisdq(i) - cisdq(1)) * ha_to_ev - enddo + if (elec_alpha_num + elec_beta_num >= 4) then + print*,'' + print*,'******************************' + print*,'Excitation energies (au) (CISD+Q)' + do i = 2, N_states + print*, i ,CI_energy(i) - CI_energy(1), cisdq(i) - cisdq(1) + enddo + print*,'' + print*,'******************************' + print*,'Excitation energies (eV) (CISD+Q)' + do i = 2, N_states + print*, i ,(CI_energy(i) - CI_energy(1)) * ha_to_ev, & + (cisdq(i) - cisdq(1)) * ha_to_ev + enddo + else + print*,'' + print*,'******************************' + print*,'Excitation energies (au) (CISD)' + do i = 2, N_states + print*, i ,CI_energy(i) - CI_energy(1) + enddo + print*,'' + print*,'******************************' + print*,'Excitation energies (eV) (CISD)' + do i = 2, N_states + print*, i ,(CI_energy(i) - CI_energy(1)) * ha_to_ev + enddo + endif endif end From a52a084f583a7bad79394aa279df421a00cd80de Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 25 May 2022 13:34:56 +0200 Subject: [PATCH 70/79] Revert "Replaces psi_det_size by N_det" This reverts commit 6224e449ca2f1850152e2fdc46f838806e1b5907. --- src/csf/configurations.irp.f | 2 +- src/davidson/davidson_parallel.irp.f | 2 +- src/davidson/davidson_parallel_csf.irp.f | 2 +- src/davidson/davidson_parallel_nos2.irp.f | 2 +- src/davidson/u0_hs2_u0.irp.f | 2 +- src/davidson/u0_wee_u0.irp.f | 2 +- src/determinants/determinants.irp.f | 69 ++++++++++++++++++----- src/determinants/h_apply.irp.f | 7 ++- src/determinants/psi_cas.irp.f | 20 +++---- src/determinants/s2.irp.f | 2 +- src/determinants/spindeterminants.irp.f | 6 +- src/determinants/zmq.irp.f | 27 ++++++--- src/generators_cas/generators.irp.f | 10 ++-- src/generators_full/generators.irp.f | 10 ++-- src/perturbation/selection.irp.f | 4 +- src/psiref_cas/psi_ref.irp.f | 12 ++-- src/psiref_utils/psi_ref_utils.irp.f | 26 ++++----- src/selectors_utils/selectors.irp.f | 2 +- src/single_ref_method/generators.irp.f | 4 +- 19 files changed, 132 insertions(+), 79 deletions(-) diff --git a/src/csf/configurations.irp.f b/src/csf/configurations.irp.f index 3ecaa517..ce5d48ab 100644 --- a/src/csf/configurations.irp.f +++ b/src/csf/configurations.irp.f @@ -332,7 +332,7 @@ subroutine configuration_to_dets_tree_addressing(o,d,sze,n_alpha,Nint) end - BEGIN_PROVIDER [ integer(bit_kind), psi_configuration, (N_int,2,N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_configuration, (N_int,2,psi_det_size) ] &BEGIN_PROVIDER [ integer, N_configuration ] implicit none BEGIN_DOC diff --git a/src/davidson/davidson_parallel.irp.f b/src/davidson/davidson_parallel.irp.f index b642d7a4..e627dfc9 100644 --- a/src/davidson/davidson_parallel.irp.f +++ b/src/davidson/davidson_parallel.irp.f @@ -99,7 +99,7 @@ subroutine davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read + integer :: N_states_read, N_det_read, psi_det_size_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/davidson_parallel_csf.irp.f b/src/davidson/davidson_parallel_csf.irp.f index 8a8fcc4a..d8e9bffa 100644 --- a/src/davidson/davidson_parallel_csf.irp.f +++ b/src/davidson/davidson_parallel_csf.irp.f @@ -99,7 +99,7 @@ subroutine davidson_csf_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read + integer :: N_states_read, N_det_read, psi_det_size_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/davidson_parallel_nos2.irp.f b/src/davidson/davidson_parallel_nos2.irp.f index dcc9687d..597b001f 100644 --- a/src/davidson/davidson_parallel_nos2.irp.f +++ b/src/davidson/davidson_parallel_nos2.irp.f @@ -99,7 +99,7 @@ subroutine davidson_nos2_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, integer :: rc, ni, nj integer*8 :: rc8 - integer :: N_states_read, N_det_read + integer :: N_states_read, N_det_read, psi_det_size_read integer :: N_det_selectors_read, N_det_generators_read integer, external :: zmq_get_dvector diff --git a/src/davidson/u0_hs2_u0.irp.f b/src/davidson/u0_hs2_u0.irp.f index e67777e7..38fb56bd 100644 --- a/src/davidson/u0_hs2_u0.irp.f +++ b/src/davidson/u0_hs2_u0.irp.f @@ -6,7 +6,7 @@ ! ! psi_s2(i) = $\langle \Psi_i | S^2 | \Psi_i \rangle$ END_DOC - call u_0_HS2_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,N_det) + call u_0_HS2_u_0(psi_energy,psi_s2,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) integer :: i do i=N_det+1,N_states psi_energy(i) = 0.d0 diff --git a/src/davidson/u0_wee_u0.irp.f b/src/davidson/u0_wee_u0.irp.f index e53d76ea..0c543aca 100644 --- a/src/davidson/u0_wee_u0.irp.f +++ b/src/davidson/u0_wee_u0.irp.f @@ -4,7 +4,7 @@ BEGIN_PROVIDER [ double precision, psi_energy_two_e, (N_states) ] ! Energy of the current wave function END_DOC integer :: i,j - call u_0_H_u_0_two_e(psi_energy_two_e,psi_coef,N_det,psi_det,N_int,N_states,N_det) + call u_0_H_u_0_two_e(psi_energy_two_e,psi_coef,N_det,psi_det,N_int,N_states,psi_det_size) do i=N_det+1,N_states psi_energy_two_e(i) = 0.d0 enddo diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index 36da8c07..4b317025 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -70,7 +70,42 @@ BEGIN_PROVIDER [integer, max_degree_exc] enddo END_PROVIDER -BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,N_det) ] +BEGIN_PROVIDER [ integer, psi_det_size ] + implicit none + BEGIN_DOC + ! Size of the psi_det and psi_coef arrays + END_DOC + PROVIDE ezfio_filename + logical :: exists + psi_det_size = 1 + PROVIDE mpi_master + if (read_wf) then + if (mpi_master) then + call ezfio_has_determinants_n_det(exists) + if (exists) then + call ezfio_get_determinants_n_det(psi_det_size) + else + psi_det_size = 1 + endif + call write_int(6,psi_det_size,'Dimension of the psi arrays') + endif + IRP_IF MPI_DEBUG + print *, irp_here, mpi_rank + call MPI_BARRIER(MPI_COMM_WORLD, ierr) + IRP_ENDIF + IRP_IF MPI + include 'mpif.h' + integer :: ierr + call MPI_BCAST( psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) + if (ierr /= MPI_SUCCESS) then + stop 'Unable to read psi_det_size with MPI' + endif + IRP_ENDIF + endif + +END_PROVIDER + +BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,psi_det_size) ] implicit none BEGIN_DOC ! The determinants of the wave function. Initialized with Hartree-Fock if the |EZFIO| file @@ -141,7 +176,7 @@ END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_coef, (N_det,N_states) ] +BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! The wave function coefficients. Initialized with Hartree-Fock if the |EZFIO| file @@ -154,7 +189,7 @@ BEGIN_PROVIDER [ double precision, psi_coef, (N_det,N_states) ] PROVIDE read_wf N_det mo_label ezfio_filename psi_coef = 0.d0 - do i=1,min(N_states,N_det) + do i=1,min(N_states,psi_det_size) psi_coef(i,i) = 1.d0 enddo @@ -202,7 +237,7 @@ BEGIN_PROVIDER [ double precision, psi_coef, (N_det,N_states) ] END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (N_det) ] +BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (psi_det_size) ] implicit none BEGIN_DOC ! Contribution of determinants to the state-averaged density. @@ -252,10 +287,10 @@ END_PROVIDER !==============================================================================! - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted, (N_det,N_states) ] -&BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted, (N_det) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_order, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted, (psi_det_size,N_states) ] +&BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted, (psi_det_size) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_order, (psi_det_size) ] implicit none BEGIN_DOC ! Wave function sorted by determinants contribution to the norm (state-averaged) @@ -284,12 +319,17 @@ END_PROVIDER psi_det_sorted_order(iorder(i)) = i enddo + psi_det_sorted(:,:,N_det+1:psi_det_size) = 0_bit_kind + psi_coef_sorted(N_det+1:psi_det_size,:) = 0.d0 + psi_average_norm_contrib_sorted(N_det+1:psi_det_size) = 0.d0 + psi_det_sorted_order(N_det+1:psi_det_size) = 0 + deallocate(iorder) END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! Determinants on which we apply $\langle i|H|psi \rangle$ for perturbation. @@ -315,6 +355,9 @@ subroutine sort_dets_by_det_search_key(Ndet, det_in, coef_in, sze, det_out, coef ! Determinants are sorted according to their :c:func:`det_search_key`. ! Useful to accelerate the search of a random determinant in the wave ! function. + ! + ! /!\ The first dimension of coef_out and coef_in need to be psi_det_size + ! END_DOC integer :: i,j,k integer, allocatable :: iorder(:) @@ -448,11 +491,7 @@ subroutine save_wavefunction_truncated(thr) endif enddo if (mpi_master) then - call save_wavefunction_general(N_det_save, & - min(N_states,N_det_save), & - psi_det_sorted, & - size(psi_coef_sorted,1), & - psi_coef_sorted) + call save_wavefunction_general(N_det_save,min(N_states,N_det_save),psi_det_sorted,size(psi_coef_sorted,1),psi_coef_sorted) endif end diff --git a/src/determinants/h_apply.irp.f b/src/determinants/h_apply.irp.f index 246ff209..d01ad1c7 100644 --- a/src/determinants/h_apply.irp.f +++ b/src/determinants/h_apply.irp.f @@ -159,7 +159,10 @@ subroutine copy_H_apply_buffer_to_wf enddo ! Update array sizes - TOUCH N_det + if (psi_det_size < N_det) then + psi_det_size = N_det + TOUCH psi_det_size + endif ! Restore backup in resized array do i=1,N_det_old @@ -177,7 +180,7 @@ subroutine copy_H_apply_buffer_to_wf !$OMP PARALLEL DEFAULT(SHARED) & !$OMP PRIVATE(j,k,i) FIRSTPRIVATE(N_det_old) & - !$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,N_det) + !$OMP SHARED(N_int,H_apply_buffer,psi_det,psi_coef,N_states,psi_det_size) j=0 !$ j=omp_get_thread_num() do k=0,j-1 diff --git a/src/determinants/psi_cas.irp.f b/src/determinants/psi_cas.irp.f index 125ec1e1..19a1c260 100644 --- a/src/determinants/psi_cas.irp.f +++ b/src/determinants/psi_cas.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_cas, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_cas_coef, (N_det,n_states) ] -&BEGIN_PROVIDER [ integer, idx_cas, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_cas, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_cas_coef, (psi_det_size,n_states) ] +&BEGIN_PROVIDER [ integer, idx_cas, (psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_cas ] implicit none BEGIN_DOC @@ -44,8 +44,8 @@ use bitmasks END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_cas_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_cas_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_cas_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_cas_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! |CAS| determinants sorted to accelerate the search of a random determinant in the wave @@ -58,9 +58,9 @@ END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_cas_coef, (N_det,n_states) ] -&BEGIN_PROVIDER [ integer, idx_non_cas, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_cas_coef, (psi_det_size,n_states) ] +&BEGIN_PROVIDER [ integer, idx_non_cas, (psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_non_cas ] implicit none BEGIN_DOC @@ -97,8 +97,8 @@ END_PROVIDER N_det_non_cas = i_non_cas END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_cas_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_cas_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_cas_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! |CAS| determinants sorted to accelerate the search of a random determinant in the wave diff --git a/src/determinants/s2.irp.f b/src/determinants/s2.irp.f index abae212f..2c1a8757 100644 --- a/src/determinants/s2.irp.f +++ b/src/determinants/s2.irp.f @@ -110,7 +110,7 @@ END_PROVIDER ! array of the averaged values of the S^2 operator on the various states END_DOC integer :: i - call u_0_S2_u_0(s2_values,psi_coef,n_det,psi_det,N_int,N_states,N_det) + call u_0_S2_u_0(s2_values,psi_coef,n_det,psi_det,N_int,N_states,psi_det_size) do i = 1, N_states s_values(i) = 0.5d0 *(-1.d0 + dsqrt(1.d0 + 4 * s2_values(i))) enddo diff --git a/src/determinants/spindeterminants.irp.f b/src/determinants/spindeterminants.irp.f index e4a857a9..dd55e112 100644 --- a/src/determinants/spindeterminants.irp.f +++ b/src/determinants/spindeterminants.irp.f @@ -24,7 +24,7 @@ integer*8 function spin_det_search_key(det,Nint) end -BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,N_det) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,psi_det_size) ] implicit none BEGIN_DOC ! List of $\alpha$ determinants of psi_det @@ -39,7 +39,7 @@ BEGIN_PROVIDER [ integer(bit_kind), psi_det_alpha, (N_int,N_det) ] END_PROVIDER -BEGIN_PROVIDER [ integer(bit_kind), psi_det_beta, (N_int,N_det) ] +BEGIN_PROVIDER [ integer(bit_kind), psi_det_beta, (N_int,psi_det_size) ] implicit none BEGIN_DOC ! List of $\beta$ determinants of psi_det @@ -56,7 +56,7 @@ END_PROVIDER BEGIN_TEMPLATE - BEGIN_PROVIDER [ integer(bit_kind), psi_det_$alpha_unique, (N_int,N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_$alpha_unique, (N_int,psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_$alpha_unique ] implicit none BEGIN_DOC diff --git a/src/determinants/zmq.irp.f b/src/determinants/zmq.irp.f index 7288de05..5a114533 100644 --- a/src/determinants/zmq.irp.f +++ b/src/determinants/zmq.irp.f @@ -10,6 +10,7 @@ integer function zmq_put_psi(zmq_to_qp_run_socket,worker_id) integer, external :: zmq_put_N_states integer, external :: zmq_put_N_det + integer, external :: zmq_put_psi_det_size integer*8, external :: zmq_put_psi_det integer*8, external :: zmq_put_psi_coef @@ -22,6 +23,10 @@ integer function zmq_put_psi(zmq_to_qp_run_socket,worker_id) zmq_put_psi = -1 return endif + if (zmq_put_psi_det_size(zmq_to_qp_run_socket, worker_id) == -1) then + zmq_put_psi = -1 + return + endif if (zmq_put_psi_det(zmq_to_qp_run_socket, worker_id) == -1) then zmq_put_psi = -1 return @@ -46,6 +51,7 @@ integer function zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) integer, external :: zmq_get_N_states integer, external :: zmq_get_N_det + integer, external :: zmq_get_psi_det_size integer*8, external :: zmq_get_psi_det integer*8, external :: zmq_get_psi_coef @@ -59,15 +65,19 @@ integer function zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) zmq_get_psi_notouch = -1 return endif - - if (size(psi_det,kind=8) /= N_int*2_8*N_det*bit_kind) then - deallocate(psi_det) - allocate(psi_det(N_int,2,N_det)) + if (zmq_get_psi_det_size(zmq_to_qp_run_socket, worker_id) == -1) then + zmq_get_psi_notouch = -1 + return endif - if (size(psi_coef,kind=8) /= N_det*N_states) then + if (size(psi_det,kind=8) /= N_int*2_8*psi_det_size*bit_kind) then + deallocate(psi_det) + allocate(psi_det(N_int,2,psi_det_size)) + endif + + if (size(psi_coef,kind=8) /= psi_det_size*N_states) then deallocate(psi_coef) - allocate(psi_coef(N_det,N_states)) + allocate(psi_coef(psi_det_size,N_states)) endif if (zmq_get_psi_det(zmq_to_qp_run_socket, worker_id) == -1_8) then @@ -92,7 +102,7 @@ integer function zmq_get_psi(zmq_to_qp_run_socket, worker_id) integer, intent(in) :: worker_id integer, external :: zmq_get_psi_notouch zmq_get_psi = zmq_get_psi_notouch(zmq_to_qp_run_socket, worker_id) - SOFT_TOUCH psi_det psi_coef N_det N_states + SOFT_TOUCH psi_det psi_coef psi_det_size N_det N_states end @@ -256,7 +266,7 @@ integer function zmq_get_psi_bilinear(zmq_to_qp_run_socket, worker_id) return endif - SOFT_TOUCH psi_bilinear_matrix_values psi_bilinear_matrix_rows psi_bilinear_matrix_columns psi_bilinear_matrix_order psi_det psi_coef N_det N_states psi_det_beta_unique psi_det_alpha_unique N_det_beta_unique N_det_alpha_unique + SOFT_TOUCH psi_bilinear_matrix_values psi_bilinear_matrix_rows psi_bilinear_matrix_columns psi_bilinear_matrix_order psi_det psi_coef psi_det_size N_det N_states psi_det_beta_unique psi_det_alpha_unique N_det_beta_unique N_det_alpha_unique end @@ -364,6 +374,7 @@ N_states ;; N_det ;; N_det_alpha_unique ;; N_det_beta_unique ;; +psi_det_size ;; END_TEMPLATE diff --git a/src/generators_cas/generators.irp.f b/src/generators_cas/generators.irp.f index e499f703..b2f58202 100644 --- a/src/generators_cas/generators.irp.f +++ b/src/generators_cas/generators.irp.f @@ -20,11 +20,11 @@ BEGIN_PROVIDER [ integer, N_det_generators ] call write_int(6,N_det_generators,'Number of generators') END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] -&BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (N_det,N_states) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] +&BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (psi_det_size,N_states) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (psi_det_size) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the diff --git a/src/generators_full/generators.irp.f b/src/generators_full/generators.irp.f index 376e5e3e..7f18947f 100644 --- a/src/generators_full/generators.irp.f +++ b/src/generators_full/generators.irp.f @@ -22,8 +22,8 @@ BEGIN_PROVIDER [ integer, N_det_generators ] call write_int(6,N_det_generators,'Number of generators') END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the @@ -34,9 +34,9 @@ END_PROVIDER END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (N_det,N_states) ] -&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_gen, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_sorted_gen, (psi_det_size,N_states) ] +&BEGIN_PROVIDER [ integer, psi_det_sorted_gen_order, (psi_det_size) ] implicit none BEGIN_DOC diff --git a/src/perturbation/selection.irp.f b/src/perturbation/selection.irp.f index d5947d25..f3f03673 100644 --- a/src/perturbation/selection.irp.f +++ b/src/perturbation/selection.irp.f @@ -90,12 +90,12 @@ subroutine remove_small_contributions enddo !$OMP PARALLEL DEFAULT(NONE) & !$OMP PRIVATE(i,j,i_H_psi_array) & - !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,N_states, & + !$OMP SHARED(k,psi_det_sorted,psi_coef_sorted,N_int,N_det,psi_det_size,N_states, & !$OMP selection_criterion_min,keep,N_det_generators) & !$OMP REDUCTION(+:N_removed) !$OMP DO do i=2*N_det_generators+1, N_det - call i_H_psi(psi_det_sorted(1,1,i),psi_det_sorted,psi_coef_sorted,N_int,min(N_det,2*N_det_generators),N_det,N_states,i_H_psi_array) + call i_H_psi(psi_det_sorted(1,1,i),psi_det_sorted,psi_coef_sorted,N_int,min(N_det,2*N_det_generators),psi_det_size,N_states,i_H_psi_array) keep(i) = .False. do j=1,N_states keep(i) = keep(i) .or. (-(psi_coef_sorted(i,j)*i_H_psi_array(j)) > selection_criterion_min) diff --git a/src/psiref_cas/psi_ref.irp.f b/src/psiref_cas/psi_ref.irp.f index 0e1df986..78dd2239 100644 --- a/src/psiref_cas/psi_ref.irp.f +++ b/src/psiref_cas/psi_ref.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef, (N_det,n_states) ] -&BEGIN_PROVIDER [ integer, idx_ref, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef, (psi_det_size,n_states) ] +&BEGIN_PROVIDER [ integer, idx_ref, (psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_ref ] implicit none BEGIN_DOC @@ -26,7 +26,7 @@ use bitmasks END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (N_det,n_states) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (psi_det_size,n_states) ] implicit none BEGIN_DOC ! 1/psi_ref_coef @@ -41,8 +41,8 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_inv, (N_det,n_states) ] END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_ref_restart, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef_restart, (N_det,n_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref_restart, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef_restart, (psi_det_size,n_states) ] implicit none BEGIN_DOC ! Projection of the CAS wave function on the restart wave function. diff --git a/src/psiref_utils/psi_ref_utils.irp.f b/src/psiref_utils/psi_ref_utils.irp.f index 185d9778..19e42283 100644 --- a/src/psiref_utils/psi_ref_utils.irp.f +++ b/src/psiref_utils/psi_ref_utils.irp.f @@ -1,8 +1,8 @@ use bitmasks - BEGIN_PROVIDER [ integer(bit_kind), psi_ref_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_ref_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_ref_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_ref_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! Reference determinants sorted to accelerate the search of a random determinant in the wave @@ -14,7 +14,7 @@ use bitmasks END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,N_det) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,psi_det_size) ] implicit none BEGIN_DOC ! Transposed psi_ref_coef @@ -27,7 +27,7 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_transp, (n_states,N_det) ] enddo END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (N_det,n_states) ] +BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (psi_det_size,n_states) ] implicit none BEGIN_DOC ! Normalized coefficients of the reference @@ -43,7 +43,7 @@ BEGIN_PROVIDER [ double precision, psi_ref_coef_normalized, (N_det,n_states) ] END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,N_det) ] +BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,psi_det_size) ] implicit none BEGIN_DOC ! Transposed psi_non_ref_coef @@ -56,10 +56,10 @@ BEGIN_PROVIDER [ double precision, psi_non_ref_coef_transp, (n_states,N_det) ] enddo END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef, (N_det,n_states) ] -&BEGIN_PROVIDER [ integer, idx_non_ref, (N_det) ] -&BEGIN_PROVIDER [ integer, idx_non_ref_rev, (N_det) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef, (psi_det_size,n_states) ] +&BEGIN_PROVIDER [ integer, idx_non_ref, (psi_det_size) ] +&BEGIN_PROVIDER [ integer, idx_non_ref_rev, (psi_det_size) ] &BEGIN_PROVIDER [ integer, N_det_non_ref ] implicit none BEGIN_DOC @@ -102,8 +102,8 @@ END_PROVIDER endif END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_restart, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_restart, (N_det,n_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_restart, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_restart, (psi_det_size,n_states) ] implicit none BEGIN_DOC ! Set of determinants which are not part of the reference, defined from the application @@ -144,8 +144,8 @@ END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_sorted_bit, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_sorted_bit, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_non_ref_sorted_bit, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_non_ref_coef_sorted_bit, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! Reference determinants sorted to accelerate the search of a random determinant in the wave diff --git a/src/selectors_utils/selectors.irp.f b/src/selectors_utils/selectors.irp.f index 765bd5e8..92366d1d 100644 --- a/src/selectors_utils/selectors.irp.f +++ b/src/selectors_utils/selectors.irp.f @@ -2,7 +2,7 @@ use bitmasks BEGIN_PROVIDER [ integer, psi_selectors_size ] implicit none - psi_selectors_size = N_det + psi_selectors_size = psi_det_size END_PROVIDER BEGIN_PROVIDER [ double precision, psi_selectors_coef_transp, (N_states,psi_selectors_size) ] diff --git a/src/single_ref_method/generators.irp.f b/src/single_ref_method/generators.irp.f index dd6985a5..ce71f996 100644 --- a/src/single_ref_method/generators.irp.f +++ b/src/single_ref_method/generators.irp.f @@ -9,8 +9,8 @@ BEGIN_PROVIDER [ integer, N_det_generators ] N_det_generators = 1 END_PROVIDER - BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,N_det) ] -&BEGIN_PROVIDER [ double precision, psi_coef_generators, (N_det,N_states) ] + BEGIN_PROVIDER [ integer(bit_kind), psi_det_generators, (N_int,2,psi_det_size) ] +&BEGIN_PROVIDER [ double precision, psi_coef_generators, (psi_det_size,N_states) ] implicit none BEGIN_DOC ! For Single reference wave functions, the generator is the From 727815751cdcadc8affbdd87897150dbb06e6e76 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 25 May 2022 19:35:44 +0200 Subject: [PATCH 71/79] DGEMM four-index transformation --- src/mo_two_e_ints/mo_bi_integrals.irp.f | 96 ++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/src/mo_two_e_ints/mo_bi_integrals.irp.f b/src/mo_two_e_ints/mo_bi_integrals.irp.f index d58932ce..c03b363d 100644 --- a/src/mo_two_e_ints/mo_bi_integrals.irp.f +++ b/src/mo_two_e_ints/mo_bi_integrals.irp.f @@ -53,7 +53,11 @@ BEGIN_PROVIDER [ logical, mo_two_e_integrals_in_map ] ! call four_idx_novvvv call four_idx_novvvv_old else - call add_integrals_to_map(full_ijkl_bitmask_4) + if (ao_num*ao_num*ao_num*ao_num*32.d-9 < dble(qp_max_mem)) then + call four_idx_dgemm + else + call add_integrals_to_map(full_ijkl_bitmask_4) + endif endif call wall_time(wall_2) @@ -77,6 +81,96 @@ BEGIN_PROVIDER [ logical, mo_two_e_integrals_in_map ] END_PROVIDER +subroutine four_idx_dgemm + implicit none + integer :: p,q,r,s,i,j,k,l + double precision, allocatable :: a1(:,:,:,:) + double precision, allocatable :: a2(:,:,:,:) + + allocate (a1(ao_num,ao_num,ao_num,ao_num)) + + print *, 'Getting AOs' + !$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(q,r,s) + do s=1,ao_num + do r=1,ao_num + do q=1,ao_num + call get_ao_two_e_integrals(q,r,s,ao_num,a1(1,q,r,s)) + enddo + enddo + enddo + !$OMP END PARALLEL DO + + print *, '1st transformation' + ! 1st transformation + allocate (a2(ao_num,ao_num,ao_num,mo_num)) + call dgemm('T','N', (ao_num*ao_num*ao_num), mo_num, ao_num, 1.d0, a1, ao_num, mo_coef, ao_num, 0.d0, a2, (ao_num*ao_num*ao_num)) + + ! 2nd transformation + print *, '2nd transformation' + deallocate (a1) + allocate (a1(ao_num,ao_num,mo_num,mo_num)) + call dgemm('T','N', (ao_num*ao_num*mo_num), mo_num, ao_num, 1.d0, a2, ao_num, mo_coef, ao_num, 0.d0, a1, (ao_num*ao_num*mo_num)) + + ! 3rd transformation + print *, '3rd transformation' + deallocate (a2) + allocate (a2(ao_num,mo_num,mo_num,mo_num)) + call dgemm('T','N', (ao_num*mo_num*mo_num), mo_num, ao_num, 1.d0, a1, ao_num, mo_coef, ao_num, 0.d0, a2, (ao_num*mo_num*mo_num)) + + ! 4th transformation + print *, '4th transformation' + deallocate (a1) + allocate (a1(mo_num,mo_num,mo_num,mo_num)) + call dgemm('T','N', (mo_num*mo_num*mo_num), mo_num, ao_num, 1.d0, a2, ao_num, mo_coef, ao_num, 0.d0, a1, (mo_num*mo_num*mo_num)) + + deallocate (a2) + + integer :: n_integrals, size_buffer + integer(key_kind) , allocatable :: buffer_i(:) + real(integral_kind), allocatable :: buffer_value(:) + size_buffer = min(ao_num*ao_num*ao_num,16000000) + + print *, 'Storing' + !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i,j,k,l,buffer_value,buffer_i,n_integrals) + allocate ( buffer_i(size_buffer), buffer_value(size_buffer) ) + + n_integrals = 0 + !$OMP DO + do l=1,mo_num + do k=1,mo_num + do j=1,l + do i=1,k + if (abs(a1(i,j,k,l)) < mo_integrals_threshold) then + cycle + endif + n_integrals += 1 + buffer_value(n_integrals) = a1(i,j,k,l) + !DIR$ FORCEINLINE + call mo_two_e_integrals_index(i,j,k,l,buffer_i(n_integrals)) + if (n_integrals == size_buffer) then + call map_append(mo_integrals_map, buffer_i, buffer_value, n_integrals) + n_integrals = 0 + endif + enddo + enddo + enddo + enddo + !$OMP END DO + + call map_append(mo_integrals_map, buffer_i, buffer_value, n_integrals) + + deallocate(buffer_i, buffer_value) + !$OMP END PARALLEL + + deallocate (a1) + + print *, 'Unique' + call map_unique(mo_integrals_map) + + integer*8 :: get_mo_map_size, mo_map_size + mo_map_size = get_mo_map_size() + +end subroutine subroutine add_integrals_to_map(mask_ijkl) use bitmasks From 4ccaa8f695a4928be80bb214dd063a7b7e9d28a9 Mon Sep 17 00:00:00 2001 From: v1j4y Date: Mon, 6 Jun 2022 13:41:29 +0200 Subject: [PATCH 72/79] Open-Shell CSF: Fix bug in getbftodetfunction. --- src/csf/cfgCI_utils.c | 50 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c index 23b984a0..63172d14 100644 --- a/src/csf/cfgCI_utils.c +++ b/src/csf/cfgCI_utils.c @@ -68,10 +68,16 @@ void getBFIndexList(int NSOMO, int *BF1, int *IdxListBF1){ break; } } - BFcopy[Iidx] = -1; - BFcopy[Jidx] = -1; - IdxListBF1[Jidx] = Iidx; - IdxListBF1[Iidx] = Jidx; + if(countN1 <= 0){ + BFcopy[Iidx] = -1; + IdxListBF1[Iidx] = Iidx; + } + else{ + BFcopy[Iidx] = -1; + BFcopy[Jidx] = -1; + IdxListBF1[Jidx] = Iidx; + IdxListBF1[Iidx] = Jidx; + } } } @@ -1297,16 +1303,21 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv double fac = 1.0; for(int i = 0; i < NSOMO; i++) donepq[i] = 0.0; + for(int i=0;i 0.0 || donepq[idxq] > 0.0) continue; + if(donepq[idxp] > 0.0 || donepq[idxq] > 0.0 || idxp == idxq) continue; fac *= 2.0; donepq[idxp] = 1.0; donepq[idxq] = 1.0; for(int j = 0; j < npairs; j = j + shft){ + printf("i=%d j=%d (%d,%d)\n",i,j,idxp,idxq); for(int k = 0; k < shft/2; k++){ detslist[(k+j)*NSOMO + idxp] = 1; detslist[(k+j)*NSOMO + idxq] = 0; @@ -1319,15 +1330,26 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv } shft /= 2; } + for(int i=0;i Date: Mon, 6 Jun 2022 14:08:34 +0200 Subject: [PATCH 73/79] Open-Shell CSF: Fix bug in build csftree. --- src/csf/cfgCI_utils.c | 34 +++++----------------------------- src/csf/tree_utils.c | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 40 deletions(-) diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c index 63172d14..91e7360a 100644 --- a/src/csf/cfgCI_utils.c +++ b/src/csf/cfgCI_utils.c @@ -1317,7 +1317,6 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv donepq[idxp] = 1.0; donepq[idxq] = 1.0; for(int j = 0; j < npairs; j = j + shft){ - printf("i=%d j=%d (%d,%d)\n",i,j,idxp,idxq); for(int k = 0; k < shft/2; k++){ detslist[(k+j)*NSOMO + idxp] = 1; detslist[(k+j)*NSOMO + idxq] = 0; @@ -1330,14 +1329,7 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv } shft /= 2; } - for(int i=0;i NSOMOMax || icpl < 0 || izeros > zeromax ) return; // If we find a valid BF assign its address - if(isomo == NSOMOMax){ + if(isomo == NSOMOMax && icpl == MSmax){ (*inode)->addr = bftree->rootNode->addr; bftree->rootNode->addr += 1; return; } // Call 0 branch - if(((*inode)->C0) == NULL && izeros+1 <= zeromax){ - ((*inode)->C0) = malloc(sizeof(Node)); - (*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo }; - buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); + if(izeros+1 <= zeromax){ + if(((*inode)->C0) == NULL){ + ((*inode)->C0) = malloc(sizeof(Node)); + (*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo }; + buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); + } + else buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); } - else buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); // Call 1 branch - if(((*inode)->C1) == NULL && icpl-1 >= 0){ - ((*inode)->C1) = malloc(sizeof(Node)); - (*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo }; - buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); + if(icpl-1 >=0){ + if(((*inode)->C1) == NULL){ + ((*inode)->C1) = malloc(sizeof(Node)); + (*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo }; + buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); + } + else buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); } - else buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); return; } From e06ab2fd05d46a8f8be6c86f23e3870615287b8d Mon Sep 17 00:00:00 2001 From: v1j4y Date: Mon, 6 Jun 2022 15:23:25 +0200 Subject: [PATCH 74/79] Open-Shell CSF: Fix bug in convertCSFtoDetBasis. --- src/csf/cfgCI_utils.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/csf/cfgCI_utils.c b/src/csf/cfgCI_utils.c index 91e7360a..746de04e 100644 --- a/src/csf/cfgCI_utils.c +++ b/src/csf/cfgCI_utils.c @@ -334,10 +334,21 @@ void convertCSFtoDetBasis(int64_t Isomo, int MS, int rowsmax, int colsmax, doubl Get Overlap ************************************/ // Fill matrix + + int rowsbftodetI, colsbftodetI; + + /*********************************** + Get BFtoDeterminant Matrix + ************************************/ + + printf("In convertcsftodet\n"); + convertBFtoDetBasis(Isomo, MS, &bftodetmatrixI, &rowsbftodetI, &colsbftodetI); + int rowsI = 0; int colsI = 0; - getOverlapMatrix(Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); + //getOverlapMatrix(Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); + getOverlapMatrix_withDet(bftodetmatrixI, rowsbftodetI, colsbftodetI, Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); /*********************************** @@ -348,14 +359,6 @@ void convertCSFtoDetBasis(int64_t Isomo, int MS, int rowsmax, int colsmax, doubl gramSchmidt(overlapMatrixI, rowsI, colsI, orthoMatrixI); - /*********************************** - Get BFtoDeterminant Matrix - ************************************/ - - int rowsbftodetI, colsbftodetI; - - convertBFtoDetBasis(Isomo, MS, &bftodetmatrixI, &rowsbftodetI, &colsbftodetI); - /*********************************** Get Final CSF to Det Matrix ************************************/ @@ -1305,7 +1308,7 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv donepq[i] = 0.0; for(int i=0;i Date: Wed, 8 Jun 2022 07:48:58 +0200 Subject: [PATCH 75/79] Update tests --- src/fci/40.fci.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index c303ea87..871de780 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -54,7 +54,7 @@ function run_stoch() { @test "HCO" { # 0:01:16 qp set_file hco.ezfio - run_stoch -113.41658256 1.e-3 50000 + run_stoch -113.41658256 2.e-3 50000 } @test "H2O2" { # 0:01:48 @@ -66,7 +66,7 @@ function run_stoch() { @test "HBO" { # 0:00:46 [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run_stoch -100.22361288 1.e-4 50000 + run_stoch -100.22361288 2.e-3 50000 } @test "H2O" { # 0:01:05 From 6861cea2ac2bd5cbd40c9bd3f4b076602da830a0 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 8 Jun 2022 11:08:53 +0200 Subject: [PATCH 76/79] Compiles with OCaml 4.13.1 --- bin/qp_test | 9 +- configure | 4 +- external/qp2-dependencies | 2 +- ocaml/Qputils.ml | 4 + ocaml/qp_tunnel.ml | 139 ++++++++++++++--------- src/fci/40.fci.bats | 16 +-- src/iterations/print_extrapolation.irp.f | 2 +- tests/bats/common.bats.sh | 2 +- 8 files changed, 102 insertions(+), 76 deletions(-) diff --git a/bin/qp_test b/bin/qp_test index 67b3ea02..288b7291 100755 --- a/bin/qp_test +++ b/bin/qp_test @@ -60,19 +60,14 @@ def main(arguments): print("Running tests for %s"%(bats_file)) print("") if arguments["-v"]: - p = None if arguments["TEST"]: test = "export TEST=%s ; "%arguments["TEST"] else: test = "" - try: - os.system(test+" python3 bats_to_sh.py "+bats_file+ + os.system(test+" python3 bats_to_sh.py "+bats_file+ "| bash") - except: - if p: - p.terminate() else: - subprocess.check_call(["bats", bats_file], env=os.environ) + subprocess.check_call(["bats", "--verbose-run", "--trace", bats_file], env=os.environ) diff --git a/configure b/configure index e70820fe..5c38b9f2 100755 --- a/configure +++ b/configure @@ -281,8 +281,8 @@ EOF execute << EOF cd "\${QP_ROOT}"/external - tar -zxf qp2-dependencies/bats-v1.1.0.tar.gz - ( cd bats-core-1.1.0/ ; ./install.sh \${QP_ROOT}) + tar -zxf qp2-dependencies/bats-v1.7.0.tar.gz + ( cd bats-core-1.7.0/ ; ./install.sh \${QP_ROOT}) EOF else diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 90ee61f5..242151e0 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 90ee61f5041c7c94a0c605625a264860292813a0 +Subproject commit 242151e03d1d6bf042387226431d82d35845686a diff --git a/ocaml/Qputils.ml b/ocaml/Qputils.ml index 270e069f..752a65a0 100644 --- a/ocaml/Qputils.ml +++ b/ocaml/Qputils.ml @@ -56,3 +56,7 @@ let string_of_string s = s let list_map f l = List.rev_map f l |> List.rev + +let socket_convert socket = + ((Obj.magic (Obj.repr socket)) : [ `Xsub ] Zmq.Socket.t ) + diff --git a/ocaml/qp_tunnel.ml b/ocaml/qp_tunnel.ml index 84e50eb5..6885db73 100644 --- a/ocaml/qp_tunnel.ml +++ b/ocaml/qp_tunnel.ml @@ -2,7 +2,7 @@ open Qputils open Qptypes type ezfio_or_address = EZFIO of string | ADDRESS of string -type req_or_sub = REQ | SUB +type req_or_sub = REQ | SUB let localport = 42379 @@ -29,7 +29,7 @@ let () = end; let arg = - let x = + let x = match Command_line.anon_args () with | [x] -> x | _ -> begin @@ -44,7 +44,7 @@ let () = in - let localhost = + let localhost = Lazy.force TaskServer.ip_address in @@ -52,28 +52,28 @@ let () = let long_address = match arg with | ADDRESS x -> x - | EZFIO x -> - let ic = + | EZFIO x -> + let ic = Filename.concat (Qpackage.ezfio_work x) "qp_run_address" |> open_in in - let result = + let result = input_line ic |> String.trim in close_in ic; result in - + let protocol, address, port = match String.split_on_char ':' long_address with | t :: a :: p :: [] -> t, a, int_of_string p - | _ -> failwith @@ + | _ -> failwith @@ Printf.sprintf "%s : Malformed address" long_address in - let zmq_context = + let zmq_context = Zmq.Context.create () in @@ -105,10 +105,10 @@ let () = let create_socket sock_type bind_or_connect addr = - let socket = + let socket = Zmq.Socket.create zmq_context sock_type in - let () = + let () = try bind_or_connect socket addr with @@ -131,37 +131,64 @@ let () = Sys.set_signal Sys.sigint handler; - let new_thread req_or_sub addr_in addr_out = + let new_thread_req addr_in addr_out = let socket_in, socket_out = - match req_or_sub with - | REQ -> create_socket Zmq.Socket.router Zmq.Socket.bind addr_in, create_socket Zmq.Socket.dealer Zmq.Socket.connect addr_out - | SUB -> - create_socket Zmq.Socket.sub Zmq.Socket.connect addr_in, - create_socket Zmq.Socket.pub Zmq.Socket.bind addr_out in - if req_or_sub = SUB then - Zmq.Socket.subscribe socket_in ""; - - - let action_in = - match req_or_sub with - | REQ -> (fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out) - | SUB -> (fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out) + let action_in = + fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out in - let action_out = - match req_or_sub with - | REQ -> (fun () -> Zmq.Socket.recv_all socket_out |> Zmq.Socket.send_all socket_in ) - | SUB -> (fun () -> () ) + let action_out = + fun () -> Zmq.Socket.recv_all socket_out |> Zmq.Socket.send_all socket_in in let pollitem = Zmq.Poll.mask_of - [| (socket_in, Zmq.Poll.In) ; (socket_out, Zmq.Poll.In) |] + [| (socket_convert socket_in, Zmq.Poll.In) ; (socket_convert socket_out, Zmq.Poll.In) |] + in + + while !run_status do + + let polling = + Zmq.Poll.poll ~timeout:1000 pollitem + in + + match polling with + | [| Some Zmq.Poll.In ; Some Zmq.Poll.In |] -> ( action_out () ; action_in () ) + | [| _ ; Some Zmq.Poll.In |] -> action_out () + | [| Some Zmq.Poll.In ; _ |] -> action_in () + | _ -> () + done; + + Zmq.Socket.close socket_in; + Zmq.Socket.close socket_out; + in + + let new_thread_sub addr_in addr_out = + let socket_in, socket_out = + create_socket Zmq.Socket.sub Zmq.Socket.connect addr_in, + create_socket Zmq.Socket.pub Zmq.Socket.bind addr_out + in + + Zmq.Socket.subscribe socket_in ""; + + + + let action_in = + fun () -> Zmq.Socket.recv_all socket_in |> Zmq.Socket.send_all socket_out + in + + let action_out = + fun () -> () + in + + let pollitem = + Zmq.Poll.mask_of + [| (socket_convert socket_in, Zmq.Poll.In) ; (socket_convert socket_out, Zmq.Poll.In) |] in @@ -173,8 +200,8 @@ let () = match polling with | [| Some Zmq.Poll.In ; Some Zmq.Poll.In |] -> ( action_out () ; action_in () ) - | [| _ ; Some Zmq.Poll.In |] -> action_out () - | [| Some Zmq.Poll.In ; _ |] -> action_in () + | [| _ ; Some Zmq.Poll.In |] -> action_out () + | [| Some Zmq.Poll.In ; _ |] -> action_in () | _ -> () done; @@ -193,8 +220,8 @@ let () = Printf.sprintf "tcp://*:%d" localport in - let f () = - new_thread REQ addr_in addr_out + let f () = + new_thread_req addr_in addr_out in (Thread.create f) () @@ -211,8 +238,8 @@ let () = Printf.sprintf "tcp://*:%d" (localport+2) in - let f () = - new_thread REQ addr_in addr_out + let f () = + new_thread_req addr_in addr_out in (Thread.create f) () in @@ -227,8 +254,8 @@ let () = Printf.sprintf "tcp://*:%d" (localport+1) in - let f () = - new_thread SUB addr_in addr_out + let f () = + new_thread_sub addr_in addr_out in (Thread.create f) () in @@ -236,7 +263,7 @@ let () = let input_thread = - let f () = + let f () = let addr_out = match arg with | EZFIO _ -> None @@ -248,22 +275,22 @@ let () = Printf.sprintf "tcp://*:%d" (localport+9) in - let socket_in = + let socket_in = create_socket Zmq.Socket.rep Zmq.Socket.bind addr_in in let socket_out = - match addr_out with + match addr_out with | Some addr_out -> Some ( create_socket Zmq.Socket.req Zmq.Socket.connect addr_out) | None -> None in - let temp_file = + let temp_file = Filename.temp_file "qp_tunnel" ".tar.gz" in - let get_ezfio_filename () = + let get_ezfio_filename () = match arg with | EZFIO x -> x | ADDRESS _ -> @@ -277,9 +304,9 @@ let () = end in - let get_input () = + let get_input () = match arg with - | EZFIO x -> + | EZFIO x -> begin Printf.sprintf "tar --exclude=\"*.gz.*\" -zcf %s %s" temp_file x |> Sys.command |> ignore; @@ -291,11 +318,11 @@ let () = in ignore @@ Unix.lseek fd 0 Unix.SEEK_SET ; let bstr = - Unix.map_file fd Bigarray.char + Unix.map_file fd Bigarray.char Bigarray.c_layout false [| len |] |> Bigarray.array1_of_genarray in - let result = + let result = String.init len (fun i -> bstr.{i}) ; in Unix.close fd; @@ -313,7 +340,7 @@ let () = end in - let () = + let () = match socket_out with | None -> () | Some socket_out -> @@ -329,7 +356,7 @@ let () = | ADDRESS _ -> begin Printf.printf "Getting input... %!"; - let ezfio_filename = + let ezfio_filename = get_ezfio_filename () in Printf.printf "%s%!" ezfio_filename; @@ -343,7 +370,7 @@ let () = |> Sys.command |> ignore ; let oc = Filename.concat (Qpackage.ezfio_work ezfio_filename) "qp_run_address" - |> open_out + |> open_out in Printf.fprintf oc "tcp://%s:%d\n" localhost localport; close_out oc; @@ -359,9 +386,9 @@ let () = let action () = match Zmq.Socket.recv socket_in with | "get_input" -> get_input () - |> Zmq.Socket.send socket_in + |> Zmq.Socket.send socket_in | "get_ezfio_filename" -> get_ezfio_filename () - |> Zmq.Socket.send socket_in + |> Zmq.Socket.send socket_in | "test" -> Zmq.Socket.send socket_in "OK" | x -> Printf.sprintf "Message '%s' not understood" x |> Zmq.Socket.send socket_in @@ -372,7 +399,7 @@ On remote hosts, create ssh tunnel using: ssh -L %d:%s:%d -L %d:%s:%d -L %d:%s:%d -L %d:%s:%d %s & Or from this host connect to clients using: ssh -R %d:localhost:%d -R %d:localhost:%d -R %d:localhost:%d -R %d:localhost:%d & -%!" +%!" (port ) localhost (localport ) (port+1) localhost (localport+1) (port+2) localhost (localport+2) @@ -392,12 +419,12 @@ Or from this host connect to clients using: match polling.(0) with | Some Zmq.Poll.In -> action () | None -> () - | Some Zmq.Poll.In_out + | Some Zmq.Poll.In_out | Some Zmq.Poll.Out -> () done; - let () = + let () = match socket_out with | Some socket_out -> Zmq.Socket.close socket_out | None -> () @@ -415,7 +442,7 @@ Or from this host connect to clients using: Thread.join ocaml_thread; Zmq.Context.terminate zmq_context; Printf.printf "qp_tunnel exited properly.\n" - + diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 871de780..600217de 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -37,48 +37,48 @@ function run_stoch() { qp set_file b2_stretched.ezfio qp set determinants n_det_max 10000 qp set_frozen_core - run_stoch -49.14104086 0.0001 10000 + run_stoch -49.14097596 0.0001 10000 } @test "NH3" { # 0:00:11 qp set_file nh3.ezfio qp set_mo_class --core="[1-4]" --act="[5-72]" - run -56.24474790 1.e-5 10000 + run -56.24474908 1.e-5 10000 } @test "DHNO" { # 0:00:10 qp set_file dhno.ezfio qp set_mo_class --core="[1-7]" --act="[8-64]" - run -130.45901042 1.e-4 10000 + run -130.45904647 1.e-4 10000 } @test "HCO" { # 0:01:16 qp set_file hco.ezfio - run_stoch -113.41658256 2.e-3 50000 + run_stoch -113.41448940 2.e-3 50000 } @test "H2O2" { # 0:01:48 qp set_file h2o2.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-38]" - run_stoch -151.02317880 2.e-3 100000 + run_stoch -151.02437936 2.e-3 100000 } @test "HBO" { # 0:00:46 [[ -n $TRAVIS ]] && skip qp set_file hbo.ezfio - run_stoch -100.22361288 2.e-3 50000 + run_stoch -100.221198108988 2.e-3 50000 } @test "H2O" { # 0:01:05 [[ -n $TRAVIS ]] && skip qp set_file h2o.ezfio - run_stoch -76.24347962 1.e-4 100000 + run_stoch -76.241332121813 1.e-3 100000 } @test "ClO" { # 0:03:07 [[ -n $TRAVIS ]] && skip qp set_file clo.ezfio - run_stoch -534.58202840 1.e-3 100000 + run_stoch -534.573564655419 1.e-3 100000 } @test "SO" { # 0:01:49 diff --git a/src/iterations/print_extrapolation.irp.f b/src/iterations/print_extrapolation.irp.f index 7f602ffb..7c6dbb9b 100644 --- a/src/iterations/print_extrapolation.irp.f +++ b/src/iterations/print_extrapolation.irp.f @@ -41,7 +41,7 @@ subroutine print_extrapolated_energy enddo print *, '' - call ezfio_set_fci_energy_extrapolated(extrapolated_energy(2,1:N_states)) + call ezfio_set_fci_energy_extrapolated(extrapolated_energy(min(N_iter,3),1:N_states)) end subroutine diff --git a/tests/bats/common.bats.sh b/tests/bats/common.bats.sh index f6ea4023..802c0232 100644 --- a/tests/bats/common.bats.sh +++ b/tests/bats/common.bats.sh @@ -46,7 +46,7 @@ function test_exe() { run_only_test() { if [[ "$BATS_TEST_DESCRIPTION" != "$1" ]] && [[ "$BATS_TEST_NUMBER" != "$1" ]]; then - if [[ -z $BATS_TEST_FILENAME ]] ; then + if [[ -z "$BATS_TEST_FILENAME" ]] ; then exit 0 else skip From cea413b00a775bb08cafd33621a63f839432935e Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 8 Jun 2022 17:44:53 +0200 Subject: [PATCH 77/79] 3-point extrapolation in tests --- src/fci/40.fci.bats | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/fci/40.fci.bats b/src/fci/40.fci.bats index 600217de..ac34251f 100644 --- a/src/fci/40.fci.bats +++ b/src/fci/40.fci.bats @@ -90,99 +90,99 @@ function run_stoch() { @test "H2S" { # 0:01:12 [[ -n $TRAVIS ]] && skip qp set_file h2s.ezfio - run_stoch -398.87187312 1.e-3 50000 + run_stoch -398.865173546866 1.e-3 50000 } @test "OH" { # 0:00:41 [[ -n $TRAVIS ]] && skip qp set_file oh.ezfio - run_stoch -75.62393829 1.e-3 50000 + run_stoch -75.6193013819546 1.e-3 50000 } @test "SiH2_3B1" { # 0:00:50 [[ -n $TRAVIS ]] && skip qp set_file sih2_3b1.ezfio - run_stoch -290.02083172 3.e-5 50000 + run_stoch -290.01754869 3.e-5 50000 } @test "H3COH" { # 0:01:05 [[ -n $TRAVIS ]] && skip qp set_file h3coh.ezfio - run_stoch -115.22625460 2.e-3 50000 + run_stoch -115.224147057725 2.e-3 50000 } @test "SiH3" { # 0:01:09 [[ -n $TRAVIS ]] && skip qp set_file sih3.ezfio - run_stoch -5.57818759 1.e-3 50000 + run_stoch -5.57812512359276 1.e-3 50000 } @test "CH4" { # 0:02:06 [[ -n $TRAVIS ]] && skip qp set_file ch4.ezfio qp set_mo_class --core="[1]" --act="[2-30]" --del="[31-59]" - run_stoch -40.24195947 1.e-4 100000 + run_stoch -40.2419474611994 1.e-4 100000 } @test "ClF" { # 0:01:55 [[ -n $TRAVIS ]] && skip qp set_file clf.ezfio - run_stoch -559.20157348 1.e-3 50000 + run_stoch -559.20666465 1.e-2 50000 } @test "SO2" { # 0:00:24 [[ -n $TRAVIS ]] && skip qp set_file so2.ezfio qp set_mo_class --core="[1-8]" --act="[9-87]" - run_stoch -41.57468087 1.e-4 50000 + run_stoch -41.57468756 1.e-4 50000 } @test "C2H2" { # 0:00:57 [[ -n $TRAVIS ]] && skip qp set_file c2h2.ezfio qp set_mo_class --act="[1-30]" --del="[31-36]" - run_stoch -12.38655876 1.e-3 50000 + run_stoch -12.3862664765532 1.e-3 50000 } @test "N2" { # 0:01:15 [[ -n $TRAVIS ]] && skip qp set_file n2.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-60]" - run_stoch -109.31133266 2.e-3 50000 + run_stoch -109.311954243348 2.e-3 50000 } @test "N2H4" { # 0:00:51 [[ -n $TRAVIS ]] && skip qp set_file n2h4.ezfio qp set_mo_class --core="[1-2]" --act="[3-24]" --del="[25-48]" - run_stoch -111.38161063 1.e-3 50000 + run_stoch -111.38119165053 1.e-3 50000 } @test "CO2" { # 0:01:00 [[ -n $TRAVIS ]] && skip qp set_file co2.ezfio qp set_mo_class --core="[1,2]" --act="[3-30]" --del="[31-42]" - run_stoch -188.00154729 2.e-3 50000 + run_stoch -188.002190327443 2.e-3 50000 } @test "[Cu(NH3)4]2+" { # 0:01:53 [[ -n $TRAVIS ]] && skip qp set_file cu_nh3_4_2plus.ezfio qp set_mo_class --core="[1-24]" --act="[25-45]" --del="[46-87]" - run_stoch -1862.98705091 1.e-05 50000 + run_stoch -1862.98705340328 1.e-05 50000 } @test "HCN" { # 0:01:26 [[ -n $TRAVIS ]] && skip qp set_file hcn.ezfio qp set_mo_class --core="[1,2]" --act="[3-40]" --del="[41-55]" - run_stoch -93.09855896 5.e-4 50000 + run_stoch -93.0980746734051 5.e-4 50000 } @test "F2" { # 0:03:34 [[ -n $TRAVIS ]] && skip qp set_file f2.ezfio qp set_frozen_core - run_stoch -199.30821487 0.002 100000 + run_stoch -199.307512211742 0.002 100000 } From 389db7b4cb4532793733d141339bf9dc1322e31c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 10 Jun 2022 12:11:08 +0200 Subject: [PATCH 78/79] Fixed max memory detection --- external/qp2-dependencies | 2 +- src/mo_two_e_ints/mo_bi_integrals.irp.f | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/external/qp2-dependencies b/external/qp2-dependencies index 242151e0..bc856147 160000 --- a/external/qp2-dependencies +++ b/external/qp2-dependencies @@ -1 +1 @@ -Subproject commit 242151e03d1d6bf042387226431d82d35845686a +Subproject commit bc856147f6e626a6616b20344e5b8e3f30f44a92 diff --git a/src/mo_two_e_ints/mo_bi_integrals.irp.f b/src/mo_two_e_ints/mo_bi_integrals.irp.f index c03b363d..6f4c5c17 100644 --- a/src/mo_two_e_ints/mo_bi_integrals.irp.f +++ b/src/mo_two_e_ints/mo_bi_integrals.irp.f @@ -53,7 +53,7 @@ BEGIN_PROVIDER [ logical, mo_two_e_integrals_in_map ] ! call four_idx_novvvv call four_idx_novvvv_old else - if (ao_num*ao_num*ao_num*ao_num*32.d-9 < dble(qp_max_mem)) then + if (32.d-9*dble(ao_num)**4 < dble(qp_max_mem)) then call four_idx_dgemm else call add_integrals_to_map(full_ijkl_bitmask_4) @@ -130,7 +130,6 @@ subroutine four_idx_dgemm real(integral_kind), allocatable :: buffer_value(:) size_buffer = min(ao_num*ao_num*ao_num,16000000) - print *, 'Storing' !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i,j,k,l,buffer_value,buffer_i,n_integrals) allocate ( buffer_i(size_buffer), buffer_value(size_buffer) ) @@ -164,7 +163,6 @@ subroutine four_idx_dgemm deallocate (a1) - print *, 'Unique' call map_unique(mo_integrals_map) integer*8 :: get_mo_map_size, mo_map_size From 31572fddc3b8de11008e214e29b602d9f0ff5c8d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 10 Jun 2022 14:28:37 +0200 Subject: [PATCH 79/79] Prepared CFG H.Psi for Vijay --- src/davidson/diagonalize_ci.irp.f | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/davidson/diagonalize_ci.irp.f b/src/davidson/diagonalize_ci.irp.f index 46ad8f78..6930cc07 100644 --- a/src/davidson/diagonalize_ci.irp.f +++ b/src/davidson/diagonalize_ci.irp.f @@ -1,3 +1,13 @@ +BEGIN_PROVIDER [ character*(3), sigma_vector_algorithm ] + implicit none + BEGIN_DOC + ! If 'det', use in Davidson + ! + ! If 'cfg', use in Davidson + END_DOC + sigma_vector_algorithm = 'det' +END_PROVIDER + BEGIN_PROVIDER [ double precision, CI_energy, (N_states_diag) ] implicit none BEGIN_DOC @@ -61,9 +71,18 @@ END_PROVIDER if (diag_algorithm == "Davidson") then if (do_csf) then - call davidson_diag_H_csf(psi_det,CI_eigenvectors, & - size(CI_eigenvectors,1),CI_electronic_energy, & - N_det,N_csf,min(N_det,N_states),min(N_det,N_states_diag),N_int,0,converged) + if (sigma_vector_algorithm == 'det') then + call davidson_diag_H_csf(psi_det,CI_eigenvectors, & + size(CI_eigenvectors,1),CI_electronic_energy, & + N_det,N_csf,min(N_det,N_states),min(N_det,N_states_diag),N_int,0,converged) +! else if (sigma_vector_algorithm == 'cfg') then +! call davidson_diag_H_csf(psi_det,CI_eigenvectors, & +! size(CI_eigenvectors,1),CI_electronic_energy, & +! N_det,N_csf,min(N_det,N_states),min(N_det,N_states_diag),N_int,0,converged) +! else +! print *, irp_here +! stop 'bug' + endif else call davidson_diag_HS2(psi_det,CI_eigenvectors, CI_s2, & size(CI_eigenvectors,1),CI_electronic_energy, &