(git:d18deda)
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 CALL get_mo_set(mo_set=mos(1), nelectron=nelec(1))
370 IF (maxval(nelec) > nmo) THEN
371 ! Should not happen as the following MO calculation is the same as during the SCF steps
372 cpabort("Not enough MOs found!")
373 END IF
374
375 ! Set the eigenvalue of the eigenvectors belonging to the linear subspace to zero
376 evals(1:ndep) = 0.0_dp
377 ! Determine the eigenvalues of the inverse square root
378 evals(ndep + 1:nao) = 1.0_dp/sqrt(evals(ndep + 1:nao))
379
380 IF (ndep > 0) THEN
381 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T76,I5)') 'Number of removed MOs:', ndep
382 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T76,I5)') 'Number of available MOs:', nmo
383
384 ! Create reduced matrices
385 NULLIFY (fm_struct)
386 CALL cp_fm_struct_create(fm_struct, template_fmstruct=fm_matrix_s%matrix_struct, ncol_global=nmo)
387
388 ALLOCATE (fm_matrix_s_red, fm_work_red)
389 CALL cp_fm_create(fm_matrix_s_red, fm_struct)
390 CALL cp_fm_create(fm_work_red, fm_struct)
391 CALL cp_fm_struct_release(fm_struct)
392
393 ALLOCATE (fm_matrix_ks_red)
394 CALL cp_fm_struct_create(fm_struct, template_fmstruct=fm_matrix_s%matrix_struct, &
395 nrow_global=nmo, ncol_global=nmo)
396 CALL cp_fm_create(fm_matrix_ks_red, fm_struct)
397 CALL cp_fm_struct_release(fm_struct)
398
399 ! Scale the eigenvalues and copy them to
400 CALL cp_fm_to_fm(evecs, fm_matrix_s_red, nmo, ndep + 1)
401 CALL cp_fm_column_scale(fm_matrix_s_red, evals(ndep + 1:))
402
403 ! Obtain ortho from (P)DGEMM, skip the linear dependent columns
404 CALL parallel_gemm("N", "T", nao, nao, nmo, 1.0_dp, fm_matrix_s_red, evecs, &
405 0.0_dp, fm_matrix_s, b_first_col=ndep + 1)
406 ELSE
407 ! Take the square roots of the target values to allow application of SYRK
408 evals = sqrt(evals)
409 CALL cp_fm_column_scale(evecs, evals)
410 CALL cp_fm_syrk("U", "N", nao, 1.0_dp, evecs, 1, 1, 0.0_dp, fm_matrix_s)
411 CALL cp_fm_uplo_to_full(fm_matrix_s, fm_matrix_work)
412 END IF
413
414 CALL cp_fm_release(evecs)
415 cholesky_method = cholesky_off
416 ELSE
417 ! calculate S^(-1/2) (cholesky decomposition)
418 CALL cp_fm_cholesky_decompose(fm_matrix_s)
419 CALL cp_fm_triangular_invert(fm_matrix_s)
420 cholesky_method = cholesky_inverse
421 END IF
422
423 ALLOCATE (mos_mp2(nspins))
424 DO ispin = 1, nspins
425
426 CALL get_mo_set(mo_set=mos(ispin), maxocc=maxocc, nelectron=nelec(ispin))
427
428 CALL allocate_mo_set(mo_set=mos_mp2(ispin), &
429 nao=nao, &
430 nmo=nmo, &
431 nelectron=nelec(ispin), &
432 n_el_f=real(nelec(ispin), dp), &
433 maxocc=maxocc, &
434 flexible_electron_count=dft_control%relax_multiplicity)
435
436 CALL get_mo_set(mos_mp2(ispin), nao=nao)
437 CALL cp_fm_struct_create(fm_struct, nrow_global=nao, &
438 ncol_global=nmo, para_env=para_env, &
439 context=blacs_env)
440
441 CALL init_mo_set(mos_mp2(ispin), &
442 fm_struct=fm_struct, &
443 name="mp2_mos")
444 CALL cp_fm_struct_release(fm_struct)
445 END DO
446
447 DO ispin = 1, nspins
448
449 ! If ADMM we should make the ks matrix up-to-date
450 IF (dft_control%do_admm) THEN
451 CALL admm_correct_for_eigenvalues(ispin, admm_env, matrix_ks(ispin)%matrix)
452 END IF
453
454 CALL copy_dbcsr_to_fm(matrix_ks(ispin)%matrix, fm_matrix_ks)
455
456 IF (dft_control%do_admm) THEN
457 CALL admm_uncorrect_for_eigenvalues(ispin, admm_env, matrix_ks(ispin)%matrix)
458 END IF
459
460 IF (cholesky_method == cholesky_inverse) THEN
461
462 ! diagonalize KS matrix
463 CALL eigensolver(matrix_ks_fm=fm_matrix_ks, &
464 mo_set=mos_mp2(ispin), &
465 ortho=fm_matrix_s, &
466 work=fm_matrix_work, &
467 cholesky_method=cholesky_method, &
468 do_level_shift=.false., &
469 level_shift=0.0_dp, &
470 use_jacobi=.false.)
471
472 ELSE IF (cholesky_method == cholesky_off) THEN
473
474 IF (ASSOCIATED(fm_matrix_s_red)) THEN
475 CALL eigensolver_symm(matrix_ks_fm=fm_matrix_ks, &
476 mo_set=mos_mp2(ispin), &
477 ortho=fm_matrix_s, &
478 work=fm_matrix_work, &
479 do_level_shift=.false., &
480 level_shift=0.0_dp, &
481 use_jacobi=.false., &
482 jacobi_threshold=0.0_dp, &
483 ortho_red=fm_matrix_s_red, &
484 matrix_ks_fm_red=fm_matrix_ks_red, &
485 work_red=fm_work_red)
486 ELSE
487 CALL eigensolver_symm(matrix_ks_fm=fm_matrix_ks, &
488 mo_set=mos_mp2(ispin), &
489 ortho=fm_matrix_s, &
490 work=fm_matrix_work, &
491 do_level_shift=.false., &
492 level_shift=0.0_dp, &
493 use_jacobi=.false., &
494 jacobi_threshold=0.0_dp)
495 END IF
496 END IF
497
498 CALL get_mo_set(mos_mp2(ispin), mo_coeff=mo_coeff)
499 END DO
500
501 CALL cp_fm_release(fm_matrix_s)
502 CALL cp_fm_release(fm_matrix_ks)
503 CALL cp_fm_release(fm_matrix_work)
504 IF (ASSOCIATED(fm_matrix_s_red)) THEN
505 CALL cp_fm_release(fm_matrix_s_red)
506 DEALLOCATE (fm_matrix_s_red)
507 END IF
508 IF (ASSOCIATED(fm_matrix_ks_red)) THEN
509 CALL cp_fm_release(fm_matrix_ks_red)
510 DEALLOCATE (fm_matrix_ks_red)
511 END IF
512 IF (ASSOCIATED(fm_work_red)) THEN
513 CALL cp_fm_release(fm_work_red)
514 DEALLOCATE (fm_work_red)
515 END IF
516
517 hfx_sections => section_vals_get_subs_vals(input, "DFT%XC%HF")
518
519 ! build the table of index
520 t1 = m_walltime()
521 ALLOCATE (mp2_biel%index_table(natom, max_nset))
522
523 CALL build_index_table(natom, max_nset, mp2_biel%index_table, basis_parameter, kind_of)
524
525 ! free the hfx_container (for now if forces are required we don't release the HFX stuff)
526 free_hfx_buffer = .false.
527 IF (ASSOCIATED(qs_env%x_data)) THEN
528 free_hfx_buffer = .true.
529 IF (calc_forces .AND. (.NOT. mp2_env%ri_grad%free_hfx_buffer)) free_hfx_buffer = .false.
530 IF (qs_env%x_data(1, 1)%do_hfx_ri) free_hfx_buffer = .false.
531 IF (calc_forces .AND. mp2_env%do_im_time) free_hfx_buffer = .false.
532 IF (mp2_env%ri_rpa%reuse_hfx) free_hfx_buffer = .false.
533 END IF
534
535 IF (.NOT. do_kpoints_cubic_rpa) THEN
536 IF (virial%pv_numer) THEN
537 ! in the case of numerical stress we don't have to free the HFX integrals
538 free_hfx_buffer = .false.
539 mp2_env%ri_grad%free_hfx_buffer = free_hfx_buffer
540 END IF
541 END IF
542
543 ! calculate the matrix sigma_x - vxc for G0W0
544 t3 = 0
545 IF (mp2_env%ri_rpa%do_ri_g0w0) THEN
546 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)
547 END IF
548
549 IF (free_hfx_buffer) THEN
550 CALL timeset(routinen//"_free_hfx", handle2)
551 CALL section_vals_get(hfx_sections, n_repetition=n_rep_hf)
552 n_threads = 1
553!$ n_threads = omp_get_max_threads()
554
555 DO irep = 1, n_rep_hf
556 DO i_thread = 0, n_threads - 1
557 actual_x_data => qs_env%x_data(irep, i_thread + 1)
558
559 do_dynamic_load_balancing = .true.
560 IF (n_threads == 1 .OR. actual_x_data%memory_parameter%do_disk_storage) do_dynamic_load_balancing = .false.
561
562 IF (do_dynamic_load_balancing) THEN
563 my_bin_size = SIZE(actual_x_data%distribution_energy)
564 ELSE
565 my_bin_size = 1
566 END IF
567
568 IF (.NOT. actual_x_data%memory_parameter%do_all_on_the_fly) THEN
569 CALL dealloc_containers(actual_x_data%store_ints, actual_x_data%memory_parameter%actual_memory_usage)
570 END IF
571 END DO
572 END DO
573 CALL timestop(handle2)
574 END IF
575
576 emp2 = 0.d+00
577 emp2_cou = 0.d+00
578 emp2_ex = 0.d+00
579 calc_ex = .true.
580
581 t1 = m_walltime()
582 SELECT CASE (mp2_env%method)
583 CASE (mp2_method_direct)
584 IF (unit_nr > 0) WRITE (unit_nr, *)
585
586 ALLOCATE (auto(dimen, nspins))
587 ALLOCATE (c(dimen, dimen, nspins))
588
589 DO ispin = 1, nspins
590 ! get the alpha coeff and eigenvalues
591 CALL get_mo_set(mo_set=mos_mp2(ispin), &
592 eigenvalues=mo_eigenvalues, &
593 mo_coeff=mo_coeff)
594
595 CALL cp_fm_get_submatrix(mo_coeff, c(:, :, ispin), 1, 1, dimen, dimen, .false.)
596 auto(:, ispin) = mo_eigenvalues(:)
597 END DO
598
599 IF (nspins == 2) THEN
600 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Unrestricted Canonical Direct Methods:'
601 ! for now, require the mos to be always present
602
603 ! calculate the alpha-alpha MP2
604 emp2_aa = 0.0_dp
605 emp2_aa_cou = 0.0_dp
606 emp2_aa_ex = 0.0_dp
607 CALL mp2_direct_energy(dimen, nelec(1), nelec(1), mp2_biel, &
608 mp2_env, c(:, :, 1), auto(:, 1), emp2_aa, emp2_aa_cou, emp2_aa_ex, &
609 qs_env, para_env, unit_nr)
610 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy Alpha-Alpha = ', emp2_aa
611 IF (unit_nr > 0) WRITE (unit_nr, *)
612
613 emp2_bb = 0.0_dp
614 emp2_bb_cou = 0.0_dp
615 emp2_bb_ex = 0.0_dp
616 CALL mp2_direct_energy(dimen, nelec(2), nelec(2), mp2_biel, mp2_env, &
617 c(:, :, 2), auto(:, 2), emp2_bb, emp2_bb_cou, emp2_bb_ex, &
618 qs_env, para_env, unit_nr)
619 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy Beta-Beta= ', emp2_bb
620 IF (unit_nr > 0) WRITE (unit_nr, *)
621
622 emp2_ab = 0.0_dp
623 emp2_ab_cou = 0.0_dp
624 emp2_ab_ex = 0.0_dp
625 CALL mp2_direct_energy(dimen, nelec(1), nelec(2), mp2_biel, mp2_env, c(:, :, 1), &
626 auto(:, 1), emp2_ab, emp2_ab_cou, emp2_ab_ex, &
627 qs_env, para_env, unit_nr, c(:, :, 2), auto(:, 2))
628 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy Alpha-Beta= ', emp2_ab
629 IF (unit_nr > 0) WRITE (unit_nr, *)
630
631 emp2 = emp2_aa + emp2_bb + emp2_ab*2.0_dp !+Emp2_BA
632 emp2_cou = emp2_aa_cou + emp2_bb_cou + emp2_ab_cou*2.0_dp !+Emp2_BA
633 emp2_ex = emp2_aa_ex + emp2_bb_ex + emp2_ab_ex*2.0_dp !+Emp2_BA
634
635 emp2_s = emp2_ab*2.0_dp
636 emp2_t = emp2_aa + emp2_bb
637
638 ELSE
639
640 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A)') 'Canonical Direct Methods:'
641
642 CALL mp2_direct_energy(dimen, nelec(1)/2, nelec(1)/2, mp2_biel, mp2_env, &
643 c(:, :, 1), auto(:, 1), emp2, emp2_cou, emp2_ex, &
644 qs_env, para_env, unit_nr)
645
646 END IF
647
648 DEALLOCATE (c, auto)
649
651 ! optimize ri basis set or tests for RI-MP2 gradients
652 IF (unit_nr > 0) THEN
653 WRITE (unit_nr, *)
654 WRITE (unit_nr, '(T3,A)') 'Optimization of the auxiliary RI-MP2 basis'
655 WRITE (unit_nr, *)
656 END IF
657
658 ALLOCATE (auto(dimen, nspins))
659 ALLOCATE (c(dimen, dimen, nspins))
660
661 DO ispin = 1, nspins
662 ! get the alpha coeff and eigenvalues
663 CALL get_mo_set(mo_set=mos_mp2(ispin), &
664 eigenvalues=mo_eigenvalues, &
665 mo_coeff=mo_coeff)
666
667 CALL cp_fm_get_submatrix(mo_coeff, c(:, :, ispin), 1, 1, dimen, dimen, .false.)
668 auto(:, ispin) = mo_eigenvalues(:)
669 END DO
670
671 ! optimize basis
672 IF (nspins == 2) THEN
673 CALL optimize_ri_basis_main(emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, dimen, natom, nelec(1), &
674 mp2_biel, mp2_env, c(:, :, 1), auto(:, 1), &
675 kind_of, qs_env, para_env, unit_nr, &
676 nelec(2), c(:, :, 2), auto(:, 2))
677
678 ELSE
679 CALL optimize_ri_basis_main(emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, dimen, natom, nelec(1)/2, &
680 mp2_biel, mp2_env, c(:, :, 1), auto(:, 1), &
681 kind_of, qs_env, para_env, unit_nr)
682 END IF
683
684 DEALLOCATE (auto, c)
685
686 CASE (mp2_method_gpw)
687 ! check if calculate the exchange contribution
688 IF (mp2_env%scale_T == 0.0_dp .AND. (nspins == 2)) calc_ex = .false.
689
690 ! go with mp2_gpw
691 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
692 mos_mp2, para_env, unit_nr, calc_forces, calc_ex)
693
694 CASE (ri_mp2_method_gpw)
695 ! check if calculate the exchange contribution
696 IF (mp2_env%scale_T == 0.0_dp .AND. (nspins == 2)) calc_ex = .false.
697
698 ! go with mp2_gpw
699 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
700 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_mp2=.true.)
701
702 CASE (ri_rpa_method_gpw)
703 ! perform RI-RPA energy calculation (since most part of the calculation
704 ! is actually equal to the RI-MP2-GPW we decided to put RPA in the MP2
705 ! section to avoid code replication)
706
707 calc_ex = .false.
708
709 ! go with ri_rpa_gpw
710 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
711 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_rpa=.true.)
712 ! Scale energy contributions
713 emp2 = emp2*mp2_env%ri_rpa%scale_rpa
714 mp2_env%ri_rpa%ener_exchange = mp2_env%ri_rpa%ener_exchange*mp2_env%ri_rpa%scale_rpa
715
716 CASE (ri_mp2_laplace)
717 ! perform RI-SOS-Laplace-MP2 energy calculation, most part of the code in common
718 ! with the RI-RPA part
719
720 ! In SOS-MP2 only the coulomb-like contribution of the MP2 energy is computed
721 calc_ex = .false.
722
723 ! go with sos_laplace_mp2_gpw
724 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
725 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_sos_laplace_mp2=.true.)
726
727 CASE DEFAULT
728 cpabort("")
729 END SELECT
730
731 t2 = m_walltime()
732 IF (unit_nr > 0) WRITE (unit_nr, *)
733 IF (mp2_env%method .NE. ri_rpa_method_gpw) THEN
734 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.6)') 'Total MP2 Time=', t2 - t1
735 IF (mp2_env%method == ri_mp2_laplace) THEN
736 emp2_s = emp2
737 emp2_t = 0.0_dp
738 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy SO component (singlet) = ', emp2_s
739 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Scaling factor SO = ', mp2_env%scale_S
740 ELSE
741 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Coulomb Energy = ', emp2_cou/2.0_dp
742 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Exchange Energy = ', emp2_ex
743 IF (nspins == 1) THEN
744 ! valid only in the closed shell case
745 emp2_s = emp2_cou/2.0_dp
746 IF (calc_ex) THEN
747 emp2_t = emp2_ex + emp2_cou/2.0_dp
748 ELSE
749 ! unknown if Emp2_ex is not computed
750 emp2_t = 0.0_dp
751 END IF
752 END IF
753 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy SO component (singlet) = ', emp2_s
754 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'MP2 Energy SS component (triplet) = ', emp2_t
755 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Scaling factor SO = ', mp2_env%scale_S
756 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Scaling factor SS = ', mp2_env%scale_T
757 END IF
758 emp2_s = emp2_s*mp2_env%scale_S
759 emp2_t = emp2_t*mp2_env%scale_T
760 emp2 = emp2_s + emp2_t
761 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Second order perturbation energy = ', emp2
762 ELSE
763 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.6)') 'Total RI-RPA Time=', t2 - t1
764
765 update_xc_energy = .true.
766 IF (mp2_env%ri_rpa%do_ri_g0w0 .AND. .NOT. mp2_env%ri_g0w0%update_xc_energy) update_xc_energy = .false.
767 IF (.NOT. update_xc_energy) emp2 = 0.0_dp
768
769 IF (unit_nr > 0 .AND. update_xc_energy) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'RI-RPA energy = ', emp2
770 IF (unit_nr > 0 .AND. mp2_env%ri_rpa%sigma_param /= sigma_none) THEN
771 WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Sigma corr. to RI-RPA energy = ', &
772 mp2_env%ri_rpa%e_sigma_corr
773 END IF
774 IF (mp2_env%ri_rpa%exchange_correction == rpa_exchange_axk) THEN
775 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'RI-RPA-AXK energy=', mp2_env%ri_rpa%ener_exchange
776 ELSE IF (mp2_env%ri_rpa%exchange_correction == rpa_exchange_sosex) THEN
777 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'RI-RPA-SOSEX energy=', mp2_env%ri_rpa%ener_exchange
778 END IF
779 IF (mp2_env%ri_rpa%do_rse) THEN
780 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Diagonal singles correction (dRSE) = ', &
781 mp2_env%ri_rpa%rse_corr_diag
782 IF (unit_nr > 0) WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Full singles correction (RSE) =', &
783 mp2_env%ri_rpa%rse_corr
784 IF (dft_control%do_admm) cpabort("RPA RSE not implemented with RI_RPA%ADMM on")
785 END IF
786 END IF
787 IF (unit_nr > 0) WRITE (unit_nr, *)
788
789 ! we have it !!!!
790 IF (mp2_env%ri_rpa%exchange_correction /= rpa_exchange_none) THEN
791 emp2 = emp2 + mp2_env%ri_rpa%ener_exchange
792 END IF
793 IF (mp2_env%ri_rpa%do_rse) THEN
794 emp2 = emp2 + mp2_env%ri_rpa%rse_corr
795 END IF
796 IF (mp2_env%ri_rpa%sigma_param /= sigma_none) THEN
797 !WRITE (unit_nr, '(T3,A,T56,F25.14)') 'Sigma corr. to RI-RPA energy = ',&
798 emp2 = emp2 + mp2_env%ri_rpa%e_sigma_corr
799 END IF
800 energy%mp2 = emp2
801 energy%total = energy%total + emp2
802
803 DO ispin = 1, nspins
804 CALL deallocate_mo_set(mo_set=mos_mp2(ispin))
805 END DO
806 DEALLOCATE (mos_mp2)
807
808 ! if necessary reallocate hfx buffer
809 IF (free_hfx_buffer .AND. (.NOT. calc_forces) .AND. &
810 (mp2_env%ri_g0w0%do_ri_Sigma_x .OR. .NOT. mp2_env%ri_rpa_im_time%do_kpoints_from_Gamma)) THEN
811 CALL timeset(routinen//"_alloc_hfx", handle2)
812 DO irep = 1, n_rep_hf
813 DO i_thread = 0, n_threads - 1
814 actual_x_data => qs_env%x_data(irep, i_thread + 1)
815
816 do_dynamic_load_balancing = .true.
817 IF (n_threads == 1 .OR. actual_x_data%memory_parameter%do_disk_storage) do_dynamic_load_balancing = .false.
818
819 IF (do_dynamic_load_balancing) THEN
820 my_bin_size = SIZE(actual_x_data%distribution_energy)
821 ELSE
822 my_bin_size = 1
823 END IF
824
825 IF (.NOT. actual_x_data%memory_parameter%do_all_on_the_fly) THEN
826 CALL alloc_containers(actual_x_data%store_ints, my_bin_size)
827
828 DO bin = 1, my_bin_size
829 maxval_container => actual_x_data%store_ints%maxval_container(bin)
830 integral_containers => actual_x_data%store_ints%integral_containers(:, bin)
831 CALL hfx_init_container(maxval_container, actual_x_data%memory_parameter%actual_memory_usage, .false.)
832 DO i = 1, 64
833 CALL hfx_init_container(integral_containers(i), actual_x_data%memory_parameter%actual_memory_usage, .false.)
834 END DO
835 END DO
836 END IF
837 END DO
838 END DO
839 CALL timestop(handle2)
840 END IF
841
842 CALL hfx_release_basis_types(basis_parameter)
843
844 ! if required calculate the EXX contribution from the DFT density
845 IF (mp2_env%method == ri_rpa_method_gpw .AND. .NOT. calc_forces) THEN
846 do_exx = .false.
847 hfx_sections => section_vals_get_subs_vals(input, "DFT%XC%WF_CORRELATION%RI_RPA%HF")
848 CALL section_vals_get(hfx_sections, explicit=do_exx)
849 IF (do_exx) THEN
850 do_gw = mp2_env%ri_rpa%do_ri_g0w0
851 do_admm = mp2_env%ri_rpa%do_admm
852 reuse_hfx = qs_env%mp2_env%ri_rpa%reuse_hfx
853 do_im_time = qs_env%mp2_env%do_im_time
854
855 CALL calculate_exx(qs_env=qs_env, &
856 unit_nr=unit_nr, &
857 hfx_sections=hfx_sections, &
858 x_data=qs_env%mp2_env%ri_rpa%x_data, &
859 do_gw=do_gw, &
860 do_admm=do_admm, &
861 calc_forces=.false., &
862 reuse_hfx=reuse_hfx, &
863 do_im_time=do_im_time, &
864 e_ex_from_gw=e_ex_from_gw, &
865 e_admm_from_gw=e_admm_from_gw, &
866 t3=t3)
867
868 END IF
869 END IF
870
871 CALL cp_print_key_finished_output(unit_nr, logger, input, &
872 "DFT%XC%WF_CORRELATION%PRINT")
873
874 CALL timestop(handle)
875
876 END SUBROUTINE mp2_main
877
878! **************************************************************************************************
879!> \brief ...
880!> \param natom ...
881!> \param max_nset ...
882!> \param index_table ...
883!> \param basis_parameter ...
884!> \param kind_of ...
885! **************************************************************************************************
886 PURE SUBROUTINE build_index_table(natom, max_nset, index_table, basis_parameter, kind_of)
887 INTEGER, INTENT(IN) :: natom, max_nset
888 INTEGER, DIMENSION(natom, max_nset), INTENT(OUT) :: index_table
889 TYPE(hfx_basis_type), DIMENSION(:), POINTER :: basis_parameter
890 INTEGER, DIMENSION(natom), INTENT(IN) :: kind_of
891
892 INTEGER :: counter, iatom, ikind, iset, nset
893
894 index_table = -huge(0)
895 counter = 0
896 DO iatom = 1, natom
897 ikind = kind_of(iatom)
898 nset = basis_parameter(ikind)%nset
899 DO iset = 1, nset
900 index_table(iatom, iset) = counter + 1
901 counter = counter + basis_parameter(ikind)%nsgf(iset)
902 END DO
903 END DO
904
905 END SUBROUTINE build_index_table
906
907! **************************************************************************************************
908!> \brief ...
909!> \param matrix_s ...
910!> \param matrix_ks ...
911!> \param mos ...
912!> \param matrix_s_kp ...
913!> \param matrix_ks_transl ...
914!> \param kpoints ...
915! **************************************************************************************************
916 PURE SUBROUTINE get_gamma(matrix_s, matrix_ks, mos, matrix_s_kp, matrix_ks_transl, kpoints)
917
918 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s, matrix_ks
919 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
920 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_s_kp, matrix_ks_transl
921 TYPE(kpoint_type), POINTER :: kpoints
922
923 INTEGER :: nspins
924
925 nspins = SIZE(matrix_ks_transl, 1)
926
927 matrix_ks(1:nspins) => matrix_ks_transl(1:nspins, 1)
928 matrix_s(1:1) => matrix_s_kp(1:1, 1)
929 mos(1:nspins) => kpoints%kp_env(1)%kpoint_env%mos(1:nspins, 1)
930
931 END SUBROUTINE get_gamma
932
933END MODULE mp2
934
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:229
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)
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.