(git:34ef472)
mp2.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 Routines to calculate MP2 energy
10 !> \par History
11 !> 05.2011 created [Mauro Del Ben]
12 !> \author Mauro Del Ben
13 ! **************************************************************************************************
14 MODULE mp2
15  USE admm_types, ONLY: admm_type
18  USE atomic_kind_types, ONLY: atomic_kind_type,&
20  USE bibliography, ONLY: delben2012,&
21  delben2015b,&
22  rybkin2016,&
23  cite_reference
24  USE cp_blacs_env, ONLY: cp_blacs_env_type
25  USE cp_control_types, ONLY: dft_control_type
29  USE cp_fm_diag, ONLY: cp_fm_power
32  cp_fm_struct_type
33  USE cp_fm_types, ONLY: cp_fm_create,&
36  cp_fm_release,&
38  cp_fm_type
40  cp_logger_type
43  USE dbcsr_api, ONLY: dbcsr_get_info,&
44  dbcsr_p_type
45  USE hfx_exx, ONLY: calculate_exx
46  USE hfx_types, ONLY: &
47  alloc_containers, dealloc_containers, hfx_basis_info_type, hfx_basis_type, &
49  hfx_type
51  cholesky_off,&
52  do_eri_gpw,&
56  section_vals_type
57  USE kinds, ONLY: dp,&
58  int_8
59  USE kpoint_types, ONLY: kpoint_type
60  USE machine, ONLY: m_flush,&
61  m_memory,&
63  USE message_passing, ONLY: mp_para_env_type
65  USE mp2_gpw, ONLY: mp2_gpw_main
67  USE mp2_types, ONLY: mp2_biel_type,&
68  mp2_method_direct,&
69  mp2_method_gpw,&
70  mp2_ri_optimize_basis,&
71  mp2_type,&
72  ri_mp2_laplace,&
73  ri_mp2_method_gpw,&
74  ri_rpa_method_gpw
75  USE particle_types, ONLY: particle_type
76  USE qs_energy_types, ONLY: qs_energy_type
77  USE qs_environment_types, ONLY: get_qs_env,&
78  qs_environment_type
79  USE qs_kind_types, ONLY: qs_kind_type
80  USE qs_mo_types, ONLY: allocate_mo_set,&
82  get_mo_set,&
83  init_mo_set,&
84  mo_set_type
85  USE qs_scf_methods, ONLY: eigensolver,&
87  USE qs_scf_types, ONLY: qs_scf_env_type
89  USE scf_control_types, ONLY: scf_control_type
90  USE virial_types, ONLY: virial_type
91 
92 !$ USE OMP_LIB, ONLY: omp_get_max_threads, omp_get_thread_num, omp_get_num_threads
93 
94 #include "./base/base_uses.f90"
95 
96  IMPLICIT NONE
97 
98  PRIVATE
99 
100  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'mp2'
101 
102  PUBLIC :: mp2_main
103 
104 CONTAINS
105 
106 ! **************************************************************************************************
107 !> \brief the main entry point for MP2 calculations
108 !> \param qs_env ...
109 !> \param calc_forces ...
110 !> \author Mauro Del Ben
111 ! **************************************************************************************************
112  SUBROUTINE mp2_main(qs_env, calc_forces)
113  TYPE(qs_environment_type), POINTER :: qs_env
114  LOGICAL, INTENT(IN) :: calc_forces
115 
116  CHARACTER(len=*), PARAMETER :: routinen = 'mp2_main'
117 
118  INTEGER :: bin, cholesky_method, dimen, handle, handle2, i, i_thread, iatom, ikind, irep, &
119  ispin, max_nset, my_bin_size, n_rep_hf, n_threads, nao, natom, ncol_block, ndep, &
120  nfullcols_total, nfullrows_total, nkind, nrow_block, nspins, unit_nr
121  INTEGER(KIND=int_8) :: mem
122  INTEGER, ALLOCATABLE, DIMENSION(:) :: kind_of, nelec
123  LOGICAL :: calc_ex, do_admm, do_admm_rpa_exx, do_dynamic_load_balancing, do_exx, do_gw, &
124  do_im_time, do_kpoints_cubic_rpa, free_hfx_buffer, reuse_hfx, update_xc_energy
125  REAL(kind=dp) :: e_admm_from_gw(2), e_ex_from_gw, emp2, emp2_aa, emp2_aa_cou, emp2_aa_ex, &
126  emp2_ab, emp2_ab_cou, emp2_ab_ex, emp2_bb, emp2_bb_cou, emp2_bb_ex, emp2_cou, emp2_ex, &
127  emp2_s, emp2_t, maxocc, mem_real, t1, t2, t3
128  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: auto
129  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: c
130  REAL(kind=dp), DIMENSION(:), POINTER :: mo_eigenvalues
131  TYPE(admm_type), POINTER :: admm_env
132  TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
133  TYPE(cp_blacs_env_type), POINTER :: blacs_env
134  TYPE(cp_fm_struct_type), POINTER :: fm_struct
135  TYPE(cp_fm_type) :: fm_matrix_ks, fm_matrix_s, fm_matrix_work
136  TYPE(cp_fm_type), POINTER :: mo_coeff
137  TYPE(cp_logger_type), POINTER :: logger
138  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks, matrix_s
139  TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_ks_transl, matrix_s_kp
140  TYPE(dft_control_type), POINTER :: dft_control
141  TYPE(hfx_basis_info_type) :: basis_info
142  TYPE(hfx_basis_type), DIMENSION(:), POINTER :: basis_parameter
143  TYPE(hfx_container_type), DIMENSION(:), POINTER :: integral_containers
144  TYPE(hfx_container_type), POINTER :: maxval_container
145  TYPE(hfx_type), POINTER :: actual_x_data
146  TYPE(kpoint_type), POINTER :: kpoints
147  TYPE(mo_set_type), ALLOCATABLE, DIMENSION(:) :: mos_mp2
148  TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
149  TYPE(mp2_biel_type) :: mp2_biel
150  TYPE(mp2_type), POINTER :: mp2_env
151  TYPE(mp_para_env_type), POINTER :: para_env
152  TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
153  TYPE(qs_energy_type), POINTER :: energy
154  TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
155  TYPE(qs_scf_env_type), POINTER :: scf_env
156  TYPE(scf_control_type), POINTER :: scf_control
157  TYPE(section_vals_type), POINTER :: hfx_sections, input
158  TYPE(virial_type), POINTER :: virial
159 
160  ! If SCF has not converged we should abort MP2 calculation
161  IF (qs_env%mp2_env%hf_fail) THEN
162  CALL cp_abort(__location__, "SCF not converged: "// &
163  "not possible to run MP2")
164  END IF
165 
166  NULLIFY (virial, dft_control, blacs_env, kpoints)
167  CALL timeset(routinen, handle)
168  logger => cp_get_default_logger()
169 
170  CALL cite_reference(delben2012)
171 
172  do_kpoints_cubic_rpa = qs_env%mp2_env%ri_rpa_im_time%do_im_time_kpoints
173 
174  ! for cubic RPA and GW, we have kpoints and therefore, we get other matrices later
175  IF (do_kpoints_cubic_rpa) THEN
176 
177  CALL get_qs_env(qs_env, &
178  input=input, &
179  atomic_kind_set=atomic_kind_set, &
180  qs_kind_set=qs_kind_set, &
181  dft_control=dft_control, &
182  particle_set=particle_set, &
183  para_env=para_env, &
184  blacs_env=blacs_env, &
185  energy=energy, &
186  kpoints=kpoints, &
187  scf_env=scf_env, &
188  scf_control=scf_control, &
189  matrix_ks_kp=matrix_ks_transl, &
190  matrix_s_kp=matrix_s_kp, &
191  mp2_env=mp2_env)
192 
193  CALL get_gamma(matrix_s, matrix_ks, mos, &
194  matrix_s_kp, matrix_ks_transl, kpoints)
195 
196  ELSE
197 
198  CALL get_qs_env(qs_env, &
199  input=input, &
200  atomic_kind_set=atomic_kind_set, &
201  qs_kind_set=qs_kind_set, &
202  dft_control=dft_control, &
203  particle_set=particle_set, &
204  para_env=para_env, &
205  blacs_env=blacs_env, &
206  energy=energy, &
207  mos=mos, &
208  scf_env=scf_env, &
209  scf_control=scf_control, &
210  virial=virial, &
211  matrix_ks=matrix_ks, &
212  matrix_s=matrix_s, &
213  mp2_env=mp2_env, &
214  admm_env=admm_env)
215 
216  END IF
217 
218  unit_nr = cp_print_key_unit_nr(logger, input, "DFT%XC%WF_CORRELATION%PRINT", &
219  extension=".mp2Log")
220 
221  IF (unit_nr > 0) THEN
222  IF (mp2_env%method .NE. ri_rpa_method_gpw) THEN
223  WRITE (unit_nr, *)
224  WRITE (unit_nr, *)
225  WRITE (unit_nr, '(T2,A)') 'MP2 section'
226  WRITE (unit_nr, '(T2,A)') '-----------'
227  WRITE (unit_nr, *)
228  ELSE
229  WRITE (unit_nr, *)
230  WRITE (unit_nr, *)
231  WRITE (unit_nr, '(T2,A)') 'RI-RPA section'
232  WRITE (unit_nr, '(T2,A)') '--------------'
233  WRITE (unit_nr, *)
234  END IF
235  END IF
236 
237  IF (calc_forces) THEN
238  CALL cite_reference(delben2015b)
239  CALL cite_reference(rybkin2016)
240  !Gradients available for RI-MP2, and low-scaling Laplace MP2/RPA
241 IF (.NOT. (mp2_env%method == ri_mp2_method_gpw .OR. mp2_env%method == ri_rpa_method_gpw .OR. mp2_env%method == ri_mp2_laplace)) THEN
242  cpabort("No forces/gradients for the selected method.")
243  END IF
244  END IF
245 
246  IF (.NOT. do_kpoints_cubic_rpa) THEN
247  IF (virial%pv_availability .AND. (.NOT. virial%pv_numer) .AND. mp2_env%eri_method == do_eri_mme) THEN
248  cpabort("analytical stress not implemented with ERI_METHOD = MME")
249  END IF
250  END IF
251 
252  IF (mp2_env%do_im_time .AND. mp2_env%eri_method .NE. do_eri_gpw) THEN
253  mp2_env%mp2_num_proc = 1
254  END IF
255 
256  IF (mp2_env%mp2_num_proc < 1 .OR. mp2_env%mp2_num_proc > para_env%num_pe) THEN
257  cpwarn("GROUP_SIZE is reset because of a too small or too large value.")
258  mp2_env%mp2_num_proc = max(min(para_env%num_pe, mp2_env%mp2_num_proc), 1)
259  END IF
260 
261  IF (mod(para_env%num_pe, mp2_env%mp2_num_proc) /= 0) THEN
262  cpabort("GROUP_SIZE must be a divisor of the total number of MPI ranks!")
263  END IF
264 
265  IF (.NOT. mp2_env%do_im_time) THEN
266  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T76,I5)') 'Used number of processes per group:', mp2_env%mp2_num_proc
267  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T68,F9.2,A4)') 'Maximum allowed memory usage per MPI process:', &
268  mp2_env%mp2_memory, ' MiB'
269  END IF
270 
271  IF ((mp2_env%method .NE. mp2_method_gpw) .AND. &
272  (mp2_env%method .NE. ri_mp2_method_gpw) .AND. &
273  (mp2_env%method .NE. ri_rpa_method_gpw) .AND. &
274  (mp2_env%method .NE. ri_mp2_laplace)) THEN
275  CALL m_memory(mem)
276  mem_real = (mem + 1024*1024 - 1)/(1024*1024)
277  CALL para_env%max(mem_real)
278  mp2_env%mp2_memory = mp2_env%mp2_memory - mem_real
279  IF (mp2_env%mp2_memory < 0.0_dp) mp2_env%mp2_memory = 1.0_dp
280 
281  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T68,F9.2,A4)') 'Available memory per MPI process for MP2:', &
282  mp2_env%mp2_memory, ' MiB'
283  END IF
284 
285  IF (unit_nr > 0) CALL m_flush(unit_nr)
286 
287  nspins = dft_control%nspins
288  natom = SIZE(particle_set, 1)
289 
290  CALL get_atomic_kind_set(atomic_kind_set, kind_of=kind_of)
291  nkind = SIZE(atomic_kind_set, 1)
292 
293  do_admm_rpa_exx = mp2_env%ri_rpa%do_admm
294  IF (do_admm_rpa_exx .AND. .NOT. dft_control%do_admm) THEN
295  cpabort("Need an ADMM input section for ADMM RI_RPA EXX to work")
296  END IF
297  IF (do_admm_rpa_exx) THEN
298  CALL hfx_create_basis_types(basis_parameter, basis_info, qs_kind_set, "AUX_FIT")
299  ELSE
300  CALL hfx_create_basis_types(basis_parameter, basis_info, qs_kind_set, "ORB")
301  END IF
302 
303  dimen = 0
304  max_nset = 0
305  DO iatom = 1, natom
306  ikind = kind_of(iatom)
307  dimen = dimen + sum(basis_parameter(ikind)%nsgf)
308  max_nset = max(max_nset, basis_parameter(ikind)%nset)
309  END DO
310 
311  CALL get_mo_set(mo_set=mos(1), nao=nao)
312 
313  ! diagonalize the KS matrix in order to have the full set of MO's
314  ! get S and KS matrices in fm_type (create also a working array)
315  NULLIFY (fm_struct)
316  CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
317  CALL cp_fm_struct_create(fm_struct, context=blacs_env, nrow_global=nfullrows_total, &
318  ncol_global=nfullcols_total, para_env=para_env)
319  CALL cp_fm_create(fm_matrix_s, fm_struct, name="fm_matrix_s")
320  CALL copy_dbcsr_to_fm(matrix_s(1)%matrix, fm_matrix_s)
321 
322  CALL cp_fm_create(fm_matrix_ks, fm_struct, name="fm_matrix_ks")
323 
324  CALL cp_fm_create(fm_matrix_work, fm_struct, name="fm_matrix_work")
325  CALL cp_fm_set_all(matrix=fm_matrix_work, alpha=0.0_dp)
326 
327  CALL cp_fm_struct_release(fm_struct)
328 
329  CALL cp_fm_get_info(matrix=fm_matrix_ks, nrow_block=nrow_block, ncol_block=ncol_block)
330 
331  IF (scf_env%cholesky_method == cholesky_off) THEN
332  CALL cp_fm_power(fm_matrix_s, fm_matrix_work, -0.5_dp, scf_control%eps_eigval, ndep)
333  cholesky_method = cholesky_off
334  ELSE
335  ! calculate S^(-1/2) (cholesky decomposition)
336  CALL cp_fm_cholesky_decompose(fm_matrix_s)
337  CALL cp_fm_triangular_invert(fm_matrix_s)
338  cholesky_method = cholesky_inverse
339  END IF
340 
341  ALLOCATE (mos_mp2(nspins))
342  ALLOCATE (nelec(nspins))
343  DO ispin = 1, nspins
344 
345  ! If ADMM we should make the ks matrix up-to-date
346  IF (dft_control%do_admm) THEN
347  CALL admm_correct_for_eigenvalues(ispin, admm_env, matrix_ks(ispin)%matrix)
348  END IF
349 
350  CALL copy_dbcsr_to_fm(matrix_ks(ispin)%matrix, fm_matrix_ks)
351 
352  IF (dft_control%do_admm) THEN
353  CALL admm_uncorrect_for_eigenvalues(ispin, admm_env, matrix_ks(ispin)%matrix)
354  END IF
355 
356  CALL get_mo_set(mo_set=mos(ispin), maxocc=maxocc, nelectron=nelec(ispin))
357 
358  CALL allocate_mo_set(mo_set=mos_mp2(ispin), &
359  nao=nao, &
360  nmo=nao, &
361  nelectron=nelec(ispin), &
362  n_el_f=real(nelec(ispin), dp), &
363  maxocc=maxocc, &
364  flexible_electron_count=dft_control%relax_multiplicity)
365 
366  CALL get_mo_set(mos_mp2(ispin), nao=nao)
367  CALL cp_fm_struct_create(fm_struct, nrow_global=nao, &
368  ncol_global=nao, para_env=para_env, &
369  context=blacs_env)
370 
371  CALL init_mo_set(mos_mp2(ispin), &
372  fm_struct=fm_struct, &
373  name="mp2_mos")
374  CALL cp_fm_struct_release(fm_struct)
375 
376  IF (cholesky_method == cholesky_inverse) THEN
377 
378  ! diagonalize KS matrix
379  CALL eigensolver(matrix_ks_fm=fm_matrix_ks, &
380  mo_set=mos_mp2(ispin), &
381  ortho=fm_matrix_s, &
382  work=fm_matrix_work, &
383  cholesky_method=cholesky_method, &
384  do_level_shift=.false., &
385  level_shift=0.0_dp, &
386  use_jacobi=.false.)
387 
388  ELSE IF (cholesky_method == cholesky_off) THEN
389 
390  CALL eigensolver_symm(matrix_ks_fm=fm_matrix_ks, &
391  mo_set=mos_mp2(ispin), &
392  ortho=fm_matrix_s, &
393  work=fm_matrix_work, &
394  do_level_shift=.false., &
395  level_shift=0.0_dp, &
396  use_jacobi=.false., &
397  jacobi_threshold=0.0_dp)
398 
399  END IF
400 
401  END DO
402 
403  CALL cp_fm_release(fm_matrix_s)
404  CALL cp_fm_release(fm_matrix_ks)
405  CALL cp_fm_release(fm_matrix_work)
406 
407  hfx_sections => section_vals_get_subs_vals(input, "DFT%XC%HF")
408 
409  ! build the table of index
410  t1 = m_walltime()
411  ALLOCATE (mp2_biel%index_table(natom, max_nset))
412 
413  CALL build_index_table(natom, max_nset, mp2_biel%index_table, basis_parameter, kind_of)
414 
415  ! free the hfx_container (for now if forces are required we don't release the HFX stuff)
416  free_hfx_buffer = .false.
417  IF (ASSOCIATED(qs_env%x_data)) THEN
418  free_hfx_buffer = .true.
419  IF (calc_forces .AND. (.NOT. mp2_env%ri_grad%free_hfx_buffer)) free_hfx_buffer = .false.
420  IF (qs_env%x_data(1, 1)%do_hfx_ri) free_hfx_buffer = .false.
421  IF (calc_forces .AND. mp2_env%do_im_time) free_hfx_buffer = .false.
422  IF (mp2_env%ri_rpa%reuse_hfx) free_hfx_buffer = .false.
423  END IF
424 
425  IF (.NOT. do_kpoints_cubic_rpa) THEN
426  IF (virial%pv_numer) THEN
427  ! in the case of numerical stress we don't have to free the HFX integrals
428  free_hfx_buffer = .false.
429  mp2_env%ri_grad%free_hfx_buffer = free_hfx_buffer
430  END IF
431  END IF
432 
433  ! calculate the matrix sigma_x - vxc for G0W0
434  t3 = 0
435  IF (mp2_env%ri_rpa%do_ri_g0w0) THEN
436  CALL compute_vec_sigma_x_minus_vxc_gw(qs_env, mp2_env, mos_mp2, e_ex_from_gw, e_admm_from_gw, t3, unit_nr)
437  END IF
438 
439  IF (free_hfx_buffer) THEN
440  CALL timeset(routinen//"_free_hfx", handle2)
441  CALL section_vals_get(hfx_sections, n_repetition=n_rep_hf)
442  n_threads = 1
443 !$ n_threads = omp_get_max_threads()
444 
445  DO irep = 1, n_rep_hf
446  DO i_thread = 0, n_threads - 1
447  actual_x_data => qs_env%x_data(irep, i_thread + 1)
448 
449  do_dynamic_load_balancing = .true.
450  IF (n_threads == 1 .OR. actual_x_data%memory_parameter%do_disk_storage) do_dynamic_load_balancing = .false.
451 
452  IF (do_dynamic_load_balancing) THEN
453  my_bin_size = SIZE(actual_x_data%distribution_energy)
454  ELSE
455  my_bin_size = 1
456  END IF
457 
458  IF (.NOT. actual_x_data%memory_parameter%do_all_on_the_fly) THEN
459  CALL dealloc_containers(actual_x_data%store_ints, actual_x_data%memory_parameter%actual_memory_usage)
460  END IF
461  END DO
462  END DO
463  CALL timestop(handle2)
464  END IF
465 
466  emp2 = 0.d+00
467  emp2_cou = 0.d+00
468  emp2_ex = 0.d+00
469  calc_ex = .true.
470 
471  t1 = m_walltime()
472  SELECT CASE (mp2_env%method)
473  CASE (mp2_method_direct)
474  IF (unit_nr > 0) WRITE (unit_nr, *)
475 
476  ALLOCATE (auto(dimen, nspins))
477  ALLOCATE (c(dimen, dimen, nspins))
478 
479  DO ispin = 1, nspins
480  ! get the alpha coeff and eigenvalues
481  CALL get_mo_set(mo_set=mos_mp2(ispin), &
482  eigenvalues=mo_eigenvalues, &
483  mo_coeff=mo_coeff)
484 
485  CALL cp_fm_get_submatrix(mo_coeff, c(:, :, ispin), 1, 1, dimen, dimen, .false.)
486  auto(:, ispin) = mo_eigenvalues(:)
487  END DO
488 
489  IF (nspins == 2) THEN
490  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Unrestricted Canonical Direct Methods:'
491  ! for now, require the mos to be always present
492 
493  ! calculate the alpha-alpha MP2
494  emp2_aa = 0.0_dp
495  emp2_aa_cou = 0.0_dp
496  emp2_aa_ex = 0.0_dp
497  CALL mp2_direct_energy(dimen, nelec(1), nelec(1), mp2_biel, &
498  mp2_env, c(:, :, 1), auto(:, 1), emp2_aa, emp2_aa_cou, emp2_aa_ex, &
499  qs_env, para_env, unit_nr)
500  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy Alpha-Alpha = ', emp2_aa
501  IF (unit_nr > 0) WRITE (unit_nr, *)
502 
503  emp2_bb = 0.0_dp
504  emp2_bb_cou = 0.0_dp
505  emp2_bb_ex = 0.0_dp
506  CALL mp2_direct_energy(dimen, nelec(2), nelec(2), mp2_biel, mp2_env, &
507  c(:, :, 2), auto(:, 2), emp2_bb, emp2_bb_cou, emp2_bb_ex, &
508  qs_env, para_env, unit_nr)
509  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy Beta-Beta= ', emp2_bb
510  IF (unit_nr > 0) WRITE (unit_nr, *)
511 
512  emp2_ab = 0.0_dp
513  emp2_ab_cou = 0.0_dp
514  emp2_ab_ex = 0.0_dp
515  CALL mp2_direct_energy(dimen, nelec(1), nelec(2), mp2_biel, mp2_env, c(:, :, 1), &
516  auto(:, 1), emp2_ab, emp2_ab_cou, emp2_ab_ex, &
517  qs_env, para_env, unit_nr, c(:, :, 2), auto(:, 2))
518  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy Alpha-Beta= ', emp2_ab
519  IF (unit_nr > 0) WRITE (unit_nr, *)
520 
521  emp2 = emp2_aa + emp2_bb + emp2_ab*2.0_dp !+Emp2_BA
522  emp2_cou = emp2_aa_cou + emp2_bb_cou + emp2_ab_cou*2.0_dp !+Emp2_BA
523  emp2_ex = emp2_aa_ex + emp2_bb_ex + emp2_ab_ex*2.0_dp !+Emp2_BA
524 
525  emp2_s = emp2_ab*2.0_dp
526  emp2_t = emp2_aa + emp2_bb
527 
528  ELSE
529 
530  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Canonical Direct Methods:'
531 
532  CALL mp2_direct_energy(dimen, nelec(1)/2, nelec(1)/2, mp2_biel, mp2_env, &
533  c(:, :, 1), auto(:, 1), emp2, emp2_cou, emp2_ex, &
534  qs_env, para_env, unit_nr)
535 
536  END IF
537 
538  DEALLOCATE (c, auto)
539 
540  CASE (mp2_ri_optimize_basis)
541  ! optimize ri basis set or tests for RI-MP2 gradients
542  IF (unit_nr > 0) THEN
543  WRITE (unit_nr, *)
544  WRITE (unit_nr, '(T3,A)') 'Optimization of the auxiliary RI-MP2 basis'
545  WRITE (unit_nr, *)
546  END IF
547 
548  ALLOCATE (auto(dimen, nspins))
549  ALLOCATE (c(dimen, dimen, nspins))
550 
551  DO ispin = 1, nspins
552  ! get the alpha coeff and eigenvalues
553  CALL get_mo_set(mo_set=mos_mp2(ispin), &
554  eigenvalues=mo_eigenvalues, &
555  mo_coeff=mo_coeff)
556 
557  CALL cp_fm_get_submatrix(mo_coeff, c(:, :, ispin), 1, 1, dimen, dimen, .false.)
558  auto(:, ispin) = mo_eigenvalues(:)
559  END DO
560 
561  ! optimize basis
562  IF (nspins == 2) THEN
563  CALL optimize_ri_basis_main(emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, dimen, natom, nelec(1), &
564  mp2_biel, mp2_env, c(:, :, 1), auto(:, 1), &
565  kind_of, qs_env, para_env, unit_nr, &
566  nelec(2), c(:, :, 2), auto(:, 2))
567 
568  ELSE
569  CALL optimize_ri_basis_main(emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, dimen, natom, nelec(1)/2, &
570  mp2_biel, mp2_env, c(:, :, 1), auto(:, 1), &
571  kind_of, qs_env, para_env, unit_nr)
572  END IF
573 
574  DEALLOCATE (auto, c)
575 
576  CASE (mp2_method_gpw)
577  ! check if calculate the exchange contribution
578  IF (mp2_env%scale_T == 0.0_dp .AND. (nspins == 2)) calc_ex = .false.
579 
580  ! go with mp2_gpw
581  CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
582  mos_mp2, para_env, unit_nr, calc_forces, calc_ex)
583 
584  CASE (ri_mp2_method_gpw)
585  ! check if calculate the exchange contribution
586  IF (mp2_env%scale_T == 0.0_dp .AND. (nspins == 2)) calc_ex = .false.
587 
588  ! go with mp2_gpw
589  CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
590  mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_mp2=.true.)
591 
592  CASE (ri_rpa_method_gpw)
593  ! perform RI-RPA energy calculation (since most part of the calculation
594  ! is actually equal to the RI-MP2-GPW we decided to put RPA in the MP2
595  ! section to avoid code replication)
596 
597  calc_ex = .false.
598 
599  ! go with ri_rpa_gpw
600  CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
601  mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_rpa=.true.)
602 
603  ! Scale energy contributions
604  emp2 = emp2*mp2_env%ri_rpa%scale_rpa
605  mp2_env%ri_rpa%ener_axk = mp2_env%ri_rpa%ener_axk*mp2_env%ri_rpa%scale_rpa
606 
607  CASE (ri_mp2_laplace)
608  ! perform RI-SOS-Laplace-MP2 energy calculation, most part of the code in common
609  ! with the RI-RPA part
610 
611  ! In SOS-MP2 only the coulomb-like contribution of the MP2 energy is computed
612  calc_ex = .false.
613 
614  ! go with sos_laplace_mp2_gpw
615  CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
616  mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_sos_laplace_mp2=.true.)
617 
618  CASE DEFAULT
619  cpabort("")
620  END SELECT
621 
622  t2 = m_walltime()
623  IF (unit_nr > 0) WRITE (unit_nr, *)
624  IF (mp2_env%method .NE. ri_rpa_method_gpw) THEN
625  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.6)') 'Total MP2 Time=', t2 - t1
626  IF (mp2_env%method == ri_mp2_laplace) THEN
627  emp2_s = emp2
628  emp2_t = 0.0_dp
629  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy SO component (singlet) = ', emp2_s
630  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Scaling factor SO = ', mp2_env%scale_S
631  ELSE
632  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Coulomb Energy = ', emp2_cou/2.0_dp
633  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Exchange Energy = ', emp2_ex
634  IF (nspins == 1) THEN
635  ! valid only in the closed shell case
636  emp2_s = emp2_cou/2.0_dp
637  IF (calc_ex) THEN
638  emp2_t = emp2_ex + emp2_cou/2.0_dp
639  ELSE
640  ! unknown if Emp2_ex is not computed
641  emp2_t = 0.0_dp
642  END IF
643  END IF
644  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy SO component (singlet) = ', emp2_s
645  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy SS component (triplet) = ', emp2_t
646  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Scaling factor SO = ', mp2_env%scale_S
647  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Scaling factor SS = ', mp2_env%scale_T
648  END IF
649  emp2_s = emp2_s*mp2_env%scale_S
650  emp2_t = emp2_t*mp2_env%scale_T
651  emp2 = emp2_s + emp2_t
652  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Second order perturbation energy = ', emp2
653  ELSE
654  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.6)') 'Total RI-RPA Time=', t2 - t1
655 
656  update_xc_energy = .true.
657  IF (mp2_env%ri_rpa%do_ri_g0w0 .AND. .NOT. mp2_env%ri_g0w0%update_xc_energy) update_xc_energy = .false.
658  IF (.NOT. update_xc_energy) emp2 = 0.0_dp
659 
660  IF (unit_nr > 0 .AND. update_xc_energy) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'RI-RPA energy = ', emp2
661  IF (mp2_env%ri_rpa%do_ri_axk) THEN
662  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'RI-RPA-AXK energy=', mp2_env%ri_rpa%ener_axk
663  END IF
664  IF (mp2_env%ri_rpa%do_rse) THEN
665  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Diagonal singles correction (dRSE) = ', &
666  mp2_env%ri_rpa%rse_corr_diag
667  IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Full singles correction (RSE) =', &
668  mp2_env%ri_rpa%rse_corr
669  IF (dft_control%do_admm) cpabort("RPA RSE not implemented with RI_RPA%ADMM on")
670  END IF
671  END IF
672  IF (unit_nr > 0) WRITE (unit_nr, *)
673 
674  ! we have it !!!!
675  IF (mp2_env%ri_rpa%do_ri_axk) THEN
676  emp2 = emp2 + mp2_env%ri_rpa%ener_axk
677  END IF
678  IF (mp2_env%ri_rpa%do_rse) THEN
679  emp2 = emp2 + mp2_env%ri_rpa%rse_corr
680  END IF
681  energy%mp2 = emp2
682  energy%total = energy%total + emp2
683 
684  DO ispin = 1, nspins
685  CALL deallocate_mo_set(mo_set=mos_mp2(ispin))
686  END DO
687  DEALLOCATE (mos_mp2)
688 
689  ! if necessary reallocate hfx buffer
690  IF (free_hfx_buffer .AND. (.NOT. calc_forces) .AND. &
691  (mp2_env%ri_g0w0%do_ri_Sigma_x .OR. .NOT. mp2_env%ri_rpa_im_time%do_kpoints_from_Gamma)) THEN
692  CALL timeset(routinen//"_alloc_hfx", handle2)
693  DO irep = 1, n_rep_hf
694  DO i_thread = 0, n_threads - 1
695  actual_x_data => qs_env%x_data(irep, i_thread + 1)
696 
697  do_dynamic_load_balancing = .true.
698  IF (n_threads == 1 .OR. actual_x_data%memory_parameter%do_disk_storage) do_dynamic_load_balancing = .false.
699 
700  IF (do_dynamic_load_balancing) THEN
701  my_bin_size = SIZE(actual_x_data%distribution_energy)
702  ELSE
703  my_bin_size = 1
704  END IF
705 
706  IF (.NOT. actual_x_data%memory_parameter%do_all_on_the_fly) THEN
707  CALL alloc_containers(actual_x_data%store_ints, my_bin_size)
708 
709  DO bin = 1, my_bin_size
710  maxval_container => actual_x_data%store_ints%maxval_container(bin)
711  integral_containers => actual_x_data%store_ints%integral_containers(:, bin)
712  CALL hfx_init_container(maxval_container, actual_x_data%memory_parameter%actual_memory_usage, .false.)
713  DO i = 1, 64
714  CALL hfx_init_container(integral_containers(i), actual_x_data%memory_parameter%actual_memory_usage, .false.)
715  END DO
716  END DO
717  END IF
718  END DO
719  END DO
720  CALL timestop(handle2)
721  END IF
722 
723  CALL hfx_release_basis_types(basis_parameter)
724 
725  ! if required calculate the EXX contribution from the DFT density
726  IF (mp2_env%method == ri_rpa_method_gpw .AND. .NOT. calc_forces) THEN
727  do_exx = .false.
728  hfx_sections => section_vals_get_subs_vals(input, "DFT%XC%WF_CORRELATION%RI_RPA%HF")
729  CALL section_vals_get(hfx_sections, explicit=do_exx)
730  IF (do_exx) THEN
731  do_gw = mp2_env%ri_rpa%do_ri_g0w0
732  do_admm = mp2_env%ri_rpa%do_admm
733  reuse_hfx = qs_env%mp2_env%ri_rpa%reuse_hfx
734  do_im_time = qs_env%mp2_env%do_im_time
735 
736  CALL calculate_exx(qs_env=qs_env, &
737  unit_nr=unit_nr, &
738  hfx_sections=hfx_sections, &
739  x_data=qs_env%mp2_env%ri_rpa%x_data, &
740  do_gw=do_gw, &
741  do_admm=do_admm, &
742  calc_forces=.false., &
743  reuse_hfx=reuse_hfx, &
744  do_im_time=do_im_time, &
745  e_ex_from_gw=e_ex_from_gw, &
746  e_admm_from_gw=e_admm_from_gw, &
747  t3=t3)
748 
749  END IF
750  END IF
751 
752  CALL cp_print_key_finished_output(unit_nr, logger, input, &
753  "DFT%XC%WF_CORRELATION%PRINT")
754 
755  CALL timestop(handle)
756 
757  END SUBROUTINE mp2_main
758 
759 ! **************************************************************************************************
760 !> \brief ...
761 !> \param natom ...
762 !> \param max_nset ...
763 !> \param index_table ...
764 !> \param basis_parameter ...
765 !> \param kind_of ...
766 ! **************************************************************************************************
767  PURE SUBROUTINE build_index_table(natom, max_nset, index_table, basis_parameter, kind_of)
768  INTEGER, INTENT(IN) :: natom, max_nset
769  INTEGER, DIMENSION(natom, max_nset), INTENT(OUT) :: index_table
770  TYPE(hfx_basis_type), DIMENSION(:), POINTER :: basis_parameter
771  INTEGER, DIMENSION(natom), INTENT(IN) :: kind_of
772 
773  INTEGER :: counter, iatom, ikind, iset, nset
774 
775  index_table = -huge(0)
776  counter = 0
777  DO iatom = 1, natom
778  ikind = kind_of(iatom)
779  nset = basis_parameter(ikind)%nset
780  DO iset = 1, nset
781  index_table(iatom, iset) = counter + 1
782  counter = counter + basis_parameter(ikind)%nsgf(iset)
783  END DO
784  END DO
785 
786  END SUBROUTINE build_index_table
787 
788 ! **************************************************************************************************
789 !> \brief ...
790 !> \param matrix_s ...
791 !> \param matrix_ks ...
792 !> \param mos ...
793 !> \param matrix_s_kp ...
794 !> \param matrix_ks_transl ...
795 !> \param kpoints ...
796 ! **************************************************************************************************
797  PURE SUBROUTINE get_gamma(matrix_s, matrix_ks, mos, matrix_s_kp, matrix_ks_transl, kpoints)
798 
799  TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s, matrix_ks
800  TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
801  TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_s_kp, matrix_ks_transl
802  TYPE(kpoint_type), POINTER :: kpoints
803 
804  INTEGER :: nspins
805 
806  nspins = SIZE(matrix_ks_transl, 1)
807 
808  matrix_ks(1:nspins) => matrix_ks_transl(1:nspins, 1)
809  matrix_s(1:1) => matrix_s_kp(1:1, 1)
810  mos(1:nspins) => kpoints%kp_env(1)%kpoint_env%mos(1:nspins, 1)
811 
812  END SUBROUTINE get_gamma
813 
814 END MODULE mp2
815 
Types and set/get functions for auxiliary density matrix methods.
Definition: admm_types.F:15
Contains methods used in the context of density fitting.
Definition: admm_utils.F:15
subroutine, public admm_uncorrect_for_eigenvalues(ispin, admm_env, ks_matrix)
...
Definition: admm_utils.F:127
subroutine, public admm_correct_for_eigenvalues(ispin, admm_env, ks_matrix)
...
Definition: admm_utils.F:53
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
collects all references to literature in CP2K as new algorithms / method are included from literature...
Definition: bibliography.F:28
integer, save, public rybkin2016
Definition: bibliography.F:43
integer, save, public delben2012
Definition: bibliography.F:43
integer, save, public delben2015b
Definition: bibliography.F:43
methods related to the blacs parallel environment
Definition: cp_blacs_env.F:15
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
basic linear algebra operations for full matrices
subroutine, public cp_fm_triangular_invert(matrix_a, uplo_tr)
inverts a triangular matrix
various cholesky decomposition related routines
subroutine, public cp_fm_cholesky_decompose(matrix, n, info_out)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
Definition: cp_fm_diag.F:17
subroutine, public cp_fm_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
...
Definition: cp_fm_diag.F:896
represent the structure of a full matrix
Definition: cp_fm_struct.F:14
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
Definition: cp_fm_struct.F:125
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
Definition: cp_fm_struct.F:320
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
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
Definition: cp_fm_types.F:535
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
Definition: cp_fm_types.F:901
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
Definition: cp_fm_types.F:167
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Routines to calculate EXX in RPA and energy correction methods.
Definition: hfx_exx.F:16
subroutine, public calculate_exx(qs_env, unit_nr, hfx_sections, x_data, do_gw, do_admm, calc_forces, reuse_hfx, do_im_time, E_ex_from_GW, E_admm_from_GW, t3)
...
Definition: hfx_exx.F:106
Types and set/get functions for HFX.
Definition: hfx_types.F:15
subroutine, public dealloc_containers(DATA, memory_usage)
...
Definition: hfx_types.F:2874
subroutine, public alloc_containers(DATA, bin_size)
...
Definition: hfx_types.F:2906
subroutine, public hfx_init_container(container, memory_usage, do_disk_storage)
This routine deletes all list entries in a container in order to deallocate the memory.
Definition: hfx_types.F:2523
subroutine, public hfx_release_basis_types(basis_parameter)
...
Definition: hfx_types.F:1781
subroutine, public hfx_create_basis_types(basis_parameter, basis_info, qs_kind_set, basis_type)
This routine allocates and initializes the basis_info and basis_parameter types
Definition: hfx_types.F:1655
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_eri_mme
integer, parameter, public cholesky_off
integer, parameter, public cholesky_inverse
integer, parameter, public do_eri_gpw
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public int_8
Definition: kinds.F:54
integer, parameter, public dp
Definition: kinds.F:34
Types and basic routines needed for a kpoint calculation.
Definition: kpoint_types.F:15
Machine interface based on Fortran 2003 and POSIX.
Definition: machine.F:17
subroutine, public m_memory(mem)
Returns the total amount of memory [bytes] in use, if known, zero otherwise.
Definition: machine.F:332
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition: machine.F:106
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition: machine.F:123
Interface to the message passing library MPI.
Routines to calculate MP2 energy.
subroutine, public mp2_direct_energy(dimen, occ_i, occ_j, mp2_biel, mp2_env, C_i, Auto_i, Emp2, Emp2_Cou, Emp2_ex, qs_env, para_env, unit_nr, C_j, Auto_j)
...
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
Routines to optimize the RI-MP2 basis. Only exponents of non-contracted auxiliary basis basis are opt...
subroutine, public optimize_ri_basis_main(Emp2, Emp2_Cou, Emp2_ex, Emp2_S, Emp2_T, dimen, natom, homo, mp2_biel, mp2_env, C, Auto, kind_of, qs_env, para_env, unit_nr, homo_beta, C_beta, Auto_beta)
optimize RI-MP2 basis set
Types needed for MP2 calculations.
Definition: mp2_types.F:14
Routines to calculate MP2 energy.
Definition: mp2.F:14
subroutine, public mp2_main(qs_env, calc_forces)
the main entry point for MP2 calculations
Definition: mp2.F:113
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.
Define the quickstep kind type and their sub types.
Definition: qs_kind_types.F:23
Definition and initialisation of the mo data type.
Definition: qs_mo_types.F:22
subroutine, public allocate_mo_set(mo_set, nao, nmo, nelectron, n_el_f, maxocc, flexible_electron_count)
Allocates a mo set and partially initializes it (nao,nmo,nelectron, and flexible_electron_count are v...
Definition: qs_mo_types.F:206
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
Definition: qs_mo_types.F:352
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
subroutine, public init_mo_set(mo_set, fm_pool, fm_ref, fm_struct, name)
initializes an allocated mo_set. eigenvalues, mo_coeff, occupation_numbers are valid only after this ...
Definition: qs_mo_types.F:245
groups fairly general SCF methods, so that modules other than qs_scf can use them too split off from ...
subroutine, public eigensolver_symm(matrix_ks_fm, mo_set, ortho, work, do_level_shift, level_shift, matrix_u_fm, use_jacobi, jacobi_threshold)
...
subroutine, public eigensolver(matrix_ks_fm, mo_set, ortho, work, cholesky_method, do_level_shift, level_shift, matrix_u_fm, use_jacobi)
Diagonalise the Kohn-Sham matrix to get a new set of MO eigen- vectors and MO eigenvalues....
module that contains the definitions of the scf types
Definition: qs_scf_types.F:14
Routines to calculate EXX within GW.
subroutine, public compute_vec_sigma_x_minus_vxc_gw(qs_env, mp2_env, mos_mp2, energy_ex, energy_xc_admm, t3, unit_nr)
...
parameters that control an scf iteration