(git:0de0cc2)
mp2_gpw.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 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 ! **************************************************************************************************
14 MODULE mp2_gpw
15  USE atomic_kind_types, ONLY: atomic_kind_type
17  gto_basis_set_p_type,&
18  gto_basis_set_type
19  USE cell_types, ONLY: cell_type,&
20  get_cell
21  USE cp_blacs_env, ONLY: blacs_grid_square,&
24  cp_blacs_env_type
25  USE cp_control_types, ONLY: dft_control_type
29  USE cp_fm_types, ONLY: cp_fm_get_info,&
30  cp_fm_release,&
31  cp_fm_type
32  USE cp_log_handling, ONLY: &
35  cp_rm_default_logger, cp_to_string
36  USE dbcsr_api, ONLY: &
37  dbcsr_clear_mempools, dbcsr_copy, dbcsr_create, dbcsr_distribution_release, &
38  dbcsr_distribution_type, dbcsr_filter, dbcsr_init_p, dbcsr_iterator_blocks_left, &
39  dbcsr_iterator_next_block, dbcsr_iterator_start, dbcsr_iterator_stop, dbcsr_iterator_type, &
40  dbcsr_p_type, dbcsr_release, dbcsr_reserve_all_blocks, dbcsr_type, dbcsr_type_no_symmetry, &
41  dbcsr_type_real_default, dbcsr_type_symmetric
42  USE dbt_api, ONLY: dbt_type
44  distribution_1d_type
46  distribution_2d_type
49  USE group_dist_types, ONLY: create_group_dist,&
50  get_group_dist,&
51  group_dist_d1_type,&
52  release_group_dist
53  USE hfx_types, ONLY: block_ind_type,&
54  hfx_compression_type
55  USE input_constants, ONLY: &
59  USE kinds, ONLY: dp
60  USE kpoint_types, ONLY: kpoint_type
63  USE machine, ONLY: default_output_unit,&
64  m_flush
66  mp_para_env_type
67  USE molecule_kind_types, ONLY: molecule_kind_type
68  USE molecule_types, ONLY: molecule_type
69  USE mp2_cphf, ONLY: solve_z_vector_eq
74  USE mp2_types, ONLY: mp2_type,&
75  three_dim_real_array
77  USE particle_types, ONLY: particle_type
78  USE qs_environment_types, ONLY: get_qs_env,&
79  qs_environment_type
82  USE qs_kind_types, ONLY: get_qs_kind,&
83  qs_kind_type
84  USE qs_ks_types, ONLY: qs_ks_env_type
85  USE qs_mo_types, ONLY: get_mo_set,&
86  mo_set_type
87  USE qs_neighbor_list_types, ONLY: neighbor_list_set_p_type,&
89  USE qs_neighbor_lists, ONLY: atom2d_build,&
92  local_atoms_type,&
94  USE rpa_main, ONLY: rpa_ri_compute_en
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 
106 CONTAINS
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, dimen_ri, dimen_ri_red, eri_method, handle, &
143  ispin, 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(:) :: ends_array_mc, ends_array_mc_block, gw_corr_lev_occ, &
146  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), ALLOCATABLE, DIMENSION(:, :, :) :: bib_c_bse_ab, bib_c_bse_ij
155  REAL(kind=dp), DIMENSION(:), POINTER :: mo_eigenvalues
156  TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
157  TYPE(block_ind_type), ALLOCATABLE, &
158  DIMENSION(:, :, :) :: t_3c_o_ind
159  TYPE(cell_type), POINTER :: cell
160  TYPE(cp_blacs_env_type), POINTER :: blacs_env_sub, blacs_env_sub_mat_munu
161  TYPE(cp_fm_type) :: fm_matrix_pq
162  TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: mo_coeff
163  TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_matrix_l_kpoints, fm_matrix_minv, &
164  fm_matrix_minv_l_kpoints, &
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_v
171  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
172  TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_s_kp
173  TYPE(dbt_type) :: t_3c_m
174  TYPE(dbt_type), ALLOCATABLE, DIMENSION(:, :) :: t_3c_o
175  TYPE(dft_control_type), POINTER :: dft_control
176  TYPE(group_dist_d1_type) :: gd_array, gd_b_all, gd_b_occ_bse, &
177  gd_b_virt_bse
178  TYPE(group_dist_d1_type), ALLOCATABLE, &
179  DIMENSION(:) :: 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(mo_set_type), DIMENSION(:), POINTER :: mos
184  TYPE(mp_para_env_type), POINTER :: para_env_sub
185  TYPE(neighbor_list_set_p_type), DIMENSION(:), &
186  POINTER :: sab_orb_sub
187  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
188  TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
189  TYPE(qs_ks_env_type), POINTER :: ks_env
190  TYPE(three_dim_real_array), ALLOCATABLE, &
191  DIMENSION(:) :: bib_c, 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%ri_g0w0%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  mos(1:nspins) => kpoints_from_dft%kp_env(1)%kpoint_env%mos(1:nspins, 1)
228  ELSE
229  CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, mos=mos)
230  END IF
231  CALL get_mo_set(mo_set=mos_mp2(1), nao=dimen)
232  ALLOCATE (homo(nspins), eigenval(dimen, nspins), mo_coeff(nspins))
233  DO ispin = 1, nspins
234  CALL get_mo_set(mo_set=mos_mp2(ispin), &
235  eigenvalues=mo_eigenvalues, nmo=nmo, homo=homo(ispin), &
236  mo_coeff=mo_coeff_ptr)
237  mo_coeff(ispin) = mo_coeff_ptr
238  eigenval(:, ispin) = mo_eigenvalues(:)
239  END DO
240 
241  ! a para_env
242  color_sub = para_env%mepos/mp2_env%mp2_num_proc
243  ALLOCATE (para_env_sub)
244  CALL para_env_sub%from_split(para_env, color_sub)
245 
246  ! each of the sub groups might need to generate output
247  logger => cp_get_default_logger()
248  IF (para_env%is_source()) THEN
249  local_unit_nr = cp_logger_get_default_unit_nr(logger, local=.false.)
250  ELSE
251  local_unit_nr = default_output_unit
252  END IF
253 
254  ! get stuff
255  CALL get_qs_env(qs_env, &
256  ks_env=ks_env, &
257  qs_kind_set=qs_kind_set, &
258  cell=cell, &
259  particle_set=particle_set, &
260  atomic_kind_set=atomic_kind_set, &
261  dft_control=dft_control, &
262  matrix_s_kp=matrix_s_kp)
263 
264  CALL get_cell(cell=cell, periodic=periodic)
265 
266  IF (do_im_time) THEN
267 
268  IF (mp2_env%ri_metric%potential_type == ri_default) THEN
269  IF (sum(periodic) == 1 .OR. sum(periodic) == 3) THEN
270  mp2_env%ri_metric%potential_type = do_potential_id
271  ELSE
272  mp2_env%ri_metric%potential_type = do_potential_truncated
273  END IF
274  END IF
275 
276  ! statically initialize libint
277  CALL cp_libint_static_init()
278 
279  END IF
280 
281  IF (mp2_env%ri_metric%potential_type == ri_default) THEN
282  mp2_env%ri_metric%potential_type = do_potential_coulomb
283  END IF
284 
285  IF (mp2_env%eri_method == eri_default) THEN
286  IF (sum(periodic) > 0) mp2_env%eri_method = do_eri_gpw
287  IF (sum(periodic) == 0) mp2_env%eri_method = do_eri_os
288  IF (sum(mp2_env%ri_rpa_im_time%kp_grid) > 0) mp2_env%eri_method = do_eri_os
289  IF (mp2_env%method == mp2_method_gpw) mp2_env%eri_method = do_eri_gpw
290  IF (mp2_env%method == ri_mp2_method_gpw) mp2_env%eri_method = do_eri_gpw
291  IF (mp2_env%ri_rpa_im_time%do_im_time_kpoints) mp2_env%eri_method = do_eri_os
292  IF (calc_forces .AND. mp2_env%eri_method == do_eri_os) mp2_env%eri_method = do_eri_gpw
293  END IF
294  eri_method = mp2_env%eri_method
295 
296  IF (unit_nr > 0 .AND. mp2_env%eri_method == do_eri_gpw) THEN
297  WRITE (unit=unit_nr, fmt="(T3,A,T71,F10.1)") &
298  "GPW_INFO| Density cutoff [a.u.]:", mp2_env%mp2_gpw%cutoff*0.5_dp
299  WRITE (unit=unit_nr, fmt="(T3,A,T71,F10.1)") &
300  "GPW_INFO| Relative density cutoff [a.u.]:", mp2_env%mp2_gpw%relative_cutoff*0.5_dp
301  CALL m_flush(unit_nr)
302  END IF
303 
304  IF (.NOT. mp2_env%ri_g0w0%print_local_bandgap) THEN
305  ! a logger
306  NULLIFY (logger_sub)
307  CALL cp_logger_create(logger_sub, para_env=para_env_sub, &
308  default_global_unit_nr=local_unit_nr, close_global_unit_on_dealloc=.false.)
309  CALL cp_logger_set(logger_sub, local_filename="MP2_localLog")
310  ! set to a custom print level (we could also have a different print level for para_env%source)
311  logger_sub%iter_info%print_level = mp2_env%mp2_gpw%print_level
312  CALL cp_add_default_logger(logger_sub)
313  END IF
314 
315  ! a blacs_env (ignore the globenv stored defaults for now)
316  blacs_grid_layout = blacs_grid_square
317  blacs_repeatable = .true.
318  NULLIFY (blacs_env_sub)
319  CALL cp_blacs_env_create(blacs_env_sub, para_env_sub, &
320  blacs_grid_layout, &
321  blacs_repeatable)
322 
323  blacs_env_sub_mat_munu => blacs_env_sub
324 
325  matrix_s(1:1) => matrix_s_kp(1:1, 1)
326 
327  CALL get_eps_old(dft_control, eps_pgf_orb_old, eps_rho_rspace_old, eps_gvg_rspace_old)
328 
329  CALL create_mat_munu(mat_munu, qs_env, mp2_env%mp2_gpw%eps_grid, &
330  blacs_env_sub_mat_munu, do_alloc_blocks_from_nbl=.NOT. do_im_time, sab_orb_sub=sab_orb_sub, &
331  do_kpoints=mp2_env%ri_rpa_im_time%do_im_time_kpoints, &
332  dbcsr_sym_type=dbcsr_type_symmetric)
333 
334  ! which RI metric we want to have
335  ri_metric_type = mp2_env%ri_metric%potential_type
336 
337  ! which interaction potential
338  potential_type = mp2_env%potential_parameter%potential_type
339 
340  ! check if we want to do ri-g0w0 on top of ri-rpa
341  my_do_gw = mp2_env%ri_rpa%do_ri_g0w0
342  ALLOCATE (gw_corr_lev_occ(nspins), gw_corr_lev_virt(nspins))
343  gw_corr_lev_occ(1) = mp2_env%ri_g0w0%corr_mos_occ
344  gw_corr_lev_virt(1) = mp2_env%ri_g0w0%corr_mos_virt
345  IF (nspins == 2) THEN
346  gw_corr_lev_occ(2) = mp2_env%ri_g0w0%corr_mos_occ_beta
347  gw_corr_lev_virt(2) = mp2_env%ri_g0w0%corr_mos_virt_beta
348  END IF
349 
350  ! After the components are inside of the routines, we can move this line insight the branch
351  ALLOCATE (mo_coeff_o(nspins), mo_coeff_v(nspins), mo_coeff_all(nspins), mo_coeff_gw(nspins))
352 
353  ! for imag. time, we do not need this
354  IF (.NOT. do_im_time) THEN
355 
356  ! new routine: replicate a full matrix from one para_env to a smaller one
357  ! keeping the memory usage as small as possible in this case the
358  ! output the two part of the C matrix (virtual, occupied)
359  DO ispin = 1, nspins
360 
361  CALL replicate_mat_to_subgroup(para_env, para_env_sub, mo_coeff(ispin), dimen, homo(ispin), mat_munu%matrix, &
362  mo_coeff_o(ispin)%matrix, mo_coeff_v(ispin)%matrix, &
363  mo_coeff_all(ispin)%matrix, mo_coeff_gw(ispin)%matrix, &
364  my_do_gw, gw_corr_lev_occ(ispin), gw_corr_lev_virt(ispin), mp2_env%mp2_gpw%eps_filter)
365  END DO
366 
367  END IF
368 
369  ! now we're kind of ready to go....
370  emp2_s = 0.0_dp
371  emp2_t = 0.0_dp
372  IF (my_do_ri_mp2 .OR. my_do_ri_rpa .OR. my_do_ri_sos_laplace_mp2) THEN
373  ! RI-GPW integrals (same stuff for both RPA and MP2)
374  IF (nspins == 2) THEN
375  ! open shell case (RI) here the (ia|K) integrals are computed for both the alpha and beta components
376  CALL mp2_ri_gpw_compute_in( &
377  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, &
378  para_env, para_env_sub, color_sub, cell, particle_set, &
379  atomic_kind_set, qs_kind_set, mo_coeff, fm_matrix_pq, fm_matrix_l_kpoints, fm_matrix_minv_l_kpoints, &
380  fm_matrix_minv, fm_matrix_minv_vtrunc_minv, nmo, homo, mat_munu, sab_orb_sub, &
381  mo_coeff_o, mo_coeff_v, mo_coeff_all, mo_coeff_gw, &
382  mp2_env%mp2_gpw%eps_filter, unit_nr, &
383  mp2_env%mp2_memory, mp2_env%calc_PQ_cond_num, calc_forces, blacs_env_sub, my_do_gw .AND. .NOT. do_im_time, &
384  do_bse, gd_b_all, starts_array_mc, ends_array_mc, starts_array_mc_block, ends_array_mc_block, &
385  gw_corr_lev_occ(1), gw_corr_lev_virt(1), &
386  do_im_time, do_kpoints_cubic_rpa, kpoints, &
387  t_3c_m, t_3c_o, t_3c_o_compressed, t_3c_o_ind, &
388  mp2_env%ri_metric, &
389  gd_b_occ_bse, gd_b_virt_bse)
390  ELSE
391  ! closed shell case (RI)
392  CALL mp2_ri_gpw_compute_in(bib_c, bib_c_gw, bib_c_bse_ij, bib_c_bse_ab, gd_array, gd_b_virtual, &
393  dimen_ri, dimen_ri_red, qs_env, para_env, para_env_sub, &
394  color_sub, cell, particle_set, &
395  atomic_kind_set, qs_kind_set, mo_coeff, fm_matrix_pq, &
396  fm_matrix_l_kpoints, fm_matrix_minv_l_kpoints, &
397  fm_matrix_minv, fm_matrix_minv_vtrunc_minv, nmo, homo, &
398  mat_munu, sab_orb_sub, &
399  mo_coeff_o, mo_coeff_v, mo_coeff_all, mo_coeff_gw, &
400  mp2_env%mp2_gpw%eps_filter, unit_nr, &
401  mp2_env%mp2_memory, mp2_env%calc_PQ_cond_num, calc_forces, &
402  blacs_env_sub, my_do_gw .AND. .NOT. do_im_time, do_bse, gd_b_all, &
403  starts_array_mc, ends_array_mc, &
404  starts_array_mc_block, ends_array_mc_block, &
405  gw_corr_lev_occ(1), gw_corr_lev_virt(1), &
406  do_im_time, do_kpoints_cubic_rpa, kpoints, &
407  t_3c_m, t_3c_o, t_3c_o_compressed, t_3c_o_ind, &
408  mp2_env%ri_metric, gd_b_occ_bse, gd_b_virt_bse)
409  END IF
410 
411  ELSE
412  ! Canonical MP2-GPW
413  IF (nspins == 2) THEN
414  ! alpha-alpha and alpha-beta components
415  IF (unit_nr > 0) WRITE (unit_nr, *)
416  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Alpha (ia|'
417  CALL mp2_gpw_compute( &
418  emp2, emp2_cou, emp2_ex, qs_env, para_env, para_env_sub, color_sub, &
419  cell, particle_set, &
420  atomic_kind_set, qs_kind_set, mo_coeff(1), eigenval, nmo, homo, mat_munu, &
421  sab_orb_sub, mo_coeff_o, mo_coeff_v, mp2_env%mp2_gpw%eps_filter, unit_nr, &
422  mp2_env%mp2_memory, calc_ex, blacs_env_sub, emp2_ab)
423 
424  ! beta-beta component
425  IF (unit_nr > 0) WRITE (unit_nr, *)
426  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Beta (ia|'
427  CALL mp2_gpw_compute( &
428  emp2_bb, emp2_cou_bb, emp2_ex_bb, qs_env, para_env, para_env_sub, color_sub, cell, particle_set, &
429  atomic_kind_set, qs_kind_set, mo_coeff(2), eigenval(:, 2:2), nmo, homo(2:2), mat_munu, &
430  sab_orb_sub, mo_coeff_o(2:2), mo_coeff_v(2:2), mp2_env%mp2_gpw%eps_filter, unit_nr, &
431  mp2_env%mp2_memory, calc_ex, blacs_env_sub)
432 
433  ! make order on the MP2 energy contributions
434  emp2_cou = emp2_cou*0.25_dp
435  emp2_ex = emp2_ex*0.5_dp
436 
437  emp2_cou_bb = emp2_cou_bb*0.25_dp
438  emp2_ex_bb = emp2_ex_bb*0.5_dp
439 
440  emp2_s = emp2_ab
441  emp2_t = emp2_cou + emp2_cou_bb + emp2_ex + emp2_ex_bb
442 
443  emp2_cou = emp2_cou + emp2_cou_bb + emp2_ab
444  emp2_ex = emp2_ex + emp2_ex_bb
445  emp2 = emp2_ex + emp2_cou
446 
447  ELSE
448  ! closed shell case
449  CALL mp2_gpw_compute( &
450  emp2, emp2_cou, emp2_ex, qs_env, para_env, para_env_sub, color_sub, cell, particle_set, &
451  atomic_kind_set, qs_kind_set, mo_coeff(1), eigenval(:, 1:1), nmo, homo(1:1), mat_munu, &
452  sab_orb_sub, mo_coeff_o(1:1), mo_coeff_v(1:1), mp2_env%mp2_gpw%eps_filter, unit_nr, &
453  mp2_env%mp2_memory, calc_ex, blacs_env_sub)
454  END IF
455  END IF
456 
457  ! Free possibly large buffers allocated by dbcsr on the GPU,
458  ! large hybrid dgemm/pdgemm's coming later will need the space.
459  CALL dbcsr_clear_mempools()
460 
461  IF (calc_forces .AND. .NOT. do_im_time) THEN
462  ! make a copy of mo_coeff_o and mo_coeff_v
463  ALLOCATE (mp2_env%ri_grad%mo_coeff_o(nspins), mp2_env%ri_grad%mo_coeff_v(nspins))
464  DO ispin = 1, nspins
465  NULLIFY (mp2_env%ri_grad%mo_coeff_o(ispin)%matrix)
466  CALL dbcsr_init_p(mp2_env%ri_grad%mo_coeff_o(ispin)%matrix)
467  CALL dbcsr_copy(mp2_env%ri_grad%mo_coeff_o(ispin)%matrix, mo_coeff_o(ispin)%matrix, &
468  name="mo_coeff_o"//cp_to_string(ispin))
469  NULLIFY (mp2_env%ri_grad%mo_coeff_v(ispin)%matrix)
470  CALL dbcsr_init_p(mp2_env%ri_grad%mo_coeff_v(ispin)%matrix)
471  CALL dbcsr_copy(mp2_env%ri_grad%mo_coeff_v(ispin)%matrix, mo_coeff_v(ispin)%matrix, &
472  name="mo_coeff_v"//cp_to_string(ispin))
473  END DO
474  CALL get_group_dist(gd_array, color_sub, my_group_l_start, my_group_l_end, my_group_l_size)
475  END IF
476  ! Copy mo coeffs for RPA AXK
477  IF (mp2_env%ri_rpa%do_ri_axk) THEN
478  NULLIFY (mp2_env%ri_rpa%mo_coeff_o)
479  CALL dbcsr_init_p(mp2_env%ri_rpa%mo_coeff_o)
480  CALL dbcsr_copy(mp2_env%ri_rpa%mo_coeff_o, mo_coeff_o(1)%matrix, name="mo_coeff_o")
481  NULLIFY (mp2_env%ri_rpa%mo_coeff_v)
482  CALL dbcsr_init_p(mp2_env%ri_rpa%mo_coeff_v)
483  CALL dbcsr_copy(mp2_env%ri_rpa%mo_coeff_v, mo_coeff_v(1)%matrix, name="mo_coeff_v")
484  END IF
485 
486  IF (.NOT. do_im_time) THEN
487 
488  DO ispin = 1, nspins
489  CALL dbcsr_release(mo_coeff_o(ispin)%matrix)
490  DEALLOCATE (mo_coeff_o(ispin)%matrix)
491  CALL dbcsr_release(mo_coeff_v(ispin)%matrix)
492  DEALLOCATE (mo_coeff_v(ispin)%matrix)
493  IF (my_do_gw) THEN
494  CALL dbcsr_release(mo_coeff_all(ispin)%matrix)
495  DEALLOCATE (mo_coeff_all(ispin)%matrix)
496  END IF
497  END DO
498  DEALLOCATE (mo_coeff_o, mo_coeff_v)
499  IF (my_do_gw) DEALLOCATE (mo_coeff_all)
500 
501  END IF
502 
503  IF (.NOT. calc_forces) THEN
504  IF (.NOT. mp2_env%ri_rpa%do_ri_axk) THEN
505 
506  CALL dbcsr_release(mat_munu%matrix)
507  DEALLOCATE (mat_munu%matrix)
508 
509  CALL release_neighbor_list_sets(sab_orb_sub)
510 
511  END IF
512 
513  END IF
514 
515  ! decide if to do RI-RPA or RI-MP2
516  IF (my_do_ri_rpa .OR. my_do_ri_sos_laplace_mp2) THEN
517 
518  IF (do_im_time) THEN
519 
520  CALL create_matrix_p(mat_p_global, qs_env, mp2_env, para_env)
521 
522  ! To be removed later
523  ALLOCATE (bib_c(nspins))
524  END IF
525 
526  IF (.NOT. ALLOCATED(bib_c)) ALLOCATE (bib_c(nspins))
527  IF (.NOT. ALLOCATED(bib_c_gw)) ALLOCATE (bib_c_gw(nspins))
528  IF (.NOT. ALLOCATED(gd_b_virtual)) ALLOCATE (gd_b_virtual(nspins))
529 
530  ! RI-RPA
531  CALL rpa_ri_compute_en(qs_env, emp2, mp2_env, bib_c, bib_c_gw, bib_c_bse_ij, bib_c_bse_ab, &
532  para_env, para_env_sub, color_sub, &
533  gd_array, gd_b_virtual, gd_b_all, gd_b_occ_bse, gd_b_virt_bse, &
534  mo_coeff, fm_matrix_pq, fm_matrix_l_kpoints, fm_matrix_minv_l_kpoints, &
535  fm_matrix_minv, fm_matrix_minv_vtrunc_minv, kpoints, &
536  eigenval, nmo, homo, dimen_ri, dimen_ri_red, gw_corr_lev_occ, gw_corr_lev_virt, &
537  unit_nr, my_do_ri_sos_laplace_mp2, my_do_gw, do_im_time, do_bse, matrix_s, &
538  mat_munu, mat_p_global, &
539  t_3c_m, t_3c_o, t_3c_o_compressed, t_3c_o_ind, &
540  starts_array_mc, ends_array_mc, &
541  starts_array_mc_block, ends_array_mc_block, calc_forces)
542 
543  IF (mp2_env%ri_rpa%do_rse) &
544  CALL rse_energy(qs_env, mp2_env, para_env, dft_control, mo_coeff, nmo, homo, eigenval)
545 
546  IF (do_im_time) THEN
547  IF (ASSOCIATED(mat_p_global%matrix)) THEN
548  CALL dbcsr_release(mat_p_global%matrix)
549  DEALLOCATE (mat_p_global%matrix)
550  END IF
551 
553  IF (calc_forces) CALL cp_fm_release(fm_matrix_pq)
554  END IF
555 
556  ! Release some memory for AXK
557  IF (mp2_env%ri_rpa%do_ri_axk .OR. (calc_forces .AND. do_im_time)) THEN
558 
559  CALL dbcsr_release(mat_munu%matrix)
560  DEALLOCATE (mat_munu%matrix)
561 
562  CALL release_neighbor_list_sets(sab_orb_sub)
563 
564  END IF
565 
566  ELSE
567  IF (my_do_ri_mp2) THEN
568  emp2 = 0.0_dp
569  emp2_cou = 0.0_dp
570  emp2_ex = 0.0_dp
571 
572  ! RI-MP2-GPW compute energy
573  CALL mp2_ri_gpw_compute_en( &
574  emp2_cou, emp2_ex, emp2_s, emp2_t, bib_c, mp2_env, para_env, para_env_sub, color_sub, &
575  gd_array, gd_b_virtual, &
576  eigenval, nmo, homo, dimen_ri_red, unit_nr, calc_forces, calc_ex)
577 
578  END IF
579  END IF
580 
581  ! if we need forces time to calculate the MP2 non-separable contribution
582  ! and start computing the Lagrangian
583  IF (calc_forces .AND. .NOT. do_im_time) THEN
584 
585  CALL calc_ri_mp2_nonsep(qs_env, mp2_env, para_env, para_env_sub, cell, &
586  particle_set, atomic_kind_set, qs_kind_set, &
587  mo_coeff, nmo, homo, dimen_ri, eigenval, &
588  my_group_l_start, my_group_l_end, my_group_l_size, &
589  sab_orb_sub, mat_munu, blacs_env_sub)
590 
591  DO ispin = 1, nspins
592  CALL dbcsr_release(mp2_env%ri_grad%mo_coeff_o(ispin)%matrix)
593  DEALLOCATE (mp2_env%ri_grad%mo_coeff_o(ispin)%matrix)
594 
595  CALL dbcsr_release(mp2_env%ri_grad%mo_coeff_v(ispin)%matrix)
596  DEALLOCATE (mp2_env%ri_grad%mo_coeff_v(ispin)%matrix)
597  END DO
598  DEALLOCATE (mp2_env%ri_grad%mo_coeff_o, mp2_env%ri_grad%mo_coeff_v)
599 
600  CALL dbcsr_release(mat_munu%matrix)
601  DEALLOCATE (mat_munu%matrix)
602 
603  CALL release_neighbor_list_sets(sab_orb_sub)
604 
605  END IF
606 
607  !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
608  ! moved from above
609  IF (my_do_gw .AND. .NOT. do_im_time) THEN
610  DO ispin = 1, nspins
611  CALL dbcsr_release(mo_coeff_gw(ispin)%matrix)
612  DEALLOCATE (mo_coeff_gw(ispin)%matrix)
613  END DO
614  DEALLOCATE (mo_coeff_gw)
615  END IF
616 
617  ! re-init the radii to be able to generate pair lists with MP2-appropriate screening
618  dft_control%qs_control%eps_pgf_orb = eps_pgf_orb_old
619  dft_control%qs_control%eps_rho_rspace = eps_rho_rspace_old
620  dft_control%qs_control%eps_gvg_rspace = eps_gvg_rspace_old
621  CALL init_interaction_radii(dft_control%qs_control, qs_kind_set)
622 
623  CALL cp_blacs_env_release(blacs_env_sub)
624 
625  IF (.NOT. mp2_env%ri_g0w0%print_local_bandgap) THEN
626  CALL cp_rm_default_logger()
627  CALL cp_logger_release(logger_sub)
628  END IF
629 
630  CALL mp_para_env_release(para_env_sub)
631 
632  ! finally solve the z-vector equation if forces are required
633  IF (calc_forces .AND. .NOT. do_im_time) THEN
634  CALL solve_z_vector_eq(qs_env, mp2_env, para_env, dft_control, &
635  mo_coeff, nmo, homo, eigenval, unit_nr)
636  END IF
637 
638  DEALLOCATE (eigenval, mo_coeff)
639 
640  CALL timestop(handle)
641 
642  END SUBROUTINE mp2_gpw_main
643 
644 ! **************************************************************************************************
645 !> \brief ...
646 !> \param para_env ...
647 !> \param para_env_sub ...
648 !> \param mo_coeff ...
649 !> \param dimen ...
650 !> \param homo ...
651 !> \param mat_munu ...
652 !> \param mo_coeff_o ...
653 !> \param mo_coeff_v ...
654 !> \param mo_coeff_all ...
655 !> \param mo_coeff_gw ...
656 !> \param my_do_gw ...
657 !> \param gw_corr_lev_occ ...
658 !> \param gw_corr_lev_virt ...
659 !> \param eps_filter ...
660 ! **************************************************************************************************
661  SUBROUTINE replicate_mat_to_subgroup(para_env, para_env_sub, mo_coeff, dimen, homo, mat_munu, &
662  mo_coeff_o, mo_coeff_v, mo_coeff_all, mo_coeff_gw, my_do_gw, &
663  gw_corr_lev_occ, gw_corr_lev_virt, eps_filter)
664  TYPE(mp_para_env_type), INTENT(IN) :: para_env, para_env_sub
665  TYPE(cp_fm_type), INTENT(IN) :: mo_coeff
666  INTEGER, INTENT(IN) :: dimen, homo
667  TYPE(dbcsr_type), INTENT(INOUT) :: mat_munu
668  TYPE(dbcsr_type), POINTER :: mo_coeff_o, mo_coeff_v, mo_coeff_all, &
669  mo_coeff_gw
670  LOGICAL, INTENT(IN) :: my_do_gw
671  INTEGER, INTENT(IN) :: gw_corr_lev_occ, gw_corr_lev_virt
672  REAL(kind=dp), INTENT(IN) :: eps_filter
673 
674  CHARACTER(LEN=*), PARAMETER :: routinen = 'replicate_mat_to_subgroup'
675 
676  INTEGER :: handle
677  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: c
678  TYPE(group_dist_d1_type) :: gd_array
679 
680  CALL timeset(routinen, handle)
681 
682  CALL grep_rows_in_subgroups(para_env, para_env_sub, mo_coeff, gd_array, c)
683 
684  ! create and fill mo_coeff_o, mo_coeff_v and mo_coeff_all
685  CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_o, c(:, 1:homo), &
686  mat_munu, gd_array, eps_filter)
687 
688  CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_v, c(:, homo + 1:dimen), &
689  mat_munu, gd_array, eps_filter)
690 
691  IF (my_do_gw) THEN
692 
693  CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_gw, c(:, homo - gw_corr_lev_occ + 1:homo + gw_corr_lev_virt), &
694  mat_munu, gd_array, eps_filter)
695 
696  ! all levels
697  CALL build_dbcsr_from_rows(para_env_sub, mo_coeff_all, c, &
698  mat_munu, gd_array, eps_filter)
699 
700  END IF
701 
702  DEALLOCATE (c)
703  CALL release_group_dist(gd_array)
704 
705  CALL timestop(handle)
706 
707  END SUBROUTINE replicate_mat_to_subgroup
708 
709 ! **************************************************************************************************
710 !> \brief ...
711 !> \param para_env ...
712 !> \param para_env_sub ...
713 !> \param mo_coeff ...
714 !> \param gd_array ...
715 !> \param C ...
716 ! **************************************************************************************************
717  SUBROUTINE grep_rows_in_subgroups(para_env, para_env_sub, mo_coeff, gd_array, C)
718  TYPE(mp_para_env_type), INTENT(IN) :: para_env, para_env_sub
719  TYPE(cp_fm_type), INTENT(IN) :: mo_coeff
720  TYPE(group_dist_d1_type), INTENT(OUT) :: gd_array
721  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :), &
722  INTENT(OUT) :: c
723 
724  CHARACTER(LEN=*), PARAMETER :: routinen = 'grep_rows_in_subgroups'
725 
726  INTEGER :: handle, i_global, iib, j_global, jjb, max_row_col_local, my_mu_end, my_mu_size, &
727  my_mu_start, ncol_global, ncol_local, ncol_rec, nrow_global, nrow_local, nrow_rec, &
728  proc_receive_static, proc_send_static, proc_shift
729  INTEGER, ALLOCATABLE, DIMENSION(:, :) :: local_col_row_info, rec_col_row_info
730  INTEGER, DIMENSION(:), POINTER :: col_indices, col_indices_rec, &
731  row_indices, row_indices_rec
732  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: local_c, rec_c
733  REAL(kind=dp), CONTIGUOUS, DIMENSION(:, :), &
734  POINTER :: local_c_internal
735 
736  CALL timeset(routinen, handle)
737 
738  CALL cp_fm_get_info(matrix=mo_coeff, &
739  ncol_global=ncol_global, &
740  nrow_global=nrow_global, &
741  nrow_local=nrow_local, &
742  ncol_local=ncol_local, &
743  row_indices=row_indices, &
744  col_indices=col_indices, &
745  local_data=local_c_internal)
746 
747  CALL create_group_dist(gd_array, para_env_sub%num_pe, nrow_global)
748  CALL get_group_dist(gd_array, para_env_sub%mepos, my_mu_start, my_mu_end, my_mu_size)
749 
750  ! local storage for the C matrix
751  ALLOCATE (c(my_mu_size, ncol_global))
752  c = 0.0_dp
753 
754  ALLOCATE (local_c(nrow_local, ncol_local))
755  local_c(:, :) = local_c_internal(1:nrow_local, 1:ncol_local)
756  NULLIFY (local_c_internal)
757 
758  max_row_col_local = max(nrow_local, ncol_local)
759  CALL para_env%max(max_row_col_local)
760 
761  ALLOCATE (local_col_row_info(0:max_row_col_local, 2))
762  local_col_row_info = 0
763  ! 0,1 nrows
764  local_col_row_info(0, 1) = nrow_local
765  local_col_row_info(1:nrow_local, 1) = row_indices(1:nrow_local)
766  ! 0,2 ncols
767  local_col_row_info(0, 2) = ncol_local
768  local_col_row_info(1:ncol_local, 2) = col_indices(1:ncol_local)
769 
770  ALLOCATE (rec_col_row_info(0:max_row_col_local, 2))
771 
772  ! accumulate data on C buffer starting from myself
773  DO iib = 1, nrow_local
774  i_global = row_indices(iib)
775  IF (i_global >= my_mu_start .AND. i_global <= my_mu_end) THEN
776  DO jjb = 1, ncol_local
777  j_global = col_indices(jjb)
778  c(i_global - my_mu_start + 1, j_global) = local_c(iib, jjb)
779  END DO
780  END IF
781  END DO
782 
783  ! start ring communication for collecting the data from the other
784  proc_send_static = modulo(para_env%mepos + 1, para_env%num_pe)
785  proc_receive_static = modulo(para_env%mepos - 1, para_env%num_pe)
786  DO proc_shift = 1, para_env%num_pe - 1
787  ! first exchange information on the local data
788  rec_col_row_info = 0
789  CALL para_env%sendrecv(local_col_row_info, proc_send_static, rec_col_row_info, proc_receive_static)
790  nrow_rec = rec_col_row_info(0, 1)
791  ncol_rec = rec_col_row_info(0, 2)
792 
793  ALLOCATE (row_indices_rec(nrow_rec))
794  row_indices_rec = rec_col_row_info(1:nrow_rec, 1)
795 
796  ALLOCATE (col_indices_rec(ncol_rec))
797  col_indices_rec = rec_col_row_info(1:ncol_rec, 2)
798 
799  ALLOCATE (rec_c(nrow_rec, ncol_rec))
800  rec_c = 0.0_dp
801 
802  ! then send and receive the real data
803  CALL para_env%sendrecv(local_c, proc_send_static, rec_c, proc_receive_static)
804 
805  ! accumulate the received data on C buffer
806  DO iib = 1, nrow_rec
807  i_global = row_indices_rec(iib)
808  IF (i_global >= my_mu_start .AND. i_global <= my_mu_end) THEN
809  DO jjb = 1, ncol_rec
810  j_global = col_indices_rec(jjb)
811  c(i_global - my_mu_start + 1, j_global) = rec_c(iib, jjb)
812  END DO
813  END IF
814  END DO
815 
816  local_col_row_info(:, :) = rec_col_row_info
817  DEALLOCATE (local_c)
818  ALLOCATE (local_c(nrow_rec, ncol_rec))
819  local_c(:, :) = rec_c
820 
821  DEALLOCATE (col_indices_rec)
822  DEALLOCATE (row_indices_rec)
823  DEALLOCATE (rec_c)
824  END DO
825 
826  DEALLOCATE (local_c)
827  DEALLOCATE (local_col_row_info)
828  DEALLOCATE (rec_col_row_info)
829 
830  CALL timestop(handle)
831 
832  END SUBROUTINE grep_rows_in_subgroups
833 
834 ! **************************************************************************************************
835 !> \brief Encapsulate the building of dbcsr_matrices mo_coeff_(v,o,all)
836 !> \param para_env_sub ...
837 !> \param mo_coeff_to_build ...
838 !> \param Cread ...
839 !> \param mat_munu ...
840 !> \param gd_array ...
841 !> \param eps_filter ...
842 !> \author Jan Wilhelm, Code by Mauro Del Ben
843 ! **************************************************************************************************
844  SUBROUTINE build_dbcsr_from_rows(para_env_sub, mo_coeff_to_build, Cread, &
845  mat_munu, gd_array, eps_filter)
846  TYPE(mp_para_env_type), INTENT(IN) :: para_env_sub
847  TYPE(dbcsr_type), POINTER :: mo_coeff_to_build
848  REAL(kind=dp), DIMENSION(:, :), INTENT(IN) :: cread
849  TYPE(dbcsr_type), INTENT(INOUT) :: mat_munu
850  TYPE(group_dist_d1_type), INTENT(IN) :: gd_array
851  REAL(kind=dp), INTENT(IN) :: eps_filter
852 
853  CHARACTER(LEN=*), PARAMETER :: routinen = 'build_dbcsr_from_rows'
854 
855  INTEGER :: blk, col, col_offset, col_size, handle, i, i_global, j, j_global, my_mu_end, &
856  my_mu_start, ncol_global, proc_receive, proc_send, proc_shift, rec_mu_end, rec_mu_size, &
857  rec_mu_start, row, row_offset, row_size
858  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: rec_c
859  REAL(kind=dp), DIMENSION(:, :), POINTER :: data_block
860  TYPE(dbcsr_iterator_type) :: iter
861 
862  CALL timeset(routinen, handle)
863 
864  ncol_global = SIZE(cread, 2)
865 
866  CALL get_group_dist(gd_array, para_env_sub%mepos, my_mu_start, my_mu_end)
867 
868  NULLIFY (mo_coeff_to_build)
869  CALL dbcsr_init_p(mo_coeff_to_build)
870  CALL cp_dbcsr_m_by_n_from_row_template(mo_coeff_to_build, template=mat_munu, n=ncol_global, &
871  sym=dbcsr_type_no_symmetry, data_type=dbcsr_type_real_default)
872  CALL dbcsr_reserve_all_blocks(mo_coeff_to_build)
873 
874  ! accumulate data on mo_coeff_to_build starting from myself
875  CALL dbcsr_iterator_start(iter, mo_coeff_to_build)
876  DO WHILE (dbcsr_iterator_blocks_left(iter))
877  CALL dbcsr_iterator_next_block(iter, row, col, data_block, blk, &
878  row_size=row_size, col_size=col_size, &
879  row_offset=row_offset, col_offset=col_offset)
880  DO i = 1, row_size
881  i_global = row_offset + i - 1
882  IF (i_global >= my_mu_start .AND. i_global <= my_mu_end) THEN
883  DO j = 1, col_size
884  j_global = col_offset + j - 1
885  data_block(i, j) = cread(i_global - my_mu_start + 1, col_offset + j - 1)
886  END DO
887  END IF
888  END DO
889  END DO
890  CALL dbcsr_iterator_stop(iter)
891 
892  ! start ring communication in the subgroup for collecting the data from the other
893  ! proc (occupied)
894  DO proc_shift = 1, para_env_sub%num_pe - 1
895  proc_send = modulo(para_env_sub%mepos + proc_shift, para_env_sub%num_pe)
896  proc_receive = modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
897 
898  CALL get_group_dist(gd_array, proc_receive, rec_mu_start, rec_mu_end, rec_mu_size)
899 
900  ALLOCATE (rec_c(rec_mu_size, ncol_global))
901  rec_c = 0.0_dp
902 
903  ! then send and receive the real data
904  CALL para_env_sub%sendrecv(cread, proc_send, rec_c, proc_receive)
905 
906  ! accumulate data on mo_coeff_to_build the data received from proc_rec
907  CALL dbcsr_iterator_start(iter, mo_coeff_to_build)
908  DO WHILE (dbcsr_iterator_blocks_left(iter))
909  CALL dbcsr_iterator_next_block(iter, row, col, data_block, blk, &
910  row_size=row_size, col_size=col_size, &
911  row_offset=row_offset, col_offset=col_offset)
912  DO i = 1, row_size
913  i_global = row_offset + i - 1
914  IF (i_global >= rec_mu_start .AND. i_global <= rec_mu_end) THEN
915  DO j = 1, col_size
916  j_global = col_offset + j - 1
917  data_block(i, j) = rec_c(i_global - rec_mu_start + 1, col_offset + j - 1)
918  END DO
919  END IF
920  END DO
921  END DO
922  CALL dbcsr_iterator_stop(iter)
923 
924  DEALLOCATE (rec_c)
925 
926  END DO
927  CALL dbcsr_filter(mo_coeff_to_build, eps_filter)
928 
929  CALL timestop(handle)
930 
931  END SUBROUTINE build_dbcsr_from_rows
932 
933 ! **************************************************************************************************
934 !> \brief Encapsulate the building of dbcsr_matrix mat_munu
935 !> \param mat_munu ...
936 !> \param qs_env ...
937 !> \param eps_grid ...
938 !> \param blacs_env_sub ...
939 !> \param do_ri_aux_basis ...
940 !> \param do_mixed_basis ...
941 !> \param group_size_prim ...
942 !> \param do_alloc_blocks_from_nbl ...
943 !> \param do_kpoints ...
944 !> \param sab_orb_sub ...
945 !> \param dbcsr_sym_type ...
946 !> \author Jan Wilhelm, code by Mauro Del Ben
947 ! **************************************************************************************************
948  SUBROUTINE create_mat_munu(mat_munu, qs_env, eps_grid, blacs_env_sub, &
949  do_ri_aux_basis, do_mixed_basis, group_size_prim, &
950  do_alloc_blocks_from_nbl, do_kpoints, sab_orb_sub, dbcsr_sym_type)
951 
952  TYPE(dbcsr_p_type), INTENT(OUT) :: mat_munu
953  TYPE(qs_environment_type), POINTER :: qs_env
954  REAL(kind=dp) :: eps_grid
955  TYPE(cp_blacs_env_type), POINTER :: blacs_env_sub
956  LOGICAL, INTENT(IN), OPTIONAL :: do_ri_aux_basis, do_mixed_basis
957  INTEGER, INTENT(IN), OPTIONAL :: group_size_prim
958  LOGICAL, INTENT(IN), OPTIONAL :: do_alloc_blocks_from_nbl, do_kpoints
959  TYPE(neighbor_list_set_p_type), DIMENSION(:), &
960  OPTIONAL, POINTER :: sab_orb_sub
961  CHARACTER, OPTIONAL :: dbcsr_sym_type
962 
963  CHARACTER(LEN=*), PARAMETER :: routinen = 'create_mat_munu'
964 
965  CHARACTER :: my_dbcsr_sym_type
966  INTEGER :: handle, ikind, natom, nkind
967  INTEGER, DIMENSION(:), POINTER :: col_blk_sizes, row_blk_sizes
968  LOGICAL :: my_do_alloc_blocks_from_nbl, &
969  my_do_kpoints, my_do_mixed_basis, &
970  my_do_ri_aux_basis
971  LOGICAL, ALLOCATABLE, DIMENSION(:) :: orb_present
972  REAL(dp), ALLOCATABLE, DIMENSION(:) :: orb_radius
973  REAL(dp), ALLOCATABLE, DIMENSION(:, :) :: pair_radius
974  REAL(kind=dp) :: subcells
975  TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
976  TYPE(cell_type), POINTER :: cell
977  TYPE(dbcsr_distribution_type), POINTER :: dbcsr_dist_sub
978  TYPE(dft_control_type), POINTER :: dft_control
979  TYPE(distribution_1d_type), POINTER :: local_molecules_sub, local_particles_sub
980  TYPE(distribution_2d_type), POINTER :: distribution_2d_sub
981  TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_ri_aux
982  TYPE(gto_basis_set_type), POINTER :: orb_basis_set
983  TYPE(local_atoms_type), ALLOCATABLE, DIMENSION(:) :: atom2d
984  TYPE(molecule_kind_type), DIMENSION(:), POINTER :: molecule_kind_set
985  TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
986  TYPE(neighbor_list_set_p_type), DIMENSION(:), &
987  POINTER :: my_sab_orb_sub
988  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
989  TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
990 
991  CALL timeset(routinen, handle)
992 
993  NULLIFY (basis_set_ri_aux)
994 
995  my_do_ri_aux_basis = .false.
996  IF (PRESENT(do_ri_aux_basis)) THEN
997  my_do_ri_aux_basis = do_ri_aux_basis
998  END IF
999 
1000  my_do_mixed_basis = .false.
1001  IF (PRESENT(do_mixed_basis)) THEN
1002  my_do_mixed_basis = do_mixed_basis
1003  END IF
1004 
1005  my_do_alloc_blocks_from_nbl = .false.
1006  IF (PRESENT(do_alloc_blocks_from_nbl)) THEN
1007  my_do_alloc_blocks_from_nbl = do_alloc_blocks_from_nbl
1008  END IF
1009 
1010  my_do_kpoints = .false.
1011  IF (PRESENT(do_kpoints)) THEN
1012  my_do_kpoints = do_kpoints
1013  END IF
1014 
1015  my_dbcsr_sym_type = dbcsr_type_no_symmetry
1016  IF (PRESENT(dbcsr_sym_type)) THEN
1017  my_dbcsr_sym_type = dbcsr_sym_type
1018  END IF
1019 
1020  CALL get_qs_env(qs_env, &
1021  qs_kind_set=qs_kind_set, &
1022  cell=cell, &
1023  particle_set=particle_set, &
1024  atomic_kind_set=atomic_kind_set, &
1025  molecule_set=molecule_set, &
1026  molecule_kind_set=molecule_kind_set, &
1027  dft_control=dft_control)
1028 
1029  IF (my_do_kpoints) THEN
1030  ! please choose EPS_PGF_ORB in QS section smaller than EPS_GRID in WFC_GPW section
1031  IF (eps_grid < dft_control%qs_control%eps_pgf_orb) THEN
1032  eps_grid = dft_control%qs_control%eps_pgf_orb
1033  cpwarn("WFC_GPW%EPS_GRID has been set to QS%EPS_PGF_ORB")
1034  END IF
1035  END IF
1036 
1037  ! hack hack hack XXXXXXXXXXXXXXX ... to be fixed
1038  dft_control%qs_control%eps_pgf_orb = eps_grid
1039  dft_control%qs_control%eps_rho_rspace = eps_grid
1040  dft_control%qs_control%eps_gvg_rspace = eps_grid
1041  CALL init_interaction_radii(dft_control%qs_control, qs_kind_set)
1042 
1043  ! get a distribution_1d
1044  NULLIFY (local_particles_sub, local_molecules_sub)
1045  CALL distribute_molecules_1d(atomic_kind_set=atomic_kind_set, &
1046  particle_set=particle_set, &
1047  local_particles=local_particles_sub, &
1048  molecule_kind_set=molecule_kind_set, &
1049  molecule_set=molecule_set, &
1050  local_molecules=local_molecules_sub, &
1051  force_env_section=qs_env%input)
1052 
1053  ! get a distribution_2d
1054  NULLIFY (distribution_2d_sub)
1055  CALL distribute_molecules_2d(cell=cell, &
1056  atomic_kind_set=atomic_kind_set, &
1057  qs_kind_set=qs_kind_set, &
1058  particle_set=particle_set, &
1059  molecule_kind_set=molecule_kind_set, &
1060  molecule_set=molecule_set, &
1061  distribution_2d=distribution_2d_sub, &
1062  blacs_env=blacs_env_sub, &
1063  force_env_section=qs_env%input)
1064 
1065  ! Build the sub orbital-orbital overlap neighbor lists
1066  CALL section_vals_val_get(qs_env%input, "DFT%SUBCELLS", r_val=subcells)
1067  nkind = SIZE(atomic_kind_set)
1068  ALLOCATE (atom2d(nkind))
1069 
1070  CALL atom2d_build(atom2d, local_particles_sub, distribution_2d_sub, atomic_kind_set, &
1071  molecule_set, molecule_only=.false., particle_set=particle_set)
1072 
1073  ALLOCATE (orb_present(nkind))
1074  ALLOCATE (orb_radius(nkind))
1075  ALLOCATE (pair_radius(nkind, nkind))
1076 
1077  DO ikind = 1, nkind
1078  CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1079  IF (ASSOCIATED(orb_basis_set)) THEN
1080  orb_present(ikind) = .true.
1081  CALL get_gto_basis_set(gto_basis_set=orb_basis_set, kind_radius=orb_radius(ikind))
1082  ELSE
1083  orb_present(ikind) = .false.
1084  orb_radius(ikind) = 0.0_dp
1085  END IF
1086  END DO
1087 
1088  CALL pair_radius_setup(orb_present, orb_present, orb_radius, orb_radius, pair_radius)
1089 
1090  IF (PRESENT(sab_orb_sub)) THEN
1091  NULLIFY (sab_orb_sub)
1092  ! for cubic RPA/GW with kpoints, we need all neighbors and not only the symmetric ones
1093  IF (my_do_kpoints) THEN
1094  CALL build_neighbor_lists(sab_orb_sub, particle_set, atom2d, cell, pair_radius, &
1095  mic=.false., subcells=subcells, molecular=.false., nlname="sab_orb_sub", &
1096  symmetric=.false.)
1097  ELSE
1098  CALL build_neighbor_lists(sab_orb_sub, particle_set, atom2d, cell, pair_radius, &
1099  mic=.false., subcells=subcells, molecular=.false., nlname="sab_orb_sub")
1100  END IF
1101  ELSE
1102  NULLIFY (my_sab_orb_sub)
1103  ! for cubic RPA/GW with kpoints, we need all neighbors and not only the symmetric ones
1104  IF (my_do_kpoints) THEN
1105  CALL build_neighbor_lists(my_sab_orb_sub, particle_set, atom2d, cell, pair_radius, &
1106  mic=.false., subcells=subcells, molecular=.false., nlname="sab_orb_sub", &
1107  symmetric=.false.)
1108  ELSE
1109  CALL build_neighbor_lists(my_sab_orb_sub, particle_set, atom2d, cell, pair_radius, &
1110  mic=.false., subcells=subcells, molecular=.false., nlname="sab_orb_sub")
1111  END IF
1112  END IF
1113  CALL atom2d_cleanup(atom2d)
1114  DEALLOCATE (atom2d)
1115  DEALLOCATE (orb_present, orb_radius, pair_radius)
1116 
1117  ! a dbcsr_dist
1118  ALLOCATE (dbcsr_dist_sub)
1119  CALL cp_dbcsr_dist2d_to_dist(distribution_2d_sub, dbcsr_dist_sub)
1120 
1121  ! build a dbcsr matrix the hard way
1122  natom = SIZE(particle_set)
1123  ALLOCATE (row_blk_sizes(natom))
1124  IF (my_do_ri_aux_basis) THEN
1125 
1126  ALLOCATE (basis_set_ri_aux(nkind))
1127  CALL basis_set_list_setup(basis_set_ri_aux, "RI_AUX", qs_kind_set)
1128  CALL get_particle_set(particle_set, qs_kind_set, nsgf=row_blk_sizes, basis=basis_set_ri_aux)
1129  DEALLOCATE (basis_set_ri_aux)
1130 
1131  ELSE IF (my_do_mixed_basis) THEN
1132 
1133  ALLOCATE (basis_set_ri_aux(nkind))
1134  CALL basis_set_list_setup(basis_set_ri_aux, "RI_AUX", qs_kind_set)
1135  CALL get_particle_set(particle_set, qs_kind_set, nsgf=row_blk_sizes, basis=basis_set_ri_aux)
1136  DEALLOCATE (basis_set_ri_aux)
1137 
1138  ALLOCATE (col_blk_sizes(natom))
1139 
1140  CALL get_particle_set(particle_set, qs_kind_set, nsgf=col_blk_sizes)
1141  col_blk_sizes = col_blk_sizes*group_size_prim
1142 
1143  ELSE
1144  CALL get_particle_set(particle_set, qs_kind_set, nsgf=row_blk_sizes)
1145  END IF
1146 
1147  NULLIFY (mat_munu%matrix)
1148  ALLOCATE (mat_munu%matrix)
1149 
1150  IF (my_do_ri_aux_basis) THEN
1151 
1152  CALL dbcsr_create(matrix=mat_munu%matrix, &
1153  name="(ai|munu)", &
1154  dist=dbcsr_dist_sub, matrix_type=my_dbcsr_sym_type, &
1155  row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
1156  nze=0)
1157 
1158  ELSE IF (my_do_mixed_basis) THEN
1159 
1160  CALL dbcsr_create(matrix=mat_munu%matrix, &
1161  name="(ai|munu)", &
1162  dist=dbcsr_dist_sub, matrix_type=my_dbcsr_sym_type, &
1163  row_blk_size=row_blk_sizes, col_blk_size=col_blk_sizes, &
1164  nze=0)
1165 
1166  ELSE
1167 
1168  CALL dbcsr_create(matrix=mat_munu%matrix, &
1169  name="(ai|munu)", &
1170  dist=dbcsr_dist_sub, matrix_type=my_dbcsr_sym_type, &
1171  row_blk_size=row_blk_sizes, col_blk_size=row_blk_sizes, &
1172  nze=0)
1173 
1174  IF (my_do_alloc_blocks_from_nbl) THEN
1175 
1176  IF (PRESENT(sab_orb_sub)) THEN
1177  CALL cp_dbcsr_alloc_block_from_nbl(mat_munu%matrix, sab_orb_sub)
1178  ELSE
1179  CALL cp_dbcsr_alloc_block_from_nbl(mat_munu%matrix, my_sab_orb_sub)
1180  END IF
1181 
1182  END IF
1183 
1184  END IF
1185 
1186  DEALLOCATE (row_blk_sizes)
1187 
1188  IF (my_do_mixed_basis) THEN
1189  DEALLOCATE (col_blk_sizes)
1190  END IF
1191 
1192  CALL dbcsr_distribution_release(dbcsr_dist_sub)
1193  DEALLOCATE (dbcsr_dist_sub)
1194 
1195  CALL distribution_2d_release(distribution_2d_sub)
1196 
1197  CALL distribution_1d_release(local_particles_sub)
1198  CALL distribution_1d_release(local_molecules_sub)
1199 
1200  IF (.NOT. PRESENT(sab_orb_sub)) THEN
1201  CALL release_neighbor_list_sets(my_sab_orb_sub)
1202  END IF
1203 
1204  CALL timestop(handle)
1205 
1206  END SUBROUTINE create_mat_munu
1207 
1208 ! **************************************************************************************************
1209 !> \brief ...
1210 !> \param mat_P_global ...
1211 !> \param qs_env ...
1212 !> \param mp2_env ...
1213 !> \param para_env ...
1214 ! **************************************************************************************************
1215  SUBROUTINE create_matrix_p(mat_P_global, qs_env, mp2_env, para_env)
1216 
1217  TYPE(dbcsr_p_type), INTENT(OUT) :: mat_p_global
1218  TYPE(qs_environment_type), POINTER :: qs_env
1219  TYPE(mp2_type) :: mp2_env
1220  TYPE(mp_para_env_type), POINTER :: para_env
1221 
1222  CHARACTER(LEN=*), PARAMETER :: routinen = 'create_matrix_P'
1223 
1224  INTEGER :: blacs_grid_layout, handle
1225  LOGICAL :: blacs_repeatable
1226  TYPE(cp_blacs_env_type), POINTER :: blacs_env_global
1227 
1228  CALL timeset(routinen, handle)
1229 
1230  blacs_grid_layout = blacs_grid_square
1231  blacs_repeatable = .true.
1232  NULLIFY (blacs_env_global)
1233  CALL cp_blacs_env_create(blacs_env_global, para_env, &
1234  blacs_grid_layout, &
1235  blacs_repeatable)
1236 
1237  CALL create_mat_munu(mat_p_global, qs_env, mp2_env%mp2_gpw%eps_grid, &
1238  blacs_env_global, do_ri_aux_basis=.true., &
1239  do_kpoints=mp2_env%ri_rpa_im_time%do_im_time_kpoints)
1240 
1241  CALL dbcsr_reserve_all_blocks(mat_p_global%matrix)
1242  CALL cp_blacs_env_release(blacs_env_global)
1243 
1244  CALL timestop(handle)
1245 
1246  END SUBROUTINE
1247 
1248 ! **************************************************************************************************
1249 !> \brief ...
1250 !> \param dft_control ...
1251 !> \param eps_pgf_orb_old ...
1252 !> \param eps_rho_rspace_old ...
1253 !> \param eps_gvg_rspace_old ...
1254 ! **************************************************************************************************
1255  PURE SUBROUTINE get_eps_old(dft_control, eps_pgf_orb_old, eps_rho_rspace_old, eps_gvg_rspace_old)
1256 
1257  TYPE(dft_control_type), INTENT(INOUT) :: dft_control
1258  REAL(kind=dp), INTENT(OUT) :: eps_pgf_orb_old, eps_rho_rspace_old, &
1259  eps_gvg_rspace_old
1260 
1261  ! re-init the radii to be able to generate pair lists with MP2-appropriate screening
1262  eps_pgf_orb_old = dft_control%qs_control%eps_pgf_orb
1263  eps_rho_rspace_old = dft_control%qs_control%eps_rho_rspace
1264  eps_gvg_rspace_old = dft_control%qs_control%eps_gvg_rspace
1265 
1266  END SUBROUTINE get_eps_old
1267 
1268 END 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....
Definition: grid_common.h:117
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)
...
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:195
methods related to the blacs parallel environment
Definition: cp_blacs_env.F:15
integer, parameter, public blacs_grid_square
Definition: cp_blacs_env.F:32
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
Definition: cp_blacs_env.F:282
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
Definition: cp_blacs_env.F:123
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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, data_type)
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
Definition: cp_fm_types.F:1016
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:15
collects all constants needed in input so that they can be used without circular dependencies
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.
Definition: kpoint_types.F:15
Interface to the Libint-Library or a c++ wrapper.
subroutine, public cp_libint_static_cleanup()
subroutine, public cp_libint_static_init()
Machine interface based on Fortran 2003 and POSIX.
Definition: machine.F:17
integer, parameter, public default_output_unit
Definition: machine.F:45
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition: machine.F:106
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, nmo, 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:161
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, mo_coeff, 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 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:846
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)
Encapsulate the building of dbcsr_matrix mat_munu.
Definition: mp2_gpw.F:951
subroutine, public grep_rows_in_subgroups(para_env, para_env_sub, mo_coeff, gd_array, C)
...
Definition: mp2_gpw.F:718
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
Routines to calculate and distribute 2c- and 3c- integrals for RI.
Definition: mp2_integrals.F:14
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, mo_coeff, fm_matrix_PQ, fm_matrix_L_kpoints, fm_matrix_Minv_L_kpoints, fm_matrix_Minv, fm_matrix_Minv_Vtrunc_Minv, nmo, homo, mat_munu, sab_orb_sub, mo_coeff_o, mo_coeff_v, mo_coeff_all, mo_coeff_gw, 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, 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:81
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, nmo, homo, 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.
Definition: mp2_ri_grad.F:114
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)
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, 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_nonbond, sab_almo, sab_kp, sab_kp_nosym, 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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
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.
Definition: qs_kind_types.F:23
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, 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_r3d_rs_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, 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, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, 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)
Get the components of a MO set data structure.
Definition: qs_mo_types.F:397
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)
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, fm_matrix_L_kpoints, fm_matrix_Minv_L_kpoints, fm_matrix_Minv, fm_matrix_Minv_Vtrunc_Minv, kpoints, Eigenval, nmo, homo, dimen_RI, dimen_RI_red, gw_corr_lev_occ, gw_corr_lev_virt, unit_nr, 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:181
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, nmo, homo, Eigenval)
Single excitations energy corrections for RPA.
Definition: rpa_rse.F:93