Skip to content

Commit

Permalink
periodic GW: RI with truncated Coulomb metric and memory reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
JWilhelm committed Jan 8, 2023
1 parent 523d85c commit ebdeb28
Show file tree
Hide file tree
Showing 15 changed files with 926 additions and 884 deletions.
59 changes: 27 additions & 32 deletions src/input_cp2k_mp2.F
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ MODULE input_cp2k_mp2
USE input_constants, ONLY: &
do_eri_gpw, do_eri_mme, do_eri_os, do_potential_coulomb, do_potential_id, &
do_potential_long, do_potential_mix_cl, do_potential_short, do_potential_truncated, &
do_potential_tshpsc, eri_default, gaussian, gw_gf_gamma, gw_gf_mic, gw_no_print_exx, &
gw_pade_approx, gw_print_exx, gw_read_exx, gw_skip_for_regtest, gw_two_pole_model, &
kp_weights_W_auto, kp_weights_W_tailored, kp_weights_W_uniform, mp2_method_direct, &
mp2_method_gpw, mp2_method_none, numerical, ot_precond_full_all, ot_precond_full_kinetic, &
do_potential_tshpsc, eri_default, gaussian, gw_no_print_exx, gw_pade_approx, gw_print_exx, &
gw_read_exx, gw_skip_for_regtest, gw_two_pole_model, kp_weights_W_auto, &
kp_weights_W_tailored, kp_weights_W_uniform, mp2_method_direct, mp2_method_gpw, &
mp2_method_none, numerical, ot_precond_full_all, ot_precond_full_kinetic, &
ot_precond_full_single, ot_precond_full_single_inverse, ot_precond_none, &
ot_precond_s_inverse, ri_default, ri_rpa_g0w0_crossing_bisection, &
ri_rpa_g0w0_crossing_newton, ri_rpa_g0w0_crossing_z_shot, wfc_mm_style_gemm, &
Expand Down Expand Up @@ -1268,18 +1268,6 @@ SUBROUTINE create_low_scaling(section)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create( &
keyword, __LOCATION__, name="REL_CUTOFFS_CHI_W", &
description="For periodic calculations, the irreducible density reponse chi^0(r,r') and the screened "// &
"Coulomb interaction W(r,r') is truncated "// &
"in real space. No truncation of chi^0(r,r') and W(r,r') for |r-r'| < cutoff_1*(smallest lattice vector length), "// &
"chi^0(r,r') is set to zero for |r-r'| > cutoff_2*(smallest lattice vector length). Smooth transition "// &
"in between. For cutoff_1 = 0.5, and cutoff_2 = 0.5, we have the minimum image convention (that is also default).", &
usage="REL_CUTOFFS_CHI cutoff_1 cutoff_2", &
n_var=2, type_of_var=real_t, default_r_vals=(/0.5_dp, 0.5_dp/))
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create( &
keyword, __LOCATION__, &
name="REGULARIZATION_RI", &
Expand All @@ -1301,6 +1289,16 @@ SUBROUTINE create_low_scaling(section)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create( &
keyword, __LOCATION__, &
name="EPS_EIGVAL_S_GAMMA", &
description="Parameter to reduce the expansion coefficients in RI for periodic GW. Removes all "// &
"eigenvectors and eigenvalues of M_PQ(k=0) that are smaller than EPS_EIGVAL_S. ", &
usage="EPS_EIGVAL_S 1.0E-3", &
default_r_val=0.0_dp)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create( &
keyword, __LOCATION__, &
name="MAKE_CHI_POS_DEFINITE", &
Expand All @@ -1313,6 +1311,19 @@ SUBROUTINE create_low_scaling(section)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create( &
keyword, __LOCATION__, &
name="MAKE_OVERLAP_MAT_AO_POS_DEFINITE", &
description="If true, makes eigenvalue decomposition of S_mu,nu(k) and removes negative "// &
"eigenvalues. Slightly increases computational cost. Only recommended to try in case "// &
"Cholesky decomposition of S_mu,nu(k) fails (error message: Cholesky decompose failed: "// &
"matrix is not positive definite or ill-conditioned; when calling create_kp_and_calc_kp_orbitals).", &
usage="MAKE_OVERLAP_MAT_AO_POS_DEFINITE", &
default_l_val=.FALSE., &
lone_keyword_l_val=.TRUE.)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create( &
keyword, __LOCATION__, &
name="DO_EXTRAPOLATE_KPOINTS", &
Expand Down Expand Up @@ -1369,22 +1380,6 @@ SUBROUTINE create_low_scaling(section)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

NULLIFY (keyword)
CALL keyword_create( &
keyword, __LOCATION__, &
name="GREENS_FUNCTION", &
description="Decides which scheme is used for the periodic Green's function "// &
"(only relevant for periodic GW calculations)."// &
"Both schemes are exact in the limit of large unit cells.", &
usage="GREENS_FUNCTION GAMMA", &
enum_c_vals=s2a("GAMMA", "MIC"), &
enum_i_vals=(/gw_gf_gamma, gw_gf_mic/), &
enum_desc=s2a("Use the Green's functions at the Gamma point. ", &
"Use the minimum-image convention for the Green's function."), &
default_i_val=gw_gf_gamma)
CALL section_add_keyword(section, keyword)
CALL keyword_release(keyword)

CALL keyword_create( &
keyword, __LOCATION__, &
name="MIN_BLOCK_SIZE", &
Expand Down
21 changes: 13 additions & 8 deletions src/mp2_gpw.F
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
TYPE(cp_blacs_env_type), POINTER :: blacs_env_sub, blacs_env_sub_mat_munu
TYPE(cp_fm_type) :: fm_matrix_PQ
TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: mo_coeff
TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_matrix_L_RI_metric, &
fm_matrix_Sinv_Vtrunc_Sinv
TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_matrix_L_kpoints, fm_matrix_Minv, &
fm_matrix_Minv_L_kpoints, &
fm_matrix_Minv_Vtrunc_Minv
TYPE(cp_fm_type), POINTER :: mo_coeff_ptr
TYPE(cp_logger_type), POINTER :: logger, logger_sub
TYPE(cp_para_env_type), POINTER :: para_env_sub
Expand Down Expand Up @@ -381,8 +382,8 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
CALL mp2_ri_gpw_compute_in( &
BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd_array, gd_B_virtual, dimen_RI, dimen_RI_red, qs_env, &
para_env, para_env_sub, color_sub, cell, particle_set, &
atomic_kind_set, qs_kind_set, mo_coeff, fm_matrix_PQ, fm_matrix_L_RI_metric, fm_matrix_Sinv_Vtrunc_Sinv, &
nmo, homo, mat_munu, sab_orb_sub, &
atomic_kind_set, qs_kind_set, mo_coeff, fm_matrix_PQ, fm_matrix_L_kpoints, fm_matrix_Minv_L_kpoints, &
fm_matrix_Minv, fm_matrix_Minv_Vtrunc_Minv, nmo, homo, mat_munu, sab_orb_sub, &
mo_coeff_o, mo_coeff_v, mo_coeff_all, mo_coeff_gw, &
mp2_env%mp2_gpw%eps_filter, unit_nr, &
mp2_env%mp2_memory, mp2_env%calc_PQ_cond_num, calc_forces, blacs_env_sub, my_do_gw .AND. .NOT. do_im_time, &
Expand All @@ -398,7 +399,8 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
dimen_RI, dimen_RI_red, qs_env, para_env, para_env_sub, &
color_sub, cell, particle_set, &
atomic_kind_set, qs_kind_set, mo_coeff, fm_matrix_PQ, &
fm_matrix_L_RI_metric, fm_matrix_Sinv_Vtrunc_Sinv, nmo, homo, &
fm_matrix_L_kpoints, fm_matrix_Minv_L_kpoints, &
fm_matrix_Minv, fm_matrix_Minv_Vtrunc_Minv, nmo, homo, &
mat_munu, sab_orb_sub, &
mo_coeff_o, mo_coeff_v, mo_coeff_all, mo_coeff_gw, &
mp2_env%mp2_gpw%eps_filter, unit_nr, &
Expand Down Expand Up @@ -537,7 +539,8 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
CALL rpa_ri_compute_en(qs_env, Emp2, mp2_env, BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, &
para_env, para_env_sub, color_sub, &
gd_array, gd_B_virtual, gd_B_all, gd_B_occ_bse, gd_B_virt_bse, &
mo_coeff, fm_matrix_PQ, fm_matrix_L_RI_metric, fm_matrix_Sinv_Vtrunc_Sinv, kpoints, &
mo_coeff, fm_matrix_PQ, fm_matrix_L_kpoints, fm_matrix_Minv_L_kpoints, &
fm_matrix_Minv, fm_matrix_Minv_Vtrunc_Minv, kpoints, &
Eigenval, nmo, homo, dimen_RI, dimen_RI_red, gw_corr_lev_occ, gw_corr_lev_virt, &
unit_nr, my_do_ri_sos_laplace_mp2, my_do_gw, do_im_time, do_bse, matrix_s, &
mat_munu, mat_P_global, &
Expand All @@ -549,8 +552,10 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
CALL rse_energy(qs_env, mp2_env, para_env, dft_control, mo_coeff, nmo, homo, Eigenval)

IF (do_im_time) THEN
CALL dbcsr_release(mat_P_global%matrix)
DEALLOCATE (mat_P_global%matrix)
IF (ASSOCIATED(mat_P_global%matrix)) THEN
CALL dbcsr_release(mat_P_global%matrix)
DEALLOCATE (mat_P_global%matrix)
END IF

CALL cp_libint_static_cleanup()
IF (calc_forces) CALL cp_fm_release(fm_matrix_PQ)
Expand Down
19 changes: 12 additions & 7 deletions src/mp2_integrals.F
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ MODULE mp2_integrals
!> \param qs_kind_set ...
!> \param mo_coeff ...
!> \param fm_matrix_PQ ...
!> \param fm_matrix_L_RI_metric ...
!> \param fm_matrix_Sinv_Vtrunc_Sinv ...
!> \param fm_matrix_L_kpoints ...
!> \param fm_matrix_Minv_L_kpoints ...
!> \param fm_matrix_Minv ...
!> \param fm_matrix_Minv_Vtrunc_Minv ...
!> \param nmo ...
!> \param homo ...
!> \param mat_munu ...
Expand Down Expand Up @@ -185,7 +187,8 @@ MODULE mp2_integrals
SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd_array, gd_B_virtual, &
dimen_RI, dimen_RI_red, qs_env, para_env, para_env_sub, color_sub, &
cell, particle_set, atomic_kind_set, qs_kind_set, mo_coeff, &
fm_matrix_PQ, fm_matrix_L_RI_metric, fm_matrix_Sinv_Vtrunc_Sinv, &
fm_matrix_PQ, fm_matrix_L_kpoints, fm_matrix_Minv_L_kpoints, &
fm_matrix_Minv, fm_matrix_Minv_Vtrunc_Minv, &
nmo, homo, mat_munu, &
sab_orb_sub, mo_coeff_o, mo_coeff_v, mo_coeff_all, &
mo_coeff_gw, eps_filter, unit_nr, &
Expand Down Expand Up @@ -214,8 +217,10 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: mo_coeff
TYPE(cp_fm_type), INTENT(OUT) :: fm_matrix_PQ
TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_matrix_L_RI_metric, &
fm_matrix_Sinv_Vtrunc_Sinv
TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_matrix_L_kpoints, &
fm_matrix_Minv_L_kpoints, &
fm_matrix_Minv, &
fm_matrix_Minv_Vtrunc_Minv
INTEGER, INTENT(IN) :: nmo
INTEGER, DIMENSION(:), INTENT(IN) :: homo
TYPE(dbcsr_p_type), INTENT(INOUT) :: mat_munu
Expand Down Expand Up @@ -355,7 +360,7 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
kpoints, my_group_L_size, my_group_L_start, my_group_L_end, &
gd_array, calc_PQ_cond_num .AND. .NOT. do_svd, do_svd, &
qs_env%mp2_env%potential_parameter, ri_metric, &
fm_matrix_L_RI_metric, fm_matrix_Sinv_Vtrunc_Sinv, &
fm_matrix_L_kpoints, fm_matrix_Minv_L_kpoints, fm_matrix_Minv, fm_matrix_Minv_Vtrunc_Minv, &
do_im_time, do_kpoints_from_Gamma .OR. do_kpoints_cubic_RPA, qs_env%mp2_env%mp2_gpw%eps_pgf_orb_S, &
qs_kind_set, sab_orb_sub, calc_forces, unit_nr)

Expand All @@ -382,7 +387,7 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
WRITE (unit_nr, FMT="(T3,A,T73,A)") &
"RI_INFO| RI metric: ", "OVERLAP"
CASE (do_potential_truncated)
WRITE (unit_nr, FMT="(T3,A,T72,A)") &
WRITE (unit_nr, FMT="(T3,A,T64,A)") &
"RI_INFO| RI metric: ", "TRUNCATED COULOMB"
rc_ang = cp_unit_from_cp2k(ri_metric%cutoff_radius, "angstrom")
WRITE (unit_nr, '(T3,A,T61,F20.2)') &
Expand Down

0 comments on commit ebdeb28

Please sign in to comment.