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