(git:858b7a1)
Loading...
Searching...
No Matches
mp2.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 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! **************************************************************************************************
14MODULE mp2
15 USE admm_types, ONLY: admm_type
20 USE bibliography, ONLY: bussy2023,&
24 stein2022,&
25 stein2024,&
26 cite_reference
29 USE cp_dbcsr_api, ONLY: dbcsr_get_info,&
41 USE cp_fm_types, ONLY: cp_fm_create,&
51 USE hfx_exx, ONLY: calculate_exx
52 USE hfx_types, ONLY: &
67 USE kinds, ONLY: dp,&
68 int_8
69 USE kpoint_types, ONLY: kpoint_type
70 USE machine, ONLY: m_flush,&
71 m_memory,&
75 USE mp2_gpw, ONLY: mp2_gpw_main
77 USE mp2_types, ONLY: mp2_biel_type,&
81 mp2_type,&
91 USE qs_mo_types, ONLY: allocate_mo_set,&
96 USE qs_scf_methods, ONLY: eigensolver,&
101 USE virial_types, ONLY: virial_type
102
103!$ USE OMP_LIB, ONLY: omp_get_max_threads, omp_get_thread_num, omp_get_num_threads
104
105#include "./base/base_uses.f90"
106
107 IMPLICIT NONE
108
109 PRIVATE
110
111 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'mp2'
112
113 PUBLIC :: mp2_main
114
115CONTAINS
116
117! **************************************************************************************************
118!> \brief the main entry point for MP2 calculations
119!> \param qs_env ...
120!> \param calc_forces ...
121!> \author Mauro Del Ben
122! **************************************************************************************************
123 SUBROUTINE mp2_main(qs_env, calc_forces)
124 TYPE(qs_environment_type), POINTER :: qs_env
125 LOGICAL, INTENT(IN) :: calc_forces
126
127 CHARACTER(len=*), PARAMETER :: routinen = 'mp2_main'
128
129 INTEGER :: bin, cholesky_method, dimen, handle, handle2, i, i_thread, iatom, ii, ikind, &
130 irep, ispin, max_nset, my_bin_size, n_rep_hf, n_threads, nao, natom, ndep, &
131 nfullcols_total, nfullrows_total, nkind, nmo, nspins, unit_nr
132 INTEGER(KIND=int_8) :: mem
133 INTEGER, ALLOCATABLE, DIMENSION(:) :: kind_of, nelec
134 LOGICAL :: calc_ex, do_admm, do_admm_rpa_exx, do_dynamic_load_balancing, do_exx, do_gw, &
135 do_im_time, do_kpoints_cubic_rpa, free_hfx_buffer, reuse_hfx, update_xc_energy
136 REAL(kind=dp) :: e_admm_from_gw(2), e_ex_from_gw, emp2, emp2_aa, emp2_aa_cou, emp2_aa_ex, &
137 emp2_ab, emp2_ab_cou, emp2_ab_ex, emp2_bb, emp2_bb_cou, emp2_bb_ex, emp2_cou, emp2_ex, &
138 emp2_s, emp2_t, maxocc, mem_real, t1, t2, t3
139 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: evals
140 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: auto
141 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: c
142 REAL(kind=dp), DIMENSION(:), POINTER :: mo_eigenvalues
143 TYPE(admm_type), POINTER :: admm_env
144 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
145 TYPE(cp_blacs_env_type), POINTER :: blacs_env
146 TYPE(cp_fm_struct_type), POINTER :: fm_struct
147 TYPE(cp_fm_type) :: evecs, fm_matrix_ks, fm_matrix_s, &
148 fm_matrix_work
149 TYPE(cp_fm_type), POINTER :: fm_matrix_ks_red, fm_matrix_s_red, &
150 fm_work_red, mo_coeff
151 TYPE(cp_logger_type), POINTER :: logger
152 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks, matrix_s
153 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_ks_transl, matrix_s_kp
154 TYPE(dft_control_type), POINTER :: dft_control
155 TYPE(hfx_basis_info_type) :: basis_info
156 TYPE(hfx_basis_type), DIMENSION(:), POINTER :: basis_parameter
157 TYPE(hfx_container_type), DIMENSION(:), POINTER :: integral_containers
158 TYPE(hfx_container_type), POINTER :: maxval_container
159 TYPE(hfx_type), POINTER :: actual_x_data
160 TYPE(kpoint_type), POINTER :: kpoints
161 TYPE(mo_set_type), ALLOCATABLE, DIMENSION(:) :: mos_mp2
162 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
163 TYPE(mp2_biel_type) :: mp2_biel
164 TYPE(mp2_type), POINTER :: mp2_env
165 TYPE(mp_para_env_type), POINTER :: para_env
166 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
167 TYPE(qs_energy_type), POINTER :: energy
168 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
169 TYPE(qs_scf_env_type), POINTER :: scf_env
170 TYPE(scf_control_type), POINTER :: scf_control
171 TYPE(section_vals_type), POINTER :: hfx_sections, input
172 TYPE(virial_type), POINTER :: virial
173
174 ! If SCF has not converged we should abort MP2 calculation
175 IF (qs_env%mp2_env%hf_fail) THEN
176 CALL cp_abort(__location__, "SCF not converged: "// &
177 "not possible to run MP2")
178 END IF
179
180 NULLIFY (virial, dft_control, blacs_env, kpoints, fm_matrix_s_red, fm_matrix_ks_red, fm_work_red)
181 CALL timeset(routinen, handle)
182 logger => cp_get_default_logger()
183
184 CALL cite_reference(delben2012)
185
186 do_kpoints_cubic_rpa = qs_env%mp2_env%ri_rpa_im_time%do_im_time_kpoints
187
188 ! for cubic RPA and GW, we have kpoints and therefore, we get other matrices later
189 IF (do_kpoints_cubic_rpa) THEN
190
191 CALL get_qs_env(qs_env, &
192 input=input, &
193 atomic_kind_set=atomic_kind_set, &
194 qs_kind_set=qs_kind_set, &
195 dft_control=dft_control, &
196 particle_set=particle_set, &
197 para_env=para_env, &
198 blacs_env=blacs_env, &
199 energy=energy, &
200 kpoints=kpoints, &
201 scf_env=scf_env, &
202 scf_control=scf_control, &
203 matrix_ks_kp=matrix_ks_transl, &
204 matrix_s_kp=matrix_s_kp, &
205 mp2_env=mp2_env)
206
207 CALL get_gamma(matrix_s, matrix_ks, mos, &
208 matrix_s_kp, matrix_ks_transl, kpoints)
209
210 ELSE
211
212 CALL get_qs_env(qs_env, &
213 input=input, &
214 atomic_kind_set=atomic_kind_set, &
215 qs_kind_set=qs_kind_set, &
216 dft_control=dft_control, &
217 particle_set=particle_set, &
218 para_env=para_env, &
219 blacs_env=blacs_env, &
220 energy=energy, &
221 mos=mos, &
222 scf_env=scf_env, &
223 scf_control=scf_control, &
224 virial=virial, &
225 matrix_ks=matrix_ks, &
226 matrix_s=matrix_s, &
227 mp2_env=mp2_env, &
228 admm_env=admm_env)
229
230 END IF
231
232 unit_nr = cp_print_key_unit_nr(logger, input, "DFT%XC%WF_CORRELATION%PRINT", &
233 extension=".mp2Log")
234
235 IF (unit_nr > 0) THEN
236 IF (mp2_env%method .NE. ri_rpa_method_gpw) THEN
237 WRITE (unit_nr, *)
238 WRITE (unit_nr, *)
239 WRITE (unit_nr, '(T2,A)') 'MP2 section'
240 WRITE (unit_nr, '(T2,A)') '-----------'
241 WRITE (unit_nr, *)
242 ELSE
243 WRITE (unit_nr, *)
244 WRITE (unit_nr, *)
245 WRITE (unit_nr, '(T2,A)') 'RI-RPA section'
246 WRITE (unit_nr, '(T2,A)') '--------------'
247 WRITE (unit_nr, *)
248 END IF
249 END IF
250
251 IF (calc_forces) THEN
252 CALL cite_reference(delben2015b)
253 CALL cite_reference(rybkin2016)
254 CALL cite_reference(stein2022)
255 CALL cite_reference(bussy2023)
256 CALL cite_reference(stein2024)
257 !Gradients available for RI-MP2, and low-scaling Laplace MP2/RPA
258 IF (.NOT. (mp2_env%method == ri_mp2_method_gpw .OR. &
259 mp2_env%method == ri_rpa_method_gpw .OR. mp2_env%method == ri_mp2_laplace)) THEN
260 cpabort("No forces/gradients for the selected method.")
261 END IF
262 END IF
263
264 IF (.NOT. do_kpoints_cubic_rpa) THEN
265 IF (virial%pv_availability .AND. (.NOT. virial%pv_numer) .AND. mp2_env%eri_method == do_eri_mme) THEN
266 cpabort("analytical stress not implemented with ERI_METHOD = MME")
267 END IF
268 END IF
269
270 IF (mp2_env%do_im_time .AND. mp2_env%eri_method .NE. do_eri_gpw) THEN
271 mp2_env%mp2_num_proc = 1
272 END IF
273
274 IF (mp2_env%mp2_num_proc < 1 .OR. mp2_env%mp2_num_proc > para_env%num_pe) THEN
275 cpwarn("GROUP_SIZE is reset because of a too small or too large value.")
276 mp2_env%mp2_num_proc = max(min(para_env%num_pe, mp2_env%mp2_num_proc), 1)
277 END IF
278
279 IF (mod(para_env%num_pe, mp2_env%mp2_num_proc) /= 0) THEN
280 cpabort("GROUP_SIZE must be a divisor of the total number of MPI ranks!")
281 END IF
282
283 IF (.NOT. mp2_env%do_im_time) THEN
284 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T76,I5)') 'Used number of processes per group:', mp2_env%mp2_num_proc
285 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T68,F9.2,A4)') 'Maximum allowed memory usage per MPI process:', &
286 mp2_env%mp2_memory, ' MiB'
287 END IF
288
289 IF ((mp2_env%method .NE. mp2_method_gpw) .AND. &
290 (mp2_env%method .NE. ri_mp2_method_gpw) .AND. &
291 (mp2_env%method .NE. ri_rpa_method_gpw) .AND. &
292 (mp2_env%method .NE. ri_mp2_laplace)) THEN
293 CALL m_memory(mem)
294 mem_real = (mem + 1024*1024 - 1)/(1024*1024)
295 CALL para_env%max(mem_real)
296 mp2_env%mp2_memory = mp2_env%mp2_memory - mem_real
297 IF (mp2_env%mp2_memory < 0.0_dp) mp2_env%mp2_memory = 1.0_dp
298
299 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T68,F9.2,A4)') 'Available memory per MPI process for MP2:', &
300 mp2_env%mp2_memory, ' MiB'
301 END IF
302
303 IF (unit_nr > 0) CALL m_flush(unit_nr)
304
305 nspins = dft_control%nspins
306 natom = SIZE(particle_set, 1)
307
308 CALL get_atomic_kind_set(atomic_kind_set, kind_of=kind_of)
309 nkind = SIZE(atomic_kind_set, 1)
310
311 do_admm_rpa_exx = mp2_env%ri_rpa%do_admm
312 IF (do_admm_rpa_exx .AND. .NOT. dft_control%do_admm) THEN
313 cpabort("Need an ADMM input section for ADMM RI_RPA EXX to work")
314 END IF
315 IF (do_admm_rpa_exx) THEN
316 CALL hfx_create_basis_types(basis_parameter, basis_info, qs_kind_set, "AUX_FIT")
317 ELSE
318 CALL hfx_create_basis_types(basis_parameter, basis_info, qs_kind_set, "ORB")
319 END IF
320
321 dimen = 0
322 max_nset = 0
323 DO iatom = 1, natom
324 ikind = kind_of(iatom)
325 dimen = dimen + sum(basis_parameter(ikind)%nsgf)
326 max_nset = max(max_nset, basis_parameter(ikind)%nset)
327 END DO
328
329 CALL get_mo_set(mo_set=mos(1), nao=nao)
330
331 ! diagonalize the KS matrix in order to have the full set of MO's
332 ! get S and KS matrices in fm_type (create also a working array)
333 NULLIFY (fm_struct)
334 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
335 CALL cp_fm_struct_create(fm_struct, context=blacs_env, nrow_global=nfullrows_total, &
336 ncol_global=nfullcols_total, para_env=para_env)
337 CALL cp_fm_create(fm_matrix_s, fm_struct, name="fm_matrix_s")
338 CALL copy_dbcsr_to_fm(matrix_s(1)%matrix, fm_matrix_s)
339
340 CALL cp_fm_create(fm_matrix_ks, fm_struct, name="fm_matrix_ks")
341
342 CALL cp_fm_create(fm_matrix_work, fm_struct, name="fm_matrix_work")
343 CALL cp_fm_set_all(matrix=fm_matrix_work, alpha=0.0_dp)
344
345 CALL cp_fm_struct_release(fm_struct)
346
347 nmo = nao
348 ALLOCATE (nelec(nspins))
349 IF (scf_env%cholesky_method == cholesky_off) THEN
350 ALLOCATE (evals(nao))
351 evals = 0
352
353 CALL cp_fm_create(evecs, fm_matrix_s%matrix_struct)
354
355 ! Perform an EVD
356 CALL choose_eigv_solver(fm_matrix_s, evecs, evals)
357
358 ! Determine the number of neglectable eigenvalues assuming that the eigenvalues are in ascending order
359 ! (Required by Lapack)
360 ndep = 0
361 DO ii = 1, nao
362 IF (evals(ii) > scf_control%eps_eigval) THEN
363 ndep = ii - 1
364 EXIT
365 END IF
366 END DO
367 nmo = nao - ndep
368
369 DO ispin = 1, nspins
370 CALL get_mo_set(mo_set=mos(ispin), nelectron=nelec(ispin))
371 END DO
372 IF (maxval(nelec)/(3 - nspins) > nmo) THEN
373 ! Should not happen as the following MO calculation is the same as during the SCF steps
374 cpabort("Not enough MOs found!")
375 END IF
376
377 ! Set the eigenvalue of the eigenvectors belonging to the linear subspace to zero
378 evals(1:ndep) = 0.0_dp
379 ! Determine the eigenvalues of the inverse square root
380 evals(ndep + 1:nao) = 1.0_dp/sqrt(evals(ndep + 1:nao))
381
382 IF (ndep > 0) THEN
383 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T76,I5)') 'Number of removed MOs:', ndep
384 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T76,I5)') 'Number of available MOs:', nmo
385
386 ! Create reduced matrices
387 NULLIFY (fm_struct)
388 CALL cp_fm_struct_create(fm_struct, template_fmstruct=fm_matrix_s%matrix_struct, ncol_global=nmo)
389
390 ALLOCATE (fm_matrix_s_red, fm_work_red)
391 CALL cp_fm_create(fm_matrix_s_red, fm_struct)
392 CALL cp_fm_create(fm_work_red, fm_struct)
393 CALL cp_fm_struct_release(fm_struct)
394
395 ALLOCATE (fm_matrix_ks_red)
396 CALL cp_fm_struct_create(fm_struct, template_fmstruct=fm_matrix_s%matrix_struct, &
397 nrow_global=nmo, ncol_global=nmo)
398 CALL cp_fm_create(fm_matrix_ks_red, fm_struct)
399 CALL cp_fm_struct_release(fm_struct)
400
401 ! Scale the eigenvalues and copy them to
402 CALL cp_fm_to_fm(evecs, fm_matrix_s_red, nmo, ndep + 1)
403 CALL cp_fm_column_scale(fm_matrix_s_red, evals(ndep + 1:))
404
405 ! Obtain ortho from (P)DGEMM, skip the linear dependent columns
406 CALL parallel_gemm("N", "T", nao, nao, nmo, 1.0_dp, fm_matrix_s_red, evecs, &
407 0.0_dp, fm_matrix_s, b_first_col=ndep + 1)
408 ELSE
409 ! Take the square roots of the target values to allow application of SYRK
410 evals = sqrt(evals)
411 CALL cp_fm_column_scale(evecs, evals)
412 CALL cp_fm_syrk("U", "N", nao, 1.0_dp, evecs, 1, 1, 0.0_dp, fm_matrix_s)
413 CALL cp_fm_uplo_to_full(fm_matrix_s, fm_matrix_work)
414 END IF
415
416 CALL cp_fm_release(evecs)
417 cholesky_method = cholesky_off
418 ELSE
419 ! calculate S^(-1/2) (cholesky decomposition)
420 CALL cp_fm_cholesky_decompose(fm_matrix_s)
421 CALL cp_fm_triangular_invert(fm_matrix_s)
422 cholesky_method = cholesky_inverse
423 END IF
424
425 ALLOCATE (mos_mp2(nspins))
426 DO ispin = 1, nspins
427
428 CALL get_mo_set(mo_set=mos(ispin), maxocc=maxocc, nelectron=nelec(ispin))
429
430 CALL allocate_mo_set(mo_set=mos_mp2(ispin), &
431 nao=nao, &
432 nmo=nmo, &
433 nelectron=nelec(ispin), &
434 n_el_f=real(nelec(ispin), dp), &
435 maxocc=maxocc, &
436 flexible_electron_count=dft_control%relax_multiplicity)
437
438 CALL get_mo_set(mos_mp2(ispin), nao=nao)
439 CALL cp_fm_struct_create(fm_struct, nrow_global=nao, &
440 ncol_global=nmo, para_env=para_env, &
441 context=blacs_env)
442
443 CALL init_mo_set(mos_mp2(ispin), &
444 fm_struct=fm_struct, &
445 name="mp2_mos")
446 CALL cp_fm_struct_release(fm_struct)
447 END DO
448
449 DO ispin = 1, nspins
450
451 ! If ADMM we should make the ks matrix up-to-date
452 IF (dft_control%do_admm) THEN
453 CALL admm_correct_for_eigenvalues(ispin, admm_env, matrix_ks(ispin)%matrix)
454 END IF
455
456 CALL copy_dbcsr_to_fm(matrix_ks(ispin)%matrix, fm_matrix_ks)
457
458 IF (dft_control%do_admm) THEN
459 CALL admm_uncorrect_for_eigenvalues(ispin, admm_env, matrix_ks(ispin)%matrix)
460 END IF
461
462 IF (cholesky_method == cholesky_inverse) THEN
463
464 ! diagonalize KS matrix
465 CALL eigensolver(matrix_ks_fm=fm_matrix_ks, &
466 mo_set=mos_mp2(ispin), &
467 ortho=fm_matrix_s, &
468 work=fm_matrix_work, &
469 cholesky_method=cholesky_method, &
470 do_level_shift=.false., &
471 level_shift=0.0_dp, &
472 use_jacobi=.false.)
473
474 ELSE IF (cholesky_method == cholesky_off) THEN
475
476 IF (ASSOCIATED(fm_matrix_s_red)) THEN
477 CALL eigensolver_symm(matrix_ks_fm=fm_matrix_ks, &
478 mo_set=mos_mp2(ispin), &
479 ortho=fm_matrix_s, &
480 work=fm_matrix_work, &
481 do_level_shift=.false., &
482 level_shift=0.0_dp, &
483 use_jacobi=.false., &
484 jacobi_threshold=0.0_dp, &
485 ortho_red=fm_matrix_s_red, &
486 matrix_ks_fm_red=fm_matrix_ks_red, &
487 work_red=fm_work_red)
488 ELSE
489 CALL eigensolver_symm(matrix_ks_fm=fm_matrix_ks, &
490 mo_set=mos_mp2(ispin), &
491 ortho=fm_matrix_s, &
492 work=fm_matrix_work, &
493 do_level_shift=.false., &
494 level_shift=0.0_dp, &
495 use_jacobi=.false., &
496 jacobi_threshold=0.0_dp)
497 END IF
498 END IF
499
500 CALL get_mo_set(mos_mp2(ispin), mo_coeff=mo_coeff)
501 END DO
502
503 CALL cp_fm_release(fm_matrix_s)
504 CALL cp_fm_release(fm_matrix_ks)
505 CALL cp_fm_release(fm_matrix_work)
506 IF (ASSOCIATED(fm_matrix_s_red)) THEN
507 CALL cp_fm_release(fm_matrix_s_red)
508 DEALLOCATE (fm_matrix_s_red)
509 END IF
510 IF (ASSOCIATED(fm_matrix_ks_red)) THEN
511 CALL cp_fm_release(fm_matrix_ks_red)
512 DEALLOCATE (fm_matrix_ks_red)
513 END IF
514 IF (ASSOCIATED(fm_work_red)) THEN
515 CALL cp_fm_release(fm_work_red)
516 DEALLOCATE (fm_work_red)
517 END IF
518
519 hfx_sections => section_vals_get_subs_vals(input, "DFT%XC%HF")
520
521 ! build the table of index
522 t1 = m_walltime()
523 ALLOCATE (mp2_biel%index_table(natom, max_nset))
524
525 CALL build_index_table(natom, max_nset, mp2_biel%index_table, basis_parameter, kind_of)
526
527 ! free the hfx_container (for now if forces are required we don't release the HFX stuff)
528 free_hfx_buffer = .false.
529 IF (ASSOCIATED(qs_env%x_data)) THEN
530 free_hfx_buffer = .true.
531 IF (calc_forces .AND. (.NOT. mp2_env%ri_grad%free_hfx_buffer)) free_hfx_buffer = .false.
532 IF (qs_env%x_data(1, 1)%do_hfx_ri) free_hfx_buffer = .false.
533 IF (calc_forces .AND. mp2_env%do_im_time) free_hfx_buffer = .false.
534 IF (mp2_env%ri_rpa%reuse_hfx) free_hfx_buffer = .false.
535 END IF
536
537 IF (.NOT. do_kpoints_cubic_rpa) THEN
538 IF (virial%pv_numer) THEN
539 ! in the case of numerical stress we don't have to free the HFX integrals
540 free_hfx_buffer = .false.
541 mp2_env%ri_grad%free_hfx_buffer = free_hfx_buffer
542 END IF
543 END IF
544
545 ! calculate the matrix sigma_x - vxc for G0W0
546 t3 = 0
547 IF (mp2_env%ri_rpa%do_ri_g0w0) THEN
548 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)
549 END IF
550
551 IF (free_hfx_buffer) THEN
552 CALL timeset(routinen//"_free_hfx", handle2)
553 CALL section_vals_get(hfx_sections, n_repetition=n_rep_hf)
554 n_threads = 1
555!$ n_threads = omp_get_max_threads()
556
557 DO irep = 1, n_rep_hf
558 DO i_thread = 0, n_threads - 1
559 actual_x_data => qs_env%x_data(irep, i_thread + 1)
560
561 do_dynamic_load_balancing = .true.
562 IF (n_threads == 1 .OR. actual_x_data%memory_parameter%do_disk_storage) do_dynamic_load_balancing = .false.
563
564 IF (do_dynamic_load_balancing) THEN
565 my_bin_size = SIZE(actual_x_data%distribution_energy)
566 ELSE
567 my_bin_size = 1
568 END IF
569
570 IF (.NOT. actual_x_data%memory_parameter%do_all_on_the_fly) THEN
571 CALL dealloc_containers(actual_x_data%store_ints, actual_x_data%memory_parameter%actual_memory_usage)
572 END IF
573 END DO
574 END DO
575 CALL timestop(handle2)
576 END IF
577
578 emp2 = 0.d+00
579 emp2_cou = 0.d+00
580 emp2_ex = 0.d+00
581 calc_ex = .true.
582
583 t1 = m_walltime()
584 SELECT CASE (mp2_env%method)
585 CASE (mp2_method_direct)
586 IF (unit_nr > 0) WRITE (unit_nr, *)
587
588 ALLOCATE (auto(dimen, nspins))
589 ALLOCATE (c(dimen, dimen, nspins))
590
591 DO ispin = 1, nspins
592 ! get the alpha coeff and eigenvalues
593 CALL get_mo_set(mo_set=mos_mp2(ispin), &
594 eigenvalues=mo_eigenvalues, &
595 mo_coeff=mo_coeff)
596
597 CALL cp_fm_get_submatrix(mo_coeff, c(:, :, ispin), 1, 1, dimen, dimen, .false.)
598 auto(:, ispin) = mo_eigenvalues(:)
599 END DO
600
601 IF (nspins == 2) THEN
602 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Unrestricted Canonical Direct Methods:'
603 ! for now, require the mos to be always present
604
605 ! calculate the alpha-alpha MP2
606 emp2_aa = 0.0_dp
607 emp2_aa_cou = 0.0_dp
608 emp2_aa_ex = 0.0_dp
609 CALL mp2_direct_energy(dimen, nelec(1), nelec(1), mp2_biel, &
610 mp2_env, c(:, :, 1), auto(:, 1), emp2_aa, emp2_aa_cou, emp2_aa_ex, &
611 qs_env, para_env, unit_nr)
612 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy Alpha-Alpha = ', emp2_aa
613 IF (unit_nr > 0) WRITE (unit_nr, *)
614
615 emp2_bb = 0.0_dp
616 emp2_bb_cou = 0.0_dp
617 emp2_bb_ex = 0.0_dp
618 CALL mp2_direct_energy(dimen, nelec(2), nelec(2), mp2_biel, mp2_env, &
619 c(:, :, 2), auto(:, 2), emp2_bb, emp2_bb_cou, emp2_bb_ex, &
620 qs_env, para_env, unit_nr)
621 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy Beta-Beta= ', emp2_bb
622 IF (unit_nr > 0) WRITE (unit_nr, *)
623
624 emp2_ab = 0.0_dp
625 emp2_ab_cou = 0.0_dp
626 emp2_ab_ex = 0.0_dp
627 CALL mp2_direct_energy(dimen, nelec(1), nelec(2), mp2_biel, mp2_env, c(:, :, 1), &
628 auto(:, 1), emp2_ab, emp2_ab_cou, emp2_ab_ex, &
629 qs_env, para_env, unit_nr, c(:, :, 2), auto(:, 2))
630 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy Alpha-Beta= ', emp2_ab
631 IF (unit_nr > 0) WRITE (unit_nr, *)
632
633 emp2 = emp2_aa + emp2_bb + emp2_ab*2.0_dp !+Emp2_BA
634 emp2_cou = emp2_aa_cou + emp2_bb_cou + emp2_ab_cou*2.0_dp !+Emp2_BA
635 emp2_ex = emp2_aa_ex + emp2_bb_ex + emp2_ab_ex*2.0_dp !+Emp2_BA
636
637 emp2_s = emp2_ab*2.0_dp
638 emp2_t = emp2_aa + emp2_bb
639
640 ELSE
641
642 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Canonical Direct Methods:'
643
644 CALL mp2_direct_energy(dimen, nelec(1)/2, nelec(1)/2, mp2_biel, mp2_env, &
645 c(:, :, 1), auto(:, 1), emp2, emp2_cou, emp2_ex, &
646 qs_env, para_env, unit_nr)
647
648 END IF
649
650 DEALLOCATE (c, auto)
651
653 ! optimize ri basis set or tests for RI-MP2 gradients
654 IF (unit_nr > 0) THEN
655 WRITE (unit_nr, *)
656 WRITE (unit_nr, '(T3,A)') 'Optimization of the auxiliary RI-MP2 basis'
657 WRITE (unit_nr, *)
658 END IF
659
660 ALLOCATE (auto(dimen, nspins))
661 ALLOCATE (c(dimen, dimen, nspins))
662
663 DO ispin = 1, nspins
664 ! get the alpha coeff and eigenvalues
665 CALL get_mo_set(mo_set=mos_mp2(ispin), &
666 eigenvalues=mo_eigenvalues, &
667 mo_coeff=mo_coeff)
668
669 CALL cp_fm_get_submatrix(mo_coeff, c(:, :, ispin), 1, 1, dimen, dimen, .false.)
670 auto(:, ispin) = mo_eigenvalues(:)
671 END DO
672
673 ! optimize basis
674 IF (nspins == 2) THEN
675 CALL optimize_ri_basis_main(emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, dimen, natom, nelec(1), &
676 mp2_biel, mp2_env, c(:, :, 1), auto(:, 1), &
677 kind_of, qs_env, para_env, unit_nr, &
678 nelec(2), c(:, :, 2), auto(:, 2))
679
680 ELSE
681 CALL optimize_ri_basis_main(emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, dimen, natom, nelec(1)/2, &
682 mp2_biel, mp2_env, c(:, :, 1), auto(:, 1), &
683 kind_of, qs_env, para_env, unit_nr)
684 END IF
685
686 DEALLOCATE (auto, c)
687
688 CASE (mp2_method_gpw)
689 ! check if calculate the exchange contribution
690 IF (mp2_env%scale_T == 0.0_dp .AND. (nspins == 2)) calc_ex = .false.
691
692 ! go with mp2_gpw
693 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
694 mos_mp2, para_env, unit_nr, calc_forces, calc_ex)
695
696 CASE (ri_mp2_method_gpw)
697 ! check if calculate the exchange contribution
698 IF (mp2_env%scale_T == 0.0_dp .AND. (nspins == 2)) calc_ex = .false.
699
700 ! go with mp2_gpw
701 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
702 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_mp2=.true.)
703
704 CASE (ri_rpa_method_gpw)
705 ! perform RI-RPA energy calculation (since most part of the calculation
706 ! is actually equal to the RI-MP2-GPW we decided to put RPA in the MP2
707 ! section to avoid code replication)
708
709 calc_ex = .false.
710
711 ! go with ri_rpa_gpw
712 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
713 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_rpa=.true.)
714 ! Scale energy contributions
715 emp2 = emp2*mp2_env%ri_rpa%scale_rpa
716 mp2_env%ri_rpa%ener_exchange = mp2_env%ri_rpa%ener_exchange*mp2_env%ri_rpa%scale_rpa
717
718 CASE (ri_mp2_laplace)
719 ! perform RI-SOS-Laplace-MP2 energy calculation, most part of the code in common
720 ! with the RI-RPA part
721
722 ! In SOS-MP2 only the coulomb-like contribution of the MP2 energy is computed
723 calc_ex = .false.
724
725 ! go with sos_laplace_mp2_gpw
726 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
727 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_sos_laplace_mp2=.true.)
728
729 CASE DEFAULT
730 cpabort("")
731 END SELECT
732
733 t2 = m_walltime()
734 IF (unit_nr > 0) WRITE (unit_nr, *)
735 IF (mp2_env%method .NE. ri_rpa_method_gpw) THEN
736 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.6)') 'Total MP2 Time=', t2 - t1
737 IF (mp2_env%method == ri_mp2_laplace) THEN
738 emp2_s = emp2
739 emp2_t = 0.0_dp
740 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy SO component (singlet) = ', emp2_s
741 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Scaling factor SO = ', mp2_env%scale_S
742 ELSE
743 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Coulomb Energy = ', emp2_cou/2.0_dp
744 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Exchange Energy = ', emp2_ex
745 IF (nspins == 1) THEN
746 ! valid only in the closed shell case
747 emp2_s = emp2_cou/2.0_dp
748 IF (calc_ex) THEN
749 emp2_t = emp2_ex + emp2_cou/2.0_dp
750 ELSE
751 ! unknown if Emp2_ex is not computed
752 emp2_t = 0.0_dp
753 END IF
754 END IF
755 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy SO component (singlet) = ', emp2_s
756 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy SS component (triplet) = ', emp2_t
757 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Scaling factor SO = ', mp2_env%scale_S
758 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Scaling factor SS = ', mp2_env%scale_T
759 END IF
760 emp2_s = emp2_s*mp2_env%scale_S
761 emp2_t = emp2_t*mp2_env%scale_T
762 emp2 = emp2_s + emp2_t
763 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Second order perturbation energy = ', emp2
764 ELSE
765 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.6)') 'Total RI-RPA Time=', t2 - t1
766
767 update_xc_energy = .true.
768 IF (mp2_env%ri_rpa%do_ri_g0w0 .AND. .NOT. mp2_env%ri_g0w0%update_xc_energy) update_xc_energy = .false.
769 IF (.NOT. update_xc_energy) emp2 = 0.0_dp
770
771 IF (unit_nr > 0 .AND. update_xc_energy) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'RI-RPA energy = ', emp2
772 IF (unit_nr > 0 .AND. mp2_env%ri_rpa%sigma_param /= sigma_none) THEN
773 WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Sigma corr. to RI-RPA energy = ', &
774 mp2_env%ri_rpa%e_sigma_corr
775 END IF
776 IF (mp2_env%ri_rpa%exchange_correction == rpa_exchange_axk) THEN
777 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'RI-RPA-AXK energy=', mp2_env%ri_rpa%ener_exchange
778 ELSE IF (mp2_env%ri_rpa%exchange_correction == rpa_exchange_sosex) THEN
779 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'RI-RPA-SOSEX energy=', mp2_env%ri_rpa%ener_exchange
780 END IF
781 IF (mp2_env%ri_rpa%do_rse) THEN
782 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Diagonal singles correction (dRSE) = ', &
783 mp2_env%ri_rpa%rse_corr_diag
784 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Full singles correction (RSE) =', &
785 mp2_env%ri_rpa%rse_corr
786 IF (dft_control%do_admm) cpabort("RPA RSE not implemented with RI_RPA%ADMM on")
787 END IF
788 END IF
789 IF (unit_nr > 0) WRITE (unit_nr, *)
790
791 ! we have it !!!!
792 IF (mp2_env%ri_rpa%exchange_correction /= rpa_exchange_none) THEN
793 emp2 = emp2 + mp2_env%ri_rpa%ener_exchange
794 END IF
795 IF (mp2_env%ri_rpa%do_rse) THEN
796 emp2 = emp2 + mp2_env%ri_rpa%rse_corr
797 END IF
798 IF (mp2_env%ri_rpa%sigma_param /= sigma_none) THEN
799 !WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Sigma corr. to RI-RPA energy = ',&
800 emp2 = emp2 + mp2_env%ri_rpa%e_sigma_corr
801 END IF
802 energy%mp2 = emp2
803 energy%total = energy%total + emp2
804
805 DO ispin = 1, nspins
806 CALL deallocate_mo_set(mo_set=mos_mp2(ispin))
807 END DO
808 DEALLOCATE (mos_mp2)
809
810 ! if necessary reallocate hfx buffer
811 IF (free_hfx_buffer .AND. (.NOT. calc_forces) .AND. &
812 (mp2_env%ri_g0w0%do_ri_Sigma_x .OR. .NOT. mp2_env%ri_rpa_im_time%do_kpoints_from_Gamma)) THEN
813 CALL timeset(routinen//"_alloc_hfx", handle2)
814 DO irep = 1, n_rep_hf
815 DO i_thread = 0, n_threads - 1
816 actual_x_data => qs_env%x_data(irep, i_thread + 1)
817
818 do_dynamic_load_balancing = .true.
819 IF (n_threads == 1 .OR. actual_x_data%memory_parameter%do_disk_storage) do_dynamic_load_balancing = .false.
820
821 IF (do_dynamic_load_balancing) THEN
822 my_bin_size = SIZE(actual_x_data%distribution_energy)
823 ELSE
824 my_bin_size = 1
825 END IF
826
827 IF (.NOT. actual_x_data%memory_parameter%do_all_on_the_fly) THEN
828 CALL alloc_containers(actual_x_data%store_ints, my_bin_size)
829
830 DO bin = 1, my_bin_size
831 maxval_container => actual_x_data%store_ints%maxval_container(bin)
832 integral_containers => actual_x_data%store_ints%integral_containers(:, bin)
833 CALL hfx_init_container(maxval_container, actual_x_data%memory_parameter%actual_memory_usage, .false.)
834 DO i = 1, 64
835 CALL hfx_init_container(integral_containers(i), actual_x_data%memory_parameter%actual_memory_usage, .false.)
836 END DO
837 END DO
838 END IF
839 END DO
840 END DO
841 CALL timestop(handle2)
842 END IF
843
844 CALL hfx_release_basis_types(basis_parameter)
845
846 ! if required calculate the EXX contribution from the DFT density
847 IF (mp2_env%method == ri_rpa_method_gpw .AND. .NOT. calc_forces) THEN
848 do_exx = .false.
849 hfx_sections => section_vals_get_subs_vals(input, "DFT%XC%WF_CORRELATION%RI_RPA%HF")
850 CALL section_vals_get(hfx_sections, explicit=do_exx)
851 IF (do_exx) THEN
852 do_gw = mp2_env%ri_rpa%do_ri_g0w0
853 do_admm = mp2_env%ri_rpa%do_admm
854 reuse_hfx = qs_env%mp2_env%ri_rpa%reuse_hfx
855 do_im_time = qs_env%mp2_env%do_im_time
856
857 CALL calculate_exx(qs_env=qs_env, &
858 unit_nr=unit_nr, &
859 hfx_sections=hfx_sections, &
860 x_data=qs_env%mp2_env%ri_rpa%x_data, &
861 do_gw=do_gw, &
862 do_admm=do_admm, &
863 calc_forces=.false., &
864 reuse_hfx=reuse_hfx, &
865 do_im_time=do_im_time, &
866 e_ex_from_gw=e_ex_from_gw, &
867 e_admm_from_gw=e_admm_from_gw, &
868 t3=t3)
869
870 END IF
871 END IF
872
873 CALL cp_print_key_finished_output(unit_nr, logger, input, &
874 "DFT%XC%WF_CORRELATION%PRINT")
875
876 CALL timestop(handle)
877
878 END SUBROUTINE mp2_main
879
880! **************************************************************************************************
881!> \brief ...
882!> \param natom ...
883!> \param max_nset ...
884!> \param index_table ...
885!> \param basis_parameter ...
886!> \param kind_of ...
887! **************************************************************************************************
888 PURE SUBROUTINE build_index_table(natom, max_nset, index_table, basis_parameter, kind_of)
889 INTEGER, INTENT(IN) :: natom, max_nset
890 INTEGER, DIMENSION(natom, max_nset), INTENT(OUT) :: index_table
891 TYPE(hfx_basis_type), DIMENSION(:), POINTER :: basis_parameter
892 INTEGER, DIMENSION(natom), INTENT(IN) :: kind_of
893
894 INTEGER :: counter, iatom, ikind, iset, nset
895
896 index_table = -huge(0)
897 counter = 0
898 DO iatom = 1, natom
899 ikind = kind_of(iatom)
900 nset = basis_parameter(ikind)%nset
901 DO iset = 1, nset
902 index_table(iatom, iset) = counter + 1
903 counter = counter + basis_parameter(ikind)%nsgf(iset)
904 END DO
905 END DO
906
907 END SUBROUTINE build_index_table
908
909! **************************************************************************************************
910!> \brief ...
911!> \param matrix_s ...
912!> \param matrix_ks ...
913!> \param mos ...
914!> \param matrix_s_kp ...
915!> \param matrix_ks_transl ...
916!> \param kpoints ...
917! **************************************************************************************************
918 PURE SUBROUTINE get_gamma(matrix_s, matrix_ks, mos, matrix_s_kp, matrix_ks_transl, kpoints)
919
920 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s, matrix_ks
921 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
922 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_s_kp, matrix_ks_transl
923 TYPE(kpoint_type), POINTER :: kpoints
924
925 INTEGER :: nspins
926
927 nspins = SIZE(matrix_ks_transl, 1)
928
929 matrix_ks(1:nspins) => matrix_ks_transl(1:nspins, 1)
930 matrix_s(1:1) => matrix_s_kp(1:1, 1)
931 mos(1:nspins) => kpoints%kp_env(1)%kpoint_env%mos(1:nspins, 1)
932
933 END SUBROUTINE get_gamma
934
935END MODULE mp2
936
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...
integer, save, public stein2024
integer, save, public stein2022
integer, save, public rybkin2016
integer, save, public delben2012
integer, save, public delben2015b
integer, save, public bussy2023
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
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_column_scale(matrixa, scaling)
scales column i of matrix a with scaling(i)
subroutine, public cp_fm_syrk(uplo, trans, k, alpha, matrix_a, ia, ja, beta, matrix_c)
performs a rank-k update of a symmetric matrix_c matrix_c = beta * matrix_c + alpha * matrix_a * tran...
subroutine, public cp_fm_uplo_to_full(matrix, work, uplo)
given a triangular matrix according to uplo, computes the corresponding full matrix
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 choose_eigv_solver(matrix, eigenvectors, eigenvalues, info)
Choose the Eigensolver depending on which library is available ELPA seems to be unstable for small sy...
Definition cp_fm_diag.F:238
represent the structure of a full matrix
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
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
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
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,...
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
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 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:2522
subroutine, public hfx_release_basis_types(basis_parameter)
...
Definition hfx_types.F:1781
subroutine, public alloc_containers(data, bin_size)
...
Definition hfx_types.F:2905
subroutine, public dealloc_containers(data, memory_usage)
...
Definition hfx_types.F:2873
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 rpa_exchange_none
integer, parameter, public sigma_none
integer, parameter, public mp2_method_direct
integer, parameter, public rpa_exchange_sosex
integer, parameter, public mp2_ri_optimize_basis
integer, parameter, public do_eri_mme
integer, parameter, public cholesky_off
integer, parameter, public cholesky_inverse
integer, parameter, public ri_rpa_method_gpw
integer, parameter, public ri_mp2_method_gpw
integer, parameter, public mp2_method_gpw
integer, parameter, public ri_mp2_laplace
integer, parameter, public rpa_exchange_axk
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.
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:440
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
Definition machine.F:130
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition machine.F:147
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:124
basic linear algebra operations for full matrixes
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_pp, 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, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
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...
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
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.
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 ...
groups fairly general SCF methods, so that modules other than qs_scf can use them too split off from ...
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....
subroutine, public eigensolver_symm(matrix_ks_fm, mo_set, ortho, work, do_level_shift, level_shift, matrix_u_fm, use_jacobi, jacobi_threshold, ortho_red, work_red, matrix_ks_fm_red, matrix_u_fm_red)
...
module that contains the definitions of the scf types
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
stores some data used in wavefunction fitting
Definition admm_types.F:120
Provides all information about an atomic kind.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores some data used in construction of Kohn-Sham matrix
Definition hfx_types.F:509
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.