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
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), j_present(nkind))
188 ALLOCATE (i_radius(nkind), j_radius(nkind))
195 IF (
PRESENT(dist_2d)) dist_2d_prv => dist_2d
202 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
203 i_present(ikind) = .true.
204 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, kind_radius=i_radius(ikind))
206 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
207 j_present(ikind) = .true.
208 CALL get_gto_basis_set(basis_j(ikind)%gto_basis_set, kind_radius=j_radius(ikind))
216 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
217 i_present(ikind) = .true.
218 IF (pot_to_rad_prv == 1) i_radius(ikind) = 1000000.0_dp
220 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
221 j_present(ikind) = .true.
222 IF (pot_to_rad_prv == 2) j_radius(ikind) = 1000000.0_dp
232 IF (
ASSOCIATED(basis_i(ikind)%gto_basis_set))
THEN
233 i_present(ikind) = .true.
234 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, kind_radius=i_radius(ikind))
235 IF (pot_to_rad_prv == 1) i_radius(ikind) = i_radius(ikind) +
cutoff_screen_factor*potential_parameter%cutoff_radius
237 IF (
ASSOCIATED(basis_j(ikind)%gto_basis_set))
THEN
238 j_present(ikind) = .true.
239 CALL get_gto_basis_set(basis_j(ikind)%gto_basis_set, kind_radius=j_radius(ikind))
240 IF (pot_to_rad_prv == 2) j_radius(ikind) = j_radius(ikind) +
cutoff_screen_factor*potential_parameter%cutoff_radius
245 cpabort(
"Operator not implemented.")
248 ALLOCATE (pair_radius(nkind, nkind))
252 ALLOCATE (atom2d(nkind))
254 CALL atom2d_build(atom2d, local_particles, dist_2d_prv, atomic_kind_set, &
255 molecule_set, molecule_only=.false., particle_set=particle_set)
257 symmetric=sym_ij, molecular=molecular, nlname=trim(name))
281 dist_3d, potential_parameter, name, qs_env, &
282 sym_ij, sym_jk, sym_ik, molecular, op_pos, &
288 CHARACTER(LEN=*),
INTENT(IN) :: name
290 LOGICAL,
INTENT(IN),
OPTIONAL :: sym_ij, sym_jk, sym_ik, molecular
291 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
292 LOGICAL,
INTENT(IN),
OPTIONAL :: own_dist
294 CHARACTER(len=*),
PARAMETER :: routinen =
'build_3c_neighbor_lists'
296 INTEGER :: handle, op_pos_prv, sym_level
299 CALL timeset(routinen, handle)
301 IF (
PRESENT(op_pos))
THEN
307 SELECT CASE (op_pos_prv)
309 pot_par_1 = potential_parameter
312 pot_par_2 = potential_parameter
317 qs_env, sym_ij=.false., molecular=molecular, &
318 dist_2d=dist_3d%dist_2d_1, pot_to_rad=1)
321 qs_env, sym_ij=.false., molecular=molecular, &
322 dist_2d=dist_3d%dist_2d_2, pot_to_rad=2)
327 IF (
PRESENT(sym_ij))
THEN
330 sym_level = sym_level + 1
334 IF (
PRESENT(sym_jk))
THEN
337 sym_level = sym_level + 1
341 IF (
PRESENT(sym_ik))
THEN
344 sym_level = sym_level + 1
348 IF (sym_level >= 2)
THEN
352 ijk_list%dist_3d = dist_3d
353 IF (
PRESENT(own_dist))
THEN
354 ijk_list%owns_dist = own_dist
356 ijk_list%owns_dist = .false.
359 CALL timestop(handle)
368 PURE FUNCTION include_symmetric(a, b)
369 INTEGER,
INTENT(IN) :: a, b
370 LOGICAL :: include_symmetric
373 include_symmetric = (
modulo(a + b, 2) /= 0)
375 include_symmetric = (
modulo(a + b, 2) == 0)
390 IF (ijk_list%owns_dist)
THEN
405 CHARACTER(len=*),
PARAMETER :: routinen =
'neighbor_list_3c_iterator_create'
409 CALL timeset(routinen, handle)
414 iterator%iter_level = 0
415 iterator%ijk_nl = ijk_nl
417 iterator%bounds_i = 0
418 iterator%bounds_j = 0
419 iterator%bounds_k = 0
421 CALL timestop(handle)
431 SUBROUTINE nl_3c_iter_set_bounds(iterator, bounds_i, bounds_j, bounds_k)
433 INTENT(INOUT) :: iterator
434 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
436 IF (
PRESENT(bounds_i)) iterator%bounds_i = bounds_i
437 IF (
PRESENT(bounds_j)) iterator%bounds_j = bounds_j
438 IF (
PRESENT(bounds_k)) iterator%bounds_k = bounds_k
448 INTENT(INOUT) :: iterator
450 CHARACTER(len=*),
PARAMETER :: routinen =
'neighbor_list_3c_iterator_destroy'
454 CALL timeset(routinen, handle)
457 NULLIFY (iterator%iter_ij)
458 NULLIFY (iterator%iter_jk)
460 CALL timestop(handle)
470 INTENT(INOUT) :: iterator
473 INTEGER :: iatom, iter_level, jatom, jatom_1, &
477 iter_level = iterator%iter_level
479 IF (iter_level == 0)
THEN
482 IF (iter_stat /= 0)
THEN
488 IF ((iterator%bounds_i(1) > 0 .AND. iatom < iterator%bounds_i(1)) &
489 .OR. (iterator%bounds_i(2) > 0 .AND. iatom > iterator%bounds_i(2))) skip_this = .true.
490 IF ((iterator%bounds_j(1) > 0 .AND. jatom < iterator%bounds_j(1)) &
491 .OR. (iterator%bounds_j(2) > 0 .AND. jatom > iterator%bounds_j(2))) skip_this = .true.
500 IF (iter_stat /= 0)
THEN
501 iterator%iter_level = 0
505 iterator%iter_level = 1
508 cpassert(iter_stat == 0)
509 cpassert(iterator%iter_level == 1)
513 cpassert(jatom_1 == jatom_2)
517 IF ((iterator%bounds_k(1) > 0 .AND. katom < iterator%bounds_k(1)) &
518 .OR. (iterator%bounds_k(2) > 0 .AND. katom > iterator%bounds_k(2))) skip_this = .true.
525 SELECT CASE (iterator%ijk_nl%sym)
529 skip_this = .NOT. include_symmetric(iatom, jatom)
531 skip_this = .NOT. include_symmetric(jatom, katom)
533 skip_this = .NOT. include_symmetric(iatom, katom)
535 skip_this = .NOT. include_symmetric(iatom, jatom) .OR. .NOT. include_symmetric(jatom, katom)
537 cpabort(
"should not happen")
565 rij, rjk, rik, cell_j, cell_k)
567 INTENT(INOUT) :: iterator
568 INTEGER,
INTENT(OUT),
OPTIONAL :: ikind, jkind, kkind, nkind, iatom, &
570 REAL(kind=
dp),
DIMENSION(3),
INTENT(OUT),
OPTIONAL :: rij, rjk, rik
571 INTEGER,
DIMENSION(3),
INTENT(OUT),
OPTIONAL :: cell_j, cell_k
573 INTEGER,
DIMENSION(2) :: atoms_1, atoms_2, kinds_1, kinds_2
574 INTEGER,
DIMENSION(3) :: cell_1, cell_2
575 REAL(kind=
dp),
DIMENSION(3) :: r_1, r_2
577 cpassert(iterator%iter_level == 1)
580 ikind=kinds_1(1), jkind=kinds_1(2), nkind=nkind, &
581 iatom=atoms_1(1), jatom=atoms_1(2), r=r_1, &
585 ikind=kinds_2(1), jkind=kinds_2(2), &
586 iatom=atoms_2(1), jatom=atoms_2(2), r=r_2, &
589 IF (
PRESENT(ikind)) ikind = kinds_1(1)
590 IF (
PRESENT(jkind)) jkind = kinds_1(2)
591 IF (
PRESENT(kkind)) kkind = kinds_2(2)
592 IF (
PRESENT(iatom)) iatom = atoms_1(1)
593 IF (
PRESENT(jatom)) jatom = atoms_1(2)
594 IF (
PRESENT(katom)) katom = atoms_2(2)
596 IF (
PRESENT(rij)) rij = r_1
597 IF (
PRESENT(rjk)) rjk = r_2
598 IF (
PRESENT(rik)) rik = r_1 + r_2
600 IF (
PRESENT(cell_j)) cell_j = cell_1
601 IF (
PRESENT(cell_k)) cell_k = cell_1 + cell_2
627 SUBROUTINE alloc_block_3c(t3c, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, op_pos, &
628 do_kpoints, do_hfx_kpoints, bounds_i, bounds_j, bounds_k, RI_range, &
629 img_to_RI_cell, cell_to_index, cell_sym)
630 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(INOUT) :: t3c
635 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
636 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
637 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
638 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
639 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
640 INTEGER,
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: cell_to_index
641 LOGICAL,
INTENT(IN),
OPTIONAL :: cell_sym
643 CHARACTER(LEN=*),
PARAMETER :: routinen =
'alloc_block_3c'
645 INTEGER :: handle, iatom, ikind, j_img, jatom, &
646 jcell, jkind, k_img, katom, kcell, &
647 kkind, natom, ncell_ri, nimg, op_ij, &
649 INTEGER(int_8) :: a, b, nblk_per_thread
650 INTEGER(int_8),
ALLOCATABLE,
DIMENSION(:, :) :: nblk
651 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
652 INTEGER,
DIMENSION(3) :: blk_idx, cell_j, cell_k, &
653 kp_index_lbounds, kp_index_ubounds
654 LOGICAL :: cell_sym_prv, do_hfx_kpoints_prv, &
656 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
657 kind_radius_i, kind_radius_j, &
659 REAL(kind=
dp),
DIMENSION(3) :: rij, rik, rjk
665 TYPE(one_dim_int_array),
ALLOCATABLE, &
666 DIMENSION(:, :) :: alloc_i, alloc_j, alloc_k
667 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
669 CALL timeset(routinen, handle)
670 NULLIFY (qs_kind_set, atomic_kind_set, cell)
672 IF (
PRESENT(do_kpoints))
THEN
673 do_kpoints_prv = do_kpoints
675 do_kpoints_prv = .false.
677 IF (
PRESENT(do_hfx_kpoints))
THEN
678 do_hfx_kpoints_prv = do_hfx_kpoints
680 do_hfx_kpoints_prv = .false.
682 IF (do_hfx_kpoints_prv)
THEN
683 cpassert(do_kpoints_prv)
684 cpassert(
PRESENT(ri_range))
685 cpassert(
PRESENT(img_to_ri_cell))
688 IF (
PRESENT(img_to_ri_cell))
THEN
689 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
690 img_to_ri_cell_prv(:) = img_to_ri_cell
693 IF (
PRESENT(cell_sym))
THEN
694 cell_sym_prv = cell_sym
696 cell_sym_prv = .false.
699 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
703 IF (
PRESENT(op_pos))
THEN
709 SELECT CASE (op_pos_prv)
711 op_ij = potential_parameter%potential_type
713 op_jk = potential_parameter%potential_type
734 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, natom=natom, &
735 dft_control=dft_control, para_env=para_env, cell=cell)
737 IF (do_kpoints_prv)
THEN
738 cpassert(
PRESENT(cell_to_index))
739 cpassert(
ASSOCIATED(cell_to_index))
741 nimg = maxval(cell_to_index)
743 IF (do_hfx_kpoints_prv)
THEN
745 ncell_ri =
SIZE(t3c, 2)
752 IF (do_kpoints_prv)
THEN
753 kp_index_lbounds = lbound(cell_to_index)
754 kp_index_ubounds = ubound(cell_to_index)
758 ALLOCATE (nblk(nimg, ncell_ri))
763 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bounds_k)
767 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
773 IF (do_kpoints_prv)
THEN
775 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
776 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
778 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
779 IF (jcell > nimg .OR. jcell < 1) cycle
781 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
782 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
784 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
785 IF (kcell > nimg .OR. kcell < 1) cycle
786 IF (do_hfx_kpoints_prv)
THEN
787 IF (dik > ri_range) cycle
798 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
799 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
800 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
802 nblk(jcell, kcell) = nblk(jcell, kcell) + 1
807 ALLOCATE (alloc_i(nimg, ncell_ri))
808 ALLOCATE (alloc_j(nimg, ncell_ri))
809 ALLOCATE (alloc_k(nimg, ncell_ri))
810 DO k_img = 1, ncell_ri
812 ALLOCATE (alloc_i(j_img, k_img)%array(nblk(j_img, k_img)))
813 ALLOCATE (alloc_j(j_img, k_img)%array(nblk(j_img, k_img)))
814 ALLOCATE (alloc_k(j_img, k_img)%array(nblk(j_img, k_img)))
821 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bounds_k)
825 iatom=iatom, jatom=jatom, katom=katom, &
826 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
832 IF (do_kpoints_prv)
THEN
834 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
835 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
837 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
838 IF (jcell > nimg .OR. jcell < 1) cycle
840 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
841 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
843 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
844 IF (kcell > nimg .OR. kcell < 1) cycle
845 IF (do_hfx_kpoints_prv)
THEN
846 IF (dik > ri_range) cycle
847 kcell = img_to_ri_cell_prv(kcell)
853 blk_idx = [iatom, jatom, katom]
854 IF (do_hfx_kpoints_prv)
THEN
855 blk_idx(3) = (kcell - 1)*natom + katom
863 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
864 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
865 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
867 nblk(jcell, kcell) = nblk(jcell, kcell) + 1
870 alloc_i(jcell, kcell)%array(nblk(jcell, kcell)) = blk_idx(1)
871 alloc_j(jcell, kcell)%array(nblk(jcell, kcell)) = blk_idx(2)
872 alloc_k(jcell, kcell)%array(nblk(jcell, kcell)) = blk_idx(3)
880 DO k_img = 1, ncell_ri
882 IF (cell_sym_prv .AND. j_img < k_img) cycle
883 IF (
ALLOCATED(alloc_i(j_img, k_img)%array))
THEN
884 nblk_per_thread = nblk(j_img, k_img)/omp_get_num_threads() + 1
885 a = omp_get_thread_num()*nblk_per_thread + 1
886 b = min(a + nblk_per_thread, nblk(j_img, k_img))
887 CALL dbt_reserve_blocks(t3c(j_img, k_img), &
888 alloc_i(j_img, k_img)%array(a:b), &
889 alloc_j(j_img, k_img)%array(a:b), &
890 alloc_k(j_img, k_img)%array(a:b))
896 CALL timestop(handle)
925 nl_3c, basis_i, basis_j, basis_k, &
926 potential_parameter, der_eps, &
927 op_pos, do_kpoints, do_hfx_kpoints, &
928 bounds_i, bounds_j, bounds_k, &
929 RI_range, img_to_RI_cell)
931 TYPE(dbt_type),
DIMENSION(:, :, :),
INTENT(INOUT) :: t3c_der_i, t3c_der_k
932 REAL(kind=
dp),
INTENT(IN) :: filter_eps
937 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: der_eps
938 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
939 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
940 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
941 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
942 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
944 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_3c_derivatives'
946 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
947 block_start_k, egfi, handle, handle2, i, i_img, i_xyz, iatom, ibasis, ikind, ilist,
imax, &
948 iset, j_img, jatom, jcell, jkind, jset, katom, kcell, kkind, kset, m_max, max_ncoj, &
949 max_nset, max_nsgfi, maxli, maxlj, maxlk, mepos, natom, nbasis, ncell_ri, ncoi, ncoj, &
950 ncok, nimg, nseti, nsetj, nsetk, nthread, op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk, &
952 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
953 INTEGER,
DIMENSION(2) :: bo
954 INTEGER,
DIMENSION(3) :: blk_idx, blk_size, cell_j, cell_k, &
955 kp_index_lbounds, kp_index_ubounds,
sp
956 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
957 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
959 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
960 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
961 LOGICAL :: do_hfx_kpoints_prv, do_kpoints_prv, &
963 LOGICAL,
DIMENSION(3) :: block_j_not_zero, block_k_not_zero, &
964 der_j_zero, der_k_zero
965 REAL(
dp),
DIMENSION(3) :: der_ext_i, der_ext_j, der_ext_k
966 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
967 kind_radius_i, kind_radius_j, &
968 kind_radius_k, prefac
969 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
970 max_contraction_i, max_contraction_j, &
972 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dijk_contr, dummy_block_t
973 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: block_t_i, block_t_j, block_t_k, dijk_j, &
974 dijk_k, tmp_ijk_i, tmp_ijk_j
975 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk
976 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
977 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
978 sphi_k, zeti, zetj, zetk
982 TYPE(dbt_type) :: t3c_tmp
983 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t3c_template
984 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: t3c_der_j
990 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
992 CALL timeset(routinen, handle)
994 IF (
PRESENT(do_kpoints))
THEN
995 do_kpoints_prv = do_kpoints
997 do_kpoints_prv = .false.
1000 IF (
PRESENT(do_hfx_kpoints))
THEN
1001 do_hfx_kpoints_prv = do_hfx_kpoints
1003 do_hfx_kpoints_prv = .false.
1005 IF (do_hfx_kpoints_prv)
THEN
1006 cpassert(do_kpoints_prv)
1007 cpassert(
PRESENT(ri_range))
1008 cpassert(
PRESENT(img_to_ri_cell))
1011 IF (
PRESENT(img_to_ri_cell))
THEN
1012 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
1013 img_to_ri_cell_prv(:) = img_to_ri_cell
1018 IF (
PRESENT(op_pos))
THEN
1024 SELECT CASE (op_pos_prv)
1026 op_ij = potential_parameter%potential_type
1028 op_jk = potential_parameter%potential_type
1031 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
1038 dr_ij = 1000000.0_dp
1039 dr_ik = 1000000.0_dp
1047 dr_jk = 1000000.0_dp
1048 dr_ik = 1000000.0_dp
1051 NULLIFY (qs_kind_set, atomic_kind_set)
1054 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
1055 natom=natom, kpoints=kpoints, dft_control=dft_control, para_env=para_env)
1057 IF (do_kpoints_prv)
THEN
1058 nimg = dft_control%nimages
1060 IF (do_hfx_kpoints_prv)
THEN
1061 nimg =
SIZE(t3c_der_k, 1)
1062 ncell_ri =
SIZE(t3c_der_k, 2)
1070 IF (do_hfx_kpoints_prv)
THEN
1071 cpassert(op_pos_prv == 2)
1073 cpassert(all(shape(t3c_der_k) == [nimg, ncell_ri, 3]))
1076 ALLOCATE (t3c_template(nimg, ncell_ri))
1077 DO j_img = 1, ncell_ri
1079 CALL dbt_create(t3c_der_i(i_img, j_img, 1), t3c_template(i_img, j_img))
1083 CALL alloc_block_3c(t3c_template, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, &
1084 op_pos=op_pos_prv, do_kpoints=do_kpoints, do_hfx_kpoints=do_hfx_kpoints, &
1085 bounds_i=bounds_i, bounds_j=bounds_j, bounds_k=bounds_k, &
1086 ri_range=ri_range, img_to_ri_cell=img_to_ri_cell, cell_to_index=cell_to_index)
1088 DO j_img = 1, ncell_ri
1090 CALL dbt_copy(t3c_template(i_img, j_img), t3c_der_i(i_img, j_img, i_xyz))
1091 CALL dbt_copy(t3c_template(i_img, j_img), t3c_der_k(i_img, j_img, i_xyz))
1096 DO j_img = 1, ncell_ri
1098 CALL dbt_destroy(t3c_template(i_img, j_img))
1101 DEALLOCATE (t3c_template)
1104 ALLOCATE (t3c_der_j(nimg, ncell_ri, 3))
1106 DO j_img = 1, ncell_ri
1108 CALL dbt_create(t3c_der_k(i_img, j_img, i_xyz), t3c_der_j(i_img, j_img, i_xyz))
1109 CALL dbt_copy(t3c_der_k(i_img, j_img, i_xyz), t3c_der_j(i_img, j_img, i_xyz))
1116 nbasis =
SIZE(basis_i)
1120 DO ibasis = 1, nbasis
1122 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
1123 maxli = max(maxli,
imax)
1124 max_nset = max(max_nset, iset)
1125 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
1129 DO ibasis = 1, nbasis
1131 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
1132 maxlj = max(maxlj,
imax)
1133 max_nset = max(max_nset, jset)
1134 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
1137 DO ibasis = 1, nbasis
1139 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
1140 maxlk = max(maxlk,
imax)
1141 max_nset = max(max_nset, kset)
1143 m_max = maxli + maxlj + maxlk + 1
1148 NULLIFY (tspj, spi, spk)
1149 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
1151 DO ibasis = 1, nbasis
1152 DO iset = 1, max_nset
1153 NULLIFY (spi(iset, ibasis)%array)
1154 NULLIFY (tspj(iset, ibasis)%array)
1155 NULLIFY (spk(iset, ibasis)%array)
1160 DO ibasis = 1, nbasis
1161 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
1162 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
1163 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
1165 DO iset = 1, basis_set%nset
1167 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
1168 sgfi = basis_set%first_sgf(1, iset)
1169 egfi = sgfi + basis_set%nsgf_set(iset) - 1
1171 IF (ilist == 1)
THEN
1172 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1173 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1175 ELSE IF (ilist == 2)
THEN
1176 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
1177 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
1180 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1181 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1193 IF (para_env%mepos == 0)
THEN
1194 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
1196 CALL init(m_max, unit_id, para_env%mepos, para_env)
1197 IF (para_env%mepos == 0)
THEN
1205 IF (do_kpoints_prv)
THEN
1206 kp_index_lbounds = lbound(cell_to_index)
1207 kp_index_ubounds = ubound(cell_to_index)
1237 IF (
PRESENT(bounds_i))
THEN
1238 bo =
get_limit(bounds_i(2) - bounds_i(1) + 1, nthread, mepos)
1239 bo(:) = bo(:) + bounds_i(1) - 1
1240 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
1241 ELSE IF (
PRESENT(bounds_j))
THEN
1242 bo =
get_limit(bounds_j(2) - bounds_j(1) + 1, nthread, mepos)
1243 bo(:) = bo(:) + bounds_j(1) - 1
1244 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bo, bounds_k)
1245 ELSE IF (
PRESENT(bounds_k))
THEN
1246 bo =
get_limit(bounds_k(2) - bounds_k(1) + 1, nthread, mepos)
1247 bo(:) = bo(:) + bounds_k(1) - 1
1248 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bo)
1251 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
1255 IF (bo(1) > bo(2)) skip = .true.
1259 iatom=iatom, jatom=jatom, katom=katom, &
1260 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
1267 IF (do_kpoints_prv)
THEN
1270 IF (jatom == katom)
THEN
1278 IF (do_hfx_kpoints_prv) prefac = 1.0_dp
1280 IF (do_kpoints_prv)
THEN
1282 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
1283 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
1285 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
1286 IF (jcell > nimg .OR. jcell < 1) cycle
1288 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
1289 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
1291 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
1292 IF (kcell > nimg .OR. kcell < 1) cycle
1294 IF (do_hfx_kpoints_prv)
THEN
1295 IF (dik > ri_range) cycle
1296 kcell = img_to_ri_cell_prv(kcell)
1299 jcell = 1; kcell = 1
1302 blk_idx = [iatom, jatom, katom]
1303 IF (do_hfx_kpoints_prv)
THEN
1304 blk_idx(3) = (kcell - 1)*natom + katom
1308 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
1309 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
1310 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
1312 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
1313 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
1314 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
1316 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
1317 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
1318 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
1320 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
1321 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
1322 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
1324 ALLOCATE (max_contraction_i(nseti))
1325 max_contraction_i = 0.0_dp
1327 sgfi = first_sgf_i(1, iset)
1328 max_contraction_i(iset) = maxval((/(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)/))
1331 ALLOCATE (max_contraction_j(nsetj))
1332 max_contraction_j = 0.0_dp
1334 sgfj = first_sgf_j(1, jset)
1335 max_contraction_j(jset) = maxval((/(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)/))
1338 ALLOCATE (max_contraction_k(nsetk))
1339 max_contraction_k = 0.0_dp
1341 sgfk = first_sgf_k(1, kset)
1342 max_contraction_k(kset) = maxval((/(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)/))
1345 CALL dbt_blk_sizes(t3c_der_i(jcell, kcell, 1), blk_idx, blk_size)
1347 ALLOCATE (block_t_i(blk_size(2), blk_size(3), blk_size(1), 3))
1348 ALLOCATE (block_t_j(blk_size(2), blk_size(3), blk_size(1), 3))
1349 ALLOCATE (block_t_k(blk_size(2), blk_size(3), blk_size(1), 3))
1354 block_j_not_zero = .false.
1355 block_k_not_zero = .false.
1361 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
1365 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
1366 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
1368 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
1369 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
1370 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
1372 sgfi = first_sgf_i(1, iset)
1373 sgfj = first_sgf_j(1, jset)
1374 sgfk = first_sgf_k(1, kset)
1376 IF (ncoj*ncok*ncoi > 0)
THEN
1377 ALLOCATE (dijk_j(ncoj, ncok, ncoi, 3))
1378 ALLOCATE (dijk_k(ncoj, ncok, ncoi, 3))
1379 dijk_j(:, :, :, :) = 0.0_dp
1380 dijk_k(:, :, :, :) = 0.0_dp
1382 der_j_zero = .false.
1383 der_k_zero = .false.
1390 IF (op_pos_prv == 1)
THEN
1392 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1393 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1394 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1395 djk, dij, dik, lib, potential_parameter, &
1396 der_abc_1_ext=der_ext_j, der_abc_2_ext=der_ext_k)
1398 ALLOCATE (tmp_ijk_i(ncoi, ncoj, ncok, 3))
1399 ALLOCATE (tmp_ijk_j(ncoi, ncoj, ncok, 3))
1400 tmp_ijk_i(:, :, :, :) = 0.0_dp
1401 tmp_ijk_j(:, :, :, :) = 0.0_dp
1404 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1405 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1406 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1407 dij, dik, djk, lib, potential_parameter, &
1408 der_abc_1_ext=der_ext_i, der_abc_2_ext=der_ext_j)
1414 dijk_j(:, :, i, i_xyz) = tmp_ijk_j(i, :, :, i_xyz)
1415 dijk_k(:, :, i, i_xyz) = -(dijk_j(:, :, i, i_xyz) + tmp_ijk_i(i, :, :, i_xyz))
1416 der_ext_k(i_xyz) = max(der_ext_k(i_xyz), maxval(abs(dijk_k(:, :, i, i_xyz))))
1419 DEALLOCATE (tmp_ijk_i, tmp_ijk_j)
1423 IF (
PRESENT(der_eps))
THEN
1425 IF (der_eps > der_ext_j(i_xyz)*(max_contraction_i(iset)* &
1426 max_contraction_j(jset)* &
1427 max_contraction_k(kset)))
THEN
1428 der_j_zero(i_xyz) = .true.
1433 IF (der_eps > der_ext_k(i_xyz)*(max_contraction_i(iset)* &
1434 max_contraction_j(jset)* &
1435 max_contraction_k(kset)))
THEN
1436 der_k_zero(i_xyz) = .true.
1439 IF (all(der_j_zero) .AND. all(der_k_zero))
THEN
1440 DEALLOCATE (dijk_j, dijk_k)
1445 ALLOCATE (dijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
1447 block_start_j = sgfj
1448 block_end_j = sgfj + nsgfj(jset) - 1
1449 block_start_k = sgfk
1450 block_end_k = sgfk + nsgfk(kset) - 1
1451 block_start_i = sgfi
1452 block_end_i = sgfi + nsgfi(iset) - 1
1455 IF (der_j_zero(i_xyz)) cycle
1457 block_j_not_zero(i_xyz) = .true.
1458 CALL abc_contract_xsmm(dijk_contr, dijk_j(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1459 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1460 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1461 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
1463 block_t_j(block_start_j:block_end_j, &
1464 block_start_k:block_end_k, &
1465 block_start_i:block_end_i, i_xyz) = &
1466 block_t_j(block_start_j:block_end_j, &
1467 block_start_k:block_end_k, &
1468 block_start_i:block_end_i, i_xyz) + &
1474 IF (der_k_zero(i_xyz)) cycle
1476 block_k_not_zero(i_xyz) = .true.
1477 CALL abc_contract_xsmm(dijk_contr, dijk_k(:, :, :, i_xyz), tspj(jset, jkind)%array, &
1478 spk(kset, kkind)%array, spi(iset, ikind)%array, &
1479 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
1480 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
1482 block_t_k(block_start_j:block_end_j, &
1483 block_start_k:block_end_k, &
1484 block_start_i:block_end_i, i_xyz) = &
1485 block_t_k(block_start_j:block_end_j, &
1486 block_start_k:block_end_k, &
1487 block_start_i:block_end_i, i_xyz) + &
1492 DEALLOCATE (dijk_j, dijk_k, dijk_contr)
1498 CALL timeset(routinen//
"_put_dbcsr", handle2)
1500 sp = shape(block_t_i(:, :, :, 1))
1505 IF ((.NOT. block_j_not_zero(i_xyz)) .AND. (.NOT. block_k_not_zero(i_xyz))) cycle
1506 block_t_i(:, :, :, i_xyz) = -(block_t_j(:, :, :, i_xyz) + block_t_k(:, :, :, i_xyz))
1508 CALL dbt_put_block(t3c_der_i(jcell, kcell, i_xyz), blk_idx,
sp, &
1509 reshape(block_t_i(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1513 sp = shape(block_t_k(:, :, :, 1))
1517 IF (.NOT. block_k_not_zero(i_xyz)) cycle
1518 CALL dbt_put_block(t3c_der_k(jcell, kcell, i_xyz), blk_idx,
sp, &
1519 reshape(block_t_k(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1525 sp = shape(block_t_j(:, :, :, 1))
1529 IF (.NOT. block_j_not_zero(i_xyz)) cycle
1530 CALL dbt_put_block(t3c_der_j(jcell, kcell, i_xyz), blk_idx,
sp, &
1531 reshape(block_t_j(:, :, :, i_xyz), shape=
sp, order=[2, 3, 1]), &
1537 CALL timestop(handle2)
1539 DEALLOCATE (block_t_i, block_t_j, block_t_k)
1540 DEALLOCATE (max_contraction_i, max_contraction_j, max_contraction_k)
1543 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
1544 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
1550 IF (do_kpoints_prv .AND. .NOT. do_hfx_kpoints_prv)
THEN
1555 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps/2)
1556 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps/2)
1563 CALL dbt_create(t3c_der_k(1, 1, 1), t3c_tmp)
1567 CALL dbt_copy(t3c_der_j(jcell, kcell, i_xyz), t3c_der_k(jcell, kcell, i_xyz), &
1568 order=[1, 3, 2], move_data=.true., summation=.true.)
1569 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps)
1571 CALL dbt_copy(t3c_der_i(jcell, kcell, i_xyz), t3c_tmp)
1572 CALL dbt_copy(t3c_tmp, t3c_der_i(jcell, kcell, i_xyz), &
1573 order=[1, 3, 2], move_data=.true., summation=.true.)
1574 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps)
1578 CALL dbt_destroy(t3c_tmp)
1582 DO kcell = 1, ncell_ri
1584 CALL dbt_filter(t3c_der_i(jcell, kcell, i_xyz), filter_eps)
1585 CALL dbt_filter(t3c_der_k(jcell, kcell, i_xyz), filter_eps)
1590 cpabort(
"requested symmetric case not implemented")
1597 CALL dbt_destroy(t3c_der_j(i_img, j_img, i_xyz))
1603 DO iset = 1, max_nset
1604 DO ibasis = 1, nbasis
1605 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
1606 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
1607 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
1611 DEALLOCATE (spi, tspj, spk)
1613 CALL timestop(handle)
1634 nl_3c, basis_i, basis_j, basis_k, &
1635 potential_parameter, der_eps, op_pos)
1637 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: work_virial
1638 TYPE(dbt_type),
INTENT(INOUT) :: t3c_trace
1639 REAL(kind=
dp),
INTENT(IN) :: pref
1644 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: der_eps
1645 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
1647 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_3c_virial'
1649 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
1650 block_start_k, egfi, handle, i, i_xyz, iatom, ibasis, ikind, ilist,
imax, iset, j_xyz, &
1651 jatom, jkind, jset, katom, kkind, kset, m_max, max_ncoj, max_nset, max_nsgfi, maxli, &
1652 maxlj, maxlk, mepos, natom, nbasis, ncoi, ncoj, ncok, nseti, nsetj, nsetk, nthread, &
1653 op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk, unit_id
1654 INTEGER,
DIMENSION(2) :: bo
1655 INTEGER,
DIMENSION(3) :: blk_size,
sp
1656 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
1657 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
1659 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
1660 LOGICAL :: found, skip
1661 LOGICAL,
DIMENSION(3) :: block_j_not_zero, block_k_not_zero, &
1662 der_j_zero, der_k_zero
1664 REAL(
dp),
DIMENSION(3) :: der_ext_i, der_ext_j, der_ext_k
1665 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
1666 kind_radius_i, kind_radius_j, &
1668 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
1669 max_contraction_i, max_contraction_j, &
1671 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ablock, dijk_contr, tmp_block
1672 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: block_t_i, block_t_j, block_t_k, dijk_j, &
1674 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk, scoord
1675 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
1676 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
1677 sphi_k, zeti, zetj, zetk
1687 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1689 CALL timeset(routinen, handle)
1693 IF (
PRESENT(op_pos))
THEN
1698 cpassert(op_pos == 1)
1701 SELECT CASE (op_pos_prv)
1703 op_ij = potential_parameter%potential_type
1705 op_jk = potential_parameter%potential_type
1708 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
1715 dr_ij = 1000000.0_dp
1716 dr_ik = 1000000.0_dp
1724 dr_jk = 1000000.0_dp
1725 dr_ik = 1000000.0_dp
1728 NULLIFY (qs_kind_set, atomic_kind_set)
1731 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
1732 natom=natom, dft_control=dft_control, para_env=para_env, &
1733 particle_set=particle_set, cell=cell)
1736 nbasis =
SIZE(basis_i)
1740 DO ibasis = 1, nbasis
1742 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
1743 maxli = max(maxli,
imax)
1744 max_nset = max(max_nset, iset)
1745 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
1749 DO ibasis = 1, nbasis
1751 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
1752 maxlj = max(maxlj,
imax)
1753 max_nset = max(max_nset, jset)
1754 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
1757 DO ibasis = 1, nbasis
1759 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
1760 maxlk = max(maxlk,
imax)
1761 max_nset = max(max_nset, kset)
1763 m_max = maxli + maxlj + maxlk + 1
1768 NULLIFY (tspj, spi, spk)
1769 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
1771 DO ibasis = 1, nbasis
1772 DO iset = 1, max_nset
1773 NULLIFY (spi(iset, ibasis)%array)
1774 NULLIFY (tspj(iset, ibasis)%array)
1776 NULLIFY (spk(iset, ibasis)%array)
1781 DO ibasis = 1, nbasis
1782 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
1783 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
1784 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
1786 DO iset = 1, basis_set%nset
1788 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
1789 sgfi = basis_set%first_sgf(1, iset)
1790 egfi = sgfi + basis_set%nsgf_set(iset) - 1
1792 IF (ilist == 1)
THEN
1793 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1794 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1796 ELSE IF (ilist == 2)
THEN
1797 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
1798 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
1801 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
1802 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
1814 IF (para_env%mepos == 0)
THEN
1815 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
1817 CALL init(m_max, unit_id, para_env%mepos, para_env)
1818 IF (para_env%mepos == 0)
THEN
1852 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i=bo)
1855 IF (bo(1) > bo(2)) skip = .true.
1859 iatom=iatom, jatom=jatom, katom=katom, &
1860 rij=rij, rjk=rjk, rik=rik)
1863 CALL dbt_get_block(t3c_trace, [iatom, jatom, katom], tmp_block, found)
1864 IF (.NOT. found) cycle
1866 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
1867 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
1868 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
1870 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
1871 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
1872 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
1874 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
1875 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
1876 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
1882 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
1883 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
1884 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
1886 ALLOCATE (max_contraction_i(nseti))
1887 max_contraction_i = 0.0_dp
1889 sgfi = first_sgf_i(1, iset)
1890 max_contraction_i(iset) = maxval((/(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)/))
1893 ALLOCATE (max_contraction_j(nsetj))
1894 max_contraction_j = 0.0_dp
1896 sgfj = first_sgf_j(1, jset)
1897 max_contraction_j(jset) = maxval((/(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)/))
1900 ALLOCATE (max_contraction_k(nsetk))
1901 max_contraction_k = 0.0_dp
1903 sgfk = first_sgf_k(1, kset)
1904 max_contraction_k(kset) = maxval((/(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)/))
1907 CALL dbt_blk_sizes(t3c_trace, [iatom, jatom, katom], blk_size)
1909 ALLOCATE (block_t_i(blk_size(2), blk_size(3), blk_size(1), 3))
1910 ALLOCATE (block_t_j(blk_size(2), blk_size(3), blk_size(1), 3))
1911 ALLOCATE (block_t_k(blk_size(2), blk_size(3), blk_size(1), 3))
1913 ALLOCATE (ablock(blk_size(2), blk_size(3), blk_size(1)))
1914 DO i = 1, blk_size(1)
1915 ablock(:, :, i) = tmp_block(i, :, :)
1917 DEALLOCATE (tmp_block)
1922 block_j_not_zero = .false.
1923 block_k_not_zero = .false.
1929 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
1933 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
1934 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
1936 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
1937 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
1938 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
1940 sgfi = first_sgf_i(1, iset)
1941 sgfj = first_sgf_j(1, jset)
1942 sgfk = first_sgf_k(1, kset)
1944 IF (ncoj*ncok*ncoi > 0)
THEN
1945 ALLOCATE (dijk_j(ncoj, ncok, ncoi, 3))
1946 ALLOCATE (dijk_k(ncoj, ncok, ncoi, 3))
1947 dijk_j(:, :, :, :) = 0.0_dp
1948 dijk_k(:, :, :, :) = 0.0_dp
1950 der_j_zero = .false.
1951 der_k_zero = .false.
1959 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
1960 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
1961 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
1962 djk, dij, dik, lib, potential_parameter, &
1963 der_abc_1_ext=der_ext_j, der_abc_2_ext=der_ext_k)
1965 IF (
PRESENT(der_eps))
THEN
1967 IF (der_eps > der_ext_j(i_xyz)*(max_contraction_i(iset)* &
1968 max_contraction_j(jset)* &
1969 max_contraction_k(kset)))
THEN
1970 der_j_zero(i_xyz) = .true.
1975 IF (der_eps > der_ext_k(i_xyz)*(max_contraction_i(iset)* &
1976 max_contraction_j(jset)* &
1977 max_contraction_k(kset)))
THEN
1978 der_k_zero(i_xyz) = .true.
1981 IF (all(der_j_zero) .AND. all(der_k_zero))
THEN
1982 DEALLOCATE (dijk_j, dijk_k)
1987 ALLOCATE (dijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
1989 block_start_j = sgfj
1990 block_end_j = sgfj + nsgfj(jset) - 1
1991 block_start_k = sgfk
1992 block_end_k = sgfk + nsgfk(kset) - 1
1993 block_start_i = sgfi
1994 block_end_i = sgfi + nsgfi(iset) - 1
1997 IF (der_j_zero(i_xyz)) cycle
1999 block_j_not_zero(i_xyz) = .true.
2000 CALL abc_contract_xsmm(dijk_contr, dijk_j(:, :, :, i_xyz), tspj(jset, jkind)%array, &
2001 spk(kset, kkind)%array, spi(iset, ikind)%array, &
2002 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
2003 nsgfi(iset), cpp_buffer, ccp_buffer)
2005 block_t_j(block_start_j:block_end_j, &
2006 block_start_k:block_end_k, &
2007 block_start_i:block_end_i, i_xyz) = &
2008 block_t_j(block_start_j:block_end_j, &
2009 block_start_k:block_end_k, &
2010 block_start_i:block_end_i, i_xyz) + &
2016 IF (der_k_zero(i_xyz)) cycle
2018 block_k_not_zero(i_xyz) = .true.
2019 CALL abc_contract_xsmm(dijk_contr, dijk_k(:, :, :, i_xyz), tspj(jset, jkind)%array, &
2020 spk(kset, kkind)%array, spi(iset, ikind)%array, &
2021 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
2022 nsgfi(iset), cpp_buffer, ccp_buffer)
2024 block_t_k(block_start_j:block_end_j, &
2025 block_start_k:block_end_k, &
2026 block_start_i:block_end_i, i_xyz) = &
2027 block_t_k(block_start_j:block_end_j, &
2028 block_start_k:block_end_k, &
2029 block_start_i:block_end_i, i_xyz) + &
2034 DEALLOCATE (dijk_j, dijk_k, dijk_contr)
2042 block_t_i(:, :, :, i_xyz) = -block_t_j(:, :, :, i_xyz) - block_t_k(:, :, :, i_xyz)
2047 force = pref*sum(ablock(:, :, :)*block_t_i(:, :, :, 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_j(:, :, :, i_xyz))
2061 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2067 force = pref*sum(ablock(:, :, :)*block_t_k(:, :, :, i_xyz))
2071 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
2075 DEALLOCATE (block_t_i, block_t_j, block_t_k)
2076 DEALLOCATE (max_contraction_i, max_contraction_j, max_contraction_k, ablock)
2079 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
2080 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
2086 DO iset = 1, max_nset
2087 DO ibasis = 1, nbasis
2088 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
2089 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
2090 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
2094 DEALLOCATE (spi, tspj, spk)
2096 CALL timestop(handle)
2128 nl_3c, basis_i, basis_j, basis_k, &
2129 potential_parameter, int_eps, &
2130 op_pos, do_kpoints, do_hfx_kpoints, desymmetrize, cell_sym, &
2131 bounds_i, bounds_j, bounds_k, &
2132 RI_range, img_to_RI_cell, cell_to_index_ext)
2134 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(INOUT) :: t3c
2135 REAL(kind=
dp),
INTENT(IN) :: filter_eps
2140 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: int_eps
2141 INTEGER,
INTENT(IN),
OPTIONAL :: op_pos
2142 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints, &
2143 desymmetrize, cell_sym
2144 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: bounds_i, bounds_j, bounds_k
2145 REAL(
dp),
INTENT(IN),
OPTIONAL :: ri_range
2146 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: img_to_ri_cell
2147 INTEGER,
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: cell_to_index_ext
2149 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_3c_integrals'
2151 INTEGER :: block_end_i, block_end_j, block_end_k, block_start_i, block_start_j, &
2152 block_start_k, egfi, handle, handle2, i, iatom, ibasis, ikind, ilist,
imax, iset, jatom, &
2153 jcell, jkind, jset, katom, kcell, kkind, kset, m_max, max_ncoj, max_nset, max_nsgfi, &
2154 maxli, maxlj, maxlk, mepos, natom, nbasis, ncell_ri, ncoi, ncoj, ncok, nimg, nseti, &
2155 nsetj, nsetk, nthread, op_ij, op_jk, op_pos_prv, sgfi, sgfj, sgfk, unit_id
2156 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: img_to_ri_cell_prv
2157 INTEGER,
DIMENSION(2) :: bo
2158 INTEGER,
DIMENSION(3) :: blk_idx, blk_size, cell_j, cell_k, &
2159 kp_index_lbounds, kp_index_ubounds,
sp
2160 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmax_k, lmin_i, lmin_j, &
2161 lmin_k, npgfi, npgfj, npgfk, nsgfi, &
2163 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j, first_sgf_k
2164 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2165 LOGICAL :: block_not_zero, cell_sym_prv, debug, &
2166 desymmetrize_prv, do_hfx_kpoints_prv, &
2167 do_kpoints_prv, found, skip
2168 REAL(kind=
dp) :: dij, dik, djk, dr_ij, dr_ik, dr_jk, &
2169 kind_radius_i, kind_radius_j, &
2170 kind_radius_k, max_contraction_i, &
2172 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: ccp_buffer, cpp_buffer, &
2173 max_contraction_j, max_contraction_k
2174 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: block_t, dummy_block_t, sijk, &
2176 REAL(kind=
dp),
DIMENSION(1, 1, 1) :: counter
2177 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rik, rj, rjk, rk
2178 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j, set_radius_k
2179 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, rpgf_k, sphi_i, sphi_j, &
2180 sphi_k, zeti, zetj, zetk
2185 TYPE(dbt_type) :: t_3c_tmp
2191 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2193 CALL timeset(routinen, handle)
2197 IF (
PRESENT(do_kpoints))
THEN
2198 do_kpoints_prv = do_kpoints
2200 do_kpoints_prv = .false.
2203 IF (
PRESENT(do_hfx_kpoints))
THEN
2204 do_hfx_kpoints_prv = do_hfx_kpoints
2206 do_hfx_kpoints_prv = .false.
2208 IF (do_hfx_kpoints_prv)
THEN
2209 cpassert(do_kpoints_prv)
2210 cpassert(
PRESENT(ri_range))
2211 cpassert(
PRESENT(img_to_ri_cell))
2214 IF (
PRESENT(img_to_ri_cell))
THEN
2215 ALLOCATE (img_to_ri_cell_prv(
SIZE(img_to_ri_cell)))
2216 img_to_ri_cell_prv(:) = img_to_ri_cell
2219 IF (
PRESENT(desymmetrize))
THEN
2220 desymmetrize_prv = desymmetrize
2222 desymmetrize_prv = .true.
2225 IF (
PRESENT(cell_sym))
THEN
2226 cell_sym_prv = cell_sym
2228 cell_sym_prv = .false.
2233 IF (
PRESENT(op_pos))
THEN
2239 SELECT CASE (op_pos_prv)
2241 op_ij = potential_parameter%potential_type
2243 op_jk = potential_parameter%potential_type
2246 dr_ij = 0.0_dp; dr_jk = 0.0_dp; dr_ik = 0.0_dp
2253 dr_ij = 1000000.0_dp
2254 dr_ik = 1000000.0_dp
2262 dr_jk = 1000000.0_dp
2263 dr_ik = 1000000.0_dp
2266 NULLIFY (qs_kind_set, atomic_kind_set)
2269 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, cell=cell, &
2270 natom=natom, dft_control=dft_control, para_env=para_env)
2272 IF (do_kpoints_prv)
THEN
2273 IF (
PRESENT(cell_to_index_ext))
THEN
2274 cell_to_index => cell_to_index_ext
2275 nimg = maxval(cell_to_index)
2279 nimg = dft_control%nimages
2282 IF (do_hfx_kpoints_prv)
THEN
2284 ncell_ri =
SIZE(t3c, 2)
2291 CALL alloc_block_3c(t3c, nl_3c, basis_i, basis_j, basis_k, qs_env, potential_parameter, &
2292 op_pos=op_pos_prv, do_kpoints=do_kpoints, do_hfx_kpoints=do_hfx_kpoints, &
2293 bounds_i=bounds_i, bounds_j=bounds_j, bounds_k=bounds_k, &
2294 ri_range=ri_range, img_to_ri_cell=img_to_ri_cell, cell_sym=cell_sym_prv, &
2295 cell_to_index=cell_to_index)
2297 IF (do_hfx_kpoints_prv)
THEN
2298 cpassert(op_pos_prv == 2)
2299 cpassert(.NOT. desymmetrize_prv)
2300 ELSE IF (do_kpoints_prv)
THEN
2301 cpassert(all(shape(t3c) == [nimg, ncell_ri]))
2305 nbasis =
SIZE(basis_i)
2309 DO ibasis = 1, nbasis
2311 nset=iset, nsgf_set=nsgfi, npgf=npgfi)
2312 maxli = max(maxli,
imax)
2313 max_nset = max(max_nset, iset)
2314 max_nsgfi = max(max_nsgfi, maxval(nsgfi))
2318 DO ibasis = 1, nbasis
2320 nset=jset, nsgf_set=nsgfj, npgf=npgfj)
2321 maxlj = max(maxlj,
imax)
2322 max_nset = max(max_nset, jset)
2323 max_ncoj = max(max_ncoj, maxval(npgfj)*
ncoset(maxlj))
2326 DO ibasis = 1, nbasis
2328 nset=kset, nsgf_set=nsgfk, npgf=npgfk)
2329 maxlk = max(maxlk,
imax)
2330 max_nset = max(max_nset, kset)
2332 m_max = maxli + maxlj + maxlk
2337 NULLIFY (tspj, spi, spk)
2338 ALLOCATE (spi(max_nset, nbasis), tspj(max_nset, nbasis), spk(max_nset, nbasis))
2340 DO ibasis = 1, nbasis
2341 DO iset = 1, max_nset
2342 NULLIFY (spi(iset, ibasis)%array)
2343 NULLIFY (tspj(iset, ibasis)%array)
2345 NULLIFY (spk(iset, ibasis)%array)
2350 DO ibasis = 1, nbasis
2351 IF (ilist == 1) basis_set => basis_i(ibasis)%gto_basis_set
2352 IF (ilist == 2) basis_set => basis_j(ibasis)%gto_basis_set
2353 IF (ilist == 3) basis_set => basis_k(ibasis)%gto_basis_set
2355 DO iset = 1, basis_set%nset
2357 ncoi = basis_set%npgf(iset)*
ncoset(basis_set%lmax(iset))
2358 sgfi = basis_set%first_sgf(1, iset)
2359 egfi = sgfi + basis_set%nsgf_set(iset) - 1
2361 IF (ilist == 1)
THEN
2362 ALLOCATE (spi(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
2363 spi(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
2365 ELSE IF (ilist == 2)
THEN
2366 ALLOCATE (tspj(iset, ibasis)%array(basis_set%nsgf_set(iset), ncoi))
2367 tspj(iset, ibasis)%array(:, :) = transpose(basis_set%sphi(1:ncoi, sgfi:egfi))
2370 ALLOCATE (spk(iset, ibasis)%array(ncoi, basis_set%nsgf_set(iset)))
2371 spk(iset, ibasis)%array(:, :) = basis_set%sphi(1:ncoi, sgfi:egfi)
2383 IF (para_env%mepos == 0)
THEN
2384 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
2386 CALL init(m_max, unit_id, para_env%mepos, para_env)
2387 IF (para_env%mepos == 0)
THEN
2395 IF (do_kpoints_prv)
THEN
2396 kp_index_lbounds = lbound(cell_to_index)
2397 kp_index_ubounds = ubound(cell_to_index)
2429 IF (
PRESENT(bounds_i))
THEN
2430 bo =
get_limit(bounds_i(2) - bounds_i(1) + 1, nthread, mepos)
2431 bo(:) = bo(:) + bounds_i(1) - 1
2432 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
2433 ELSE IF (
PRESENT(bounds_j))
THEN
2435 bo =
get_limit(bounds_j(2) - bounds_j(1) + 1, nthread, mepos)
2436 bo(:) = bo(:) + bounds_j(1) - 1
2437 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bo, bounds_k)
2438 ELSE IF (
PRESENT(bounds_k))
THEN
2439 bo =
get_limit(bounds_k(2) - bounds_k(1) + 1, nthread, mepos)
2440 bo(:) = bo(:) + bounds_k(1) - 1
2441 CALL nl_3c_iter_set_bounds(nl_3c_iter, bounds_i, bounds_j, bo)
2444 CALL nl_3c_iter_set_bounds(nl_3c_iter, bo, bounds_j, bounds_k)
2448 IF (bo(1) > bo(2)) skip = .true.
2452 iatom=iatom, jatom=jatom, katom=katom, &
2453 rij=rij, rjk=rjk, rik=rik, cell_j=cell_j, cell_k=cell_k)
2461 IF (jatom == katom)
THEN
2469 IF (iatom == jatom)
THEN
2479 IF (do_kpoints_prv) prefac = 1.0_dp
2481 IF (do_kpoints_prv)
THEN
2483 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
2484 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
2486 jcell = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
2487 IF (jcell > nimg .OR. jcell < 1) cycle
2489 IF (any([cell_k(1), cell_k(2), cell_k(3)] < kp_index_lbounds) .OR. &
2490 any([cell_k(1), cell_k(2), cell_k(3)] > kp_index_ubounds)) cycle
2492 kcell = cell_to_index(cell_k(1), cell_k(2), cell_k(3))
2493 IF (kcell > nimg .OR. kcell < 1) cycle
2495 IF (do_hfx_kpoints_prv)
THEN
2496 IF (dik > ri_range) cycle
2497 kcell = img_to_ri_cell_prv(kcell)
2500 jcell = 1; kcell = 1
2503 IF (cell_sym_prv .AND. jcell < kcell) cycle
2505 blk_idx = [iatom, jatom, katom]
2506 IF (do_hfx_kpoints_prv)
THEN
2507 blk_idx(3) = (kcell - 1)*natom + katom
2511 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
2512 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
2513 sphi=sphi_i, zet=zeti, kind_radius=kind_radius_i)
2515 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
2516 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
2517 sphi=sphi_j, zet=zetj, kind_radius=kind_radius_j)
2519 CALL get_gto_basis_set(basis_k(kkind)%gto_basis_set, first_sgf=first_sgf_k, lmax=lmax_k, lmin=lmin_k, &
2520 npgf=npgfk, nset=nsetk, nsgf_set=nsgfk, pgf_radius=rpgf_k, set_radius=set_radius_k, &
2521 sphi=sphi_k, zet=zetk, kind_radius=kind_radius_k)
2523 IF (kind_radius_j + kind_radius_i + dr_ij < dij) cycle
2524 IF (kind_radius_j + kind_radius_k + dr_jk < djk) cycle
2525 IF (kind_radius_k + kind_radius_i + dr_ik < dik) cycle
2527 ALLOCATE (max_contraction_j(nsetj))
2529 sgfj = first_sgf_j(1, jset)
2530 max_contraction_j(jset) = maxval((/(sum(abs(sphi_j(:, i))), i=sgfj, sgfj + nsgfj(jset) - 1)/))
2533 ALLOCATE (max_contraction_k(nsetk))
2535 sgfk = first_sgf_k(1, kset)
2536 max_contraction_k(kset) = maxval((/(sum(abs(sphi_k(:, i))), i=sgfk, sgfk + nsgfk(kset) - 1)/))
2539 CALL dbt_blk_sizes(t3c(jcell, kcell), blk_idx, blk_size)
2541 ALLOCATE (block_t(blk_size(2), blk_size(3), blk_size(1)))
2544 block_not_zero = .false.
2547 sgfi = first_sgf_i(1, iset)
2548 max_contraction_i = maxval((/(sum(abs(sphi_i(:, i))), i=sgfi, sgfi + nsgfi(iset) - 1)/))
2552 IF (set_radius_j(jset) + set_radius_i(iset) + dr_ij < dij) cycle
2556 IF (set_radius_j(jset) + set_radius_k(kset) + dr_jk < djk) cycle
2557 IF (set_radius_k(kset) + set_radius_i(iset) + dr_ik < dik) cycle
2559 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
2560 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
2561 ncok = npgfk(kset)*
ncoset(lmax_k(kset))
2564 IF (ncoj*ncok*ncoi == 0) cycle
2571 ALLOCATE (sijk(ncoj, ncok, ncoi))
2572 IF (op_pos_prv == 1)
THEN
2573 sijk(:, :, :) = 0.0_dp
2575 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
2576 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
2577 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
2578 djk, dij, dik, lib, potential_parameter, int_abc_ext=sijk_ext)
2580 ALLOCATE (tmp_ijk(ncoi, ncoj, ncok))
2581 tmp_ijk(:, :, :) = 0.0_dp
2583 lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), rpgf_i(:, iset), ri, &
2584 lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), rpgf_j(:, jset), rj, &
2585 lmin_k(kset), lmax_k(kset), npgfk(kset), zetk(:, kset), rpgf_k(:, kset), rk, &
2586 dij, dik, djk, lib, potential_parameter, int_abc_ext=sijk_ext)
2590 sijk(:, :, i) = tmp_ijk(i, :, :)
2592 DEALLOCATE (tmp_ijk)
2595 IF (
PRESENT(int_eps))
THEN
2596 IF (int_eps > sijk_ext*(max_contraction_i* &
2597 max_contraction_j(jset)* &
2598 max_contraction_k(kset)))
THEN
2604 block_not_zero = .true.
2605 ALLOCATE (sijk_contr(nsgfj(jset), nsgfk(kset), nsgfi(iset)))
2607 spk(kset, kkind)%array, spi(iset, ikind)%array, &
2608 ncoj, ncok, ncoi, nsgfj(jset), nsgfk(kset), &
2609 nsgfi(iset), cpp_buffer, ccp_buffer, prefac)
2612 sgfj = first_sgf_j(1, jset)
2613 sgfk = first_sgf_k(1, kset)
2615 block_start_j = sgfj
2616 block_end_j = sgfj + nsgfj(jset) - 1
2617 block_start_k = sgfk
2618 block_end_k = sgfk + nsgfk(kset) - 1
2619 block_start_i = sgfi
2620 block_end_i = sgfi + nsgfi(iset) - 1
2622 block_t(block_start_j:block_end_j, &
2623 block_start_k:block_end_k, &
2624 block_start_i:block_end_i) = &
2625 block_t(block_start_j:block_end_j, &
2626 block_start_k:block_end_k, &
2627 block_start_i:block_end_i) + &
2629 DEALLOCATE (sijk_contr)
2637 IF (block_not_zero)
THEN
2639 CALL timeset(routinen//
"_put_dbcsr", handle2)
2641 CALL dbt_get_block(t3c(jcell, kcell), blk_idx, dummy_block_t, found=found)
2648 CALL dbt_put_block(t3c(jcell, kcell), blk_idx,
sp, &
2649 reshape(block_t, shape=
sp, order=[2, 3, 1]), summation=.true.)
2651 CALL timestop(handle2)
2655 DEALLOCATE (block_t)
2656 DEALLOCATE (max_contraction_j, max_contraction_k)
2659 IF (
ALLOCATED(ccp_buffer))
DEALLOCATE (ccp_buffer)
2660 IF (
ALLOCATED(cpp_buffer))
DEALLOCATE (cpp_buffer)
2667 IF (nl_3c%sym ==
symmetric_jk .OR. do_kpoints_prv)
THEN
2669 IF (.NOT. do_hfx_kpoints_prv)
THEN
2673 CALL dbt_filter(t3c(jcell, kcell), filter_eps/2)
2677 DO kcell = 1, ncell_ri
2679 CALL dbt_filter(t3c(jcell, kcell), filter_eps)
2684 IF (desymmetrize_prv)
THEN
2686 CALL dbt_create(t3c(1, 1), t_3c_tmp)
2689 CALL dbt_copy(t3c(jcell, kcell), t_3c_tmp)
2690 CALL dbt_copy(t_3c_tmp, t3c(kcell, jcell), order=[1, 3, 2], summation=.true., move_data=.true.)
2691 CALL dbt_filter(t3c(kcell, jcell), filter_eps)
2694 DO kcell = jcell + 1, nimg
2696 CALL dbt_copy(t3c(jcell, kcell), t_3c_tmp)
2697 CALL dbt_copy(t_3c_tmp, t3c(kcell, jcell), order=[1, 3, 2], summation=.false., move_data=.true.)
2698 CALL dbt_filter(t3c(kcell, jcell), filter_eps)
2701 CALL dbt_destroy(t_3c_tmp)
2706 CALL dbt_filter(t3c(jcell, kcell), filter_eps/2)
2712 CALL dbt_filter(t3c(jcell, kcell), filter_eps)
2716 cpabort(
"requested symmetric case not implemented")
2719 DO iset = 1, max_nset
2720 DO ibasis = 1, nbasis
2721 IF (
ASSOCIATED(spi(iset, ibasis)%array))
DEALLOCATE (spi(iset, ibasis)%array)
2722 IF (
ASSOCIATED(tspj(iset, ibasis)%array))
DEALLOCATE (tspj(iset, ibasis)%array)
2723 IF (
ASSOCIATED(spk(iset, ibasis)%array))
DEALLOCATE (spk(iset, ibasis)%array)
2726 DEALLOCATE (spi, tspj, spk)
2728 CALL timestop(handle)
2744 nl_2c, basis_i, basis_j, &
2745 potential_parameter, do_kpoints)
2747 TYPE(
dbcsr_type),
DIMENSION(:, :),
INTENT(INOUT) :: t2c_der
2748 REAL(kind=
dp),
INTENT(IN) :: filter_eps
2754 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints
2756 CHARACTER(len=*),
PARAMETER :: routinen =
'build_2c_derivatives'
2758 INTEGER :: handle, i_xyz, iatom, ibasis, icol, ikind,
imax, img, irow, iset, jatom, jkind, &
2759 jset, m_max, maxli, maxlj, natom, ncoi, ncoj, nimg, nseti, nsetj, op_prv, sgfi, sgfj, &
2761 INTEGER,
DIMENSION(3) :: cell_j, kp_index_lbounds, &
2763 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
2765 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
2766 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
2767 LOGICAL :: do_kpoints_prv, do_symmetric, found, &
2769 REAL(kind=
dp) :: dab
2770 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dij_contr, dij_rs
2771 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dij
2772 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj
2773 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
2774 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
2783 DIMENSION(:),
POINTER :: nl_iterator
2784 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2786 CALL timeset(routinen, handle)
2788 IF (
PRESENT(do_kpoints))
THEN
2789 do_kpoints_prv = do_kpoints
2791 do_kpoints_prv = .false.
2794 op_prv = potential_parameter%potential_type
2796 NULLIFY (qs_kind_set, atomic_kind_set, block_t(1)%block, block_t(2)%block, block_t(3)%block, cell_to_index)
2799 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
2800 natom=natom, kpoints=kpoints, dft_control=dft_control, para_env=para_env)
2802 IF (do_kpoints_prv)
THEN
2803 nimg =
SIZE(t2c_der, 1)
2805 kp_index_lbounds = lbound(cell_to_index)
2806 kp_index_ubounds = ubound(cell_to_index)
2812 cpassert(
SIZE(nl_2c) > 0)
2815 IF (do_symmetric)
THEN
2837 DO ibasis = 1,
SIZE(basis_i)
2839 maxli = max(maxli,
imax)
2842 DO ibasis = 1,
SIZE(basis_j)
2844 maxlj = max(maxlj,
imax)
2847 m_max = maxli + maxlj + 1
2853 IF (para_env%mepos == 0)
THEN
2854 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
2856 CALL init(m_max, unit_id, para_env%mepos, para_env)
2857 IF (para_env%mepos == 0)
THEN
2872 iatom=iatom, jatom=jatom, r=rij, cell=cell_j)
2873 IF (do_kpoints_prv)
THEN
2874 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
2875 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
2876 img = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
2877 IF (img > nimg .OR. img < 1) cycle
2882 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
2883 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
2884 sphi=sphi_i, zet=zeti)
2886 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
2887 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
2888 sphi=sphi_j, zet=zetj)
2890 IF (do_symmetric)
THEN
2891 IF (iatom <= jatom)
THEN
2904 trans = do_symmetric .AND. (iatom > jatom)
2908 row=irow, col=icol, block=block_t(i_xyz)%block, found=found)
2914 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
2915 sgfi = first_sgf_i(1, iset)
2919 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
2920 sgfj = first_sgf_j(1, jset)
2922 IF (ncoi*ncoj > 0)
THEN
2923 ALLOCATE (dij_contr(nsgfi(iset), nsgfj(jset)))
2924 ALLOCATE (dij(ncoi, ncoj, 3))
2925 dij(:, :, :) = 0.0_dp
2930 CALL eri_2center_derivs(dij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
2931 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
2932 rpgf_j(:, jset), rj, dab, lib, potential_parameter)
2936 dij_contr(:, :) = 0.0_dp
2938 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
2939 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
2943 ALLOCATE (dij_rs(nsgfj(jset), nsgfi(iset)))
2944 dij_rs(:, :) = -1.0_dp*transpose(dij_contr)
2946 ALLOCATE (dij_rs(nsgfi(iset), nsgfj(jset)))
2947 dij_rs(:, :) = dij_contr
2951 nsgfi(iset), nsgfj(jset), block_t(i_xyz)%block, &
2952 sgfi, sgfj, trans=trans)
2956 DEALLOCATE (dij, dij_contr)
2972 CALL timestop(handle)
2988 SUBROUTINE calc_2c_virial(work_virial, t2c_trace, pref, qs_env, nl_2c, basis_i, basis_j, potential_parameter)
2989 REAL(
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: work_virial
2991 REAL(kind=
dp),
INTENT(IN) :: pref
2998 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_2c_virial'
3000 INTEGER :: handle, i_xyz, iatom, ibasis, ikind,
imax, iset, j_xyz, jatom, jkind, jset, &
3001 m_max, maxli, maxlj, natom, ncoi, ncoj, nseti, nsetj, op_prv, sgfi, sgfj, unit_id
3002 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
3004 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
3005 LOGICAL :: do_symmetric, found
3007 REAL(
dp),
DIMENSION(:, :),
POINTER :: pblock
3008 REAL(kind=
dp) :: dab
3009 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dij_contr
3010 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: dij
3011 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj, scoord
3012 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
3013 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
3021 DIMENSION(:),
POINTER :: nl_iterator
3023 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3025 CALL timeset(routinen, handle)
3027 op_prv = potential_parameter%potential_type
3029 NULLIFY (qs_kind_set, atomic_kind_set, pblock, particle_set, cell)
3032 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, &
3033 natom=natom, dft_control=dft_control, para_env=para_env, &
3034 particle_set=particle_set, cell=cell)
3037 cpassert(
SIZE(nl_2c) > 0)
3039 cpassert(.NOT. do_symmetric)
3042 DO ibasis = 1,
SIZE(basis_i)
3044 maxli = max(maxli,
imax)
3047 DO ibasis = 1,
SIZE(basis_j)
3049 maxlj = max(maxlj,
imax)
3052 m_max = maxli + maxlj + 1
3058 IF (para_env%mepos == 0)
THEN
3059 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
3061 CALL init(m_max, unit_id, para_env%mepos, para_env)
3062 IF (para_env%mepos == 0)
THEN
3077 iatom=iatom, jatom=jatom, r=rij)
3079 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
3080 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
3081 sphi=sphi_i, zet=zeti)
3083 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
3084 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
3085 sphi=sphi_j, zet=zetj)
3090 IF (.NOT. found) cycle
3094 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
3095 sgfi = first_sgf_i(1, iset)
3099 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
3100 sgfj = first_sgf_j(1, jset)
3102 IF (ncoi*ncoj > 0)
THEN
3103 ALLOCATE (dij_contr(nsgfi(iset), nsgfj(jset)))
3104 ALLOCATE (dij(ncoi, ncoj, 3))
3105 dij(:, :, :) = 0.0_dp
3110 CALL eri_2center_derivs(dij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
3111 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
3112 rpgf_j(:, jset), rj, dab, lib, potential_parameter)
3116 dij_contr(:, :) = 0.0_dp
3118 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
3119 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
3121 force = sum(pblock(sgfi:sgfi + nsgfi(iset) - 1, sgfj:sgfj + nsgfj(jset) - 1)*dij_contr(:, :))
3127 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) + force*scoord(j_xyz)
3133 work_virial(i_xyz, j_xyz) = work_virial(i_xyz, j_xyz) - force*scoord(j_xyz)
3137 DEALLOCATE (dij, dij_contr)
3146 CALL timestop(handle)
3166 nl_2c, basis_i, basis_j, &
3167 potential_parameter, do_kpoints, &
3168 do_hfx_kpoints, ext_kpoints, regularization_RI)
3170 TYPE(
dbcsr_type),
DIMENSION(:),
INTENT(INOUT) :: t2c
3171 REAL(kind=
dp),
INTENT(IN) :: filter_eps
3177 LOGICAL,
INTENT(IN),
OPTIONAL :: do_kpoints, do_hfx_kpoints
3178 TYPE(
kpoint_type),
OPTIONAL,
POINTER :: ext_kpoints
3179 REAL(kind=
dp),
OPTIONAL :: regularization_ri
3181 CHARACTER(len=*),
PARAMETER :: routinen =
'build_2c_integrals'
3183 INTEGER :: handle, i_diag, iatom, ibasis, icol, ikind,
imax, img, irow, iset, jatom, jkind, &
3184 jset, m_max, maxli, maxlj, natom, ncoi, ncoj, nimg, nseti, nsetj, op_prv, sgfi, sgfj, &
3186 INTEGER,
DIMENSION(3) :: cell_j, kp_index_lbounds, &
3188 INTEGER,
DIMENSION(:),
POINTER :: lmax_i, lmax_j, lmin_i, lmin_j, npgfi, &
3190 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf_i, first_sgf_j
3191 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
3192 LOGICAL :: do_hfx_kpoints_prv, do_kpoints_prv, &
3193 do_symmetric, found, trans
3194 REAL(kind=
dp) :: dab, min_zet
3195 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: sij, sij_contr, sij_rs
3196 REAL(kind=
dp),
DIMENSION(3) :: ri, rij, rj
3197 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_i, set_radius_j
3198 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgf_i, rpgf_j, sphi_i, sphi_j, zeti, &
3208 DIMENSION(:),
POINTER :: nl_iterator
3209 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
3211 CALL timeset(routinen, handle)
3213 IF (
PRESENT(do_kpoints))
THEN
3214 do_kpoints_prv = do_kpoints
3216 do_kpoints_prv = .false.
3219 IF (
PRESENT(do_hfx_kpoints))
THEN
3220 do_hfx_kpoints_prv = do_hfx_kpoints
3222 do_hfx_kpoints_prv = .false.
3224 IF (do_hfx_kpoints_prv)
THEN
3225 cpassert(do_kpoints_prv)
3228 op_prv = potential_parameter%potential_type
3230 NULLIFY (qs_kind_set, atomic_kind_set, block_t%block, cell_to_index)
3233 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set, cell=cell, &
3234 natom=natom, dft_control=dft_control, para_env=para_env, kpoints=kpoints)
3236 IF (
PRESENT(ext_kpoints)) kpoints => ext_kpoints
3238 IF (do_kpoints_prv)
THEN
3241 kp_index_lbounds = lbound(cell_to_index)
3242 kp_index_ubounds = ubound(cell_to_index)
3248 cpassert(
SIZE(nl_2c) > 0)
3251 IF (do_symmetric)
THEN
3266 DO ibasis = 1,
SIZE(basis_i)
3268 maxli = max(maxli,
imax)
3271 DO ibasis = 1,
SIZE(basis_j)
3273 maxlj = max(maxlj,
imax)
3276 m_max = maxli + maxlj
3282 IF (para_env%mepos == 0)
THEN
3283 CALL open_file(unit_number=unit_id, file_name=potential_parameter%filename)
3285 CALL init(m_max, unit_id, para_env%mepos, para_env)
3286 IF (para_env%mepos == 0)
THEN
3301 iatom=iatom, jatom=jatom, r=rij, cell=cell_j)
3302 IF (do_kpoints_prv)
THEN
3303 IF (any([cell_j(1), cell_j(2), cell_j(3)] < kp_index_lbounds) .OR. &
3304 any([cell_j(1), cell_j(2), cell_j(3)] > kp_index_ubounds)) cycle
3305 img = cell_to_index(cell_j(1), cell_j(2), cell_j(3))
3306 IF (img > nimg .OR. img < 1) cycle
3311 CALL get_gto_basis_set(basis_i(ikind)%gto_basis_set, first_sgf=first_sgf_i, lmax=lmax_i, lmin=lmin_i, &
3312 npgf=npgfi, nset=nseti, nsgf_set=nsgfi, pgf_radius=rpgf_i, set_radius=set_radius_i, &
3313 sphi=sphi_i, zet=zeti)
3315 CALL get_gto_basis_set(basis_j(jkind)%gto_basis_set, first_sgf=first_sgf_j, lmax=lmax_j, lmin=lmin_j, &
3316 npgf=npgfj, nset=nsetj, nsgf_set=nsgfj, pgf_radius=rpgf_j, set_radius=set_radius_j, &
3317 sphi=sphi_j, zet=zetj)
3319 IF (do_symmetric)
THEN
3320 IF (iatom <= jatom)
THEN
3335 row=irow, col=icol, block=block_t%block, found=found)
3337 trans = do_symmetric .AND. (iatom > jatom)
3341 ncoi = npgfi(iset)*
ncoset(lmax_i(iset))
3342 sgfi = first_sgf_i(1, iset)
3346 ncoj = npgfj(jset)*
ncoset(lmax_j(jset))
3347 sgfj = first_sgf_j(1, jset)
3349 IF (ncoi*ncoj > 0)
THEN
3350 ALLOCATE (sij_contr(nsgfi(iset), nsgfj(jset)))
3351 sij_contr(:, :) = 0.0_dp
3353 ALLOCATE (sij(ncoi, ncoj))
3359 CALL eri_2center(sij, lmin_i(iset), lmax_i(iset), npgfi(iset), zeti(:, iset), &
3360 rpgf_i(:, iset), ri, lmin_j(jset), lmax_j(jset), npgfj(jset), zetj(:, jset), &
3361 rpgf_j(:, jset), rj, dab, lib, potential_parameter)
3364 sphi_i(:, sgfi:), sphi_j(:, sgfj:), &
3365 ncoi, ncoj, nsgfi(iset), nsgfj(jset))
3369 ALLOCATE (sij_rs(nsgfj(jset), nsgfi(iset)))
3370 sij_rs(:, :) = transpose(sij_contr)
3372 ALLOCATE (sij_rs(nsgfi(iset), nsgfj(jset)))
3373 sij_rs(:, :) = sij_contr
3376 DEALLOCATE (sij_contr)
3379 IF (.NOT. do_hfx_kpoints_prv .AND.
PRESENT(regularization_ri) .AND. &
3380 iatom == jatom .AND. iset == jset .AND. &
3381 cell_j(1) == 0 .AND. cell_j(2) == 0 .AND. cell_j(3) == 0)
THEN
3382 DO i_diag = 1, nsgfi(iset)
3383 min_zet = minval(zeti(:, iset))
3384 cpassert(min_zet > 1.0e-10_dp)
3385 sij_rs(i_diag, i_diag) = sij_rs(i_diag, i_diag) + &
3386 regularization_ri*max(1.0_dp, 1.0_dp/min_zet)
3391 nsgfi(iset), nsgfj(jset), block_t%block, &
3392 sgfi, sgfj, trans=trans)
3408 CALL timestop(handle)
3421 TYPE(dbt_type),
INTENT(INOUT) ::
tensor
3422 INTEGER,
ALLOCATABLE,
DIMENSION(:, :), &
3423 INTENT(INOUT) :: blk_indices
3425 REAL(
dp),
INTENT(IN) :: eps
3426 REAL(
dp),
INTENT(INOUT) :: memory
3428 INTEGER :: buffer_left, buffer_size, buffer_start, &
3429 i, iblk, memory_usage, nbits, nblk, &
3430 nints, offset, shared_offset
3431 INTEGER(int_8) :: estimate_to_store_int, &
3432 storage_counter_integrals
3433 INTEGER,
DIMENSION(3) :: ind
3435 REAL(
dp) :: spherical_estimate
3436 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :),
TARGET :: blk_data
3437 REAL(
dp),
DIMENSION(:),
POINTER :: blk_data_1d
3438 TYPE(dbt_iterator_type) :: iter
3447 maxval_container => compressed%maxval_container(1)
3448 integral_containers => compressed%integral_containers(:, 1)
3455 maxval_cache => compressed%maxval_cache(1)
3456 integral_caches => compressed%integral_caches(:, 1)
3458 IF (
ALLOCATED(blk_indices))
DEALLOCATE (blk_indices)
3459 ALLOCATE (blk_indices(dbt_get_num_blocks(
tensor), 3))
3463 CALL dbt_iterator_start(iter,
tensor)
3464 nblk = dbt_iterator_num_blocks(iter)
3466 offset = shared_offset
3467 shared_offset = shared_offset + nblk
3470 CALL dbt_iterator_next_block(iter, ind)
3471 blk_indices(offset + iblk, :) = ind(:)
3473 CALL dbt_iterator_stop(iter)
3477 DO i = 1,
SIZE(blk_indices, 1)
3478 ind = blk_indices(i, :)
3479 CALL dbt_get_block(
tensor, ind, blk_data, found)
3481 nints =
SIZE(blk_data)
3482 blk_data_1d(1:nints) => blk_data
3483 spherical_estimate = maxval(abs(blk_data_1d))
3484 IF (spherical_estimate == 0.0_dp) spherical_estimate = tiny(spherical_estimate)
3485 estimate_to_store_int = exponent(spherical_estimate)
3486 estimate_to_store_int = max(estimate_to_store_int, -15_int_8)
3489 maxval_cache, maxval_container, memory_usage, &
3492 spherical_estimate = set_exponent(1.0_dp, estimate_to_store_int + 1)
3494 nbits = exponent(anint(spherical_estimate/eps)) + 1
3495 IF (nbits > 64)
THEN
3496 CALL cp_abort(__location__, &
3497 "Overflow during tensor compression. Please use a larger EPS_FILTER or EPS_STORAGE_SCALING")
3503 DO WHILE (buffer_left > 0)
3504 buffer_size = min(buffer_left, cache_size)
3506 buffer_size, nbits, &
3507 integral_caches(nbits), &
3508 integral_containers(nbits), &
3512 buffer_left = buffer_left - buffer_size
3513 buffer_start = buffer_start + buffer_size
3516 NULLIFY (blk_data_1d);
DEALLOCATE (blk_data)
3521 storage_counter_integrals = memory_usage*cache_size
3522 memory = memory + real(storage_counter_integrals,
dp)/1024/128
3530 memory_usage, .false.)
3536 memory_usage, .false.)
3550 TYPE(dbt_type),
INTENT(INOUT) ::
tensor
3551 INTEGER,
DIMENSION(:, :) :: blk_indices
3553 REAL(
dp),
INTENT(IN) :: eps
3555 INTEGER :: a, b, buffer_left, buffer_size, &
3556 buffer_start, i, memory_usage, nbits, &
3557 nblk_per_thread, nints
3558 INTEGER(int_8) :: estimate_to_store_int
3559 INTEGER,
DIMENSION(3) :: blk_size, ind
3560 REAL(
dp) :: spherical_estimate
3561 REAL(
dp),
ALLOCATABLE,
DIMENSION(:),
TARGET :: blk_data
3562 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: blk_data_3d
3568 maxval_cache => compressed%maxval_cache(1)
3569 maxval_container => compressed%maxval_container(1)
3570 integral_caches => compressed%integral_caches(:, 1)
3571 integral_containers => compressed%integral_containers(:, 1)
3579 memory_usage, .false.)
3584 nblk_per_thread =
SIZE(blk_indices, 1)/omp_get_num_threads() + 1
3585 a = omp_get_thread_num()*nblk_per_thread + 1
3586 b = min(a + nblk_per_thread,
SIZE(blk_indices, 1))
3587 CALL dbt_reserve_blocks(
tensor, blk_indices(a:b, :))
3591 DO i = 1,
SIZE(blk_indices, 1)
3592 ind = blk_indices(i, :)
3593 CALL dbt_blk_sizes(
tensor, ind, blk_size)
3594 nints = product(blk_size)
3596 estimate_to_store_int, 6, &
3597 maxval_cache, maxval_container, memory_usage, &
3600 spherical_estimate = set_exponent(1.0_dp, estimate_to_store_int + 1)
3602 nbits = exponent(anint(spherical_estimate/eps)) + 1
3607 ALLOCATE (blk_data(nints))
3608 DO WHILE (buffer_left > 0)
3609 buffer_size = min(buffer_left, cache_size)
3611 buffer_size, nbits, &
3612 integral_caches(nbits), &
3613 integral_containers(nbits), &
3617 buffer_left = buffer_left - buffer_size
3618 buffer_start = buffer_start + buffer_size
3621 blk_data_3d(1:blk_size(1), 1:blk_size(2), 1:blk_size(3)) => blk_data
3622 CALL dbt_put_block(
tensor, ind, blk_size, blk_data_3d)
3623 NULLIFY (blk_data_3d);
DEALLOCATE (blk_data)
3629 memory_usage, .false.)
3640 TYPE(dbt_type),
INTENT(IN) ::
tensor
3641 INTEGER(int_8),
INTENT(OUT) :: nze
3642 REAL(
dp),
INTENT(OUT) :: occ
3644 INTEGER,
DIMENSION(dbt_ndims(tensor)) :: dims
3646 nze = dbt_get_nze_total(
tensor)
3647 CALL dbt_get_info(
tensor, nfull_total=dims)
3648 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, 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.