(git:08825b9)
Loading...
Searching...
No Matches
mp2_types.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Types needed for MP2 calculations
10!> \par History
11!> 2011.05 created [Mauro Del Ben]
12!> \author MDB
13! **************************************************************************************************
15 USE bse_types, ONLY: bse_env_release,&
17 USE cp_dbcsr_api, ONLY: dbcsr_p_type,&
21 USE cp_fm_types, ONLY: cp_fm_type
22 USE hfx_types, ONLY: hfx_release,&
23 hfx_type,&
25 USE input_constants, ONLY: &
32 USE kinds, ONLY: dp
33 USE kpoint_types, ONLY: kpoint_type
34 USE libint_2c_3c, ONLY: libint_potential_type
36 USE matrix_communication, ONLY: integ_mat_buffer_type => matrix_buffer_type
42#include "./base/base_uses.f90"
43
44 IMPLICIT NONE
45
46 PRIVATE
47
48 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'mp2_types'
49
50 PUBLIC :: mp2_type, &
51 integ_mat_buffer_type, &
61
62 PUBLIC :: mp2_env_create, &
71
72 INTEGER, SAVE :: init_tshpsc_lmax = -1
73
74! TYPE definitions
75
77 INTEGER, DIMENSION(:), ALLOCATABLE :: array
78 END TYPE one_dim_int_array
79
81 INTEGER, DIMENSION(:, :), ALLOCATABLE :: array
82 END TYPE two_dim_int_array
83
85 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: array
86 END TYPE one_dim_real_array
87
89 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: array
90 END TYPE two_dim_real_array
91
93 REAL(kind=dp), DIMENSION(:, :, :), ALLOCATABLE :: array
95
97 INTEGER, DIMENSION(:, :), ALLOCATABLE :: index_table
98 END TYPE mp2_biel_type
99
100 TYPE mp2_laplace_type
101 INTEGER :: n_quadrature = -1, &
102 num_integ_groups = -1
103 END TYPE mp2_laplace_type
104
105 TYPE mp2_direct_type
106 LOGICAL :: big_send = .false.
107 END TYPE mp2_direct_type
108
109 TYPE mp2_gpw_type
110 REAL(kind=dp) :: eps_grid = 0.0_dp, &
111 eps_filter = 0.0_dp, &
112 eps_pgf_orb_s = 0.0_dp
113 INTEGER :: print_level = 0
114 REAL(kind=dp) :: cutoff = 0.0_dp, &
115 relative_cutoff = 0.0_dp
116 INTEGER :: size_lattice_sum = 0
117 END TYPE mp2_gpw_type
118
119 TYPE ri_mp2_type
120 INTEGER :: block_size = 0, &
121 number_integration_groups = 0
122 LOGICAL :: print_dgemm_info = .false.
123 END TYPE ri_mp2_type
124
125 TYPE ri_rpa_type
126 INTEGER :: rpa_num_quad_points = -1, &
127 rpa_num_integ_groups = -1, &
128 mm_style = wfc_mm_style_gemm
129 TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data => null()
130 TYPE(section_vals_type), POINTER :: xc_section_primary => null(), &
131 xc_section_aux => null()
132 LOGICAL :: reuse_hfx = .false., &
133 minimax_quad = .false., &
134 do_ri_g0w0 = .false., &
135 do_admm = .false., &
136 do_rse = .false., &
137 print_dgemm_info = .false.
138
139 ! GCC 8 has an issue with this being an ALLOCATABLE
140 TYPE(dbcsr_type), DIMENSION(:), POINTER :: mo_coeff_o => null(), &
141 mo_coeff_v => null()
142 INTEGER :: exchange_correction = rpa_exchange_none, &
143 exchange_block_size = -1
144 LOGICAL :: use_hfx_implementation = .false.
145 REAL(kind=dp) :: ener_exchange = 0.0_dp, &
146 rse_corr_diag = 0.0_dp, &
147 rse_corr = 0.0_dp, &
148 scale_rpa = 0.0_dp
149
150 !LOGICAL :: do_sigma = .FALSE.
151 INTEGER :: sigma_param = 0.0_dp
152 REAL(kind=dp) :: e_sigma_corr = 0.0_dp
153
154 END TYPE ri_rpa_type
155
156 TYPE ri_rpa_im_time_type
157 INTEGER :: cut_memory = 0
158 LOGICAL :: memory_info = .false., &
159 make_chi_pos_definite = .false., &
160 make_overlap_mat_ao_pos_definite = .false., &
161 trunc_coulomb_ri_x = .false., &
162 keep_quad = .false., &
163 do_kpoints_from_gamma = .false., &
164 do_extrapolate_kpoints = .false.
165 REAL(kind=dp) :: eps_filter = 0.0_dp, &
166 eps_filter_factor = 0.0_dp, &
167 eps_compress = 0.0_dp, &
168 exp_tailored_weights = 0.0_dp, &
169 regularization_ri = 0.0_dp, &
170 eps_eigval_s = 0.0_dp, &
171 eps_eigval_s_gamma = 0.0_dp, &
172 rel_cutoff_trunc_coulomb_ri_x = 0.0_dp
173 TYPE(time_frequency_grid_type) :: time_frequency_grid
174 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: eigenval_gamma, &
175 wkp_v
176 INTEGER :: group_size_p = 0, &
177 group_size_3c = 0, &
178 kpoint_weights_w_method = kp_weights_w_auto, &
179 k_mesh_g_factor = 0
180 INTEGER, DIMENSION(:), POINTER :: kp_grid => null()
181 INTEGER, DIMENSION(3) :: kp_grid_extra = -1
182 LOGICAL :: do_im_time_kpoints = .false.
183 INTEGER :: min_bsize = 0, &
184 min_bsize_mo = 0, &
185 nkp_orig = 0, &
186 nkp_extra = 0
187 TYPE(kpoint_type), POINTER :: kpoints_g => null(), &
188 kpoints_sigma => null(), &
189 kpoints_sigma_no_xc => null()
190 INTEGER, ALLOCATABLE, DIMENSION(:) :: starts_array_mc_ri, ends_array_mc_ri, &
191 starts_array_mc_block_ri, &
192 ends_array_mc_block_ri, &
193 starts_array_mc, ends_array_mc, &
194 starts_array_mc_block, &
195 ends_array_mc_block
196
197 END TYPE ri_rpa_im_time_type
198
199 TYPE ri_g0w0_type
200 INTEGER :: corr_mos_occ = 0, &
201 corr_mos_virt = 0, &
202 corr_mos_occ_beta = 0, &
203 corr_mos_virt_beta = 0, &
204 num_poles = 0, &
205 nparam_pade = 0, &
206 analytic_continuation = gw_pade_approx
207 REAL(kind=dp) :: omega_max_fit = 0.0_dp
208 INTEGER :: crossing_search = ri_rpa_g0w0_crossing_z_shot
209 REAL(kind=dp) :: fermi_level_offset = 0.0_dp
210 INTEGER :: iter_evgw = 0, &
211 iter_sc_gw0 = 0
212 REAL(kind=dp) :: eps_iter = 0.0_dp
213 LOGICAL :: do_hedin_shift = .false., &
214 do_ri_sigma_x = .false., &
215 do_periodic = .false., &
216 print_self_energy = .false.
217 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: vec_sigma_x_minus_vxc_gw
218 INTEGER, DIMENSION(:), POINTER :: kp_grid => null(), &
219 kp_grid_sigma => null()
220 INTEGER :: num_kp_grids = 0
221 REAL(kind=dp) :: eps_kpoint = 0.0_dp
222 LOGICAL :: do_mo_coeff_gamma = .false., &
223 do_average_deg_levels = .false.
224 REAL(kind=dp) :: eps_eigenval = 0.0_dp
225 LOGICAL :: do_extra_kpoints = .false., &
226 do_aux_bas_gw = .false.
227 REAL(kind=dp) :: frac_aux_mos = 0.0_dp
228 INTEGER :: num_omega_points = 0
229 LOGICAL :: do_ic_model = .false., &
230 print_ic_values = .false.
231 REAL(kind=dp) :: eps_dist = 0.0_dp
232 TYPE(one_dim_real_array), DIMENSION(2) :: ic_corr_list = one_dim_real_array(null())
233 INTEGER :: print_exx = 0
234 LOGICAL :: do_gamma_only_sigma = .false.
235 LOGICAL :: update_xc_energy = .false., &
236 do_kpoints_sigma = .false., &
237 print_local_bandgap = .false.
238 INTEGER :: n_kp_in_kp_line = 0, &
239 n_special_kp = 0, &
240 nkp_self_energy = 0, &
241 nkp_self_energy_special_kp = 0, &
242 nkp_self_energy_monkh_pack = 0, &
243 soc_type = soc_none
244 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: xkp_special_kp
245 TYPE(dbcsr_p_type), DIMENSION(:), ALLOCATABLE :: matrix_sigma_x_minus_vxc, &
246 matrix_ks, &
247 matrix_vxc
248 LOGICAL :: do_static_cohsex = .false.
249 INTEGER :: cohsex_flavor = cohsex_off
250 REAL(kind=dp) :: cohsex_scale_occ = 1.0_dp, &
251 cohsex_scale_virt = 1.0_dp
252 REAL(kind=dp) :: broadening_print_loc_bandgap = 0.0_dp, &
253 energy_window_print_loc_bandgap = 0.0_dp, &
254 ldos_thresh_print_loc_bandgap = 0.0_dp, &
255 energy_spacing_print_loc_bandgap = 0.0_dp, &
256 regularization_minimax = 0.0_dp, &
257 soc_energy_window = 0.0_dp
258 INTEGER, DIMENSION(:), POINTER :: stride_loc_bandgap => null()
259
260 !GW_DOS
261 REAL(kind=dp) :: dos_upper = 0.0_dp, &
262 dos_lower = 0.0_dp, &
263 dos_prec = 0.0_dp, &
264 dos_eta = 0.0_dp
265 INTEGER :: max_level_self_energy = 0, &
266 min_level_self_energy = 0, &
267 dos_min = 0, &
268 dos_max = 0
269 END TYPE ri_g0w0_type
270
271 TYPE ri_basis_opt
272 REAL(kind=dp) :: di_rel = 0.0_dp, &
273 dri = 0.0_dp, &
274 eps_step = 0.0_dp
275 INTEGER :: max_num_iter = 0, &
276 basis_quality = 0
277 INTEGER, DIMENSION(:), ALLOCATABLE :: ri_nset_per_l
278 END TYPE ri_basis_opt
279
280 TYPE grad_util
281 TYPE(two_dim_real_array), DIMENSION(2) :: p_ij = two_dim_real_array(null()), &
282 p_ab = two_dim_real_array(null())
283 TYPE(three_dim_real_array), DIMENSION(2) :: gamma_p_ia = three_dim_real_array(null())
284 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: operator_half, &
285 pq_half, &
286 gamma_pq, &
287 gamma_pq_2
288 TYPE(dbcsr_p_type), DIMENSION(:, :), ALLOCATABLE :: g_p_ia
289 TYPE(dbcsr_p_type), DIMENSION(:), ALLOCATABLE :: mo_coeff_o, &
290 mo_coeff_v
291 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: p_mo, w_mo, l_jb
292 REAL(kind=dp) :: cphf_eps_conv = 0.0_dp, &
293 scale_step_size = 0.0_dp
294 INTEGER :: cphf_max_num_iter = 0, &
295 z_solver_method = 0, &
296 cphf_restart = 0
297 LOGICAL :: enforce_decrease = .false., &
298 recalc_residual = .false., &
299 polak_ribiere = .false.
300 TYPE(qs_p_env_type), POINTER :: p_env => null()
301 TYPE(qs_force_type), DIMENSION(:), POINTER :: mp2_force => null()
302 REAL(kind=dp), DIMENSION(3, 3) :: mp2_virial = 0.0_dp
303 REAL(dp) :: eps_canonical = 0.0_dp
304 LOGICAL :: free_hfx_buffer = .false.
305 INTEGER :: dot_blksize = 0
306 INTEGER :: max_parallel_comm = 0
307 END TYPE grad_util
308
310 INTEGER :: method = mp2_method_none
311 TYPE(mp2_laplace_type) :: ri_laplace = mp2_laplace_type()
312 TYPE(mp2_direct_type) :: direct_canonical = mp2_direct_type()
313 TYPE(libint_potential_type) :: potential_parameter = libint_potential_type()
314 TYPE(mp2_gpw_type) :: mp2_gpw = mp2_gpw_type()
315 TYPE(ri_mp2_type) :: ri_mp2 = ri_mp2_type()
316 TYPE(ri_rpa_type) :: ri_rpa = ri_rpa_type()
317 ! There is a bug with some older compilers preventing requiring an explicit initialization of allocatable components
318#if defined(FTN_NO_DEFAULT_INIT)
319 TYPE(ri_rpa_im_time_type) :: ri_rpa_im_time = ri_rpa_im_time_type( &
320 time_frequency_grid=time_frequency_grid_type( &
321 frequency=null(), &
322 frequency_weights=null(), &
323 imaginary_time=null(), &
324 time_weights_at_zero_frequency=null(), &
326 cosine_frequency_to_time=null(), &
327 sine_time_to_frequency=null()), &
328 eigenval_gamma=null(), &
329 wkp_v=null(), &
330 starts_array_mc_ri=null(), &
331 ends_array_mc_ri=null(), &
332 starts_array_mc_block_ri=null(), &
333 ends_array_mc_block_ri=null(), &
334 starts_array_mc=null(), ends_array_mc=null(), &
335 starts_array_mc_block=null(), &
336 ends_array_mc_block=null())
337 TYPE(ri_g0w0_type) :: ri_g0w0 = ri_g0w0_type(vec_sigma_x_minus_vxc_gw=null(), &
338 xkp_special_kp=null(), &
339 matrix_sigma_x_minus_vxc=null(), &
340 matrix_ks=null(), &
341 matrix_vxc=null())
342 TYPE(ri_basis_opt) :: ri_opt_param = ri_basis_opt(ri_nset_per_l=null())
343 TYPE(grad_util) :: ri_grad = grad_util(operator_half=null(), &
344 pq_half=null(), &
345 gamma_pq=null(), &
346 gamma_pq_2=null(), &
347 g_p_ia=null(), &
348 mo_coeff_o=null(), &
349 mo_coeff_v=null(), &
350 p_mo=null(), w_mo=null(), l_jb=null())
351 TYPE(bse_env_type) :: bse = bse_env_type(bse_nto_state_list_final=null(), &
352 homo_red=null(), virt_red=null(), &
353 homo_full=null(), gw_corr_lev_virt=null(), &
354 eigenval_dft=null(), eigenval_qp=null(), &
355 fm_s_ia=null(), &
356 fm_s_ij=null(), fm_s_ab=null(), &
357 fm_s_bar_ia=null(), fm_s_bar_ij=null())
358#else
359 TYPE(ri_rpa_im_time_type) :: ri_rpa_im_time = ri_rpa_im_time_type()
360 TYPE(ri_g0w0_type) :: ri_g0w0 = ri_g0w0_type()
361 TYPE(ri_basis_opt) :: ri_opt_param = ri_basis_opt()
362 TYPE(grad_util) :: ri_grad = grad_util()
363 TYPE(bse_env_type) :: bse = bse_env_type()
364#endif
365 REAL(kind=dp) :: mp2_memory = 0.0_dp, &
366 scale_s = 0.0_dp, &
367 scale_t = 0.0_dp
368 INTEGER :: mp2_num_proc = 0
369 INTEGER :: block_size_row = 0
370 INTEGER :: block_size_col = 0
371 LOGICAL :: calc_pq_cond_num = .false.
372 LOGICAL :: hf_fail = .false.
373 LOGICAL :: p_screen = .false.
374 LOGICAL :: not_last_hfx = .false.
375 LOGICAL :: do_im_time = .false.
376 INTEGER :: eri_method = eri_default
377 TYPE(cp_eri_mme_param), POINTER :: eri_mme_param => null()
378 INTEGER, DIMENSION(:), POINTER :: eri_blksize => null()
379 LOGICAL :: do_svd = .false.
380 REAL(kind=dp) :: eps_svd = -1.0_dp
381 REAL(kind=dp) :: eps_range = 0.0_dp
382 TYPE(libint_potential_type) :: ri_metric = libint_potential_type()
383 TYPE(local_gemm_ctxt_type) :: local_gemm_ctx = local_gemm_ctxt_type()
384 REAL(dp) :: e_gap = 0.0_dp, &
385 e_range = 0.0_dp
386 LOGICAL :: ri_aux_auto_generated = .false.
387 END TYPE mp2_type
388
390 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: msg
391 INTEGER :: proc = -1
392 TYPE(mp_request_type) :: msg_req = mp_request_type()
394
396 TYPE(pair_list_element_type), DIMENSION(:), &
397 ALLOCATABLE :: elements
398 INTEGER :: n_element = 0
399 END TYPE pair_list_type_mp2
400
401CONTAINS
402
403! **************************************************************************************************
404!> \brief ...
405!> \param mp2_env ...
406! **************************************************************************************************
407 SUBROUTINE mp2_env_release(mp2_env)
408 TYPE(mp2_type) :: mp2_env
409
410 CHARACTER(LEN=*), PARAMETER :: routinen = 'mp2_env_release'
411
412 INTEGER :: handle
413
414 CALL timeset(routinen, handle)
415
416 ! release the HFX section for the EXX calculation
417 IF (.NOT. mp2_env%ri_rpa%reuse_hfx) THEN
418 IF (ASSOCIATED(mp2_env%ri_rpa%x_data)) CALL hfx_release(mp2_env%ri_rpa%x_data)
419 END IF
420 IF (ASSOCIATED(mp2_env%ri_rpa%xc_section_aux)) CALL section_vals_release(mp2_env%ri_rpa%xc_section_aux)
421 IF (ASSOCIATED(mp2_env%ri_rpa%xc_section_primary)) CALL section_vals_release(mp2_env%ri_rpa%xc_section_primary)
422
423 IF (mp2_env%eri_method == do_eri_mme) CALL cp_eri_mme_finalize(mp2_env%eri_mme_param)
424 IF (ASSOCIATED(mp2_env%eri_mme_param)) DEALLOCATE (mp2_env%eri_mme_param)
425 CALL time_frequency_grid_release(mp2_env%ri_rpa_im_time%time_frequency_grid)
426
427 CALL mp2_env%local_gemm_ctx%destroy()
428 CALL bse_env_release(mp2_env%bse)
429
430 CALL timestop(handle)
431
432 END SUBROUTINE mp2_env_release
433
434! **************************************************************************************************
435!> \brief ...
436!> \param mp2_env ...
437! **************************************************************************************************
438 SUBROUTINE mp2_env_create(mp2_env)
439 TYPE(mp2_type), POINTER :: mp2_env
440
441 CHARACTER(LEN=*), PARAMETER :: routinen = 'mp2_env_create'
442
443 INTEGER :: handle
444
445 CALL timeset(routinen, handle)
446
447 cpassert(.NOT. ASSOCIATED(mp2_env))
448
449 ALLOCATE (mp2_env)
450
451 NULLIFY (mp2_env%ri_rpa%x_data)
452
453 CALL timestop(handle)
454
455 END SUBROUTINE mp2_env_create
456
457END MODULE mp2_types
The BSE environment: the settings of the &BSE section and the state a GW path prepares for the solver...
Definition bse_types.F:14
subroutine, public bse_env_release(bse_env)
Releases the state a GW path prepared and nullifies the QS pointers; the settings stay,...
Definition bse_types.F:135
Interface to Minimax-Ewald method for periodic ERI's to be used in CP2K.
subroutine, public cp_eri_mme_finalize(param)
Release eri mme data. Prints some statistics on summation methods chosen.
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
Types and set/get functions for HFX.
Definition hfx_types.F:16
subroutine, public hfx_release(x_data)
This routine deallocates all data structures
Definition hfx_types.F:1971
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public rpa_exchange_none
integer, parameter, public gw_pade_approx
integer, parameter, public mp2_method_direct
integer, parameter, public mp2_ri_optimize_basis
integer, parameter, public kp_weights_w_auto
integer, parameter, public do_eri_mme
integer, parameter, public wfc_mm_style_gemm
integer, parameter, public ri_rpa_method_gpw
integer, parameter, public ri_mp2_method_gpw
integer, parameter, public mp2_method_gpw
integer, parameter, public mp2_method_none
integer, parameter, public ri_mp2_laplace
integer, parameter, public eri_default
integer, parameter, public cohsex_off
integer, parameter, public ri_rpa_g0w0_crossing_z_shot
integer, parameter, public soc_none
objects that represent the structure of input sections and the data contained in an input section
recursive subroutine, public section_vals_release(section_vals)
releases the given object
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Types and basic routines needed for a kpoint calculation.
2- and 3-center electron repulsion integral routines based on libint2 Currently available operators: ...
Exchange numerical matrix payloads and integer metadata between MPI ranks.
Interface to the message passing library MPI.
Calls routines to get RI integrals and calculate total energies.
Definition mp2_gpw.F:14
Types needed for MP2 calculations.
Definition mp2_types.F:14
subroutine, public mp2_env_create(mp2_env)
...
Definition mp2_types.F:439
integer, save, public init_tshpsc_lmax
Definition mp2_types.F:72
subroutine, public mp2_env_release(mp2_env)
...
Definition mp2_types.F:408
basis types for the calculation of the perturbation of density theory.
Definition and construction of time/frequency grids for correlation methods.
integer, parameter cosine_time_to_frequency
subroutine, public time_frequency_grid_release(grid)
Release all data owned by a time_frequency_grid_type object.
Settings of the &BSE section (read_bse_section, re-read before every BSE run, normalised in place by ...
Definition bse_types.F:43
represent a full matrix
stores some data used in construction of Kohn-Sham matrix
Definition hfx_types.F:514
Contains information about kpoints.
Represent a qs system that is perturbed. Can calculate the linear operator and the rhs of the system ...