76#include "./base/base_uses.f90"
82 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'mp2_ri_grad'
113 atomic_kind_set, qs_kind_set, mo_coeff, nmo, homo, dimen_RI, Eigenval, &
114 my_group_L_start, my_group_L_end, my_group_L_size, sab_orb_sub, mat_munu, &
122 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
123 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: mo_coeff
124 INTEGER,
INTENT(IN) :: nmo
125 INTEGER,
DIMENSION(:),
INTENT(IN) :: homo
126 INTEGER,
INTENT(IN) :: dimen_ri
127 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: eigenval
128 INTEGER,
INTENT(IN) :: my_group_l_start, my_group_l_end, &
131 POINTER :: sab_orb_sub
135 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_ri_mp2_nonsep'
137 INTEGER :: dimen, eri_method, handle, handle2, i, &
138 ikind, ispin, itmp(2), l_counter, lll, &
139 my_p_end, my_p_size, my_p_start, nspins
140 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind, kind_of, natom_of_kind, &
142 LOGICAL :: alpha_beta, use_virial
143 REAL(kind=
dp) :: cutoff_old, eps_filter, factor, &
144 factor_2c, relative_cutoff_old
145 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: e_cutoff_old
146 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: g_pq_local, g_pq_local_2
147 REAL(kind=
dp),
DIMENSION(3, 3) :: h_stress, pv_virial
148 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: i_tmp2
151 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: l1_mu_i, l2_nu_a
153 TYPE(
dbcsr_p_type),
ALLOCATABLE,
DIMENSION(:) :: mo_coeff_o, mo_coeff_v
154 TYPE(
dbcsr_p_type),
ALLOCATABLE,
DIMENSION(:, :) :: g_p_ia
155 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_munu_local, matrix_p_munu_local
157 TYPE(
dbcsr_type),
ALLOCATABLE,
DIMENSION(:) :: lag_mu_i_1, lag_nu_a_2, matrix_p_inu
159 TYPE(
mp2_eri_force),
ALLOCATABLE,
DIMENSION(:) :: force_2c, force_2c_ri, force_3c_aux, &
160 force_3c_orb_mu, force_3c_orb_nu
166 TYPE(
qs_force_type),
DIMENSION(:),
POINTER :: force, mp2_force
171 CALL timeset(routinen, handle)
173 eri_method = mp2_env%eri_method
174 eri_param => mp2_env%eri_mme_param
178 alpha_beta = (nspins == 2)
181 ALLOCATE (virtual(nspins))
182 virtual(:) = dimen - homo(:)
183 eps_filter = mp2_env%mp2_gpw%eps_filter
184 ALLOCATE (mo_coeff_o(nspins), mo_coeff_v(nspins), g_p_ia(nspins, my_group_l_size))
186 mo_coeff_o(ispin)%matrix => mp2_env%ri_grad%mo_coeff_o(ispin)%matrix
187 mo_coeff_v(ispin)%matrix => mp2_env%ri_grad%mo_coeff_v(ispin)%matrix
188 DO lll = 1, my_group_l_size
189 g_p_ia(ispin, lll)%matrix => mp2_env%ri_grad%G_P_ia(lll, ispin)%matrix
192 DEALLOCATE (mp2_env%ri_grad%G_P_ia)
194 itmp =
get_limit(dimen_ri, para_env_sub%num_pe, para_env_sub%mepos)
197 my_p_size = itmp(2) - itmp(1) + 1
199 ALLOCATE (g_pq_local(dimen_ri, my_group_l_size))
201 g_pq_local(my_p_start:my_p_end, :) = mp2_env%ri_grad%Gamma_PQ
202 DEALLOCATE (mp2_env%ri_grad%Gamma_PQ)
203 g_pq_local(my_p_start:my_p_end, :) = g_pq_local(my_p_start:my_p_end, :)/real(nspins,
dp)
204 CALL para_env_sub%sum(g_pq_local)
206 ALLOCATE (g_pq_local_2(dimen_ri, my_group_l_size))
207 g_pq_local_2 = 0.0_dp
208 g_pq_local_2(my_p_start:my_p_end, :) = mp2_env%ri_grad%Gamma_PQ_2
209 DEALLOCATE (mp2_env%ri_grad%Gamma_PQ_2)
210 g_pq_local_2(my_p_start:my_p_end, :) = g_pq_local_2(my_p_start:my_p_end, :)/real(nspins,
dp)
211 CALL para_env_sub%sum(g_pq_local_2)
215 ALLOCATE (matrix_p_inu(nspins))
217 CALL dbcsr_create(matrix_p_inu(ispin), template=mo_coeff_o(ispin)%matrix)
221 CALL dbcsr_create(matrix_p_munu_nosym, template=mat_munu%matrix, &
222 matrix_type=dbcsr_type_no_symmetry)
225 ALLOCATE (lag_mu_i_1(nspins))
227 CALL dbcsr_create(lag_mu_i_1(ispin), template=mo_coeff_o(ispin)%matrix)
228 CALL dbcsr_set(lag_mu_i_1(ispin), 0.0_dp)
231 ALLOCATE (lag_nu_a_2(nspins))
233 CALL dbcsr_create(lag_nu_a_2(ispin), template=mo_coeff_v(ispin)%matrix)
234 CALL dbcsr_set(lag_nu_a_2(ispin), 0.0_dp)
238 NULLIFY (force, virial)
239 CALL get_qs_env(qs_env=qs_env, force=force, virial=virial)
242 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
247 DEALLOCATE (natom_of_kind)
249 mp2_env%ri_grad%mp2_force => mp2_force
254 IF (alpha_beta) factor_2c = -2.0_dp
259 ALLOCATE (matrix_p_munu_local(my_group_l_size))
260 ALLOCATE (mat_munu_local(my_group_l_size))
262 DO lll = my_group_l_start, my_group_l_end
263 l_counter = l_counter + 1
264 ALLOCATE (mat_munu_local(l_counter)%matrix)
265 CALL dbcsr_create(mat_munu_local(l_counter)%matrix, template=mat_munu%matrix, &
266 matrix_type=dbcsr_type_symmetric)
267 CALL dbcsr_copy(mat_munu_local(l_counter)%matrix, mat_munu%matrix)
268 CALL dbcsr_set(mat_munu_local(l_counter)%matrix, 0.0_dp)
270 CALL g_p_transform_mo_to_ao(matrix_p_munu_local(l_counter)%matrix, matrix_p_munu_nosym, mat_munu%matrix, &
271 g_p_ia(:, l_counter), matrix_p_inu, &
272 mo_coeff_v, mo_coeff_o, eps_filter)
275 ALLOCATE (i_tmp2(dimen_ri, my_group_l_size))
276 i_tmp2(:, :) = 0.0_dp
278 basis_type_a=
"RI_AUX", basis_type_b=
"RI_AUX", &
279 hab=i_tmp2, first_b=my_group_l_start, last_b=my_group_l_end, &
280 eri_method=eri_method, pab=g_pq_local, force_a=force_2c)
282 i_tmp2(:, :) = 0.0_dp
284 basis_type_a=
"RI_AUX", basis_type_b=
"RI_AUX", &
285 hab=i_tmp2, first_b=my_group_l_start, last_b=my_group_l_end, &
286 eri_method=eri_method, pab=g_pq_local_2, force_a=force_2c_ri)
291 first_c=my_group_l_start, last_c=my_group_l_end, mat_ab=mat_munu_local, &
292 basis_type_a=
"ORB", basis_type_b=
"ORB", basis_type_c=
"RI_AUX", &
293 sab_nl=sab_orb_sub, eri_method=eri_method, &
294 pabc=matrix_p_munu_local, &
295 force_a=force_3c_orb_mu, force_b=force_3c_orb_nu, force_c=force_3c_aux)
298 DO lll = my_group_l_start, my_group_l_end
299 l_counter = l_counter + 1
301 CALL dbcsr_multiply(
"N",
"T", 1.0_dp, mo_coeff_v(ispin)%matrix, g_p_ia(ispin, l_counter)%matrix, &
302 0.0_dp, matrix_p_inu(ispin), filter_eps=eps_filter)
306 CALL update_lagrangian(mat_munu_local(l_counter)%matrix, matrix_p_inu, lag_mu_i_1, &
307 g_p_ia(:, l_counter), mo_coeff_o, lag_nu_a_2, &
311 DO ikind = 1,
SIZE(force)
312 mp2_force(ikind)%mp2_non_sep(:, :) = factor_2c*force_2c(ikind)%forces(:, :) + &
313 force_3c_orb_mu(ikind)%forces(:, :) + &
314 force_3c_orb_nu(ikind)%forces(:, :) + &
315 force_3c_aux(ikind)%forces(:, :)
318 mp2_force(ikind)%mp2_non_sep(:, :) = mp2_force(ikind)%mp2_non_sep(:, :) + factor_2c*force_2c_ri(ikind)%forces
338 CALL prepare_gpw(qs_env, dft_control, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, &
339 auxbas_pw_pool, poisson_env, task_list_sub, rho_r, rho_g, pot_g, psi_l, sab_orb_sub)
345 CALL auxbas_pw_pool%create_pw(rho_g_copy)
347 CALL auxbas_pw_pool%create_pw(dvg(i))
352 CALL timeset(routinen//
"_loop", handle2)
354 IF (use_virial) h_stress = 0.0_dp
357 DO lll = my_group_l_start, my_group_l_end
358 l_counter = l_counter + 1
360 CALL g_p_transform_mo_to_ao(matrix_p_munu%matrix, matrix_p_munu_nosym, mat_munu%matrix, &
361 g_p_ia(:, l_counter), matrix_p_inu, &
362 mo_coeff_v, mo_coeff_o, eps_filter)
365 qs_kind_set, particle_set, cell, pw_env_sub, poisson_env, &
366 pot_g, mp2_env%potential_parameter, use_virial, &
367 rho_g_copy, dvg, kind_of, atom_of_kind, g_pq_local(:, l_counter), &
368 mp2_force, h_stress, para_env_sub, dft_control, psi_l, factor_2c)
373 qs_kind_set, particle_set, cell, pw_env_sub, poisson_env, &
374 pot_g, mp2_env%ri_metric, use_virial, &
375 rho_g_copy, dvg, kind_of, atom_of_kind, g_pq_local_2(:, l_counter), &
376 mp2_force, h_stress, para_env_sub, dft_control, psi_l, factor_2c)
379 IF (use_virial) pv_virial = virial%pv_virial
383 h_stress = h_stress + (virial%pv_virial - pv_virial)
384 virial%pv_virial = pv_virial
388 CALL update_lagrangian(mat_munu%matrix, matrix_p_inu, lag_mu_i_1, &
389 g_p_ia(:, l_counter), mo_coeff_o, lag_nu_a_2, &
394 ks_env, poisson_env, pot_g, use_virial, rho_g_copy, dvg, &
395 h_stress, para_env_sub, kind_of, atom_of_kind, &
396 qs_kind_set, particle_set, cell, lll, mp2_force, dft_control)
399 CALL timestop(handle2)
402 DEALLOCATE (atom_of_kind)
405 CALL auxbas_pw_pool%give_back_pw(rho_g_copy)
407 CALL auxbas_pw_pool%give_back_pw(dvg(i))
411 CALL cleanup_gpw(qs_env, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, &
412 task_list_sub, auxbas_pw_pool, rho_r, rho_g, pot_g, psi_l)
415 DEALLOCATE (matrix_p_munu%matrix)
419 IF (use_virial) mp2_env%ri_grad%mp2_virial = h_stress
421 DEALLOCATE (g_pq_local)
429 DEALLOCATE (matrix_p_inu, g_p_ia)
433 DO ikind = 1,
SIZE(mp2_force)
434 mp2_force(ikind)%mp2_non_sep(:, :) = force(ikind)%rho_elec(:, :)
435 force(ikind)%rho_elec(:, :) = 0.0_dp
443 ALLOCATE (l1_mu_i(nspins), l2_nu_a(nspins))
448 NULLIFY (fm_struct_tmp)
450 nrow_global=dimen, ncol_global=homo(ispin))
451 CALL cp_fm_create(l1_mu_i(ispin), fm_struct_tmp, name=
"Lag_mu_i")
459 NULLIFY (fm_struct_tmp)
461 nrow_global=dimen, ncol_global=virtual(ispin))
462 CALL cp_fm_create(l2_nu_a(ispin), fm_struct_tmp, name=
"Lag_nu_a")
470 DEALLOCATE (lag_mu_i_1, lag_nu_a_2)
474 IF (alpha_beta) factor = 0.50_dp
477 CALL create_w_p(qs_env, mp2_env, mo_coeff(ispin), homo(ispin), virtual(ispin), dimen, para_env, &
478 para_env_sub, eigenval(:, ispin), l1_mu_i(ispin), l2_nu_a(ispin), &
481 DEALLOCATE (l1_mu_i, l2_nu_a)
483 CALL timestop(handle)
498 SUBROUTINE g_p_transform_mo_to_ao(G_P_munu, G_P_munu_nosym, mat_munu, G_P_ia, G_P_inu, &
499 mo_coeff_v, mo_coeff_o, eps_filter)
501 TYPE(
dbcsr_type),
INTENT(INOUT) :: g_p_munu_nosym, mat_munu
503 TYPE(
dbcsr_type),
DIMENSION(:),
INTENT(INOUT) :: g_p_inu
504 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(IN) :: mo_coeff_v, mo_coeff_o
505 REAL(kind=
dp),
INTENT(IN) :: eps_filter
507 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_P_transform_MO_to_AO'
511 IF (.NOT.
ASSOCIATED(g_p_munu))
THEN
514 matrix_type=dbcsr_type_symmetric)
517 CALL g_p_transform_alpha_beta(g_p_ia, g_p_inu, g_p_munu_nosym, mo_coeff_v, mo_coeff_o, eps_filter)
520 CALL timeset(routinen//
"_symmetrize", handle)
523 CALL dbcsr_add(g_p_munu, g_p_munu_nosym, &
524 alpha_scalar=2.0_dp, beta_scalar=2.0_dp)
526 CALL dbcsr_copy(mat_munu, g_p_munu, keep_sparsity=.true.)
529 CALL timestop(handle)
531 END SUBROUTINE g_p_transform_mo_to_ao
542 SUBROUTINE g_p_transform_alpha_beta(G_P_ia, G_P_inu, G_P_munu, mo_coeff_v, mo_coeff_o, eps_filter)
544 TYPE(
dbcsr_type),
DIMENSION(:),
INTENT(INOUT) :: g_p_inu
546 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(IN) :: mo_coeff_v, mo_coeff_o
547 REAL(kind=
dp),
INTENT(IN) :: eps_filter
549 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_P_transform_alpha_beta'
551 INTEGER :: handle, ispin
552 REAL(kind=
dp) :: factor
554 CALL timeset(routinen, handle)
556 factor = 1.0_dp/real(
SIZE(g_p_ia),
dp)
560 DO ispin = 1,
SIZE(g_p_ia)
562 CALL dbcsr_multiply(
"N",
"T", 1.0_dp, mo_coeff_v(ispin)%matrix, g_p_ia(ispin)%matrix, &
563 0.0_dp, g_p_inu(ispin), filter_eps=eps_filter)
566 CALL dbcsr_multiply(
"N",
"T", factor, g_p_inu(ispin), mo_coeff_o(ispin)%matrix, &
567 1.0_dp, g_p_munu, filter_eps=eps_filter)
570 CALL timestop(handle)
572 END SUBROUTINE g_p_transform_alpha_beta
584 SUBROUTINE update_lagrangian(mat_munu, matrix_P_inu, Lag_mu_i_1, &
585 G_P_ia, mo_coeff_o, Lag_nu_a_2, &
588 TYPE(
dbcsr_type),
DIMENSION(:),
INTENT(INOUT) :: matrix_p_inu, lag_mu_i_1
589 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT) :: g_p_ia
590 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(IN) :: mo_coeff_o
591 TYPE(
dbcsr_type),
DIMENSION(:),
INTENT(INOUT) :: lag_nu_a_2
592 REAL(kind=
dp),
INTENT(IN) :: eps_filter
594 CHARACTER(LEN=*),
PARAMETER :: routinen =
'update_lagrangian'
596 INTEGER :: handle, ispin
599 CALL timeset(routinen, handle)
601 DO ispin = 1,
SIZE(g_p_ia)
604 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, mat_munu, matrix_p_inu(ispin), &
605 1.0_dp, lag_mu_i_1(ispin), filter_eps=eps_filter)
608 CALL dbcsr_set(matrix_p_inu(ispin), 0.0_dp)
609 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, mat_munu, mo_coeff_o(ispin)%matrix, &
610 0.0_dp, matrix_p_inu(ispin), filter_eps=eps_filter)
614 CALL dbcsr_multiply(
"N",
"N", -1.0_dp, matrix_p_inu(ispin), g_p_ia(ispin)%matrix, &
615 1.0_dp, lag_nu_a_2(ispin), filter_eps=eps_filter)
619 DEALLOCATE (g_p_ia(ispin)%matrix)
622 CALL timestop(handle)
624 END SUBROUTINE update_lagrangian
642 SUBROUTINE create_w_p(qs_env, mp2_env, mo_coeff, homo, virtual, dimen, para_env, para_env_sub, &
643 Eigenval, L1_mu_i, L2_nu_a, factor, kspin)
647 INTEGER,
INTENT(IN) :: homo, virtual, dimen
649 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: eigenval
650 TYPE(
cp_fm_type),
INTENT(INOUT) :: l1_mu_i, l2_nu_a
651 REAL(kind=
dp),
INTENT(IN) :: factor
652 INTEGER,
INTENT(IN) :: kspin
654 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_W_P'
656 INTEGER :: color_exchange, dummy_proc, handle, handle2, handle3, i_global, i_local, iib, &
657 iii, iproc, itmp(2), j_global, j_local, jjb, max_col_size, max_row_size, &
658 my_b_virtual_end, my_b_virtual_start, mypcol, myprow, ncol_local, ncol_local_1i, &
659 ncol_local_2a, npcol, nprow, nrow_local, nrow_local_1i, nrow_local_2a, number_of_rec, &
660 number_of_send, proc_receive, proc_receive_static, proc_send, proc_send_ex, &
661 proc_send_static, proc_send_sub, proc_shift, rec_col_size, rec_counter, rec_row_size, &
662 send_col_size, send_counter, send_pcol, send_prow, send_row_size, size_rec_buffer, &
664 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iii_vet, map_rec_size, map_send_size, &
665 pos_info, pos_info_ex, proc_2_send_pos
666 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: grid_2_mepos, mepos_2_grid, my_col_indeces_info_1i, &
667 my_col_indeces_info_2a, my_row_indeces_info_1i, my_row_indeces_info_2a, sizes, sizes_1i, &
669 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: col_indeces_info_1i, &
670 col_indeces_info_2a, &
671 row_indeces_info_1i, &
673 INTEGER,
DIMENSION(:),
POINTER :: col_indices, col_indices_1i, &
674 col_indices_2a, row_indices, &
675 row_indices_1i, row_indices_2a
676 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ab_rec, ab_send, mat_rec, mat_send
681 DIMENSION(:) :: buffer_rec, buffer_send
683 DIMENSION(:) :: buffer_cyclic
687 CALL timeset(routinen, handle)
693 NULLIFY (fm_struct_tmp)
695 nrow_global=dimen, ncol_global=dimen)
696 CALL cp_fm_create(l_mu_q, fm_struct_tmp, name=
"Lag_mu_q")
701 ALLOCATE (pos_info(0:para_env%num_pe - 1))
702 CALL para_env%allgather(para_env_sub%mepos, pos_info)
706 nrow_local=nrow_local, &
707 ncol_local=ncol_local, &
708 row_indices=row_indices, &
709 col_indices=col_indices)
710 myprow = l_mu_q%matrix_struct%context%mepos(1)
711 mypcol = l_mu_q%matrix_struct%context%mepos(2)
712 nprow = l_mu_q%matrix_struct%context%num_pe(1)
713 npcol = l_mu_q%matrix_struct%context%num_pe(2)
715 ALLOCATE (grid_2_mepos(0:nprow - 1, 0:npcol - 1))
717 grid_2_mepos(myprow, mypcol) = para_env%mepos
718 CALL para_env%sum(grid_2_mepos)
722 nrow_local=nrow_local_1i, &
723 ncol_local=ncol_local_1i, &
724 row_indices=row_indices_1i, &
725 col_indices=col_indices_1i)
727 ALLOCATE (sizes_1i(2, 0:para_env_sub%num_pe - 1))
728 CALL para_env_sub%allgather([nrow_local_1i, ncol_local_1i], sizes_1i)
732 nrow_local=nrow_local_2a, &
733 ncol_local=ncol_local_2a, &
734 row_indices=row_indices_2a, &
735 col_indices=col_indices_2a)
737 ALLOCATE (sizes_2a(2, 0:para_env_sub%num_pe - 1))
738 CALL para_env_sub%allgather([nrow_local_2a, ncol_local_2a], sizes_2a)
749 color_exchange = para_env_sub%mepos
750 ALLOCATE (para_env_exchange)
751 CALL para_env_exchange%from_split(para_env, color_exchange)
752 ALLOCATE (pos_info_ex(0:para_env%num_pe - 1))
753 CALL para_env%allgather(para_env_exchange%mepos, pos_info_ex)
754 ALLOCATE (sizes(2, 0:para_env_exchange%num_pe - 1))
755 CALL para_env_exchange%allgather([nrow_local, ncol_local], sizes)
758 CALL timeset(routinen//
"_inx", handle2)
760 max_row_size = maxval(sizes_1i(1, :))
761 max_col_size = maxval(sizes_1i(2, :))
762 ALLOCATE (row_indeces_info_1i(2, max_row_size, 0:para_env_sub%num_pe - 1))
763 ALLOCATE (col_indeces_info_1i(2, max_col_size, 0:para_env_sub%num_pe - 1))
764 ALLOCATE (my_row_indeces_info_1i(2, max_row_size))
765 ALLOCATE (my_col_indeces_info_1i(2, max_col_size))
766 row_indeces_info_1i = 0
767 col_indeces_info_1i = 0
770 DO iib = 1, nrow_local_1i
771 i_global = row_indices_1i(iib)
772 send_prow = l_mu_q%matrix_struct%g2p_row(i_global)
773 i_local = l_mu_q%matrix_struct%g2l_row(i_global)
774 my_row_indeces_info_1i(1, iib) = send_prow
775 my_row_indeces_info_1i(2, iib) = i_local
778 DO jjb = 1, ncol_local_1i
779 j_global = col_indices_1i(jjb)
780 send_pcol = l_mu_q%matrix_struct%g2p_col(j_global)
781 j_local = l_mu_q%matrix_struct%g2l_col(j_global)
782 my_col_indeces_info_1i(1, jjb) = send_pcol
783 my_col_indeces_info_1i(2, jjb) = j_local
785 CALL para_env_sub%allgather(my_row_indeces_info_1i, row_indeces_info_1i)
786 CALL para_env_sub%allgather(my_col_indeces_info_1i, col_indeces_info_1i)
787 DEALLOCATE (my_row_indeces_info_1i, my_col_indeces_info_1i)
790 max_row_size = maxval(sizes_2a(1, :))
791 max_col_size = maxval(sizes_2a(2, :))
792 ALLOCATE (row_indeces_info_2a(2, max_row_size, 0:para_env_sub%num_pe - 1))
793 ALLOCATE (col_indeces_info_2a(2, max_col_size, 0:para_env_sub%num_pe - 1))
794 ALLOCATE (my_row_indeces_info_2a(2, max_row_size))
795 ALLOCATE (my_col_indeces_info_2a(2, max_col_size))
796 row_indeces_info_2a = 0
797 col_indeces_info_2a = 0
799 DO iib = 1, nrow_local_2a
800 i_global = row_indices_2a(iib)
801 send_prow = l_mu_q%matrix_struct%g2p_row(i_global)
802 i_local = l_mu_q%matrix_struct%g2l_row(i_global)
803 my_row_indeces_info_2a(1, iib) = send_prow
804 my_row_indeces_info_2a(2, iib) = i_local
807 DO jjb = 1, ncol_local_2a
808 j_global = col_indices_2a(jjb) + homo
809 send_pcol = l_mu_q%matrix_struct%g2p_col(j_global)
810 j_local = l_mu_q%matrix_struct%g2l_col(j_global)
811 my_col_indeces_info_2a(1, jjb) = send_pcol
812 my_col_indeces_info_2a(2, jjb) = j_local
814 CALL para_env_sub%allgather(my_row_indeces_info_2a, row_indeces_info_2a)
815 CALL para_env_sub%allgather(my_col_indeces_info_2a, col_indeces_info_2a)
816 DEALLOCATE (my_row_indeces_info_2a, my_col_indeces_info_2a)
817 CALL timestop(handle2)
820 CALL timeset(routinen//
"_subinfo", handle2)
821 ALLOCATE (map_send_size(0:para_env_sub%num_pe - 1))
823 DO jjb = 1, ncol_local_1i
824 send_pcol = col_indeces_info_1i(1, jjb, para_env_sub%mepos)
825 DO iib = 1, nrow_local_1i
826 send_prow = row_indeces_info_1i(1, iib, para_env_sub%mepos)
827 proc_send = grid_2_mepos(send_prow, send_pcol)
828 proc_send_sub = pos_info(proc_send)
829 map_send_size(proc_send_sub) = map_send_size(proc_send_sub) + 1
833 DO jjb = 1, ncol_local_2a
834 send_pcol = col_indeces_info_2a(1, jjb, para_env_sub%mepos)
835 DO iib = 1, nrow_local_2a
836 send_prow = row_indeces_info_2a(1, iib, para_env_sub%mepos)
837 proc_send = grid_2_mepos(send_prow, send_pcol)
838 proc_send_sub = pos_info(proc_send)
839 map_send_size(proc_send_sub) = map_send_size(proc_send_sub) + 1
843 ALLOCATE (map_rec_size(0:para_env_sub%num_pe - 1))
845 CALL para_env_sub%alltoall(map_send_size, map_rec_size, 1)
846 CALL timestop(handle2)
849 CALL timeset(routinen//
"_sub_Bsend", handle2)
852 DO proc_shift = 0, para_env_sub%num_pe - 1
853 proc_send =
modulo(para_env_sub%mepos + proc_shift, para_env_sub%num_pe)
854 IF (map_send_size(proc_send) > 0)
THEN
855 number_of_send = number_of_send + 1
859 ALLOCATE (buffer_send(number_of_send))
861 ALLOCATE (proc_2_send_pos(0:para_env_sub%num_pe - 1))
863 DO proc_shift = 0, para_env_sub%num_pe - 1
864 proc_send =
modulo(para_env_sub%mepos + proc_shift, para_env_sub%num_pe)
865 size_send_buffer = map_send_size(proc_send)
866 IF (map_send_size(proc_send) > 0)
THEN
867 send_counter = send_counter + 1
869 ALLOCATE (buffer_send(send_counter)%msg(size_send_buffer))
870 buffer_send(send_counter)%msg = 0.0_dp
871 buffer_send(send_counter)%proc = proc_send
872 proc_2_send_pos(proc_send) = send_counter
878 ALLOCATE (iii_vet(number_of_send))
880 DO jjb = 1, ncol_local_1i
881 send_pcol = col_indeces_info_1i(1, jjb, para_env_sub%mepos)
882 DO iib = 1, nrow_local_1i
883 send_prow = row_indeces_info_1i(1, iib, para_env_sub%mepos)
884 proc_send = grid_2_mepos(send_prow, send_pcol)
885 proc_send_sub = pos_info(proc_send)
886 send_counter = proc_2_send_pos(proc_send_sub)
887 iii_vet(send_counter) = iii_vet(send_counter) + 1
888 iii = iii_vet(send_counter)
889 buffer_send(send_counter)%msg(iii) = l1_mu_i%local_data(iib, jjb)
893 DEALLOCATE (l1_mu_i%local_data)
895 DO jjb = 1, ncol_local_2a
896 send_pcol = col_indeces_info_2a(1, jjb, para_env_sub%mepos)
897 DO iib = 1, nrow_local_2a
898 send_prow = row_indeces_info_2a(1, iib, para_env_sub%mepos)
899 proc_send = grid_2_mepos(send_prow, send_pcol)
900 proc_send_sub = pos_info(proc_send)
901 send_counter = proc_2_send_pos(proc_send_sub)
902 iii_vet(send_counter) = iii_vet(send_counter) + 1
903 iii = iii_vet(send_counter)
904 buffer_send(send_counter)%msg(iii) = l2_nu_a%local_data(iib, jjb)
907 DEALLOCATE (l2_nu_a%local_data)
908 DEALLOCATE (proc_2_send_pos)
910 CALL timestop(handle2)
914 CALL timeset(routinen//
"_sub_isendrecv", handle2)
917 DO proc_shift = 0, para_env_sub%num_pe - 1
918 proc_receive =
modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
919 IF (map_rec_size(proc_receive) > 0)
THEN
920 number_of_rec = number_of_rec + 1
923 ALLOCATE (buffer_rec(number_of_rec))
925 DO proc_shift = 0, para_env_sub%num_pe - 1
926 proc_receive =
modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
927 size_rec_buffer = map_rec_size(proc_receive)
928 IF (map_rec_size(proc_receive) > 0)
THEN
929 rec_counter = rec_counter + 1
931 ALLOCATE (buffer_rec(rec_counter)%msg(size_rec_buffer))
932 buffer_rec(rec_counter)%msg = 0.0_dp
933 buffer_rec(rec_counter)%proc = proc_receive
935 IF (proc_receive /= para_env_sub%mepos)
THEN
936 CALL para_env_sub%irecv(buffer_rec(rec_counter)%msg, proc_receive, &
937 buffer_rec(rec_counter)%msg_req)
942 ALLOCATE (req_send(number_of_send))
945 DO proc_shift = 0, para_env_sub%num_pe - 1
946 proc_send =
modulo(para_env_sub%mepos + proc_shift, para_env_sub%num_pe)
947 IF (map_send_size(proc_send) > 0)
THEN
948 send_counter = send_counter + 1
949 IF (proc_send == para_env_sub%mepos)
THEN
950 buffer_rec(send_counter)%msg(:) = buffer_send(send_counter)%msg
952 CALL para_env_sub%isend(buffer_send(send_counter)%msg, proc_send, &
953 buffer_send(send_counter)%msg_req)
954 req_send(send_counter) = buffer_send(send_counter)%msg_req
958 DEALLOCATE (map_send_size)
959 CALL timestop(handle2)
965 CALL timeset(routinen//
"_Bcyclic", handle2)
967 ALLOCATE (buffer_cyclic(0:para_env_exchange%num_pe - 1))
968 DO iproc = 0, para_env_exchange%num_pe - 1
969 rec_row_size = sizes(1, iproc)
970 rec_col_size = sizes(2, iproc)
971 ALLOCATE (buffer_cyclic(iproc)%msg(rec_row_size, rec_col_size))
972 buffer_cyclic(iproc)%msg = 0.0_dp
977 DO proc_shift = 0, para_env_sub%num_pe - 1
978 proc_receive =
modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
979 size_rec_buffer = map_rec_size(proc_receive)
980 IF (map_rec_size(proc_receive) > 0)
THEN
981 rec_counter = rec_counter + 1
984 IF (proc_receive /= para_env_sub%mepos)
CALL buffer_rec(rec_counter)%msg_req%wait()
986 CALL timeset(routinen//
"_fill", handle3)
988 DO jjb = 1, sizes_1i(2, proc_receive)
989 send_pcol = col_indeces_info_1i(1, jjb, proc_receive)
990 j_local = col_indeces_info_1i(2, jjb, proc_receive)
991 DO iib = 1, sizes_1i(1, proc_receive)
992 send_prow = row_indeces_info_1i(1, iib, proc_receive)
993 proc_send = grid_2_mepos(send_prow, send_pcol)
994 proc_send_sub = pos_info(proc_send)
995 IF (proc_send_sub /= para_env_sub%mepos) cycle
997 i_local = row_indeces_info_1i(2, iib, proc_receive)
998 proc_send_ex = pos_info_ex(proc_send)
999 buffer_cyclic(proc_send_ex)%msg(i_local, j_local) = buffer_rec(rec_counter)%msg(iii)
1003 DO jjb = 1, sizes_2a(2, proc_receive)
1004 send_pcol = col_indeces_info_2a(1, jjb, proc_receive)
1005 j_local = col_indeces_info_2a(2, jjb, proc_receive)
1006 DO iib = 1, sizes_2a(1, proc_receive)
1007 send_prow = row_indeces_info_2a(1, iib, proc_receive)
1008 proc_send = grid_2_mepos(send_prow, send_pcol)
1009 proc_send_sub = pos_info(proc_send)
1010 IF (proc_send_sub /= para_env_sub%mepos) cycle
1012 i_local = row_indeces_info_2a(2, iib, proc_receive)
1013 proc_send_ex = pos_info_ex(proc_send)
1014 buffer_cyclic(proc_send_ex)%msg(i_local, j_local) = buffer_rec(rec_counter)%msg(iii)
1017 CALL timestop(handle3)
1020 DEALLOCATE (buffer_rec(rec_counter)%msg)
1023 DEALLOCATE (row_indeces_info_1i)
1024 DEALLOCATE (col_indeces_info_1i)
1025 DEALLOCATE (row_indeces_info_2a)
1026 DEALLOCATE (col_indeces_info_2a)
1027 DEALLOCATE (buffer_rec)
1028 DEALLOCATE (map_rec_size)
1029 CALL timestop(handle2)
1032 CALL timeset(routinen//
"_sub_waitall", handle2)
1034 DO send_counter = 1, number_of_send
1035 DEALLOCATE (buffer_send(send_counter)%msg)
1037 DEALLOCATE (buffer_send)
1038 DEALLOCATE (req_send)
1039 CALL timestop(handle2)
1042 CALL timeset(routinen//
"_ring", handle2)
1043 proc_send_static =
modulo(para_env_exchange%mepos + 1, para_env_exchange%num_pe)
1044 proc_receive_static =
modulo(para_env_exchange%mepos - 1, para_env_exchange%num_pe)
1045 max_row_size = maxval(sizes(1, :))
1046 max_col_size = maxval(sizes(2, :))
1047 ALLOCATE (mat_send(max_row_size, max_col_size))
1048 ALLOCATE (mat_rec(max_row_size, max_col_size))
1050 mat_send(1:nrow_local, 1:ncol_local) = buffer_cyclic(para_env_exchange%mepos)%msg(:, :)
1051 DEALLOCATE (buffer_cyclic(para_env_exchange%mepos)%msg)
1052 DO proc_shift = 1, para_env_exchange%num_pe - 1
1053 proc_receive =
modulo(para_env_exchange%mepos - proc_shift, para_env_exchange%num_pe)
1055 rec_row_size = sizes(1, proc_receive)
1056 rec_col_size = sizes(2, proc_receive)
1059 CALL para_env_exchange%sendrecv(mat_send, proc_send_static, &
1060 mat_rec, proc_receive_static)
1063 mat_send(1:rec_row_size, 1:rec_col_size) = mat_rec(1:rec_row_size, 1:rec_col_size) + &
1064 buffer_cyclic(proc_receive)%msg(:, :)
1066 DEALLOCATE (buffer_cyclic(proc_receive)%msg)
1069 CALL para_env_exchange%sendrecv(mat_send, proc_send_static, &
1070 mat_rec, proc_receive_static)
1071 l_mu_q%local_data(1:nrow_local, 1:ncol_local) = mat_rec(1:nrow_local, 1:ncol_local)
1072 DEALLOCATE (buffer_cyclic)
1073 DEALLOCATE (mat_send)
1074 DEALLOCATE (mat_rec)
1075 CALL timestop(handle2)
1082 DEALLOCATE (pos_info_ex)
1083 DEALLOCATE (grid_2_mepos)
1085 DEALLOCATE (sizes_1i)
1086 DEALLOCATE (sizes_2a)
1090 CALL timeset(routinen//
"_Pij", handle2)
1091 NULLIFY (fm_struct_tmp)
1093 nrow_global=homo, ncol_global=homo)
1094 CALL cp_fm_create(fm_p_ij, fm_struct_tmp, name=
"fm_P_ij")
1100 nrow_local=nrow_local, &
1101 ncol_local=ncol_local, &
1102 row_indices=row_indices, &
1103 col_indices=col_indices)
1107 mo_coeff, l_mu_q, 0.0_dp, fm_p_ij, &
1115 l_mu_q, mo_coeff, 2.0_dp, fm_p_ij, &
1123 DO jjb = 1, ncol_local
1124 j_global = col_indices(jjb)
1125 DO iib = 1, nrow_local
1126 i_global = row_indices(iib)
1128 IF (abs(eigenval(j_global) - eigenval(i_global)) < mp2_env%ri_grad%eps_canonical)
THEN
1129 fm_p_ij%local_data(iib, jjb) = mp2_env%ri_grad%P_ij(kspin)%array(i_global, j_global)
1131 fm_p_ij%local_data(iib, jjb) = &
1132 factor*fm_p_ij%local_data(iib, jjb)/(eigenval(j_global) - eigenval(i_global))
1137 DO jjb = 1, ncol_local
1138 j_global = col_indices(jjb)
1139 DO iib = 1, nrow_local
1140 i_global = row_indices(iib)
1141 fm_p_ij%local_data(iib, jjb) = mp2_env%ri_grad%P_ij(kspin)%array(i_global, j_global)
1146 DEALLOCATE (mp2_env%ri_grad%P_ij(kspin)%array)
1147 CALL timestop(handle2)
1151 IF (.NOT.
ALLOCATED(mp2_env%ri_grad%P_mo))
THEN
1152 ALLOCATE (mp2_env%ri_grad%P_mo(
SIZE(mp2_env%ri_grad%mo_coeff_o)))
1155 CALL timeset(routinen//
"_PMO", handle2)
1156 NULLIFY (fm_struct_tmp)
1158 nrow_global=dimen, ncol_global=dimen)
1159 CALL cp_fm_create(mp2_env%ri_grad%P_mo(kspin), fm_struct_tmp, name=
"P_MP2_MO")
1163 itmp =
get_limit(virtual, para_env_sub%num_pe, para_env_sub%mepos)
1164 my_b_virtual_start = itmp(1)
1165 my_b_virtual_end = itmp(2)
1168 CALL cp_fm_to_fm_submat(fm_p_ij, mp2_env%ri_grad%P_mo(kspin), homo, homo, 1, 1, 1, 1)
1172 nrow_local=nrow_local, &
1173 ncol_local=ncol_local, &
1174 row_indices=row_indices, &
1175 col_indices=col_indices)
1178 CALL parallel_gemm(
'T',
'N', virtual, virtual, dimen, 1.0_dp, &
1179 mo_coeff, l_mu_q, 0.0_dp, mp2_env%ri_grad%P_mo(kspin), &
1180 a_first_col=homo + 1, &
1182 b_first_col=homo + 1, &
1184 c_first_col=homo + 1, &
1185 c_first_row=homo + 1)
1186 CALL parallel_gemm(
'T',
'N', virtual, virtual, dimen, -2.0_dp, &
1187 l_mu_q, mo_coeff, 2.0_dp, mp2_env%ri_grad%P_mo(kspin), &
1188 a_first_col=homo + 1, &
1190 b_first_col=homo + 1, &
1192 c_first_col=homo + 1, &
1193 c_first_row=homo + 1)
1198 DO jjb = 1, ncol_local
1199 j_global = col_indices(jjb)
1200 IF (j_global <= homo) cycle
1201 DO iib = 1, nrow_local
1202 i_global = row_indices(iib)
1203 IF (my_b_virtual_start <= i_global - homo .AND. i_global - homo <= my_b_virtual_end)
THEN
1204 mp2_env%ri_grad%P_mo(kspin)%local_data(iib, jjb) = &
1205 mp2_env%ri_grad%P_ab(kspin)%array(i_global - homo - my_b_virtual_start + 1, j_global - homo)
1211 DO jjb = 1, ncol_local
1212 j_global = col_indices(jjb)
1213 IF (j_global <= homo) cycle
1214 DO iib = 1, nrow_local
1215 i_global = row_indices(iib)
1216 IF (abs(eigenval(i_global) - eigenval(j_global)) < mp2_env%ri_grad%eps_canonical)
THEN
1217 IF (my_b_virtual_start <= i_global - homo .AND. i_global - homo <= my_b_virtual_end)
THEN
1218 mp2_env%ri_grad%P_mo(kspin)%local_data(iib, jjb) = &
1219 mp2_env%ri_grad%P_ab(kspin)%array(i_global - homo - my_b_virtual_start + 1, j_global - homo)
1221 mp2_env%ri_grad%P_mo(kspin)%local_data(iib, jjb) = 0.0_dp
1224 mp2_env%ri_grad%P_mo(kspin)%local_data(iib, jjb) = &
1225 factor*mp2_env%ri_grad%P_mo(kspin)%local_data(iib, jjb)/ &
1226 (eigenval(i_global) - eigenval(j_global))
1231 cpabort(
"Calculation of virt-virt block of density matrix is dealt with elsewhere!")
1236 ALLOCATE (mepos_2_grid(2, 0:para_env_sub%num_pe - 1))
1237 CALL para_env_sub%allgather([myprow, mypcol], mepos_2_grid)
1239 ALLOCATE (sizes(2, 0:para_env_sub%num_pe - 1))
1240 CALL para_env_sub%allgather([nrow_local, ncol_local], sizes)
1242 ALLOCATE (ab_rec(nrow_local, ncol_local))
1243 DO proc_shift = 1, para_env_sub%num_pe - 1
1244 proc_send =
modulo(para_env_sub%mepos + proc_shift, para_env_sub%num_pe)
1245 proc_receive =
modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
1247 send_prow = mepos_2_grid(1, proc_send)
1248 send_pcol = mepos_2_grid(2, proc_send)
1250 send_row_size = sizes(1, proc_send)
1251 send_col_size = sizes(2, proc_send)
1253 ALLOCATE (ab_send(send_row_size, send_col_size))
1257 DO iib = 1, send_row_size
1258 i_global = mp2_env%ri_grad%P_mo(kspin)%matrix_struct%l2g_row(iib, send_prow)
1259 IF (i_global <= homo) cycle
1260 i_global = i_global - homo
1261 IF (.NOT. (my_b_virtual_start <= i_global .AND. i_global <= my_b_virtual_end)) cycle
1262 DO jjb = 1, send_col_size
1263 j_global = mp2_env%ri_grad%P_mo(kspin)%matrix_struct%l2g_col(jjb, send_pcol)
1264 IF (j_global <= homo) cycle
1265 j_global = j_global - homo
1266 ab_send(iib, jjb) = mp2_env%ri_grad%P_ab(kspin)%array(i_global - my_b_virtual_start + 1, j_global)
1271 CALL para_env_sub%sendrecv(ab_send, proc_send, &
1272 ab_rec, proc_receive)
1273 mp2_env%ri_grad%P_mo(kspin)%local_data(1:nrow_local, 1:ncol_local) = &
1274 mp2_env%ri_grad%P_mo(kspin)%local_data(1:nrow_local, 1:ncol_local) + &
1275 ab_rec(1:nrow_local, 1:ncol_local)
1277 DEALLOCATE (ab_send)
1280 DEALLOCATE (mepos_2_grid)
1284 DEALLOCATE (mp2_env%ri_grad%P_ab(kspin)%array)
1285 CALL timestop(handle2)
1288 CALL timeset(routinen//
"_WMO", handle2)
1289 IF (.NOT.
ALLOCATED(mp2_env%ri_grad%W_mo))
THEN
1290 ALLOCATE (mp2_env%ri_grad%W_mo(
SIZE(mp2_env%ri_grad%mo_coeff_o)))
1293 CALL cp_fm_create(mp2_env%ri_grad%W_mo(kspin), fm_struct_tmp, name=
"W_MP2_MO")
1297 CALL parallel_gemm(
'T',
'N', dimen, dimen, dimen, 2.0_dp*factor, &
1298 l_mu_q, mo_coeff, 0.0_dp, mp2_env%ri_grad%W_mo(kspin), &
1307 CALL parallel_gemm(
'T',
'N', homo, homo, dimen, -2.0_dp*factor, &
1308 l_mu_q, mo_coeff, 0.0_dp, mp2_env%ri_grad%W_mo(kspin), &
1317 CALL parallel_gemm(
'T',
'N', homo, virtual, dimen, 2.0_dp*factor, &
1318 mo_coeff, l_mu_q, 0.0_dp, mp2_env%ri_grad%W_mo(kspin), &
1321 b_first_col=homo + 1, &
1323 c_first_col=homo + 1, &
1325 CALL timestop(handle2)
1328 CALL timeset(routinen//
"_Ljb", handle2)
1329 IF (.NOT.
ALLOCATED(mp2_env%ri_grad%L_jb))
THEN
1330 ALLOCATE (mp2_env%ri_grad%L_jb(
SIZE(mp2_env%ri_grad%mo_coeff_o)))
1334 nrow_global=homo, ncol_global=virtual)
1335 CALL cp_fm_create(mp2_env%ri_grad%L_jb(kspin), fm_struct_tmp, name=
"fm_L_jb")
1339 CALL parallel_gemm(
'T',
'N', homo, virtual, dimen, 2.0_dp*factor, &
1340 l_mu_q, mo_coeff, 0.0_dp, mp2_env%ri_grad%L_jb(kspin), &
1343 b_first_col=homo + 1, &
1348 CALL parallel_gemm(
'T',
'N', homo, virtual, dimen, 2.0_dp*factor, &
1349 mo_coeff, l_mu_q, 1.0_dp, mp2_env%ri_grad%L_jb(kspin), &
1352 b_first_col=homo + 1, &
1359 CALL timestop(handle2)
1363 DEALLOCATE (pos_info)
1365 CALL timestop(handle)
1367 END SUBROUTINE create_w_p
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
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.
Handles all functions related to the CELL.
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_transposed(transposed, normal, shallow_data_copy, transpose_distribution, use_distribution)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, first_row, last_row, first_column, last_column, first_k, last_k, retain_sparsity, filter_eps, flop)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
Interface to Minimax-Ewald method for periodic ERI's to be used in CP2K.
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_to_fm_submat(msource, mtarget, nrow, ncol, s_firstrow, s_firstcol, t_firstrow, t_firstcol)
copy just a part ot the 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_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
Defines the basic variable types.
integer, parameter, public dp
2- and 3-center electron repulsion integral routines based on libint2 Currently available operators: ...
pure logical function, public compare_potential_types(potential1, potential2)
Helper function to compare libint_potential_types.
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
type(mp_request_type), parameter, public mp_request_null
Routines to calculate 2c- and 3c-integrals for RI with GPW.
subroutine, public integrate_potential_forces_3c_2c(matrix_p_munu, rho_r, rho_g, task_list_sub, pw_env_sub, potential_parameter, ks_env, poisson_env, pot_g, use_virial, rho_g_copy, dvg, h_stress, para_env_sub, kind_of, atom_of_kind, qs_kind_set, particle_set, cell, lll, force, dft_control)
Integrates potential of two Gaussians to a potential.
subroutine, public prepare_gpw(qs_env, dft_control, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, auxbas_pw_pool, poisson_env, task_list_sub, rho_r, rho_g, pot_g, psi_l, sab_orb_sub)
Prepares GPW calculation for RI-MP2/RI-RPA.
subroutine, public integrate_potential_forces_2c(rho_r, lll, rho_g, atomic_kind_set, qs_kind_set, particle_set, cell, pw_env_sub, poisson_env, pot_g, potential_parameter, use_virial, rho_g_copy, dvg, kind_of, atom_of_kind, g_pq_local, force, h_stress, para_env_sub, dft_control, psi_l, factor)
Integrates the potential of a RI function obtaining the forces and stress tensor.
subroutine, public integrate_potential_forces_3c_1c(mat_munu, rho_r, matrix_p_munu, qs_env, pw_env_sub, task_list_sub)
Takes the precomputed potential of an RI wave-function and determines matrix element and gradients wi...
subroutine, public cleanup_gpw(qs_env, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, task_list_sub, auxbas_pw_pool, rho_r, rho_g, pot_g, psi_l)
Cleanup GPW integration for RI-MP2/RI-RPA.
Interface to direct methods for electron repulsion integrals for MP2.
subroutine, public mp2_eri_2c_integrate(param, potential_parameter, para_env, qs_env, basis_type_a, basis_type_b, hab, first_b, last_b, eri_method, pab, force_a, force_b, hdab, hadb, reflection_z_a, reflection_z_b, do_reflection_a, do_reflection_b)
high-level integration routine for 2c integrals over CP2K basis sets. Contiguous column-wise distribu...
subroutine, public mp2_eri_3c_integrate(param, potential_parameter, para_env, qs_env, first_c, last_c, mat_ab, basis_type_a, basis_type_b, basis_type_c, sab_nl, eri_method, pabc, force_a, force_b, force_c, mat_dabc, mat_adbc, mat_abdc)
high-level integration routine for 3c integrals (ab|c) over CP2K basis sets. For each local function ...
pure subroutine, public mp2_eri_deallocate_forces(force)
...
Routines to calculate gradients of RI-GPW-MP2 energy using pw.
subroutine, public calc_ri_mp2_nonsep(qs_env, mp2_env, para_env, para_env_sub, cell, particle_set, atomic_kind_set, qs_kind_set, mo_coeff, nmo, homo, dimen_ri, eigenval, my_group_l_start, my_group_l_end, my_group_l_size, sab_orb_sub, mat_munu, blacs_env_sub)
Calculate the non-separable part of the gradients and update the Lagrangian.
Types needed for MP2 calculations.
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
container for various plainwaves related things
functions related to the poisson solver on regular grids
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
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.
subroutine, public zero_qs_force(qs_force)
Initialize a Quickstep force data structure.
subroutine, public allocate_qs_force(qs_force, natom_of_kind)
Allocate a Quickstep force data structure.
Define the quickstep kind type and their sub types.
Define the neighbor list data types and the corresponding functionality.
All kind of helpful little routines.
pure integer function, dimension(2), public get_limit(m, n, me)
divide m entries into n parts, return size of part me
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
stores all the informations relevant to an mpi environment
contained for different pw related things
environment for the poisson solver
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...