BSE/RI-RPA: improve abort messages and fix bug for ERI_METHOD OS

This commit is contained in:
Max Graml 2025-01-31 11:18:35 +01:00 committed by GitHub
parent 0974da54a8
commit 59ebee199f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 45 additions and 15 deletions

View file

@ -475,7 +475,12 @@ CONTAINS
ALLOCATE (Exc_ens(homo*virtual))
CALL choose_eigv_solver(fm_C, fm_eigvec_Z, Exc_ens, diag_info)
CPASSERT(diag_info == 0)
IF (diag_info /= 0) THEN
CALL cp_abort(__LOCATION__, &
"Diagonalization of C=(A-B)^0.5 (A+B) (A-B)^0.5 failed in BSE")
END IF
! C could have negative eigenvalues, since we do not explicitly check A+B
! for positive definiteness (would make another O(N^6) Diagon. necessary)
! Instead, we include a check here
@ -589,7 +594,12 @@ CONTAINS
ALLOCATE (Exc_ens(homo*virtual))
CALL choose_eigv_solver(fm_A, fm_eigvec, Exc_ens, diag_info)
CPASSERT(diag_info == 0)
IF (diag_info /= 0) THEN
CALL cp_abort(__LOCATION__, &
"Diagonalization of A failed in TDA-BSE")
END IF
CALL postprocess_bse(Exc_ens, fm_eigvec, mp2_env, qs_env, mo_coeff, &
homo, virtual, homo_irred, unit_nr, .TRUE.)

View file

