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
104#include "./base/base_uses.f90"
110 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_tensors'
119 TYPE one_dim_int_array
120 INTEGER,
DIMENSION(:),
ALLOCATABLE :: array
121 END TYPE one_dim_int_array
124 INTEGER,
PARAMETER,
PRIVATE :: cache_size = 1024
143 sym_ij, molecular, dist_2d, pot_to_rad)
148 CHARACTER(LEN=*),
INTENT(IN) :: name
150 LOGICAL,
INTENT(IN),
OPTIONAL :: sym_ij, molecular
152 INTEGER,
INTENT(IN),
OPTIONAL :: pot_to_rad
154 INTEGER :: ikind, nkind, pot_to_rad_prv
155 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: i_present, j_present
156 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pair_radius
157 REAL(kind=
dp) :: subcells
158 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: i_radius, j_radius
167 NULLIFY (atomic_kind_set, cell, local_particles, molecule_set, &
168 particle_set, dist_2d_prv)
170 IF (
PRESENT(pot_to_rad))
THEN
171 pot_to_rad_prv = pot_to_rad
179 particle_set=particle_set, &
180 atomic_kind_set=atomic_kind_set, &
181 local_particles=local_particles, &
182 distribution_2d=dist_2d_prv, &
183 molecule_set=molecule_set)
187 ALLOCATE (i_present(nkind), source=.false.)
188 ALLOCATE (j_present(nkind), source=.false.)
189 ALLOCATE (i_radius(nkind), source=0.0_dp)
190 ALLOCATE (j_radius(nkind), source=0.0_dp)
192 IF (
PRESENT(dist_2d)) dist_2d_prv => dist_2d
199 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
200 i_present(ikind) = .true.
201 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, kind_radius=i_radius(ikind))
203 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
204 j_present(ikind) = .true.
205 CALL get_gto_basis_set(basis_j(ikind)%gto_basis_set, kind_radius=j_radius(ikind))
213 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
214 i_present(ikind) = .true.
215 IF (pot_to_rad_prv == 1) i_radius(ikind) = 1000000.0_dp
217 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
218 j_present(ikind) = .true.
219 IF (pot_to_rad_prv == 2) j_radius(ikind) = 1000000.0_dp
229 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
230 i_present(ikind) = .true.
231 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, kind_radius=i_radius(ikind))
232 IF (pot_to_rad_prv == 1) i_radius(ikind) = i_radius(ikind) +
cutoff_screen_factor*potential_parameter%cutoff_radius
234 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
235 j_present(ikind) = .true.
236 CALL get_gto_basis_set(basis_j(ikind)%gto_basis_set, kind_radius=j_radius(ikind))
237 IF (pot_to_rad_prv == 2) j_radius(ikind) = j_radius(ikind) +
cutoff_screen_factor*potential_parameter%cutoff_radius
242 cpabort(
"Operator not implemented.")
245 ALLOCATE (pair_radius(nkind, nkind), source=0.0_dp)
248 ALLOCATE (atom2d(nkind))
250 CALL atom2d_build(atom2d, local_particles, dist_2d_prv, atomic_kind_set, &
251 molecule_set, molecule_only=.false., particle_set=particle_set)
253 symmetric=sym_ij, molecular=molecular, nlname=trim(name))
277 dist_3d, potential_parameter, name, qs_env, &
278 sym_ij, sym_jk, sym_ik, molecular, op_pos, &
284 CHARACTER(LEN=*),
INTENT(IN) :: name
286 LOGICAL,
INTENT(IN),
OPTIONAL :: sym_ij, sym_jk, sym_ik, molecular
287 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
288 LOGICAL,
INTENT(IN),
OPTIONAL :: own_dist
290 CHARACTER(len=*),
PARAMETER :: routinen =
'build_3c_neighbor_lists'
292 INTEGER :: handle, op_pos_prv, sym_level
295 CALL timeset(routinen, handle)
297 IF (
PRESENT(op_pos))
THEN
303 SELECT CASE (op_pos_prv)
305 pot_par_1 = potential_parameter
308 pot_par_2 = potential_parameter
313 qs_env, sym_ij=.false., molecular=molecular, &
314 dist_2d=dist_3d%dist_2d_1, pot_to_rad=1)
317 qs_env, sym_ij=.false., molecular=molecular, &
318 dist_2d=dist_3d%dist_2d_2, pot_to_rad=2)
323 IF (
PRESENT(sym_ij))
THEN
326 sym_level = sym_level + 1
330 IF (
PRESENT(sym_jk))
THEN
333 sym_level = sym_level + 1
337 IF (
PRESENT(sym_ik))
THEN
340 sym_level = sym_level + 1
344 IF (sym_level >= 2)
THEN
348 ijk_list%dist_3d = dist_3d
349 IF (
PRESENT(own_dist))
THEN
350 ijk_list%owns_dist = own_dist
352 ijk_list%owns_dist = .false.
355 CALL timestop(handle)
364 PURE FUNCTION include_symmetric(a, b)
365 INTEGER,
INTENT(IN) :: a, b
366 LOGICAL :: include_symmetric
369 include_symmetric = (
modulo(a + b, 2) /= 0)
371 include_symmetric = (
modulo(a + b, 2) == 0)
374 END FUNCTION include_symmetric
386 IF (ijk_list%owns_dist)
THEN
401 CHARACTER(len=*),
PARAMETER :: routinen =
'neighbor_list_3c_iterator_create'
405 CALL timeset(routinen, handle)
410 iterator%iter_level = 0
411 iterator%ijk_nl = ijk_nl
413 iterator%bounds_i = 0
414 iterator%bounds_j = 0
415 iterator%bounds_k = 0
417 CALL timestop(handle)
427 SUBROUTINE nl_3c_iter_set_bounds(iterator, bounds_i, bounds_j, bounds_k)
429 INTENT(INOUT) :: iterator
430 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
432 IF (
PRESENT(bounds_i)) iterator%bounds_i = bounds_i
433 IF (
PRESENT(bounds_j)) iterator%bounds_j = bounds_j
434 IF (
PRESENT(bounds_k)) iterator%bounds_k = bounds_k
436 END SUBROUTINE nl_3c_iter_set_bounds
444 INTENT(INOUT) :: iterator
446 CHARACTER(len=*),
PARAMETER :: routinen =
'neighbor_list_3c_iterator_destroy'
450 CALL timeset(routinen, handle)
453 NULLIFY (iterator%iter_ij)
454 NULLIFY (iterator%iter_jk)
456 CALL timestop(handle)
466 INTENT(INOUT) :: iterator
469 INTEGER :: iatom, iter_level, jatom, jatom_1, &
473 iter_level = iterator%iter_level
475 IF (iter_level == 0)
THEN
478 IF (iter_stat /= 0)
THEN
484 IF ((iterator%bounds_i(1) > 0 .AND. iatom < iterator%bounds_i(1)) &
485 .OR. (iterator%bounds_i(2) > 0 .AND. iatom > iterator%bounds_i(2))) skip_this = .true.
486 IF ((iterator%bounds_j(1) > 0 .AND. jatom < iterator%bounds_j(1)) &
487 .OR. (iterator%bounds_j(2) > 0 .AND. jatom > iterator%bounds_j(2))) skip_this = .true.
496 IF (iter_stat /= 0)
THEN
497 iterator%iter_level = 0
501 iterator%iter_level = 1
504 cpassert(iter_stat == 0)
505 cpassert(iterator%iter_level == 1)
509 cpassert(jatom_1 == jatom_2)
513 IF ((iterator%bounds_k(1) > 0 .AND. katom < iterator%bounds_k(1)) &
514 .OR. (iterator%bounds_k(2) > 0 .AND. katom > iterator%bounds_k(2))) skip_this = .true.
521 SELECT CASE (iterator%ijk_nl%sym)
525 skip_this = .NOT. include_symmetric(iatom, jatom)
527 skip_this = .NOT. include_symmetric(jatom, katom)
529 skip_this = .NOT. include_symmetric(iatom, katom)
531 skip_this = .NOT. include_symmetric(iatom, jatom) .OR. .NOT. include_symmetric(jatom, katom)
533 cpabort(
"should not happen")
561 rij, rjk, rik, cell_j, cell_k)
563 INTENT(INOUT) :: iterator
564 INTEGER,
INTENT(OUT),
OPTIONAL :: ikind, jkind, kkind, nkind, iatom, &
566 REAL(kind=
dp),
DIMENSION(3),
INTENT(OUT),
OPTIONAL :: rij, rjk, rik
567 INTEGER,
DIMENSION(3),
INTENT(OUT),
OPTIONAL :: cell_j, cell_k
569 INTEGER,
DIMENSION(2) :: atoms_1, atoms_2, kinds_1, kinds_2
570 INTEGER,
DIMENSION(3) :: cell_1, cell_2
571 REAL(kind=
dp),
DIMENSION(3) :: r_1, r_2
573 cpassert(iterator%iter_level == 1)
576 ikind=kinds_1(1), jkind=kinds_1(2), nkind=nkind, &
577 iatom=atoms_1(1), jatom=atoms_1(2), r=r_1, &
581 ikind=kinds_2(1), jkind=kinds_2(2), &
582 iatom=atoms_2(1), jatom=atoms_2(2), r=r_2, &
585 IF (
PRESENT(ikind)) ikind = kinds_1(1)
586 IF (
PRESENT(jkind)) jkind = kinds_1(2)
587 IF (
PRESENT(kkind)) kkind = kinds_2(2)
588 IF (
PRESENT(iatom)) iatom = atoms_1(1)
589 IF (
PRESENT(jatom)) jatom = atoms_1(2)
590 IF (
PRESENT(katom)) katom = atoms_2(2)
592 IF (
PRESENT(rij)) rij = r_1
593 IF (
PRESENT(rjk)) rjk = r_2
594 IF (
PRESENT(rik)) rik = r_1 + r_2
596 IF (
PRESENT(cell_j)) cell_j = cell_1
597 IF (
PRESENT(cell_k)) cell_k = cell_1 + cell_2
623 SUBROUTINE alloc_block_3c(t3c, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, op_pos, &
624 do_kpoints, do_hfx_kpoints, bounds_i, bounds_j, bounds_k, RI_range, &
625 img_to_RI_cell, cell_to_index, cell_sym)
626 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(INOUT) :: t3c
631 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
632 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
633 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
634 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
635 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
636 INTEGER,
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: cell_to_index
637 LOGICAL,
INTENT(IN),
OPTIONAL :: cell_sym
639 CHARACTER(LEN=*),
PARAMETER :: routinen =
'alloc_block_3c'
641 INTEGER :: handle, iatom, ikind, j_img, jatom, &
642 jcell, jkind, k_img, katom, kcell, &
643 kkind, natom, ncell_ri, nimg, op_ij, &
645 INTEGER(int_8) :: a, b, nblk_per_thread
646 INTEGER(int_8),
ALLOCATABLE,
DIMENSION(:, :) :: nblk
647 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
648 INTEGER,
DIMENSION(3) :: blk_idx, cell_j, cell_k, &
649 kp_index_lbounds, kp_index_ubounds
650 LOGICAL :: cell_sym_prv, do_hfx_kpoints_prv, &
652 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
653 kind_radius_i, kind_radius_j, &
655 REAL(kind=
dp),
DIMENSION(3) :: rij, rik, rjk
661 TYPE(one_dim_int_array),
ALLOCATABLE, &
662 DIMENSION(:, :) :: alloc_i, alloc_j, alloc_k
663 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
665 CALL timeset(routinen, handle)
666 NULLIFY (qs_kind_set, atomic_kind_set, cell)
668 IF (
PRESENT(do_kpoints))
THEN
669 do_kpoints_prv = do_kpoints
671 do_kpoints_prv = .false.
673 IF (
PRESENT(do_hfx_kpoints))
THEN
674 do_hfx_kpoints_prv = do_hfx_kpoints
676 do_hfx_kpoints_prv = .false.
678 IF (do_hfx_kpoints_prv)
THEN
679 cpassert(do_kpoints_prv)
680 cpassert(
PRESENT(ri_range))
681 cpassert(
PRESENT(img_to_ri_cell))
684 IF (
PRESENT(img_to_ri_cell))
THEN
685 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
686 img_to_ri_cell_prv(:) = img_to_ri_cell
689 IF (
PRESENT(cell_sym))
THEN
690 cell_sym_prv = cell_sym
692 cell_sym_prv = .false.
695 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
699 IF (
PRESENT(op_pos))
THEN
705 SELECT CASE (op_pos_prv)
707 op_ij = potential_parameter%potential_type
709 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)
894 END SUBROUTINE alloc_block_3c
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
1034 dr_ij = 1000000.0_dp
1035 dr_ik = 1000000.0_dp
1043 dr_jk = 1000000.0_dp
1044 dr_ik = 1000000.0_dp
1047 NULLIFY (qs_kind_set, atomic_kind_set)
1050 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
1051 natom=natom, kpoints=kpoints, dft_control=dft_control, para_env=para_env)
1053 IF (do_kpoints_prv)
THEN
1054 nimg = dft_control%nimages
1056 IF (do_hfx_kpoints_prv)
THEN
1057 nimg =
SIZE(t3c_der_k, 1)
1058 ncell_ri =
SIZE(t3c_der_k, 2)
1066 IF (do_hfx_kpoints_prv)
THEN
1067 cpassert(op_pos_prv == 2)
1069 cpassert(all(shape(t3c_der_k) == [nimg, ncell_ri, 3]))
1072 ALLOCATE (t3c_template(nimg, ncell_ri))
1073 DO j_img = 1, ncell_ri
1075 CALL dbt_create(t3c_der_i(i_img, j_img, 1), t3c_template(i_img, j_img))
1079 CALL alloc_block_3c(t3c_template, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, &
1080 op_pos=op_pos_prv, do_kpoints=do_kpoints, do_hfx_kpoints=do_hfx_kpoints, &
1081 bounds_i=bounds_i, bounds_j=bounds_j, bounds_k=bounds_k, &
1082 ri_range=ri_range, img_to_ri_cell=img_to_ri_cell, cell_to_index=cell_to_index)
1084 DO j_img = 1, ncell_ri
1086 CALL dbt_copy(t3c_template(i_img, j_img), t3c_der_i(i_img, j_img, i_xyz))
1087 CALL dbt_copy(t3c_template(i_img, j_img), t3c_der_k(i_img, j_img, i_xyz))
1092 DO j_img = 1, ncell_ri
1094 CALL dbt_destroy(t3c_template(i_img, j_img))
1097 DEALLOCATE (t3c_template)
1100 ALLOCATE (t3c_der_j(nimg, ncell_ri, 3))
1102 DO j_img = 1, ncell_ri
1104 CALL dbt_create(t3c_der_k(i_img, j_img, i_xyz), t3c_der_j(i_img, j_img, i_xyz))
1105 CALL dbt_copy(t3c_der_k(i_img, j_img, i_xyz), t3c_der_j(i_img, j_img, i_xyz))
1112 nbasis =
SIZE(basis_i)
1116 DO ibasis = 1, nbasis
1118 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
1119 maxli = max(maxli,
imax)
1120 max_nset = max(max_nset, iset)
1121 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
1125 DO ibasis = 1, nbasis
1127 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
1128 maxlj = max(maxlj,
imax)
1129 max_nset = max(max_nset, jset)
1130 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
1133 DO ibasis = 1, nbasis
1135 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
1136 maxlk = max(maxlk,
imax)
1137 max_nset = max(max_nset, kset)
1139 m_max = maxli + maxlj + maxlk + 1
1144 NULLIFY (tspj, spi, spk)
1145 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
1147 DO ibasis = 1, nbasis
1148 DO iset = 1, max_nset
1149 NULLIFY (spi(iset, ibasis)%array)
1150 NULLIFY (tspj(iset, ibasis)%array)
1151 NULLIFY (spk(iset, ibasis)%array)
1156 DO ibasis = 1, nbasis
1157 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
1158 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
1159 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
1161 DO iset = 1, basis_set%nset
1163 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
1164 sgfi = basis_set%first_sgf(1, iset)
1165 egfi = sgfi + basis_set%nsgf_set(iset) - 1
1167 IF (ilist == 1)
THEN
1168 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1169 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1171 ELSE IF (ilist == 2)
THEN
1172 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
1173 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
1176 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1177 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1189 IF (para_env%mepos == 0)
THEN
1190 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
1192 CALL init(m_max, unit_id, para_env%mepos, para_env)
1193 IF (para_env%mepos == 0)
THEN
1201 IF (do_kpoints_prv)
THEN
1202 kp_index_lbounds = lbound(cell_to_index)
1203 kp_index_ubounds = ubound(cell_to_index)
1233 IF (
PRESENT(bounds_i))
THEN
1234 bo =
get_limit(bounds_i(2) - bounds_i(1) + 1, nthread, mepos)
1235 bo(:) = bo(:) + bounds_i(1) - 1
1236 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
1237 ELSE IF (
PRESENT(bounds_j))
THEN
1238 bo =
get_limit(bounds_j(2) - bounds_j(1) + 1, nthread, mepos)
1239 bo(:) = bo(:) + bounds_j(1) - 1
1240 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bo, bounds_k)
1241 ELSE IF (
PRESENT(bounds_k))
THEN
1242 bo =
get_limit(bounds_k(2) - bounds_k(1) + 1, nthread, mepos)
1243 bo(:) = bo(:) + bounds_k(1) - 1
1244 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bo)
1247 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
1251 IF (bo(1) > bo(2)) skip = .true.
1255 iatom=iatom, jatom=jatom, katom=katom, &
1256 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
1263 IF (do_kpoints_prv)
THEN
1266 IF (jatom == katom)
THEN
1274 IF (do_hfx_kpoints_prv) prefac = 1.0_dp
1276 IF (do_kpoints_prv)
THEN
1278 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
1279 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
1281 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
1282 IF (jcell > nimg .OR. jcell < 1) cycle
1284 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
1285 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
1287 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
1288 IF (kcell > nimg .OR. kcell < 1) cycle
1290 IF (do_hfx_kpoints_prv)
THEN
1291 IF (dik > ri_range) cycle
1292 kcell = img_to_ri_cell_prv(kcell)
1295 jcell = 1; kcell = 1
1298 blk_idx = [iatom, jatom, katom]
1299 IF (do_hfx_kpoints_prv)
THEN
1300 blk_idx(3) = (kcell - 1)*natom + katom
1304 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
1305 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
1306 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
1308 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
1309 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
1310 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
1312 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
1313 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
1314 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
1316 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
1317 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
1318 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
1320 IF (
PRESENT(der_eps))
THEN
1321 ALLOCATE (max_contraction_i(nseti))
1323 sgfi = first_sgf_i(1, iset)
1324 max_contraction_i(iset) = maxval([(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)])
1327 ALLOCATE (max_contraction_j(nsetj))
1329 sgfj = first_sgf_j(1, jset)
1330 max_contraction_j(jset) = maxval([(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)])
1333 ALLOCATE (max_contraction_k(nsetk))
1335 sgfk = first_sgf_k(1, kset)
1336 max_contraction_k(kset) = maxval([(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)])
1340 CALL dbt_blk_sizes(t3c_der_i(jcell, kcell, 1), blk_idx, blk_size)
1342 ALLOCATE (block_t_i(blk_size(2), blk_size(3), blk_size(1), 3), source=0.0_dp)
1343 ALLOCATE (block_t_j(blk_size(2), blk_size(3), blk_size(1), 3), source=0.0_dp)
1344 ALLOCATE (block_t_k(blk_size(2), blk_size(3), blk_size(1), 3), source=0.0_dp)
1346 block_j_not_zero = .false.
1347 block_k_not_zero = .false.
1353 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
1357 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
1358 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
1360 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
1361 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
1362 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
1364 sgfi = first_sgf_i(1, iset)
1365 sgfj = first_sgf_j(1, jset)
1366 sgfk = first_sgf_k(1, kset)
1368 IF (ncoj*ncok*ncoi > 0)
THEN
1369 ALLOCATE (dijk_j(ncoj, ncok, ncoi, 3), source=0.0_dp)
1370 ALLOCATE (dijk_k(ncoj, ncok, ncoi, 3), source=0.0_dp)
1372 der_j_zero = .false.
1373 der_k_zero = .false.
1380 IF (op_pos_prv == 1)
THEN
1382 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1383 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1384 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1385 djk, dij, dik, lib, potential_parameter, &
1386 der_abc_1_ext=der_ext_j, der_abc_2_ext=der_ext_k)
1388 ALLOCATE (tmp_ijk_i(ncoi, ncoj, ncok, 3), source=0.0_dp)
1389 ALLOCATE (tmp_ijk_j(ncoi, ncoj, ncok, 3), source=0.0_dp)
1392 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1393 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1394 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1395 dij, dik, djk, lib, potential_parameter, &
1396 der_abc_1_ext=der_ext_i, der_abc_2_ext=der_ext_j)
1402 dijk_j(:, :, i, i_xyz) = tmp_ijk_j(i, :, :, i_xyz)
1403 dijk_k(:, :, i, i_xyz) = -(dijk_j(:, :, i, i_xyz) + tmp_ijk_i(i, :, :, i_xyz))
1404 der_ext_k(i_xyz) = max(der_ext_k(i_xyz), maxval(abs(dijk_k(:, :, i, i_xyz))))
1407 DEALLOCATE (tmp_ijk_i, tmp_ijk_j)
1411 IF (
PRESENT(der_eps))
THEN
1413 IF (der_eps > der_ext_j(i_xyz)*(max_contraction_i(iset)* &
1414 max_contraction_j(jset)* &
1415 max_contraction_k(kset)))
THEN
1416 der_j_zero(i_xyz) = .true.
1421 IF (der_eps > der_ext_k(i_xyz)*(max_contraction_i(iset)* &
1422 max_contraction_j(jset)* &
1423 max_contraction_k(kset)))
THEN
1424 der_k_zero(i_xyz) = .true.
1427 IF (all(der_j_zero) .AND. all(der_k_zero))
THEN
1428 DEALLOCATE (dijk_j, dijk_k)
1433 ALLOCATE (dijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
1435 block_start_j = sgfj
1436 block_end_j = sgfj + nsgfj(jset) - 1
1437 block_start_k = sgfk
1438 block_end_k = sgfk + nsgfk(kset) - 1
1439 block_start_i = sgfi
1440 block_end_i = sgfi + nsgfi(iset) - 1
1443 IF (der_j_zero(i_xyz)) cycle
1445 block_j_not_zero(i_xyz) = .true.
1446 CALL abc_contract_xsmm(dijk_contr, dijk_j(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1447 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1448 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1449 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
1451 block_t_j(block_start_j:block_end_j, &
1452 block_start_k:block_end_k, &
1453 block_start_i:block_end_i, i_xyz) = &
1454 block_t_j(block_start_j:block_end_j, &
1455 block_start_k:block_end_k, &
1456 block_start_i:block_end_i, i_xyz) + &
1462 IF (der_k_zero(i_xyz)) cycle
1464 block_k_not_zero(i_xyz) = .true.
1465 CALL abc_contract_xsmm(dijk_contr, dijk_k(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1466 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1467 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1468 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
1470 block_t_k(block_start_j:block_end_j, &
1471 block_start_k:block_end_k, &
1472 block_start_i:block_end_i, i_xyz) = &
1473 block_t_k(block_start_j:block_end_j, &
1474 block_start_k:block_end_k, &
1475 block_start_i:block_end_i, i_xyz) + &
1480 DEALLOCATE (dijk_j, dijk_k, dijk_contr)
1486 CALL timeset(routinen//
"_put_dbcsr", handle2)
1488 sp = shape(block_t_i(:, :, :, 1))
1493 IF ((.NOT. block_j_not_zero(i_xyz)) .AND. (.NOT. block_k_not_zero(i_xyz))) cycle
1494 block_t_i(:, :, :, i_xyz) = -(block_t_j(:, :, :, i_xyz) + block_t_k(:, :, :, i_xyz))
1496 CALL dbt_put_block(t3c_der_i(jcell, kcell, i_xyz), blk_idx,
sp, &
1497 reshape(block_t_i(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1501 sp = shape(block_t_k(:, :, :, 1))
1505 IF (.NOT. block_k_not_zero(i_xyz)) cycle
1506 CALL dbt_put_block(t3c_der_k(jcell, kcell, i_xyz), blk_idx,
sp, &
1507 reshape(block_t_k(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1513 sp = shape(block_t_j(:, :, :, 1))
1517 IF (.NOT. block_j_not_zero(i_xyz)) cycle
1518 CALL dbt_put_block(t3c_der_j(jcell, kcell, i_xyz), blk_idx,
sp, &
1519 reshape(block_t_j(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1525 CALL timestop(handle2)
1527 DEALLOCATE (block_t_i, block_t_j, block_t_k)
1528 IF (
PRESENT(der_eps))
THEN
1529 DEALLOCATE (max_contraction_i, max_contraction_j, max_contraction_k)
1533 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
1534 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
1540 IF (do_kpoints_prv .AND. .NOT. do_hfx_kpoints_prv)
THEN
1545 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps/2)
1546 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps/2)
1553 CALL dbt_create(t3c_der_k(1, 1, 1), t3c_tmp)
1557 CALL dbt_copy(t3c_der_j(jcell, kcell, i_xyz), t3c_der_k(jcell, kcell, i_xyz), &
1558 order=[1, 3, 2], move_data=.true., summation=.true.)
1559 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps)
1561 CALL dbt_copy(t3c_der_i(jcell, kcell, i_xyz), t3c_tmp)
1562 CALL dbt_copy(t3c_tmp, t3c_der_i(jcell, kcell, i_xyz), &
1563 order=[1, 3, 2], move_data=.true., summation=.true.)
1564 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps)
1568 CALL dbt_destroy(t3c_tmp)
1572 DO kcell = 1, ncell_ri
1574 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps)
1575 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps)
1580 cpabort(
"requested symmetric case not implemented")
1587 CALL dbt_destroy(t3c_der_j(i_img, j_img, i_xyz))
1593 DO iset = 1, max_nset
1594 DO ibasis = 1, nbasis
1595 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
1596 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
1597 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
1601 DEALLOCATE (spi, tspj, spk)
1603 CALL timestop(handle)
1624 nl_3c, basis_i, basis_j, basis_k, &
1625 potential_parameter, der_eps, op_pos)
1627 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: work_virial
1628 TYPE(dbt_type),
INTENT(INOUT) :: t3c_trace
1629 REAL(kind=
dp),
INTENT(IN) :: pref
1634 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: der_eps
1635 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
1637 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_3c_virial'
1639 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
1640 block_start_k, egfi, handle, i, i_xyz, iatom, ibasis, ikind, ilist,
imax, iset, j_xyz, &
1641 jatom, jkind, jset, katom, kkind, kset, m_max, max_ncoj, max_nset, max_nsgfi, maxli, &
1642 maxlj, maxlk, mepos, natom, nbasis, ncoi, ncoj, ncok, nseti, nsetj, nsetk, nthread, &
1643 op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk, unit_id
1644 INTEGER,
DIMENSION(2) :: bo
1645 INTEGER,
DIMENSION(3) :: blk_size,
sp
1646 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
1647 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
1649 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
1650 LOGICAL :: found, skip
1651 LOGICAL,
DIMENSION(3) :: block_j_not_zero, block_k_not_zero, &
1652 der_j_zero, der_k_zero
1654 REAL(
dp),
DIMENSION(3) :: der_ext_i, der_ext_j, der_ext_k
1655 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
1656 kind_radius_i, kind_radius_j, &
1658 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
1659 max_contraction_i, max_contraction_j, &
1661 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ablock, dijk_contr, tmp_block
1662 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: block_t_i, block_t_j, block_t_k, dijk_j, &
1664 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk, scoord
1665 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
1666 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
1667 sphi_k, zeti, zetj, zetk
1677 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1679 CALL timeset(routinen, handle)
1683 IF (
PRESENT(op_pos))
THEN
1688 cpassert(op_pos == 1)
1691 SELECT CASE (op_pos_prv)
1693 op_ij = potential_parameter%potential_type
1695 op_jk = potential_parameter%potential_type
1698 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
1705 dr_ij = 1000000.0_dp
1706 dr_ik = 1000000.0_dp
1714 dr_jk = 1000000.0_dp
1715 dr_ik = 1000000.0_dp
1718 NULLIFY (qs_kind_set, atomic_kind_set)
1721 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
1722 natom=natom, dft_control=dft_control, para_env=para_env, &
1723 particle_set=particle_set, cell=cell)
1726 nbasis =
SIZE(basis_i)
1730 DO ibasis = 1, nbasis
1732 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
1733 maxli = max(maxli,
imax)
1734 max_nset = max(max_nset, iset)
1735 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
1739 DO ibasis = 1, nbasis
1741 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
1742 maxlj = max(maxlj,
imax)
1743 max_nset = max(max_nset, jset)
1744 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
1747 DO ibasis = 1, nbasis
1749 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
1750 maxlk = max(maxlk,
imax)
1751 max_nset = max(max_nset, kset)
1753 m_max = maxli + maxlj + maxlk + 1
1758 NULLIFY (tspj, spi, spk)
1759 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
1761 DO ibasis = 1, nbasis
1762 DO iset = 1, max_nset
1763 NULLIFY (spi(iset, ibasis)%array)
1764 NULLIFY (tspj(iset, ibasis)%array)
1766 NULLIFY (spk(iset, ibasis)%array)
1771 DO ibasis = 1, nbasis
1772 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
1773 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
1774 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
1776 DO iset = 1, basis_set%nset
1778 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
1779 sgfi = basis_set%first_sgf(1, iset)
1780 egfi = sgfi + basis_set%nsgf_set(iset) - 1
1782 IF (ilist == 1)
THEN
1783 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1784 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1786 ELSE IF (ilist == 2)
THEN
1787 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
1788 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
1791 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1792 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 IF (
PRESENT(der_eps))
THEN
1877 ALLOCATE (max_contraction_i(nseti))
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))
1885 sgfj = first_sgf_j(1, jset)
1886 max_contraction_j(jset) = maxval([(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)])
1889 ALLOCATE (max_contraction_k(nsetk))
1891 sgfk = first_sgf_k(1, kset)
1892 max_contraction_k(kset) = maxval([(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)])
1896 CALL dbt_blk_sizes(t3c_trace, [iatom, jatom, katom], blk_size)
1898 ALLOCATE (block_t_i(blk_size(2), blk_size(3), blk_size(1), 3))
1899 ALLOCATE (block_t_j(blk_size(2), blk_size(3), blk_size(1), 3))
1900 ALLOCATE (block_t_k(blk_size(2), blk_size(3), blk_size(1), 3))
1902 ALLOCATE (ablock(blk_size(2), blk_size(3), blk_size(1)))
1903 DO i = 1, blk_size(1)
1904 ablock(:, :, i) = tmp_block(i, :, :)
1906 DEALLOCATE (tmp_block)
1911 block_j_not_zero = .false.
1912 block_k_not_zero = .false.
1918 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
1922 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
1923 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
1925 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
1926 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
1927 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
1929 sgfi = first_sgf_i(1, iset)
1930 sgfj = first_sgf_j(1, jset)
1931 sgfk = first_sgf_k(1, kset)
1933 IF (ncoj*ncok*ncoi > 0)
THEN
1934 ALLOCATE (dijk_j(ncoj, ncok, ncoi, 3), source=0.0_dp)
1935 ALLOCATE (dijk_k(ncoj, ncok, ncoi, 3), source=0.0_dp)
1937 der_j_zero = .false.
1938 der_k_zero = .false.
1946 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1947 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1948 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1949 djk, dij, dik, lib, potential_parameter, &
1950 der_abc_1_ext=der_ext_j, der_abc_2_ext=der_ext_k)
1952 IF (
PRESENT(der_eps))
THEN
1954 IF (der_eps > der_ext_j(i_xyz)*(max_contraction_i(iset)* &
1955 max_contraction_j(jset)* &
1956 max_contraction_k(kset)))
THEN
1957 der_j_zero(i_xyz) = .true.
1962 IF (der_eps > der_ext_k(i_xyz)*(max_contraction_i(iset)* &
1963 max_contraction_j(jset)* &
1964 max_contraction_k(kset)))
THEN
1965 der_k_zero(i_xyz) = .true.
1968 IF (all(der_j_zero) .AND. all(der_k_zero))
THEN
1969 DEALLOCATE (dijk_j, dijk_k)
1974 ALLOCATE (dijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
1976 block_start_j = sgfj
1977 block_end_j = sgfj + nsgfj(jset) - 1
1978 block_start_k = sgfk
1979 block_end_k = sgfk + nsgfk(kset) - 1
1980 block_start_i = sgfi
1981 block_end_i = sgfi + nsgfi(iset) - 1
1984 IF (der_j_zero(i_xyz)) cycle
1986 block_j_not_zero(i_xyz) = .true.
1987 CALL abc_contract_xsmm(dijk_contr, dijk_j(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1988 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1989 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1990 nsgfi(iset), cpp_buffer, ccp_buffer)
1992 block_t_j(block_start_j:block_end_j, &
1993 block_start_k:block_end_k, &
1994 block_start_i:block_end_i, i_xyz) = &
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) + &
2003 IF (der_k_zero(i_xyz)) cycle
2005 block_k_not_zero(i_xyz) = .true.
2006 CALL abc_contract_xsmm(dijk_contr, dijk_k(:, :, :, i_xyz), tspj(jset, jkind)%array, &
2007 spk(kset, kkind)%array, spi(iset, ikind)%array, &
2008 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
2009 nsgfi(iset), cpp_buffer, ccp_buffer)
2011 block_t_k(block_start_j:block_end_j, &
2012 block_start_k:block_end_k, &
2013 block_start_i:block_end_i, i_xyz) = &
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) + &
2021 DEALLOCATE (dijk_j, dijk_k, dijk_contr)
2029 block_t_i(:, :, :, i_xyz) = -block_t_j(:, :, :, i_xyz) - block_t_k(:, :, :, i_xyz)
2034 force = pref*sum(ablock(:, :, :)*block_t_i(:, :, :, i_xyz))
2038 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2044 force = pref*sum(ablock(:, :, :)*block_t_j(:, :, :, i_xyz))
2048 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2054 force = pref*sum(ablock(:, :, :)*block_t_k(:, :, :, i_xyz))
2058 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2062 DEALLOCATE (block_t_i, block_t_j, block_t_k)
2063 IF (
PRESENT(der_eps))
THEN
2064 DEALLOCATE (max_contraction_i, max_contraction_j, max_contraction_k, ablock)
2068 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
2069 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
2075 DO iset = 1, max_nset
2076 DO ibasis = 1, nbasis
2077 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
2078 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
2079 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
2083 DEALLOCATE (spi, tspj, spk)
2085 CALL timestop(handle)
2117 nl_3c, basis_i, basis_j, basis_k, &
2118 potential_parameter, int_eps, &
2119 op_pos, do_kpoints, do_hfx_kpoints, desymmetrize, cell_sym, &
2120 bounds_i, bounds_j, bounds_k, &
2121 RI_range, img_to_RI_cell, cell_to_index_ext)
2123 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(INOUT) :: t3c
2124 REAL(kind=
dp),
INTENT(IN) :: filter_eps
2129 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: int_eps
2130 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
2131 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints, &
2132 desymmetrize, cell_sym
2133 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
2134 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
2135 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
2136 INTEGER,
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: cell_to_index_ext
2138 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_3c_integrals'
2140 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
2141 block_start_k, egfi, handle, handle2, i, iatom, ibasis, ikind, ilist,
imax, iset, jatom, &
2142 jcell, jkind, jset, katom, kcell, kkind, kset, m_max, max_ncoj, max_nset, max_nsgfi, &
2143 maxli, maxlj, maxlk, mepos, natom, nbasis, ncell_ri, ncoi, ncoj, ncok, nimg, nseti, &
2144 nsetj, nsetk, nthread, op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk, unit_id
2145 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
2146 INTEGER,
DIMENSION(2) :: bo
2147 INTEGER,
DIMENSION(3) :: blk_idx, blk_size, cell_j, cell_k, &
2148 kp_index_lbounds, kp_index_ubounds,
sp
2149 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
2150 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
2152 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
2153 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2154 LOGICAL :: block_not_zero, cell_sym_prv, debug, &
2155 desymmetrize_prv, do_hfx_kpoints_prv, &
2156 do_kpoints_prv, found, skip
2157 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
2158 kind_radius_i, kind_radius_j, &
2159 kind_radius_k, max_contraction_i, &
2161 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
2162 max_contraction_j, max_contraction_k
2163 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: block_t, dummy_block_t, sijk, &
2165 REAL(kind=
dp),
DIMENSION(1, 1, 1) :: counter
2166 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk
2167 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
2168 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
2169 sphi_k, zeti, zetj, zetk
2174 TYPE(dbt_type) :: t_3c_tmp
2180 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2182 CALL timeset(routinen, handle)
2186 IF (
PRESENT(do_kpoints))
THEN
2187 do_kpoints_prv = do_kpoints
2189 do_kpoints_prv = .false.
2192 IF (
PRESENT(do_hfx_kpoints))
THEN
2193 do_hfx_kpoints_prv = do_hfx_kpoints
2195 do_hfx_kpoints_prv = .false.
2197 IF (do_hfx_kpoints_prv)
THEN
2198 cpassert(do_kpoints_prv)
2199 cpassert(
PRESENT(ri_range))
2200 cpassert(
PRESENT(img_to_ri_cell))
2203 IF (
PRESENT(img_to_ri_cell))
THEN
2204 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
2205 img_to_ri_cell_prv(:) = img_to_ri_cell
2208 IF (
PRESENT(desymmetrize))
THEN
2209 desymmetrize_prv = desymmetrize
2211 desymmetrize_prv = .true.
2214 IF (
PRESENT(cell_sym))
THEN
2215 cell_sym_prv = cell_sym
2217 cell_sym_prv = .false.
2222 IF (
PRESENT(op_pos))
THEN
2228 SELECT CASE (op_pos_prv)
2230 op_ij = potential_parameter%potential_type
2232 op_jk = potential_parameter%potential_type
2235 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
2251 dr_jk = 1000000.0_dp
2252 dr_ik = 1000000.0_dp
2255 NULLIFY (qs_kind_set, atomic_kind_set)
2258 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, cell=cell, &
2259 natom=natom, dft_control=dft_control, para_env=para_env)
2261 IF (do_kpoints_prv)
THEN
2262 IF (
PRESENT(cell_to_index_ext))
THEN
2263 cell_to_index => cell_to_index_ext
2264 nimg = maxval(cell_to_index)
2268 nimg = dft_control%nimages
2271 IF (do_hfx_kpoints_prv)
THEN
2273 ncell_ri =
SIZE(t3c, 2)
2280 CALL alloc_block_3c(t3c, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, &
2281 op_pos=op_pos_prv, do_kpoints=do_kpoints, do_hfx_kpoints=do_hfx_kpoints, &
2282 bounds_i=bounds_i, bounds_j=bounds_j, bounds_k=bounds_k, &
2283 ri_range=ri_range, img_to_ri_cell=img_to_ri_cell, cell_sym=cell_sym_prv, &
2284 cell_to_index=cell_to_index)
2286 IF (do_hfx_kpoints_prv)
THEN
2287 cpassert(op_pos_prv == 2)
2288 cpassert(.NOT. desymmetrize_prv)
2289 ELSE IF (do_kpoints_prv)
THEN
2290 cpassert(all(shape(t3c) == [nimg, ncell_ri]))
2294 nbasis =
SIZE(basis_i)
2298 DO ibasis = 1, nbasis
2300 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
2301 maxli = max(maxli,
imax)
2302 max_nset = max(max_nset, iset)
2303 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
2307 DO ibasis = 1, nbasis
2309 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
2310 maxlj = max(maxlj,
imax)
2311 max_nset = max(max_nset, jset)
2312 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
2315 DO ibasis = 1, nbasis
2317 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
2318 maxlk = max(maxlk,
imax)
2319 max_nset = max(max_nset, kset)
2321 m_max = maxli + maxlj + maxlk
2326 NULLIFY (tspj, spi, spk)
2327 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
2329 DO ibasis = 1, nbasis
2330 DO iset = 1, max_nset
2331 NULLIFY (spi(iset, ibasis)%array)
2332 NULLIFY (tspj(iset, ibasis)%array)
2334 NULLIFY (spk(iset, ibasis)%array)
2339 DO ibasis = 1, nbasis
2340 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
2341 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
2342 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
2344 DO iset = 1, basis_set%nset
2346 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
2347 sgfi = basis_set%first_sgf(1, iset)
2348 egfi = sgfi + basis_set%nsgf_set(iset) - 1
2350 IF (ilist == 1)
THEN
2351 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
2352 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
2354 ELSE IF (ilist == 2)
THEN
2355 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
2356 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
2359 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
2360 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
2372 IF (para_env%mepos == 0)
THEN
2373 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
2375 CALL init(m_max, unit_id, para_env%mepos, para_env)
2376 IF (para_env%mepos == 0)
THEN
2384 IF (do_kpoints_prv)
THEN
2385 kp_index_lbounds = lbound(cell_to_index)
2386 kp_index_ubounds = ubound(cell_to_index)
2418 IF (
PRESENT(bounds_i))
THEN
2419 bo =
get_limit(bounds_i(2) - bounds_i(1) + 1, nthread, mepos)
2420 bo(:) = bo(:) + bounds_i(1) - 1
2421 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
2422 ELSE IF (
PRESENT(bounds_j))
THEN
2424 bo =
get_limit(bounds_j(2) - bounds_j(1) + 1, nthread, mepos)
2425 bo(:) = bo(:) + bounds_j(1) - 1
2426 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bo, bounds_k)
2427 ELSE IF (
PRESENT(bounds_k))
THEN
2428 bo =
get_limit(bounds_k(2) - bounds_k(1) + 1, nthread, mepos)
2429 bo(:) = bo(:) + bounds_k(1) - 1
2430 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bo)
2433 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
2437 IF (bo(1) > bo(2)) skip = .true.
2441 iatom=iatom, jatom=jatom, katom=katom, &
2442 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
2450 IF (jatom == katom)
THEN
2458 IF (iatom == jatom)
THEN
2468 IF (do_kpoints_prv) prefac = 1.0_dp
2470 IF (do_kpoints_prv)
THEN
2472 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
2473 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
2475 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
2476 IF (jcell > nimg .OR. jcell < 1) cycle
2478 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
2479 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
2481 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
2482 IF (kcell > nimg .OR. kcell < 1) cycle
2484 IF (do_hfx_kpoints_prv)
THEN
2485 IF (dik > ri_range) cycle
2486 kcell = img_to_ri_cell_prv(kcell)
2489 jcell = 1; kcell = 1
2492 IF (cell_sym_prv .AND. jcell < kcell) cycle
2494 blk_idx = [iatom, jatom, katom]
2495 IF (do_hfx_kpoints_prv)
THEN
2496 blk_idx(3) = (kcell - 1)*natom + katom
2500 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
2501 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
2502 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
2503 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
2504 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
2505 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
2506 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
2508 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
2509 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
2510 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
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 IF (
PRESENT(int_eps))
THEN
2515 ALLOCATE (max_contraction_j(nsetj))
2517 sgfj = first_sgf_j(1, jset)
2518 max_contraction_j(jset) = maxval([(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)])
2521 ALLOCATE (max_contraction_k(nsetk))
2523 sgfk = first_sgf_k(1, kset)
2524 max_contraction_k(kset) = maxval([(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)])
2528 CALL dbt_blk_sizes(t3c(jcell, kcell), blk_idx, blk_size)
2530 ALLOCATE (block_t(blk_size(2), blk_size(3), blk_size(1)), source=0.0_dp)
2532 block_not_zero = .false.
2535 sgfi = first_sgf_i(1, iset)
2536 max_contraction_i = maxval([(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)])
2540 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
2544 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
2545 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
2547 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
2548 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
2549 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
2552 IF (ncoj*ncok*ncoi == 0) cycle
2559 ALLOCATE (sijk(ncoj, ncok, ncoi))
2560 IF (op_pos_prv == 1)
THEN
2561 sijk(:, :, :) = 0.0_dp
2563 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
2564 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
2565 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
2566 djk, dij, dik, lib, potential_parameter, int_abc_ext=sijk_ext)
2568 ALLOCATE (tmp_ijk(ncoi, ncoj, ncok), source=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 IF (
PRESENT(int_eps))
THEN
2644 DEALLOCATE (max_contraction_j, max_contraction_k)
2648 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
2649 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
2656 IF (nl_3c%sym ==
symmetric_jk .OR. do_kpoints_prv)
THEN
2658 IF (.NOT. do_hfx_kpoints_prv)
THEN
2662 CALL dbt_filter(t3c(jcell, kcell), filter_eps/2)
2666 DO kcell = 1, ncell_ri
2668 CALL dbt_filter(t3c(jcell, kcell), filter_eps)
2673 IF (desymmetrize_prv)
THEN
2675 CALL dbt_create(t3c(1, 1), t_3c_tmp)
2678 CALL dbt_copy(t3c(jcell, kcell), t_3c_tmp)
2679 CALL dbt_copy(t_3c_tmp, t3c(kcell, jcell), order=[1, 3, 2], summation=.true., move_data=.true.)
2680 CALL dbt_filter(t3c(kcell, jcell), filter_eps)
2683 DO kcell = jcell + 1, nimg
2685 CALL dbt_copy(t3c(jcell, kcell), t_3c_tmp)
2686 CALL dbt_copy(t_3c_tmp, t3c(kcell, jcell), order=[1, 3, 2], summation=.false., move_data=.true.)
2687 CALL dbt_filter(t3c(kcell, jcell), filter_eps)
2690 CALL dbt_destroy(t_3c_tmp)
2695 CALL dbt_filter(t3c(jcell, kcell), filter_eps/2)
2701 CALL dbt_filter(t3c(jcell, kcell), filter_eps)
2705 cpabort(
"requested symmetric case not implemented")
2708 DO ibasis = 1, nbasis
2709 DO iset = 1, max_nset
2710 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
2711 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
2712 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
2715 DEALLOCATE (spi, tspj, spk)
2717 CALL timestop(handle)
2733 nl_2c, basis_i, basis_j, &
2734 potential_parameter, do_kpoints)
2736 TYPE(
dbcsr_type),
DIMENSION(:, :),
INTENT(INOUT) :: t2c_der
2737 REAL(kind=
dp),
INTENT(IN) :: filter_eps
2743 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints
2745 CHARACTER(len=*),
PARAMETER :: routinen =
'build_2c_derivatives'
2747 INTEGER :: handle, i_xyz, iatom, ibasis, icol, ikind,
imax, img, irow, iset, jatom, jkind, &
2748 jset, m_max, maxli, maxlj, natom, ncoi, ncoj, nimg, nseti, nsetj, op_prv, sgfi, sgfj, &
2750 INTEGER,
DIMENSION(3) :: cell_j, kp_index_lbounds, &
2752 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
2754 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
2755 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2756 LOGICAL :: do_kpoints_prv, do_symmetric, found, &
2758 REAL(kind=
dp) :: dab
2759 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dij_contr, dij_rs
2760 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dij
2761 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj
2762 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
2763 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
2772 DIMENSION(:),
POINTER :: nl_iterator
2773 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2775 CALL timeset(routinen, handle)
2777 IF (
PRESENT(do_kpoints))
THEN
2778 do_kpoints_prv = do_kpoints
2780 do_kpoints_prv = .false.
2783 op_prv = potential_parameter%potential_type
2785 NULLIFY (qs_kind_set, atomic_kind_set, block_t(1)%block, block_t(2)%block, block_t(3)%block, cell_to_index)
2788 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
2789 natom=natom, kpoints=kpoints, dft_control=dft_control, para_env=para_env)
2791 IF (do_kpoints_prv)
THEN
2792 nimg =
SIZE(t2c_der, 1)
2794 kp_index_lbounds = lbound(cell_to_index)
2795 kp_index_ubounds = ubound(cell_to_index)
2801 cpassert(
SIZE(nl_2c) > 0)
2804 IF (do_symmetric)
THEN
2826 DO ibasis = 1,
SIZE(basis_i)
2828 maxli = max(maxli,
imax)
2831 DO ibasis = 1,
SIZE(basis_j)
2833 maxlj = max(maxlj,
imax)
2836 m_max = maxli + maxlj + 1
2842 IF (para_env%mepos == 0)
THEN
2843 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
2845 CALL init(m_max, unit_id, para_env%mepos, para_env)
2846 IF (para_env%mepos == 0)
THEN
2861 iatom=iatom, jatom=jatom, r=rij, cell=cell_j)
2862 IF (do_kpoints_prv)
THEN
2863 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
2864 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
2865 img = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
2866 IF (img > nimg .OR. img < 1) cycle
2871 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
2872 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
2873 sphi=sphi_i, zet=zeti)
2875 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
2876 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
2877 sphi=sphi_j, zet=zetj)
2879 IF (do_symmetric)
THEN
2880 IF (iatom <= jatom)
THEN
2893 trans = do_symmetric .AND. (iatom > jatom)
2897 row=irow, col=icol, block=block_t(i_xyz)%block, found=found)
2903 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
2904 sgfi = first_sgf_i(1, iset)
2908 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
2909 sgfj = first_sgf_j(1, jset)
2911 IF (ncoi*ncoj > 0)
THEN
2912 ALLOCATE (dij_contr(nsgfi(iset), nsgfj(jset)))
2913 ALLOCATE (dij(ncoi, ncoj, 3), source=0.0_dp)
2918 CALL eri_2center_derivs(dij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
2919 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
2920 rpgf_j(:, jset), rj, dab, lib, potential_parameter)
2924 dij_contr(:, :) = 0.0_dp
2926 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
2927 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
2931 ALLOCATE (dij_rs(nsgfj(jset), nsgfi(iset)))
2932 dij_rs(:, :) = -1.0_dp*transpose(dij_contr)
2934 ALLOCATE (dij_rs(nsgfi(iset), nsgfj(jset)))
2935 dij_rs(:, :) = dij_contr
2939 nsgfi(iset), nsgfj(jset), block_t(i_xyz)%block, &
2940 sgfi, sgfj, trans=trans)
2944 DEALLOCATE (dij, dij_contr)
2960 CALL timestop(handle)
2976 SUBROUTINE calc_2c_virial(work_virial, t2c_trace, pref, qs_env, nl_2c, basis_i, basis_j, potential_parameter)
2977 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: work_virial
2979 REAL(kind=
dp),
INTENT(IN) :: pref
2986 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_2c_virial'
2988 INTEGER :: handle, i_xyz, iatom, ibasis, ikind,
imax, iset, j_xyz, jatom, jkind, jset, &
2989 m_max, maxli, maxlj, natom, ncoi, ncoj, nseti, nsetj, op_prv, sgfi, sgfj, unit_id
2990 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
2992 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
2993 LOGICAL :: do_symmetric, found
2995 REAL(
dp),
DIMENSION(:, :),
POINTER :: pblock
2996 REAL(kind=
dp) :: dab
2997 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dij_contr
2998 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dij
2999 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj, scoord
3000 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
3001 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
3009 DIMENSION(:),
POINTER :: nl_iterator
3011 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3013 CALL timeset(routinen, handle)
3015 op_prv = potential_parameter%potential_type
3017 NULLIFY (qs_kind_set, atomic_kind_set, pblock, particle_set, cell)
3020 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
3021 natom=natom, dft_control=dft_control, para_env=para_env, &
3022 particle_set=particle_set, cell=cell)
3025 cpassert(
SIZE(nl_2c) > 0)
3027 cpassert(.NOT. do_symmetric)
3030 DO ibasis = 1,
SIZE(basis_i)
3032 maxli = max(maxli,
imax)
3035 DO ibasis = 1,
SIZE(basis_j)
3037 maxlj = max(maxlj,
imax)
3040 m_max = maxli + maxlj + 1
3046 IF (para_env%mepos == 0)
THEN
3047 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
3049 CALL init(m_max, unit_id, para_env%mepos, para_env)
3050 IF (para_env%mepos == 0)
THEN
3065 iatom=iatom, jatom=jatom, r=rij)
3067 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
3068 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
3069 sphi=sphi_i, zet=zeti)
3071 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
3072 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
3073 sphi=sphi_j, zet=zetj)
3078 IF (.NOT. found) cycle
3082 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
3083 sgfi = first_sgf_i(1, iset)
3087 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
3088 sgfj = first_sgf_j(1, jset)
3090 IF (ncoi*ncoj > 0)
THEN
3091 ALLOCATE (dij_contr(nsgfi(iset), nsgfj(jset)))
3092 ALLOCATE (dij(ncoi, ncoj, 3), source=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)), source=0.0_dp)
3338 ALLOCATE (sij(ncoi, ncoj), source=0.0_dp)
3343 CALL eri_2center(sij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
3344 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
3345 rpgf_j(:, jset), rj, dab, lib, potential_parameter)
3348 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
3349 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
3353 ALLOCATE (sij_rs(nsgfj(jset), nsgfi(iset)))
3354 sij_rs(:, :) = transpose(sij_contr)
3356 ALLOCATE (sij_rs(nsgfi(iset), nsgfj(jset)))
3357 sij_rs(:, :) = sij_contr
3360 DEALLOCATE (sij_contr)
3363 IF (.NOT. do_hfx_kpoints_prv .AND.
PRESENT(regularization_ri) .AND. &
3364 iatom == jatom .AND. iset == jset .AND. &
3365 cell_j(1) == 0 .AND. cell_j(2) == 0 .AND. cell_j(3) == 0)
THEN
3366 DO i_diag = 1, nsgfi(iset)
3367 min_zet = minval(zeti(:, iset))
3368 cpassert(min_zet > 1.0e-10_dp)
3369 sij_rs(i_diag, i_diag) = sij_rs(i_diag, i_diag) + &
3370 regularization_ri*max(1.0_dp, 1.0_dp/min_zet)
3375 nsgfi(iset), nsgfj(jset), block_t%block, &
3376 sgfi, sgfj, trans=trans)
3392 CALL timestop(handle)
3405 TYPE(dbt_type),
INTENT(INOUT) ::
tensor
3406 INTEGER,
ALLOCATABLE,
DIMENSION(:, :), &
3407 INTENT(INOUT) :: blk_indices
3409 REAL(
dp),
INTENT(IN) :: eps
3410 REAL(
dp),
INTENT(INOUT) :: memory
3412 INTEGER :: buffer_left, buffer_size, buffer_start, &
3413 i, iblk, memory_usage, nbits, nblk, &
3414 nints, offset, shared_offset
3415 INTEGER(int_8) :: estimate_to_store_int, &
3416 storage_counter_integrals
3417 INTEGER,
DIMENSION(3) :: ind
3419 REAL(
dp) :: spherical_estimate
3420 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :),
TARGET :: blk_data
3421 REAL(
dp),
DIMENSION(:),
POINTER :: blk_data_1d
3422 TYPE(dbt_iterator_type) :: iter
3431 maxval_container => compressed%maxval_container(1)
3432 integral_containers => compressed%integral_containers(:, 1)
3439 maxval_cache => compressed%maxval_cache(1)
3440 integral_caches => compressed%integral_caches(:, 1)
3442 IF (
ALLOCATED(blk_indices))
DEALLOCATE (blk_indices)
3443 ALLOCATE (blk_indices(dbt_get_num_blocks(
tensor), 3))
3447 CALL dbt_iterator_start(iter,
tensor)
3448 nblk = dbt_iterator_num_blocks(iter)
3450 offset = shared_offset
3451 shared_offset = shared_offset + nblk
3454 CALL dbt_iterator_next_block(iter, ind)
3455 blk_indices(offset + iblk, :) = ind(:)
3457 CALL dbt_iterator_stop(iter)
3461 DO i = 1,
SIZE(blk_indices, 1)
3462 ind = blk_indices(i, :)
3463 CALL dbt_get_block(
tensor, ind, blk_data, found)
3465 nints =
SIZE(blk_data)
3466 blk_data_1d(1:nints) => blk_data
3467 spherical_estimate = maxval(abs(blk_data_1d))
3468 IF (spherical_estimate == 0.0_dp) spherical_estimate = tiny(spherical_estimate)
3469 estimate_to_store_int = exponent(spherical_estimate)
3470 estimate_to_store_int = max(estimate_to_store_int, -15_int_8)
3473 maxval_cache, maxval_container, memory_usage, &
3476 spherical_estimate = set_exponent(1.0_dp, estimate_to_store_int + 1)
3478 nbits = exponent(anint(spherical_estimate/eps)) + 1
3479 IF (nbits > 64)
THEN
3480 CALL cp_abort(__location__, &
3481 "Overflow during tensor compression. Please use a larger EPS_FILTER or EPS_STORAGE_SCALING")
3487 DO WHILE (buffer_left > 0)
3488 buffer_size = min(buffer_left, cache_size)
3490 buffer_size, nbits, &
3491 integral_caches(nbits), &
3492 integral_containers(nbits), &
3496 buffer_left = buffer_left - buffer_size
3497 buffer_start = buffer_start + buffer_size
3500 NULLIFY (blk_data_1d);
DEALLOCATE (blk_data)
3505 storage_counter_integrals = memory_usage*cache_size
3506 memory = memory + real(storage_counter_integrals,
dp)/1024/128
3514 memory_usage, .false.)
3520 memory_usage, .false.)
3534 TYPE(dbt_type),
INTENT(INOUT) ::
tensor
3535 INTEGER,
DIMENSION(:, :) :: blk_indices
3537 REAL(
dp),
INTENT(IN) :: eps
3539 INTEGER :: a, b, buffer_left, buffer_size, &
3540 buffer_start, i, memory_usage, nbits, &
3541 nblk_per_thread, nints
3542 INTEGER(int_8) :: estimate_to_store_int
3543 INTEGER,
DIMENSION(3) :: blk_size, ind
3544 REAL(
dp) :: spherical_estimate
3545 REAL(
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: blk_data
3546 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: blk_data_3d
3552 maxval_cache => compressed%maxval_cache(1)
3553 maxval_container => compressed%maxval_container(1)
3554 integral_caches => compressed%integral_caches(:, 1)
3555 integral_containers => compressed%integral_containers(:, 1)
3563 memory_usage, .false.)
3568 nblk_per_thread =
SIZE(blk_indices, 1)/omp_get_num_threads() + 1
3569 a = omp_get_thread_num()*nblk_per_thread + 1
3570 b = min(a + nblk_per_thread,
SIZE(blk_indices, 1))
3571 CALL dbt_reserve_blocks(
tensor, blk_indices(a:b, :))
3575 DO i = 1,
SIZE(blk_indices, 1)
3576 ind = blk_indices(i, :)
3577 CALL dbt_blk_sizes(
tensor, ind, blk_size)
3578 nints = product(blk_size)
3580 estimate_to_store_int, 6, &
3581 maxval_cache, maxval_container, memory_usage, &
3584 spherical_estimate = set_exponent(1.0_dp, estimate_to_store_int + 1)
3586 nbits = exponent(anint(spherical_estimate/eps)) + 1
3591 ALLOCATE (blk_data(nints))
3592 DO WHILE (buffer_left > 0)
3593 buffer_size = min(buffer_left, cache_size)
3595 buffer_size, nbits, &
3596 integral_caches(nbits), &
3597 integral_containers(nbits), &
3601 buffer_left = buffer_left - buffer_size
3602 buffer_start = buffer_start + buffer_size
3605 blk_data_3d(1:blk_size(1), 1:blk_size(2), 1:blk_size(3)) => blk_data
3606 CALL dbt_put_block(
tensor, ind, blk_size, blk_data_3d)
3607 NULLIFY (blk_data_3d);
DEALLOCATE (blk_data)
3613 memory_usage, .false.)
3624 TYPE(dbt_type),
INTENT(IN) ::
tensor
3625 INTEGER(int_8),
INTENT(OUT) :: nze
3626 REAL(
dp),
INTENT(OUT) :: occ
3628 INTEGER,
DIMENSION(dbt_ndims(tensor)) :: dims
3630 nze = dbt_get_nze_total(
tensor)
3631 CALL dbt_get_info(
tensor, nfull_total=dims)
3632 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, 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, 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, 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)
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.