Skip to content

Commit

Permalink
WFC: Coulomb metric as default for RI_METRIC without IM_TIME, Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederick Stein authored and oschuett committed Sep 18, 2019
1 parent 229a9cc commit 1814088
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/input_cp2k_mp2.F
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ SUBROUTINE create_mp2_section(section)
usage="RI_METRIC COULOMB", &
enum_c_vals=s2a("DEFAULT", "COULOMB", "OVERLAP", "LONGRANGE"), &
enum_i_vals=(/ri_default, do_potential_coulomb, do_potential_id, do_potential_long/), &
enum_desc=s2a("Use overlap metric for cubic scaling methods and interaction potential for higher scaling methods.", &
enum_desc=s2a("Use overlap metric for cubic scaling methods and Coulomb metric for higher scaling methods.", &
"Use Coulomb metric.", &
"Use overlap metric, recommended in combination with imaginary time for O(N^3) RPA.", &
"Use longrange metric. Not recommended with DO_SVD .TRUE."), &
Expand Down
40 changes: 21 additions & 19 deletions src/mp2_gpw.F
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ MODULE mp2_gpw
release_group_dist
USE input_constants, ONLY: do_eri_gpw,&
do_eri_os,&
do_eri_mme,&
do_potential_coulomb,&
do_potential_id,&
do_potential_long,&
Expand Down Expand Up @@ -193,11 +194,11 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
dimen_RI, dimen_RI_red, group_size_3c, group_size_P, gw_corr_lev_occ, &
gw_corr_lev_occ_beta, gw_corr_lev_virt, gw_corr_lev_virt_beta, handle, homo, homo_beta, &
i, i_multigrid, local_unit_nr, my_group_L_end, my_group_L_size, my_group_L_start, &
n_multigrid, nelectron, nelectron_beta, nmo, nspins, ri_metric
n_multigrid, nelectron, nelectron_beta, nmo, nspins, ri_metric, eri_method
INTEGER, ALLOCATABLE, DIMENSION(:) :: ends_array_mc_t, starts_array_mc_t
LOGICAL :: blacs_repeatable, do_bse, do_dbcsr_t, do_im_time, do_kpoints_cubic_RPA, do_mao, &
my_do_gw, my_do_ri_mp2, my_do_ri_rpa, my_do_ri_sos_laplace_mp2, &
skip_load_balance_distributed
skip_load_balance_distributed, do_gpw
REAL(KIND=dp) :: cutoff_old, Emp2_AB, Emp2_BB, Emp2_Cou_BB, Emp2_d2_AB, Emp2_d_AB, &
Emp2_EX_BB, eps_gvg_rspace_old, eps_pgf_orb_old, eps_rho_rspace_old, progression_factor, &
relative_cutoff_old
Expand Down Expand Up @@ -338,6 +339,8 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T

blacs_env_sub_mat_munu => blacs_env_sub

eri_method = qs_env%mp2_env%eri_method

IF (do_im_time) THEN

group_size_3c = mp2_env%ri_rpa_im_time%group_size_3c
Expand Down Expand Up @@ -374,7 +377,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
blacs_grid_layout, &
blacs_repeatable)

IF (qs_env%mp2_env%eri_method == do_eri_gpw) THEN
IF (eri_method == do_eri_gpw) THEN
blacs_env_sub_mat_munu => blacs_env_sub
ELSE
blacs_env_sub_mat_munu => blacs_env_sub_im_time_3c
Expand All @@ -387,8 +390,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
END IF

IF (mp2_env%ri_metric == ri_default) THEN
mp2_env%ri_metric = mp2_env%potential_parameter%potential_type
mp2_env%omega = mp2_env%potential_parameter%omega
mp2_env%ri_metric = do_potential_coulomb
END IF

! get stuff
Expand Down Expand Up @@ -425,6 +427,12 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
! which RI metric we want to have
ri_metric = mp2_env%ri_metric

! whether we need gpw integrals (plus pw stuff)
do_gpw = (eri_method == do_eri_gpw) .OR. &
((mp2_env%potential_parameter%potential_type == do_potential_long .OR. ri_metric == do_potential_long) &
.AND. eri_method == do_eri_os) &
.OR. (ri_metric == do_potential_id .AND. eri_method == do_eri_mme)

! check if we want to do ri-g0w0 on top of ri-rpa
my_do_gw = mp2_env%ri_rpa%do_ri_g0w0
gw_corr_lev_occ = mp2_env%ri_g0w0%corr_mos_occ
Expand Down Expand Up @@ -462,8 +470,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T

END IF

