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
118 nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, &
119 matrix_p, matrixkp_p)
125 POINTER :: matrixkp_s
126 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: matrix_name
127 INTEGER,
INTENT(IN),
OPTIONAL :: nderivative
128 CHARACTER(LEN=*),
INTENT(IN) :: basis_type_a, basis_type_b
131 LOGICAL,
INTENT(IN),
OPTIONAL :: calculate_forces
132 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: matrix_p
134 POINTER :: matrixkp_p
142 CALL build_overlap_matrix_low(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, &
143 basis_type_a, basis_type_b, sab_nl, calculate_forces, &
144 matrix_p, matrixkp_p, natom)
164 SUBROUTINE build_overlap_matrix_low(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, &
165 basis_type_a, basis_type_b, sab_nl, calculate_forces, &
166 matrix_p, matrixkp_p, natom)
172 POINTER :: matrixkp_s
173 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: matrix_name
174 INTEGER,
INTENT(IN),
OPTIONAL :: nderivative
175 CHARACTER(LEN=*),
INTENT(IN) :: basis_type_a, basis_type_b
178 LOGICAL,
INTENT(IN),
OPTIONAL :: calculate_forces
179 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: matrix_p
181 POINTER :: matrixkp_p
182 INTEGER,
INTENT(IN) :: natom
184 CHARACTER(len=*),
PARAMETER :: routinen =
'build_overlap_matrix_low'
186 INTEGER :: atom_a, handle, i, iatom, ic, icol, ikind, irow, iset, jatom, jkind, jset, ldsab, &
187 maxder, maxs, n1, n2, ncoa, ncob, nder, nimg, nkind, nseta, nsetb, sgfa, sgfb, slot
188 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind, kind_of
189 INTEGER,
DIMENSION(3) :: cell
190 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
192 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
193 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
194 LOGICAL :: do_forces, do_symmetric, dokp, found, &
195 trans, use_cell_mapping, use_virial
196 REAL(kind=
dp) :: dab, f, f0, ff, rab2
197 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: owork, pmat
198 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: oint
199 REAL(kind=
dp),
DIMENSION(3) :: force_a, rab
200 REAL(kind=
dp),
DIMENSION(3, 3) :: pv_thread
201 REAL(kind=
dp),
DIMENSION(3, natom) :: force_thread
202 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
203 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, rpgfa, rpgfb, scon_a, scon_b, &
212 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
221 CALL timeset(routinen, handle)
224 IF (
PRESENT(matrix_s))
THEN
226 use_cell_mapping = .false.
227 ELSEIF (
PRESENT(matrixkp_s))
THEN
229 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
231 use_cell_mapping = (
SIZE(cell_to_index) > 1)
236 NULLIFY (atomic_kind_set)
238 atomic_kind_set=atomic_kind_set, &
239 qs_kind_set=qs_kind_set, &
240 dft_control=dft_control)
242 nimg = dft_control%nimages
243 nkind =
SIZE(qs_kind_set)
245 IF (
PRESENT(calculate_forces))
THEN
246 do_forces = calculate_forces
251 IF (
PRESENT(nderivative))
THEN
259 cpassert(
SIZE(sab_nl) > 0)
261 IF (do_symmetric)
THEN
262 cpassert(basis_type_a == basis_type_b)
266 ALLOCATE (basis_set_list_a(nkind), basis_set_list_b(nkind))
272 CALL create_sab_matrix(ks_env, matrixkp_s, matrix_name, basis_set_list_a, basis_set_list_b, &
273 sab_nl, do_symmetric)
276 CALL create_sab_matrix(ks_env, matrix_s, matrix_name, basis_set_list_a, basis_set_list_b, &
277 sab_nl, do_symmetric)
283 CALL get_ks_env(ks_env=ks_env, force=force, virial=virial)
284 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
287 force_thread = 0.0_dp
294 cpassert(
PRESENT(matrixkp_p))
296 cpassert(
PRESENT(matrix_p))
326 ALLOCATE (oint(ldsab, ldsab, maxder), owork(ldsab, ldsab))
327 IF (do_forces)
ALLOCATE (pmat(ldsab, ldsab))
328 ALLOCATE (sint(maxs))
330 NULLIFY (sint(i)%block)
334 DO slot = 1, sab_nl(1)%nl_size
336 ikind = sab_nl(1)%nlist_task(slot)%ikind
337 jkind = sab_nl(1)%nlist_task(slot)%jkind
338 iatom = sab_nl(1)%nlist_task(slot)%iatom
339 jatom = sab_nl(1)%nlist_task(slot)%jatom
340 cell(:) = sab_nl(1)%nlist_task(slot)%cell(:)
341 rab(1:3) = sab_nl(1)%nlist_task(slot)%r(1:3)
343 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
344 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
345 basis_set_b => basis_set_list_b(jkind)%gto_basis_set
346 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
352 first_sgfa => basis_set_a%first_sgf
353 la_max => basis_set_a%lmax
354 la_min => basis_set_a%lmin
355 npgfa => basis_set_a%npgf
356 nseta = basis_set_a%nset
357 nsgfa => basis_set_a%nsgf_set
358 rpgfa => basis_set_a%pgf_radius
359 set_radius_a => basis_set_a%set_radius
360 scon_a => basis_set_a%scon
361 zeta => basis_set_a%zet
363 first_sgfb => basis_set_b%first_sgf
364 lb_max => basis_set_b%lmax
365 lb_min => basis_set_b%lmin
366 npgfb => basis_set_b%npgf
367 nsetb = basis_set_b%nset
368 nsgfb => basis_set_b%nsgf_set
369 rpgfb => basis_set_b%pgf_radius
370 set_radius_b => basis_set_b%set_radius
371 scon_b => basis_set_b%scon
372 zetb => basis_set_b%zet
374 IF (use_cell_mapping)
THEN
375 ic = cell_to_index(cell(1), cell(2), cell(3))
376 IF (ic < 1 .OR. ic > nimg) cycle
381 IF (do_symmetric)
THEN
382 IF (iatom <= jatom)
THEN
391 IF (iatom == jatom) f0 = 1.0_dp
399 NULLIFY (sint(i)%block)
402 row=irow, col=icol, block=sint(i)%block, found=found)
406 row=irow, col=icol, block=sint(i)%block, found=found)
414 row=irow, col=icol, block=p_block, found=found)
418 block=p_block, found=found)
422 trans = do_symmetric .AND. (iatom > jatom)
424 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
429 ncoa = npgfa(iset)*
ncoset(la_max(iset))
430 n1 = npgfa(iset)*(
ncoset(la_max(iset)) -
ncoset(la_min(iset) - 1))
431 sgfa = first_sgfa(1, iset)
435 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
440 ncob = npgfb(jset)*
ncoset(lb_max(jset))
441 n2 = npgfb(jset)*(
ncoset(lb_max(jset)) -
ncoset(lb_min(jset) - 1))
442 sgfb = first_sgfb(1, jset)
447 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
448 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
449 rab, sab=oint(:, :, 1))
451 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
452 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
453 rab, sab=oint(:, :, 1), dab=oint(:, :, 2:4))
455 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
456 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
457 rab, sab=oint(:, :, 1), dab=oint(:, :, 2:4), ddab=oint(:, :, 5:10))
461 IF (do_forces .AND.
ASSOCIATED(p_block) .AND. ((iatom /= jatom) .OR. use_virial))
THEN
464 CALL block_add(
"OUT", owork, nsgfa(iset), nsgfb(jset), p_block, sgfa, sgfb, trans=trans)
465 CALL decontraction(owork, pmat, scon_a(:, sgfa:), n1, nsgfa(iset), scon_b(:, sgfb:), n2, &
466 nsgfb(jset), trans=trans)
467 CALL force_trace(force_a, oint(:, :, 2:4), pmat, n1, n2, 3)
468 force_thread(:, iatom) = force_thread(:, iatom) - ff*force_a(:)
469 force_thread(:, jatom) = force_thread(:, jatom) + ff*force_a(:)
477 IF (ndod(i) == 1 .AND. trans) f = -1.0_dp
478 CALL contraction(oint(:, :, i), owork, ca=scon_a(:, sgfa:), na=n1, ma=nsgfa(iset), &
479 cb=scon_b(:, sgfb:), nb=n2, mb=nsgfb(jset), fscale=f, trans=trans)
481 CALL block_add(
"IN", owork, nsgfa(iset), nsgfb(jset), sint(i)%block, &
482 sgfa, sgfb, trans=trans)
490 IF (do_forces)
DEALLOCATE (pmat)
491 DEALLOCATE (oint, owork)
509 atom_a = atom_of_kind(iatom)
510 ikind = kind_of(iatom)
511 force(ikind)%overlap(:, atom_a) = force(ikind)%overlap(:, atom_a) + force_thread(:, iatom)
515 IF (do_forces .AND. use_virial)
THEN
516 virial%pv_overlap = virial%pv_overlap + pv_thread
517 virial%pv_virial = virial%pv_virial + pv_thread
525 dft_control%qs_control%eps_filter_matrix)
532 dft_control%qs_control%eps_filter_matrix)
537 DEALLOCATE (basis_set_list_a, basis_set_list_b)
539 CALL timestop(handle)
541 END SUBROUTINE build_overlap_matrix_low
557 basis_set_list_a, basis_set_list_b, sab_nl)
565 CHARACTER(len=*),
PARAMETER :: routinen =
'build_overlap_matrix_simple'
567 INTEGER :: handle, iatom, icol, ikind, irow, iset, &
568 jatom, jkind, jset, ldsab, m1, m2, n1, &
569 n2, natom, ncoa, ncob, nkind, nseta, &
570 nsetb, sgfa, sgfb, slot
571 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
573 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
574 LOGICAL :: do_symmetric, found, trans
575 REAL(kind=
dp) :: dab, rab2
576 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: owork
577 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: oint
578 REAL(kind=
dp),
DIMENSION(3) :: rab
579 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
580 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rpgfa, rpgfb, scon_a, scon_b, zeta, zetb
585 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
593 NULLIFY (dft_control)
595 CALL timeset(routinen, handle)
597 NULLIFY (atomic_kind_set)
599 atomic_kind_set=atomic_kind_set, &
601 qs_kind_set=qs_kind_set, &
602 dft_control=dft_control)
605 cpassert(
SIZE(sab_nl) > 0)
608 nkind =
SIZE(qs_kind_set)
611 CALL create_sab_matrix(ks_env, matrix_s,
"Matrix", basis_set_list_a, basis_set_list_b, &
612 sab_nl, do_symmetric)
616 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
618 ldsab = max(m1, m2, ldsab)
619 basis_set_b => basis_set_list_b(ikind)%gto_basis_set
621 ldsab = max(m1, m2, ldsab)
643 ALLOCATE (oint(ldsab, ldsab, 1), owork(ldsab, ldsab))
645 NULLIFY (sint(1)%block)
648 DO slot = 1, sab_nl(1)%nl_size
649 ikind = sab_nl(1)%nlist_task(slot)%ikind
650 jkind = sab_nl(1)%nlist_task(slot)%jkind
651 iatom = sab_nl(1)%nlist_task(slot)%iatom
652 jatom = sab_nl(1)%nlist_task(slot)%jatom
653 rab(1:3) = sab_nl(1)%nlist_task(slot)%r(1:3)
657 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
658 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
659 basis_set_b => basis_set_list_b(jkind)%gto_basis_set
660 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
662 first_sgfa => basis_set_a%first_sgf
663 la_max => basis_set_a%lmax
664 la_min => basis_set_a%lmin
665 npgfa => basis_set_a%npgf
666 nseta = basis_set_a%nset
667 nsgfa => basis_set_a%nsgf_set
668 rpgfa => basis_set_a%pgf_radius
669 set_radius_a => basis_set_a%set_radius
670 scon_a => basis_set_a%scon
671 zeta => basis_set_a%zet
673 first_sgfb => basis_set_b%first_sgf
674 lb_max => basis_set_b%lmax
675 lb_min => basis_set_b%lmin
676 npgfb => basis_set_b%npgf
677 nsetb = basis_set_b%nset
678 nsgfb => basis_set_b%nsgf_set
679 rpgfb => basis_set_b%pgf_radius
680 set_radius_b => basis_set_b%set_radius
681 scon_b => basis_set_b%scon
682 zetb => basis_set_b%zet
684 IF (do_symmetric)
THEN
685 IF (iatom <= jatom)
THEN
697 NULLIFY (sint(1)%block)
699 row=irow, col=icol, block=sint(1)%block, found=found)
701 trans = do_symmetric .AND. (iatom > jatom)
703 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
708 ncoa = npgfa(iset)*
ncoset(la_max(iset))
709 n1 = npgfa(iset)*(
ncoset(la_max(iset)) -
ncoset(la_min(iset) - 1))
710 sgfa = first_sgfa(1, iset)
714 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
719 ncob = npgfb(jset)*
ncoset(lb_max(jset))
720 n2 = npgfb(jset)*(
ncoset(lb_max(jset)) -
ncoset(lb_min(jset) - 1))
721 sgfb = first_sgfb(1, jset)
724 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
725 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
726 rab, sab=oint(:, :, 1))
728 CALL contraction(oint(:, :, 1), owork, ca=scon_a(:, sgfa:), na=n1, ma=nsgfa(iset), &
729 cb=scon_b(:, sgfb:), nb=n2, mb=nsgfb(jset), fscale=1.0_dp, trans=trans)
731 CALL block_add(
"IN", owork, nsgfa(iset), nsgfb(jset), sint(1)%block, &
732 sgfa, sgfb, trans=trans)
739 DEALLOCATE (oint, owork)
754 CALL dbcsr_filter(matrix_s(1)%matrix, dft_control%qs_control%eps_filter_matrix)
756 CALL timestop(handle)
783 sab_nl, matrix_p, matrixkp_p)
786 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: force
787 CHARACTER(LEN=*),
INTENT(IN) :: basis_type_a, basis_type_b
791 TYPE(
dbcsr_p_type),
DIMENSION(:),
OPTIONAL :: matrixkp_p
793 CHARACTER(len=*),
PARAMETER :: routinen =
'build_overlap_force'
795 INTEGER :: handle, iatom, ic, icol, ikind, irow, iset, jatom, jkind, jset, ldsab, n1, n2, &
796 natom, ncoa, ncob, nder, nimg, nkind, nseta, nsetb, sgfa, sgfb, slot
797 INTEGER,
DIMENSION(3) :: cell
798 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
800 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
801 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
802 LOGICAL :: do_symmetric, dokp, found, trans, &
803 use_cell_mapping, use_virial
804 REAL(kind=
dp) :: dab, f0, ff, rab2
805 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pab, sab
806 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: drab
807 REAL(kind=
dp),
DIMENSION(3) :: force_a, rab
808 REAL(kind=
dp),
DIMENSION(3, 3) :: virial_thread
809 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
810 REAL(kind=
dp),
DIMENSION(3, SIZE(force, 2)) :: force_thread
811 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, rpgfa, rpgfb, scon_a, scon_b, &
817 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
820 CALL timeset(routinen, handle)
822 NULLIFY (qs_kind_set)
823 CALL get_ks_env(ks_env=ks_env, qs_kind_set=qs_kind_set, dft_control=dft_control)
824 nimg = dft_control%nimages
827 IF (
PRESENT(matrix_p))
THEN
829 use_cell_mapping = .false.
830 ELSEIF (
PRESENT(matrixkp_p))
THEN
832 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
834 use_cell_mapping = (
SIZE(cell_to_index) > 1)
839 nkind =
SIZE(qs_kind_set)
843 cpassert(
SIZE(sab_nl) > 0)
847 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
848 virial_thread = 0.0_dp
851 ALLOCATE (basis_set_list_a(nkind), basis_set_list_b(nkind))
856 natom =
SIZE(force, 2)
857 force_thread = 0.0_dp
871 ALLOCATE (sab(ldsab, ldsab), pab(ldsab, ldsab))
872 ALLOCATE (drab(ldsab, ldsab, 3))
876 DO slot = 1, sab_nl(1)%nl_size
877 ikind = sab_nl(1)%nlist_task(slot)%ikind
878 jkind = sab_nl(1)%nlist_task(slot)%jkind
879 iatom = sab_nl(1)%nlist_task(slot)%iatom
880 jatom = sab_nl(1)%nlist_task(slot)%jatom
881 cell(:) = sab_nl(1)%nlist_task(slot)%cell(:)
882 rab(1:3) = sab_nl(1)%nlist_task(slot)%r(1:3)
884 basis_set_a => basis_set_list_a(ikind)%gto_basis_set
885 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
886 basis_set_b => basis_set_list_b(jkind)%gto_basis_set
887 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
889 first_sgfa => basis_set_a%first_sgf
890 la_max => basis_set_a%lmax
891 la_min => basis_set_a%lmin
892 npgfa => basis_set_a%npgf
893 nseta = basis_set_a%nset
894 nsgfa => basis_set_a%nsgf_set
895 rpgfa => basis_set_a%pgf_radius
896 set_radius_a => basis_set_a%set_radius
897 scon_a => basis_set_a%scon
898 zeta => basis_set_a%zet
900 first_sgfb => basis_set_b%first_sgf
901 lb_max => basis_set_b%lmax
902 lb_min => basis_set_b%lmin
903 npgfb => basis_set_b%npgf
904 nsetb = basis_set_b%nset
905 nsgfb => basis_set_b%nsgf_set
906 rpgfb => basis_set_b%pgf_radius
907 set_radius_b => basis_set_b%set_radius
908 scon_b => basis_set_b%scon
909 zetb => basis_set_b%zet
911 IF (use_cell_mapping)
THEN
912 ic = cell_to_index(cell(1), cell(2), cell(3))
913 IF (ic < 1 .OR. ic > nimg) cycle
918 IF (do_symmetric)
THEN
919 IF (iatom <= jatom)
THEN
927 IF (iatom == jatom) f0 = 1.0_dp
938 block=p_block, found=found)
941 block=p_block, found=found)
944 trans = do_symmetric .AND. (iatom > jatom)
946 rab2 = rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3)
951 ncoa = npgfa(iset)*
ncoset(la_max(iset))
952 n1 = npgfa(iset)*(
ncoset(la_max(iset)) -
ncoset(la_min(iset) - 1))
953 sgfa = first_sgfa(1, iset)
957 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
959 ncob = npgfb(jset)*
ncoset(lb_max(jset))
960 n2 = npgfb(jset)*(
ncoset(lb_max(jset)) -
ncoset(lb_min(jset) - 1))
961 sgfb = first_sgfb(1, jset)
963 IF (
ASSOCIATED(p_block) .AND. ((iatom /= jatom) .OR. use_virial))
THEN
966 CALL block_add(
"OUT", sab, nsgfa(iset), nsgfb(jset), p_block, sgfa, sgfb, trans=trans)
967 CALL decontraction(sab, pab, scon_a(:, sgfa:), n1, nsgfa(iset), scon_b(:, sgfb:), n2, &
968 nsgfb(jset), trans=trans)
970 CALL overlap_ab(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
971 lb_max(jset), lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
974 force_thread(1:3, iatom) = force_thread(1:3, iatom) - ff*force_a(1:3)
975 force_thread(1:3, jatom) = force_thread(1:3, jatom) + ff*force_a(1:3)
985 DEALLOCATE (sab, pab, drab)
991 force(1:3, 1:natom) = force(1:3, 1:natom) + force_thread(1:3, 1:natom)
995 virial%pv_virial = virial%pv_virial + virial_thread
996 virial%pv_overlap = virial%pv_overlap + virial_thread
999 DEALLOCATE (basis_set_list_a, basis_set_list_b)
1001 CALL timestop(handle)
1016 SUBROUTINE create_sab_matrix_1d(ks_env, matrix_s, matrix_name, &
1017 basis_set_list_a, basis_set_list_b, sab_nl, symmetric)
1021 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: matrix_name
1025 LOGICAL,
INTENT(IN) :: symmetric
1027 CHARACTER(LEN=12) :: cgfsym
1028 CHARACTER(LEN=32) :: symmetry_string
1029 CHARACTER(LEN=default_string_length) :: mname, name
1030 INTEGER :: i, maxs, natom
1031 INTEGER,
DIMENSION(:),
POINTER :: col_blk_sizes, row_blk_sizes
1034 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1036 CALL get_ks_env(ks_env=ks_env, particle_set=particle_set, &
1037 qs_kind_set=qs_kind_set, dbcsr_dist=dbcsr_dist)
1039 natom =
SIZE(particle_set)
1041 IF (
PRESENT(matrix_name))
THEN
1047 maxs =
SIZE(matrix_s)
1049 ALLOCATE (row_blk_sizes(natom), col_blk_sizes(natom))
1052 basis=basis_set_list_a)
1054 basis=basis_set_list_b)
1058 symmetry_string = dbcsr_type_symmetric
1060 symmetry_string = dbcsr_type_no_symmetry
1065 IF (ndod(i) == 1)
THEN
1067 symmetry_string = dbcsr_type_antisymmetric
1069 symmetry_string = dbcsr_type_symmetric
1072 symmetry_string = dbcsr_type_no_symmetry
1078 name = trim(cgfsym(4:))//
" DERIVATIVE OF THE "//trim(mname)// &
1079 " W.R.T. THE NUCLEAR COORDINATES"
1083 ALLOCATE (matrix_s(i)%matrix)
1086 dist=dbcsr_dist, matrix_type=symmetry_string, &
1087 row_blk_size=row_blk_sizes, col_blk_size=col_blk_sizes)
1091 DEALLOCATE (row_blk_sizes, col_blk_sizes)
1093 END SUBROUTINE create_sab_matrix_1d
1106 SUBROUTINE create_sab_matrix_2d(ks_env, matrix_s, matrix_name, &
1107 basis_set_list_a, basis_set_list_b, sab_nl, symmetric)
1110 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s
1111 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: matrix_name
1115 LOGICAL,
INTENT(IN) :: symmetric
1117 CHARACTER(LEN=12) :: cgfsym
1118 CHARACTER(LEN=32) :: symmetry_string
1119 CHARACTER(LEN=default_string_length) :: mname, name
1120 INTEGER :: i1, i2, natom
1121 INTEGER,
DIMENSION(:),
POINTER :: col_blk_sizes, row_blk_sizes
1124 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1126 CALL get_ks_env(ks_env=ks_env, particle_set=particle_set, &
1127 qs_kind_set=qs_kind_set, dbcsr_dist=dbcsr_dist)
1129 natom =
SIZE(particle_set)
1131 IF (
PRESENT(matrix_name))
THEN
1137 ALLOCATE (row_blk_sizes(natom), col_blk_sizes(natom))
1140 basis=basis_set_list_a)
1142 basis=basis_set_list_b)
1146 symmetry_string = dbcsr_type_symmetric
1148 symmetry_string = dbcsr_type_no_symmetry
1151 DO i2 = 1,
SIZE(matrix_s, 2)
1152 DO i1 = 1,
SIZE(matrix_s, 1)
1154 IF (ndod(i1) == 1)
THEN
1156 symmetry_string = dbcsr_type_antisymmetric
1158 symmetry_string = dbcsr_type_symmetric
1161 symmetry_string = dbcsr_type_no_symmetry
1167 name = trim(cgfsym(4:))//
" DERIVATIVE OF THE "//trim(mname)// &
1168 " W.R.T. THE NUCLEAR COORDINATES"
1172 ALLOCATE (matrix_s(i1, i2)%matrix)
1175 dist=dbcsr_dist, matrix_type=symmetry_string, &
1176 row_blk_size=row_blk_sizes, col_blk_size=col_blk_sizes)
1181 DEALLOCATE (row_blk_sizes, col_blk_sizes)
1183 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, 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, 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, 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_matrix(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, matrix_p, matrixkp_p)
Calculation of the overlap matrix over Cartesian Gaussian functions.
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.
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 ...