65#include "./base/base_uses.f90"
73 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_overlap'
76 INTEGER,
DIMENSION(1:56),
SAVE :: ndod = [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, &
77 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, &
78 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, &
79 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
82 MODULE PROCEDURE create_sab_matrix_1d, create_sab_matrix_2d
119 nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, &
120 matrix_p, matrixkp_p, ext_kpoints)
126 POINTER :: matrixkp_s
127 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: matrix_name
128 INTEGER,
INTENT(IN),
OPTIONAL :: nderivative
129 CHARACTER(LEN=*),
INTENT(IN) :: basis_type_a, basis_type_b
132 LOGICAL,
INTENT(IN),
OPTIONAL :: calculate_forces
133 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: matrix_p
135 POINTER :: matrixkp_p
136 TYPE(
kpoint_type),
OPTIONAL,
POINTER :: ext_kpoints
144 CALL build_overlap_matrix_low(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, &
145 basis_type_a, basis_type_b, sab_nl, calculate_forces, &
146 matrix_p, matrixkp_p, ext_kpoints, natom)
167 SUBROUTINE build_overlap_matrix_low(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, &
168 basis_type_a, basis_type_b, sab_nl, calculate_forces, &
169 matrix_p, matrixkp_p, ext_kpoints, natom)
175 POINTER :: matrixkp_s
176 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: matrix_name
177 INTEGER,
INTENT(IN),
OPTIONAL :: nderivative
178 CHARACTER(LEN=*),
INTENT(IN) :: basis_type_a, basis_type_b
181 LOGICAL,
INTENT(IN),
OPTIONAL :: calculate_forces
182 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: matrix_p
184 POINTER :: matrixkp_p
185 TYPE(
kpoint_type),
OPTIONAL,
POINTER :: ext_kpoints
186 INTEGER,
INTENT(IN) :: natom
188 CHARACTER(len=*),
PARAMETER :: routinen =
'build_overlap_matrix_low'
190 INTEGER :: atom_a, handle, i, iatom, ic, icol, ikind, irow, iset, jatom, jkind, jset, ldsab, &
191 maxder, maxs, n1, n2, ncoa, ncob, nder, nimg, nkind, nseta, nsetb, sgfa, sgfb, slot
192 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind, kind_of
193 INTEGER,
DIMENSION(3) :: cell
194 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
196 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
197 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
198 LOGICAL :: do_forces, do_symmetric, dokp, found, &
199 trans, use_cell_mapping, use_virial
200 REAL(kind=
dp) :: dab, f, f0, ff, rab2
201 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: owork, pmat
202 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: oint
203 REAL(kind=
dp),
DIMENSION(3) :: force_a, rab
204 REAL(kind=
dp),
DIMENSION(3, 3) :: pv_thread
205 REAL(kind=
dp),
DIMENSION(3, natom) :: force_thread
206 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
207 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, rpgfa, rpgfb, scon_a, scon_b, &
216 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
225 CALL timeset(routinen, handle)
227 NULLIFY (atomic_kind_set)
229 atomic_kind_set=atomic_kind_set, &
230 qs_kind_set=qs_kind_set, &
231 dft_control=dft_control)
234 IF (
PRESENT(matrix_s))
THEN
236 use_cell_mapping = .false.
237 nimg = dft_control%nimages
238 ELSEIF (
PRESENT(matrixkp_s))
THEN
240 IF (
PRESENT(ext_kpoints))
THEN
241 IF (
ASSOCIATED(ext_kpoints))
THEN
243 use_cell_mapping = (
SIZE(cell_to_index) > 1)
244 nimg =
SIZE(ext_kpoints%index_to_cell, 2)
246 use_cell_mapping = .false.
250 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
252 use_cell_mapping = (
SIZE(cell_to_index) > 1)
253 nimg = dft_control%nimages
259 nkind =
SIZE(qs_kind_set)
261 IF (
PRESENT(calculate_forces))
THEN
262 do_forces = calculate_forces
267 IF (
PRESENT(nderivative))
THEN
275 cpassert(
SIZE(sab_nl) > 0)
277 IF (do_symmetric)
THEN
278 cpassert(basis_type_a == basis_type_b)
282 ALLOCATE (basis_set_list_a(nkind), basis_set_list_b(nkind))
288 CALL create_sab_matrix(ks_env, matrixkp_s, matrix_name, basis_set_list_a, basis_set_list_b, &
289 sab_nl, do_symmetric)
292 CALL create_sab_matrix(ks_env, matrix_s, matrix_name, basis_set_list_a, basis_set_list_b, &
293 sab_nl, do_symmetric)
299 CALL get_ks_env(ks_env=ks_env, force=force, virial=virial)
300 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
303 force_thread = 0.0_dp
310 cpassert(
PRESENT(matrixkp_p))
312 cpassert(
PRESENT(matrix_p))
342 ALLOCATE (oint(ldsab, ldsab, maxder), owork(ldsab, ldsab))
343 IF (do_forces)
ALLOCATE (pmat(ldsab, ldsab))
344 ALLOCATE (sint(maxs))
346 NULLIFY (sint(i)%block)
350 DO slot = 1, sab_nl(1)%nl_size
352 ikind = sab_nl(1)%nlist_task(slot)%ikind
353 jkind = sab_nl(1)%nlist_task(slot)%jkind
354 iatom = sab_nl(1)%nlist_task(slot)%iatom
355 jatom = sab_nl(1)%nlist_task(slot)%jatom
356 cell(:) = sab_nl(1)%nlist_task(slot)%cell(:)
357 rab(1:3) = sab_nl(1)%nlist_task(slot)%r(1:3)
359 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
360 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
361 basis_set_b => basis_set_list_b(jkind)%gto_basis_set
362 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
368 first_sgfa => basis_set_a%first_sgf
369 la_max => basis_set_a%lmax
370 la_min => basis_set_a%lmin
371 npgfa => basis_set_a%npgf
372 nseta = basis_set_a%nset
373 nsgfa => basis_set_a%nsgf_set
374 rpgfa => basis_set_a%pgf_radius
375 set_radius_a => basis_set_a%set_radius
376 scon_a => basis_set_a%scon
377 zeta => basis_set_a%zet
379 first_sgfb => basis_set_b%first_sgf
380 lb_max => basis_set_b%lmax
381 lb_min => basis_set_b%lmin
382 npgfb => basis_set_b%npgf
383 nsetb = basis_set_b%nset
384 nsgfb => basis_set_b%nsgf_set
385 rpgfb => basis_set_b%pgf_radius
386 set_radius_b => basis_set_b%set_radius
387 scon_b => basis_set_b%scon
388 zetb => basis_set_b%zet
390 IF (use_cell_mapping)
THEN
391 ic = cell_to_index(cell(1), cell(2), cell(3))
392 IF (ic < 1 .OR. ic > nimg) cycle
397 IF (do_symmetric)
THEN
398 IF (iatom <= jatom)
THEN
407 IF (iatom == jatom) f0 = 1.0_dp
415 NULLIFY (sint(i)%block)
418 row=irow, col=icol, block=sint(i)%block, found=found)
422 row=irow, col=icol, block=sint(i)%block, found=found)
430 row=irow, col=icol, block=p_block, found=found)
434 block=p_block, found=found)
438 trans = do_symmetric .AND. (iatom > jatom)
440 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
445 ncoa = npgfa(iset)*
ncoset(la_max(iset))
446 n1 = npgfa(iset)*(
ncoset(la_max(iset)) -
ncoset(la_min(iset) - 1))
447 sgfa = first_sgfa(1, iset)
451 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
456 ncob = npgfb(jset)*
ncoset(lb_max(jset))
457 n2 = npgfb(jset)*(
ncoset(lb_max(jset)) -
ncoset(lb_min(jset) - 1))
458 sgfb = first_sgfb(1, jset)
463 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
464 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
465 rab, sab=oint(:, :, 1))
467 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
468 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
469 rab, sab=oint(:, :, 1), dab=oint(:, :, 2:4))
471 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
472 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
473 rab, sab=oint(:, :, 1), dab=oint(:, :, 2:4), ddab=oint(:, :, 5:10))
477 IF (do_forces .AND.
ASSOCIATED(p_block) .AND. ((iatom /= jatom) .OR. use_virial))
THEN
480 CALL block_add(
"OUT", owork, nsgfa(iset), nsgfb(jset), p_block, sgfa, sgfb, trans=trans)
481 CALL decontraction(owork, pmat, scon_a(:, sgfa:), n1, nsgfa(iset), scon_b(:, sgfb:), n2, &
482 nsgfb(jset), trans=trans)
483 CALL force_trace(force_a, oint(:, :, 2:4), pmat, n1, n2, 3)
484 force_thread(:, iatom) = force_thread(:, iatom) - ff*force_a(:)
485 force_thread(:, jatom) = force_thread(:, jatom) + ff*force_a(:)
493 IF (ndod(i) == 1 .AND. trans) f = -1.0_dp
494 CALL contraction(oint(:, :, i), owork, ca=scon_a(:, sgfa:), na=n1, ma=nsgfa(iset), &
495 cb=scon_b(:, sgfb:), nb=n2, mb=nsgfb(jset), fscale=f, trans=trans)
497 CALL block_add(
"IN", owork, nsgfa(iset), nsgfb(jset), sint(i)%block, &
498 sgfa, sgfb, trans=trans)
506 IF (do_forces)
DEALLOCATE (pmat)
507 DEALLOCATE (oint, owork)
525 atom_a = atom_of_kind(iatom)
526 ikind = kind_of(iatom)
527 force(ikind)%overlap(:, atom_a) = force(ikind)%overlap(:, atom_a) + force_thread(:, iatom)
531 IF (do_forces .AND. use_virial)
THEN
532 virial%pv_overlap = virial%pv_overlap + pv_thread
533 virial%pv_virial = virial%pv_virial + pv_thread
541 dft_control%qs_control%eps_filter_matrix)
548 dft_control%qs_control%eps_filter_matrix)
553 DEALLOCATE (basis_set_list_a, basis_set_list_b)
555 CALL timestop(handle)
557 END SUBROUTINE build_overlap_matrix_low
573 basis_set_list_a, basis_set_list_b, sab_nl)
581 CHARACTER(len=*),
PARAMETER :: routinen =
'build_overlap_matrix_simple'
583 INTEGER :: handle, iatom, icol, ikind, irow, iset, &
584 jatom, jkind, jset, ldsab, m1, m2, n1, &
585 n2, natom, ncoa, ncob, nkind, nseta, &
586 nsetb, sgfa, sgfb, slot
587 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
589 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
590 LOGICAL :: do_symmetric, found, trans
591 REAL(kind=
dp) :: dab, rab2
592 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: owork
593 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: oint
594 REAL(kind=
dp),
DIMENSION(3) :: rab
595 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
596 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgfa, rpgfb, scon_a, scon_b, zeta, zetb
601 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
609 NULLIFY (dft_control)
611 CALL timeset(routinen, handle)
613 NULLIFY (atomic_kind_set)
615 atomic_kind_set=atomic_kind_set, &
617 qs_kind_set=qs_kind_set, &
618 dft_control=dft_control)
621 cpassert(
SIZE(sab_nl) > 0)
624 nkind =
SIZE(qs_kind_set)
627 CALL create_sab_matrix(ks_env, matrix_s,
"Matrix", basis_set_list_a, basis_set_list_b, &
628 sab_nl, do_symmetric)
632 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
634 ldsab = max(m1, m2, ldsab)
635 basis_set_b => basis_set_list_b(ikind)%gto_basis_set
637 ldsab = max(m1, m2, ldsab)
659 ALLOCATE (oint(ldsab, ldsab, 1), owork(ldsab, ldsab))
661 NULLIFY (sint(1)%block)
664 DO slot = 1, sab_nl(1)%nl_size
665 ikind = sab_nl(1)%nlist_task(slot)%ikind
666 jkind = sab_nl(1)%nlist_task(slot)%jkind
667 iatom = sab_nl(1)%nlist_task(slot)%iatom
668 jatom = sab_nl(1)%nlist_task(slot)%jatom
669 rab(1:3) = sab_nl(1)%nlist_task(slot)%r(1:3)
673 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
674 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
675 basis_set_b => basis_set_list_b(jkind)%gto_basis_set
676 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
678 first_sgfa => basis_set_a%first_sgf
679 la_max => basis_set_a%lmax
680 la_min => basis_set_a%lmin
681 npgfa => basis_set_a%npgf
682 nseta = basis_set_a%nset
683 nsgfa => basis_set_a%nsgf_set
684 rpgfa => basis_set_a%pgf_radius
685 set_radius_a => basis_set_a%set_radius
686 scon_a => basis_set_a%scon
687 zeta => basis_set_a%zet
689 first_sgfb => basis_set_b%first_sgf
690 lb_max => basis_set_b%lmax
691 lb_min => basis_set_b%lmin
692 npgfb => basis_set_b%npgf
693 nsetb = basis_set_b%nset
694 nsgfb => basis_set_b%nsgf_set
695 rpgfb => basis_set_b%pgf_radius
696 set_radius_b => basis_set_b%set_radius
697 scon_b => basis_set_b%scon
698 zetb => basis_set_b%zet
700 IF (do_symmetric)
THEN
701 IF (iatom <= jatom)
THEN
713 NULLIFY (sint(1)%block)
715 row=irow, col=icol, block=sint(1)%block, found=found)
717 trans = do_symmetric .AND. (iatom > jatom)
719 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
724 ncoa = npgfa(iset)*
ncoset(la_max(iset))
725 n1 = npgfa(iset)*(
ncoset(la_max(iset)) -
ncoset(la_min(iset) - 1))
726 sgfa = first_sgfa(1, iset)
730 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
735 ncob = npgfb(jset)*
ncoset(lb_max(jset))
736 n2 = npgfb(jset)*(
ncoset(lb_max(jset)) -
ncoset(lb_min(jset) - 1))
737 sgfb = first_sgfb(1, jset)
740 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
741 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
742 rab, sab=oint(:, :, 1))
744 CALL contraction(oint(:, :, 1), owork, ca=scon_a(:, sgfa:), na=n1, ma=nsgfa(iset), &
745 cb=scon_b(:, sgfb:), nb=n2, mb=nsgfb(jset), fscale=1.0_dp, trans=trans)
747 CALL block_add(
"IN", owork, nsgfa(iset), nsgfb(jset), sint(1)%block, &
748 sgfa, sgfb, trans=trans)
755 DEALLOCATE (oint, owork)
770 CALL dbcsr_filter(matrix_s(1)%matrix, dft_control%qs_control%eps_filter_matrix)
772 CALL timestop(handle)
799 sab_nl, matrix_p, matrixkp_p)
802 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: force
803 CHARACTER(LEN=*),
INTENT(IN) :: basis_type_a, basis_type_b
807 TYPE(
dbcsr_p_type),
DIMENSION(:),
OPTIONAL :: matrixkp_p
809 CHARACTER(len=*),
PARAMETER :: routinen =
'build_overlap_force'
811 INTEGER :: handle, iatom, ic, icol, ikind, irow, iset, jatom, jkind, jset, ldsab, n1, n2, &
812 natom, ncoa, ncob, nder, nimg, nkind, nseta, nsetb, sgfa, sgfb, slot
813 INTEGER,
DIMENSION(3) :: cell
814 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
816 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
817 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
818 LOGICAL :: do_symmetric, dokp, found, trans, &
819 use_cell_mapping, use_virial
820 REAL(kind=
dp) :: dab, f0, ff, rab2
821 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pab, sab
822 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: drab
823 REAL(kind=
dp),
DIMENSION(3) :: force_a, rab
824 REAL(kind=
dp),
DIMENSION(3, 3) :: virial_thread
825 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
826 REAL(kind=
dp),
DIMENSION(3, SIZE(force, 2)) :: force_thread
827 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, rpgfa, rpgfb, scon_a, scon_b, &
833 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
836 CALL timeset(routinen, handle)
838 NULLIFY (qs_kind_set)
839 CALL get_ks_env(ks_env=ks_env, qs_kind_set=qs_kind_set, dft_control=dft_control)
840 nimg = dft_control%nimages
843 IF (
PRESENT(matrix_p))
THEN
845 use_cell_mapping = .false.
846 ELSEIF (
PRESENT(matrixkp_p))
THEN
848 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
850 use_cell_mapping = (
SIZE(cell_to_index) > 1)
855 nkind =
SIZE(qs_kind_set)
859 cpassert(
SIZE(sab_nl) > 0)
863 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
864 virial_thread = 0.0_dp
867 ALLOCATE (basis_set_list_a(nkind), basis_set_list_b(nkind))
872 natom =
SIZE(force, 2)
873 force_thread = 0.0_dp
887 ALLOCATE (sab(ldsab, ldsab), pab(ldsab, ldsab))
888 ALLOCATE (drab(ldsab, ldsab, 3))
892 DO slot = 1, sab_nl(1)%nl_size
893 ikind = sab_nl(1)%nlist_task(slot)%ikind
894 jkind = sab_nl(1)%nlist_task(slot)%jkind
895 iatom = sab_nl(1)%nlist_task(slot)%iatom
896 jatom = sab_nl(1)%nlist_task(slot)%jatom
897 cell(:) = sab_nl(1)%nlist_task(slot)%cell(:)
898 rab(1:3) = sab_nl(1)%nlist_task(slot)%r(1:3)
900 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
901 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
902 basis_set_b => basis_set_list_b(jkind)%gto_basis_set
903 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
905 first_sgfa => basis_set_a%first_sgf
906 la_max => basis_set_a%lmax
907 la_min => basis_set_a%lmin
908 npgfa => basis_set_a%npgf
909 nseta = basis_set_a%nset
910 nsgfa => basis_set_a%nsgf_set
911 rpgfa => basis_set_a%pgf_radius
912 set_radius_a => basis_set_a%set_radius
913 scon_a => basis_set_a%scon
914 zeta => basis_set_a%zet
916 first_sgfb => basis_set_b%first_sgf
917 lb_max => basis_set_b%lmax
918 lb_min => basis_set_b%lmin
919 npgfb => basis_set_b%npgf
920 nsetb = basis_set_b%nset
921 nsgfb => basis_set_b%nsgf_set
922 rpgfb => basis_set_b%pgf_radius
923 set_radius_b => basis_set_b%set_radius
924 scon_b => basis_set_b%scon
925 zetb => basis_set_b%zet
927 IF (use_cell_mapping)
THEN
928 ic = cell_to_index(cell(1), cell(2), cell(3))
929 IF (ic < 1 .OR. ic > nimg) cycle
934 IF (do_symmetric)
THEN
935 IF (iatom <= jatom)
THEN
943 IF (iatom == jatom) f0 = 1.0_dp
954 block=p_block, found=found)
957 block=p_block, found=found)
960 trans = do_symmetric .AND. (iatom > jatom)
962 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
967 ncoa = npgfa(iset)*
ncoset(la_max(iset))
968 n1 = npgfa(iset)*(
ncoset(la_max(iset)) -
ncoset(la_min(iset) - 1))
969 sgfa = first_sgfa(1, iset)
973 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
975 ncob = npgfb(jset)*
ncoset(lb_max(jset))
976 n2 = npgfb(jset)*(
ncoset(lb_max(jset)) -
ncoset(lb_min(jset) - 1))
977 sgfb = first_sgfb(1, jset)
979 IF (
ASSOCIATED(p_block) .AND. ((iatom /= jatom) .OR. use_virial))
THEN
982 CALL block_add(
"OUT", sab, nsgfa(iset), nsgfb(jset), p_block, sgfa, sgfb, trans=trans)
983 CALL decontraction(sab, pab, scon_a(:, sgfa:), n1, nsgfa(iset), scon_b(:, sgfb:), n2, &
984 nsgfb(jset), trans=trans)
986 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
987 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
990 force_thread(1:3, iatom) = force_thread(1:3, iatom) - ff*force_a(1:3)
991 force_thread(1:3, jatom) = force_thread(1:3, jatom) + ff*force_a(1:3)
1001 DEALLOCATE (sab, pab, drab)
1007 force(1:3, 1:natom) = force(1:3, 1:natom) + force_thread(1:3, 1:natom)
1010 IF (use_virial)
THEN
1011 virial%pv_virial = virial%pv_virial + virial_thread
1012 virial%pv_overlap = virial%pv_overlap + virial_thread
1015 DEALLOCATE (basis_set_list_a, basis_set_list_b)
1017 CALL timestop(handle)
1032 SUBROUTINE create_sab_matrix_1d(ks_env, matrix_s, matrix_name, &
1033 basis_set_list_a, basis_set_list_b, sab_nl, symmetric)
1037 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: matrix_name
1041 LOGICAL,
INTENT(IN) :: symmetric
1043 CHARACTER(LEN=12) :: cgfsym
1044 CHARACTER(LEN=32) :: symmetry_string
1045 CHARACTER(LEN=default_string_length) :: mname, name
1046 INTEGER :: i, maxs, natom
1047 INTEGER,
DIMENSION(:),
POINTER :: col_blk_sizes, row_blk_sizes
1050 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1052 CALL get_ks_env(ks_env=ks_env, particle_set=particle_set, &
1053 qs_kind_set=qs_kind_set, dbcsr_dist=dbcsr_dist)
1055 natom =
SIZE(particle_set)
1057 IF (
PRESENT(matrix_name))
THEN
1063 maxs =
SIZE(matrix_s)
1065 ALLOCATE (row_blk_sizes(natom), col_blk_sizes(natom))
1068 basis=basis_set_list_a)
1070 basis=basis_set_list_b)
1074 symmetry_string = dbcsr_type_symmetric
1076 symmetry_string = dbcsr_type_no_symmetry
1081 IF (ndod(i) == 1)
THEN
1083 symmetry_string = dbcsr_type_antisymmetric
1085 symmetry_string = dbcsr_type_symmetric
1088 symmetry_string = dbcsr_type_no_symmetry
1094 name = trim(cgfsym(4:))//
" DERIVATIVE OF THE "//trim(mname)// &
1095 " W.R.T. THE NUCLEAR COORDINATES"
1099 ALLOCATE (matrix_s(i)%matrix)
1102 dist=dbcsr_dist, matrix_type=symmetry_string, &
1103 row_blk_size=row_blk_sizes, col_blk_size=col_blk_sizes)
1107 DEALLOCATE (row_blk_sizes, col_blk_sizes)
1109 END SUBROUTINE create_sab_matrix_1d
1122 SUBROUTINE create_sab_matrix_2d(ks_env, matrix_s, matrix_name, &
1123 basis_set_list_a, basis_set_list_b, sab_nl, symmetric)
1126 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s
1127 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: matrix_name
1131 LOGICAL,
INTENT(IN) :: symmetric
1133 CHARACTER(LEN=12) :: cgfsym
1134 CHARACTER(LEN=32) :: symmetry_string
1135 CHARACTER(LEN=default_string_length) :: mname, name
1136 INTEGER :: i1, i2, natom
1137 INTEGER,
DIMENSION(:),
POINTER :: col_blk_sizes, row_blk_sizes
1140 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1142 CALL get_ks_env(ks_env=ks_env, particle_set=particle_set, &
1143 qs_kind_set=qs_kind_set, dbcsr_dist=dbcsr_dist)
1145 natom =
SIZE(particle_set)
1147 IF (
PRESENT(matrix_name))
THEN
1153 ALLOCATE (row_blk_sizes(natom), col_blk_sizes(natom))
1156 basis=basis_set_list_a)
1158 basis=basis_set_list_b)
1162 symmetry_string = dbcsr_type_symmetric
1164 symmetry_string = dbcsr_type_no_symmetry
1167 DO i2 = 1,
SIZE(matrix_s, 2)
1168 DO i1 = 1,
SIZE(matrix_s, 1)
1170 IF (ndod(i1) == 1)
THEN
1172 symmetry_string = dbcsr_type_antisymmetric
1174 symmetry_string = dbcsr_type_symmetric
1177 symmetry_string = dbcsr_type_no_symmetry
1183 name = trim(cgfsym(4:))//
" DERIVATIVE OF THE "//trim(mname)// &
1184 " W.R.T. THE NUCLEAR COORDINATES"
1188 ALLOCATE (matrix_s(i1, i2)%matrix)
1191 dist=dbcsr_dist, matrix_type=symmetry_string, &
1192 row_blk_size=row_blk_sizes, col_blk_size=col_blk_sizes)
1197 DEALLOCATE (row_blk_sizes, col_blk_sizes)
1199 END SUBROUTINE create_sab_matrix_2d
Set of routines to: Contract integrals over primitive Gaussians Decontract (density) matrices Trace m...
Calculation of the overlap integrals over Cartesian Gaussian-type functions.
subroutine, public overlap_ab(la_max, la_min, npgfa, rpgfa, zeta, lb_max, lb_min, npgfb, rpgfb, zetb, rab, sab, dab, ddab)
Calculation of the two-center overlap integrals [a|b] over Cartesian Gaussian-type functions....
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
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
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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
DBCSR operations in CP2K.
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
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.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :), allocatable, public indco
character(len=12) function, public cgf_symbol(n, lxyz)
Build a Cartesian orbital symbol (orbital labels for printing).
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis)
Get the components of a particle set.
Define the data structure for the particle information.
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
Define the quickstep kind type and their sub types.
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
Define the neighbor list data types and the corresponding functionality.
subroutine, public get_neighbor_list_set_p(neighbor_list_sets, nlist, symmetric)
Return the components of the first neighbor list set.
Calculation of overlap matrix, its derivatives and forces.
subroutine, public build_overlap_force(ks_env, force, basis_type_a, basis_type_b, sab_nl, matrix_p, matrixkp_p)
Calculation of the force contribution from an overlap matrix over Cartesian Gaussian functions.
subroutine, public build_overlap_matrix_simple(ks_env, matrix_s, basis_set_list_a, basis_set_list_b, sab_nl)
Calculation of the overlap matrix over Cartesian Gaussian functions.
subroutine, public build_overlap_matrix(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, matrix_p, matrixkp_p, ext_kpoints)
Calculation of the overlap matrix over Cartesian Gaussian functions.
Utilities for string manipulations.
subroutine, public compress(string, full)
Eliminate multiple space characters in a string. If full is .TRUE., then all spaces are eliminated.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
pure subroutine, public virial_pair_force(pv_virial, f0, force, rab)
Computes the contribution to the stress tensor from two-body pair-wise forces.
Provides all information about an atomic kind.
Contains information about kpoints.
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...