12 USE omp_lib,
ONLY: omp_get_num_threads,&
32 dbcsr_type_antisymmetric,&
33 dbcsr_type_no_symmetry
38 dbt_blk_sizes, dbt_clear, dbt_copy, dbt_create, dbt_destroy, dbt_filter, dbt_get_block, &
39 dbt_get_info, dbt_get_num_blocks, dbt_get_nze_total, dbt_iterator_next_block, &
40 dbt_iterator_num_blocks, dbt_iterator_start, dbt_iterator_stop, dbt_iterator_type, &
41 dbt_ndims, dbt_put_block, dbt_reserve_blocks, dbt_type
103#include "./base/base_uses.f90"
109 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_tensors'
118 TYPE one_dim_int_array
119 INTEGER,
DIMENSION(:),
ALLOCATABLE :: array
123 INTEGER,
PARAMETER,
PRIVATE :: cache_size = 1024
142 sym_ij, molecular, dist_2d, pot_to_rad)
147 CHARACTER(LEN=*),
INTENT(IN) :: name
149 LOGICAL,
INTENT(IN),
OPTIONAL :: sym_ij, molecular
151 INTEGER,
INTENT(IN),
OPTIONAL :: pot_to_rad
153 INTEGER :: ikind, nkind, pot_to_rad_prv
154 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: i_present, j_present
155 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pair_radius
156 REAL(kind=
dp) :: subcells
157 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: i_radius, j_radius
166 NULLIFY (atomic_kind_set, cell, local_particles, molecule_set, &
167 particle_set, dist_2d_prv)
169 IF (
PRESENT(pot_to_rad))
THEN
170 pot_to_rad_prv = pot_to_rad
178 particle_set=particle_set, &
179 atomic_kind_set=atomic_kind_set, &
180 local_particles=local_particles, &
181 distribution_2d=dist_2d_prv, &
182 molecule_set=molecule_set)
186 ALLOCATE (i_present(nkind), j_present(nkind))
187 ALLOCATE (i_radius(nkind), j_radius(nkind))
194 IF (
PRESENT(dist_2d)) dist_2d_prv => dist_2d
201 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
202 i_present(ikind) = .true.
203 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, kind_radius=i_radius(ikind))
205 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
206 j_present(ikind) = .true.
207 CALL get_gto_basis_set(basis_j(ikind)%gto_basis_set, kind_radius=j_radius(ikind))
215 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
216 i_present(ikind) = .true.
217 IF (pot_to_rad_prv == 1) i_radius(ikind) = 1000000.0_dp
219 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
220 j_present(ikind) = .true.
221 IF (pot_to_rad_prv == 2) j_radius(ikind) = 1000000.0_dp
230 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
231 i_present(ikind) = .true.
232 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, kind_radius=i_radius(ikind))
233 IF (pot_to_rad_prv == 1) i_radius(ikind) = i_radius(ikind) +
cutoff_screen_factor*potential_parameter%cutoff_radius
235 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
236 j_present(ikind) = .true.
237 CALL get_gto_basis_set(basis_j(ikind)%gto_basis_set, kind_radius=j_radius(ikind))
238 IF (pot_to_rad_prv == 2) j_radius(ikind) = j_radius(ikind) +
cutoff_screen_factor*potential_parameter%cutoff_radius
243 cpabort(
"Operator not implemented.")
246 ALLOCATE (pair_radius(nkind, nkind))
250 ALLOCATE (atom2d(nkind))
252 CALL atom2d_build(atom2d, local_particles, dist_2d_prv, atomic_kind_set, &
253 molecule_set, molecule_only=.false., particle_set=particle_set)
255 symmetric=sym_ij, molecular=molecular, nlname=trim(name))
279 dist_3d, potential_parameter, name, qs_env, &
280 sym_ij, sym_jk, sym_ik, molecular, op_pos, &
286 CHARACTER(LEN=*),
INTENT(IN) :: name
288 LOGICAL,
INTENT(IN),
OPTIONAL :: sym_ij, sym_jk, sym_ik, molecular
289 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
290 LOGICAL,
INTENT(IN),
OPTIONAL :: own_dist
292 CHARACTER(len=*),
PARAMETER :: routinen =
'build_3c_neighbor_lists'
294 INTEGER :: handle, op_pos_prv, sym_level
297 CALL timeset(routinen, handle)
299 IF (
PRESENT(op_pos))
THEN
305 SELECT CASE (op_pos_prv)
307 pot_par_1 = potential_parameter
310 pot_par_2 = potential_parameter
315 qs_env, sym_ij=.false., molecular=molecular, &
316 dist_2d=dist_3d%dist_2d_1, pot_to_rad=1)
319 qs_env, sym_ij=.false., molecular=molecular, &
320 dist_2d=dist_3d%dist_2d_2, pot_to_rad=2)
325 IF (
PRESENT(sym_ij))
THEN
328 sym_level = sym_level + 1
332 IF (
PRESENT(sym_jk))
THEN
335 sym_level = sym_level + 1
339 IF (
PRESENT(sym_ik))
THEN
342 sym_level = sym_level + 1
346 IF (sym_level >= 2)
THEN
350 ijk_list%dist_3d = dist_3d
351 IF (
PRESENT(own_dist))
THEN
352 ijk_list%owns_dist = own_dist
354 ijk_list%owns_dist = .false.
357 CALL timestop(handle)
366 PURE FUNCTION include_symmetric(a, b)
367 INTEGER,
INTENT(IN) :: a, b
368 LOGICAL :: include_symmetric
371 include_symmetric = (
modulo(a + b, 2) /= 0)
373 include_symmetric = (
modulo(a + b, 2) == 0)
388 IF (ijk_list%owns_dist)
THEN
403 CHARACTER(len=*),
PARAMETER :: routinen =
'neighbor_list_3c_iterator_create'
407 CALL timeset(routinen, handle)
412 iterator%iter_level = 0
413 iterator%ijk_nl = ijk_nl
415 iterator%bounds_i = 0
416 iterator%bounds_j = 0
417 iterator%bounds_k = 0
419 CALL timestop(handle)
429 SUBROUTINE nl_3c_iter_set_bounds(iterator, bounds_i, bounds_j, bounds_k)
431 INTENT(INOUT) :: iterator
432 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
434 IF (
PRESENT(bounds_i)) iterator%bounds_i = bounds_i
435 IF (
PRESENT(bounds_j)) iterator%bounds_j = bounds_j
436 IF (
PRESENT(bounds_k)) iterator%bounds_k = bounds_k
446 INTENT(INOUT) :: iterator
448 CHARACTER(len=*),
PARAMETER :: routinen =
'neighbor_list_3c_iterator_destroy'
452 CALL timeset(routinen, handle)
455 NULLIFY (iterator%iter_ij)
456 NULLIFY (iterator%iter_jk)
458 CALL timestop(handle)
468 INTENT(INOUT) :: iterator
471 INTEGER :: iatom, iter_level, jatom, jatom_1, &
475 iter_level = iterator%iter_level
477 IF (iter_level == 0)
THEN
480 IF (iter_stat /= 0)
THEN
486 IF ((iterator%bounds_i(1) > 0 .AND. iatom < iterator%bounds_i(1)) &
487 .OR. (iterator%bounds_i(2) > 0 .AND. iatom > iterator%bounds_i(2))) skip_this = .true.
488 IF ((iterator%bounds_j(1) > 0 .AND. jatom < iterator%bounds_j(1)) &
489 .OR. (iterator%bounds_j(2) > 0 .AND. jatom > iterator%bounds_j(2))) skip_this = .true.
498 IF (iter_stat /= 0)
THEN
499 iterator%iter_level = 0
503 iterator%iter_level = 1
506 cpassert(iter_stat == 0)
507 cpassert(iterator%iter_level == 1)
511 cpassert(jatom_1 == jatom_2)
515 IF ((iterator%bounds_k(1) > 0 .AND. katom < iterator%bounds_k(1)) &
516 .OR. (iterator%bounds_k(2) > 0 .AND. katom > iterator%bounds_k(2))) skip_this = .true.
523 SELECT CASE (iterator%ijk_nl%sym)
527 skip_this = .NOT. include_symmetric(iatom, jatom)
529 skip_this = .NOT. include_symmetric(jatom, katom)
531 skip_this = .NOT. include_symmetric(iatom, katom)
533 skip_this = .NOT. include_symmetric(iatom, jatom) .OR. .NOT. include_symmetric(jatom, katom)
535 cpabort(
"should not happen")
563 rij, rjk, rik, cell_j, cell_k)
565 INTENT(INOUT) :: iterator
566 INTEGER,
INTENT(OUT),
OPTIONAL :: ikind, jkind, kkind, nkind, iatom, &
568 REAL(kind=
dp),
DIMENSION(3),
INTENT(OUT),
OPTIONAL :: rij, rjk, rik
569 INTEGER,
DIMENSION(3),
INTENT(OUT),
OPTIONAL :: cell_j, cell_k
571 INTEGER,
DIMENSION(2) :: atoms_1, atoms_2, kinds_1, kinds_2
572 INTEGER,
DIMENSION(3) :: cell_1, cell_2
573 REAL(kind=
dp),
DIMENSION(3) :: r_1, r_2
575 cpassert(iterator%iter_level == 1)
578 ikind=kinds_1(1), jkind=kinds_1(2), nkind=nkind, &
579 iatom=atoms_1(1), jatom=atoms_1(2), r=r_1, &
583 ikind=kinds_2(1), jkind=kinds_2(2), &
584 iatom=atoms_2(1), jatom=atoms_2(2), r=r_2, &
587 IF (
PRESENT(ikind)) ikind = kinds_1(1)
588 IF (
PRESENT(jkind)) jkind = kinds_1(2)
589 IF (
PRESENT(kkind)) kkind = kinds_2(2)
590 IF (
PRESENT(iatom)) iatom = atoms_1(1)
591 IF (
PRESENT(jatom)) jatom = atoms_1(2)
592 IF (
PRESENT(katom)) katom = atoms_2(2)
594 IF (
PRESENT(rij)) rij = r_1
595 IF (
PRESENT(rjk)) rjk = r_2
596 IF (
PRESENT(rik)) rik = r_1 + r_2
598 IF (
PRESENT(cell_j)) cell_j = cell_1
599 IF (
PRESENT(cell_k)) cell_k = cell_1 + cell_2
625 SUBROUTINE alloc_block_3c(t3c, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, op_pos, &
626 do_kpoints, do_hfx_kpoints, bounds_i, bounds_j, bounds_k, RI_range, &
627 img_to_RI_cell, cell_to_index, cell_sym)
628 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(INOUT) :: t3c
633 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
634 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
635 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
636 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
637 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
638 INTEGER,
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: cell_to_index
639 LOGICAL,
INTENT(IN),
OPTIONAL :: cell_sym
641 CHARACTER(LEN=*),
PARAMETER :: routinen =
'alloc_block_3c'
643 INTEGER :: handle, iatom, ikind, j_img, jatom, &
644 jcell, jkind, k_img, katom, kcell, &
645 kkind, natom, ncell_ri, nimg, op_ij, &
647 INTEGER(int_8) :: a, b, nblk_per_thread
648 INTEGER(int_8),
ALLOCATABLE,
DIMENSION(:, :) :: nblk
649 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
650 INTEGER,
DIMENSION(3) :: blk_idx, cell_j, cell_k, &
651 kp_index_lbounds, kp_index_ubounds
652 LOGICAL :: cell_sym_prv, do_hfx_kpoints_prv, &
654 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
655 kind_radius_i, kind_radius_j, &
657 REAL(kind=
dp),
DIMENSION(3) :: rij, rik, rjk
663 TYPE(one_dim_int_array),
ALLOCATABLE, &
664 DIMENSION(:, :) :: alloc_i, alloc_j, alloc_k
665 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
667 CALL timeset(routinen, handle)
668 NULLIFY (qs_kind_set, atomic_kind_set, cell)
670 IF (
PRESENT(do_kpoints))
THEN
671 do_kpoints_prv = do_kpoints
673 do_kpoints_prv = .false.
675 IF (
PRESENT(do_hfx_kpoints))
THEN
676 do_hfx_kpoints_prv = do_hfx_kpoints
678 do_hfx_kpoints_prv = .false.
680 IF (do_hfx_kpoints_prv)
THEN
681 cpassert(do_kpoints_prv)
682 cpassert(
PRESENT(ri_range))
683 cpassert(
PRESENT(img_to_ri_cell))
686 IF (
PRESENT(img_to_ri_cell))
THEN
687 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
688 img_to_ri_cell_prv(:) = img_to_ri_cell
691 IF (
PRESENT(cell_sym))
THEN
692 cell_sym_prv = cell_sym
694 cell_sym_prv = .false.
697 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
701 IF (
PRESENT(op_pos))
THEN
707 SELECT CASE (op_pos_prv)
709 op_ij = potential_parameter%potential_type
711 op_jk = potential_parameter%potential_type
730 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, natom=natom, &
731 dft_control=dft_control, para_env=para_env, cell=cell)
733 IF (do_kpoints_prv)
THEN
734 cpassert(
PRESENT(cell_to_index))
735 cpassert(
ASSOCIATED(cell_to_index))
737 nimg = maxval(cell_to_index)
739 IF (do_hfx_kpoints_prv)
THEN
741 ncell_ri =
SIZE(t3c, 2)
748 IF (do_kpoints_prv)
THEN
749 kp_index_lbounds = lbound(cell_to_index)
750 kp_index_ubounds = ubound(cell_to_index)
754 ALLOCATE (nblk(nimg, ncell_ri))
759 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bounds_k)
763 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
769 IF (do_kpoints_prv)
THEN
771 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
772 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
774 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
775 IF (jcell > nimg .OR. jcell < 1) cycle
777 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
778 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
780 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
781 IF (kcell > nimg .OR. kcell < 1) cycle
782 IF (do_hfx_kpoints_prv)
THEN
783 IF (dik > ri_range) cycle
794 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
795 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
796 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
798 nblk(jcell, kcell) = nblk(jcell, kcell) + 1
803 ALLOCATE (alloc_i(nimg, ncell_ri))
804 ALLOCATE (alloc_j(nimg, ncell_ri))
805 ALLOCATE (alloc_k(nimg, ncell_ri))
806 DO k_img = 1, ncell_ri
808 ALLOCATE (alloc_i(j_img, k_img)%array(nblk(j_img, k_img)))
809 ALLOCATE (alloc_j(j_img, k_img)%array(nblk(j_img, k_img)))
810 ALLOCATE (alloc_k(j_img, k_img)%array(nblk(j_img, k_img)))
817 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bounds_k)
821 iatom=iatom, jatom=jatom, katom=katom, &
822 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
828 IF (do_kpoints_prv)
THEN
830 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
831 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
833 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
834 IF (jcell > nimg .OR. jcell < 1) cycle
836 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
837 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
839 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
840 IF (kcell > nimg .OR. kcell < 1) cycle
841 IF (do_hfx_kpoints_prv)
THEN
842 IF (dik > ri_range) cycle
843 kcell = img_to_ri_cell_prv(kcell)
849 blk_idx = [iatom, jatom, katom]
850 IF (do_hfx_kpoints_prv)
THEN
851 blk_idx(3) = (kcell - 1)*natom + katom
859 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
860 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
861 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
863 nblk(jcell, kcell) = nblk(jcell, kcell) + 1
866 alloc_i(jcell, kcell)%array(nblk(jcell, kcell)) = blk_idx(1)
867 alloc_j(jcell, kcell)%array(nblk(jcell, kcell)) = blk_idx(2)
868 alloc_k(jcell, kcell)%array(nblk(jcell, kcell)) = blk_idx(3)
876 DO k_img = 1, ncell_ri
878 IF (cell_sym_prv .AND. j_img < k_img) cycle
879 IF (
ALLOCATED(alloc_i(j_img, k_img)%array))
THEN
880 nblk_per_thread = nblk(j_img, k_img)/omp_get_num_threads() + 1
881 a = omp_get_thread_num()*nblk_per_thread + 1
882 b = min(a + nblk_per_thread, nblk(j_img, k_img))
883 CALL dbt_reserve_blocks(t3c(j_img, k_img), &
884 alloc_i(j_img, k_img)%array(a:b), &
885 alloc_j(j_img, k_img)%array(a:b), &
886 alloc_k(j_img, k_img)%array(a:b))
892 CALL timestop(handle)
921 nl_3c, basis_i, basis_j, basis_k, &
922 potential_parameter, der_eps, &
923 op_pos, do_kpoints, do_hfx_kpoints, &
924 bounds_i, bounds_j, bounds_k, &
925 RI_range, img_to_RI_cell)
927 TYPE(dbt_type),
DIMENSION(:, :, :),
INTENT(INOUT) :: t3c_der_i, t3c_der_k
928 REAL(kind=
dp),
INTENT(IN) :: filter_eps
933 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: der_eps
934 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
935 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
936 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
937 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
938 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
940 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_3c_derivatives'
942 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
943 block_start_k, egfi, handle, handle2, i, i_img, i_xyz, iatom, ibasis, ikind, ilist,
imax, &
944 iset, j_img, jatom, jcell, jkind, jset, katom, kcell, kkind, kset, m_max, max_ncoj, &
945 max_nset, max_nsgfi, maxli, maxlj, maxlk, mepos, natom, nbasis, ncell_ri, ncoi, ncoj, &
946 ncok, nimg, nseti, nsetj, nsetk, nthread, op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk, &
948 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
949 INTEGER,
DIMENSION(2) :: bo
950 INTEGER,
DIMENSION(3) :: blk_idx, blk_size, cell_j, cell_k, &
951 kp_index_lbounds, kp_index_ubounds,
sp
952 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
953 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
955 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
956 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
957 LOGICAL :: do_hfx_kpoints_prv, do_kpoints_prv, &
959 LOGICAL,
DIMENSION(3) :: block_j_not_zero, block_k_not_zero, &
960 der_j_zero, der_k_zero
961 REAL(
dp),
DIMENSION(3) :: der_ext_i, der_ext_j, der_ext_k
962 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
963 kind_radius_i, kind_radius_j, &
964 kind_radius_k, prefac
965 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
966 max_contraction_i, max_contraction_j, &
968 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dijk_contr, dummy_block_t
969 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: block_t_i, block_t_j, block_t_k, dijk_j, &
970 dijk_k, tmp_ijk_i, tmp_ijk_j
971 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk
972 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
973 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
974 sphi_k, zeti, zetj, zetk
978 TYPE(dbt_type) :: t3c_tmp
979 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t3c_template
980 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: t3c_der_j
986 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
988 CALL timeset(routinen, handle)
990 IF (
PRESENT(do_kpoints))
THEN
991 do_kpoints_prv = do_kpoints
993 do_kpoints_prv = .false.
996 IF (
PRESENT(do_hfx_kpoints))
THEN
997 do_hfx_kpoints_prv = do_hfx_kpoints
999 do_hfx_kpoints_prv = .false.
1001 IF (do_hfx_kpoints_prv)
THEN
1002 cpassert(do_kpoints_prv)
1003 cpassert(
PRESENT(ri_range))
1004 cpassert(
PRESENT(img_to_ri_cell))
1007 IF (
PRESENT(img_to_ri_cell))
THEN
1008 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
1009 img_to_ri_cell_prv(:) = img_to_ri_cell
1014 IF (
PRESENT(op_pos))
THEN
1020 SELECT CASE (op_pos_prv)
1022 op_ij = potential_parameter%potential_type
1024 op_jk = potential_parameter%potential_type
1027 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
1033 dr_ij = 1000000.0_dp
1034 dr_ik = 1000000.0_dp
1041 dr_jk = 1000000.0_dp
1042 dr_ik = 1000000.0_dp
1045 NULLIFY (qs_kind_set, atomic_kind_set)
1048 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
1049 natom=natom, kpoints=kpoints, dft_control=dft_control, para_env=para_env)
1051 IF (do_kpoints_prv)
THEN
1052 nimg = dft_control%nimages
1054 IF (do_hfx_kpoints_prv)
THEN
1055 nimg =
SIZE(t3c_der_k, 1)
1056 ncell_ri =
SIZE(t3c_der_k, 2)
1064 IF (do_hfx_kpoints_prv)
THEN
1065 cpassert(op_pos_prv == 2)
1067 cpassert(all(shape(t3c_der_k) == [nimg, ncell_ri, 3]))
1070 ALLOCATE (t3c_template(nimg, ncell_ri))
1071 DO j_img = 1, ncell_ri
1073 CALL dbt_create(t3c_der_i(i_img, j_img, 1), t3c_template(i_img, j_img))
1077 CALL alloc_block_3c(t3c_template, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, &
1078 op_pos=op_pos_prv, do_kpoints=do_kpoints, do_hfx_kpoints=do_hfx_kpoints, &
1079 bounds_i=bounds_i, bounds_j=bounds_j, bounds_k=bounds_k, &
1080 ri_range=ri_range, img_to_ri_cell=img_to_ri_cell, cell_to_index=cell_to_index)
1082 DO j_img = 1, ncell_ri
1084 CALL dbt_copy(t3c_template(i_img, j_img), t3c_der_i(i_img, j_img, i_xyz))
1085 CALL dbt_copy(t3c_template(i_img, j_img), t3c_der_k(i_img, j_img, i_xyz))
1090 DO j_img = 1, ncell_ri
1092 CALL dbt_destroy(t3c_template(i_img, j_img))
1095 DEALLOCATE (t3c_template)
1098 ALLOCATE (t3c_der_j(nimg, ncell_ri, 3))
1100 DO j_img = 1, ncell_ri
1102 CALL dbt_create(t3c_der_k(i_img, j_img, i_xyz), t3c_der_j(i_img, j_img, i_xyz))
1103 CALL dbt_copy(t3c_der_k(i_img, j_img, i_xyz), t3c_der_j(i_img, j_img, i_xyz))
1110 nbasis =
SIZE(basis_i)
1114 DO ibasis = 1, nbasis
1116 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
1117 maxli = max(maxli,
imax)
1118 max_nset = max(max_nset, iset)
1119 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
1123 DO ibasis = 1, nbasis
1125 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
1126 maxlj = max(maxlj,
imax)
1127 max_nset = max(max_nset, jset)
1128 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
1131 DO ibasis = 1, nbasis
1133 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
1134 maxlk = max(maxlk,
imax)
1135 max_nset = max(max_nset, kset)
1137 m_max = maxli + maxlj + maxlk + 1
1142 NULLIFY (tspj, spi, spk)
1143 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
1145 DO ibasis = 1, nbasis
1146 DO iset = 1, max_nset
1147 NULLIFY (spi(iset, ibasis)%array)
1148 NULLIFY (tspj(iset, ibasis)%array)
1149 NULLIFY (spk(iset, ibasis)%array)
1154 DO ibasis = 1, nbasis
1155 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
1156 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
1157 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
1159 DO iset = 1, basis_set%nset
1161 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
1162 sgfi = basis_set%first_sgf(1, iset)
1163 egfi = sgfi + basis_set%nsgf_set(iset) - 1
1165 IF (ilist == 1)
THEN
1166 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1167 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1169 ELSE IF (ilist == 2)
THEN
1170 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
1171 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
1174 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1175 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1186 IF (para_env%mepos == 0)
THEN
1187 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
1189 CALL init(m_max, unit_id, para_env%mepos, para_env)
1190 IF (para_env%mepos == 0)
THEN
1198 IF (do_kpoints_prv)
THEN
1199 kp_index_lbounds = lbound(cell_to_index)
1200 kp_index_ubounds = ubound(cell_to_index)
1230 IF (
PRESENT(bounds_i))
THEN
1231 bo =
get_limit(bounds_i(2) - bounds_i(1) + 1, nthread, mepos)
1232 bo(:) = bo(:) + bounds_i(1) - 1
1233 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
1234 ELSE IF (
PRESENT(bounds_j))
THEN
1235 bo =
get_limit(bounds_j(2) - bounds_j(1) + 1, nthread, mepos)
1236 bo(:) = bo(:) + bounds_j(1) - 1
1237 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bo, bounds_k)
1238 ELSE IF (
PRESENT(bounds_k))
THEN
1239 bo =
get_limit(bounds_k(2) - bounds_k(1) + 1, nthread, mepos)
1240 bo(:) = bo(:) + bounds_k(1) - 1
1241 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bo)
1244 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
1248 IF (bo(1) > bo(2)) skip = .true.
1252 iatom=iatom, jatom=jatom, katom=katom, &
1253 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
1260 IF (do_kpoints_prv)
THEN
1263 IF (jatom == katom)
THEN
1271 IF (do_hfx_kpoints_prv) prefac = 1.0_dp
1273 IF (do_kpoints_prv)
THEN
1275 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
1276 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
1278 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
1279 IF (jcell > nimg .OR. jcell < 1) cycle
1281 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
1282 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
1284 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
1285 IF (kcell > nimg .OR. kcell < 1) cycle
1287 IF (do_hfx_kpoints_prv)
THEN
1288 IF (dik > ri_range) cycle
1289 kcell = img_to_ri_cell_prv(kcell)
1292 jcell = 1; kcell = 1
1295 blk_idx = [iatom, jatom, katom]
1296 IF (do_hfx_kpoints_prv)
THEN
1297 blk_idx(3) = (kcell - 1)*natom + katom
1301 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
1302 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
1303 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
1305 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
1306 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
1307 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
1309 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
1310 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
1311 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
1313 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
1314 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
1315 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
1317 ALLOCATE (max_contraction_i(nseti))
1318 max_contraction_i = 0.0_dp
1320 sgfi = first_sgf_i(1, iset)
1321 max_contraction_i(iset) = maxval((/(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)/))
1324 ALLOCATE (max_contraction_j(nsetj))
1325 max_contraction_j = 0.0_dp
1327 sgfj = first_sgf_j(1, jset)
1328 max_contraction_j(jset) = maxval((/(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)/))
1331 ALLOCATE (max_contraction_k(nsetk))
1332 max_contraction_k = 0.0_dp
1334 sgfk = first_sgf_k(1, kset)
1335 max_contraction_k(kset) = maxval((/(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)/))
1338 CALL dbt_blk_sizes(t3c_der_i(jcell, kcell, 1), blk_idx, blk_size)
1340 ALLOCATE (block_t_i(blk_size(2), blk_size(3), blk_size(1), 3))
1341 ALLOCATE (block_t_j(blk_size(2), blk_size(3), blk_size(1), 3))
1342 ALLOCATE (block_t_k(blk_size(2), blk_size(3), blk_size(1), 3))
1347 block_j_not_zero = .false.
1348 block_k_not_zero = .false.
1354 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
1358 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
1359 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
1361 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
1362 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
1363 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
1365 sgfi = first_sgf_i(1, iset)
1366 sgfj = first_sgf_j(1, jset)
1367 sgfk = first_sgf_k(1, kset)
1369 IF (ncoj*ncok*ncoi > 0)
THEN
1370 ALLOCATE (dijk_j(ncoj, ncok, ncoi, 3))
1371 ALLOCATE (dijk_k(ncoj, ncok, ncoi, 3))
1372 dijk_j(:, :, :, :) = 0.0_dp
1373 dijk_k(:, :, :, :) = 0.0_dp
1375 der_j_zero = .false.
1376 der_k_zero = .false.
1383 IF (op_pos_prv == 1)
THEN
1385 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1386 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1387 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1388 djk, dij, dik, lib, potential_parameter, &
1389 der_abc_1_ext=der_ext_j, der_abc_2_ext=der_ext_k)
1391 ALLOCATE (tmp_ijk_i(ncoi, ncoj, ncok, 3))
1392 ALLOCATE (tmp_ijk_j(ncoi, ncoj, ncok, 3))
1393 tmp_ijk_i(:, :, :, :) = 0.0_dp
1394 tmp_ijk_j(:, :, :, :) = 0.0_dp
1397 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1398 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1399 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1400 dij, dik, djk, lib, potential_parameter, &
1401 der_abc_1_ext=der_ext_i, der_abc_2_ext=der_ext_j)
1407 dijk_j(:, :, i, i_xyz) = tmp_ijk_j(i, :, :, i_xyz)
1408 dijk_k(:, :, i, i_xyz) = -(dijk_j(:, :, i, i_xyz) + tmp_ijk_i(i, :, :, i_xyz))
1409 der_ext_k(i_xyz) = max(der_ext_k(i_xyz), maxval(abs(dijk_k(:, :, i, i_xyz))))
1412 DEALLOCATE (tmp_ijk_i, tmp_ijk_j)
1416 IF (
PRESENT(der_eps))
THEN
1418 IF (der_eps > der_ext_j(i_xyz)*(max_contraction_i(iset)* &
1419 max_contraction_j(jset)* &
1420 max_contraction_k(kset)))
THEN
1421 der_j_zero(i_xyz) = .true.
1426 IF (der_eps > der_ext_k(i_xyz)*(max_contraction_i(iset)* &
1427 max_contraction_j(jset)* &
1428 max_contraction_k(kset)))
THEN
1429 der_k_zero(i_xyz) = .true.
1432 IF (all(der_j_zero) .AND. all(der_k_zero))
THEN
1433 DEALLOCATE (dijk_j, dijk_k)
1438 ALLOCATE (dijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
1440 block_start_j = sgfj
1441 block_end_j = sgfj + nsgfj(jset) - 1
1442 block_start_k = sgfk
1443 block_end_k = sgfk + nsgfk(kset) - 1
1444 block_start_i = sgfi
1445 block_end_i = sgfi + nsgfi(iset) - 1
1448 IF (der_j_zero(i_xyz)) cycle
1450 block_j_not_zero(i_xyz) = .true.
1451 CALL abc_contract_xsmm(dijk_contr, dijk_j(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1452 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1453 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1454 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
1456 block_t_j(block_start_j:block_end_j, &
1457 block_start_k:block_end_k, &
1458 block_start_i:block_end_i, i_xyz) = &
1459 block_t_j(block_start_j:block_end_j, &
1460 block_start_k:block_end_k, &
1461 block_start_i:block_end_i, i_xyz) + &
1467 IF (der_k_zero(i_xyz)) cycle
1469 block_k_not_zero(i_xyz) = .true.
1470 CALL abc_contract_xsmm(dijk_contr, dijk_k(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1471 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1472 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1473 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
1475 block_t_k(block_start_j:block_end_j, &
1476 block_start_k:block_end_k, &
1477 block_start_i:block_end_i, i_xyz) = &
1478 block_t_k(block_start_j:block_end_j, &
1479 block_start_k:block_end_k, &
1480 block_start_i:block_end_i, i_xyz) + &
1485 DEALLOCATE (dijk_j, dijk_k, dijk_contr)
1491 CALL timeset(routinen//
"_put_dbcsr", handle2)
1493 sp = shape(block_t_i(:, :, :, 1))
1498 IF ((.NOT. block_j_not_zero(i_xyz)) .AND. (.NOT. block_k_not_zero(i_xyz))) cycle
1499 block_t_i(:, :, :, i_xyz) = -(block_t_j(:, :, :, i_xyz) + block_t_k(:, :, :, i_xyz))
1501 CALL dbt_put_block(t3c_der_i(jcell, kcell, i_xyz), blk_idx,
sp, &
1502 reshape(block_t_i(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1506 sp = shape(block_t_k(:, :, :, 1))
1510 IF (.NOT. block_k_not_zero(i_xyz)) cycle
1511 CALL dbt_put_block(t3c_der_k(jcell, kcell, i_xyz), blk_idx,
sp, &
1512 reshape(block_t_k(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1518 sp = shape(block_t_j(:, :, :, 1))
1522 IF (.NOT. block_j_not_zero(i_xyz)) cycle
1523 CALL dbt_put_block(t3c_der_j(jcell, kcell, i_xyz), blk_idx,
sp, &
1524 reshape(block_t_j(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1530 CALL timestop(handle2)
1532 DEALLOCATE (block_t_i, block_t_j, block_t_k)
1533 DEALLOCATE (max_contraction_i, max_contraction_j, max_contraction_k)
1536 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
1537 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
1543 IF (do_kpoints_prv .AND. .NOT. do_hfx_kpoints_prv)
THEN
1548 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps/2)
1549 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps/2)
1556 CALL dbt_create(t3c_der_k(1, 1, 1), t3c_tmp)
1560 CALL dbt_copy(t3c_der_j(jcell, kcell, i_xyz), t3c_der_k(jcell, kcell, i_xyz), &
1561 order=[1, 3, 2], move_data=.true., summation=.true.)
1562 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps)
1564 CALL dbt_copy(t3c_der_i(jcell, kcell, i_xyz), t3c_tmp)
1565 CALL dbt_copy(t3c_tmp, t3c_der_i(jcell, kcell, i_xyz), &
1566 order=[1, 3, 2], move_data=.true., summation=.true.)
1567 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps)
1571 CALL dbt_destroy(t3c_tmp)
1575 DO kcell = 1, ncell_ri
1577 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps)
1578 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps)
1583 cpabort(
"requested symmetric case not implemented")
1590 CALL dbt_destroy(t3c_der_j(i_img, j_img, i_xyz))
1596 DO iset = 1, max_nset
1597 DO ibasis = 1, nbasis
1598 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
1599 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
1600 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
1604 DEALLOCATE (spi, tspj, spk)
1606 CALL timestop(handle)
1627 nl_3c, basis_i, basis_j, basis_k, &
1628 potential_parameter, der_eps, op_pos)
1630 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: work_virial
1631 TYPE(dbt_type),
INTENT(INOUT) :: t3c_trace
1632 REAL(kind=
dp),
INTENT(IN) :: pref
1637 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: der_eps
1638 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
1640 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_3c_virial'
1642 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
1643 block_start_k, egfi, handle, i, i_xyz, iatom, ibasis, ikind, ilist,
imax, iset, j_xyz, &
1644 jatom, jkind, jset, katom, kkind, kset, m_max, max_ncoj, max_nset, max_nsgfi, maxli, &
1645 maxlj, maxlk, mepos, natom, nbasis, ncoi, ncoj, ncok, nseti, nsetj, nsetk, nthread, &
1646 op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk, unit_id
1647 INTEGER,
DIMENSION(2) :: bo
1648 INTEGER,
DIMENSION(3) :: blk_size,
sp
1649 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
1650 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
1652 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
1653 LOGICAL :: found, skip
1654 LOGICAL,
DIMENSION(3) :: block_j_not_zero, block_k_not_zero, &
1655 der_j_zero, der_k_zero
1657 REAL(
dp),
DIMENSION(3) :: der_ext_i, der_ext_j, der_ext_k
1658 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
1659 kind_radius_i, kind_radius_j, &
1661 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
1662 max_contraction_i, max_contraction_j, &
1664 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ablock, dijk_contr, tmp_block
1665 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: block_t_i, block_t_j, block_t_k, dijk_j, &
1667 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk, scoord
1668 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
1669 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
1670 sphi_k, zeti, zetj, zetk
1680 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1682 CALL timeset(routinen, handle)
1686 IF (
PRESENT(op_pos))
THEN
1691 cpassert(op_pos == 1)
1694 SELECT CASE (op_pos_prv)
1696 op_ij = potential_parameter%potential_type
1698 op_jk = potential_parameter%potential_type
1701 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
1707 dr_ij = 1000000.0_dp
1708 dr_ik = 1000000.0_dp
1715 dr_jk = 1000000.0_dp
1716 dr_ik = 1000000.0_dp
1719 NULLIFY (qs_kind_set, atomic_kind_set)
1722 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
1723 natom=natom, dft_control=dft_control, para_env=para_env, &
1724 particle_set=particle_set, cell=cell)
1727 nbasis =
SIZE(basis_i)
1731 DO ibasis = 1, nbasis
1733 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
1734 maxli = max(maxli,
imax)
1735 max_nset = max(max_nset, iset)
1736 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
1740 DO ibasis = 1, nbasis
1742 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
1743 maxlj = max(maxlj,
imax)
1744 max_nset = max(max_nset, jset)
1745 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
1748 DO ibasis = 1, nbasis
1750 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
1751 maxlk = max(maxlk,
imax)
1752 max_nset = max(max_nset, kset)
1754 m_max = maxli + maxlj + maxlk + 1
1759 NULLIFY (tspj, spi, spk)
1760 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
1762 DO ibasis = 1, nbasis
1763 DO iset = 1, max_nset
1764 NULLIFY (spi(iset, ibasis)%array)
1765 NULLIFY (tspj(iset, ibasis)%array)
1767 NULLIFY (spk(iset, ibasis)%array)
1772 DO ibasis = 1, nbasis
1773 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
1774 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
1775 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
1777 DO iset = 1, basis_set%nset
1779 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
1780 sgfi = basis_set%first_sgf(1, iset)
1781 egfi = sgfi + basis_set%nsgf_set(iset) - 1
1783 IF (ilist == 1)
THEN
1784 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1785 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1787 ELSE IF (ilist == 2)
THEN
1788 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
1789 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
1792 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1793 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1804 IF (para_env%mepos == 0)
THEN
1805 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
1807 CALL init(m_max, unit_id, para_env%mepos, para_env)
1808 IF (para_env%mepos == 0)
THEN
1842 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i=bo)
1845 IF (bo(1) > bo(2)) skip = .true.
1849 iatom=iatom, jatom=jatom, katom=katom, &
1850 rij=rij, rjk=rjk, rik=rik)
1853 CALL dbt_get_block(t3c_trace, [iatom, jatom, katom], tmp_block, found)
1854 IF (.NOT. found) cycle
1856 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
1857 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
1858 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
1860 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
1861 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
1862 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
1864 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
1865 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
1866 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
1872 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
1873 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
1874 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
1876 ALLOCATE (max_contraction_i(nseti))
1877 max_contraction_i = 0.0_dp
1879 sgfi = first_sgf_i(1, iset)
1880 max_contraction_i(iset) = maxval((/(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)/))
1883 ALLOCATE (max_contraction_j(nsetj))
1884 max_contraction_j = 0.0_dp
1886 sgfj = first_sgf_j(1, jset)
1887 max_contraction_j(jset) = maxval((/(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)/))
1890 ALLOCATE (max_contraction_k(nsetk))
1891 max_contraction_k = 0.0_dp
1893 sgfk = first_sgf_k(1, kset)
1894 max_contraction_k(kset) = maxval((/(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)/))
1897 CALL dbt_blk_sizes(t3c_trace, [iatom, jatom, katom], blk_size)
1899 ALLOCATE (block_t_i(blk_size(2), blk_size(3), blk_size(1), 3))
1900 ALLOCATE (block_t_j(blk_size(2), blk_size(3), blk_size(1), 3))
1901 ALLOCATE (block_t_k(blk_size(2), blk_size(3), blk_size(1), 3))
1903 ALLOCATE (ablock(blk_size(2), blk_size(3), blk_size(1)))
1904 DO i = 1, blk_size(1)
1905 ablock(:, :, i) = tmp_block(i, :, :)
1907 DEALLOCATE (tmp_block)
1912 block_j_not_zero = .false.
1913 block_k_not_zero = .false.
1919 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
1923 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
1924 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
1926 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
1927 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
1928 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
1930 sgfi = first_sgf_i(1, iset)
1931 sgfj = first_sgf_j(1, jset)
1932 sgfk = first_sgf_k(1, kset)
1934 IF (ncoj*ncok*ncoi > 0)
THEN
1935 ALLOCATE (dijk_j(ncoj, ncok, ncoi, 3))
1936 ALLOCATE (dijk_k(ncoj, ncok, ncoi, 3))
1937 dijk_j(:, :, :, :) = 0.0_dp
1938 dijk_k(:, :, :, :) = 0.0_dp
1940 der_j_zero = .false.
1941 der_k_zero = .false.
1949 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1950 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1951 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1952 djk, dij, dik, lib, potential_parameter, &
1953 der_abc_1_ext=der_ext_j, der_abc_2_ext=der_ext_k)
1955 IF (
PRESENT(der_eps))
THEN
1957 IF (der_eps > der_ext_j(i_xyz)*(max_contraction_i(iset)* &
1958 max_contraction_j(jset)* &
1959 max_contraction_k(kset)))
THEN
1960 der_j_zero(i_xyz) = .true.
1965 IF (der_eps > der_ext_k(i_xyz)*(max_contraction_i(iset)* &
1966 max_contraction_j(jset)* &
1967 max_contraction_k(kset)))
THEN
1968 der_k_zero(i_xyz) = .true.
1971 IF (all(der_j_zero) .AND. all(der_k_zero))
THEN
1972 DEALLOCATE (dijk_j, dijk_k)
1977 ALLOCATE (dijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
1979 block_start_j = sgfj
1980 block_end_j = sgfj + nsgfj(jset) - 1
1981 block_start_k = sgfk
1982 block_end_k = sgfk + nsgfk(kset) - 1
1983 block_start_i = sgfi
1984 block_end_i = sgfi + nsgfi(iset) - 1
1987 IF (der_j_zero(i_xyz)) cycle
1989 block_j_not_zero(i_xyz) = .true.
1990 CALL abc_contract_xsmm(dijk_contr, dijk_j(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1991 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1992 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1993 nsgfi(iset), cpp_buffer, ccp_buffer)
1995 block_t_j(block_start_j:block_end_j, &
1996 block_start_k:block_end_k, &
1997 block_start_i:block_end_i, i_xyz) = &
1998 block_t_j(block_start_j:block_end_j, &
1999 block_start_k:block_end_k, &
2000 block_start_i:block_end_i, i_xyz) + &
2006 IF (der_k_zero(i_xyz)) cycle
2008 block_k_not_zero(i_xyz) = .true.
2009 CALL abc_contract_xsmm(dijk_contr, dijk_k(:, :, :, i_xyz), tspj(jset, jkind)%array, &
2010 spk(kset, kkind)%array, spi(iset, ikind)%array, &
2011 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
2012 nsgfi(iset), cpp_buffer, ccp_buffer)
2014 block_t_k(block_start_j:block_end_j, &
2015 block_start_k:block_end_k, &
2016 block_start_i:block_end_i, i_xyz) = &
2017 block_t_k(block_start_j:block_end_j, &
2018 block_start_k:block_end_k, &
2019 block_start_i:block_end_i, i_xyz) + &
2024 DEALLOCATE (dijk_j, dijk_k, dijk_contr)
2032 block_t_i(:, :, :, i_xyz) = -block_t_j(:, :, :, i_xyz) - block_t_k(:, :, :, i_xyz)
2037 force = pref*sum(ablock(:, :, :)*block_t_i(:, :, :, i_xyz))
2041 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2047 force = pref*sum(ablock(:, :, :)*block_t_j(:, :, :, i_xyz))
2051 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2057 force = pref*sum(ablock(:, :, :)*block_t_k(:, :, :, i_xyz))
2061 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2065 DEALLOCATE (block_t_i, block_t_j, block_t_k)
2066 DEALLOCATE (max_contraction_i, max_contraction_j, max_contraction_k, ablock)
2069 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
2070 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
2076 DO iset = 1, max_nset
2077 DO ibasis = 1, nbasis
2078 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
2079 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
2080 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
2084 DEALLOCATE (spi, tspj, spk)
2086 CALL timestop(handle)
2118 nl_3c, basis_i, basis_j, basis_k, &
2119 potential_parameter, int_eps, &
2120 op_pos, do_kpoints, do_hfx_kpoints, desymmetrize, cell_sym, &
2121 bounds_i, bounds_j, bounds_k, &
2122 RI_range, img_to_RI_cell, cell_to_index_ext)
2124 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(INOUT) :: t3c
2125 REAL(kind=
dp),
INTENT(IN) :: filter_eps
2130 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: int_eps
2131 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
2132 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints, &
2133 desymmetrize, cell_sym
2134 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
2135 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
2136 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
2137 INTEGER,
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: cell_to_index_ext
2139 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_3c_integrals'
2141 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
2142 block_start_k, egfi, handle, handle2, i, iatom, ibasis, ikind, ilist,
imax, iset, jatom, &
2143 jcell, jkind, jset, katom, kcell, kkind, kset, m_max, max_ncoj, max_nset, max_nsgfi, &
2144 maxli, maxlj, maxlk, mepos, natom, nbasis, ncell_ri, ncoi, ncoj, ncok, nimg, nseti, &
2145 nsetj, nsetk, nthread, op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk, unit_id
2146 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
2147 INTEGER,
DIMENSION(2) :: bo
2148 INTEGER,
DIMENSION(3) :: blk_idx, blk_size, cell_j, cell_k, &
2149 kp_index_lbounds, kp_index_ubounds,
sp
2150 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
2151 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
2153 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
2154 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2155 LOGICAL :: block_not_zero, cell_sym_prv, debug, &
2156 desymmetrize_prv, do_hfx_kpoints_prv, &
2157 do_kpoints_prv, found, skip
2158 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
2159 kind_radius_i, kind_radius_j, &
2160 kind_radius_k, max_contraction_i, &
2162 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
2163 max_contraction_j, max_contraction_k
2164 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: block_t, dummy_block_t, sijk, &
2166 REAL(kind=
dp),
DIMENSION(1, 1, 1) :: counter
2167 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk
2168 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
2169 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
2170 sphi_k, zeti, zetj, zetk
2175 TYPE(dbt_type) :: t_3c_tmp
2181 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2183 CALL timeset(routinen, handle)
2187 IF (
PRESENT(do_kpoints))
THEN
2188 do_kpoints_prv = do_kpoints
2190 do_kpoints_prv = .false.
2193 IF (
PRESENT(do_hfx_kpoints))
THEN
2194 do_hfx_kpoints_prv = do_hfx_kpoints
2196 do_hfx_kpoints_prv = .false.
2198 IF (do_hfx_kpoints_prv)
THEN
2199 cpassert(do_kpoints_prv)
2200 cpassert(
PRESENT(ri_range))
2201 cpassert(
PRESENT(img_to_ri_cell))
2204 IF (
PRESENT(img_to_ri_cell))
THEN
2205 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
2206 img_to_ri_cell_prv(:) = img_to_ri_cell
2209 IF (
PRESENT(desymmetrize))
THEN
2210 desymmetrize_prv = desymmetrize
2212 desymmetrize_prv = .true.
2215 IF (
PRESENT(cell_sym))
THEN
2216 cell_sym_prv = cell_sym
2218 cell_sym_prv = .false.
2223 IF (
PRESENT(op_pos))
THEN
2229 SELECT CASE (op_pos_prv)
2231 op_ij = potential_parameter%potential_type
2233 op_jk = potential_parameter%potential_type
2236 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
2242 dr_ij = 1000000.0_dp
2243 dr_ik = 1000000.0_dp
2250 dr_jk = 1000000.0_dp
2251 dr_ik = 1000000.0_dp
2254 NULLIFY (qs_kind_set, atomic_kind_set)
2257 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, cell=cell, &
2258 natom=natom, dft_control=dft_control, para_env=para_env)
2260 IF (do_kpoints_prv)
THEN
2261 IF (
PRESENT(cell_to_index_ext))
THEN
2262 cell_to_index => cell_to_index_ext
2263 nimg = maxval(cell_to_index)
2267 nimg = dft_control%nimages
2270 IF (do_hfx_kpoints_prv)
THEN
2272 ncell_ri =
SIZE(t3c, 2)
2279 CALL alloc_block_3c(t3c, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, &
2280 op_pos=op_pos_prv, do_kpoints=do_kpoints, do_hfx_kpoints=do_hfx_kpoints, &
2281 bounds_i=bounds_i, bounds_j=bounds_j, bounds_k=bounds_k, &
2282 ri_range=ri_range, img_to_ri_cell=img_to_ri_cell, cell_sym=cell_sym_prv, &
2283 cell_to_index=cell_to_index)
2285 IF (do_hfx_kpoints_prv)
THEN
2286 cpassert(op_pos_prv == 2)
2287 cpassert(.NOT. desymmetrize_prv)
2288 ELSE IF (do_kpoints_prv)
THEN
2289 cpassert(all(shape(t3c) == [nimg, ncell_ri]))
2293 nbasis =
SIZE(basis_i)
2297 DO ibasis = 1, nbasis
2299 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
2300 maxli = max(maxli,
imax)
2301 max_nset = max(max_nset, iset)
2302 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
2306 DO ibasis = 1, nbasis
2308 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
2309 maxlj = max(maxlj,
imax)
2310 max_nset = max(max_nset, jset)
2311 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
2314 DO ibasis = 1, nbasis
2316 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
2317 maxlk = max(maxlk,
imax)
2318 max_nset = max(max_nset, kset)
2320 m_max = maxli + maxlj + maxlk
2325 NULLIFY (tspj, spi, spk)
2326 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
2328 DO ibasis = 1, nbasis
2329 DO iset = 1, max_nset
2330 NULLIFY (spi(iset, ibasis)%array)
2331 NULLIFY (tspj(iset, ibasis)%array)
2333 NULLIFY (spk(iset, ibasis)%array)
2338 DO ibasis = 1, nbasis
2339 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
2340 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
2341 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
2343 DO iset = 1, basis_set%nset
2345 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
2346 sgfi = basis_set%first_sgf(1, iset)
2347 egfi = sgfi + basis_set%nsgf_set(iset) - 1
2349 IF (ilist == 1)
THEN
2350 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
2351 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
2353 ELSE IF (ilist == 2)
THEN
2354 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
2355 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
2358 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
2359 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
2370 IF (para_env%mepos == 0)
THEN
2371 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
2373 CALL init(m_max, unit_id, para_env%mepos, para_env)
2374 IF (para_env%mepos == 0)
THEN
2382 IF (do_kpoints_prv)
THEN
2383 kp_index_lbounds = lbound(cell_to_index)
2384 kp_index_ubounds = ubound(cell_to_index)
2416 IF (
PRESENT(bounds_i))
THEN
2417 bo =
get_limit(bounds_i(2) - bounds_i(1) + 1, nthread, mepos)
2418 bo(:) = bo(:) + bounds_i(1) - 1
2419 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
2420 ELSE IF (
PRESENT(bounds_j))
THEN
2422 bo =
get_limit(bounds_j(2) - bounds_j(1) + 1, nthread, mepos)
2423 bo(:) = bo(:) + bounds_j(1) - 1
2424 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bo, bounds_k)
2425 ELSE IF (
PRESENT(bounds_k))
THEN
2426 bo =
get_limit(bounds_k(2) - bounds_k(1) + 1, nthread, mepos)
2427 bo(:) = bo(:) + bounds_k(1) - 1
2428 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bo)
2431 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
2435 IF (bo(1) > bo(2)) skip = .true.
2439 iatom=iatom, jatom=jatom, katom=katom, &
2440 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
2448 IF (jatom == katom)
THEN
2456 IF (iatom == jatom)
THEN
2466 IF (do_kpoints_prv) prefac = 1.0_dp
2468 IF (do_kpoints_prv)
THEN
2470 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
2471 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
2473 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
2474 IF (jcell > nimg .OR. jcell < 1) cycle
2476 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
2477 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
2479 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
2480 IF (kcell > nimg .OR. kcell < 1) cycle
2482 IF (do_hfx_kpoints_prv)
THEN
2483 IF (dik > ri_range) cycle
2484 kcell = img_to_ri_cell_prv(kcell)
2487 jcell = 1; kcell = 1
2490 IF (cell_sym_prv .AND. jcell < kcell) cycle
2492 blk_idx = [iatom, jatom, katom]
2493 IF (do_hfx_kpoints_prv)
THEN
2494 blk_idx(3) = (kcell - 1)*natom + katom
2498 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
2499 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
2500 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
2502 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
2503 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
2504 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
2506 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
2507 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
2508 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
2510 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
2511 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
2512 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
2514 ALLOCATE (max_contraction_j(nsetj))
2516 sgfj = first_sgf_j(1, jset)
2517 max_contraction_j(jset) = maxval((/(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)/))
2520 ALLOCATE (max_contraction_k(nsetk))
2522 sgfk = first_sgf_k(1, kset)
2523 max_contraction_k(kset) = maxval((/(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)/))
2526 CALL dbt_blk_sizes(t3c(jcell, kcell), blk_idx, blk_size)
2528 ALLOCATE (block_t(blk_size(2), blk_size(3), blk_size(1)))
2531 block_not_zero = .false.
2534 sgfi = first_sgf_i(1, iset)
2535 max_contraction_i = maxval((/(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)/))
2539 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
2543 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
2544 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
2546 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
2547 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
2548 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
2551 IF (ncoj*ncok*ncoi == 0) cycle
2558 ALLOCATE (sijk(ncoj, ncok, ncoi))
2559 IF (op_pos_prv == 1)
THEN
2560 sijk(:, :, :) = 0.0_dp
2562 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
2563 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
2564 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
2565 djk, dij, dik, lib, potential_parameter, int_abc_ext=sijk_ext)
2567 ALLOCATE (tmp_ijk(ncoi, ncoj, ncok))
2568 tmp_ijk(:, :, :) = 0.0_dp
2570 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
2571 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
2572 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
2573 dij, dik, djk, lib, potential_parameter, int_abc_ext=sijk_ext)
2577 sijk(:, :, i) = tmp_ijk(i, :, :)
2579 DEALLOCATE (tmp_ijk)
2582 IF (
PRESENT(int_eps))
THEN
2583 IF (int_eps > sijk_ext*(max_contraction_i* &
2584 max_contraction_j(jset)* &
2585 max_contraction_k(kset)))
THEN
2591 block_not_zero = .true.
2592 ALLOCATE (sijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
2594 spk(kset, kkind)%array, spi(iset, ikind)%array, &
2595 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
2596 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
2599 sgfj = first_sgf_j(1, jset)
2600 sgfk = first_sgf_k(1, kset)
2602 block_start_j = sgfj
2603 block_end_j = sgfj + nsgfj(jset) - 1
2604 block_start_k = sgfk
2605 block_end_k = sgfk + nsgfk(kset) - 1
2606 block_start_i = sgfi
2607 block_end_i = sgfi + nsgfi(iset) - 1
2609 block_t(block_start_j:block_end_j, &
2610 block_start_k:block_end_k, &
2611 block_start_i:block_end_i) = &
2612 block_t(block_start_j:block_end_j, &
2613 block_start_k:block_end_k, &
2614 block_start_i:block_end_i) + &
2616 DEALLOCATE (sijk_contr)
2624 IF (block_not_zero)
THEN
2626 CALL timeset(routinen//
"_put_dbcsr", handle2)
2628 CALL dbt_get_block(t3c(jcell, kcell), blk_idx, dummy_block_t, found=found)
2635 CALL dbt_put_block(t3c(jcell, kcell), blk_idx,
sp, &
2636 reshape(block_t, shape=
sp, order=[2, 3, 1]), summation=.true.)
2638 CALL timestop(handle2)
2642 DEALLOCATE (block_t)
2643 DEALLOCATE (max_contraction_j, max_contraction_k)
2646 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
2647 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
2654 IF (nl_3c%sym ==
symmetric_jk .OR. do_kpoints_prv)
THEN
2656 IF (.NOT. do_hfx_kpoints_prv)
THEN
2660 CALL dbt_filter(t3c(jcell, kcell), filter_eps/2)
2664 DO kcell = 1, ncell_ri
2666 CALL dbt_filter(t3c(jcell, kcell), filter_eps)
2671 IF (desymmetrize_prv)
THEN
2673 CALL dbt_create(t3c(1, 1), t_3c_tmp)
2676 CALL dbt_copy(t3c(jcell, kcell), t_3c_tmp)
2677 CALL dbt_copy(t_3c_tmp, t3c(kcell, jcell), order=[1, 3, 2], summation=.true., move_data=.true.)
2678 CALL dbt_filter(t3c(kcell, jcell), filter_eps)
2681 DO kcell = jcell + 1, nimg
2683 CALL dbt_copy(t3c(jcell, kcell), t_3c_tmp)
2684 CALL dbt_copy(t_3c_tmp, t3c(kcell, jcell), order=[1, 3, 2], summation=.false., move_data=.true.)
2685 CALL dbt_filter(t3c(kcell, jcell), filter_eps)
2688 CALL dbt_destroy(t_3c_tmp)
2693 CALL dbt_filter(t3c(jcell, kcell), filter_eps/2)
2699 CALL dbt_filter(t3c(jcell, kcell), filter_eps)
2703 cpabort(
"requested symmetric case not implemented")
2706 DO iset = 1, max_nset
2707 DO ibasis = 1, nbasis
2708 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
2709 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
2710 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
2713 DEALLOCATE (spi, tspj, spk)
2715 CALL timestop(handle)
2731 nl_2c, basis_i, basis_j, &
2732 potential_parameter, do_kpoints)
2734 TYPE(
dbcsr_type),
DIMENSION(:, :),
INTENT(INOUT) :: t2c_der
2735 REAL(kind=
dp),
INTENT(IN) :: filter_eps
2741 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints
2743 CHARACTER(len=*),
PARAMETER :: routinen =
'build_2c_derivatives'
2745 INTEGER :: handle, i_xyz, iatom, ibasis, icol, ikind,
imax, img, irow, iset, jatom, jkind, &
2746 jset, m_max, maxli, maxlj, natom, ncoi, ncoj, nimg, nseti, nsetj, op_prv, sgfi, sgfj, &
2748 INTEGER,
DIMENSION(3) :: cell_j, kp_index_lbounds, &
2750 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
2752 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
2753 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2754 LOGICAL :: do_kpoints_prv, do_symmetric, found, &
2756 REAL(kind=
dp) :: dab
2757 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dij_contr, dij_rs
2758 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dij
2759 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj
2760 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
2761 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
2770 DIMENSION(:),
POINTER :: nl_iterator
2771 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2773 CALL timeset(routinen, handle)
2775 IF (
PRESENT(do_kpoints))
THEN
2776 do_kpoints_prv = do_kpoints
2778 do_kpoints_prv = .false.
2781 op_prv = potential_parameter%potential_type
2783 NULLIFY (qs_kind_set, atomic_kind_set, block_t(1)%block, block_t(2)%block, block_t(3)%block, cell_to_index)
2786 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
2787 natom=natom, kpoints=kpoints, dft_control=dft_control, para_env=para_env)
2789 IF (do_kpoints_prv)
THEN
2790 nimg =
SIZE(t2c_der, 1)
2792 kp_index_lbounds = lbound(cell_to_index)
2793 kp_index_ubounds = ubound(cell_to_index)
2799 cpassert(
SIZE(nl_2c) > 0)
2802 IF (do_symmetric)
THEN
2824 DO ibasis = 1,
SIZE(basis_i)
2826 maxli = max(maxli,
imax)
2829 DO ibasis = 1,
SIZE(basis_j)
2831 maxlj = max(maxlj,
imax)
2834 m_max = maxli + maxlj + 1
2840 IF (para_env%mepos == 0)
THEN
2841 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
2843 CALL init(m_max, unit_id, para_env%mepos, para_env)
2844 IF (para_env%mepos == 0)
THEN
2859 iatom=iatom, jatom=jatom, r=rij, cell=cell_j)
2860 IF (do_kpoints_prv)
THEN
2861 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
2862 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
2863 img = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
2864 IF (img > nimg .OR. img < 1) cycle
2869 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
2870 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
2871 sphi=sphi_i, zet=zeti)
2873 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
2874 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
2875 sphi=sphi_j, zet=zetj)
2877 IF (do_symmetric)
THEN
2878 IF (iatom <= jatom)
THEN
2891 trans = do_symmetric .AND. (iatom > jatom)
2895 row=irow, col=icol, block=block_t(i_xyz)%block, found=found)
2901 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
2902 sgfi = first_sgf_i(1, iset)
2906 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
2907 sgfj = first_sgf_j(1, jset)
2909 IF (ncoi*ncoj > 0)
THEN
2910 ALLOCATE (dij_contr(nsgfi(iset), nsgfj(jset)))
2911 ALLOCATE (dij(ncoi, ncoj, 3))
2912 dij(:, :, :) = 0.0_dp
2917 CALL eri_2center_derivs(dij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
2918 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
2919 rpgf_j(:, jset), rj, dab, lib, potential_parameter)
2923 dij_contr(:, :) = 0.0_dp
2925 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
2926 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
2930 ALLOCATE (dij_rs(nsgfj(jset), nsgfi(iset)))
2931 dij_rs(:, :) = -1.0_dp*transpose(dij_contr)
2933 ALLOCATE (dij_rs(nsgfi(iset), nsgfj(jset)))
2934 dij_rs(:, :) = dij_contr
2938 nsgfi(iset), nsgfj(jset), block_t(i_xyz)%block, &
2939 sgfi, sgfj, trans=trans)
2943 DEALLOCATE (dij, dij_contr)
2959 CALL timestop(handle)
2975 SUBROUTINE calc_2c_virial(work_virial, t2c_trace, pref, qs_env, nl_2c, basis_i, basis_j, potential_parameter)
2976 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: work_virial
2978 REAL(kind=
dp),
INTENT(IN) :: pref
2985 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_2c_virial'
2987 INTEGER :: handle, i_xyz, iatom, ibasis, ikind,
imax, iset, j_xyz, jatom, jkind, jset, &
2988 m_max, maxli, maxlj, natom, ncoi, ncoj, nseti, nsetj, op_prv, sgfi, sgfj, unit_id
2989 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
2991 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
2992 LOGICAL :: do_symmetric, found
2994 REAL(
dp),
DIMENSION(:, :),
POINTER :: pblock
2995 REAL(kind=
dp) :: dab
2996 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dij_contr
2997 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dij
2998 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj, scoord
2999 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
3000 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
3008 DIMENSION(:),
POINTER :: nl_iterator
3010 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3012 CALL timeset(routinen, handle)
3014 op_prv = potential_parameter%potential_type
3016 NULLIFY (qs_kind_set, atomic_kind_set, pblock, particle_set, cell)
3019 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
3020 natom=natom, dft_control=dft_control, para_env=para_env, &
3021 particle_set=particle_set, cell=cell)
3024 cpassert(
SIZE(nl_2c) > 0)
3026 cpassert(.NOT. do_symmetric)
3029 DO ibasis = 1,
SIZE(basis_i)
3031 maxli = max(maxli,
imax)
3034 DO ibasis = 1,
SIZE(basis_j)
3036 maxlj = max(maxlj,
imax)
3039 m_max = maxli + maxlj + 1
3045 IF (para_env%mepos == 0)
THEN
3046 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
3048 CALL init(m_max, unit_id, para_env%mepos, para_env)
3049 IF (para_env%mepos == 0)
THEN
3064 iatom=iatom, jatom=jatom, r=rij)
3066 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
3067 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
3068 sphi=sphi_i, zet=zeti)
3070 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
3071 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
3072 sphi=sphi_j, zet=zetj)
3077 IF (.NOT. found) cycle
3081 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
3082 sgfi = first_sgf_i(1, iset)
3086 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
3087 sgfj = first_sgf_j(1, jset)
3089 IF (ncoi*ncoj > 0)
THEN
3090 ALLOCATE (dij_contr(nsgfi(iset), nsgfj(jset)))
3091 ALLOCATE (dij(ncoi, ncoj, 3))
3092 dij(:, :, :) = 0.0_dp
3097 CALL eri_2center_derivs(dij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
3098 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
3099 rpgf_j(:, jset), rj, dab, lib, potential_parameter)
3103 dij_contr(:, :) = 0.0_dp
3105 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
3106 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
3108 force = sum(pblock(sgfi:sgfi + nsgfi(iset) - 1, sgfj:sgfj + nsgfj(jset) - 1)*dij_contr(:, :))
3114 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
3120 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) - force*scoord(j_xyz)
3124 DEALLOCATE (dij, dij_contr)
3133 CALL timestop(handle)
3153 nl_2c, basis_i, basis_j, &
3154 potential_parameter, do_kpoints, &
3155 do_hfx_kpoints, ext_kpoints, regularization_RI)
3157 TYPE(
dbcsr_type),
DIMENSION(:),
INTENT(INOUT) :: t2c
3158 REAL(kind=
dp),
INTENT(IN) :: filter_eps
3164 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
3165 TYPE(
kpoint_type),
OPTIONAL,
POINTER :: ext_kpoints
3166 REAL(kind=
dp),
OPTIONAL :: regularization_ri
3168 CHARACTER(len=*),
PARAMETER :: routinen =
'build_2c_integrals'
3170 INTEGER :: handle, i_diag, iatom, ibasis, icol, ikind,
imax, img, irow, iset, jatom, jkind, &
3171 jset, m_max, maxli, maxlj, natom, ncoi, ncoj, nimg, nseti, nsetj, op_prv, sgfi, sgfj, &
3173 INTEGER,
DIMENSION(3) :: cell_j, kp_index_lbounds, &
3175 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
3177 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
3178 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
3179 LOGICAL :: do_hfx_kpoints_prv, do_kpoints_prv, &
3180 do_symmetric, found, trans
3181 REAL(kind=
dp) :: dab, min_zet
3182 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: sij, sij_contr, sij_rs
3183 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj
3184 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
3185 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
3195 DIMENSION(:),
POINTER :: nl_iterator
3196 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3198 CALL timeset(routinen, handle)
3200 IF (
PRESENT(do_kpoints))
THEN
3201 do_kpoints_prv = do_kpoints
3203 do_kpoints_prv = .false.
3206 IF (
PRESENT(do_hfx_kpoints))
THEN
3207 do_hfx_kpoints_prv = do_hfx_kpoints
3209 do_hfx_kpoints_prv = .false.
3211 IF (do_hfx_kpoints_prv)
THEN
3212 cpassert(do_kpoints_prv)
3215 op_prv = potential_parameter%potential_type
3217 NULLIFY (qs_kind_set, atomic_kind_set, block_t%block, cell_to_index)
3220 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, cell=cell, &
3221 natom=natom, dft_control=dft_control, para_env=para_env, kpoints=kpoints)
3223 IF (
PRESENT(ext_kpoints)) kpoints => ext_kpoints
3225 IF (do_kpoints_prv)
THEN
3228 kp_index_lbounds = lbound(cell_to_index)
3229 kp_index_ubounds = ubound(cell_to_index)
3235 cpassert(
SIZE(nl_2c) > 0)
3238 IF (do_symmetric)
THEN
3253 DO ibasis = 1,
SIZE(basis_i)
3255 maxli = max(maxli,
imax)
3258 DO ibasis = 1,
SIZE(basis_j)
3260 maxlj = max(maxlj,
imax)
3263 m_max = maxli + maxlj
3269 IF (para_env%mepos == 0)
THEN
3270 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
3272 CALL init(m_max, unit_id, para_env%mepos, para_env)
3273 IF (para_env%mepos == 0)
THEN
3288 iatom=iatom, jatom=jatom, r=rij, cell=cell_j)
3289 IF (do_kpoints_prv)
THEN
3290 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
3291 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
3292 img = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
3293 IF (img > nimg .OR. img < 1) cycle
3298 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
3299 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
3300 sphi=sphi_i, zet=zeti)
3302 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
3303 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
3304 sphi=sphi_j, zet=zetj)
3306 IF (do_symmetric)
THEN
3307 IF (iatom <= jatom)
THEN
3322 row=irow, col=icol, block=block_t%block, found=found)
3324 trans = do_symmetric .AND. (iatom > jatom)
3328 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
3329 sgfi = first_sgf_i(1, iset)
3333 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
3334 sgfj = first_sgf_j(1, jset)
3336 IF (ncoi*ncoj > 0)
THEN
3337 ALLOCATE (sij_contr(nsgfi(iset), nsgfj(jset)))
3338 sij_contr(:, :) = 0.0_dp
3340 ALLOCATE (sij(ncoi, ncoj))
3346 CALL eri_2center(sij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
3347 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
3348 rpgf_j(:, jset), rj, dab, lib, potential_parameter)
3351 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
3352 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
3356 ALLOCATE (sij_rs(nsgfj(jset), nsgfi(iset)))
3357 sij_rs(:, :) = transpose(sij_contr)
3359 ALLOCATE (sij_rs(nsgfi(iset), nsgfj(jset)))
3360 sij_rs(:, :) = sij_contr
3363 DEALLOCATE (sij_contr)
3366 IF (.NOT. do_hfx_kpoints_prv .AND.
PRESENT(regularization_ri) .AND. &
3367 iatom == jatom .AND. iset == jset .AND. &
3368 cell_j(1) == 0 .AND. cell_j(2) == 0 .AND. cell_j(3) == 0)
THEN
3369 DO i_diag = 1, nsgfi(iset)
3370 min_zet = minval(zeti(:, iset))
3371 cpassert(min_zet > 1.0e-10_dp)
3372 sij_rs(i_diag, i_diag) = sij_rs(i_diag, i_diag) + &
3373 regularization_ri*max(1.0_dp, 1.0_dp/min_zet)
3378 nsgfi(iset), nsgfj(jset), block_t%block, &
3379 sgfi, sgfj, trans=trans)
3395 CALL timestop(handle)
3408 TYPE(dbt_type),
INTENT(INOUT) ::
tensor
3409 INTEGER,
ALLOCATABLE,
DIMENSION(:, :), &
3410 INTENT(INOUT) :: blk_indices
3412 REAL(
dp),
INTENT(IN) :: eps
3413 REAL(
dp),
INTENT(INOUT) :: memory
3415 INTEGER :: buffer_left, buffer_size, buffer_start, &
3416 i, iblk, memory_usage, nbits, nblk, &
3417 nints, offset, shared_offset
3418 INTEGER(int_8) :: estimate_to_store_int, &
3419 storage_counter_integrals
3420 INTEGER,
DIMENSION(3) :: ind
3422 REAL(
dp) :: spherical_estimate
3423 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :),
TARGET :: blk_data
3424 REAL(
dp),
DIMENSION(:),
POINTER :: blk_data_1d
3425 TYPE(dbt_iterator_type) :: iter
3434 maxval_container => compressed%maxval_container(1)
3435 integral_containers => compressed%integral_containers(:, 1)
3442 maxval_cache => compressed%maxval_cache(1)
3443 integral_caches => compressed%integral_caches(:, 1)
3445 IF (
ALLOCATED(blk_indices))
DEALLOCATE (blk_indices)
3446 ALLOCATE (blk_indices(dbt_get_num_blocks(
tensor), 3))
3450 CALL dbt_iterator_start(iter,
tensor)
3451 nblk = dbt_iterator_num_blocks(iter)
3453 offset = shared_offset
3454 shared_offset = shared_offset + nblk
3457 CALL dbt_iterator_next_block(iter, ind)
3458 blk_indices(offset + iblk, :) = ind(:)
3460 CALL dbt_iterator_stop(iter)
3464 DO i = 1,
SIZE(blk_indices, 1)
3465 ind = blk_indices(i, :)
3466 CALL dbt_get_block(
tensor, ind, blk_data, found)
3468 nints =
SIZE(blk_data)
3469 blk_data_1d(1:nints) => blk_data
3470 spherical_estimate = maxval(abs(blk_data_1d))
3471 IF (spherical_estimate == 0.0_dp) spherical_estimate = tiny(spherical_estimate)
3472 estimate_to_store_int = exponent(spherical_estimate)
3473 estimate_to_store_int = max(estimate_to_store_int, -15_int_8)
3476 maxval_cache, maxval_container, memory_usage, &
3479 spherical_estimate = set_exponent(1.0_dp, estimate_to_store_int + 1)
3481 nbits = exponent(anint(spherical_estimate/eps)) + 1
3482 IF (nbits > 64)
THEN
3483 CALL cp_abort(__location__, &
3484 "Overflow during tensor compression. Please use a larger EPS_FILTER or EPS_STORAGE_SCALING")
3490 DO WHILE (buffer_left > 0)
3491 buffer_size = min(buffer_left, cache_size)
3493 buffer_size, nbits, &
3494 integral_caches(nbits), &
3495 integral_containers(nbits), &
3499 buffer_left = buffer_left - buffer_size
3500 buffer_start = buffer_start + buffer_size
3503 NULLIFY (blk_data_1d);
DEALLOCATE (blk_data)
3508 storage_counter_integrals = memory_usage*cache_size
3509 memory = memory + real(storage_counter_integrals,
dp)/1024/128
3517 memory_usage, .false.)
3523 memory_usage, .false.)
3537 TYPE(dbt_type),
INTENT(INOUT) ::
tensor
3538 INTEGER,
DIMENSION(:, :) :: blk_indices
3540 REAL(
dp),
INTENT(IN) :: eps
3542 INTEGER :: a, b, buffer_left, buffer_size, &
3543 buffer_start, i, memory_usage, nbits, &
3544 nblk_per_thread, nints
3545 INTEGER(int_8) :: estimate_to_store_int
3546 INTEGER,
DIMENSION(3) :: blk_size, ind
3547 REAL(
dp) :: spherical_estimate
3548 REAL(
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: blk_data
3549 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: blk_data_3d
3555 maxval_cache => compressed%maxval_cache(1)
3556 maxval_container => compressed%maxval_container(1)
3557 integral_caches => compressed%integral_caches(:, 1)
3558 integral_containers => compressed%integral_containers(:, 1)
3566 memory_usage, .false.)
3571 nblk_per_thread =
SIZE(blk_indices, 1)/omp_get_num_threads() + 1
3572 a = omp_get_thread_num()*nblk_per_thread + 1
3573 b = min(a + nblk_per_thread,
SIZE(blk_indices, 1))
3574 CALL dbt_reserve_blocks(
tensor, blk_indices(a:b, :))
3578 DO i = 1,
SIZE(blk_indices, 1)
3579 ind = blk_indices(i, :)
3580 CALL dbt_blk_sizes(
tensor, ind, blk_size)
3581 nints = product(blk_size)
3583 estimate_to_store_int, 6, &
3584 maxval_cache, maxval_container, memory_usage, &
3587 spherical_estimate = set_exponent(1.0_dp, estimate_to_store_int + 1)
3589 nbits = exponent(anint(spherical_estimate/eps)) + 1
3594 ALLOCATE (blk_data(nints))
3595 DO WHILE (buffer_left > 0)
3596 buffer_size = min(buffer_left, cache_size)
3598 buffer_size, nbits, &
3599 integral_caches(nbits), &
3600 integral_containers(nbits), &
3604 buffer_left = buffer_left - buffer_size
3605 buffer_start = buffer_start + buffer_size
3608 blk_data_3d(1:blk_size(1), 1:blk_size(2), 1:blk_size(3)) => blk_data
3609 CALL dbt_put_block(
tensor, ind, blk_size, blk_data_3d)
3610 NULLIFY (blk_data_3d);
DEALLOCATE (blk_data)
3616 memory_usage, .false.)
3627 TYPE(dbt_type),
INTENT(IN) ::
tensor
3628 INTEGER(int_8),
INTENT(OUT) :: nze
3629 REAL(
dp),
INTENT(OUT) :: occ
3631 INTEGER,
DIMENSION(dbt_ndims(tensor)) :: dims
3633 nze = dbt_get_nze_total(
tensor)
3634 CALL dbt_get_info(
tensor, nfull_total=dims)
3635 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; can ...
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)
...
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.
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
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
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...
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
subroutine, public init_md_ftable(nmax)
Initialize a table of F_n(t) values in the range 0 <= t <= 12 with a stepsize of 0....
routines and types for Hartree-Fock-Exchange
subroutine, public hfx_add_single_cache_element(value, nbits, cache, container, memory_usage, use_disk_storage, max_val_memory)
This routine adds an int_8 value to a cache. If the cache is full a compression routine is invoked an...
subroutine, public hfx_get_mult_cache_elements(values, nints, nbits, cache, container, eps_schwarz, pmax_entry, memory_usage, use_disk_storage)
This routine returns a bunch real values from a cache. If the cache is empty a decompression routine ...
subroutine, public hfx_flush_last_cache(nbits, cache, container, memory_usage, use_disk_storage)
This routine compresses the last probably not yet compressed cache into a container
subroutine, public hfx_get_single_cache_element(value, nbits, cache, container, memory_usage, use_disk_storage)
This routine returns an int_8 value from a cache. If the cache is empty a decompression routine is in...
subroutine, public hfx_decompress_first_cache(nbits, cache, container, memory_usage, use_disk_storage)
This routine decompresses the first bunch of data in a container and copies them into a cache
subroutine, public hfx_add_mult_cache_elements(values, nints, nbits, cache, container, eps_schwarz, pmax_entry, memory_usage, use_disk_storage)
This routine adds an a few real values to a cache. If the cache is full a compression routine is invo...
subroutine, public hfx_reset_cache_and_container(cache, container, memory_usage, do_disk_storage)
This routine resets the containers list pointer to the first element and moves the element counters o...
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 alloc_containers(data, bin_size)
...
subroutine, public dealloc_containers(data, memory_usage)
...
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)
Retrieve information from a kpoint environment.
2- and 3-center electron repulsion integral routines based on libint2 Currently available operators: ...
subroutine, public eri_2center(int_ab, la_min, la_max, npgfa, zeta, rpgfa, ra, lb_min, lb_max, npgfb, zetb, rpgfb, rb, dab, lib, potential_parameter)
Computes the 2-center electron repulsion integrals (a|b) for a given set of cartesian gaussian orbita...
subroutine, public eri_3center(int_abc, la_min, la_max, npgfa, zeta, rpgfa, ra, lb_min, lb_max, npgfb, zetb, rpgfb, rb, lc_min, lc_max, npgfc, zetc, rpgfc, rc, dab, dac, dbc, lib, potential_parameter, int_abc_ext)
Computes the 3-center electron repulsion integrals (ab|c) for a given set of cartesian gaussian orbit...
real(kind=dp), parameter, public cutoff_screen_factor
subroutine, public eri_2center_derivs(der_ab, la_min, la_max, npgfa, zeta, rpgfa, ra, lb_min, lb_max, npgfb, zetb, rpgfb, rb, dab, lib, potential_parameter)
Computes the 2-center derivatives of the electron repulsion integrals (a|b) for a given set of cartes...
subroutine, public eri_3center_derivs(der_abc_1, der_abc_2, la_min, la_max, npgfa, zeta, rpgfa, ra, lb_min, lb_max, npgfb, zetb, rpgfb, rb, lc_min, lc_max, npgfc, zetc, rpgfc, rc, dab, dac, dbc, lib, potential_parameter, der_abc_1_ext, der_abc_2_ext)
Computes the derivatives of the 3-center electron repulsion integrals (ab|c) for a given set of carte...
Interface to the Libint-Library or a c++ wrapper.
subroutine, public cp_libint_cleanup_3eri1(lib)
subroutine, public cp_libint_init_3eri1(lib, max_am)
subroutine, public cp_libint_cleanup_2eri1(lib)
subroutine, public cp_libint_init_2eri1(lib, max_am)
subroutine, public cp_libint_init_2eri(lib, max_am)
subroutine, public cp_libint_init_3eri(lib, max_am)
subroutine, public cp_libint_cleanup_3eri(lib)
subroutine, public cp_libint_set_contrdepth(lib, contrdepth)
subroutine, public cp_libint_cleanup_2eri(lib)
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, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
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)
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.
recursive integer function, public neighbor_list_3c_iterate(iterator)
Iterate 3c-nl iterator.
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.
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.
This module computes the basic integrals for the truncated coulomb operator.
subroutine, public init(nder, iunit, mepos, group)
...
integer function, public get_lmax_init()
Returns the value of nderiv_init so that one can check if opening the potential file is worhtwhile.
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.