(git:27c966b)
Loading...
Searching...
No Matches
mp2_gpw.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 Calls routines to get RI integrals and calculate total energies
10!> \par History
11!> 10.2011 created [Joost VandeVondele and Mauro Del Ben]
12!> 07.2019 split from mp2_gpw.F [Frederick Stein]
13! **************************************************************************************************
14MODULE mp2_gpw
19 USE cell_types, ONLY: cell_type,&
25 USE cp_cfm_types, ONLY: cp_cfm_type
27 USE cp_dbcsr_api, ONLY: &
28 dbcsr_clear_mempools, dbcsr_copy, dbcsr_create, dbcsr_distribution_release, &
31 dbcsr_p_type, dbcsr_release, dbcsr_type, dbcsr_type_no_symmetry, dbcsr_type_symmetric
36 USE cp_fm_types, ONLY: cp_fm_get_info,&
39 USE cp_log_handling, ONLY: &
43 USE dbt_api, ONLY: dbt_clear_mempools,&
44 dbt_type
55 USE hfx_types, ONLY: block_ind_type,&
57 USE input_constants, ONLY: &
61 USE kinds, ONLY: dp
62 USE kpoint_types, ONLY: kpoint_type
63 USE machine, ONLY: default_output_unit,&
74 USE mp2_types, ONLY: mp2_type,&
82 USE qs_kind_types, ONLY: get_qs_kind,&
85 USE qs_mo_types, ONLY: get_mo_set,&
95 USE rpa_rse, ONLY: rse_energy
96#include "./base/base_uses.f90"
97
98 IMPLICIT NONE
99
100 PRIVATE
101
102 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'mp2_gpw'
103
105
106CONTAINS
107
108! **************************************************************************************************
109!> \brief with a big bang to mp2
110!> \param qs_env ...
111!> \param mp2_env ...
112!> \param Emp2 ...
113!> \param Emp2_Cou ...
114!> \param Emp2_EX ...
115!> \param Emp2_S ...
116!> \param Emp2_T ...
117!> \param mos_mp2 ...
118!> \param para_env ...
119!> \param unit_nr ...
120!> \param calc_forces ...
121!> \param calc_ex ...
122!> \param do_ri_mp2 ...
123!> \param do_ri_rpa ...
124!> \param do_ri_sos_laplace_mp2 ...
125!> \author Mauro Del Ben and Joost VandeVondele
126! **************************************************************************************************
127 SUBROUTINE mp2_gpw_main(qs_env, mp2_env, Emp2, Emp2_Cou, Emp2_EX, Emp2_S, Emp2_T, &
128 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_mp2, do_ri_rpa, &
129 do_ri_sos_laplace_mp2)
130 TYPE(qs_environment_type), POINTER :: qs_env
131 TYPE(mp2_type) :: mp2_env
132 REAL(kind=dp), INTENT(OUT) :: emp2, emp2_cou, emp2_ex, emp2_s, emp2_t
133 TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mos_mp2
134 TYPE(mp_para_env_type), POINTER :: para_env
135 INTEGER, INTENT(IN) :: unit_nr
136 LOGICAL, INTENT(IN) :: calc_forces, calc_ex
137 LOGICAL, INTENT(IN), OPTIONAL :: do_ri_mp2, do_ri_rpa, &
138 do_ri_sos_laplace_mp2
139
140 CHARACTER(LEN=*), PARAMETER :: routinen = 'mp2_gpw_main'
141
142 INTEGER :: blacs_grid_layout, color_sub, dimen_ri, dimen_ri_red, eri_method, handle, ispin, &
143 local_unit_nr, my_group_l_end, my_group_l_size, my_group_l_start, nmo, nspins, &
144 potential_type, ri_metric_type
145 INTEGER, ALLOCATABLE, DIMENSION(:) :: bse_lev_virt, ends_array_mc, ends_array_mc_block, &
146 gw_corr_lev_occ, gw_corr_lev_virt, homo, starts_array_mc, starts_array_mc_block
147 INTEGER, DIMENSION(3) :: periodic
148 LOGICAL :: blacs_repeatable, do_bse, do_im_time, do_kpoints_cubic_rpa, my_do_gw, &
149 my_do_ri_mp2, my_do_ri_rpa, my_do_ri_sos_laplace_mp2
150 REAL(kind=dp) :: emp2_ab, emp2_bb, emp2_cou_bb, &
151 emp2_ex_bb, eps_gvg_rspace_old, &
152 eps_pgf_orb_old, eps_rho_rspace_old
153 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: eigenval
154 REAL(kind=dp), DIMENSION(:), POINTER :: mo_eigenvalues
155 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
156 TYPE(block_ind_type), ALLOCATABLE, &
157 DIMENSION(:, :, :) :: t_3c_o_ind
158 TYPE(cell_type), POINTER :: cell
159 TYPE(cp_blacs_env_type), POINTER :: blacs_env_sub, blacs_env_sub_mat_munu
160 TYPE(cp_cfm_type), ALLOCATABLE, DIMENSION(:) :: cfm_matrix_l_kpoints, &
161 cfm_matrix_minv_l_kpoints
162 TYPE(cp_fm_type) :: fm_matrix_pq
163 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: mo_coeff
164 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_matrix_minv, fm_matrix_minv_l_gamma, &
165 fm_matrix_minv_vtrunc_minv
166 TYPE(cp_fm_type), POINTER :: mo_coeff_ptr
167 TYPE(cp_logger_type), POINTER :: logger, logger_sub
168 TYPE(dbcsr_p_type) :: mat_munu, mat_p_global
169 TYPE(dbcsr_p_type), ALLOCATABLE, DIMENSION(:) :: mo_coeff_all, mo_coeff_gw, mo_coeff_o, &
170 mo_coeff_o_bse, mo_coeff_v, &
171 mo_coeff_v_bse
172 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
173 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_s_kp
174 TYPE(dbt_type) :: t_3c_m
175 TYPE(dbt_type), ALLOCATABLE, DIMENSION(:, :) :: t_3c_o
176 TYPE(dft_control_type), POINTER :: dft_control
177 TYPE(group_dist_d1_type) :: gd_array, gd_b_all
178 TYPE(group_dist_d1_type), ALLOCATABLE, &
179 DIMENSION(:) :: gd_b_occ_bse, gd_b_virt_bse, gd_b_virtual
180 TYPE(hfx_compression_type), ALLOCATABLE, &
181 DIMENSION(:, :, :) :: t_3c_o_compressed
182 TYPE(kpoint_type), POINTER :: kpoints, kpoints_from_dft
183 TYPE(mp_para_env_type), POINTER :: para_env_sub
184 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
185 POINTER :: sab_orb_sub
186 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
187 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
188 TYPE(qs_ks_env_type), POINTER :: ks_env
189 TYPE(three_dim_real_array), ALLOCATABLE, &
190 DIMENSION(:) :: bib_c, bib_c_bse_ab, bib_c_bse_ij, &
191 bib_c_gw
192
193 CALL timeset(routinen, handle)
194
195 ! check if we want to do ri-mp2
196 my_do_ri_mp2 = .false.
197 IF (PRESENT(do_ri_mp2)) my_do_ri_mp2 = do_ri_mp2
198
199 ! check if we want to do ri-rpa
200 my_do_ri_rpa = .false.
201 IF (PRESENT(do_ri_rpa)) my_do_ri_rpa = do_ri_rpa
202
203 ! check if we want to do ri-sos-laplace-mp2
204 my_do_ri_sos_laplace_mp2 = .false.
205 IF (PRESENT(do_ri_sos_laplace_mp2)) my_do_ri_sos_laplace_mp2 = do_ri_sos_laplace_mp2
206
207 ! GW and SOS-MP2 cannot be used together
208 IF (my_do_ri_sos_laplace_mp2) THEN
209 cpassert(.NOT. mp2_env%ri_rpa%do_ri_g0w0)
210 END IF
211
212 ! check if we want to do imaginary time
213 do_im_time = mp2_env%do_im_time
214 do_bse = qs_env%mp2_env%bse%do_bse
215 do_kpoints_cubic_rpa = qs_env%mp2_env%ri_rpa_im_time%do_im_time_kpoints
216
217 IF (do_kpoints_cubic_rpa .AND. mp2_env%ri_rpa%do_ri_g0w0) THEN
218 cpabort("Full RPA k-points (DO_KPOINTS in LOW_SCALING section) not implemented with GW")
219 END IF
220
221 ! Get the number of spins
222 nspins = SIZE(mos_mp2)
223
224 ! ... setup needed to be able to qs_integrate in a subgroup.
225 IF (do_kpoints_cubic_rpa) THEN
226 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, kpoints=kpoints_from_dft)
227 ELSE
228 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
229 END IF
230 CALL get_mo_set(mo_set=mos_mp2(1), nmo=nmo)
231 ALLOCATE (homo(nspins), eigenval(nmo, nspins), mo_coeff(nspins))
232 DO ispin = 1, nspins
233 CALL get_mo_set(mo_set=mos_mp2(ispin), &
234 eigenvalues=mo_eigenvalues, homo=homo(ispin), &
235 mo_coeff=mo_coeff_ptr)
236 mo_coeff(ispin) = mo_coeff_ptr
237 eigenval(:, ispin) = mo_eigenvalues(1:nmo)
238 END DO
239
240 ! a para_env
241 color_sub = para_env%mepos/mp2_env%mp2_num_proc
242 ALLOCATE (para_env_sub)
243 CALL para_env_sub%from_split(para_env, color_sub)
244
245 ! each of the sub groups might need to generate output
246 logger => cp_get_default_logger()
247 IF (para_env%is_source()) THEN
248 local_unit_nr = cp_logger_get_default_unit_nr(logger, local=.false.)
249 ELSE
250 local_unit_nr = default_output_unit
251 END IF
252
253 ! get stuff
254 CALL get_qs_env(qs_env, &
255 ks_env=ks_env, &
256 qs_kind_set=qs_kind_set, &
257 cell=cell, &
258 particle_set=particle_set, &
259 atomic_kind_set=atomic_kind_set, &
260 dft_control=dft_control, &
261 matrix_s_kp=matrix_s_kp)
262
263 CALL get_cell(cell=cell, periodic=periodic)
264
265 IF (do_im_time) THEN
266 IF (mp2_env%ri_metric%potential_type == ri_default) THEN
267 IF (sum(periodic) == 1 .OR. sum(periodic) == 3) THEN
268 mp2_env%ri_metric%potential_type = do_potential_id
269 ELSE
270 mp2_env%ri_metric%potential_type = do_potential_truncated
271 END IF
272 END IF
273
274 END IF
275
276 IF (mp2_env%ri_metric%potential_type == ri_default) THEN
277 mp2_env%ri_metric%potential_type = do_potential_coulomb
278 END IF
279
280 IF (mp2_env%eri_method == eri_default) THEN
281 IF (sum(periodic) > 0) mp2_env%eri_method = do_eri_gpw
282 IF (sum(periodic) == 0) mp2_env%eri_method = do_eri_os
283 IF (sum(mp2_env%ri_rpa_im_time%kp_grid) > 0) mp2_env%eri_method = do_eri_os
284 IF (mp2_env%method == mp2_method_gpw) mp2_env%eri_method = do_eri_gpw
285 IF (mp2_env%method == ri_mp2_method_gpw) mp2_env%eri_method = do_eri_gpw
286 IF (mp2_env%ri_rpa_im_time%do_im_time_kpoints) mp2_env%eri_method = do_eri_os
287 IF (calc_forces .AND. mp2_env%eri_method == do_eri_os) mp2_env%eri_method = do_eri_gpw
288 END IF
289 eri_method = mp2_env%eri_method
290
291 IF (unit_nr > 0 .AND. mp2_env%eri_method == do_eri_gpw) THEN
292 WRITE (unit=unit_nr, fmt="(T3,A,T71,F10.1)") &
293 "GPW_INFO| Density cutoff [a.u.]:", mp2_env%mp2_gpw%cutoff*0.5_dp
294 WRITE (unit=unit_nr, fmt="(T3,A,T71,F10.1)") &
295 "GPW_INFO| Relative density cutoff [a.u.]:", mp2_env%mp2_gpw%relative_cutoff*0.5_dp
296 CALL m_flush(unit_nr)
297 END IF
298
299 ! MG: Disable logger layer for BSE, misses some key information to print cube files properly;
300 ! the same holds for the static COHSEX MOs (DFT%PRINT%MO, DFT%PRINT%MO_CUBES)
301 IF (.NOT. (mp2_env%ri_g0w0%print_local_bandgap .OR. mp2_env%bse%do_nto_analysis .OR. &
302 mp2_env%ri_g0w0%do_static_cohsex)) THEN
303 ! a logger
304 NULLIFY (logger_sub)
305 CALL cp_logger_create(logger_sub, para_env=para_env_sub, &
306 default_global_unit_nr=local_unit_nr, &
307 close_global_unit_on_dealloc=.false.)
308 CALL cp_logger_set(logger_sub, local_filename="MP2_localLog")
309 ! set to a custom print level (we could also have a different print level for para_env%source)
310 logger_sub%iter_info%print_level = mp2_env%mp2_gpw%print_level
311 CALL cp_add_default_logger(logger_sub)
312 END IF
313
314 ! a blacs_env (ignore the globenv stored defaults for now)
315 blacs_grid_layout = blacs_grid_square
316 blacs_repeatable = .true.
317 NULLIFY (blacs_env_sub)
318 CALL cp_blacs_env_create(blacs_env_sub, para_env_sub, &
319 blacs_grid_layout, &
320 blacs_repeatable)
321
322 blacs_env_sub_mat_munu => blacs_env_sub
323
324 matrix_s(1:1) => matrix_s_kp(1:1, 1)
325
326 CALL get_eps_old(dft_control, eps_pgf_orb_old, eps_rho_rspace_old, eps_gvg_rspace_old)
327
328 CALL create_mat_munu(mat_munu, qs_env, mp2_env%mp2_gpw%eps_grid, &
329 blacs_env_sub_mat_munu, do_alloc_blocks_from_nbl=.NOT. do_im_time, sab_orb_sub=sab_orb_sub, &
330 do_kpoints=mp2_env%ri_rpa_im_time%do_im_time_kpoints, &
331 dbcsr_sym_type=dbcsr_type_symmetric)
332
333 ! which RI metric we want to have
334 ri_metric_type = mp2_env%ri_metric%potential_type
335
336 ! which interaction potential
337 potential_type = mp2_env%potential_parameter%potential_type
338
339 ! check if we want to do ri-g0w0 on top of ri-rpa
340 my_do_gw = mp2_env%ri_rpa%do_ri_g0w0
341 ALLOCATE (gw_corr_lev_occ(nspins), gw_corr_lev_virt(nspins), bse_lev_virt(nspins))
342 gw_corr_lev_occ(1) = mp2_env%ri_g0w0%corr_mos_occ
343 gw_corr_lev_virt(1) = mp2_env%ri_g0w0%corr_mos_virt
344 IF (nspins == 2) THEN
345 gw_corr_lev_occ(2) = mp2_env%ri_g0w0%corr_mos_occ_beta
346 gw_corr_lev_virt(2) = mp2_env%ri_g0w0%corr_mos_virt_beta
347 END IF
348
349 IF (do_bse) THEN
350 !Keep default behavior for occupied
351 ! We do not implement an explicit bse_lev_occ here, because the small number of occupied levels
352 ! does not critically influence the memory
353 ! bse_lev_virt is per-spin (= the per-spin GW-corrected virtual count): the (ab|K) block is sized per spin
354 bse_lev_virt(:) = gw_corr_lev_virt(:)
355 END IF
356
357 ! After the components are inside of the routines, we can move this line insight the branch
358 ALLOCATE (mo_coeff_o(nspins), mo_coeff_v(nspins), mo_coeff_all(nspins), mo_coeff_gw(nspins))
359
360 ! Always allocate for usage in call of replicate_mat_to_subgroup
361 ALLOCATE (mo_coeff_o_bse(nspins), mo_coeff_v_bse(nspins))
362
363 ! for imag. time, we do not need this
364 IF (.NOT. do_im_time) THEN
365
366 ! new routine: replicate a full matrix from one para_env to a smaller one
367 ! keeping the memory usage as small as possible in this case the
368 ! output the two part of the C matrix (virtual, occupied)
369 DO ispin = 1, nspins
370
371 CALL replicate_mat_to_subgroup(para_env, para_env_sub, mo_coeff(ispin), homo(ispin), mat_munu%matrix, &
372 mo_coeff_o(ispin)%matrix, mo_coeff_v(ispin)%matrix, &
373 mo_coeff_all(ispin)%matrix, mo_coeff_gw(ispin)%matrix, &
374 my_do_gw, gw_corr_lev_occ(ispin), gw_corr_lev_virt(ispin), do_bse, &
375 bse_lev_virt(ispin), mo_coeff_o_bse(ispin)%matrix, mo_coeff_v_bse(ispin)%matrix, &
376 mp2_env%mp2_gpw%eps_filter)
377
378 END DO
379
380 END IF
381
382 ! now we're kind of ready to go....
383 emp2_s = 0.0_dp
384 emp2_t = 0.0_dp
385 IF (my_do_ri_mp2 .OR. my_do_ri_rpa .OR. my_do_ri_sos_laplace_mp2) THEN
386 ! RI-GPW integrals (same stuff for both RPA and MP2)
387 IF (nspins == 2) THEN
388 ! open shell case (RI) here the (ia|K) integrals are computed for both the alpha and beta components
390 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, &
391 para_env, para_env_sub, color_sub, cell, particle_set, &
392 atomic_kind_set, qs_kind_set, fm_matrix_pq, cfm_matrix_l_kpoints, cfm_matrix_minv_l_kpoints, &
393 fm_matrix_minv_l_gamma, &
394 fm_matrix_minv, fm_matrix_minv_vtrunc_minv, nmo, homo, mat_munu, sab_orb_sub, &
395 mo_coeff_o, mo_coeff_v, mo_coeff_all, mo_coeff_gw, mo_coeff_o_bse, mo_coeff_v_bse, &
396 mp2_env%mp2_gpw%eps_filter, unit_nr, &
397 mp2_env%mp2_memory, mp2_env%calc_PQ_cond_num, calc_forces, blacs_env_sub, my_do_gw .AND. .NOT. do_im_time, &
398 do_bse, gd_b_all, starts_array_mc, ends_array_mc, starts_array_mc_block, ends_array_mc_block, &
399 gw_corr_lev_occ(1), gw_corr_lev_virt(1), &
400 bse_lev_virt, &
401 do_im_time, do_kpoints_cubic_rpa, kpoints, &
402 t_3c_m, t_3c_o, t_3c_o_compressed, t_3c_o_ind, &
403 mp2_env%ri_metric, &
404 gd_b_occ_bse, gd_b_virt_bse)
405 ELSE
406 ! closed shell case (RI)
407 CALL mp2_ri_gpw_compute_in(bib_c, bib_c_gw, bib_c_bse_ij, bib_c_bse_ab, gd_array, gd_b_virtual, &
408 dimen_ri, dimen_ri_red, qs_env, para_env, para_env_sub, &
409 color_sub, cell, particle_set, &
410 atomic_kind_set, qs_kind_set, fm_matrix_pq, &
411 cfm_matrix_l_kpoints, cfm_matrix_minv_l_kpoints, &
412 fm_matrix_minv_l_gamma, &
413 fm_matrix_minv, fm_matrix_minv_vtrunc_minv, nmo, homo, &
414 mat_munu, sab_orb_sub, &
415 mo_coeff_o, mo_coeff_v, mo_coeff_all, mo_coeff_gw, mo_coeff_o_bse, mo_coeff_v_bse, &
416 mp2_env%mp2_gpw%eps_filter, unit_nr, &
417 mp2_env%mp2_memory, mp2_env%calc_PQ_cond_num, calc_forces, &
418 blacs_env_sub, my_do_gw .AND. .NOT. do_im_time, do_bse, gd_b_all, &
419 starts_array_mc, ends_array_mc, &
420 starts_array_mc_block, ends_array_mc_block, &
421 gw_corr_lev_occ(1), gw_corr_lev_virt(1), &
422 bse_lev_virt, &
423 do_im_time, do_kpoints_cubic_rpa, kpoints, &
424 t_3c_m, t_3c_o, t_3c_o_compressed, t_3c_o_ind, &
425 mp2_env%ri_metric, gd_b_occ_bse, gd_b_virt_bse)
426 END IF
427
428 ELSE
429 ! Canonical MP2-GPW
430 IF (nspins == 2) THEN
431 ! alpha-alpha and alpha-beta components
432 IF (unit_nr > 0) WRITE (unit_nr, *)
433 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Alpha (ia|'
434 CALL mp2_gpw_compute( &
435 emp2, emp2_cou, emp2_ex, qs_env, para_env, para_env_sub, color_sub, &
436 cell, particle_set, &
437 atomic_kind_set, qs_kind_set, eigenval, nmo, homo, mat_munu, &
438 sab_orb_sub, mo_coeff_o, mo_coeff_v, mp2_env%mp2_gpw%eps_filter, unit_nr, &
439 mp2_env%mp2_memory, calc_ex, blacs_env_sub, emp2_ab)
440
441 ! beta-beta component
442 IF (unit_nr > 0) WRITE (unit_nr, *)
443 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Beta (ia|'
444 CALL mp2_gpw_compute( &
445 emp2_bb, emp2_cou_bb, emp2_ex_bb, qs_env, para_env, para_env_sub, color_sub, cell, particle_set, &
446 atomic_kind_set, qs_kind_set, eigenval(:, 2:2), nmo, homo(2:2), mat_munu, &
447 sab_orb_sub, mo_coeff_o(2:2), mo_coeff_v(2:2), mp2_env%mp2_gpw%eps_filter, unit_nr, &
448 mp2_env%mp2_memory, calc_ex, blacs_env_sub)
449
450 ! make order on the MP2 energy contributions
451 emp2_cou = emp2_cou*0.25_dp
452 emp2_ex = emp2_ex*0.5_dp
453
454 emp2_cou_bb = emp2_cou_bb*0.25_dp
455 emp2_ex_bb = emp2_ex_bb*0.5_dp
456
457 emp2_s = emp2_ab
458 emp2_t = emp2_cou + emp2_cou_bb + emp2_ex + emp2_ex_bb
459
460 emp2_cou = emp2_cou + emp2_cou_bb + emp2_ab
461 emp2_ex = emp2_ex + emp2_ex_bb
462 emp2 = emp2_ex + emp2_cou
463
464 ELSE
465 ! closed shell case
466 CALL mp2_gpw_compute( &
467 emp2, emp2_cou, emp2_ex, qs_env, para_env, para_env_sub, color_sub, cell, particle_set, &
468 atomic_kind_set, qs_kind_set, eigenval(:, 1:1), nmo, homo(1:1), mat_munu, &
469 sab_orb_sub, mo_coeff_o(1:1), mo_coeff_v(1:1), mp2_env%mp2_gpw%eps_filter, unit_nr, &
470 mp2_env%mp2_memory, calc_ex, blacs_env_sub)
471 END IF
472 END IF
473
474 ! Free possibly large buffers allocated by dbcsr on the GPU,
475 ! large hybrid dgemm/pdgemm's coming later will need the space.
476 CALL dbcsr_clear_mempools()
477 CALL dbt_clear_mempools()
478
479 IF (calc_forces .AND. .NOT. do_im_time) THEN
480 ! make a copy of mo_coeff_o and mo_coeff_v
481 ALLOCATE (mp2_env%ri_grad%mo_coeff_o(nspins), mp2_env%ri_grad%mo_coeff_v(nspins))
482 DO ispin = 1, nspins
483 NULLIFY (mp2_env%ri_grad%mo_coeff_o(ispin)%matrix)
484 CALL dbcsr_init_p(mp2_env%ri_grad%mo_coeff_o(ispin)%matrix)
485 CALL dbcsr_copy(mp2_env%ri_grad%mo_coeff_o(ispin)%matrix, mo_coeff_o(ispin)%matrix, &
486 name="mo_coeff_o"//cp_to_string(ispin))
487 NULLIFY (mp2_env%ri_grad%mo_coeff_v(ispin)%matrix)
488 CALL dbcsr_init_p(mp2_env%ri_grad%mo_coeff_v(ispin)%matrix)
489 CALL dbcsr_copy(mp2_env%ri_grad%mo_coeff_v(ispin)%matrix, mo_coeff_v(ispin)%matrix, &
490 name="mo_coeff_v"//cp_to_string(ispin))
491 END DO
492 CALL get_group_dist(gd_array, color_sub, my_group_l_start, my_group_l_end, my_group_l_size)
493 END IF
494 ! Copy mo coeffs for RPA exchange correction
495 IF (mp2_env%ri_rpa%exchange_correction /= rpa_exchange_none) THEN
496 ALLOCATE (mp2_env%ri_rpa%mo_coeff_o(nspins), mp2_env%ri_rpa%mo_coeff_v(nspins))
497 DO ispin = 1, nspins
498 CALL dbcsr_copy(mp2_env%ri_rpa%mo_coeff_o(ispin), mo_coeff_o(ispin)%matrix, name="mo_coeff_o")
499 CALL dbcsr_copy(mp2_env%ri_rpa%mo_coeff_v(ispin), mo_coeff_v(ispin)%matrix, name="mo_coeff_v")
500 END DO
501 END IF
502
503 IF (.NOT. do_im_time) THEN
504
505 DO ispin = 1, nspins
506 CALL dbcsr_release(mo_coeff_o(ispin)%matrix)
507 DEALLOCATE (mo_coeff_o(ispin)%matrix)
508 CALL dbcsr_release(mo_coeff_v(ispin)%matrix)
509 DEALLOCATE (mo_coeff_v(ispin)%matrix)
510 IF (my_do_gw) THEN
511 CALL dbcsr_release(mo_coeff_all(ispin)%matrix)
512 DEALLOCATE (mo_coeff_all(ispin)%matrix)
513 END IF
514 END DO
515 DEALLOCATE (mo_coeff_o, mo_coeff_v)
516 IF (my_do_gw) DEALLOCATE (mo_coeff_all)
517
518 END IF
519 IF (do_bse) THEN
520 DO ispin = 1, nspins
521 CALL dbcsr_release(mo_coeff_o_bse(ispin)%matrix)
522 CALL dbcsr_release(mo_coeff_v_bse(ispin)%matrix)
523 DEALLOCATE (mo_coeff_o_bse(ispin)%matrix)
524 DEALLOCATE (mo_coeff_v_bse(ispin)%matrix)
525 END DO
526 END IF
527 DEALLOCATE (mo_coeff_o_bse, mo_coeff_v_bse)
528
529 ! Release some memory for RPA exchange correction
530 IF (calc_forces .AND. do_im_time .OR. &
531 (.NOT. calc_forces .AND. mp2_env%ri_rpa%exchange_correction == rpa_exchange_none)) THEN
532
533 CALL dbcsr_release(mat_munu%matrix)
534 DEALLOCATE (mat_munu%matrix)
535
536 CALL release_neighbor_list_sets(sab_orb_sub)
537
538 END IF
539
540 ! decide if to do RI-RPA or RI-MP2
541 IF (my_do_ri_rpa .OR. my_do_ri_sos_laplace_mp2) THEN
542
543 IF (do_im_time) CALL create_matrix_p(mat_p_global, qs_env, mp2_env, para_env)
544
545 IF (.NOT. ALLOCATED(bib_c)) ALLOCATE (bib_c(nspins))
546 IF (.NOT. ALLOCATED(bib_c_gw)) ALLOCATE (bib_c_gw(nspins))
547 IF (.NOT. ALLOCATED(gd_b_virtual)) ALLOCATE (gd_b_virtual(nspins))
548
549 ! RI-RPA
550 CALL rpa_ri_compute_en(qs_env, emp2, mp2_env, bib_c, bib_c_gw, bib_c_bse_ij, bib_c_bse_ab, &
551 para_env, para_env_sub, color_sub, &
552 gd_array, gd_b_virtual, gd_b_all, gd_b_occ_bse, gd_b_virt_bse, &
553 mo_coeff, fm_matrix_pq, cfm_matrix_l_kpoints, cfm_matrix_minv_l_kpoints, &
554 fm_matrix_minv_l_gamma, &
555 fm_matrix_minv, fm_matrix_minv_vtrunc_minv, kpoints, &
556 eigenval, nmo, homo, dimen_ri, dimen_ri_red, gw_corr_lev_occ, gw_corr_lev_virt, &
557 bse_lev_virt, &
558 unit_nr, my_do_ri_sos_laplace_mp2, my_do_gw, do_im_time, do_bse, matrix_s, &
559 mat_munu, mat_p_global, t_3c_m, t_3c_o, t_3c_o_compressed, t_3c_o_ind, &
560 starts_array_mc, ends_array_mc, &
561 starts_array_mc_block, ends_array_mc_block, calc_forces)
562
563 IF (mp2_env%ri_rpa%do_rse) THEN
564 CALL rse_energy(qs_env, mp2_env, para_env, dft_control, mo_coeff, homo, eigenval)
565 END IF
566
567 IF (do_im_time) THEN
568 IF (ASSOCIATED(mat_p_global%matrix)) THEN
569 CALL dbcsr_release(mat_p_global%matrix)
570 DEALLOCATE (mat_p_global%matrix)
571 END IF
572
573 IF (calc_forces) CALL cp_fm_release(fm_matrix_pq)
574 END IF
575
576 ! Release some memory for RPA exchange correction
577 IF (mp2_env%ri_rpa%exchange_correction /= rpa_exchange_none) THEN
578
579 CALL dbcsr_release(mat_munu%matrix)
580 DEALLOCATE (mat_munu%matrix)
581
582 CALL release_neighbor_list_sets(sab_orb_sub)
583
584 END IF
585
586 ELSE
587 IF (my_do_ri_mp2) THEN
588 emp2 = 0.0_dp
589 emp2_cou = 0.0_dp
590 emp2_ex = 0.0_dp
591
592 ! RI-MP2-GPW compute energy
594 emp2_cou, emp2_ex, emp2_s, emp2_t, bib_c, mp2_env, para_env, para_env_sub, color_sub, &
595 gd_array, gd_b_virtual, &
596 eigenval, nmo, homo, dimen_ri_red, unit_nr, calc_forces, calc_ex)
597
598 END IF
599 END IF
600
601 ! if we need forces time to calculate the MP2 non-separable contribution
602 ! and start computing the Lagrangian
603 IF (calc_forces .AND. .NOT. do_im_time) THEN
604
605 CALL calc_ri_mp2_nonsep(qs_env, mp2_env, para_env, para_env_sub, cell, &
606 particle_set, atomic_kind_set, qs_kind_set, &
607 mo_coeff, dimen_ri, eigenval, &
608 my_group_l_start, my_group_l_end, my_group_l_size, &
609 sab_orb_sub, mat_munu, blacs_env_sub)
610
611 DO ispin = 1, nspins
612 CALL dbcsr_release(mp2_env%ri_grad%mo_coeff_o(ispin)%matrix)
613 DEALLOCATE (mp2_env%ri_grad%mo_coeff_o(ispin)%matrix)
614
615 CALL dbcsr_release(mp2_env%ri_grad%mo_coeff_v(ispin)%matrix)
616 DEALLOCATE (mp2_env%ri_grad%mo_coeff_v(ispin)%matrix)
617 END DO
618 DEALLOCATE (mp2_env%ri_grad%mo_coeff_o, mp2_env%ri_grad%mo_coeff_v)
619
620 CALL dbcsr_release(mat_munu%matrix)
621 DEALLOCATE (mat_munu%matrix)
622
623 CALL release_neighbor_list_sets(sab_orb_sub)
624
625 END IF
626
627 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
628 ! moved from above
629 IF (my_do_gw .AND. .NOT. do_im_time) THEN
630 DO ispin = 1, nspins
631 CALL dbcsr_release(mo_coeff_gw(ispin)%matrix)
632 DEALLOCATE (mo_coeff_gw(ispin)%matrix)
633 END DO
634 DEALLOCATE (mo_coeff_gw)
635 END IF
636
637 ! re-init the radii to be able to generate pair lists with MP2-appropriate screening
638 dft_control%qs_control%eps_pgf_orb = eps_pgf_orb_old
639 dft_control%qs_control%eps_rho_rspace = eps_rho_rspace_old
640 dft_control%qs_control%eps_gvg_rspace = eps_gvg_rspace_old
641 CALL init_interaction_radii(dft_control%qs_control, qs_kind_set)
642
643 CALL cp_blacs_env_release(blacs_env_sub)
644
645 IF (.NOT. (mp2_env%ri_g0w0%print_local_bandgap .OR. mp2_env%bse%do_nto_analysis .OR. &
646 mp2_env%ri_g0w0%do_static_cohsex)) THEN
648 CALL cp_logger_release(logger_sub)
649 END IF
650
651 CALL mp_para_env_release(para_env_sub)
652
653 ! finally solve the z-vector equation if forces are required
654 IF (calc_forces .AND. .NOT. do_im_time) THEN
655 CALL solve_z_vector_eq(qs_env, mp2_env, para_env, dft_control, &
656 mo_coeff, homo, eigenval, unit_nr)
657 END IF
658
659 DEALLOCATE (eigenval, mo_coeff)
660
661 ! buffers of the tensor operations (e.g., low-scaling RPA/GW) are not kept beyond this point
662 CALL dbt_clear_mempools()
663
664 CALL timestop(handle)
665
666 END SUBROUTINE mp2_gpw_main
667
668! **************************************************************************************************
669!> \brief ...
670!> \param para_env ...
671!> \param para_env_sub ...
672!> \param mo_coeff ...
673!> \param homo ...
674!> \param mat_munu ...
675!> \param mo_coeff_o ...
676!> \param mo_coeff_v ...
677!> \param mo_coeff_all ...
678!> \param mo_coeff_gw ...
679!> \param my_do_gw ...
680!> \param gw_corr_lev_occ ...
681!> \param gw_corr_lev_virt ...
682!> \param my_do_bse ...
683!> \param bse_lev_virt ...
684!> \param mo_coeff_o_bse ...
685!> \param mo_coeff_v_bse ...
686!> \param eps_filter ...
687! **************************************************************************************************
688 SUBROUTINE replicate_mat_to_subgroup(para_env, para_env_sub, mo_coeff, homo, mat_munu, &
689 mo_coeff_o, mo_coeff_v, mo_coeff_all, mo_coeff_gw, my_do_gw, &
690 gw_corr_lev_occ, gw_corr_lev_virt, my_do_bse, &
691 bse_lev_virt, mo_coeff_o_bse, mo_coeff_v_bse, eps_filter)
692 TYPE(mp_para_env_type), INTENT(IN) :: para_env, para_env_sub
693 TYPE(cp_fm_type), INTENT(IN) :: mo_coeff
694 INTEGER, INTENT(IN) :: homo
695 TYPE(dbcsr_type), INTENT(INOUT) :: mat_munu
696 TYPE(dbcsr_type), POINTER :: mo_coeff_o, mo_coeff_v, mo_coeff_all, &
697 mo_coeff_gw
698 LOGICAL, INTENT(IN) :: my_do_gw
699 INTEGER, INTENT(IN) :: gw_corr_lev_occ, gw_corr_lev_virt
700 LOGICAL, INTENT(IN) :: my_do_bse
701 INTEGER, INTENT(IN) :: bse_lev_virt
702 TYPE(dbcsr_type), POINTER :: mo_coeff_o_bse, mo_coeff_v_bse
703 REAL(kind=dp), INTENT(IN) :: eps_filter
704
705 CHARACTER(LEN=*), PARAMETER :: routinen = 'replicate_mat_to_subgroup'
706
707 INTEGER :: handle
708 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: c
709 TYPE(group_dist_d1_type) :: gd_array
710
711 CALL timeset(routinen, handle)
712
713 CALL grep_rows_in_subgroups(para_env, para_env_sub, mo_coeff, gd_array, c)
714
715 ! create and fill mo_coeff_o, mo_coeff_v and mo_coeff_all
716 ALLOCATE (mo_coeff_o)
717 CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_o, c(:, 1:homo), &
718 mat_munu, gd_array, eps_filter)
719
720 ALLOCATE (mo_coeff_v)
721 CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_v, c(:, homo + 1:), &
722 mat_munu, gd_array, eps_filter)
723
724 IF (my_do_gw) THEN
725 ALLOCATE (mo_coeff_gw)
726 CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_gw, c(:, homo - gw_corr_lev_occ + 1:homo + gw_corr_lev_virt), &
727 mat_munu, gd_array, eps_filter)
728
729 ! all levels
730 ALLOCATE (mo_coeff_all)
731 CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_all, c, &
732 mat_munu, gd_array, eps_filter)
733
734 END IF
735
736 IF (my_do_bse) THEN
737
738 ALLOCATE (mo_coeff_o_bse)
739 CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_o_bse, c(:, 1:homo), &
740 mat_munu, gd_array, eps_filter)
741
742 ALLOCATE (mo_coeff_v_bse)
743 CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_v_bse, c(:, homo + 1:homo + bse_lev_virt), &
744 mat_munu, gd_array, eps_filter)
745
746 END IF
747 DEALLOCATE (c)
748 CALL release_group_dist(gd_array)
749
750 CALL timestop(handle)
751
752 END SUBROUTINE replicate_mat_to_subgroup
753
754! **************************************************************************************************
755!> \brief ...
756!> \param para_env ...
757!> \param para_env_sub ...
758!> \param mo_coeff ...
759!> \param gd_array ...
760!> \param C ...
761! **************************************************************************************************
762 SUBROUTINE grep_rows_in_subgroups(para_env, para_env_sub, mo_coeff, gd_array, C)
763 TYPE(mp_para_env_type), INTENT(IN) :: para_env, para_env_sub
764 TYPE(cp_fm_type), INTENT(IN) :: mo_coeff
765 TYPE(group_dist_d1_type), INTENT(OUT) :: gd_array
766 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :), &
767 INTENT(OUT) :: c
768
769 CHARACTER(LEN=*), PARAMETER :: routinen = 'grep_rows_in_subgroups'
770
771 INTEGER :: handle, i_global, iib, j_global, jjb, max_row_col_local, my_mu_end, my_mu_size, &
772 my_mu_start, ncol_global, ncol_local, ncol_rec, nrow_global, nrow_local, nrow_rec, &
773 proc_receive_static, proc_send_static, proc_shift
774 INTEGER, ALLOCATABLE, DIMENSION(:, :) :: local_col_row_info, rec_col_row_info
775 INTEGER, DIMENSION(:), POINTER :: col_indices, col_indices_rec, &
776 row_indices, row_indices_rec
777 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: local_c, rec_c
778 REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :), &
779 POINTER :: local_c_internal
780
781 CALL timeset(routinen, handle)
782
783 CALL cp_fm_get_info(matrix=mo_coeff, &
784 ncol_global=ncol_global, &
785 nrow_global=nrow_global, &
786 nrow_local=nrow_local, &
787 ncol_local=ncol_local, &
788 row_indices=row_indices, &
789 col_indices=col_indices, &
790 local_data=local_c_internal)
791
792 CALL create_group_dist(gd_array, para_env_sub%num_pe, nrow_global)
793 CALL get_group_dist(gd_array, para_env_sub%mepos, my_mu_start, my_mu_end, my_mu_size)
794
795 ! local storage for the C matrix
796 ALLOCATE (c(my_mu_size, ncol_global))
797 c = 0.0_dp
798
799 ALLOCATE (local_c(nrow_local, ncol_local))
800 local_c(:, :) = local_c_internal(1:nrow_local, 1:ncol_local)
801 NULLIFY (local_c_internal)
802
803 max_row_col_local = max(nrow_local, ncol_local)
804 CALL para_env%max(max_row_col_local)
805
806 ALLOCATE (local_col_row_info(0:max_row_col_local, 2))
807 local_col_row_info = 0
808 ! 0,1 nrows
809 local_col_row_info(0, 1) = nrow_local
810 local_col_row_info(1:nrow_local, 1) = row_indices(1:nrow_local)
811 ! 0,2 ncols
812 local_col_row_info(0, 2) = ncol_local
813 local_col_row_info(1:ncol_local, 2) = col_indices(1:ncol_local)
814
815 ALLOCATE (rec_col_row_info(0:max_row_col_local, 2))
816
817 ! accumulate data on C buffer starting from myself
818 DO iib = 1, nrow_local
819 i_global = row_indices(iib)
820 IF (i_global >= my_mu_start .AND. i_global <= my_mu_end) THEN
821 DO jjb = 1, ncol_local
822 j_global = col_indices(jjb)
823 c(i_global - my_mu_start + 1, j_global) = local_c(iib, jjb)
824 END DO
825 END IF
826 END DO
827
828 ! start ring communication for collecting the data from the other
829 proc_send_static = modulo(para_env%mepos + 1, para_env%num_pe)
830 proc_receive_static = modulo(para_env%mepos - 1, para_env%num_pe)
831 DO proc_shift = 1, para_env%num_pe - 1
832 ! first exchange information on the local data
833 rec_col_row_info = 0
834 CALL para_env%sendrecv(local_col_row_info, proc_send_static, rec_col_row_info, proc_receive_static)
835 nrow_rec = rec_col_row_info(0, 1)
836 ncol_rec = rec_col_row_info(0, 2)
837
838 ALLOCATE (row_indices_rec(nrow_rec))
839 row_indices_rec = rec_col_row_info(1:nrow_rec, 1)
840
841 ALLOCATE (col_indices_rec(ncol_rec))
842 col_indices_rec = rec_col_row_info(1:ncol_rec, 2)
843
844 ALLOCATE (rec_c(nrow_rec, ncol_rec))
845 rec_c = 0.0_dp
846
847 ! then send and receive the real data
848 CALL para_env%sendrecv(local_c, proc_send_static, rec_c, proc_receive_static)
849
850 ! accumulate the received data on C buffer
851 DO iib = 1, nrow_rec
852 i_global = row_indices_rec(iib)
853 IF (i_global >= my_mu_start .AND. i_global <= my_mu_end) THEN
854 DO jjb = 1, ncol_rec
855 j_global = col_indices_rec(jjb)
856 c(i_global - my_mu_start + 1, j_global) = rec_c(iib, jjb)
857 END DO
858 END IF
859 END DO
860
861 local_col_row_info(:, :) = rec_col_row_info
862 DEALLOCATE (local_c)
863 ALLOCATE (local_c(nrow_rec, ncol_rec))
864 local_c(:, :) = rec_c
865
866 DEALLOCATE (col_indices_rec)
867 DEALLOCATE (row_indices_rec)
868 DEALLOCATE (rec_c)
869 END DO
870
871 DEALLOCATE (local_c)
872 DEALLOCATE (local_col_row_info)
873 DEALLOCATE (rec_col_row_info)
874
875 CALL timestop(handle)
876
877 END SUBROUTINE grep_rows_in_subgroups
878
879! **************************************************************************************************
880!> \brief Encapsulate the building of dbcsr_matrices mo_coeff_(v,o,all)
881!> \param para_env_sub ...
882!> \param mo_coeff_to_build ...
883!> \param Cread ...
884!> \param mat_munu ...
885!> \param gd_array ...
886!> \param eps_filter ...
887!> \author Jan Wilhelm, Code by Mauro Del Ben
888! **************************************************************************************************
889 SUBROUTINE build_dbcsr_from_rows(para_env_sub, mo_coeff_to_build, Cread, &
890 mat_munu, gd_array, eps_filter)
891 TYPE(mp_para_env_type), INTENT(IN) :: para_env_sub
892 TYPE(dbcsr_type) :: mo_coeff_to_build
893 REAL(kind=dp), DIMENSION(:, :), INTENT(IN) :: cread
894 TYPE(dbcsr_type), INTENT(INOUT) :: mat_munu
895 TYPE(group_dist_d1_type), INTENT(IN) :: gd_array
896 REAL(kind=dp), INTENT(IN) :: eps_filter
897
898 CHARACTER(LEN=*), PARAMETER :: routinen = 'build_dbcsr_from_rows'
899
900 INTEGER :: col, col_offset, col_size, handle, i, i_global, j, j_global, my_mu_end, &
901 my_mu_start, ncol_global, proc_receive, proc_send, proc_shift, rec_mu_end, rec_mu_size, &
902 rec_mu_start, row, row_offset, row_size
903 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: rec_c
904 REAL(kind=dp), DIMENSION(:, :), POINTER :: data_block
905 TYPE(dbcsr_iterator_type) :: iter
906
907 CALL timeset(routinen, handle)
908
909 ncol_global = SIZE(cread, 2)
910
911 CALL get_group_dist(gd_array, para_env_sub%mepos, my_mu_start, my_mu_end)
912
913 CALL cp_dbcsr_m_by_n_from_row_template(mo_coeff_to_build, template=mat_munu, n=ncol_global, &
914 sym=dbcsr_type_no_symmetry)
915 CALL dbcsr_reserve_all_blocks(mo_coeff_to_build)
916
917 ! accumulate data on mo_coeff_to_build starting from myself
918 CALL dbcsr_iterator_start(iter, mo_coeff_to_build)
919 DO WHILE (dbcsr_iterator_blocks_left(iter))
920 CALL dbcsr_iterator_next_block(iter, row, col, data_block, &
921 row_size=row_size, col_size=col_size, &
922 row_offset=row_offset, col_offset=col_offset)
923 DO i = 1, row_size
924 i_global = row_offset + i - 1
925 IF (i_global >= my_mu_start .AND. i_global <= my_mu_end) THEN
926 DO j = 1, col_size
927 j_global = col_offset + j - 1
928 data_block(i, j) = cread(i_global - my_mu_start + 1, col_offset + j - 1)
929 END DO
930 END IF
931 END DO
932 END DO
933 CALL dbcsr_iterator_stop(iter)
934
935 ! start ring communication in the subgroup for collecting the data from the other
936 ! proc (occupied)
937 DO proc_shift = 1, para_env_sub%num_pe - 1
938 proc_send = modulo(para_env_sub%mepos + proc_shift, para_env_sub%num_pe)
939 proc_receive = modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
940
941 CALL get_group_dist(gd_array, proc_receive, rec_mu_start, rec_mu_end, rec_mu_size)
942
943 ALLOCATE (rec_c(rec_mu_size, ncol_global))
944 rec_c = 0.0_dp
945
946 ! then send and receive the real data
947 CALL para_env_sub%sendrecv(cread, proc_send, rec_c, proc_receive)
948
949 ! accumulate data on mo_coeff_to_build the data received from proc_rec
950 CALL dbcsr_iterator_start(iter, mo_coeff_to_build)
951 DO WHILE (dbcsr_iterator_blocks_left(iter))
952 CALL dbcsr_iterator_next_block(iter, row, col, data_block, &
953 row_size=row_size, col_size=col_size, &
954 row_offset=row_offset, col_offset=col_offset)
955 DO i = 1, row_size
956 i_global = row_offset + i - 1
957 IF (i_global >= rec_mu_start .AND. i_global <= rec_mu_end) THEN
958 DO j = 1, col_size
959 j_global = col_offset + j - 1
960 data_block(i, j) = rec_c(i_global - rec_mu_start + 1, col_offset + j - 1)
961 END DO
962 END IF
963 END DO
964 END DO
965 CALL dbcsr_iterator_stop(iter)
966
967 DEALLOCATE (rec_c)
968
969 END DO
970 CALL dbcsr_filter(mo_coeff_to_build, eps_filter)
971
972 CALL timestop(handle)
973
974 END SUBROUTINE build_dbcsr_from_rows
975
976! **************************************************************************************************
977!> \brief Encapsulate the building of dbcsr_matrix mat_munu
978!> \param mat_munu ...
979!> \param qs_env ...
980!> \param eps_grid ...
981!> \param blacs_env_sub ...
982!> \param do_ri_aux_basis ...
983!> \param do_mixed_basis ...
984!> \param group_size_prim ...
985!> \param do_alloc_blocks_from_nbl ...
986!> \param do_kpoints ...
987!> \param sab_orb_sub ...
988!> \param dbcsr_sym_type ...
989!> \param custom_row_blk_sizes ...
990!> \author Jan Wilhelm, code by Mauro Del Ben
991! **************************************************************************************************
992 SUBROUTINE create_mat_munu(mat_munu, qs_env, eps_grid, blacs_env_sub, &
993 do_ri_aux_basis, do_mixed_basis, group_size_prim, &
994 do_alloc_blocks_from_nbl, do_kpoints, sab_orb_sub, dbcsr_sym_type, &
995 custom_row_blk_sizes)
996
997 TYPE(dbcsr_p_type), INTENT(OUT) :: mat_munu
998 TYPE(qs_environment_type), POINTER :: qs_env
999 REAL(kind=dp) :: eps_grid
1000 TYPE(cp_blacs_env_type), POINTER :: blacs_env_sub
1001 LOGICAL, INTENT(IN), OPTIONAL :: do_ri_aux_basis, do_mixed_basis
1002 INTEGER, INTENT(IN), OPTIONAL :: group_size_prim
1003 LOGICAL, INTENT(IN), OPTIONAL :: do_alloc_blocks_from_nbl, do_kpoints
1004 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1005 OPTIONAL, POINTER :: sab_orb_sub
1006 CHARACTER, OPTIONAL :: dbcsr_sym_type
1007 INTEGER, DIMENSION(:), INTENT(IN), OPTIONAL :: custom_row_blk_sizes
1008
1009 CHARACTER(LEN=*), PARAMETER :: routinen = 'create_mat_munu'
1010
1011 CHARACTER :: my_dbcsr_sym_type
1012 INTEGER :: handle, ikind, natom, nkind
1013 INTEGER, DIMENSION(:), POINTER :: col_blk_sizes, row_blk_sizes
1014 LOGICAL :: my_do_alloc_blocks_from_nbl, &
1015 my_do_kpoints, my_do_mixed_basis, &
1016 my_do_ri_aux_basis
1017 LOGICAL, ALLOCATABLE, DIMENSION(:) :: orb_present
1018 REAL(dp), ALLOCATABLE, DIMENSION(:) :: orb_radius
1019 REAL(dp), ALLOCATABLE, DIMENSION(:, :) :: pair_radius
1020 REAL(kind=dp) :: subcells
1021 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
1022 TYPE(cell_type), POINTER :: cell
1023 TYPE(dbcsr_distribution_type), POINTER :: dbcsr_dist_sub
1024 TYPE(dft_control_type), POINTER :: dft_control
1025 TYPE(distribution_1d_type), POINTER :: local_molecules_sub, local_particles_sub
1026 TYPE(distribution_2d_type), POINTER :: distribution_2d_sub
1027 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_ri_aux
1028 TYPE(gto_basis_set_type), POINTER :: orb_basis_set
1029 TYPE(local_atoms_type), ALLOCATABLE, DIMENSION(:) :: atom2d
1030 TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
1031 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
1032 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
1033 POINTER :: my_sab_orb_sub
1034 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1035 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
1036
1037 CALL timeset(routinen, handle)
1038
1039 NULLIFY (basis_set_ri_aux)
1040
1041 my_do_ri_aux_basis = .false.
1042 IF (PRESENT(do_ri_aux_basis)) THEN
1043 my_do_ri_aux_basis = do_ri_aux_basis
1044 END IF
1045
1046 my_do_mixed_basis = .false.
1047 IF (PRESENT(do_mixed_basis)) THEN
1048 my_do_mixed_basis = do_mixed_basis
1049 END IF
1050
1051 my_do_alloc_blocks_from_nbl = .false.
1052 IF (PRESENT(do_alloc_blocks_from_nbl)) THEN
1053 my_do_alloc_blocks_from_nbl = do_alloc_blocks_from_nbl
1054 END IF
1055
1056 my_do_kpoints = .false.
1057 IF (PRESENT(do_kpoints)) THEN
1058 my_do_kpoints = do_kpoints
1059 END IF
1060
1061 my_dbcsr_sym_type = dbcsr_type_no_symmetry
1062 IF (PRESENT(dbcsr_sym_type)) THEN
1063 my_dbcsr_sym_type = dbcsr_sym_type
1064 END IF
1065
1066 CALL get_qs_env(qs_env, &
1067 qs_kind_set=qs_kind_set, &
1068 cell=cell, &
1069 particle_set=particle_set, &
1070 atomic_kind_set=atomic_kind_set, &
1071 molecule_set=molecule_set, &
1072 molecule_kind_set=molecule_kind_set, &
1073 dft_control=dft_control)
1074
1075 IF (my_do_kpoints) THEN
1076 ! please choose EPS_PGF_ORB in QS section smaller than EPS_GRID in WFC_GPW section
1077 IF (eps_grid < dft_control%qs_control%eps_pgf_orb) THEN
1078 eps_grid = dft_control%qs_control%eps_pgf_orb
1079 cpwarn("WFC_GPW%EPS_GRID has been set to QS%EPS_PGF_ORB")
1080 END IF
1081 END IF
1082
1083 ! hack hack hack XXXXXXXXXXXXXXX ... to be fixed
1084 dft_control%qs_control%eps_pgf_orb = eps_grid
1085 dft_control%qs_control%eps_rho_rspace = eps_grid
1086 dft_control%qs_control%eps_gvg_rspace = eps_grid
1087 CALL init_interaction_radii(dft_control%qs_control, qs_kind_set)
1088
1089 ! get a distribution_1d
1090 NULLIFY (local_particles_sub, local_molecules_sub)
1091 CALL distribute_molecules_1d(atomic_kind_set=atomic_kind_set, &
1092 particle_set=particle_set, &
1093 local_particles=local_particles_sub, &
1094 molecule_kind_set=molecule_kind_set, &
1095 molecule_set=molecule_set, &
1096 local_molecules=local_molecules_sub, &
1097 force_env_section=qs_env%input)
1098
1099 ! get a distribution_2d
1100 NULLIFY (distribution_2d_sub)
1101 CALL distribute_molecules_2d(cell=cell, &
1102 atomic_kind_set=atomic_kind_set, &
1103 qs_kind_set=qs_kind_set, &
1104 particle_set=particle_set, &
1105 molecule_kind_set=molecule_kind_set, &
1106 molecule_set=molecule_set, &
1107 distribution_2d=distribution_2d_sub, &
1108 blacs_env=blacs_env_sub, &
1109 force_env_section=qs_env%input)
1110
1111 ! Build the sub orbital-orbital overlap neighbor lists
1112 CALL section_vals_val_get(qs_env%input, "DFT%SUBCELLS", r_val=subcells)
1113 nkind = SIZE(atomic_kind_set)
1114 ALLOCATE (atom2d(nkind))
1115
1116 CALL atom2d_build(atom2d, local_particles_sub, distribution_2d_sub, atomic_kind_set, &
1117 molecule_set, molecule_only=.false., particle_set=particle_set)
1118
1119 ALLOCATE (orb_present(nkind))
1120 ALLOCATE (orb_radius(nkind))
1121 ALLOCATE (pair_radius(nkind, nkind))
1122
1123 DO ikind = 1, nkind
1124 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1125 IF (ASSOCIATED(orb_basis_set)) THEN
1126 orb_present(ikind) = .true.
1127 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, kind_radius=orb_radius(ikind))
1128 ELSE
1129 orb_present(ikind) = .false.
1130 orb_radius(ikind) = 0.0_dp
1131 END IF
1132 END DO
1133
1134 CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
1135
1136 IF (PRESENT(sab_orb_sub)) THEN
1137 NULLIFY (sab_orb_sub)
1138 ! for cubic RPA/GW with kpoints, we need all neighbors and not only the symmetric ones
1139 IF (my_do_kpoints) THEN
1140 CALL build_neighbor_lists(sab_orb_sub, particle_set, atom2d, cell, pair_radius, &
1141 mic=.false., subcells=subcells, molecular=.false., nlname="sab_orb_sub", &
1142 symmetric=.false.)
1143 ELSE
1144 CALL build_neighbor_lists(sab_orb_sub, particle_set, atom2d, cell, pair_radius, &
1145 mic=.false., subcells=subcells, molecular=.false., nlname="sab_orb_sub")
1146 END IF
1147 ELSE
1148 NULLIFY (my_sab_orb_sub)
1149 ! for cubic RPA/GW with kpoints, we need all neighbors and not only the symmetric ones
1150 IF (my_do_kpoints) THEN
1151 CALL build_neighbor_lists(my_sab_orb_sub, particle_set, atom2d, cell, pair_radius, &
1152 mic=.false., subcells=subcells, molecular=.false., nlname="sab_orb_sub", &
1153 symmetric=.false.)
1154 ELSE
1155 CALL build_neighbor_lists(my_sab_orb_sub, particle_set, atom2d, cell, pair_radius, &
1156 mic=.false., subcells=subcells, molecular=.false., nlname="sab_orb_sub")
1157 END IF
1158 END IF
1159 CALL atom2d_cleanup(atom2d)
1160 DEALLOCATE (atom2d)
1161 DEALLOCATE (orb_present, orb_radius, pair_radius)
1162
1163 ! a dbcsr_dist
1164 ALLOCATE (dbcsr_dist_sub)
1165 CALL cp_dbcsr_dist2d_to_dist(distribution_2d_sub, dbcsr_dist_sub)
1166
1167 ! build a dbcsr matrix the hard way
1168 natom = SIZE(particle_set)
1169 ALLOCATE (row_blk_sizes(natom))
1170 IF (my_do_ri_aux_basis) THEN
1171 IF (PRESENT(custom_row_blk_sizes)) THEN
1172 cpassert(SIZE(custom_row_blk_sizes) == natom)
1173 row_blk_sizes(:) = custom_row_blk_sizes
1174 ELSE
1175 ALLOCATE (basis_set_ri_aux(nkind))
1176 CALL basis_set_list_setup(basis_set_ri_aux, "RI_AUX", qs_kind_set)
1177 CALL get_particle_set(particle_set, qs_kind_set, nsgf=row_blk_sizes, basis=basis_set_ri_aux)
1178 DEALLOCATE (basis_set_ri_aux)
1179 END IF
1180
1181 ELSE IF (my_do_mixed_basis) THEN
1182
1183 ALLOCATE (basis_set_ri_aux(nkind))
1184 CALL basis_set_list_setup(basis_set_ri_aux, "RI_AUX", qs_kind_set)
1185 CALL get_particle_set(particle_set, qs_kind_set, nsgf=row_blk_sizes, basis=basis_set_ri_aux)
1186 DEALLOCATE (basis_set_ri_aux)
1187
1188 ALLOCATE (col_blk_sizes(natom))
1189
1190 CALL get_particle_set(particle_set, qs_kind_set, nsgf=col_blk_sizes)
1191 col_blk_sizes = col_blk_sizes*group_size_prim
1192
1193 ELSE
1194 CALL get_particle_set(particle_set, qs_kind_set, nsgf=row_blk_sizes)
1195 END IF
1196
1197 NULLIFY (mat_munu%matrix)
1198 ALLOCATE (mat_munu%matrix)
1199
1200 IF (my_do_ri_aux_basis) THEN
1201
1202 CALL dbcsr_create(matrix=mat_munu%matrix, &
1203 name="(ai|munu)", &
1204 dist=dbcsr_dist_sub, matrix_type=my_dbcsr_sym_type, &
1205 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes)
1206
1207 ELSE IF (my_do_mixed_basis) THEN
1208
1209 CALL dbcsr_create(matrix=mat_munu%matrix, &
1210 name="(ai|munu)", &
1211 dist=dbcsr_dist_sub, matrix_type=my_dbcsr_sym_type, &
1212 row_blk_size=row_blk_sizes, col_blk_size=col_blk_sizes)
1213
1214 ELSE
1215
1216 CALL dbcsr_create(matrix=mat_munu%matrix, &
1217 name="(ai|munu)", &
1218 dist=dbcsr_dist_sub, matrix_type=my_dbcsr_sym_type, &
1219 row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes)
1220
1221 IF (my_do_alloc_blocks_from_nbl) THEN
1222
1223 IF (PRESENT(sab_orb_sub)) THEN
1224 CALL cp_dbcsr_alloc_block_from_nbl(mat_munu%matrix, sab_orb_sub)
1225 ELSE
1226 CALL cp_dbcsr_alloc_block_from_nbl(mat_munu%matrix, my_sab_orb_sub)
1227 END IF
1228
1229 END IF
1230
1231 END IF
1232
1233 DEALLOCATE (row_blk_sizes)
1234
1235 IF (my_do_mixed_basis) THEN
1236 DEALLOCATE (col_blk_sizes)
1237 END IF
1238
1239 CALL dbcsr_distribution_release(dbcsr_dist_sub)
1240 DEALLOCATE (dbcsr_dist_sub)
1241
1242 CALL distribution_2d_release(distribution_2d_sub)
1243
1244 CALL distribution_1d_release(local_particles_sub)
1245 CALL distribution_1d_release(local_molecules_sub)
1246
1247 IF (.NOT. PRESENT(sab_orb_sub)) THEN
1248 CALL release_neighbor_list_sets(my_sab_orb_sub)
1249 END IF
1250
1251 CALL timestop(handle)
1252
1253 END SUBROUTINE create_mat_munu
1254
1255! **************************************************************************************************
1256!> \brief ...
1257!> \param mat_P_global ...
1258!> \param qs_env ...
1259!> \param mp2_env ...
1260!> \param para_env ...
1261! **************************************************************************************************
1262 SUBROUTINE create_matrix_p(mat_P_global, qs_env, mp2_env, para_env)
1263
1264 TYPE(dbcsr_p_type), INTENT(OUT) :: mat_p_global
1265 TYPE(qs_environment_type), POINTER :: qs_env
1266 TYPE(mp2_type) :: mp2_env
1267 TYPE(mp_para_env_type), POINTER :: para_env
1268
1269 CHARACTER(LEN=*), PARAMETER :: routinen = 'create_matrix_P'
1270
1271 INTEGER :: blacs_grid_layout, handle
1272 LOGICAL :: blacs_repeatable
1273 TYPE(cp_blacs_env_type), POINTER :: blacs_env_global
1274
1275 CALL timeset(routinen, handle)
1276
1277 blacs_grid_layout = blacs_grid_square
1278 blacs_repeatable = .true.
1279 NULLIFY (blacs_env_global)
1280 CALL cp_blacs_env_create(blacs_env_global, para_env, &
1281 blacs_grid_layout, &
1282 blacs_repeatable)
1283
1284 CALL create_mat_munu(mat_p_global, qs_env, mp2_env%mp2_gpw%eps_grid, &
1285 blacs_env_global, do_ri_aux_basis=.true., &
1286 do_kpoints=mp2_env%ri_rpa_im_time%do_im_time_kpoints)
1287
1288 CALL dbcsr_reserve_all_blocks(mat_p_global%matrix)
1289 CALL cp_blacs_env_release(blacs_env_global)
1290
1291 CALL timestop(handle)
1292
1293 END SUBROUTINE create_matrix_p
1294
1295! **************************************************************************************************
1296!> \brief ...
1297!> \param dft_control ...
1298!> \param eps_pgf_orb_old ...
1299!> \param eps_rho_rspace_old ...
1300!> \param eps_gvg_rspace_old ...
1301! **************************************************************************************************
1302 PURE SUBROUTINE get_eps_old(dft_control, eps_pgf_orb_old, eps_rho_rspace_old, eps_gvg_rspace_old)
1303
1304 TYPE(dft_control_type), INTENT(INOUT) :: dft_control
1305 REAL(kind=dp), INTENT(OUT) :: eps_pgf_orb_old, eps_rho_rspace_old, &
1306 eps_gvg_rspace_old
1307
1308 ! re-init the radii to be able to generate pair lists with MP2-appropriate screening
1309 eps_pgf_orb_old = dft_control%qs_control%eps_pgf_orb
1310 eps_rho_rspace_old = dft_control%qs_control%eps_rho_rspace
1311 eps_gvg_rspace_old = dft_control%qs_control%eps_gvg_rspace
1312
1313 END SUBROUTINE get_eps_old
1314
1315END MODULE mp2_gpw
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Define the atomic kind types and their sub types.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
Definition cell_types.F:234
methods related to the blacs parallel environment
integer, parameter, public blacs_grid_square
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
subroutine, public cp_blacs_env_create(blacs_env, para_env, blacs_grid_layout, blacs_repeatable, row_major, grid_2d)
allocates and initializes a type that represent a blacs context
Represents a complex full matrix distributed on many processors.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_distribution_release(dist)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_init_p(matrix)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_reserve_all_blocks(matrix)
Reserves all blocks.
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_dist2d_to_dist(dist2d, dist)
Creates a DBCSR distribution from a distribution_2d.
subroutine, public cp_dbcsr_m_by_n_from_row_template(matrix, template, n, sym)
Utility function to create dbcsr matrix, m x n matrix (n arbitrary) with the same processor grid and ...
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
subroutine, public cp_logger_set(logger, local_filename, global_filename)
sets various attributes of the given logger
subroutine, public cp_rm_default_logger()
the cousin of cp_add_default_logger, decrements the stack, so that the default logger is what it has ...
subroutine, public cp_logger_release(logger)
releases this logger
subroutine, public cp_logger_create(logger, para_env, print_level, default_global_unit_nr, default_local_unit_nr, global_filename, local_filename, close_global_unit_on_dealloc, iter_info, close_local_unit_on_dealloc, suffix, template_logger)
initializes a logger
subroutine, public cp_add_default_logger(logger)
adds a default logger. MUST be called before logging occours
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
This is the start of a dbt_api, all publically needed functions are exported here....
Definition dbt_api.F:17
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public distribution_1d_release(distribution_1d)
releases the given distribution_1d
stores a mapping of 2D info (e.g. matrix) on a 2D processor distribution (i.e. blacs grid) where cpus...
subroutine, public distribution_2d_release(distribution_2d)
...
Distribution methods for atoms, particles, or molecules.
subroutine, public distribute_molecules_1d(atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, force_env_section, prev_molecule_kind_set, prev_local_molecules)
Distribute molecules and particles.
subroutine, public distribute_molecules_2d(cell, atomic_kind_set, particle_set, qs_kind_set, molecule_kind_set, molecule_set, distribution_2d, blacs_env, force_env_section)
Distributes the particle pairs creating a 2d distribution optimally suited for quickstep.
Types to describe group distributions.
Types and set/get functions for HFX.
Definition hfx_types.F:16
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public rpa_exchange_none
integer, parameter, public do_eri_os
integer, parameter, public ri_mp2_method_gpw
integer, parameter, public do_potential_truncated
integer, parameter, public mp2_method_gpw
integer, parameter, public do_potential_id
integer, parameter, public eri_default
integer, parameter, public ri_default
integer, parameter, public do_potential_coulomb
integer, parameter, public do_eri_gpw
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
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.
Machine interface based on Fortran 2003 and POSIX.
Definition machine.F:17
integer, parameter, public default_output_unit
Definition machine.F:48
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition machine.F:127
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
Define the molecule kind structure types and the corresponding functionality.
Define the data structure for the molecule information.
Routines to calculate CPHF like update and solve Z-vector equation for MP2 gradients (only GPW).
Definition mp2_cphf.F:14
subroutine, public solve_z_vector_eq(qs_env, mp2_env, para_env, dft_control, mo_coeff, homo, eigenval, unit_nr)
Solve Z-vector equations necessary for the calculation of the MP2 gradients, in order to be consisten...
Definition mp2_cphf.F:155
Routines to calculate MP2 energy using GPW method.
subroutine, public mp2_gpw_compute(emp2, emp2_cou, emp2_ex, qs_env, para_env, para_env_sub, color_sub, cell, particle_set, atomic_kind_set, qs_kind_set, eigenval, nmo, homo, mat_munu, sab_orb_sub, mo_coeff_o, mo_coeff_v, eps_filter, unit_nr, mp2_memory, calc_ex, blacs_env_sub, emp2_ab)
...
Calls routines to get RI integrals and calculate total energies.
Definition mp2_gpw.F:14
subroutine, public mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_mp2, do_ri_rpa, do_ri_sos_laplace_mp2)
with a big bang to mp2
Definition mp2_gpw.F:130
subroutine, public grep_rows_in_subgroups(para_env, para_env_sub, mo_coeff, gd_array, c)
...
Definition mp2_gpw.F:763
subroutine, public build_dbcsr_from_rows(para_env_sub, mo_coeff_to_build, cread, mat_munu, gd_array, eps_filter)
Encapsulate the building of dbcsr_matrices mo_coeff_(v,o,all).
Definition mp2_gpw.F:891
subroutine, public create_mat_munu(mat_munu, qs_env, eps_grid, blacs_env_sub, do_ri_aux_basis, do_mixed_basis, group_size_prim, do_alloc_blocks_from_nbl, do_kpoints, sab_orb_sub, dbcsr_sym_type, custom_row_blk_sizes)
Encapsulate the building of dbcsr_matrix mat_munu.
Definition mp2_gpw.F:996
Routines to calculate and distribute 2c- and 3c- integrals for RI.
subroutine, public 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, fm_matrix_pq, cfm_matrix_l_kpoints, cfm_matrix_minv_l_kpoints, fm_matrix_minv_l_gamma, 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, mo_coeff_o_bse, mo_coeff_v_bse, eps_filter, unit_nr, mp2_memory, calc_pq_cond_num, calc_forces, blacs_env_sub, my_do_gw, do_bse, gd_b_all, starts_array_mc, ends_array_mc, starts_array_mc_block, ends_array_mc_block, gw_corr_lev_occ, gw_corr_lev_virt, bse_lev_virt, do_im_time, do_kpoints_cubic_rpa, kpoints, t_3c_m, t_3c_o, t_3c_o_compressed, t_3c_o_ind, ri_metric, gd_b_occ_bse, gd_b_virt_bse)
with ri mp2 gpw
Routines to calculate RI-GPW-MP2 energy using pw.
Definition mp2_ri_gpw.F:14
subroutine, public mp2_ri_gpw_compute_en(emp2_cou, emp2_ex, emp2_s, emp2_t, bib_c, mp2_env, para_env, para_env_sub, color_sub, gd_array, gd_b_virtual, eigenval, nmo, homo, dimen_ri, unit_nr, calc_forces, calc_ex)
...
Definition mp2_ri_gpw.F:75
Routines to calculate gradients of RI-GPW-MP2 energy using pw.
Definition mp2_ri_grad.F:13
subroutine, public calc_ri_mp2_nonsep(qs_env, mp2_env, para_env, para_env_sub, cell, particle_set, atomic_kind_set, qs_kind_set, mo_coeff, dimen_ri, eigenval, my_group_l_start, my_group_l_end, my_group_l_size, sab_orb_sub, mat_munu, blacs_env_sub)
Calculate the non-separable part of the gradients and update the Lagrangian.
Types needed for MP2 calculations.
Definition mp2_types.F:14
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis, ncgf)
Get the components of a particle set.
Define the data structure for the particle information.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
Calculate the interaction radii for the operator matrix calculation.
subroutine, public init_interaction_radii(qs_control, qs_kind_set)
Initialize all the atomic kind radii for a given threshold value.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count, cmo_coeff)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
subroutine, public release_neighbor_list_sets(nlists)
releases an array of neighbor_list_sets
Generate the atomic neighbor lists.
subroutine, public atom2d_cleanup(atom2d)
free the internals of atom2d
subroutine, public pair_radius_setup(present_a, present_b, radius_a, radius_b, pair_radius, prmin)
...
subroutine, public build_neighbor_lists(ab_list, particle_set, atom, cell, pair_radius, subcells, mic, symmetric, molecular, subset_of_mol, current_subset, operator_type, nlname, atomb_to_keep, stable_images)
Build simple pair neighbor lists.
subroutine, public atom2d_build(atom2d, distribution_1d, distribution_2d, atomic_kind_set, molecule_set, molecule_only, particle_set)
Build some distribution structure of atoms, refactored from build_qs_neighbor_lists.
Routines to calculate RI-RPA energy.
Definition rpa_main.F:17
subroutine, public rpa_ri_compute_en(qs_env, erpa, 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, cfm_matrix_l_kpoints, cfm_matrix_minv_l_kpoints, fm_matrix_minv_l_gamma, 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, bse_lev_virt, unit_nr, do_ri_sos_laplace_mp2, my_do_gw, do_im_time, do_bse, matrix_s, mat_munu, mat_p_global, t_3c_m, t_3c_o, t_3c_o_compressed, t_3c_o_ind, starts_array_mc, ends_array_mc, starts_array_mc_block, ends_array_mc_block, calc_forces)
...
Definition rpa_main.F:206
Routines to compute singles correction to RPA (RSE).
Definition rpa_rse.F:14
subroutine, public rse_energy(qs_env, mp2_env, para_env, dft_control, mo_coeff, homo, eigenval)
Single excitations energy corrections for RPA.
Definition rpa_rse.F:93
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
Represent a complex full matrix.
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
structure to store local (to a processor) ordered lists of integers.
distributes pairs on a 2d grid of processors
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...