43 USE dbcsr_api,
ONLY: dbcsr_get_info,&
70 mp2_ri_optimize_basis,&
94 #include "./base/base_uses.f90"
100 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'mp2'
113 TYPE(qs_environment_type),
POINTER :: qs_env
114 LOGICAL,
INTENT(IN) :: calc_forces
116 CHARACTER(len=*),
PARAMETER :: routinen =
'mp2_main'
118 INTEGER :: bin, cholesky_method, dimen, handle, handle2, i, i_thread, iatom, ikind, irep, &
119 ispin, max_nset, my_bin_size, n_rep_hf, n_threads, nao, natom, ncol_block, ndep, &
120 nfullcols_total, nfullrows_total, nkind, nrow_block, nspins, unit_nr
121 INTEGER(KIND=int_8) :: mem
122 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of, nelec
123 LOGICAL :: calc_ex, do_admm, do_admm_rpa_exx, do_dynamic_load_balancing, do_exx, do_gw, &
124 do_im_time, do_kpoints_cubic_rpa, free_hfx_buffer, reuse_hfx, update_xc_energy
125 REAL(kind=
dp) :: e_admm_from_gw(2), e_ex_from_gw, emp2, emp2_aa, emp2_aa_cou, emp2_aa_ex, &
126 emp2_ab, emp2_ab_cou, emp2_ab_ex, emp2_bb, emp2_bb_cou, emp2_bb_ex, emp2_cou, emp2_ex, &
127 emp2_s, emp2_t, maxocc, mem_real, t1, t2, t3
128 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: auto
129 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: c
130 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
131 TYPE(admm_type),
POINTER :: admm_env
132 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
133 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
134 TYPE(cp_fm_struct_type),
POINTER :: fm_struct
135 TYPE(cp_fm_type) :: fm_matrix_ks, fm_matrix_s, fm_matrix_work
136 TYPE(cp_fm_type),
POINTER :: mo_coeff
137 TYPE(cp_logger_type),
POINTER :: logger
138 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
139 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_transl, matrix_s_kp
140 TYPE(dft_control_type),
POINTER :: dft_control
141 TYPE(hfx_basis_info_type) :: basis_info
142 TYPE(hfx_basis_type),
DIMENSION(:),
POINTER :: basis_parameter
143 TYPE(hfx_container_type),
DIMENSION(:),
POINTER :: integral_containers
144 TYPE(hfx_container_type),
POINTER :: maxval_container
145 TYPE(hfx_type),
POINTER :: actual_x_data
146 TYPE(kpoint_type),
POINTER :: kpoints
147 TYPE(mo_set_type),
ALLOCATABLE,
DIMENSION(:) :: mos_mp2
148 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
149 TYPE(mp2_biel_type) :: mp2_biel
150 TYPE(mp2_type),
POINTER :: mp2_env
151 TYPE(mp_para_env_type),
POINTER :: para_env
152 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
153 TYPE(qs_energy_type),
POINTER :: energy
154 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
155 TYPE(qs_scf_env_type),
POINTER :: scf_env
156 TYPE(scf_control_type),
POINTER :: scf_control
157 TYPE(section_vals_type),
POINTER :: hfx_sections, input
158 TYPE(virial_type),
POINTER :: virial
161 IF (qs_env%mp2_env%hf_fail)
THEN
162 CALL cp_abort(__location__,
"SCF not converged: "// &
163 "not possible to run MP2")
166 NULLIFY (virial, dft_control, blacs_env, kpoints)
167 CALL timeset(routinen, handle)
172 do_kpoints_cubic_rpa = qs_env%mp2_env%ri_rpa_im_time%do_im_time_kpoints
175 IF (do_kpoints_cubic_rpa)
THEN
179 atomic_kind_set=atomic_kind_set, &
180 qs_kind_set=qs_kind_set, &
181 dft_control=dft_control, &
182 particle_set=particle_set, &
184 blacs_env=blacs_env, &
188 scf_control=scf_control, &
189 matrix_ks_kp=matrix_ks_transl, &
190 matrix_s_kp=matrix_s_kp, &
193 CALL get_gamma(matrix_s, matrix_ks, mos, &
194 matrix_s_kp, matrix_ks_transl, kpoints)
200 atomic_kind_set=atomic_kind_set, &
201 qs_kind_set=qs_kind_set, &
202 dft_control=dft_control, &
203 particle_set=particle_set, &
205 blacs_env=blacs_env, &
209 scf_control=scf_control, &
211 matrix_ks=matrix_ks, &
221 IF (unit_nr > 0)
THEN
222 IF (mp2_env%method .NE. ri_rpa_method_gpw)
THEN
225 WRITE (unit_nr,
'(T2,A)')
'MP2 section'
226 WRITE (unit_nr,
'(T2,A)')
'-----------'
231 WRITE (unit_nr,
'(T2,A)')
'RI-RPA section'
232 WRITE (unit_nr,
'(T2,A)')
'--------------'
237 IF (calc_forces)
THEN
241 IF (.NOT. (mp2_env%method == ri_mp2_method_gpw .OR. mp2_env%method == ri_rpa_method_gpw .OR. mp2_env%method == ri_mp2_laplace))
THEN
242 cpabort(
"No forces/gradients for the selected method.")
246 IF (.NOT. do_kpoints_cubic_rpa)
THEN
247 IF (virial%pv_availability .AND. (.NOT. virial%pv_numer) .AND. mp2_env%eri_method ==
do_eri_mme)
THEN
248 cpabort(
"analytical stress not implemented with ERI_METHOD = MME")
252 IF (mp2_env%do_im_time .AND. mp2_env%eri_method .NE.
do_eri_gpw)
THEN
253 mp2_env%mp2_num_proc = 1
256 IF (mp2_env%mp2_num_proc < 1 .OR. mp2_env%mp2_num_proc > para_env%num_pe)
THEN
257 cpwarn(
"GROUP_SIZE is reset because of a too small or too large value.")
258 mp2_env%mp2_num_proc = max(min(para_env%num_pe, mp2_env%mp2_num_proc), 1)
261 IF (mod(para_env%num_pe, mp2_env%mp2_num_proc) /= 0)
THEN
262 cpabort(
"GROUP_SIZE must be a divisor of the total number of MPI ranks!")
265 IF (.NOT. mp2_env%do_im_time)
THEN
266 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T76,I5)')
'Used number of processes per group:', mp2_env%mp2_num_proc
267 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T68,F9.2,A4)')
'Maximum allowed memory usage per MPI process:', &
268 mp2_env%mp2_memory,
' MiB'
271 IF ((mp2_env%method .NE. mp2_method_gpw) .AND. &
272 (mp2_env%method .NE. ri_mp2_method_gpw) .AND. &
273 (mp2_env%method .NE. ri_rpa_method_gpw) .AND. &
274 (mp2_env%method .NE. ri_mp2_laplace))
THEN
276 mem_real = (mem + 1024*1024 - 1)/(1024*1024)
277 CALL para_env%max(mem_real)
278 mp2_env%mp2_memory = mp2_env%mp2_memory - mem_real
279 IF (mp2_env%mp2_memory < 0.0_dp) mp2_env%mp2_memory = 1.0_dp
281 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T68,F9.2,A4)')
'Available memory per MPI process for MP2:', &
282 mp2_env%mp2_memory,
' MiB'
285 IF (unit_nr > 0)
CALL m_flush(unit_nr)
287 nspins = dft_control%nspins
288 natom =
SIZE(particle_set, 1)
291 nkind =
SIZE(atomic_kind_set, 1)
293 do_admm_rpa_exx = mp2_env%ri_rpa%do_admm
294 IF (do_admm_rpa_exx .AND. .NOT. dft_control%do_admm)
THEN
295 cpabort(
"Need an ADMM input section for ADMM RI_RPA EXX to work")
297 IF (do_admm_rpa_exx)
THEN
306 ikind = kind_of(iatom)
307 dimen = dimen + sum(basis_parameter(ikind)%nsgf)
308 max_nset = max(max_nset, basis_parameter(ikind)%nset)
316 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
318 ncol_global=nfullcols_total, para_env=para_env)
319 CALL cp_fm_create(fm_matrix_s, fm_struct, name=
"fm_matrix_s")
322 CALL cp_fm_create(fm_matrix_ks, fm_struct, name=
"fm_matrix_ks")
324 CALL cp_fm_create(fm_matrix_work, fm_struct, name=
"fm_matrix_work")
329 CALL cp_fm_get_info(matrix=fm_matrix_ks, nrow_block=nrow_block, ncol_block=ncol_block)
332 CALL cp_fm_power(fm_matrix_s, fm_matrix_work, -0.5_dp, scf_control%eps_eigval, ndep)
341 ALLOCATE (mos_mp2(nspins))
342 ALLOCATE (nelec(nspins))
346 IF (dft_control%do_admm)
THEN
352 IF (dft_control%do_admm)
THEN
356 CALL get_mo_set(mo_set=mos(ispin), maxocc=maxocc, nelectron=nelec(ispin))
361 nelectron=nelec(ispin), &
362 n_el_f=real(nelec(ispin),
dp), &
364 flexible_electron_count=dft_control%relax_multiplicity)
368 ncol_global=nao, para_env=para_env, &
372 fm_struct=fm_struct, &
380 mo_set=mos_mp2(ispin), &
382 work=fm_matrix_work, &
383 cholesky_method=cholesky_method, &
384 do_level_shift=.false., &
385 level_shift=0.0_dp, &
391 mo_set=mos_mp2(ispin), &
393 work=fm_matrix_work, &
394 do_level_shift=.false., &
395 level_shift=0.0_dp, &
396 use_jacobi=.false., &
397 jacobi_threshold=0.0_dp)
403 CALL cp_fm_release(fm_matrix_s)
404 CALL cp_fm_release(fm_matrix_ks)
405 CALL cp_fm_release(fm_matrix_work)
411 ALLOCATE (mp2_biel%index_table(natom, max_nset))
413 CALL build_index_table(natom, max_nset, mp2_biel%index_table, basis_parameter, kind_of)
416 free_hfx_buffer = .false.
417 IF (
ASSOCIATED(qs_env%x_data))
THEN
418 free_hfx_buffer = .true.
419 IF (calc_forces .AND. (.NOT. mp2_env%ri_grad%free_hfx_buffer)) free_hfx_buffer = .false.
420 IF (qs_env%x_data(1, 1)%do_hfx_ri) free_hfx_buffer = .false.
421 IF (calc_forces .AND. mp2_env%do_im_time) free_hfx_buffer = .false.
422 IF (mp2_env%ri_rpa%reuse_hfx) free_hfx_buffer = .false.
425 IF (.NOT. do_kpoints_cubic_rpa)
THEN
426 IF (virial%pv_numer)
THEN
428 free_hfx_buffer = .false.
429 mp2_env%ri_grad%free_hfx_buffer = free_hfx_buffer
435 IF (mp2_env%ri_rpa%do_ri_g0w0)
THEN
439 IF (free_hfx_buffer)
THEN
440 CALL timeset(routinen//
"_free_hfx", handle2)
445 DO irep = 1, n_rep_hf
446 DO i_thread = 0, n_threads - 1
447 actual_x_data => qs_env%x_data(irep, i_thread + 1)
449 do_dynamic_load_balancing = .true.
450 IF (n_threads == 1 .OR. actual_x_data%memory_parameter%do_disk_storage) do_dynamic_load_balancing = .false.
452 IF (do_dynamic_load_balancing)
THEN
453 my_bin_size =
SIZE(actual_x_data%distribution_energy)
458 IF (.NOT. actual_x_data%memory_parameter%do_all_on_the_fly)
THEN
459 CALL dealloc_containers(actual_x_data%store_ints, actual_x_data%memory_parameter%actual_memory_usage)
463 CALL timestop(handle2)
472 SELECT CASE (mp2_env%method)
473 CASE (mp2_method_direct)
474 IF (unit_nr > 0)
WRITE (unit_nr, *)
476 ALLOCATE (auto(dimen, nspins))
477 ALLOCATE (c(dimen, dimen, nspins))
482 eigenvalues=mo_eigenvalues, &
486 auto(:, ispin) = mo_eigenvalues(:)
489 IF (nspins == 2)
THEN
490 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A)')
'Unrestricted Canonical Direct Methods:'
498 mp2_env, c(:, :, 1), auto(:, 1), emp2_aa, emp2_aa_cou, emp2_aa_ex, &
499 qs_env, para_env, unit_nr)
500 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'MP2 Energy Alpha-Alpha = ', emp2_aa
501 IF (unit_nr > 0)
WRITE (unit_nr, *)
507 c(:, :, 2), auto(:, 2), emp2_bb, emp2_bb_cou, emp2_bb_ex, &
508 qs_env, para_env, unit_nr)
509 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'MP2 Energy Beta-Beta= ', emp2_bb
510 IF (unit_nr > 0)
WRITE (unit_nr, *)
515 CALL mp2_direct_energy(dimen, nelec(1), nelec(2), mp2_biel, mp2_env, c(:, :, 1), &
516 auto(:, 1), emp2_ab, emp2_ab_cou, emp2_ab_ex, &
517 qs_env, para_env, unit_nr, c(:, :, 2), auto(:, 2))
518 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'MP2 Energy Alpha-Beta= ', emp2_ab
519 IF (unit_nr > 0)
WRITE (unit_nr, *)
521 emp2 = emp2_aa + emp2_bb + emp2_ab*2.0_dp
522 emp2_cou = emp2_aa_cou + emp2_bb_cou + emp2_ab_cou*2.0_dp
523 emp2_ex = emp2_aa_ex + emp2_bb_ex + emp2_ab_ex*2.0_dp
525 emp2_s = emp2_ab*2.0_dp
526 emp2_t = emp2_aa + emp2_bb
530 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A)')
'Canonical Direct Methods:'
533 c(:, :, 1), auto(:, 1), emp2, emp2_cou, emp2_ex, &
534 qs_env, para_env, unit_nr)
540 CASE (mp2_ri_optimize_basis)
542 IF (unit_nr > 0)
THEN
544 WRITE (unit_nr,
'(T3,A)')
'Optimization of the auxiliary RI-MP2 basis'
548 ALLOCATE (auto(dimen, nspins))
549 ALLOCATE (c(dimen, dimen, nspins))
554 eigenvalues=mo_eigenvalues, &
558 auto(:, ispin) = mo_eigenvalues(:)
562 IF (nspins == 2)
THEN
564 mp2_biel, mp2_env, c(:, :, 1), auto(:, 1), &
565 kind_of, qs_env, para_env, unit_nr, &
566 nelec(2), c(:, :, 2), auto(:, 2))
570 mp2_biel, mp2_env, c(:, :, 1), auto(:, 1), &
571 kind_of, qs_env, para_env, unit_nr)
576 CASE (mp2_method_gpw)
578 IF (mp2_env%scale_T == 0.0_dp .AND. (nspins == 2)) calc_ex = .false.
581 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
582 mos_mp2, para_env, unit_nr, calc_forces, calc_ex)
584 CASE (ri_mp2_method_gpw)
586 IF (mp2_env%scale_T == 0.0_dp .AND. (nspins == 2)) calc_ex = .false.
589 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
590 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_mp2=.true.)
592 CASE (ri_rpa_method_gpw)
600 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
601 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_rpa=.true.)
604 emp2 = emp2*mp2_env%ri_rpa%scale_rpa
605 mp2_env%ri_rpa%ener_axk = mp2_env%ri_rpa%ener_axk*mp2_env%ri_rpa%scale_rpa
607 CASE (ri_mp2_laplace)
615 CALL mp2_gpw_main(qs_env, mp2_env, emp2, emp2_cou, emp2_ex, emp2_s, emp2_t, &
616 mos_mp2, para_env, unit_nr, calc_forces, calc_ex, do_ri_sos_laplace_mp2=.true.)
623 IF (unit_nr > 0)
WRITE (unit_nr, *)
624 IF (mp2_env%method .NE. ri_rpa_method_gpw)
THEN
625 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.6)')
'Total MP2 Time=', t2 - t1
626 IF (mp2_env%method == ri_mp2_laplace)
THEN
629 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'MP2 Energy SO component (singlet) = ', emp2_s
630 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'Scaling factor SO = ', mp2_env%scale_S
632 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'MP2 Coulomb Energy = ', emp2_cou/2.0_dp
633 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'MP2 Exchange Energy = ', emp2_ex
634 IF (nspins == 1)
THEN
636 emp2_s = emp2_cou/2.0_dp
638 emp2_t = emp2_ex + emp2_cou/2.0_dp
644 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'MP2 Energy SO component (singlet) = ', emp2_s
645 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'MP2 Energy SS component (triplet) = ', emp2_t
646 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'Scaling factor SO = ', mp2_env%scale_S
647 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'Scaling factor SS = ', mp2_env%scale_T
649 emp2_s = emp2_s*mp2_env%scale_S
650 emp2_t = emp2_t*mp2_env%scale_T
651 emp2 = emp2_s + emp2_t
652 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'Second order perturbation energy = ', emp2
654 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.6)')
'Total RI-RPA Time=', t2 - t1
656 update_xc_energy = .true.
657 IF (mp2_env%ri_rpa%do_ri_g0w0 .AND. .NOT. mp2_env%ri_g0w0%update_xc_energy) update_xc_energy = .false.
658 IF (.NOT. update_xc_energy) emp2 = 0.0_dp
660 IF (unit_nr > 0 .AND. update_xc_energy)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'RI-RPA energy = ', emp2
661 IF (mp2_env%ri_rpa%do_ri_axk)
THEN
662 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'RI-RPA-AXK energy=', mp2_env%ri_rpa%ener_axk
664 IF (mp2_env%ri_rpa%do_rse)
THEN
665 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'Diagonal singles correction (dRSE) = ', &
666 mp2_env%ri_rpa%rse_corr_diag
667 IF (unit_nr > 0)
WRITE (unit_nr,
'(T3,A,T56,F25.14)')
'Full singles correction (RSE) =', &
668 mp2_env%ri_rpa%rse_corr
669 IF (dft_control%do_admm) cpabort(
"RPA RSE not implemented with RI_RPA%ADMM on")
672 IF (unit_nr > 0)
WRITE (unit_nr, *)
675 IF (mp2_env%ri_rpa%do_ri_axk)
THEN
676 emp2 = emp2 + mp2_env%ri_rpa%ener_axk
678 IF (mp2_env%ri_rpa%do_rse)
THEN
679 emp2 = emp2 + mp2_env%ri_rpa%rse_corr
682 energy%total = energy%total + emp2
690 IF (free_hfx_buffer .AND. (.NOT. calc_forces) .AND. &
691 (mp2_env%ri_g0w0%do_ri_Sigma_x .OR. .NOT. mp2_env%ri_rpa_im_time%do_kpoints_from_Gamma))
THEN
692 CALL timeset(routinen//
"_alloc_hfx", handle2)
693 DO irep = 1, n_rep_hf
694 DO i_thread = 0, n_threads - 1
695 actual_x_data => qs_env%x_data(irep, i_thread + 1)
697 do_dynamic_load_balancing = .true.
698 IF (n_threads == 1 .OR. actual_x_data%memory_parameter%do_disk_storage) do_dynamic_load_balancing = .false.
700 IF (do_dynamic_load_balancing)
THEN
701 my_bin_size =
SIZE(actual_x_data%distribution_energy)
706 IF (.NOT. actual_x_data%memory_parameter%do_all_on_the_fly)
THEN
709 DO bin = 1, my_bin_size
710 maxval_container => actual_x_data%store_ints%maxval_container(bin)
711 integral_containers => actual_x_data%store_ints%integral_containers(:, bin)
712 CALL hfx_init_container(maxval_container, actual_x_data%memory_parameter%actual_memory_usage, .false.)
714 CALL hfx_init_container(integral_containers(i), actual_x_data%memory_parameter%actual_memory_usage, .false.)
720 CALL timestop(handle2)
726 IF (mp2_env%method == ri_rpa_method_gpw .AND. .NOT. calc_forces)
THEN
731 do_gw = mp2_env%ri_rpa%do_ri_g0w0
732 do_admm = mp2_env%ri_rpa%do_admm
733 reuse_hfx = qs_env%mp2_env%ri_rpa%reuse_hfx
734 do_im_time = qs_env%mp2_env%do_im_time
738 hfx_sections=hfx_sections, &
739 x_data=qs_env%mp2_env%ri_rpa%x_data, &
742 calc_forces=.false., &
743 reuse_hfx=reuse_hfx, &
744 do_im_time=do_im_time, &
745 e_ex_from_gw=e_ex_from_gw, &
746 e_admm_from_gw=e_admm_from_gw, &
753 "DFT%XC%WF_CORRELATION%PRINT")
755 CALL timestop(handle)
767 PURE SUBROUTINE build_index_table(natom, max_nset, index_table, basis_parameter, kind_of)
768 INTEGER,
INTENT(IN) :: natom, max_nset
769 INTEGER,
DIMENSION(natom, max_nset),
INTENT(OUT) :: index_table
770 TYPE(hfx_basis_type),
DIMENSION(:),
POINTER :: basis_parameter
771 INTEGER,
DIMENSION(natom),
INTENT(IN) :: kind_of
773 INTEGER :: counter, iatom, ikind, iset, nset
775 index_table = -huge(0)
778 ikind = kind_of(iatom)
779 nset = basis_parameter(ikind)%nset
781 index_table(iatom, iset) = counter + 1
782 counter = counter + basis_parameter(ikind)%nsgf(iset)
786 END SUBROUTINE build_index_table
797 PURE SUBROUTINE get_gamma(matrix_s, matrix_ks, mos, matrix_s_kp, matrix_ks_transl, kpoints)
799 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, matrix_ks
800 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
801 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp, matrix_ks_transl
802 TYPE(kpoint_type),
POINTER :: kpoints
806 nspins =
SIZE(matrix_ks_transl, 1)
808 matrix_ks(1:nspins) => matrix_ks_transl(1:nspins, 1)
809 matrix_s(1:1) => matrix_s_kp(1:1, 1)
810 mos(1:nspins) => kpoints%kp_env(1)%kpoint_env%mos(1:nspins, 1)
812 END SUBROUTINE get_gamma
Types and set/get functions for auxiliary density matrix methods.
Contains methods used in the context of density fitting.
subroutine, public admm_uncorrect_for_eigenvalues(ispin, admm_env, ks_matrix)
...
subroutine, public admm_correct_for_eigenvalues(ispin, admm_env, ks_matrix)
...
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 rybkin2016
integer, save, public delben2012
integer, save, public delben2015b
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
basic linear algebra operations for full matrices
subroutine, public cp_fm_triangular_invert(matrix_a, uplo_tr)
inverts a triangular matrix
various cholesky decomposition related routines
subroutine, public cp_fm_cholesky_decompose(matrix, n, info_out)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public cp_fm_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
...
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
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
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.
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)
...
Types and set/get functions for HFX.
subroutine, public dealloc_containers(DATA, memory_usage)
...
subroutine, public alloc_containers(DATA, bin_size)
...
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.
subroutine, public hfx_release_basis_types(basis_parameter)
...
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
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
Types and basic routines needed for a kpoint calculation.
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_memory(mem)
Returns the total amount of memory [bytes] in use, if known, zero otherwise.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
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.
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
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.
Routines to calculate MP2 energy.
subroutine, public mp2_main(qs_env, calc_forces)
the main entry point for MP2 calculations
Define the data structure for the particle information.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, WannierCentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
Definition and initialisation of the mo data type.
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_symm(matrix_ks_fm, mo_set, ortho, work, do_level_shift, level_shift, matrix_u_fm, use_jacobi, jacobi_threshold)
...
subroutine, public eigensolver(matrix_ks_fm, mo_set, ortho, work, cholesky_method, do_level_shift, level_shift, matrix_u_fm, use_jacobi)
Diagonalise the Kohn-Sham matrix to get a new set of MO eigen- vectors and MO eigenvalues....
module that contains the definitions of the scf types
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