@ -154,7 +154,9 @@ CONTAINS
! calculate Trace(Log(Matrix)) as Log(DET(Matrix)) via cholesky decomposition
CALL cp_fm_cholesky_decompose(matrix=fm_mat_Q_static_bse_gemm, n=dimen_RI, info_out=info_chol)
CPASSERT(info_chol == 0)
IF (info_chol /= 0) THEN
CALL cp_abort(__LOCATION__, 'Cholesky decomposition failed for static polarization in BSE')
END IF
! calculate [1+Q(i0)]^-1
CALL cp_fm_cholesky_invert(fm_mat_Q_static_bse_gemm)
@ -1542,7 +1544,7 @@ CONTAINS
mp2_env%bse%num_print_exc > homo*virtual) THEN
mp2_env%bse%num_print_exc = homo*virtual
IF (unit_nr > 0) THEN
CALL cp_warn(__LOCATION__, &
CALL cp_hint(__LOCATION__, &
"Keyword NUM_PRINT_EXC is either negative or too large. "// &
"Printing all computed excitations.")
END IF
@ -1558,7 +1560,7 @@ CONTAINS
IF (mp2_env%bse%explicit_nto_list) THEN
IF (mp2_env%bse%num_print_exc_ntos > 0) THEN
IF (unit_nr > 0) THEN
CALL cp_warn(__LOCATION__, &
CALL cp_hint(__LOCATION__, &
"Keywords NUM_PRINT_EXC_NTOS and STATE_LIST are both given in input. "// &
"Overriding NUM_PRINT_EXC_NTOS.")
END IF
@ -1574,7 +1576,7 @@ CONTAINS
END DO
IF (num_state_list_exceptions > 0) THEN
IF (unit_nr > 0) THEN
CALL cp_warn(__LOCATION__, &
CALL cp_hint(__LOCATION__, &
"STATE_LIST contains indices outside the range of included excitation levels. "// &
"Ignoring these states.")
END IF
@ -1619,7 +1621,7 @@ CONTAINS
IF (mp2_env%bse%num_print_exc_descr < 0 .OR. &
mp2_env%bse%num_print_exc_descr > mp2_env%bse%num_print_exc) THEN
IF (unit_nr > 0) THEN
CALL cp_warn(__LOCATION__, &
CALL cp_hint(__LOCATION__, &
"Keyword NUM_PRINT_EXC_DESCR is either negative or too large. "// &
"Printing exciton descriptors up to NUM_PRINT_EXC.")
END IF

View file

@ -362,7 +362,10 @@ CONTAINS
DO ikind = 1, n_kind
CALL get_qs_kind(qs_kind=qs_kind_set(ikind), basis_set=basis_set_a, &
basis_type="RI_AUX")
CPASSERT(ASSOCIATED(basis_set_a))
IF (.NOT. ASSOCIATED(basis_set_a)) THEN
CALL cp_abort(__LOCATION__, &
"At least one RI_AUX basis set was not explicitly invoked in &KIND-section.")
END IF
END DO
ALLOCATE (bs_env%i_RI_start_from_atom(n_atom))

View file

@ -1320,11 +1320,9 @@ CONTAINS
! in the RI basis, there is only a single primitive Gaussian
kpgf = 1
IF (lc_max == 0) THEN
nc_start = 1
ELSE
nc_start = ncoset(lc_max - 1) + 1
END IF
! ncoset is indexed by -1,..., ,5
! e.g. for pure s: lc_min = lc_max = 0, nc_start = 1
nc_start = ncoset(lc_min - 1) + 1
nc_end = ncoset(lc_max)
CALL coulomb3(la_max, npgfa, zeta(:), rpgfa(:), la_min, &

View file

@ -334,8 +334,12 @@ CONTAINS
END IF
IF (do_bse) THEN
CPASSERT(my_do_gw)
CPASSERT(.NOT. do_im_time)
IF (.NOT. my_do_gw) THEN
CALL cp_abort(__LOCATION__, "BSE calculations require prior GW calculations.")
END IF
IF (do_im_time) THEN
CALL cp_abort(__LOCATION__, "BSE calculations are not implemented for low-scaling GW.")
END IF
! GPW integrals have to be implemented later
IF (eri_method == do_eri_gpw) THEN
CALL cp_abort(__LOCATION__, &
@ -539,6 +543,15 @@ CONTAINS
(ri_metric%potential_type == do_potential_coulomb .OR. ri_metric%potential_type == do_potential_long) .OR. &
eri_method == do_eri_os .AND. ri_metric%potential_type == do_potential_coulomb) THEN
! Add a warning for automatically generated RI_AUX basis sets
! Tend to be not sufficiently converged
IF (qs_env%mp2_env%ri_aux_auto_generated) THEN
CALL cp_warn(__LOCATION__, &
"At least one RI_AUX basis set was not explicitly invoked in &KIND-section. "// &
"Automatically RI-basis sets and ERI_METHOD OS tend to be not converged. "// &
"Consider specifying BASIS_SET RI_AUX explicitly with a sufficiently large basis.")
END IF
NULLIFY (mat_munu_local_L)
ALLOCATE (mat_munu_local_L(my_group_L_size))
DO LLL = 1, my_group_L_size

View file

@ -403,6 +403,7 @@ MODULE mp2_types
TYPE(local_gemm_ctxt_type) :: local_gemm_ctx = local_gemm_ctxt_type()
REAL(dp) :: e_gap = 0.0_dp, &
e_range = 0.0_dp
LOGICAL :: ri_aux_auto_generated = .FALSE.
END TYPE mp2_type
TYPE integ_mat_buffer_type

View file

@ -1011,6 +1011,9 @@ CONTAINS
! Generate a default basis
CALL create_ri_aux_basis_set(ri_aux_basis_set, qs_kind, dft_control%auto_basis_ri_aux, basis_sort=sort_basis)
CALL add_basis_set_to_container(qs_kind%basis_sets, ri_aux_basis_set, "RI_AUX")
! Add a flag, which allows to check if the basis was generated
! when applying ERI_METHOD OS to mp2, ri-rpa, gw etc
qs_env%mp2_env%ri_aux_auto_generated = .TRUE.
END IF
END DO
END IF