12 USE omp_lib,
ONLY: omp_get_max_threads,&
26 compute_coulomb_2c_derivs,&
28 compute_coulomb_3c_derivs,&
29 coulomb_integral_cleanup,&
30 coulomb_integral_context_type,&
40 dbcsr_type_antisymmetric,&
41 dbcsr_type_no_symmetry
44 dbt_blk_sizes, dbt_clear, dbt_copy, dbt_create, dbt_destroy, dbt_filter, dbt_get_block, &
45 dbt_get_info, dbt_get_num_blocks, dbt_get_nze_total, dbt_iterator_next_block, &
46 dbt_iterator_num_blocks, dbt_iterator_start, dbt_iterator_stop, dbt_iterator_type, &
47 dbt_ndims, dbt_put_block, dbt_reserve_blocks, dbt_type
98#include "./base/base_uses.f90"
104 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_tensors'
113 TYPE one_dim_int_array
114 INTEGER,
DIMENSION(:),
ALLOCATABLE :: array
115 END TYPE one_dim_int_array
118 INTEGER,
PARAMETER,
PRIVATE :: cache_size = 1024
137 sym_ij, molecular, dist_2d, pot_to_rad)
142 CHARACTER(LEN=*),
INTENT(IN) :: name
144 LOGICAL,
INTENT(IN),
OPTIONAL :: sym_ij, molecular
146 INTEGER,
INTENT(IN),
OPTIONAL :: pot_to_rad
148 INTEGER :: ikind, nkind, pot_to_rad_prv
149 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: i_present, j_present
150 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pair_radius
151 REAL(kind=
dp) :: subcells
152 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: i_radius, j_radius
161 NULLIFY (atomic_kind_set, cell, local_particles, molecule_set, &
162 particle_set, dist_2d_prv)
164 IF (
PRESENT(pot_to_rad))
THEN
165 pot_to_rad_prv = pot_to_rad
173 particle_set=particle_set, &
174 atomic_kind_set=atomic_kind_set, &
175 local_particles=local_particles, &
176 distribution_2d=dist_2d_prv, &
177 molecule_set=molecule_set)
181 ALLOCATE (i_present(nkind), source=.false.)
182 ALLOCATE (j_present(nkind), source=.false.)
183 ALLOCATE (i_radius(nkind), source=0.0_dp)
184 ALLOCATE (j_radius(nkind), source=0.0_dp)
186 IF (
PRESENT(dist_2d)) dist_2d_prv => dist_2d
193 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
194 i_present(ikind) = .true.
195 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, kind_radius=i_radius(ikind))
197 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
198 j_present(ikind) = .true.
199 CALL get_gto_basis_set(basis_j(ikind)%gto_basis_set, kind_radius=j_radius(ikind))
207 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
208 i_present(ikind) = .true.
209 IF (pot_to_rad_prv == 1) i_radius(ikind) = 1000000.0_dp
211 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
212 j_present(ikind) = .true.
213 IF (pot_to_rad_prv == 2) j_radius(ikind) = 1000000.0_dp
223 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
224 i_present(ikind) = .true.
225 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, kind_radius=i_radius(ikind))
226 IF (pot_to_rad_prv == 1) i_radius(ikind) = i_radius(ikind) +
cutoff_screen_factor*potential_parameter%cutoff_radius
228 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
229 j_present(ikind) = .true.
230 CALL get_gto_basis_set(basis_j(ikind)%gto_basis_set, kind_radius=j_radius(ikind))
231 IF (pot_to_rad_prv == 2) j_radius(ikind) = j_radius(ikind) +
cutoff_screen_factor*potential_parameter%cutoff_radius
236 cpabort(
"Operator not implemented.")
239 ALLOCATE (pair_radius(nkind, nkind), source=0.0_dp)
242 ALLOCATE (atom2d(nkind))
244 CALL atom2d_build(atom2d, local_particles, dist_2d_prv, atomic_kind_set, &
245 molecule_set, molecule_only=.false., particle_set=particle_set)
247 symmetric=sym_ij, molecular=molecular, nlname=trim(name))
271 dist_3d, potential_parameter, name, qs_env, &
272 sym_ij, sym_jk, sym_ik, molecular, op_pos, &
278 CHARACTER(LEN=*),
INTENT(IN) :: name
280 LOGICAL,
INTENT(IN),
OPTIONAL :: sym_ij, sym_jk, sym_ik, molecular
281 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
282 LOGICAL,
INTENT(IN),
OPTIONAL :: own_dist
284 CHARACTER(len=*),
PARAMETER :: routinen =
'build_3c_neighbor_lists'
286 INTEGER :: handle, op_pos_prv, sym_level
289 CALL timeset(routinen, handle)
291 IF (
PRESENT(op_pos))
THEN
297 SELECT CASE (op_pos_prv)
299 pot_par_1 = potential_parameter
302 pot_par_2 = potential_parameter
307 qs_env, sym_ij=.false., molecular=molecular, &
308 dist_2d=dist_3d%dist_2d_1, pot_to_rad=1)
311 qs_env, sym_ij=.false., molecular=molecular, &
312 dist_2d=dist_3d%dist_2d_2, pot_to_rad=2)
317 IF (
PRESENT(sym_ij))
THEN
320 sym_level = sym_level + 1
324 IF (
PRESENT(sym_jk))
THEN
327 sym_level = sym_level + 1
331 IF (
PRESENT(sym_ik))
THEN
334 sym_level = sym_level + 1
338 IF (sym_level >= 2)
THEN
342 ijk_list%dist_3d = dist_3d
343 IF (
PRESENT(own_dist))
THEN
344 ijk_list%owns_dist = own_dist
346 ijk_list%owns_dist = .false.
349 CALL timestop(handle)
358 PURE FUNCTION include_symmetric(a, b)
359 INTEGER,
INTENT(IN) :: a, b
360 LOGICAL :: include_symmetric
363 include_symmetric = (
modulo(a + b, 2) /= 0)
365 include_symmetric = (
modulo(a + b, 2) == 0)
368 END FUNCTION include_symmetric
380 IF (ijk_list%owns_dist)
THEN
395 CHARACTER(len=*),
PARAMETER :: routinen =
'neighbor_list_3c_iterator_create'
399 CALL timeset(routinen, handle)
404 iterator%iter_level = 0
405 iterator%ijk_nl = ijk_nl
407 iterator%bounds_i = 0
408 iterator%bounds_j = 0
409 iterator%bounds_k = 0
412 iterator%my_pair = -1
414 CALL timestop(handle)
424 SUBROUTINE nl_3c_iter_set_bounds(iterator, bounds_i, bounds_j, bounds_k)
426 INTENT(INOUT) :: iterator
427 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
429 IF (
PRESENT(bounds_i)) iterator%bounds_i = bounds_i
430 IF (
PRESENT(bounds_j)) iterator%bounds_j = bounds_j
431 IF (
PRESENT(bounds_k)) iterator%bounds_k = bounds_k
433 END SUBROUTINE nl_3c_iter_set_bounds
441 INTENT(INOUT) :: iterator
443 CHARACTER(len=*),
PARAMETER :: routinen =
'neighbor_list_3c_iterator_destroy'
447 CALL timeset(routinen, handle)
450 NULLIFY (iterator%iter_ij)
451 NULLIFY (iterator%iter_jk)
453 CALL timestop(handle)
465 INTENT(INOUT) :: iterator
466 INTEGER,
INTENT(INOUT),
OPTIONAL :: next_pair
469 INTEGER :: iatom, jatom, jatom_1, jatom_2, katom
470 LOGICAL :: found, skip_this
475 DO WHILE (.NOT. found .AND. iter_stat == 0)
478 IF (iterator%iter_level == 0)
THEN
481 IF (iter_stat == 0)
THEN
483 IF ((iterator%bounds_i(1) > 0 .AND. iatom < iterator%bounds_i(1)) &
484 .OR. (iterator%bounds_i(2) > 0 .AND. iatom > iterator%bounds_i(2))) skip_this = .true.
485 IF ((iterator%bounds_j(1) > 0 .AND. jatom < iterator%bounds_j(1)) &
486 .OR. (iterator%bounds_j(2) > 0 .AND. jatom > iterator%bounds_j(2))) skip_this = .true.
488 IF (
PRESENT(next_pair) .AND. .NOT. skip_this)
THEN
489 IF (iterator%my_pair < 0)
THEN
491 iterator%my_pair = next_pair
492 next_pair = next_pair + 1
495 iterator%ipair = iterator%ipair + 1
496 IF (iterator%ipair == iterator%my_pair)
THEN
498 iterator%my_pair = next_pair
499 next_pair = next_pair + 1
508 IF (iter_stat == 0 .AND. .NOT. skip_this)
THEN
510 IF (iter_stat /= 0)
THEN
511 iterator%iter_level = 0
514 iterator%iter_level = 1
519 cpassert(jatom_1 == jatom_2)
522 IF ((iterator%bounds_k(1) > 0 .AND. katom < iterator%bounds_k(1)) &
523 .OR. (iterator%bounds_k(2) > 0 .AND. katom > iterator%bounds_k(2))) skip_this = .true.
525 IF (.NOT. skip_this)
THEN
526 SELECT CASE (iterator%ijk_nl%sym)
530 skip_this = .NOT. include_symmetric(iatom, jatom)
532 skip_this = .NOT. include_symmetric(jatom, katom)
534 skip_this = .NOT. include_symmetric(iatom, katom)
536 skip_this = .NOT. include_symmetric(iatom, jatom) .OR. .NOT. include_symmetric(jatom, katom)
538 cpabort(
"should not happen")
542 found = .NOT. skip_this
567 rij, rjk, rik, cell_j, cell_k)
569 INTENT(INOUT) :: iterator
570 INTEGER,
INTENT(OUT),
OPTIONAL :: ikind, jkind, kkind, nkind, iatom, &
572 REAL(kind=
dp),
DIMENSION(3),
INTENT(OUT),
OPTIONAL :: rij, rjk, rik
573 INTEGER,
DIMENSION(3),
INTENT(OUT),
OPTIONAL :: cell_j, cell_k
575 INTEGER,
DIMENSION(2) :: atoms_1, atoms_2, kinds_1, kinds_2
576 INTEGER,
DIMENSION(3) :: cell_1, cell_2
577 REAL(kind=
dp),
DIMENSION(3) :: r_1, r_2
579 cpassert(iterator%iter_level == 1)
582 ikind=kinds_1(1), jkind=kinds_1(2), nkind=nkind, &
583 iatom=atoms_1(1), jatom=atoms_1(2), r=r_1, &
587 ikind=kinds_2(1), jkind=kinds_2(2), &
588 iatom=atoms_2(1), jatom=atoms_2(2), r=r_2, &
591 IF (
PRESENT(ikind)) ikind = kinds_1(1)
592 IF (
PRESENT(jkind)) jkind = kinds_1(2)
593 IF (
PRESENT(kkind)) kkind = kinds_2(2)
594 IF (
PRESENT(iatom)) iatom = atoms_1(1)
595 IF (
PRESENT(jatom)) jatom = atoms_1(2)
596 IF (
PRESENT(katom)) katom = atoms_2(2)
598 IF (
PRESENT(rij)) rij = r_1
599 IF (
PRESENT(rjk)) rjk = r_2
600 IF (
PRESENT(rik)) rik = r_1 + r_2
602 IF (
PRESENT(cell_j)) cell_j = cell_1
603 IF (
PRESENT(cell_k)) cell_k = cell_1 + cell_2
629 SUBROUTINE alloc_block_3c(t3c, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, op_pos, &
630 do_kpoints, do_hfx_kpoints, bounds_i, bounds_j, bounds_k, RI_range, &
631 img_to_RI_cell, cell_to_index, cell_sym)
632 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(INOUT) :: t3c
637 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
638 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
639 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
640 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
641 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
642 INTEGER,
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: cell_to_index
643 LOGICAL,
INTENT(IN),
OPTIONAL :: cell_sym
645 CHARACTER(LEN=*),
PARAMETER :: routinen =
'alloc_block_3c'
647 INTEGER :: handle, iatom, ikind, j_img, jatom, &
648 jcell, jkind, k_img, katom, kcell, &
649 kkind, natom, ncell_ri, nimg, op_ij, &
651 INTEGER(int_8) :: a, b, nblk_per_thread
652 INTEGER(int_8),
ALLOCATABLE,
DIMENSION(:, :) :: nblk
653 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
654 INTEGER,
DIMENSION(3) :: blk_idx, cell_j, cell_k, &
655 kp_index_lbounds, kp_index_ubounds
656 LOGICAL :: cell_sym_prv, do_hfx_kpoints_prv, &
658 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
659 kind_radius_i, kind_radius_j, &
661 REAL(kind=
dp),
DIMENSION(3) :: rij, rik, rjk
667 TYPE(one_dim_int_array),
ALLOCATABLE, &
668 DIMENSION(:, :) :: alloc_i, alloc_j, alloc_k
669 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
671 CALL timeset(routinen, handle)
672 NULLIFY (qs_kind_set, atomic_kind_set, cell)
674 IF (
PRESENT(do_kpoints))
THEN
675 do_kpoints_prv = do_kpoints
677 do_kpoints_prv = .false.
679 IF (
PRESENT(do_hfx_kpoints))
THEN
680 do_hfx_kpoints_prv = do_hfx_kpoints
682 do_hfx_kpoints_prv = .false.
684 IF (do_hfx_kpoints_prv)
THEN
685 cpassert(do_kpoints_prv)
686 cpassert(
PRESENT(ri_range))
687 cpassert(
PRESENT(img_to_ri_cell))
690 IF (
PRESENT(img_to_ri_cell))
THEN
691 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
692 img_to_ri_cell_prv(:) = img_to_ri_cell
695 IF (
PRESENT(cell_sym))
THEN
696 cell_sym_prv = cell_sym
698 cell_sym_prv = .false.
701 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
705 IF (
PRESENT(op_pos))
THEN
711 SELECT CASE (op_pos_prv)
713 op_ij = potential_parameter%potential_type
715 op_jk = potential_parameter%potential_type
736 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, natom=natom, &
737 dft_control=dft_control, para_env=para_env, cell=cell)
739 IF (do_kpoints_prv)
THEN
740 cpassert(
PRESENT(cell_to_index))
741 cpassert(
ASSOCIATED(cell_to_index))
743 nimg = maxval(cell_to_index)
745 IF (do_hfx_kpoints_prv)
THEN
747 ncell_ri =
SIZE(t3c, 2)
754 IF (do_kpoints_prv)
THEN
755 kp_index_lbounds = lbound(cell_to_index)
756 kp_index_ubounds = ubound(cell_to_index)
760 ALLOCATE (nblk(nimg, ncell_ri))
765 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bounds_k)
769 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
775 IF (do_kpoints_prv)
THEN
777 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
778 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
780 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
781 IF (jcell > nimg .OR. jcell < 1) cycle
783 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
784 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
786 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
787 IF (kcell > nimg .OR. kcell < 1) cycle
788 IF (do_hfx_kpoints_prv)
THEN
789 IF (dik > ri_range) cycle
800 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
801 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
802 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
804 nblk(jcell, kcell) = nblk(jcell, kcell) + 1
809 ALLOCATE (alloc_i(nimg, ncell_ri))
810 ALLOCATE (alloc_j(nimg, ncell_ri))
811 ALLOCATE (alloc_k(nimg, ncell_ri))
812 DO k_img = 1, ncell_ri
814 ALLOCATE (alloc_i(j_img, k_img)%array(nblk(j_img, k_img)))
815 ALLOCATE (alloc_j(j_img, k_img)%array(nblk(j_img, k_img)))
816 ALLOCATE (alloc_k(j_img, k_img)%array(nblk(j_img, k_img)))
823 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bounds_k)
827 iatom=iatom, jatom=jatom, katom=katom, &
828 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
834 IF (do_kpoints_prv)
THEN
836 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
837 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
839 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
840 IF (jcell > nimg .OR. jcell < 1) cycle
842 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
843 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
845 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
846 IF (kcell > nimg .OR. kcell < 1) cycle
847 IF (do_hfx_kpoints_prv)
THEN
848 IF (dik > ri_range) cycle
849 kcell = img_to_ri_cell_prv(kcell)
855 blk_idx = [iatom, jatom, katom]
856 IF (do_hfx_kpoints_prv)
THEN
857 blk_idx(3) = (kcell - 1)*natom + katom
865 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
866 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
867 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
869 nblk(jcell, kcell) = nblk(jcell, kcell) + 1
872 alloc_i(jcell, kcell)%array(nblk(jcell, kcell)) = blk_idx(1)
873 alloc_j(jcell, kcell)%array(nblk(jcell, kcell)) = blk_idx(2)
874 alloc_k(jcell, kcell)%array(nblk(jcell, kcell)) = blk_idx(3)
882 DO k_img = 1, ncell_ri
884 IF (cell_sym_prv .AND. j_img < k_img) cycle
885 IF (
ALLOCATED(alloc_i(j_img, k_img)%array))
THEN
886 nblk_per_thread = nblk(j_img, k_img)/omp_get_num_threads() + 1
887 a = omp_get_thread_num()*nblk_per_thread + 1
888 b = min(a + nblk_per_thread, nblk(j_img, k_img))
889 CALL dbt_reserve_blocks(t3c(j_img, k_img), &
890 alloc_i(j_img, k_img)%array(a:b), &
891 alloc_j(j_img, k_img)%array(a:b), &
892 alloc_k(j_img, k_img)%array(a:b))
898 CALL timestop(handle)
900 END SUBROUTINE alloc_block_3c
927 nl_3c, basis_i, basis_j, basis_k, &
928 potential_parameter, der_eps, &
929 op_pos, do_kpoints, do_hfx_kpoints, &
930 bounds_i, bounds_j, bounds_k, &
931 RI_range, img_to_RI_cell)
933 TYPE(dbt_type),
DIMENSION(:, :, :),
INTENT(INOUT) :: t3c_der_i, t3c_der_k
934 REAL(kind=
dp),
INTENT(IN) :: filter_eps
939 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: der_eps
940 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
941 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
942 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
943 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
944 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
946 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_3c_derivatives'
948 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
949 block_start_k, egfi, handle, handle2, i, i_img, i_xyz, iatom, ibasis, ikind, ilist,
imax, &
950 iset, j_img, jatom, jcell, jkind, jset, katom, kcell, kkind, kset, m_max, max_ncoj, &
951 max_nset, max_nsgfi, maxli, maxlj, maxlk, mepos, natom, nbasis, ncell_ri, ncoi, ncoj, &
952 ncok, nimg, nseti, nsetj, nsetk, nthread, op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk
953 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
954 INTEGER,
DIMENSION(2) :: bo
955 INTEGER,
DIMENSION(3) :: blk_idx, blk_size, cell_j, cell_k, &
956 kp_index_lbounds, kp_index_ubounds,
sp
957 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
958 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
960 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
961 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
962 LOGICAL :: do_hfx_kpoints_prv, do_kpoints_prv, &
964 LOGICAL,
DIMENSION(3) :: block_j_not_zero, block_k_not_zero, &
965 der_j_zero, der_k_zero
966 REAL(
dp),
DIMENSION(3) :: der_ext_i, der_ext_j, der_ext_k
967 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
968 kind_radius_i, kind_radius_j, &
969 kind_radius_k, prefac
970 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
971 max_contraction_i, max_contraction_j, &
973 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dijk_contr, dummy_block_t
974 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: block_t_i, block_t_j, block_t_k, dijk_j, &
975 dijk_k, tmp_ijk_i, tmp_ijk_j
976 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk
977 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
978 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
979 sphi_k, zeti, zetj, zetk
981 TYPE(coulomb_integral_context_type) :: integral_context
983 TYPE(dbt_type) :: t3c_tmp
984 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t3c_template
985 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: t3c_der_j
991 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
993 CALL timeset(routinen, handle)
995 IF (
PRESENT(do_kpoints))
THEN
996 do_kpoints_prv = do_kpoints
998 do_kpoints_prv = .false.
1001 IF (
PRESENT(do_hfx_kpoints))
THEN
1002 do_hfx_kpoints_prv = do_hfx_kpoints
1004 do_hfx_kpoints_prv = .false.
1006 IF (do_hfx_kpoints_prv)
THEN
1007 cpassert(do_kpoints_prv)
1008 cpassert(
PRESENT(ri_range))
1009 cpassert(
PRESENT(img_to_ri_cell))
1012 IF (
PRESENT(img_to_ri_cell))
THEN
1013 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
1014 img_to_ri_cell_prv(:) = img_to_ri_cell
1019 IF (
PRESENT(op_pos))
THEN
1025 SELECT CASE (op_pos_prv)
1027 op_ij = potential_parameter%potential_type
1029 op_jk = potential_parameter%potential_type
1032 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
1039 dr_ij = 1000000.0_dp
1040 dr_ik = 1000000.0_dp
1048 dr_jk = 1000000.0_dp
1049 dr_ik = 1000000.0_dp
1052 NULLIFY (qs_kind_set, atomic_kind_set)
1055 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
1056 natom=natom, kpoints=kpoints, dft_control=dft_control, para_env=para_env)
1058 IF (do_kpoints_prv)
THEN
1059 nimg = dft_control%nimages
1061 IF (do_hfx_kpoints_prv)
THEN
1062 nimg =
SIZE(t3c_der_k, 1)
1063 ncell_ri =
SIZE(t3c_der_k, 2)
1071 IF (do_hfx_kpoints_prv)
THEN
1072 cpassert(op_pos_prv == 2)
1074 cpassert(all(shape(t3c_der_k) == [nimg, ncell_ri, 3]))
1077 ALLOCATE (t3c_template(nimg, ncell_ri))
1078 DO j_img = 1, ncell_ri
1080 CALL dbt_create(t3c_der_i(i_img, j_img, 1), t3c_template(i_img, j_img))
1084 CALL alloc_block_3c(t3c_template, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, &
1085 op_pos=op_pos_prv, do_kpoints=do_kpoints, do_hfx_kpoints=do_hfx_kpoints, &
1086 bounds_i=bounds_i, bounds_j=bounds_j, bounds_k=bounds_k, &
1087 ri_range=ri_range, img_to_ri_cell=img_to_ri_cell, cell_to_index=cell_to_index)
1089 DO j_img = 1, ncell_ri
1091 CALL dbt_copy(t3c_template(i_img, j_img), t3c_der_i(i_img, j_img, i_xyz))
1092 CALL dbt_copy(t3c_template(i_img, j_img), t3c_der_k(i_img, j_img, i_xyz))
1097 DO j_img = 1, ncell_ri
1099 CALL dbt_destroy(t3c_template(i_img, j_img))
1102 DEALLOCATE (t3c_template)
1105 ALLOCATE (t3c_der_j(nimg, ncell_ri, 3))
1107 DO j_img = 1, ncell_ri
1109 CALL dbt_create(t3c_der_k(i_img, j_img, i_xyz), t3c_der_j(i_img, j_img, i_xyz))
1110 CALL dbt_copy(t3c_der_k(i_img, j_img, i_xyz), t3c_der_j(i_img, j_img, i_xyz))
1117 nbasis =
SIZE(basis_i)
1121 DO ibasis = 1, nbasis
1123 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
1124 maxli = max(maxli,
imax)
1125 max_nset = max(max_nset, iset)
1126 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
1130 DO ibasis = 1, nbasis
1132 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
1133 maxlj = max(maxlj,
imax)
1134 max_nset = max(max_nset, jset)
1135 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
1138 DO ibasis = 1, nbasis
1140 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
1141 maxlk = max(maxlk,
imax)
1142 max_nset = max(max_nset, kset)
1144 m_max = maxli + maxlj + maxlk + 1
1149 NULLIFY (tspj, spi, spk)
1150 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
1152 DO ibasis = 1, nbasis
1153 DO iset = 1, max_nset
1154 NULLIFY (spi(iset, ibasis)%array)
1155 NULLIFY (tspj(iset, ibasis)%array)
1156 NULLIFY (spk(iset, ibasis)%array)
1161 DO ibasis = 1, nbasis
1162 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
1163 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
1164 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
1166 DO iset = 1, basis_set%nset
1168 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
1169 sgfi = basis_set%first_sgf(1, iset)
1170 egfi = sgfi + basis_set%nsgf_set(iset) - 1
1172 IF (ilist == 1)
THEN
1173 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1174 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1176 ELSE IF (ilist == 2)
THEN
1177 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
1178 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
1181 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1182 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1191 IF (do_kpoints_prv)
THEN
1192 kp_index_lbounds = lbound(cell_to_index)
1193 kp_index_ubounds = ubound(cell_to_index)
1218 integral_context = coulomb_integral_context_type()
1219 CALL coulomb_integral_init(integral_context, max_am_3c=max(maxli, maxlj, maxlk), &
1224 IF (
PRESENT(bounds_i))
THEN
1225 bo =
get_limit(bounds_i(2) - bounds_i(1) + 1, nthread, mepos)
1226 bo(:) = bo(:) + bounds_i(1) - 1
1227 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
1228 ELSE IF (
PRESENT(bounds_j))
THEN
1229 bo =
get_limit(bounds_j(2) - bounds_j(1) + 1, nthread, mepos)
1230 bo(:) = bo(:) + bounds_j(1) - 1
1231 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bo, bounds_k)
1232 ELSE IF (
PRESENT(bounds_k))
THEN
1233 bo =
get_limit(bounds_k(2) - bounds_k(1) + 1, nthread, mepos)
1234 bo(:) = bo(:) + bounds_k(1) - 1
1235 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bo)
1238 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
1242 IF (bo(1) > bo(2)) skip = .true.
1246 iatom=iatom, jatom=jatom, katom=katom, &
1247 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
1254 IF (do_kpoints_prv)
THEN
1257 IF (jatom == katom)
THEN
1265 IF (do_hfx_kpoints_prv) prefac = 1.0_dp
1267 IF (do_kpoints_prv)
THEN
1269 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
1270 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
1272 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
1273 IF (jcell > nimg .OR. jcell < 1) cycle
1275 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
1276 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
1278 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
1279 IF (kcell > nimg .OR. kcell < 1) cycle
1281 IF (do_hfx_kpoints_prv)
THEN
1282 IF (dik > ri_range) cycle
1283 kcell = img_to_ri_cell_prv(kcell)
1286 jcell = 1; kcell = 1
1289 blk_idx = [iatom, jatom, katom]
1290 IF (do_hfx_kpoints_prv)
THEN
1291 blk_idx(3) = (kcell - 1)*natom + katom
1295 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
1296 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
1297 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
1299 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
1300 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
1301 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
1303 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
1304 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
1305 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
1307 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
1308 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
1309 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
1311 IF (
PRESENT(der_eps))
THEN
1312 ALLOCATE (max_contraction_i(nseti))
1314 sgfi = first_sgf_i(1, iset)
1315 max_contraction_i(iset) = maxval([(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)])
1318 ALLOCATE (max_contraction_j(nsetj))
1320 sgfj = first_sgf_j(1, jset)
1321 max_contraction_j(jset) = maxval([(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)])
1324 ALLOCATE (max_contraction_k(nsetk))
1326 sgfk = first_sgf_k(1, kset)
1327 max_contraction_k(kset) = maxval([(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)])
1331 CALL dbt_blk_sizes(t3c_der_i(jcell, kcell, 1), blk_idx, blk_size)
1333 ALLOCATE (block_t_i(blk_size(2), blk_size(3), blk_size(1), 3), source=0.0_dp)
1334 ALLOCATE (block_t_j(blk_size(2), blk_size(3), blk_size(1), 3), source=0.0_dp)
1335 ALLOCATE (block_t_k(blk_size(2), blk_size(3), blk_size(1), 3), source=0.0_dp)
1337 block_j_not_zero = .false.
1338 block_k_not_zero = .false.
1344 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
1348 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
1349 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
1351 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
1352 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
1353 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
1355 sgfi = first_sgf_i(1, iset)
1356 sgfj = first_sgf_j(1, jset)
1357 sgfk = first_sgf_k(1, kset)
1359 IF (ncoj*ncok*ncoi > 0)
THEN
1360 ALLOCATE (dijk_j(ncoj, ncok, ncoi, 3), source=0.0_dp)
1361 ALLOCATE (dijk_k(ncoj, ncok, ncoi, 3), source=0.0_dp)
1363 der_j_zero = .false.
1364 der_k_zero = .false.
1371 IF (op_pos_prv == 1)
THEN
1372 CALL compute_coulomb_3c_derivs(dijk_j, dijk_k, &
1373 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1374 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1375 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1376 djk, dij, dik, integral_context, potential_parameter, &
1377 der_abc_1_ext=der_ext_j, der_abc_2_ext=der_ext_k)
1379 ALLOCATE (tmp_ijk_i(ncoi, ncoj, ncok, 3), source=0.0_dp)
1380 ALLOCATE (tmp_ijk_j(ncoi, ncoj, ncok, 3), source=0.0_dp)
1382 CALL compute_coulomb_3c_derivs(tmp_ijk_i, tmp_ijk_j, &
1383 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1384 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1385 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1386 dij, dik, djk, integral_context, potential_parameter, &
1387 der_abc_1_ext=der_ext_i, der_abc_2_ext=der_ext_j)
1393 dijk_j(:, :, i, i_xyz) = tmp_ijk_j(i, :, :, i_xyz)
1394 dijk_k(:, :, i, i_xyz) = -(dijk_j(:, :, i, i_xyz) + tmp_ijk_i(i, :, :, i_xyz))
1395 der_ext_k(i_xyz) = max(der_ext_k(i_xyz), maxval(abs(dijk_k(:, :, i, i_xyz))))
1398 DEALLOCATE (tmp_ijk_i, tmp_ijk_j)
1402 IF (
PRESENT(der_eps))
THEN
1404 IF (der_eps > der_ext_j(i_xyz)*(max_contraction_i(iset)* &
1405 max_contraction_j(jset)* &
1406 max_contraction_k(kset)))
THEN
1407 der_j_zero(i_xyz) = .true.
1412 IF (der_eps > der_ext_k(i_xyz)*(max_contraction_i(iset)* &
1413 max_contraction_j(jset)* &
1414 max_contraction_k(kset)))
THEN
1415 der_k_zero(i_xyz) = .true.
1418 IF (all(der_j_zero) .AND. all(der_k_zero))
THEN
1419 DEALLOCATE (dijk_j, dijk_k)
1424 ALLOCATE (dijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
1426 block_start_j = sgfj
1427 block_end_j = sgfj + nsgfj(jset) - 1
1428 block_start_k = sgfk
1429 block_end_k = sgfk + nsgfk(kset) - 1
1430 block_start_i = sgfi
1431 block_end_i = sgfi + nsgfi(iset) - 1
1434 IF (der_j_zero(i_xyz)) cycle
1436 block_j_not_zero(i_xyz) = .true.
1437 CALL abc_contract_xsmm(dijk_contr, dijk_j(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1438 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1439 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1440 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
1442 block_t_j(block_start_j:block_end_j, &
1443 block_start_k:block_end_k, &
1444 block_start_i:block_end_i, i_xyz) = &
1445 block_t_j(block_start_j:block_end_j, &
1446 block_start_k:block_end_k, &
1447 block_start_i:block_end_i, i_xyz) + &
1453 IF (der_k_zero(i_xyz)) cycle
1455 block_k_not_zero(i_xyz) = .true.
1456 CALL abc_contract_xsmm(dijk_contr, dijk_k(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1457 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1458 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1459 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
1461 block_t_k(block_start_j:block_end_j, &
1462 block_start_k:block_end_k, &
1463 block_start_i:block_end_i, i_xyz) = &
1464 block_t_k(block_start_j:block_end_j, &
1465 block_start_k:block_end_k, &
1466 block_start_i:block_end_i, i_xyz) + &
1471 DEALLOCATE (dijk_j, dijk_k, dijk_contr)
1477 CALL timeset(routinen//
"_put_dbcsr", handle2)
1479 sp = shape(block_t_i(:, :, :, 1))
1484 IF ((.NOT. block_j_not_zero(i_xyz)) .AND. (.NOT. block_k_not_zero(i_xyz))) cycle
1485 block_t_i(:, :, :, i_xyz) = -(block_t_j(:, :, :, i_xyz) + block_t_k(:, :, :, i_xyz))
1487 CALL dbt_put_block(t3c_der_i(jcell, kcell, i_xyz), blk_idx,
sp, &
1488 reshape(block_t_i(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1492 sp = shape(block_t_k(:, :, :, 1))
1496 IF (.NOT. block_k_not_zero(i_xyz)) cycle
1497 CALL dbt_put_block(t3c_der_k(jcell, kcell, i_xyz), blk_idx,
sp, &
1498 reshape(block_t_k(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1504 sp = shape(block_t_j(:, :, :, 1))
1508 IF (.NOT. block_j_not_zero(i_xyz)) cycle
1509 CALL dbt_put_block(t3c_der_j(jcell, kcell, i_xyz), blk_idx,
sp, &
1510 reshape(block_t_j(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1516 CALL timestop(handle2)
1518 DEALLOCATE (block_t_i, block_t_j, block_t_k)
1519 IF (
PRESENT(der_eps))
THEN
1520 DEALLOCATE (max_contraction_i, max_contraction_j, max_contraction_k)
1524 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
1525 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
1527 CALL coulomb_integral_cleanup(integral_context)
1531 IF (do_kpoints_prv .AND. .NOT. do_hfx_kpoints_prv)
THEN
1536 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps/2)
1537 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps/2)
1544 CALL dbt_create(t3c_der_k(1, 1, 1), t3c_tmp)
1548 CALL dbt_copy(t3c_der_j(jcell, kcell, i_xyz), t3c_der_k(jcell, kcell, i_xyz), &
1549 order=[1, 3, 2], move_data=.true., summation=.true.)
1550 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps)
1552 CALL dbt_copy(t3c_der_i(jcell, kcell, i_xyz), t3c_tmp)
1553 CALL dbt_copy(t3c_tmp, t3c_der_i(jcell, kcell, i_xyz), &
1554 order=[1, 3, 2], move_data=.true., summation=.true.)
1555 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps)
1559 CALL dbt_destroy(t3c_tmp)
1563 DO kcell = 1, ncell_ri
1565 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps)
1566 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps)
1571 cpabort(
"requested symmetric case not implemented")
1578 CALL dbt_destroy(t3c_der_j(i_img, j_img, i_xyz))
1584 DO iset = 1, max_nset
1585 DO ibasis = 1, nbasis
1586 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
1587 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
1588 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
1592 DEALLOCATE (spi, tspj, spk)
1594 CALL timestop(handle)
1615 nl_3c, basis_i, basis_j, basis_k, &
1616 potential_parameter, der_eps, op_pos)
1618 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: work_virial
1619 TYPE(dbt_type),
INTENT(INOUT) :: t3c_trace
1620 REAL(kind=
dp),
INTENT(IN) :: pref
1625 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: der_eps
1626 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
1628 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_3c_virial'
1630 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
1631 block_start_k, egfi, handle, i, i_xyz, iatom, ibasis, ikind, ilist,
imax, iset, j_xyz, &
1632 jatom, jkind, jset, katom, kkind, kset, m_max, max_ncoj, max_nset, max_nsgfi, maxli, &
1633 maxlj, maxlk, mepos, natom, nbasis, ncoi, ncoj, ncok, nseti, nsetj, nsetk, nthread, &
1634 op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk
1635 INTEGER,
DIMENSION(2) :: bo
1636 INTEGER,
DIMENSION(3) :: blk_size,
sp
1637 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
1638 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
1640 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
1641 LOGICAL :: found, skip
1642 LOGICAL,
DIMENSION(3) :: block_j_not_zero, block_k_not_zero, &
1643 der_j_zero, der_k_zero
1645 REAL(
dp),
DIMENSION(3) :: der_ext_i, der_ext_j, der_ext_k
1646 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
1647 kind_radius_i, kind_radius_j, &
1649 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
1650 max_contraction_i, max_contraction_j, &
1652 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ablock, dijk_contr, tmp_block
1653 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: block_t_i, block_t_j, block_t_k, dijk_j, &
1655 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk, scoord
1656 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
1657 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
1658 sphi_k, zeti, zetj, zetk
1661 TYPE(coulomb_integral_context_type) :: integral_context
1668 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1670 CALL timeset(routinen, handle)
1674 IF (
PRESENT(op_pos))
THEN
1679 cpassert(op_pos == 1)
1682 SELECT CASE (op_pos_prv)
1684 op_ij = potential_parameter%potential_type
1686 op_jk = potential_parameter%potential_type
1689 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
1696 dr_ij = 1000000.0_dp
1697 dr_ik = 1000000.0_dp
1705 dr_jk = 1000000.0_dp
1706 dr_ik = 1000000.0_dp
1709 NULLIFY (qs_kind_set, atomic_kind_set)
1712 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
1713 natom=natom, dft_control=dft_control, para_env=para_env, &
1714 particle_set=particle_set, cell=cell)
1717 nbasis =
SIZE(basis_i)
1721 DO ibasis = 1, nbasis
1723 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
1724 maxli = max(maxli,
imax)
1725 max_nset = max(max_nset, iset)
1726 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
1730 DO ibasis = 1, nbasis
1732 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
1733 maxlj = max(maxlj,
imax)
1734 max_nset = max(max_nset, jset)
1735 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
1738 DO ibasis = 1, nbasis
1740 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
1741 maxlk = max(maxlk,
imax)
1742 max_nset = max(max_nset, kset)
1744 m_max = maxli + maxlj + maxlk + 1
1749 NULLIFY (tspj, spi, spk)
1750 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
1752 DO ibasis = 1, nbasis
1753 DO iset = 1, max_nset
1754 NULLIFY (spi(iset, ibasis)%array)
1755 NULLIFY (tspj(iset, ibasis)%array)
1757 NULLIFY (spk(iset, ibasis)%array)
1762 DO ibasis = 1, nbasis
1763 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
1764 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
1765 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
1767 DO iset = 1, basis_set%nset
1769 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
1770 sgfi = basis_set%first_sgf(1, iset)
1771 egfi = sgfi + basis_set%nsgf_set(iset) - 1
1773 IF (ilist == 1)
THEN
1774 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1775 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1777 ELSE IF (ilist == 2)
THEN
1778 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
1779 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
1782 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1783 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1811 integral_context = coulomb_integral_context_type()
1812 CALL coulomb_integral_init(integral_context, max_am_3c=max(maxli, maxlj, maxlk), &
1819 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i=bo)
1822 IF (bo(1) > bo(2)) skip = .true.
1826 iatom=iatom, jatom=jatom, katom=katom, &
1827 rij=rij, rjk=rjk, rik=rik)
1830 CALL dbt_get_block(t3c_trace, [iatom, jatom, katom], tmp_block, found)
1831 IF (.NOT. found) cycle
1833 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
1834 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
1835 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
1837 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
1838 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
1839 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
1841 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
1842 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
1843 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
1849 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
1850 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
1851 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
1853 IF (
PRESENT(der_eps))
THEN
1854 ALLOCATE (max_contraction_i(nseti))
1856 sgfi = first_sgf_i(1, iset)
1857 max_contraction_i(iset) = maxval([(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)])
1860 ALLOCATE (max_contraction_j(nsetj))
1862 sgfj = first_sgf_j(1, jset)
1863 max_contraction_j(jset) = maxval([(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)])
1866 ALLOCATE (max_contraction_k(nsetk))
1868 sgfk = first_sgf_k(1, kset)
1869 max_contraction_k(kset) = maxval([(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)])
1873 CALL dbt_blk_sizes(t3c_trace, [iatom, jatom, katom], blk_size)
1875 ALLOCATE (block_t_i(blk_size(2), blk_size(3), blk_size(1), 3))
1876 ALLOCATE (block_t_j(blk_size(2), blk_size(3), blk_size(1), 3))
1877 ALLOCATE (block_t_k(blk_size(2), blk_size(3), blk_size(1), 3))
1879 ALLOCATE (ablock(blk_size(2), blk_size(3), blk_size(1)))
1880 DO i = 1, blk_size(1)
1881 ablock(:, :, i) = tmp_block(i, :, :)
1883 DEALLOCATE (tmp_block)
1888 block_j_not_zero = .false.
1889 block_k_not_zero = .false.
1895 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
1899 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
1900 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
1902 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
1903 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
1904 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
1906 sgfi = first_sgf_i(1, iset)
1907 sgfj = first_sgf_j(1, jset)
1908 sgfk = first_sgf_k(1, kset)
1910 IF (ncoj*ncok*ncoi > 0)
THEN
1911 ALLOCATE (dijk_j(ncoj, ncok, ncoi, 3), source=0.0_dp)
1912 ALLOCATE (dijk_k(ncoj, ncok, ncoi, 3), source=0.0_dp)
1914 der_j_zero = .false.
1915 der_k_zero = .false.
1922 CALL compute_coulomb_3c_derivs(dijk_j, dijk_k, &
1923 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1924 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1925 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1926 djk, dij, dik, integral_context, potential_parameter, &
1927 der_abc_1_ext=der_ext_j, der_abc_2_ext=der_ext_k)
1929 IF (
PRESENT(der_eps))
THEN
1931 IF (der_eps > der_ext_j(i_xyz)*(max_contraction_i(iset)* &
1932 max_contraction_j(jset)* &
1933 max_contraction_k(kset)))
THEN
1934 der_j_zero(i_xyz) = .true.
1939 IF (der_eps > der_ext_k(i_xyz)*(max_contraction_i(iset)* &
1940 max_contraction_j(jset)* &
1941 max_contraction_k(kset)))
THEN
1942 der_k_zero(i_xyz) = .true.
1945 IF (all(der_j_zero) .AND. all(der_k_zero))
THEN
1946 DEALLOCATE (dijk_j, dijk_k)
1951 ALLOCATE (dijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
1953 block_start_j = sgfj
1954 block_end_j = sgfj + nsgfj(jset) - 1
1955 block_start_k = sgfk
1956 block_end_k = sgfk + nsgfk(kset) - 1
1957 block_start_i = sgfi
1958 block_end_i = sgfi + nsgfi(iset) - 1
1961 IF (der_j_zero(i_xyz)) cycle
1963 block_j_not_zero(i_xyz) = .true.
1964 CALL abc_contract_xsmm(dijk_contr, dijk_j(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1965 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1966 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1967 nsgfi(iset), cpp_buffer, ccp_buffer)
1969 block_t_j(block_start_j:block_end_j, &
1970 block_start_k:block_end_k, &
1971 block_start_i:block_end_i, i_xyz) = &
1972 block_t_j(block_start_j:block_end_j, &
1973 block_start_k:block_end_k, &
1974 block_start_i:block_end_i, i_xyz) + &
1980 IF (der_k_zero(i_xyz)) cycle
1982 block_k_not_zero(i_xyz) = .true.
1983 CALL abc_contract_xsmm(dijk_contr, dijk_k(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1984 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1985 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1986 nsgfi(iset), cpp_buffer, ccp_buffer)
1988 block_t_k(block_start_j:block_end_j, &
1989 block_start_k:block_end_k, &
1990 block_start_i:block_end_i, i_xyz) = &
1991 block_t_k(block_start_j:block_end_j, &
1992 block_start_k:block_end_k, &
1993 block_start_i:block_end_i, i_xyz) + &
1998 DEALLOCATE (dijk_j, dijk_k, dijk_contr)
2006 block_t_i(:, :, :, i_xyz) = -block_t_j(:, :, :, i_xyz) - block_t_k(:, :, :, i_xyz)
2011 force = pref*sum(ablock(:, :, :)*block_t_i(:, :, :, i_xyz))
2015 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2021 force = pref*sum(ablock(:, :, :)*block_t_j(:, :, :, i_xyz))
2025 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2031 force = pref*sum(ablock(:, :, :)*block_t_k(:, :, :, i_xyz))
2035 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2039 DEALLOCATE (block_t_i, block_t_j, block_t_k)
2040 IF (
PRESENT(der_eps))
THEN
2041 DEALLOCATE (max_contraction_i, max_contraction_j, max_contraction_k, ablock)
2045 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
2046 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
2048 CALL coulomb_integral_cleanup(integral_context)
2052 DO iset = 1, max_nset
2053 DO ibasis = 1, nbasis
2054 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
2055 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
2056 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
2060 DEALLOCATE (spi, tspj, spk)
2062 CALL timestop(handle)
2094 nl_3c, basis_i, basis_j, basis_k, &
2095 potential_parameter, int_eps, &
2096 op_pos, do_kpoints, do_hfx_kpoints, desymmetrize, cell_sym, &
2097 bounds_i, bounds_j, bounds_k, &
2098 RI_range, img_to_RI_cell, cell_to_index_ext)
2100 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(INOUT) :: t3c
2101 REAL(kind=
dp),
INTENT(IN) :: filter_eps
2106 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: int_eps
2107 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
2108 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints, &
2109 desymmetrize, cell_sym
2110 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
2111 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
2112 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
2113 INTEGER,
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: cell_to_index_ext
2115 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_3c_integrals'
2117 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
2118 block_start_k, eg_local, handle, handle2, i, iatom, ibasis, ikind, ilist,
imax, iset, &
2119 jatom, jcell, jkind, jset, katom, kcell, kkind, kset, m_max, max_ncoj, max_nset, &
2120 max_nsgfi, maxli, maxlj, maxlk, natom, nbasis, ncell_ri, ncoi, ncoj, ncok, next_pair, &
2121 nimg, nseti, nsetj, nsetk, nsgf, op_ij, op_jk, op_pos_prv, sg_local, sgfi, sgfj, sgfk
2122 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
2123 INTEGER,
DIMENSION(3) :: blk_idx, blk_size, cell_j, cell_k, &
2124 kp_index_lbounds, kp_index_ubounds,
sp
2125 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
2126 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
2128 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
2129 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2130 LOGICAL :: block_not_zero, cell_sym_prv, debug, &
2131 desymmetrize_prv, do_hfx_kpoints_prv, &
2132 do_kpoints_prv, found
2133 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, kind_radius_i, kind_radius_j, &
2134 kind_radius_k, max_contraction_i, max_contraction_j, max_contraction_k, prefac, sijk_ext
2135 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer
2136 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :), &
2137 TARGET :: max_sphi_norm_i, max_sphi_norm_j, &
2139 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: block_t, dummy_block_t, sijk, &
2141 REAL(kind=
dp),
DIMENSION(1, 1, 1) :: counter
2142 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk
2143 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
2144 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
2145 sphi_k, zeti, zetj, zetk
2146 REAL(kind=
dp),
POINTER :: max_contr_i_ptr(:), max_contr_j_ptr(:), &
2150 TYPE(coulomb_integral_context_type) :: integral_context
2152 TYPE(dbt_type) :: t_3c_tmp
2158 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2160 CALL timeset(routinen, handle)
2164 IF (
PRESENT(do_kpoints))
THEN
2165 do_kpoints_prv = do_kpoints
2167 do_kpoints_prv = .false.
2170 IF (
PRESENT(do_hfx_kpoints))
THEN
2171 do_hfx_kpoints_prv = do_hfx_kpoints
2173 do_hfx_kpoints_prv = .false.
2175 IF (do_hfx_kpoints_prv)
THEN
2176 cpassert(do_kpoints_prv)
2177 cpassert(
PRESENT(ri_range))
2178 cpassert(
PRESENT(img_to_ri_cell))
2181 IF (
PRESENT(img_to_ri_cell))
THEN
2182 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
2183 img_to_ri_cell_prv(:) = img_to_ri_cell
2186 IF (
PRESENT(desymmetrize))
THEN
2187 desymmetrize_prv = desymmetrize
2189 desymmetrize_prv = .true.
2192 IF (
PRESENT(cell_sym))
THEN
2193 cell_sym_prv = cell_sym
2195 cell_sym_prv = .false.
2200 IF (
PRESENT(op_pos))
THEN
2206 SELECT CASE (op_pos_prv)
2208 op_ij = potential_parameter%potential_type
2210 op_jk = potential_parameter%potential_type
2213 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
2220 dr_ij = 1000000.0_dp
2221 dr_ik = 1000000.0_dp
2229 dr_jk = 1000000.0_dp
2230 dr_ik = 1000000.0_dp
2233 NULLIFY (qs_kind_set, atomic_kind_set)
2236 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, cell=cell, &
2237 natom=natom, dft_control=dft_control, para_env=para_env)
2239 IF (do_kpoints_prv)
THEN
2240 IF (
PRESENT(cell_to_index_ext))
THEN
2241 cell_to_index => cell_to_index_ext
2242 nimg = maxval(cell_to_index)
2246 nimg = dft_control%nimages
2249 IF (do_hfx_kpoints_prv)
THEN
2251 ncell_ri =
SIZE(t3c, 2)
2258 CALL alloc_block_3c(t3c, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, &
2259 op_pos=op_pos_prv, do_kpoints=do_kpoints, do_hfx_kpoints=do_hfx_kpoints, &
2260 bounds_i=bounds_i, bounds_j=bounds_j, bounds_k=bounds_k, &
2261 ri_range=ri_range, img_to_ri_cell=img_to_ri_cell, cell_sym=cell_sym_prv, &
2262 cell_to_index=cell_to_index)
2264 IF (do_hfx_kpoints_prv)
THEN
2265 cpassert(op_pos_prv == 2)
2266 cpassert(.NOT. desymmetrize_prv)
2267 ELSE IF (do_kpoints_prv)
THEN
2268 cpassert(all(shape(t3c) == [nimg, ncell_ri]))
2272 nbasis =
SIZE(basis_i)
2276 DO ibasis = 1, nbasis
2278 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
2279 maxli = max(maxli,
imax)
2280 max_nset = max(max_nset, iset)
2281 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
2285 DO ibasis = 1, nbasis
2287 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
2288 maxlj = max(maxlj,
imax)
2289 max_nset = max(max_nset, jset)
2290 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
2293 DO ibasis = 1, nbasis
2295 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
2296 maxlk = max(maxlk,
imax)
2297 max_nset = max(max_nset, kset)
2299 m_max = maxli + maxlj + maxlk
2304 NULLIFY (tspj, spi, spk)
2305 NULLIFY (max_contr_i_ptr, max_contr_j_ptr, max_contr_k_ptr)
2306 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
2308 DO ibasis = 1, nbasis
2309 DO iset = 1, max_nset
2310 NULLIFY (spi(iset, ibasis)%array)
2311 NULLIFY (tspj(iset, ibasis)%array)
2313 NULLIFY (spk(iset, ibasis)%array)
2317 IF (
PRESENT(int_eps))
THEN
2318 ALLOCATE (max_sphi_norm_i(max_nset, nbasis), source=0.0_dp)
2319 ALLOCATE (max_sphi_norm_j(max_nset, nbasis), source=0.0_dp)
2320 ALLOCATE (max_sphi_norm_k(max_nset, nbasis), source=0.0_dp)
2324 DO ibasis = 1, nbasis
2327 basis_set => basis_i(ibasis)%gto_basis_set
2329 basis_set => basis_j(ibasis)%gto_basis_set
2331 basis_set => basis_k(ibasis)%gto_basis_set
2334 DO iset = 1, basis_set%nset
2335 nsgf = basis_set%nsgf_set(iset)
2336 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
2337 sg_local = basis_set%first_sgf(1, iset)
2338 eg_local = sg_local + nsgf - 1
2342 ALLOCATE (spi(iset, ibasis)%array(ncoi, nsgf))
2343 IF (ncoi > 0 .AND. nsgf > 0)
THEN
2344 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sg_local:eg_local)
2346 spi(iset, ibasis)%array(:, :) = 0.0_dp
2348 IF (
PRESENT(int_eps))
THEN
2349 IF (ncoi > 0 .AND. nsgf > 0)
THEN
2350 max_sphi_norm_i(iset, ibasis) = maxval(sum(abs(basis_set%sphi(1:ncoi, sg_local:eg_local)), &
2353 max_sphi_norm_i(iset, ibasis) = 0.0_dp
2357 ALLOCATE (tspj(iset, ibasis)%array(nsgf, ncoi))
2358 IF (ncoi > 0 .AND. nsgf > 0)
THEN
2359 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sg_local:eg_local))
2361 tspj(iset, ibasis)%array(:, :) = 0.0_dp
2363 IF (
PRESENT(int_eps))
THEN
2364 IF (ncoi > 0 .AND. nsgf > 0)
THEN
2365 max_sphi_norm_j(iset, ibasis) = maxval(sum(abs(basis_set%sphi(1:ncoi, sg_local:eg_local)), &
2368 max_sphi_norm_j(iset, ibasis) = 0.0_dp
2372 ALLOCATE (spk(iset, ibasis)%array(ncoi, nsgf))
2373 IF (ncoi > 0 .AND. nsgf > 0)
THEN
2374 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sg_local:eg_local)
2376 spk(iset, ibasis)%array(:, :) = 0.0_dp
2378 IF (
PRESENT(int_eps))
THEN
2379 IF (ncoi > 0 .AND. nsgf > 0)
THEN
2380 max_sphi_norm_k(iset, ibasis) = maxval(sum(abs(basis_set%sphi(1:ncoi, sg_local:eg_local)), &
2383 max_sphi_norm_k(iset, ibasis) = 0.0_dp
2394 IF (do_kpoints_prv)
THEN
2395 kp_index_lbounds = lbound(cell_to_index)
2396 kp_index_ubounds = ubound(cell_to_index)
2419 integral_context = coulomb_integral_context_type()
2420 CALL coulomb_integral_init(integral_context, max_am_3c=max(maxli, maxlj, maxlk), &
2426 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bounds_k)
2430 iatom=iatom, jatom=jatom, katom=katom, &
2431 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
2438 IF (jatom == katom)
THEN
2446 IF (iatom == jatom)
THEN
2456 IF (do_kpoints_prv) prefac = 1.0_dp
2458 IF (do_kpoints_prv)
THEN
2459 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
2460 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
2462 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
2463 IF (jcell > nimg .OR. jcell < 1) cycle
2465 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
2466 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
2468 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
2469 IF (kcell > nimg .OR. kcell < 1) cycle
2471 IF (do_hfx_kpoints_prv)
THEN
2472 IF (dik > ri_range) cycle
2473 kcell = img_to_ri_cell_prv(kcell)
2476 jcell = 1; kcell = 1
2479 IF (cell_sym_prv .AND. jcell < kcell) cycle
2481 blk_idx = [iatom, jatom, katom]
2482 IF (do_hfx_kpoints_prv)
THEN
2483 blk_idx(3) = (kcell - 1)*natom + katom
2487 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
2488 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
2489 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
2490 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
2491 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
2492 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
2493 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
2495 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
2496 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
2497 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
2498 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
2499 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
2501 IF (
PRESENT(int_eps))
THEN
2502 NULLIFY (max_contr_i_ptr, max_contr_j_ptr, max_contr_k_ptr)
2503 IF (nseti > 0) max_contr_i_ptr => max_sphi_norm_i(1:nseti, ikind)
2504 IF (nsetj > 0) max_contr_j_ptr => max_sphi_norm_j(1:nsetj, jkind)
2505 IF (nsetk > 0) max_contr_k_ptr => max_sphi_norm_k(1:nsetk, kkind)
2508 CALL dbt_blk_sizes(t3c(jcell, kcell), blk_idx, blk_size)
2510 ALLOCATE (block_t(blk_size(2), blk_size(3), blk_size(1)), source=0.0_dp)
2512 block_not_zero = .false.
2515 sgfi = first_sgf_i(1, iset)
2516 IF (
PRESENT(int_eps)) max_contraction_i = max_contr_i_ptr(iset)
2519 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
2522 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
2523 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
2525 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
2526 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
2527 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
2530 IF (ncoj*ncok*ncoi == 0) cycle
2537 ALLOCATE (sijk(ncoj, ncok, ncoi))
2538 IF (op_pos_prv == 1)
THEN
2539 sijk(:, :, :) = 0.0_dp
2540 CALL compute_coulomb_3c(integral_context, lmin_j(jset), lmax_j(jset), lmin_k(kset), &
2541 lmax_k(kset), lmin_i(iset), lmax_i(iset), npgfj(jset), npgfk(kset), npgfi(iset), &
2542 zetj(:, jset), zetk(:, kset), zeti(:, iset), rpgf_j(:, jset), rpgf_k(:, kset), &
2543 rpgf_i(:, iset), rj, rk, ri, sijk, potential_parameter, dab=djk, dac=dij, dbc=dik, &
2544 int_abc_ext=sijk_ext)
2546 ALLOCATE (tmp_ijk(ncoi, ncoj, ncok), source=0.0_dp)
2547 CALL compute_coulomb_3c(integral_context, lmin_i(iset), lmax_i(iset), lmin_j(jset), &
2548 lmax_j(jset), lmin_k(kset), lmax_k(kset), npgfi(iset), npgfj(jset), npgfk(kset), &
2549 zeti(:, iset), zetj(:, jset), zetk(:, kset), rpgf_i(:, iset), rpgf_j(:, jset), &
2550 rpgf_k(:, kset), ri, rj, rk, tmp_ijk, potential_parameter, dab=dij, dac=dik, dbc=djk, &
2551 int_abc_ext=sijk_ext)
2555 sijk(:, :, i) = tmp_ijk(i, :, :)
2557 DEALLOCATE (tmp_ijk)
2560 IF (
PRESENT(int_eps))
THEN
2561 max_contraction_j = max_contr_j_ptr(jset)
2562 max_contraction_k = max_contr_k_ptr(kset)
2563 IF (int_eps > sijk_ext*(max_contraction_i* &
2564 max_contraction_j* &
2565 max_contraction_k))
THEN
2571 block_not_zero = .true.
2572 ALLOCATE (sijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
2574 spk(kset, kkind)%array, spi(iset, ikind)%array, &
2575 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
2576 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
2579 sgfj = first_sgf_j(1, jset)
2580 sgfk = first_sgf_k(1, kset)
2582 block_start_j = sgfj
2583 block_end_j = sgfj + nsgfj(jset) - 1
2584 block_start_k = sgfk
2585 block_end_k = sgfk + nsgfk(kset) - 1
2586 block_start_i = sgfi
2587 block_end_i = sgfi + nsgfi(iset) - 1
2589 block_t(block_start_j:block_end_j, &
2590 block_start_k:block_end_k, &
2591 block_start_i:block_end_i) = &
2592 block_t(block_start_j:block_end_j, &
2593 block_start_k:block_end_k, &
2594 block_start_i:block_end_i) + &
2596 DEALLOCATE (sijk_contr)
2604 IF (block_not_zero)
THEN
2606 CALL timeset(routinen//
"_put_dbcsr", handle2)
2608 CALL dbt_get_block(t3c(jcell, kcell), blk_idx, dummy_block_t, found=found)
2615 CALL dbt_put_block(t3c(jcell, kcell), blk_idx,
sp, &
2616 reshape(block_t, shape=
sp, order=[2, 3, 1]), summation=.true.)
2618 CALL timestop(handle2)
2622 DEALLOCATE (block_t)
2625 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
2626 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
2628 CALL coulomb_integral_cleanup(integral_context)
2633 IF (nl_3c%sym ==
symmetric_jk .OR. do_kpoints_prv)
THEN
2635 IF (.NOT. do_hfx_kpoints_prv)
THEN
2639 CALL dbt_filter(t3c(jcell, kcell), filter_eps/2)
2643 DO kcell = 1, ncell_ri
2645 CALL dbt_filter(t3c(jcell, kcell), filter_eps)
2650 IF (desymmetrize_prv)
THEN
2652 CALL dbt_create(t3c(1, 1), t_3c_tmp)
2655 CALL dbt_copy(t3c(jcell, kcell), t_3c_tmp)
2656 CALL dbt_copy(t_3c_tmp, t3c(kcell, jcell), order=[1, 3, 2], summation=.true., move_data=.true.)
2657 CALL dbt_filter(t3c(kcell, jcell), filter_eps)
2660 DO kcell = jcell + 1, nimg
2662 CALL dbt_copy(t3c(jcell, kcell), t_3c_tmp)
2663 CALL dbt_copy(t_3c_tmp, t3c(kcell, jcell), order=[1, 3, 2], summation=.false., move_data=.true.)
2664 CALL dbt_filter(t3c(kcell, jcell), filter_eps)
2667 CALL dbt_destroy(t_3c_tmp)
2672 CALL dbt_filter(t3c(jcell, kcell), filter_eps/2)
2678 CALL dbt_filter(t3c(jcell, kcell), filter_eps)
2682 cpabort(
"requested symmetric case not implemented")
2685 IF (
ALLOCATED(max_sphi_norm_i))
DEALLOCATE (max_sphi_norm_i)
2686 IF (
ALLOCATED(max_sphi_norm_j))
DEALLOCATE (max_sphi_norm_j)
2687 IF (
ALLOCATED(max_sphi_norm_k))
DEALLOCATE (max_sphi_norm_k)
2689 DO ibasis = 1, nbasis
2690 DO iset = 1, max_nset
2691 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
2692 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
2693 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
2696 DEALLOCATE (spi, tspj, spk)
2698 CALL timestop(handle)
2714 nl_2c, basis_i, basis_j, &
2715 potential_parameter, do_kpoints)
2717 TYPE(
dbcsr_type),
DIMENSION(:, :),
INTENT(INOUT) :: t2c_der
2718 REAL(kind=
dp),
INTENT(IN) :: filter_eps
2724 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints
2726 CHARACTER(len=*),
PARAMETER :: routinen =
'build_2c_derivatives'
2728 INTEGER :: handle, i_xyz, iatom, ibasis, icol, ikind,
imax, img, irow, iset, jatom, jkind, &
2729 jset, m_max, maxli, maxlj, natom, ncoi, ncoj, nimg, nseti, nsetj, op_prv, sgfi, sgfj
2730 INTEGER,
DIMENSION(3) :: cell_j, kp_index_lbounds, &
2732 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
2734 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
2735 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2736 LOGICAL :: do_kpoints_prv, do_symmetric, found, &
2738 REAL(kind=
dp) :: dab
2739 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dij_contr, dij_rs
2740 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dij
2741 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj
2742 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
2743 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
2747 TYPE(coulomb_integral_context_type) :: integral_context
2752 DIMENSION(:),
POINTER :: nl_iterator
2753 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2755 CALL timeset(routinen, handle)
2757 IF (
PRESENT(do_kpoints))
THEN
2758 do_kpoints_prv = do_kpoints
2760 do_kpoints_prv = .false.
2763 op_prv = potential_parameter%potential_type
2765 NULLIFY (qs_kind_set, atomic_kind_set, block_t(1)%block, block_t(2)%block, block_t(3)%block, cell_to_index)
2768 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
2769 natom=natom, kpoints=kpoints, dft_control=dft_control, para_env=para_env)
2771 IF (do_kpoints_prv)
THEN
2772 nimg =
SIZE(t2c_der, 1)
2774 kp_index_lbounds = lbound(cell_to_index)
2775 kp_index_ubounds = ubound(cell_to_index)
2781 cpassert(
SIZE(nl_2c) > 0)
2784 IF (do_symmetric)
THEN
2806 DO ibasis = 1,
SIZE(basis_i)
2808 maxli = max(maxli,
imax)
2811 DO ibasis = 1,
SIZE(basis_j)
2813 maxlj = max(maxlj,
imax)
2816 m_max = maxli + maxlj + 1
2820 CALL coulomb_integral_init(integral_context, max_am_2c=max(maxli, maxlj), &
2827 iatom=iatom, jatom=jatom, r=rij, cell=cell_j)
2828 IF (do_kpoints_prv)
THEN
2829 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
2830 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
2831 img = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
2832 IF (img > nimg .OR. img < 1) cycle
2837 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
2838 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
2839 sphi=sphi_i, zet=zeti)
2841 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
2842 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
2843 sphi=sphi_j, zet=zetj)
2845 IF (do_symmetric)
THEN
2846 IF (iatom <= jatom)
THEN
2859 trans = do_symmetric .AND. (iatom > jatom)
2863 row=irow, col=icol, block=block_t(i_xyz)%block, found=found)
2869 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
2870 sgfi = first_sgf_i(1, iset)
2874 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
2875 sgfj = first_sgf_j(1, jset)
2877 IF (ncoi*ncoj > 0)
THEN
2878 ALLOCATE (dij_contr(nsgfi(iset), nsgfj(jset)))
2879 ALLOCATE (dij(ncoi, ncoj, 3), source=0.0_dp)
2884 CALL compute_coulomb_2c_derivs(dij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
2885 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
2886 rpgf_j(:, jset), rj, dab, integral_context, potential_parameter)
2890 dij_contr(:, :) = 0.0_dp
2892 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
2893 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
2897 ALLOCATE (dij_rs(nsgfj(jset), nsgfi(iset)))
2898 dij_rs(:, :) = -1.0_dp*transpose(dij_contr)
2900 ALLOCATE (dij_rs(nsgfi(iset), nsgfj(jset)))
2901 dij_rs(:, :) = dij_contr
2905 nsgfi(iset), nsgfj(jset), block_t(i_xyz)%block, &
2906 sgfi, sgfj, trans=trans)
2910 DEALLOCATE (dij, dij_contr)
2916 CALL coulomb_integral_cleanup(integral_context)
2926 CALL timestop(handle)
2942 SUBROUTINE calc_2c_virial(work_virial, t2c_trace, pref, qs_env, nl_2c, basis_i, basis_j, potential_parameter)
2943 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: work_virial
2945 REAL(kind=
dp),
INTENT(IN) :: pref
2952 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_2c_virial'
2954 INTEGER :: handle, i_xyz, iatom, ibasis, ikind,
imax, iset, j_xyz, jatom, jkind, jset, &
2955 m_max, maxli, maxlj, natom, ncoi, ncoj, nseti, nsetj, op_prv, sgfi, sgfj
2956 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
2958 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
2959 LOGICAL :: do_symmetric, found
2961 REAL(
dp),
DIMENSION(:, :),
POINTER :: pblock
2962 REAL(kind=
dp) :: dab
2963 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dij_contr
2964 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dij
2965 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj, scoord
2966 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
2967 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
2971 TYPE(coulomb_integral_context_type) :: integral_context
2975 DIMENSION(:),
POINTER :: nl_iterator
2977 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2979 CALL timeset(routinen, handle)
2981 op_prv = potential_parameter%potential_type
2983 NULLIFY (qs_kind_set, atomic_kind_set, pblock, particle_set, cell)
2986 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
2987 natom=natom, dft_control=dft_control, para_env=para_env, &
2988 particle_set=particle_set, cell=cell)
2991 cpassert(
SIZE(nl_2c) > 0)
2993 cpassert(.NOT. do_symmetric)
2996 DO ibasis = 1,
SIZE(basis_i)
2998 maxli = max(maxli,
imax)
3001 DO ibasis = 1,
SIZE(basis_j)
3003 maxlj = max(maxlj,
imax)
3006 m_max = maxli + maxlj + 1
3010 CALL coulomb_integral_init(integral_context, max_am_2c=max(maxli, maxlj), &
3017 iatom=iatom, jatom=jatom, r=rij)
3019 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
3020 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
3021 sphi=sphi_i, zet=zeti)
3023 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
3024 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
3025 sphi=sphi_j, zet=zetj)
3030 IF (.NOT. found) cycle
3034 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
3035 sgfi = first_sgf_i(1, iset)
3039 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
3040 sgfj = first_sgf_j(1, jset)
3042 IF (ncoi*ncoj > 0)
THEN
3043 ALLOCATE (dij_contr(nsgfi(iset), nsgfj(jset)))
3044 ALLOCATE (dij(ncoi, ncoj, 3), source=0.0_dp)
3049 CALL compute_coulomb_2c_derivs(dij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
3050 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
3051 rpgf_j(:, jset), rj, dab, integral_context, potential_parameter)
3055 dij_contr(:, :) = 0.0_dp
3057 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
3058 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
3060 force = sum(pblock(sgfi:sgfi + nsgfi(iset) - 1, sgfj:sgfj + nsgfj(jset) - 1)*dij_contr(:, :))
3066 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
3072 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) - force*scoord(j_xyz)
3076 DEALLOCATE (dij, dij_contr)
3083 CALL coulomb_integral_cleanup(integral_context)
3085 CALL timestop(handle)
3105 nl_2c, basis_i, basis_j, &
3106 potential_parameter, do_kpoints, &
3107 do_hfx_kpoints, ext_kpoints, regularization_RI)
3109 TYPE(
dbcsr_type),
DIMENSION(:),
INTENT(INOUT) :: t2c
3110 REAL(kind=
dp),
INTENT(IN) :: filter_eps
3116 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
3117 TYPE(
kpoint_type),
OPTIONAL,
POINTER :: ext_kpoints
3118 REAL(kind=
dp),
OPTIONAL :: regularization_ri
3120 CHARACTER(len=*),
PARAMETER :: routinen =
'build_2c_integrals'
3122 INTEGER :: handle, i_diag, iatom, ibasis, icol, ikind,
imax, img, irow, iset, jatom, jkind, &
3123 jset, m_max, maxli, maxlj, natom, ncoi, ncoj, nimg, nseti, nsetj, op_prv, sgfi, sgfj
3124 INTEGER,
DIMENSION(3) :: cell_j, kp_index_lbounds, &
3126 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
3128 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
3129 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
3130 LOGICAL :: do_hfx_kpoints_prv, do_kpoints_prv, &
3131 do_symmetric, found, trans
3132 REAL(kind=
dp) :: dab, min_zet
3133 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: sij, sij_contr, sij_rs
3134 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj
3135 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
3136 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
3141 TYPE(coulomb_integral_context_type) :: integral_context
3146 DIMENSION(:),
POINTER :: nl_iterator
3147 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3149 CALL timeset(routinen, handle)
3151 IF (
PRESENT(do_kpoints))
THEN
3152 do_kpoints_prv = do_kpoints
3154 do_kpoints_prv = .false.
3157 IF (
PRESENT(do_hfx_kpoints))
THEN
3158 do_hfx_kpoints_prv = do_hfx_kpoints
3160 do_hfx_kpoints_prv = .false.
3162 IF (do_hfx_kpoints_prv)
THEN
3163 cpassert(do_kpoints_prv)
3166 op_prv = potential_parameter%potential_type
3168 NULLIFY (qs_kind_set, atomic_kind_set, block_t%block, cell_to_index)
3171 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, cell=cell, &
3172 natom=natom, dft_control=dft_control, para_env=para_env, kpoints=kpoints)
3174 IF (
PRESENT(ext_kpoints)) kpoints => ext_kpoints
3176 IF (do_kpoints_prv)
THEN
3179 kp_index_lbounds = lbound(cell_to_index)
3180 kp_index_ubounds = ubound(cell_to_index)
3186 cpassert(
SIZE(nl_2c) > 0)
3189 IF (do_symmetric)
THEN
3204 DO ibasis = 1,
SIZE(basis_i)
3206 maxli = max(maxli,
imax)
3209 DO ibasis = 1,
SIZE(basis_j)
3211 maxlj = max(maxlj,
imax)
3214 m_max = maxli + maxlj
3218 CALL coulomb_integral_init(integral_context, max_am_2c=max(maxli, maxlj), &
3225 iatom=iatom, jatom=jatom, r=rij, cell=cell_j)
3226 IF (do_kpoints_prv)
THEN
3227 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
3228 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
3229 img = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
3230 IF (img > nimg .OR. img < 1) cycle
3235 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
3236 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
3237 sphi=sphi_i, zet=zeti)
3239 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
3240 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
3241 sphi=sphi_j, zet=zetj)
3243 IF (do_symmetric)
THEN
3244 IF (iatom <= jatom)
THEN
3259 row=irow, col=icol, block=block_t%block, found=found)
3261 trans = do_symmetric .AND. (iatom > jatom)
3265 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
3266 sgfi = first_sgf_i(1, iset)
3270 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
3271 sgfj = first_sgf_j(1, jset)
3273 IF (ncoi*ncoj > 0)
THEN
3274 ALLOCATE (sij_contr(nsgfi(iset), nsgfj(jset)), source=0.0_dp)
3275 ALLOCATE (sij(ncoi, ncoj), source=0.0_dp)
3280 CALL compute_coulomb_2c(integral_context, lmin_i(iset), lmax_i(iset), lmin_j(jset), lmax_j(jset), &
3281 npgfi(iset), npgfj(jset), zeti(:, iset), zetj(:, jset), rpgf_i(:, iset), rpgf_j(:, jset), &
3282 ri, rj, sij, potential_parameter, dab=dab)
3285 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
3286 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
3290 ALLOCATE (sij_rs(nsgfj(jset), nsgfi(iset)))
3291 sij_rs(:, :) = transpose(sij_contr)
3293 ALLOCATE (sij_rs(nsgfi(iset), nsgfj(jset)))
3294 sij_rs(:, :) = sij_contr
3297 DEALLOCATE (sij_contr)
3300 IF (.NOT. do_hfx_kpoints_prv .AND.
PRESENT(regularization_ri) .AND. &
3301 iatom == jatom .AND. iset == jset .AND. &
3302 cell_j(1) == 0 .AND. cell_j(2) == 0 .AND. cell_j(3) == 0)
THEN
3303 DO i_diag = 1, nsgfi(iset)
3304 min_zet = minval(zeti(1:npgfi(iset), iset))
3305 cpassert(min_zet > 1.0e-10_dp)
3306 sij_rs(i_diag, i_diag) = sij_rs(i_diag, i_diag) + &
3307 regularization_ri*max(1.0_dp, 1.0_dp/min_zet)
3312 nsgfi(iset), nsgfj(jset), block_t%block, &
3313 sgfi, sgfj, trans=trans)
3321 CALL coulomb_integral_cleanup(integral_context)
3329 CALL timestop(handle)
3342 TYPE(dbt_type),
INTENT(INOUT) ::
tensor
3343 INTEGER,
ALLOCATABLE,
DIMENSION(:, :), &
3344 INTENT(INOUT) :: blk_indices
3346 REAL(
dp),
INTENT(IN) :: eps
3347 REAL(
dp),
INTENT(INOUT) :: memory
3349 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compress_tensor'
3351 INTEGER :: buffer_left, buffer_size, buffer_start, &
3352 handle, i, ibin, iblk, memory_usage, &
3353 nbins, nblk, nints, offset, &
3355 INTEGER(int_8) :: storage_counter_integrals
3356 INTEGER,
DIMENSION(3) :: ind
3358 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :),
TARGET :: blk_data
3359 REAL(
dp),
DIMENSION(:),
POINTER :: blk_data_1d
3360 TYPE(dbt_iterator_type) :: iter
3364 CALL timeset(routinen, handle)
3368 nbins = omp_get_max_threads()
3371 ALLOCATE (compressed%maxval_container(nbins), compressed%integral_containers(64, nbins))
3373 IF (
ALLOCATED(blk_indices))
DEALLOCATE (blk_indices)
3374 ALLOCATE (blk_indices(dbt_get_num_blocks(
tensor), 3))
3378 CALL dbt_iterator_start(iter,
tensor)
3379 nblk = dbt_iterator_num_blocks(iter)
3381 offset = shared_offset
3382 shared_offset = shared_offset + nblk
3385 CALL dbt_iterator_next_block(iter, ind)
3386 blk_indices(offset + iblk, :) = ind(:)
3388 CALL dbt_iterator_stop(iter)
3392 nblk =
SIZE(blk_indices, 1)
3393 storage_counter_integrals = 0
3400 integral_container => compressed%integral_containers(1, ibin)
3402 real_cache%element_counter = 1
3404 DO i = (ibin - 1)*nblk/nbins + 1, ibin*nblk/nbins
3405 ind = blk_indices(i, :)
3406 CALL dbt_get_block(
tensor, ind, blk_data, found)
3408 nints =
SIZE(blk_data)
3409 blk_data_1d(1:nints) => blk_data
3414 DO WHILE (buffer_left > 0)
3415 buffer_size = min(buffer_left, cache_size)
3417 integral_container, eps, memory_usage, .false.)
3418 buffer_left = buffer_left - buffer_size
3419 buffer_start = buffer_start + buffer_size
3422 NULLIFY (blk_data_1d);
DEALLOCATE (blk_data)
3428 storage_counter_integrals = storage_counter_integrals + int(memory_usage,
int_8)*cache_size
3436 memory = memory + real(storage_counter_integrals,
dp)/1024/128
3440 CALL timestop(handle)
3453 TYPE(dbt_type),
INTENT(INOUT) ::
tensor
3454 INTEGER,
DIMENSION(:, :) :: blk_indices
3456 REAL(
dp),
INTENT(IN) :: eps
3458 CHARACTER(LEN=*),
PARAMETER :: routinen =
'decompress_tensor'
3460 INTEGER :: a, b, buffer_left, buffer_size, &
3461 buffer_start, handle, i, ibin, &
3462 memory_usage, nbins, nblk, &
3463 nblk_per_thread, nints
3464 INTEGER,
DIMENSION(3) :: blk_size, ind
3465 REAL(
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: blk_data
3466 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: blk_data_3d
3470 CALL timeset(routinen, handle)
3474 nblk_per_thread =
SIZE(blk_indices, 1)/omp_get_num_threads() + 1
3475 a = omp_get_thread_num()*nblk_per_thread + 1
3476 b = min(a + nblk_per_thread,
SIZE(blk_indices, 1))
3477 CALL dbt_reserve_blocks(
tensor, blk_indices(a:b, :))
3481 nbins =
SIZE(compressed%integral_containers, 2)
3482 nblk =
SIZE(blk_indices, 1)
3487 integral_container => compressed%integral_containers(1, ibin)
3491 DO i = (ibin - 1)*nblk/nbins + 1, ibin*nblk/nbins
3492 ind = blk_indices(i, :)
3493 CALL dbt_blk_sizes(
tensor, ind, blk_size)
3494 nints = product(blk_size)
3499 ALLOCATE (blk_data(nints))
3500 DO WHILE (buffer_left > 0)
3501 buffer_size = min(buffer_left, cache_size)
3503 integral_container, eps, memory_usage, .false.)
3504 buffer_left = buffer_left - buffer_size
3505 buffer_start = buffer_start + buffer_size
3508 blk_data_3d(1:blk_size(1), 1:blk_size(2), 1:blk_size(3)) => blk_data
3509 CALL dbt_put_block(
tensor, ind, blk_size, blk_data_3d)
3510 NULLIFY (blk_data_3d);
DEALLOCATE (blk_data)
3517 CALL timestop(handle)
3527 TYPE(dbt_type),
INTENT(IN) ::
tensor
3528 INTEGER(int_8),
INTENT(OUT) :: nze
3529 REAL(
dp),
INTENT(OUT) :: occ
3531 INTEGER,
DIMENSION(dbt_ndims(tensor)) :: dims
3533 nze = dbt_get_nze_total(
tensor)
3534 CALL dbt_get_info(
tensor, nfull_total=dims)
3535 occ = real(nze,
dp)/product(real(dims,
dp))
static int imax(int x, int y)
Returns the larger of two given integers (missing from the C standard).
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Contraction of integrals over primitive Cartesian Gaussians based on the contraction matrix sphi whic...
subroutine, public abc_contract_xsmm(abcint, sabc, sphi_a, sphi_b, sphi_c, ncoa, ncob, ncoc, nsgfa, nsgfb, nsgfc, cpp_buffer, ccp_buffer, prefac, pstfac)
3-center contraction routine from primitive cartesian Gaussians to spherical Gaussian functions using...
subroutine, public ab_contract(abint, sab, sphi_a, sphi_b, ncoa, ncob, nsgfa, nsgfb)
contract overlap integrals (a,b) and transfer to spherical Gaussians
Set of routines to: Contract integrals over primitive Gaussians Decontract (density) matrices Trace m...
Define the atomic kind types and their sub types.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
collect pointers to a block of reals
Handles all functions related to the CELL.
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
Common interface for two- and three-center Coulomb integrals.
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
logical function, public dbcsr_has_symmetry(matrix)
...
character function, public dbcsr_get_matrix_type(matrix)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_finalize(matrix)
...
Routines that link DBCSR and CP2K concepts together.
subroutine, public cp_dbcsr_alloc_block_from_nbl(matrix, sab_orb, desymmetrize)
allocate the blocks of a dbcsr based on the neighbor list
This is the start of a dbt_api, all publically needed functions are exported here....
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
stores a mapping of 2D info (e.g. matrix) on a 2D processor distribution (i.e. blacs grid) where cpus...
routines and types for Hartree-Fock-Exchange
subroutine, public hfx_flush_last_real_cache(cache, container, eps, memory_usage, use_disk_storage)
Packs the last cache of real values (unused values as zeros) into the container.
subroutine, public hfx_get_mult_real_elements(values, nints, cache, container, eps, memory_usage, use_disk_storage)
Gets real values from a cache (at most a cache full); an exhausted cache is refilled from the next re...
subroutine, public hfx_add_mult_real_elements(values, nints, cache, container, eps, memory_usage, use_disk_storage)
Adds real values to a cache (at most a cache full); a full cache is packed into the container,...
subroutine, public hfx_decompress_first_real_cache(cache, container, eps, memory_usage, use_disk_storage)
Fills a cache of real values with the first record of a container.
subroutine, public hfx_reset_real_cache_and_container(cache, container, memory_usage, do_disk_storage)
Moves a cache of real values and its container back to the beginning (as hfx_reset_cache_and_containe...
Types and set/get functions for HFX.
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 dealloc_containers(data, memory_usage)
...
Library choices for electronic integral APIs.
real(dp), parameter, public cutoff_screen_factor
integer, parameter, public library_libint
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public sp
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered, rskp_transform)
Retrieve information from a kpoint environment.
Interface to the message passing library MPI.
Define the data structure for the molecule information.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
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, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, 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, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
Define the neighbor list data types and the corresponding functionality.
subroutine, public release_neighbor_list_sets(nlists)
releases an array of neighbor_list_sets
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
subroutine, public get_neighbor_list_set_p(neighbor_list_sets, nlist, symmetric)
Return the components of the first neighbor list set.
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
Generate the atomic neighbor lists.
subroutine, public atom2d_cleanup(atom2d)
free the internals of atom2d
subroutine, public pair_radius_setup(present_a, present_b, radius_a, radius_b, pair_radius, prmin)
...
subroutine, public build_neighbor_lists(ab_list, particle_set, atom, cell, pair_radius, subcells, mic, symmetric, molecular, subset_of_mol, current_subset, operator_type, nlname, atomb_to_keep, stable_images)
Build simple pair neighbor lists.
subroutine, public atom2d_build(atom2d, distribution_1d, distribution_2d, atomic_kind_set, molecule_set, molecule_only, particle_set)
Build some distribution structure of atoms, refactored from build_qs_neighbor_lists.
Utility methods to build 3-center integral tensors of various types.
integer, parameter, public symmetrik_ik
integer, parameter, public symmetric_jk
integer, parameter, public symmetric_ijk
integer, parameter, public symmetric_ij
integer, parameter, public symmetric_none
subroutine, public distribution_3d_destroy(dist)
Destroy a 3d distribution.
Utility methods to build 3-center integral tensors of various types.
subroutine, public build_2c_integrals(t2c, filter_eps, qs_env, nl_2c, basis_i, basis_j, potential_parameter, do_kpoints, do_hfx_kpoints, ext_kpoints, regularization_ri)
...
subroutine, public calc_3c_virial(work_virial, t3c_trace, pref, qs_env, nl_3c, basis_i, basis_j, basis_k, potential_parameter, der_eps, op_pos)
Calculates the 3c virial contributions on the fly.
subroutine, public build_3c_derivatives(t3c_der_i, t3c_der_k, filter_eps, qs_env, nl_3c, basis_i, basis_j, basis_k, potential_parameter, der_eps, op_pos, do_kpoints, do_hfx_kpoints, bounds_i, bounds_j, bounds_k, ri_range, img_to_ri_cell)
Build 3-center derivative tensors.
subroutine, public build_2c_neighbor_lists(ij_list, basis_i, basis_j, potential_parameter, name, qs_env, sym_ij, molecular, dist_2d, pot_to_rad)
Build 2-center neighborlists adapted to different operators This mainly wraps build_neighbor_lists fo...
subroutine, public build_3c_integrals(t3c, filter_eps, qs_env, nl_3c, basis_i, basis_j, basis_k, potential_parameter, int_eps, op_pos, do_kpoints, do_hfx_kpoints, desymmetrize, cell_sym, bounds_i, bounds_j, bounds_k, ri_range, img_to_ri_cell, cell_to_index_ext)
Build 3-center integral tensor.
subroutine, public compress_tensor(tensor, blk_indices, compressed, eps, memory)
...
subroutine, public neighbor_list_3c_iterator_destroy(iterator)
Destroy 3c-nl iterator.
subroutine, public neighbor_list_3c_destroy(ijk_list)
Destroy 3c neighborlist.
subroutine, public calc_2c_virial(work_virial, t2c_trace, pref, qs_env, nl_2c, basis_i, basis_j, potential_parameter)
Calculates the virial coming from 2c derivatives on the fly.
subroutine, public decompress_tensor(tensor, blk_indices, compressed, eps)
...
subroutine, public build_2c_derivatives(t2c_der, filter_eps, qs_env, nl_2c, basis_i, basis_j, potential_parameter, do_kpoints)
Calculates the derivatives of 2-center integrals, wrt to the first center.
subroutine, public get_tensor_occupancy(tensor, nze, occ)
...
subroutine, public build_3c_neighbor_lists(ijk_list, basis_i, basis_j, basis_k, dist_3d, potential_parameter, name, qs_env, sym_ij, sym_jk, sym_ik, molecular, op_pos, own_dist)
Build a 3-center neighbor list.
integer function, public neighbor_list_3c_iterate(iterator, next_pair)
Iterate 3c-nl iterator.
subroutine, public neighbor_list_3c_iterator_create(iterator, ijk_nl)
Create a 3-center neighborlist iterator.
subroutine, public get_3c_iterator_info(iterator, ikind, jkind, kkind, nkind, iatom, jatom, katom, rij, rjk, rik, cell_j, cell_k)
Get info of current iteration.
Radial fundamentals for Gaussian two-electron integrals. Entry m+1 stores order m....
subroutine, public r12_fundamentals_init(m_max, potential_parameter, para_env)
Prepare shared radial evaluator tables before entering a threaded evaluation region.
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 pointer to a 2d array
structure to store local (to a processor) ordered lists of integers.
distributes pairs on a 2d grid of processors
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.