IF (qs_env%mp2_env%eri_method == do_eri_gpw .OR. (qs_env%mp2_env%potential_parameter%potential_type == do_potential_long &
.AND. qs_env%mp2_env%eri_method == do_eri_os)) THEN
IF (do_gpw) THEN

! hack hack hack XXXXXXXXXXXXXXX rebuilds the pw_en with the new cutoffs
progression_factor = dft_control%qs_control%progression_factor
Expand Down Expand Up @@ -599,8 +606,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
END IF
END IF
IF (qs_env%mp2_env%eri_method == do_eri_gpw .OR. (qs_env%mp2_env%potential_parameter%potential_type == do_potential_long &
.AND. qs_env%mp2_env%eri_method == do_eri_os)) THEN
IF (do_gpw) THEN
! and now free the whole lot
CALL pw_pool_give_back_pw(auxbas_pw_pool, rho_r%pw)
Expand All @@ -616,9 +622,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
! moved down
! CALL deallocate_task_list(task_list_sub)
! CALL pw_env_release(pw_env_sub)
IF ((qs_env%mp2_env%eri_method == do_eri_gpw .OR. (qs_env%mp2_env%eri_method == do_eri_os .AND. &
qs_env%mp2_env%potential_parameter%potential_type == do_potential_long)) .AND. &
(my_do_ri_rpa .OR. my_do_ri_sos_laplace_mp2)) THEN
IF (do_gpw .AND. (my_do_ri_rpa .OR. my_do_ri_sos_laplace_mp2)) THEN
CALL deallocate_task_list(task_list_sub)
CALL pw_env_release(pw_env_sub)
END IF
Expand Down Expand Up @@ -695,7 +699,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T

IF (do_im_time) THEN

IF (qs_env%mp2_env%eri_method == do_eri_gpw) THEN
IF (eri_method == do_eri_gpw) THEN
para_env_sub_RPA => para_env_sub
blacs_env_sub_RPA => blacs_env_sub
ELSE
Expand Down Expand Up @@ -842,7 +846,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
IF (calc_forces) THEN
! since we have to compute again integrals reinitialize the stuff we need
! get some of the grids ready
IF (qs_env%mp2_env%eri_method == do_eri_gpw) THEN
IF (do_gpw) THEN
NULLIFY (rho_r%pw, rho_g%pw, pot_g%pw)
CALL pw_pool_create_pw(auxbas_pw_pool, rho_r%pw, &
use_data=REALDATA3D, &
Expand Down Expand Up @@ -873,7 +877,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
blacs_env_sub)
ENDIF

IF (qs_env%mp2_env%eri_method == do_eri_gpw) THEN
IF (do_gpw) THEN
! release
CALL pw_pool_give_back_pw(auxbas_pw_pool, rho_r%pw)
CALL pw_pool_give_back_pw(auxbas_pw_pool, rho_g%pw)
Expand Down Expand Up @@ -934,9 +938,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
END IF
END IF

IF (qs_env%mp2_env%eri_method == do_eri_gpw .AND. &
(.NOT. (my_do_ri_rpa .OR. my_do_ri_sos_laplace_mp2)) &
) THEN
IF (do_gpw .AND. .NOT. (my_do_ri_rpa .OR. my_do_ri_sos_laplace_mp2)) THEN
CALL deallocate_task_list(task_list_sub)
CALL pw_env_release(pw_env_sub)
END IF
Expand All @@ -947,7 +949,7 @@ SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T
dft_control%qs_control%eps_gvg_rspace = eps_gvg_rspace_old
CALL init_interaction_radii(dft_control%qs_control, atomic_kind_set, qs_kind_set)

IF (qs_env%mp2_env%eri_method == do_eri_gpw) THEN
IF (do_gpw) THEN
! restore the initial value of the cutoff
dft_control%qs_control%e_cutoff = e_cutoff_old
dft_control%qs_control%cutoff = cutoff_old
Expand Down
26 changes: 15 additions & 11 deletions src/mp2_integrals.F
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ MODULE mp2_integrals
do_eri_mme,&
do_eri_os,&
do_potential_coulomb,&
do_potential_long
do_potential_long,&
do_potential_id
USE kinds, ONLY: dp
USE kpoint_coulomb_2c, ONLY: build_2c_coulomb_matrix_kp
USE kpoint_methods, ONLY: kpoint_init_cell_index,&
Expand Down Expand Up @@ -335,7 +336,7 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
local_col_row_info_gw, local_col_row_info_occ_bse, local_col_row_info_virt_bse
INTEGER, DIMENSION(3) :: pdims_t3c, periodic
LOGICAL :: do_alpha_beta, do_kpoints_from_Gamma, &
impose_split, memory_info, do_svd
impose_split, memory_info, do_svd, do_gpw
REAL(KIND=dp) :: cond_num, eps_svd, mem_for_iaK, &
omega_metric, omega_pot
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: my_Lrows
Expand Down Expand Up @@ -381,6 +382,11 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
omega_pot = qs_env%mp2_env%potential_parameter%omega
omega_metric = qs_env%mp2_env%omega_metric

