From 09f6d338e88dfc66ecb598f1c719322c6ca3ca22 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 20 Jan 2025 17:56:13 +0100 Subject: [PATCH] provide all_mo_integrals --- src/davidson/diagonalization_h_dressed.irp.f | 2 +- .../diagonalization_hcsf_dressed.irp.f | 2 +- .../diagonalization_hs2_dressed.irp.f | 2 +- .../diagonalization_nonsym_h_dressed.irp.f | 2 +- src/determinants/h_apply_nozmq.template.f | 2 +- src/determinants/slater_rules.irp.f | 12 ++++----- src/determinants/slater_rules_wee_mono.irp.f | 4 +-- src/determinants/utils.irp.f | 9 +++---- src/mo_two_e_ints/map_integrals.irp.f | 25 ++++++++++++++----- 9 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/davidson/diagonalization_h_dressed.irp.f b/src/davidson/diagonalization_h_dressed.irp.f index 15bf256d..a7e501ea 100644 --- a/src/davidson/diagonalization_h_dressed.irp.f +++ b/src/davidson/diagonalization_h_dressed.irp.f @@ -31,7 +31,7 @@ subroutine davidson_diag_h(dets_in,u_in,dim_in,energies,sze,N_st,N_st_diag,Nint, ASSERT (sze > 0) ASSERT (Nint > 0) ASSERT (Nint == N_int) - PROVIDE mo_two_e_integrals_in_map + PROVIDE all_mo_integrals allocate(H_jj(sze)) H_jj(1) = diag_h_mat_elem(dets_in(1,1,1),Nint) diff --git a/src/davidson/diagonalization_hcsf_dressed.irp.f b/src/davidson/diagonalization_hcsf_dressed.irp.f index 656dd1d9..1fb24e08 100644 --- a/src/davidson/diagonalization_hcsf_dressed.irp.f +++ b/src/davidson/diagonalization_hcsf_dressed.irp.f @@ -30,7 +30,7 @@ subroutine davidson_diag_h_csf(dets_in,u_in,dim_in,energies,sze,sze_csf,N_st,N_s ASSERT (sze > 0) ASSERT (Nint > 0) ASSERT (Nint == N_int) - PROVIDE mo_two_e_integrals_in_map + PROVIDE all_mo_integrals allocate(H_jj(sze)) H_jj(1) = diag_h_mat_elem(dets_in(1,1,1),Nint) diff --git a/src/davidson/diagonalization_hs2_dressed.irp.f b/src/davidson/diagonalization_hs2_dressed.irp.f index d299f982..ce2cb63f 100644 --- a/src/davidson/diagonalization_hs2_dressed.irp.f +++ b/src/davidson/diagonalization_hs2_dressed.irp.f @@ -62,7 +62,7 @@ subroutine davidson_diag_hs2(dets_in,u_in,s2_out,dim_in,energies,sze,N_st,N_st_d ASSERT (sze > 0) ASSERT (Nint > 0) ASSERT (Nint == N_int) - PROVIDE mo_two_e_integrals_in_map + PROVIDE all_mo_integrals allocate(H_jj(sze)) H_jj(1) = diag_h_mat_elem(dets_in(1,1,1),Nint) diff --git a/src/davidson/diagonalization_nonsym_h_dressed.irp.f b/src/davidson/diagonalization_nonsym_h_dressed.irp.f index 86df3a19..3ac37f1d 100644 --- a/src/davidson/diagonalization_nonsym_h_dressed.irp.f +++ b/src/davidson/diagonalization_nonsym_h_dressed.irp.f @@ -42,7 +42,7 @@ subroutine davidson_diag_nonsym_h(dets_in, u_in, dim_in, energies, sze, N_st, N_ ASSERT (sze > 0) ASSERT (Nint > 0) ASSERT (Nint == N_int) - PROVIDE mo_two_e_integrals_in_map + PROVIDE all_mo_integrals allocate(H_jj(sze)) diff --git a/src/determinants/h_apply_nozmq.template.f b/src/determinants/h_apply_nozmq.template.f index bd261bbe..3463a818 100644 --- a/src/determinants/h_apply_nozmq.template.f +++ b/src/determinants/h_apply_nozmq.template.f @@ -17,7 +17,7 @@ subroutine $subroutine($params_main) double precision, allocatable :: fock_diag_tmp(:,:) $initialization - PROVIDE H_apply_buffer_allocated mo_two_e_integrals_in_map psi_det_generators psi_coef_generators + PROVIDE H_apply_buffer_allocated all_mo_integrals psi_det_generators psi_coef_generators call wall_time(wall_0) diff --git a/src/determinants/slater_rules.irp.f b/src/determinants/slater_rules.irp.f index 3a33a37d..5c170b9e 100644 --- a/src/determinants/slater_rules.irp.f +++ b/src/determinants/slater_rules.irp.f @@ -521,7 +521,7 @@ subroutine i_H_j_s2(key_i,key_j,Nint,hij,s2) 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 all_mo_integrals ASSERT (Nint > 0) ASSERT (Nint == N_int) @@ -623,7 +623,7 @@ 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 all_mo_integrals ASSERT (Nint > 0) ASSERT (Nint == N_int) @@ -724,7 +724,7 @@ subroutine i_H_j_verbose(key_i,key_j,Nint,hij,hmono,hdouble,phase) integer :: n_occ_ab(2) logical :: has_mipi(Nint*bit_kind_size) double precision :: mipi(Nint*bit_kind_size), miip(Nint*bit_kind_size) - PROVIDE mo_two_e_integrals_in_map mo_integrals_map + PROVIDE all_mo_integrals ASSERT (Nint > 0) ASSERT (Nint == N_int) @@ -2227,7 +2227,7 @@ subroutine i_H_j_single_spin(key_i,key_j,Nint,spin,hij) integer :: exc(0:2,2) double precision :: phase - PROVIDE big_array_exchange_integrals mo_two_e_integrals_in_map + PROVIDE all_mo_integrals call get_single_excitation_spin(key_i(1,spin),key_j(1,spin),exc,phase,Nint) call get_single_excitation_from_fock(key_i,key_j,exc(1,1),exc(1,2),spin,phase,hij) @@ -2248,7 +2248,7 @@ subroutine i_H_j_double_spin(key_i,key_j,Nint,hij) double precision :: phase double precision, external :: get_two_e_integral - PROVIDE big_array_exchange_integrals mo_two_e_integrals_in_map + PROVIDE all_mo_integrals call get_double_excitation_spin(key_i,key_j,exc,phase,Nint) hij = phase*(get_two_e_integral( & exc(1,1), & @@ -2277,7 +2277,7 @@ subroutine i_H_j_double_alpha_beta(key_i,key_j,Nint,hij) double precision :: phase, phase2 double precision, external :: get_two_e_integral - PROVIDE big_array_exchange_integrals mo_two_e_integrals_in_map + PROVIDE all_mo_integrals call get_single_excitation_spin(key_i(1,1),key_j(1,1),exc(0,1,1),phase,Nint) call get_single_excitation_spin(key_i(1,2),key_j(1,2),exc(0,1,2),phase2,Nint) diff --git a/src/determinants/slater_rules_wee_mono.irp.f b/src/determinants/slater_rules_wee_mono.irp.f index 4c1c9330..b94927e3 100644 --- a/src/determinants/slater_rules_wee_mono.irp.f +++ b/src/determinants/slater_rules_wee_mono.irp.f @@ -13,7 +13,7 @@ subroutine i_Wee_j_single(key_i,key_j,Nint,spin,hij) integer :: exc(0:2,2) double precision :: phase - PROVIDE big_array_exchange_integrals mo_two_e_integrals_in_map + PROVIDE all_mo_integrals call get_single_excitation_spin(key_i(1,spin),key_j(1,spin),exc,phase,Nint) call single_excitation_wee(key_i,key_j,exc(1,1),exc(1,2),spin,phase,hij) @@ -285,7 +285,7 @@ subroutine i_H_j_two_e(key_i,key_j,Nint,hij) 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 + PROVIDE all_mo_integrals ref_bitmask_two_e_energy ASSERT (Nint > 0) ASSERT (Nint == N_int) diff --git a/src/determinants/utils.irp.f b/src/determinants/utils.irp.f index 7b75d985..07a6334b 100644 --- a/src/determinants/utils.irp.f +++ b/src/determinants/utils.irp.f @@ -4,12 +4,11 @@ BEGIN_PROVIDER [ double precision, H_matrix_all_dets,(N_det,N_det) ] BEGIN_DOC ! |H| matrix on the basis of the Slater determinants defined by psi_det END_DOC - integer :: i,j,k + integer :: i,j double precision :: hij - integer :: degree(N_det),idx(0:N_det) - call i_H_j(psi_det(1,1,1),psi_det(1,1,1),N_int,hij) + PROVIDE all_mo_integrals print*,'Providing the H_matrix_all_dets ...' - !$OMP PARALLEL DO SCHEDULE(GUIDED) DEFAULT(NONE) PRIVATE(i,j,hij,degree,idx,k) & + !$OMP PARALLEL DO SCHEDULE(GUIDED) DEFAULT(NONE) PRIVATE(i,j,hij) & !$OMP SHARED (N_det, psi_det, N_int,H_matrix_all_dets) do i =1,N_det do j = i, N_det @@ -31,7 +30,7 @@ BEGIN_PROVIDER [ double precision, H_matrix_diag_all_dets,(N_det) ] integer :: i double precision :: hij integer :: degree(N_det) - call i_H_j(psi_det(1,1,1),psi_det(1,1,1),N_int,hij) + PROVIDE all_mo_integrals !$OMP PARALLEL DO SCHEDULE(GUIDED) DEFAULT(NONE) PRIVATE(i,hij,degree) & !$OMP SHARED (N_det, psi_det, N_int,H_matrix_diag_all_dets) do i =1,N_det diff --git a/src/mo_two_e_ints/map_integrals.irp.f b/src/mo_two_e_ints/map_integrals.irp.f index eeb4279f..e6b2967a 100644 --- a/src/mo_two_e_ints/map_integrals.irp.f +++ b/src/mo_two_e_ints/map_integrals.irp.f @@ -1,5 +1,15 @@ use map_module +BEGIN_PROVIDER [ logical, all_mo_integrals ] + implicit none + BEGIN_DOC +! Used to provide everything needed before using MO integrals +! PROVIDE all_mo_integrals + END_DOC + PROVIDE mo_two_e_integrals_in_map mo_integrals_cache mo_two_e_integrals_jj_exchange mo_two_e_integrals_jj_anti mo_two_e_integrals_jj big_array_exchange_integrals big_array_coulomb_integrals +END_PROVIDER + + !! MO Map !! ====== @@ -35,20 +45,24 @@ end BEGIN_PROVIDER [ integer, mo_integrals_cache_min ] &BEGIN_PROVIDER [ integer, mo_integrals_cache_max ] &BEGIN_PROVIDER [ integer, mo_integrals_cache_size ] +&BEGIN_PROVIDER [ integer*8, mo_integrals_cache_size_8 ] implicit none BEGIN_DOC ! Min and max values of the MOs for which the integrals are in the cache END_DOC - mo_integrals_cache_size = 2**mo_integrals_cache_shift + mo_integrals_cache_size = shiftl(1,mo_integrals_cache_shift) + mo_integrals_cache_size_8 = shiftl(1_8, mo_integrals_cache_shift*4) + mo_integrals_cache_min = max(1,elec_alpha_num - (mo_integrals_cache_size/2 - 1) ) mo_integrals_cache_max = min(mo_num, mo_integrals_cache_min + mo_integrals_cache_size - 1) - print *, 'MO integrals cache: (', mo_integrals_cache_min, ', ', mo_integrals_cache_max, ')' + print *, 'MO integrals cache: (', mo_integrals_cache_min, ', ', mo_integrals_cache_max, '), ', & + shiftr(mo_integrals_cache_size_8, 17), 'MiB' END_PROVIDER -BEGIN_PROVIDER [ double precision, mo_integrals_cache, (0_8:(1_8*mo_integrals_cache_size)**4) ] +BEGIN_PROVIDER [ double precision, mo_integrals_cache, (0_8:mo_integrals_cache_size_8**4_8) ] implicit none BEGIN_DOC ! Cache of MO integrals for fast access @@ -67,8 +81,7 @@ BEGIN_PROVIDER [ double precision, mo_integrals_cache, (0_8:(1_8*mo_integrals_ca do k=mo_integrals_cache_min,mo_integrals_cache_max ii = int(l-mo_integrals_cache_min,8) ii = ior( shiftl(ii,mo_integrals_cache_shift), int(k-mo_integrals_cache_min,8)) - ii = shiftl(ii,mo_integrals_cache_shift) - ii = shiftl(ii,mo_integrals_cache_shift) + ii = shiftl(ii,2*mo_integrals_cache_shift) call dgemm('T','N', mo_integrals_cache_max-mo_integrals_cache_min+1, & mo_integrals_cache_max-mo_integrals_cache_min+1, & cholesky_mo_num, 1.d0, & @@ -328,7 +341,7 @@ double precision function mo_two_e_integral(i,j,k,l) END_DOC integer, intent(in) :: i,j,k,l double precision :: get_two_e_integral - PROVIDE mo_two_e_integrals_in_map mo_integrals_cache + PROVIDE all_mo_integrals !DIR$ FORCEINLINE mo_two_e_integral = get_two_e_integral(i,j,k,l,mo_integrals_map) return