! whether we need gpw integrals (plus pw stuff)
do_gpw = (eri_method == do_eri_gpw) .OR. ((potential_type == do_potential_long .OR. ri_metric == do_potential_long) &
.AND. qs_env%mp2_env%eri_method == do_eri_os) &
.OR. (ri_metric == do_potential_id .AND. qs_env%mp2_env%eri_method == do_eri_mme)

IF (do_svd .AND. calc_forces) THEN
CPABORT("SVD not implemented for forces.!")
END IF
Expand Down Expand Up @@ -483,8 +489,7 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
sub_proc_map(para_env_sub%num_pe+i) = i
END DO
IF (eri_method == do_eri_gpw .OR. (potential_type == do_potential_long .AND. qs_env%mp2_env%eri_method == do_eri_os)) THEN
IF (do_gpw) THEN
! start real calculation
NULLIFY (psi_L%pw)
CALL pw_pool_create_pw(auxbas_pw_pool, psi_L%pw, &
Expand Down Expand Up @@ -629,10 +634,6 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
IF (eri_method == do_eri_mme .AND. (ri_metric == do_potential_coulomb .OR. ri_metric == do_potential_long) .OR. &
eri_method == do_eri_os .AND. ri_metric == do_potential_coulomb) THEN
! MME and Obara-Saika Coulomb integrals only used for RI with
! Coulomb metric, not for overlap metric
! CPASSERT(ri_metric == do_potential_coulomb)
NULLIFY (mat_munu_local_L)
ALLOCATE (mat_munu_local_L(my_group_L_size))
DO LLL = 1, my_group_L_size
Expand Down Expand Up @@ -725,7 +726,7 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
ENDDO
DEALLOCATE (mat_munu_local_L)
ELSE IF (eri_method == do_eri_gpw .OR. ri_metric == do_potential_long) THEN
ELSE IF (do_gpw) THEN
DO LLL = my_group_L_start, my_group_L_end
i_counter = i_counter+1
Expand Down Expand Up @@ -779,6 +780,8 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
END IF
END DO
ELSE
CPABORT("No integration method chosen ?!")
END IF
ENDIF
Expand Down Expand Up @@ -971,7 +974,7 @@ SUBROUTINE mp2_ri_gpw_compute_in(BIb_C, BIb_C_gw, BIb_C_bse_ij, BIb_C_bse_ab, gd
END IF
IF (eri_method == do_eri_gpw .OR. (potential_type == do_potential_long .AND. qs_env%mp2_env%eri_method == do_eri_os)) THEN
IF (do_gpw) THEN
CALL pw_pool_give_back_pw(auxbas_pw_pool, psi_L%pw)
Expand Down Expand Up @@ -2314,7 +2317,8 @@ SUBROUTINE compute_2c_integrals(qs_env, eri_method, eri_param, para_env, para_en
hab=L_local_col, first_b=my_group_L_start, last_b=my_group_L_end, &
eri_method=eri_method)
ELSEIF (eri_method .EQ. do_eri_gpw .OR. ri_metric .NE. do_potential_coulomb) THEN
ELSEIF (eri_method .EQ. do_eri_gpw .OR. (ri_metric == do_potential_long .AND. qs_env%mp2_env%eri_method == do_eri_os) &
.OR. (ri_metric == do_potential_id .AND. qs_env%mp2_env%eri_method == do_eri_mme)) THEN
ALLOCATE (wf_vector(dimen_RI))
Expand Down
2 changes: 0 additions & 2 deletions src/mp2_ri_gpw.F
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ SUBROUTINE mp2_ri_gpw_compute_en(Emp2, Emp2_Cou, Emp2_EX, BIb_C, mp2_env, para_e
my_beta_beta_case, local_ba, virtual_beta)
ENDIF

WRITE(*,*) NORM2(BIb_C), SUM(BIb_C)

CALL timeset(routineN//"_RI_loop", handle2)
null_mat_rec = 0.0_dp
null_mat_send = 0.0_dp
Expand Down
6 changes: 3 additions & 3 deletions tests/QS/regtest-mp2-lr/H2O-ri-mp2-lr-mme.inp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
&TIMINGS
THRESHOLD 0.01
&END
TRACE
TRACE_MASTER
&END GLOBAL
&FORCE_EVAL
METHOD Quickstep
&DFT
BASIS_SET_FILE_NAME HFX_BASIS
POTENTIAL_FILE_NAME POTENTIAL
&MGRID
CUTOFF 200
CUTOFF 100
REL_CUTOFF 20
&END MGRID
&POISSON
Expand Down Expand Up @@ -50,8 +52,6 @@
CUTOFF 100
REL_CUTOFF 20
&END
# DEFAULT is numerically unstable
RI_METRIC COULOMB
ERI_METHOD MME
MEMORY 200.
NUMBER_PROC 1
Expand Down
6 changes: 3 additions & 3 deletions tests/QS/regtest-mp2-lr/H2O-ri-mp2-lr.inp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
REL_CUTOFF 20
&END MGRID
&POISSON
PERIODIC NONE
PERIODIC XYZ
POISSON_SOLVER WAVELET
&END POISSON
&QS
Expand Down Expand Up @@ -48,7 +48,7 @@
&END INTERACTION_POTENTIAL
&WFC_GPW
CUTOFF 100
REL_CUTOFF 20
REL_CUTOFF 50
&END
MEMORY 200.
NUMBER_PROC 1
Expand All @@ -61,7 +61,7 @@
&SUBSYS
&CELL
ABC [angstrom] 8.000 8.000 8.000
PERIODIC NONE
PERIODIC XYZ
&END CELL
&KIND H
BASIS_SET DZVP-GTH
Expand Down
6 changes: 2 additions & 4 deletions tests/QS/regtest-rpa-lr/H2O-ri-rpa-lr-mme.inp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
&GLOBAL
PROJECT H2O-ri-rpa-lr
PROJECT H2O-ri-rpa-lr-mme
PRINT_LEVEL MEDIUM
RUN_TYPE ENERGY
&TIMINGS
Expand All @@ -11,9 +11,8 @@
&DFT
BASIS_SET_FILE_NAME HFX_BASIS
POTENTIAL_FILE_NAME POTENTIAL
#GTH_POTENTIAL
&MGRID
CUTOFF 500
CUTOFF 100
REL_CUTOFF 30
&END MGRID
&POISSON
Expand Down Expand Up @@ -66,7 +65,6 @@
&END HF
&END RI_RPA
ERI_METHOD MME
RI_METRIC COULOMB
MEMORY 200.
NUMBER_PROC 1
DO_SVD
Expand Down
24 changes: 16 additions & 8 deletions tests/QS/regtest-rpa-lr/H2O-ri-rpa-lr.inp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
METHOD Quickstep
&DFT
BASIS_SET_FILE_NAME HFX_BASIS
POTENTIAL_FILE_NAME GTH_POTENTIALS
POTENTIAL_FILE_NAME POTENTIAL
&MGRID
CUTOFF 100
REL_CUTOFF 20
REL_CUTOFF 30
&END MGRID
&POISSON
PERIODIC NONE
PERIODIC XYZ
POISSON_SOLVER WAVELET
&END POISSON
&QS
Expand All @@ -34,8 +34,15 @@
&END
&END SCF
&XC
&XC_FUNCTIONAL PBE
&XC_FUNCTIONAL NONE
&END XC_FUNCTIONAL
&HF
FRACTION 1.0000000
&SCREENING
EPS_SCHWARZ 1.0E-8
SCREEN_ON_INITIAL_P FALSE
&END SCREENING
&END HF
&WF_CORRELATION
METHOD RI_RPA_GPW
&INTERACTION_POTENTIAL
Expand All @@ -47,7 +54,8 @@
REL_CUTOFF 20
&END
&RI_RPA
RPA_NUM_QUAD_POINTS 40
RPA_NUM_QUAD_POINTS 15
MINIMAX
&HF
FRACTION 1.0000000
&SCREENING
Expand All @@ -66,17 +74,17 @@
&SUBSYS
&CELL
ABC [angstrom] 8.000 8.000 8.000
PERIODIC NONE
PERIODIC XYZ
&END CELL
&KIND H
BASIS_SET DZVP-GTH
BASIS_SET RI_AUX RI_DZVP-GTH
POTENTIAL GTH-PBE-q1
POTENTIAL GTH-HF-q1
&END KIND
&KIND O
BASIS_SET DZVP-GTH
BASIS_SET RI_AUX RI_DZVP-GTH
POTENTIAL GTH-PBE-q6
POTENTIAL GTH-HF-q6
&END KIND
&TOPOLOGY
COORD_FILE_NAME H2O_gas.xyz
Expand Down

0 comments on commit 1814088

Please sign in to comment.