86#include "./base/base_uses.f90"
94 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_vcd_ao'
95 INTEGER,
PARAMETER :: bi_1 = 1, bi_x = 2, bi_y = 3, bi_z = 4, bi_xx = 5, &
96 bi_xy = 6, bi_xz = 7, bi_yy = 8, bi_yz = 9, bi_zz = 10
120 REAL(
dp),
DIMENSION(3) :: rc
122 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_matrix_hr_rh'
123 INTEGER,
PARAMETER :: ispin = 1
126 REAL(kind=
dp) :: eps_ppnl
130 POINTER :: sab_all, sap_ppnl
132 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
134 CALL timeset(routinen, handle)
137 dft_control=dft_control, &
138 particle_set=particle_set, &
141 qs_kind_set=qs_kind_set, &
144 eps_ppnl = dft_control%qs_control%eps_ppnl
146 CALL dbcsr_set(vcd_env%matrix_hr(ispin, i)%matrix, 0._dp)
147 CALL dbcsr_set(vcd_env%matrix_rh(ispin, i)%matrix, 0._dp)
150 associate(my_matrix_hr_1d => vcd_env%matrix_hr(ispin, 1:3))
151 CALL build_rpnl_matrix(my_matrix_hr_1d, qs_kind_set, particle_set, sab_all, sap_ppnl, &
152 dft_control%qs_control%eps_ppnl, cell, rc, &
154 CALL build_tr_matrix(my_matrix_hr_1d, qs_env, qs_kind_set,
"ORB", sab_all, &
155 direction_or=.true., rc=rc)
160 associate(my_matrix_hr_1d => vcd_env%matrix_rh(ispin, 1:3))
161 CALL build_rpnl_matrix(my_matrix_hr_1d, qs_kind_set, particle_set, sab_all, sap_ppnl, &
162 dft_control%qs_control%eps_ppnl, cell, rc, &
163 direction_or=.false.)
164 CALL build_tr_matrix(my_matrix_hr_1d, qs_env, qs_kind_set,
"ORB", sab_all, &
165 direction_or=.false., rc=rc)
170 CALL timestop(handle)
186 SUBROUTINE build_rpnl_matrix(matrix_rv, qs_kind_set, particle_set, sab_all, sap_ppnl, eps_ppnl, &
187 cell, ref_point, direction_Or)
189 TYPE(dbcsr_p_type),
DIMENSION(:) :: matrix_rv
190 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
191 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
192 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
193 POINTER :: sab_all, sap_ppnl
194 REAL(kind=dp),
INTENT(IN) :: eps_ppnl
195 TYPE(cell_type),
INTENT(IN),
OPTIONAL,
POINTER :: cell
196 REAL(kind=dp),
DIMENSION(3) :: ref_point
197 LOGICAL :: direction_or
199 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_rpnl_matrix'
201 INTEGER :: handle, i, iab, iac, iatom, ibc, icol, &
202 ikind, irow, jatom, jkind, kac, kbc, &
203 kkind, na, natom, nb, nkind, np, slot
204 INTEGER,
DIMENSION(3) :: cell_b
205 LOGICAL :: found, ppnl_present
206 REAL(kind=dp),
DIMENSION(:, :, :),
POINTER :: achint, acint, bchint, bcint
207 TYPE(alist_type),
POINTER :: alist_ac, alist_bc
208 TYPE(block_p_type),
DIMENSION(3) :: blocks_rv
209 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set
210 TYPE(gto_basis_set_type),
POINTER :: orb_basis_set
211 TYPE(sap_int_type),
DIMENSION(:),
POINTER :: sap_int
218 ppnl_present =
ASSOCIATED(sap_ppnl)
219 IF (.NOT. ppnl_present)
RETURN
221 CALL timeset(routinen, handle)
222 nkind =
SIZE(qs_kind_set)
223 natom =
SIZE(particle_set)
227 ALLOCATE (sap_int(nkind*nkind))
228 DO i = 1, nkind*nkind
229 NULLIFY (sap_int(i)%alist, sap_int(i)%asort, sap_int(i)%aindex)
230 sap_int(i)%nalist = 0
235 CALL build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder=1, moment_mode=.true., &
236 particle_set=particle_set, cell=cell, refpoint=ref_point)
239 CALL sap_sort(sap_int)
241 ALLOCATE (basis_set(nkind))
243 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
244 IF (
ASSOCIATED(orb_basis_set))
THEN
245 basis_set(ikind)%gto_basis_set => orb_basis_set
247 NULLIFY (basis_set(ikind)%gto_basis_set)
276 DO slot = 1, sab_all(1)%nl_size
278 ikind = sab_all(1)%nlist_task(slot)%ikind
279 jkind = sab_all(1)%nlist_task(slot)%jkind
280 iatom = sab_all(1)%nlist_task(slot)%iatom
281 jatom = sab_all(1)%nlist_task(slot)%jatom
282 cell_b(:) = sab_all(1)%nlist_task(slot)%cell(:)
284 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
285 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
286 iab = ikind + nkind*(jkind - 1)
292 CALL dbcsr_get_block_p(matrix_rv(i)%matrix, irow, icol, blocks_rv(i)%block, found)
298 iac = ikind + nkind*(kkind - 1)
299 ibc = jkind + nkind*(kkind - 1)
300 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist)) cycle
301 IF (.NOT.
ASSOCIATED(sap_int(ibc)%alist)) cycle
302 CALL get_alist(sap_int(iac), alist_ac, iatom)
303 CALL get_alist(sap_int(ibc), alist_bc, jatom)
305 IF (.NOT.
ASSOCIATED(alist_ac)) cycle
306 IF (.NOT.
ASSOCIATED(alist_bc)) cycle
307 DO kac = 1, alist_ac%nclist
308 DO kbc = 1, alist_bc%nclist
309 IF (alist_ac%clist(kac)%catom /= alist_bc%clist(kbc)%catom) cycle
310 IF (all(cell_b + alist_bc%clist(kbc)%cell - alist_ac%clist(kac)%cell == 0))
THEN
311 IF (alist_ac%clist(kac)%maxac*alist_bc%clist(kbc)%maxach < eps_ppnl) cycle
312 acint => alist_ac%clist(kac)%acint
313 bcint => alist_bc%clist(kbc)%acint
314 achint => alist_ac%clist(kac)%achint
315 bchint => alist_bc%clist(kbc)%achint
321 IF (direction_or)
THEN
323 blocks_rv(1)%block(1:na, 1:nb) = blocks_rv(1)%block(1:na, 1:nb) + &
324 matmul(achint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, 2)))
325 blocks_rv(2)%block(1:na, 1:nb) = blocks_rv(2)%block(1:na, 1:nb) + &
326 matmul(achint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, 3)))
327 blocks_rv(3)%block(1:na, 1:nb) = blocks_rv(3)%block(1:na, 1:nb) + &
328 matmul(achint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, 4)))
331 blocks_rv(1)%block(1:na, 1:nb) = blocks_rv(1)%block(1:na, 1:nb) + &
332 matmul(achint(1:na, 1:np, 2), transpose(bcint(1:nb, 1:np, 1)))
333 blocks_rv(2)%block(1:na, 1:nb) = blocks_rv(2)%block(1:na, 1:nb) + &
334 matmul(achint(1:na, 1:np, 3), transpose(bcint(1:nb, 1:np, 1)))
335 blocks_rv(3)%block(1:na, 1:nb) = blocks_rv(3)%block(1:na, 1:nb) + &
336 matmul(achint(1:na, 1:np, 4), transpose(bcint(1:nb, 1:np, 1)))
345 NULLIFY (blocks_rv(i)%block)
361 CALL release_sap_int(sap_int)
363 DEALLOCATE (basis_set)
365 CALL timestop(handle)
388 SUBROUTINE build_tr_matrix(matrix_tr, qs_env, qs_kind_set, basis_type, sab_nl, direction_Or, rc)
390 TYPE(dbcsr_p_type),
DIMENSION(:) :: matrix_tr
391 TYPE(qs_environment_type),
POINTER :: qs_env
392 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
393 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
394 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
396 LOGICAL :: direction_or
397 REAL(kind=dp),
DIMENSION(3),
OPTIONAL :: rc
399 CHARACTER(len=*),
PARAMETER :: routinen =
'build_tr_matrix'
401 INTEGER :: handle, iatom, icol, ikind, ir, irow, &
402 iset, jatom, jkind, jset, ldsab, ltab, &
403 natom, ncoa, ncob, nkind, nseta, &
404 nsetb, sgfa, sgfb, slot
405 INTEGER,
DIMENSION(3) :: cell
406 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
408 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
409 LOGICAL :: do_symmetric, found, trans
411 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: qab, tkab
412 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: kab
413 REAL(kind=dp),
DIMENSION(3) :: ra, rab, rac, rb, rbc
414 REAL(kind=dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
415 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: kx_block, ky_block, kz_block, rpgfa, &
416 rpgfb, scon_a, scon_b, zeta, zetb
417 TYPE(cell_type),
POINTER :: qs_cell
418 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set_list
419 TYPE(gto_basis_set_type),
POINTER :: basis_set_a, basis_set_b
420 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
430 CALL timeset(routinen, handle)
432 nkind =
SIZE(qs_kind_set)
435 cpassert(
SIZE(sab_nl) > 0)
436 CALL get_neighbor_list_set_p(neighbor_list_sets=sab_nl, symmetric=do_symmetric)
439 ALLOCATE (basis_set_list(nkind))
440 CALL basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
443 ldsab = get_memory_usage(qs_kind_set, basis_type)
445 CALL get_qs_env(qs_env=qs_env, &
446 particle_set=particle_set, &
472 ALLOCATE (kab(ldsab, ldsab, 3), qab(ldsab, ldsab))
475 DO slot = 1, sab_nl(1)%nl_size
477 ikind = sab_nl(1)%nlist_task(slot)%ikind
478 jkind = sab_nl(1)%nlist_task(slot)%jkind
479 iatom = sab_nl(1)%nlist_task(slot)%iatom
480 jatom = sab_nl(1)%nlist_task(slot)%jatom
481 cell(:) = sab_nl(1)%nlist_task(slot)%cell(:)
482 rab(1:3) = sab_nl(1)%nlist_task(slot)%r(1:3)
484 basis_set_a => basis_set_list(ikind)%gto_basis_set
485 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
486 basis_set_b => basis_set_list(jkind)%gto_basis_set
487 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
493 first_sgfa => basis_set_a%first_sgf
494 la_max => basis_set_a%lmax
495 la_min => basis_set_a%lmin
496 npgfa => basis_set_a%npgf
497 nsgfa => basis_set_a%nsgf_set
498 rpgfa => basis_set_a%pgf_radius
499 set_radius_a => basis_set_a%set_radius
500 scon_a => basis_set_a%scon
501 zeta => basis_set_a%zet
503 first_sgfb => basis_set_b%first_sgf
504 lb_max => basis_set_b%lmax
505 lb_min => basis_set_b%lmin
506 npgfb => basis_set_b%npgf
507 nsgfb => basis_set_b%nsgf_set
508 rpgfb => basis_set_b%pgf_radius
509 set_radius_b => basis_set_b%set_radius
510 scon_b => basis_set_b%scon
511 zetb => basis_set_b%zet
513 nseta = basis_set_a%nset
514 nsetb = basis_set_b%nset
516 IF (do_symmetric)
THEN
517 IF (iatom <= jatom)
THEN
529 CALL dbcsr_get_block_p(matrix=matrix_tr(1)%matrix, &
530 row=irow, col=icol, block=kx_block, found=found)
533 CALL dbcsr_get_block_p(matrix=matrix_tr(2)%matrix, &
534 row=irow, col=icol, block=ky_block, found=found)
537 CALL dbcsr_get_block_p(matrix=matrix_tr(3)%matrix, &
538 row=irow, col=icol, block=kz_block, found=found)
545 ra = pbc(particle_set(iatom)%r(:), qs_cell)
546 rb(:) = ra(:) + rab(:)
547 rac = pbc(rc, ra, qs_cell)
550 trans = do_symmetric .AND. (iatom > jatom)
554 ncoa = npgfa(iset)*(
ncoset(la_max(iset)) -
ncoset(la_min(iset) - 1))
555 sgfa = first_sgfa(1, iset)
559 IF (set_radius_a(iset) + set_radius_b(jset) < tab) cycle
564 ncob = npgfb(jset)*(
ncoset(lb_max(jset)) -
ncoset(lb_min(jset) - 1))
565 sgfb = first_sgfb(1, jset)
568 ltab = max(npgfa(iset)*
ncoset(la_max(iset) + 1), npgfb(jset)*
ncoset(lb_max(jset) + 1))
569 ALLOCATE (tkab(ltab, ltab))
570 CALL kinetic(la_max(iset) + 1, la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
571 lb_max(jset) + 1, lb_min(jset), npgfb(jset), rpgfb(:, jset), zetb(:, jset), &
574 CALL ab_opr(la_max(iset), npgfa(iset), rpgfa(:, iset), la_min(iset), &
575 lb_max(jset), npgfb(jset), rpgfb(:, jset), lb_min(jset), &
576 tab, tkab, kab, rac, rbc, direction_or)
581 CALL contraction(kab(:, :, ir), qab, ca=scon_a(:, sgfa:), na=ncoa, ma=nsgfa(iset), &
582 cb=scon_b(:, sgfb:), nb=ncob, mb=nsgfb(jset), trans=trans)
587 CALL block_add(
"IN", qab, nsgfa(iset), nsgfb(jset), kx_block, sgfa, sgfb, trans=trans)
589 CALL block_add(
"IN", qab, nsgfa(iset), nsgfb(jset), ky_block, sgfa, sgfb, trans=trans)
591 CALL block_add(
"IN", qab, nsgfa(iset), nsgfb(jset), kz_block, sgfa, sgfb, trans=trans)
599 DEALLOCATE (kab, qab)
613 DEALLOCATE (basis_set_list)
614 CALL timestop(handle)
629 TYPE(dbcsr_p_type),
DIMENSION(:) :: matrix_rcore
630 TYPE(qs_environment_type),
POINTER :: qs_env
631 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
632 CHARACTER(LEN=*) :: basis_type
633 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
635 REAL(kind=dp),
DIMENSION(3),
OPTIONAL :: rf
637 CHARACTER(len=*),
PARAMETER :: routinen =
'build_rcore_matrix'
638 INTEGER,
PARAMETER :: nexp_max = 30
640 INTEGER :: atom_a, atom_b, handle, i, iatom, icol, idir, ikind, inode, irow, iset, jatom, &
641 jkind, jset, katom, kkind, ldai, ldsab, maxco, maxder, maxl, maxlgto, maxlppl, maxnset, &
642 maxsgf, mepos, n_local, ncoa, ncob, nder, nexp_lpot, nexp_ppl, nimages, nkind, nloc, &
643 nseta, nsetb, nthread, sgfa, sgfb
644 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind
645 INTEGER,
DIMENSION(1:10) :: nrloc
646 INTEGER,
DIMENSION(3) :: cellind
647 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, &
648 nct_lpot, npgfa, npgfb, nsgfa, nsgfb
649 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
650 INTEGER,
DIMENSION(nexp_max) :: nct_ppl
651 LOGICAL :: do_symmetric, dokp, ecp_local, &
652 ecp_semi_local, found, lpotextended
653 REAL(kind=dp) :: alpha, dab, dac, dbc, ppl_radius
654 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: hab, qab
655 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ppl_work, rhab, work
656 REAL(kind=dp),
DIMENSION(1:10) :: aloc, bloc
657 REAL(kind=dp),
DIMENSION(3) :: ra, rab, rac, raf, rb, rbc, rbf
658 REAL(kind=dp),
DIMENSION(4, nexp_max) :: cval_ppl
659 REAL(kind=dp),
DIMENSION(:),
POINTER :: a_local, alpha_lpot, c_local, cexp_ppl, &
660 set_radius_a, set_radius_b
661 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: cval_lpot, hx_block, hy_block, hz_block, &
662 rpgfa, rpgfb, scon_a, scon_b, sphi_a, &
664 REAL(kind=dp),
DIMENSION(nexp_max) :: alpha_ppl
665 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
666 TYPE(cell_type),
POINTER :: cell
667 TYPE(gth_potential_type),
POINTER :: gth_potential
668 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set_list
669 TYPE(gto_basis_set_type),
POINTER :: basis_set_a, basis_set_b
670 TYPE(neighbor_list_iterator_p_type), &
671 DIMENSION(:),
POINTER :: ap_iterator, nl_iterator
672 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
674 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
675 TYPE(sgp_potential_type),
POINTER :: sgp_potential
677 CALL timeset(routinen, handle)
679 CALL get_qs_env(qs_env=qs_env, &
680 atomic_kind_set=atomic_kind_set, &
681 qs_kind_set=qs_kind_set, &
682 particle_set=particle_set, &
687 cpassert(
SIZE(sab_nl) > 0)
688 CALL get_neighbor_list_set_p(neighbor_list_sets=sab_nl, symmetric=do_symmetric)
690 nkind =
SIZE(qs_kind_set)
693 ALLOCATE (basis_set_list(nkind))
694 CALL basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
703 nkind =
SIZE(atomic_kind_set)
707 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, atom_of_kind=atom_of_kind)
711 CALL get_qs_kind_set(qs_kind_set, maxco=maxco, maxlgto=maxlgto, &
712 maxsgf=maxsgf, maxnset=maxnset, maxlppl=maxlppl, &
713 basis_type=basis_type)
715 maxl = max(maxlgto, maxlppl)
716 CALL init_orbital_pointers(2*maxl + 2*nder + 2)
720 ldsab = max(maxco,
ncoset(maxlppl), maxsgf, maxlppl, maxco*
ncoset(maxlgto + 1))
721 ldai =
ncoset(2*maxlgto + 2)
724 CALL get_qs_kind(qs_kind_set(ikind), basis_set=basis_set_a, basis_type=basis_type)
725 IF (
ASSOCIATED(basis_set_a))
THEN
726 basis_set_list(ikind)%gto_basis_set => basis_set_a
728 NULLIFY (basis_set_list(ikind)%gto_basis_set)
735 CALL neighbor_list_iterator_create(nl_iterator, sab_nl, nthread=nthread)
738 CALL neighbor_list_iterator_create(ap_iterator, sac_ppl, search=.true., nthread=nthread)
766 ALLOCATE (hab(ldsab, ldsab), rhab(ldsab, ldsab, 3), work(ldsab, ldsab*(nder + 1), 3))
767 ALLOCATE (qab(ldsab, ldsab))
769 ldai =
ncoset(2*maxlgto + 2)
770 ALLOCATE (ppl_work(ldai, ldai, max(maxder, 2*maxlgto + 2 + 1)))
772 DO WHILE (neighbor_list_iterate(nl_iterator, mepos=mepos) == 0)
774 CALL get_iterator_info(nl_iterator, mepos=mepos, ikind=ikind, jkind=jkind, inode=inode, &
775 iatom=iatom, jatom=jatom, r=rab, cell=cellind)
777 basis_set_a => basis_set_list(ikind)%gto_basis_set
778 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
779 basis_set_b => basis_set_list(jkind)%gto_basis_set
780 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
782 atom_a = atom_of_kind(iatom)
783 atom_b = atom_of_kind(jatom)
786 first_sgfa => basis_set_a%first_sgf
787 la_max => basis_set_a%lmax
788 la_min => basis_set_a%lmin
789 npgfa => basis_set_a%npgf
790 nsgfa => basis_set_a%nsgf_set
791 rpgfa => basis_set_a%pgf_radius
792 set_radius_a => basis_set_a%set_radius
793 sphi_a => basis_set_a%sphi
794 zeta => basis_set_a%zet
795 scon_a => basis_set_a%scon
797 first_sgfb => basis_set_b%first_sgf
798 lb_max => basis_set_b%lmax
799 lb_min => basis_set_b%lmin
800 npgfb => basis_set_b%npgf
801 nsgfb => basis_set_b%nsgf_set
802 rpgfb => basis_set_b%pgf_radius
803 set_radius_b => basis_set_b%set_radius
804 sphi_b => basis_set_b%sphi
805 zetb => basis_set_b%zet
806 scon_b => basis_set_b%scon
808 nseta = basis_set_a%nset
809 nsetb = basis_set_b%nset
818 CALL dbcsr_get_block_p(matrix=matrix_rcore(1)%matrix, &
819 row=irow, col=icol, block=hx_block, found=found)
821 CALL dbcsr_get_block_p(matrix=matrix_rcore(2)%matrix, &
822 row=irow, col=icol, block=hy_block, found=found)
824 CALL dbcsr_get_block_p(matrix=matrix_rcore(3)%matrix, &
825 row=irow, col=icol, block=hz_block, found=found)
829 ra = pbc(particle_set(iatom)%r(:), cell)
830 rb(:) = ra(:) + rab(:)
832 raf = pbc(rf, ra, cell)
837 CALL get_qs_kind(qs_kind_set(kkind), gth_potential=gth_potential, &
838 sgp_potential=sgp_potential)
839 IF (
ASSOCIATED(gth_potential))
THEN
840 CALL get_potential(potential=gth_potential, &
841 alpha_ppl=alpha, cexp_ppl=cexp_ppl, &
842 lpot_present=lpotextended, ppl_radius=ppl_radius)
845 nct_ppl(1) =
SIZE(cexp_ppl)
846 cval_ppl(1:nct_ppl(1), 1) = cexp_ppl(1:nct_ppl(1))
847 IF (lpotextended)
THEN
848 CALL get_potential(potential=gth_potential, &
849 nexp_lpot=nexp_lpot, alpha_lpot=alpha_lpot, nct_lpot=nct_lpot, cval_lpot=cval_lpot)
850 cpassert(nexp_lpot < nexp_max)
851 nexp_ppl = nexp_lpot + 1
852 alpha_ppl(2:nexp_lpot + 1) = alpha_lpot(1:nexp_lpot)
853 nct_ppl(2:nexp_lpot + 1) = nct_lpot(1:nexp_lpot)
855 cval_ppl(1:nct_lpot(i), i + 1) = cval_lpot(1:nct_lpot(i), i)
858 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
859 CALL get_potential(potential=sgp_potential, ecp_local=ecp_local, ecp_semi_local=ecp_semi_local, &
860 ppl_radius=ppl_radius)
862 CALL get_potential(potential=sgp_potential, nloc=nloc, nrloc=nrloc, aloc=aloc, bloc=bloc)
863 IF (sum(abs(aloc(1:nloc))) < 1.0e-12_dp) cycle
865 cpassert(nexp_ppl <= nexp_max)
866 nct_ppl(1:nloc) = nrloc(1:nloc) - 1
867 alpha_ppl(1:nloc) = bloc(1:nloc)
868 cval_ppl(1, 1:nloc) = aloc(1:nloc)
870 CALL get_potential(potential=sgp_potential, n_local=n_local, a_local=a_local, c_local=c_local)
872 cpassert(nexp_ppl <= nexp_max)
873 nct_ppl(1:n_local) = 1
874 alpha_ppl(1:n_local) = a_local(1:n_local)
875 cval_ppl(1, 1:n_local) = c_local(1:n_local)
877 IF (ecp_semi_local)
THEN
878 cpabort(
"VCD with semi-local ECPs not implemented")
884 CALL nl_set_sub_iterator(ap_iterator, ikind, kkind, iatom, mepos=mepos)
886 DO WHILE (nl_sub_iterate(ap_iterator, mepos=mepos) == 0)
888 CALL get_iterator_info(ap_iterator, mepos=mepos, jatom=katom, r=rac)
889 dac = sqrt(sum(rac*rac))
890 rbc(:) = rac(:) - rab(:)
891 dbc = sqrt(sum(rbc*rbc))
892 IF ((maxval(set_radius_a(:)) + ppl_radius < dac) .OR. &
893 (maxval(set_radius_b(:)) + ppl_radius < dbc))
THEN
897 IF (set_radius_a(iset) + ppl_radius < dac) cycle
898 ncoa = npgfa(iset)*
ncoset(la_max(iset))
900 sgfa = first_sgfa(1, iset)
902 IF (set_radius_b(jset) + ppl_radius < dbc) cycle
903 ncob = npgfb(jset)*
ncoset(lb_max(jset))
905 sgfb = first_sgfb(1, jset)
906 IF (set_radius_a(iset) + set_radius_b(jset) < dab) cycle
914 la_max(iset) + 1, la_min(iset), npgfa(iset), &
915 rpgfa(:, iset), zeta(:, iset), &
916 lb_max(jset) + 1, lb_min(jset), npgfb(jset), &
917 rpgfb(:, jset), zetb(:, jset), &
918 nexp_ppl, alpha_ppl, nct_ppl, cval_ppl, ppl_radius, &
919 rab, dab, rac, dac, rbc, dbc, hab(:, :), ppl_work)
922 CALL ab_opr(la_max(iset), npgfa(iset), rpgfa(:, iset), 0, &
923 lb_max(jset), npgfb(jset), rpgfb(:, jset), 0, &
924 dab, hab(:, :), rhab(:, :, :), raf, rbf, &
925 direction_or=.false.)
928 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), ncob, &
929 1.0_dp, rhab(1, 1, idir),
SIZE(rhab, 1), &
930 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
931 0.0_dp, work(1, 1, idir),
SIZE(work, 1))
935 CALL dgemm(
"T",
"N", nsgfa(iset), nsgfb(jset), ncoa, &
936 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
937 work(1, 1, idir),
SIZE(work, 1), &
938 1.0_dp, hx_block(sgfa, sgfb),
SIZE(hx_block, 1))
940 CALL dgemm(
"T",
"N", nsgfa(iset), nsgfb(jset), ncoa, &
941 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
942 work(1, 1, idir),
SIZE(work, 1), &
943 1.0_dp, hy_block(sgfa, sgfb),
SIZE(hy_block, 1))
945 CALL dgemm(
"T",
"N", nsgfa(iset), nsgfb(jset), ncoa, &
946 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
947 work(1, 1, idir),
SIZE(work, 1), &
948 1.0_dp, hz_block(sgfa, sgfb),
SIZE(hz_block, 1))
958 DEALLOCATE (hab, rhab, work, ppl_work)
962 CALL neighbor_list_iterator_release(ap_iterator)
963 CALL neighbor_list_iterator_release(nl_iterator)
965 DEALLOCATE (atom_of_kind, basis_set_list)
967 CALL timestop(handle)
979 TYPE(dbcsr_p_type),
DIMENSION(:, :), &
980 INTENT(INOUT),
POINTER :: matrix_rv
981 TYPE(qs_environment_type),
POINTER :: qs_env
982 REAL(kind=dp),
DIMENSION(3) :: rc
984 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_matrix_r_vhxc'
985 INTEGER,
PARAMETER :: nspins = 1
987 INTEGER :: handle, idir, ispin
988 REAL(kind=dp) :: edisp
989 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks
990 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_rvxc, matrix_rvxc_desymm
991 TYPE(pw_env_type),
POINTER :: pw_env
992 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
993 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: v_rspace, v_tau_rspace
994 TYPE(pw_r3d_rs_type),
POINTER :: v_hartree_rspace
995 TYPE(qs_energy_type),
POINTER :: energy
996 TYPE(qs_ks_env_type),
POINTER :: ks_env
997 TYPE(qs_rho_type),
POINTER :: rho_struct
998 TYPE(section_vals_type),
POINTER :: input, xc_section
1000 CALL timeset(routinen, handle)
1002 CALL get_qs_env(qs_env, matrix_ks=matrix_ks, &
1006 v_hartree_rspace=v_hartree_rspace, &
1009 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
1015 NULLIFY (matrix_rvxc, matrix_rvxc_desymm)
1016 CALL dbcsr_allocate_matrix_set(matrix_rvxc, nspins, 3)
1017 CALL dbcsr_allocate_matrix_set(matrix_rvxc_desymm, nspins, 3)
1019 DO ispin = 1, nspins
1021 CALL dbcsr_init_p(matrix_rvxc(ispin, idir)%matrix)
1022 CALL dbcsr_init_p(matrix_rvxc_desymm(ispin, idir)%matrix)
1024 CALL dbcsr_copy(matrix_rvxc_desymm(ispin, idir)%matrix, matrix_rv(1, 1)%matrix)
1025 CALL dbcsr_set(matrix_rvxc_desymm(ispin, idir)%matrix, 0._dp)
1027 CALL dbcsr_copy(matrix_rvxc(ispin, idir)%matrix, matrix_ks(ispin)%matrix)
1028 CALL dbcsr_set(matrix_rvxc(ispin, idir)%matrix, 0.0_dp)
1032 xc_section => section_vals_get_subs_vals(input,
"DFT%XC")
1033 CALL get_qs_env(qs_env=qs_env, rho=rho_struct)
1036 NULLIFY (v_tau_rspace)
1037 CALL qs_vxc_create(ks_env=ks_env, rho_struct=rho_struct, xc_section=xc_section, &
1038 vxc_rho=v_rspace, vxc_tau=v_tau_rspace, exc=energy%exc, &
1039 edisp=edisp, dispersion_env=qs_env%dispersion_env, &
1040 just_energy=.false.)
1042 IF (.NOT.
ASSOCIATED(v_rspace))
THEN
1043 ALLOCATE (v_rspace(nspins))
1044 DO ispin = 1, nspins
1045 CALL auxbas_pw_pool%create_pw(v_rspace(ispin))
1046 CALL pw_zero(v_rspace(ispin))
1050 DO ispin = 1, nspins
1051 CALL pw_axpy(v_hartree_rspace, v_rspace(ispin), 1.0_dp/v_hartree_rspace%pw_grid%dvol)
1052 CALL integrate_rv_rspace(v_rspace=v_rspace(ispin), hmat=matrix_rvxc(ispin, :), qs_env=qs_env, &
1056 CALL dbcsr_scale(matrix_rvxc(ispin, idir)%matrix, v_rspace(ispin)%pw_grid%dvol)
1057 CALL dbcsr_desymmetrize(matrix_rvxc(ispin, idir)%matrix, matrix_rvxc_desymm(ispin, idir)%matrix)
1058 CALL dbcsr_add(matrix_rv(ispin, idir)%matrix, matrix_rvxc_desymm(ispin, idir)%matrix, 1.0_dp, 1.0_dp)
1063 DO ispin = 1, nspins
1064 CALL auxbas_pw_pool%give_back_pw(v_rspace(ispin))
1066 DEALLOCATE (v_rspace)
1068 CALL dbcsr_deallocate_matrix_set(matrix_rvxc)
1069 CALL dbcsr_deallocate_matrix_set(matrix_rvxc_desymm)
1071 CALL timestop(handle)
1086 SUBROUTINE integrate_rv_rspace(v_rspace, hmat, qs_env, rc)
1088 TYPE(pw_r3d_rs_type) :: v_rspace
1089 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT) :: hmat
1090 TYPE(qs_environment_type),
POINTER :: qs_env
1091 REAL(kind=dp),
DIMENSION(3) :: rc
1093 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_rv_rspace'
1095 CHARACTER(len=default_string_length) :: my_basis_type
1096 INTEGER :: bcol, brow, handle, iatom, idir, igrid_level, ikind, ikind_old, ilevel, img, &
1097 ipair, ipgf, ipgf_new, iset, iset_new, iset_old, itask, ithread, jatom, jkind, jkind_old, &
1098 jpgf, jpgf_new, jset, jset_new, jset_old, ldsab, maxco, maxlgto, maxpgf, maxset, &
1099 maxsgf_set, na1, na2, natom, nb1, nb2, ncoa, ncoa_full, ncob, ncob_full, nkind, nseta, &
1100 nsetb, nthread, sgfa, sgfb
1101 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
1103 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
1104 LOGICAL :: atom_pair_changed, atom_pair_done, distributed_grids, found, has_threads, &
1105 my_compute_tau, my_gapw, new_set_pair_coming
1106 REAL(kind=dp) :: dab, eps_rho_rspace, f, prefactor, &
1108 REAL(kind=dp),
DIMENSION(3) :: ra, rab, rab_inv, rac, rb, rbc, rp
1109 REAL(kind=dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
1110 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: hab, rpgfa, rpgfb, sphi_a, sphi_b, work, &
1112 REAL(kind=dp),
DIMENSION(:, :, :),
POINTER :: habt, rhab, workt
1113 TYPE(atom_pair_type),
DIMENSION(:),
POINTER :: atom_pair_recv, atom_pair_send
1114 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1115 TYPE(block_p_type),
ALLOCATABLE,
DIMENSION(:) :: h_block
1116 TYPE(cell_type),
POINTER :: cell
1117 TYPE(dbcsr_distribution_type) :: dist
1118 TYPE(dft_control_type),
POINTER :: dft_control
1119 TYPE(gridlevel_info_type),
POINTER :: gridlevel_info
1120 TYPE(gto_basis_set_type),
POINTER :: orb_basis_set
1121 TYPE(mp_comm_type) :: group
1122 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1123 TYPE(pw_env_type),
POINTER :: pw_env
1124 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1125 TYPE(realspace_grid_type),
DIMENSION(:),
POINTER :: rs_v
1126 TYPE(task_list_type),
POINTER :: task_list, task_list_soft
1127 TYPE(task_type),
DIMENSION(:),
POINTER :: tasks
1128 TYPE(virial_type),
POINTER :: virial
1130 CALL timeset(routinen, handle)
1132 my_compute_tau = .false.
1134 my_basis_type =
"ORB"
1137 CALL get_qs_env(qs_env=qs_env, &
1138 task_list=task_list, &
1139 task_list_soft=task_list_soft)
1140 cpassert(
ASSOCIATED(task_list))
1145 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1146 cpassert(
ASSOCIATED(pw_env))
1149 CALL get_qs_env(qs_env=qs_env, &
1150 atomic_kind_set=atomic_kind_set, &
1151 qs_kind_set=qs_kind_set, &
1153 dft_control=dft_control, &
1154 particle_set=particle_set, &
1163 tasks => task_list%tasks
1164 atom_pair_send => task_list%atom_pair_send
1165 atom_pair_recv => task_list%atom_pair_recv
1167 cpassert(
ASSOCIATED(pw_env))
1168 CALL pw_env_get(pw_env, rs_grids=rs_v)
1171 group = rs_v(1)%desc%group
1174 gridlevel_info => pw_env%gridlevel_info
1177 CALL potential_pw2rs(rs_v, v_rspace, pw_env)
1179 nkind =
SIZE(qs_kind_set)
1182 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1184 CALL get_qs_kind_set(qs_kind_set=qs_kind_set, &
1187 maxsgf_set=maxsgf_set, &
1188 basis_type=my_basis_type)
1190 distributed_grids = .false.
1191 DO igrid_level = 1, gridlevel_info%ngrid_levels
1192 IF (rs_v(igrid_level)%desc%distributed)
THEN
1193 distributed_grids = .true.
1204 CALL get_qs_kind(qs_kind_set(ikind), &
1205 basis_set=orb_basis_set, basis_type=my_basis_type)
1207 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
1209 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
1210 npgf=npgfa, nset=nseta)
1212 maxset = max(nseta, maxset)
1213 maxpgf = max(maxval(npgfa), maxpgf)
1216 ldsab = max(maxco, maxsgf_set, maxpgf*
ncoset(maxlgto + 1))
1219 NULLIFY (habt, workt)
1220 CALL reallocate(habt, 1, ldsab, 1, ldsab, 0, nthread)
1221 CALL reallocate(workt, 1, ldsab, 1, maxsgf_set, 0, nthread)
1222 ALLOCATE (rhab(ldsab, ldsab, 3))
1224 ALLOCATE (h_block(3))
1228 work => workt(:, :, ithread)
1229 hab => habt(:, :, ithread)
1232 iset_old = -1; jset_old = -1
1233 ikind_old = -1; jkind_old = -1
1239 loop_gridlevels:
DO igrid_level = 1, gridlevel_info%ngrid_levels
1241 CALL dbcsr_work_create(hmat(idir)%matrix, work_mutable=.true., n=nthread)
1242 CALL dbcsr_get_info(hmat(idir)%matrix, distribution=dist)
1243 CALL dbcsr_distribution_get(dist, has_threads=has_threads)
1248 loop_pairs:
DO ipair = 1, task_list%npairs(igrid_level)
1249 loop_tasks:
DO itask = task_list%taskstart(ipair, igrid_level), task_list%taskstop(ipair, igrid_level)
1250 ilevel = tasks(itask)%grid_level
1251 img = tasks(itask)%image
1252 iatom = tasks(itask)%iatom
1253 jatom = tasks(itask)%jatom
1254 iset = tasks(itask)%iset
1255 jset = tasks(itask)%jset
1256 ipgf = tasks(itask)%ipgf
1257 jpgf = tasks(itask)%jpgf
1261 IF (itask == task_list%taskstart(ipair, igrid_level))
THEN
1263 ikind = particle_set(iatom)%atomic_kind%kind_number
1264 jkind = particle_set(jatom)%atomic_kind%kind_number
1266 IF (iatom <= jatom)
THEN
1274 IF (ikind /= ikind_old)
THEN
1275 CALL get_qs_kind(qs_kind_set(ikind), &
1276 basis_set=orb_basis_set, basis_type=my_basis_type)
1278 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
1279 first_sgf=first_sgfa, &
1286 set_radius=set_radius_a, &
1291 IF (jkind /= jkind_old)
THEN
1292 CALL get_qs_kind(qs_kind_set(jkind), &
1293 basis_set=orb_basis_set, basis_type=my_basis_type)
1294 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, &
1295 first_sgf=first_sgfb, &
1302 set_radius=set_radius_b, &
1309 NULLIFY (h_block(idir)%block)
1310 CALL dbcsr_get_block_p(hmat(idir)%matrix, brow, bcol, h_block(idir)%block, found)
1317 atom_pair_changed = .true.
1321 atom_pair_changed = .false.
1325 IF (atom_pair_changed .OR. iset_old /= iset .OR. jset_old /= jset)
THEN
1328 ncoa = npgfa(iset)*
ncoset(la_max(iset))
1329 ncoa_full = npgfa(iset)*
ncoset(la_max(iset) + 1)
1330 sgfa = first_sgfa(1, iset)
1331 ncob = npgfb(jset)*
ncoset(lb_max(jset))
1332 ncob_full = npgfb(jset)*
ncoset(lb_max(jset) + 1)
1333 sgfb = first_sgfb(1, jset)
1335 IF (iatom <= jatom)
THEN
1336 hab(1:ncoa_full, 1:ncob_full) = 0._dp
1338 hab(1:ncob_full, 1:ncoa_full) = 0._dp
1346 rab = tasks(itask)%rab
1349 ra = pbc(particle_set(iatom)%r(:), cell)
1350 rb(:) = ra(:) + rab(:)
1351 rac = pbc(rc, ra, cell)
1354 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
1355 f = zetb(jpgf, jset)/zetp
1356 rp(:) = ra(:) + f*rab(:)
1358 prefactor = exp(-zeta(ipgf, iset)*f*dot_product(rab, rab))
1359 radius = exp_radius_very_extended(la_min=la_min(iset), la_max=la_max(iset), &
1360 lb_min=lb_min(jset), lb_max=lb_max(jset), &
1361 ra=ra, rb=rb, rp=rp, &
1362 zetp=zetp, eps=eps_rho_rspace, &
1363 prefactor=prefactor, cutoff=1.0_dp)
1365 na1 = (ipgf - 1)*
ncoset(la_max(iset) + 1) + 1
1366 na2 = ipgf*
ncoset(la_max(iset) + 1)
1367 nb1 = (jpgf - 1)*
ncoset(lb_max(jset) + 1) + 1
1368 nb2 = jpgf*
ncoset(lb_max(jset) + 1)
1370 IF (iatom <= jatom)
THEN
1371 CALL integrate_pgf_product( &
1372 la_max(iset) + 1, zeta(ipgf, iset), la_min(iset), &
1373 lb_max(jset) + 1, zetb(jpgf, jset), lb_min(jset), &
1374 ra, rab, rs_v(igrid_level), &
1375 hab, o1=na1 - 1, o2=nb1 - 1, &
1377 calculate_forces=.false.)
1380 CALL integrate_pgf_product( &
1381 lb_max(jset) + 1, zetb(jpgf, jset), lb_min(jset), &
1382 la_max(iset) + 1, zeta(ipgf, iset), la_min(iset), &
1383 rb, rab_inv, rs_v(igrid_level), &
1384 hab, o1=nb1 - 1, o2=na1 - 1, &
1386 calculate_forces=.false.)
1389 new_set_pair_coming = .false.
1390 atom_pair_done = .false.
1391 IF (itask < task_list%taskstop(ipair, igrid_level))
THEN
1392 ilevel = tasks(itask + 1)%grid_level
1393 img = tasks(itask + 1)%image
1394 iatom = tasks(itask + 1)%iatom
1395 jatom = tasks(itask + 1)%jatom
1396 iset_new = tasks(itask + 1)%iset
1397 jset_new = tasks(itask + 1)%jset
1398 ipgf_new = tasks(itask + 1)%ipgf
1399 jpgf_new = tasks(itask + 1)%jpgf
1400 IF (iset_new /= iset .OR. jset_new /= jset)
THEN
1401 new_set_pair_coming = .true.
1405 new_set_pair_coming = .true.
1406 atom_pair_done = .true.
1409 IF (new_set_pair_coming)
THEN
1411 IF (iatom <= jatom)
THEN
1413 CALL ab_opr(la_max(iset), npgfa(iset), rpgfa(:, iset), 0, &
1414 lb_max(jset), npgfb(jset), rpgfb(:, jset), 0, &
1415 dab, hab(:, :), rhab(:, :, :), rac, rbc, direction_or=.false.)
1419 CALL ab_opr(lb_max(jset), npgfb(jset), rpgfb(:, jset), 0, &
1420 la_max(iset), npgfa(iset), rpgfa(:, iset), 0, &
1421 dab, hab(:, :), rhab(:, :, :), rbc, rac, direction_or=.true.)
1426 IF (iatom <= jatom)
THEN
1428 work(1:ncoa, 1:nsgfb(jset)) = matmul(rhab(1:ncoa, 1:ncob, idir), sphi_b(1:ncob, sgfb:sgfb + nsgfb(jset) - 1))
1429 h_block(idir)%block(sgfa:sgfa + nsgfa(iset) - 1, sgfb:sgfb + nsgfb(jset) - 1) = &
1430 h_block(idir)%block(sgfa:sgfa + nsgfa(iset) - 1, sgfb:sgfb + nsgfb(jset) - 1) + &
1431 matmul(transpose(sphi_a(1:ncoa, sgfa:sgfa + nsgfa(iset) - 1)), work(1:ncoa, 1:nsgfb(jset)))
1433 work(1:ncob, 1:nsgfa(iset)) = matmul(rhab(1:ncob, 1:ncoa, idir), sphi_a(1:ncoa, sgfa:sgfa + nsgfa(iset) - 1))
1434 h_block(idir)%block(sgfb:sgfb + nsgfb(jset) - 1, sgfa:sgfa + nsgfa(iset) - 1) = &
1435 h_block(idir)%block(sgfb:sgfb + nsgfb(jset) - 1, sgfa:sgfa + nsgfa(iset) - 1) + &
1436 matmul(transpose(sphi_b(1:ncob, sgfb:sgfb + nsgfb(jset) - 1)), work(1:ncob, 1:nsgfa(iset)))
1445 CALL dbcsr_finalize(hmat(idir)%matrix)
1448 END DO loop_gridlevels
1451 DEALLOCATE (habt, rhab, workt, h_block)
1453 CALL timestop(handle)
1455 END SUBROUTINE integrate_rv_rspace
1467 TYPE(qs_environment_type),
POINTER :: qs_env
1468 TYPE(dbcsr_p_type),
DIMENSION(:) :: matrix_dsdv
1469 REAL(kind=dp),
DIMENSION(:, :) :: deltar
1470 REAL(kind=dp),
DIMENSION(3) :: rcc
1472 CHARACTER(len=*),
PARAMETER :: routinen =
'build_dSdV_matrix'
1474 INTEGER :: handle, i
1475 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, my_matrix_dsdv, &
1476 my_matrix_dsdv2, my_matrix_mom
1477 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
1479 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1481 CALL timeset(routinen, handle)
1483 NULLIFY (my_matrix_mom, my_matrix_dsdv, my_matrix_dsdv2, sab_all, qs_kind_set)
1485 CALL get_qs_env(qs_env=qs_env, &
1487 qs_kind_set=qs_kind_set, &
1488 matrix_ks=matrix_ks)
1491 CALL dbcsr_allocate_matrix_set(my_matrix_dsdv, 3)
1492 CALL dbcsr_allocate_matrix_set(my_matrix_dsdv2, 3)
1493 CALL dbcsr_allocate_matrix_set(my_matrix_mom, 3)
1496 ALLOCATE (my_matrix_dsdv(i)%matrix)
1497 ALLOCATE (my_matrix_dsdv2(i)%matrix)
1498 ALLOCATE (my_matrix_mom(i)%matrix)
1500 CALL dbcsr_copy(my_matrix_dsdv(i)%matrix, matrix_dsdv(i)%matrix)
1501 CALL dbcsr_copy(my_matrix_dsdv2(i)%matrix, matrix_dsdv(i)%matrix)
1502 CALL dbcsr_copy(my_matrix_mom(i)%matrix, matrix_ks(1)%matrix)
1504 CALL dbcsr_set(my_matrix_dsdv2(i)%matrix, 0.0_dp)
1505 CALL dbcsr_set(my_matrix_dsdv(i)%matrix, 0.0_dp)
1506 CALL dbcsr_set(my_matrix_mom(i)%matrix, 0.0_dp)
1507 CALL dbcsr_set(matrix_dsdv(i)%matrix, 0.0_dp)
1510 CALL build_dsdv_moments(qs_env, my_matrix_mom, 1, rcc)
1513 CALL dbcsr_desymmetrize(my_matrix_mom(i)%matrix, my_matrix_dsdv(i)%matrix)
1514 CALL dbcsr_copy(my_matrix_dsdv2(i)%matrix, my_matrix_dsdv(i)%matrix)
1519 deltar, direction_or=.true.)
1522 deltar, direction_or=.false.)
1524 CALL dbcsr_copy(matrix_dsdv(i)%matrix, my_matrix_dsdv(i)%matrix)
1525 CALL dbcsr_add(matrix_dsdv(i)%matrix, my_matrix_dsdv2(i)%matrix, 1.0_dp, -1.0_dp)
1528 CALL dbcsr_deallocate_matrix_set(my_matrix_dsdv)
1529 CALL dbcsr_deallocate_matrix_set(my_matrix_dsdv2)
1530 CALL dbcsr_deallocate_matrix_set(my_matrix_mom)
1532 CALL timestop(handle)
1549 particle_set, cell, direction_Or)
1551 TYPE(dbcsr_p_type),
DIMENSION(:, :) :: matrix_rv
1552 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1553 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
1554 POINTER :: sab_all, sap_ppnl
1555 REAL(kind=dp),
INTENT(IN) :: eps_ppnl
1556 TYPE(particle_type),
DIMENSION(:),
INTENT(IN), &
1557 POINTER :: particle_set
1558 TYPE(cell_type),
POINTER :: cell
1559 LOGICAL,
INTENT(IN) :: direction_or
1561 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_com_rpnl_r'
1563 INTEGER :: handle, i, iab, iac, iatom, ibc, icol, &
1564 ikind, irow, j, jatom, jkind, kac, &
1565 kbc, kkind, na, natom, nb, nkind, np, &
1567 INTEGER,
DIMENSION(3) :: cell_b
1568 LOGICAL :: found, ppnl_present
1569 REAL(kind=dp),
DIMENSION(3) :: rab
1570 REAL(kind=dp),
DIMENSION(:, :, :),
POINTER :: achint, acint, bchint, bcint
1571 TYPE(alist_type),
POINTER :: alist_ac, alist_bc
1572 TYPE(block_p_type),
DIMENSION(3, 3) :: blocks_rvr
1573 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set
1574 TYPE(gto_basis_set_type),
POINTER :: orb_basis_set
1575 TYPE(sap_int_type),
DIMENSION(:),
POINTER :: sap_int
1582 ppnl_present =
ASSOCIATED(sap_ppnl)
1583 IF (.NOT. ppnl_present)
RETURN
1585 CALL timeset(routinen, handle)
1586 nkind =
SIZE(qs_kind_set)
1587 natom =
SIZE(particle_set)
1591 ALLOCATE (sap_int(nkind*nkind))
1592 DO i = 1, nkind*nkind
1593 NULLIFY (sap_int(i)%alist, sap_int(i)%asort, sap_int(i)%aindex)
1594 sap_int(i)%nalist = 0
1603 CALL build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder=2, moment_mode=.true., &
1604 particle_set=particle_set, cell=cell, refpoint=[0._dp, 0._dp, 0._dp])
1607 CALL sap_sort(sap_int)
1609 ALLOCATE (basis_set(nkind))
1611 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1612 IF (
ASSOCIATED(orb_basis_set))
THEN
1613 basis_set(ikind)%gto_basis_set => orb_basis_set
1615 NULLIFY (basis_set(ikind)%gto_basis_set)
1644 DO slot = 1, sab_all(1)%nl_size
1646 ikind = sab_all(1)%nlist_task(slot)%ikind
1647 jkind = sab_all(1)%nlist_task(slot)%jkind
1648 iatom = sab_all(1)%nlist_task(slot)%iatom
1649 jatom = sab_all(1)%nlist_task(slot)%jatom
1650 cell_b(:) = sab_all(1)%nlist_task(slot)%cell(:)
1651 rab(1:3) = sab_all(1)%nlist_task(slot)%r(1:3)
1653 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
1654 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
1655 iab = ikind + nkind*(jkind - 1)
1665 CALL dbcsr_get_block_p(matrix_rv(i, j)%matrix, irow, icol, blocks_rvr(i, j)%block, found)
1672 iac = ikind + nkind*(kkind - 1)
1673 ibc = jkind + nkind*(kkind - 1)
1674 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist)) cycle
1675 IF (.NOT.
ASSOCIATED(sap_int(ibc)%alist)) cycle
1676 CALL get_alist(sap_int(iac), alist_ac, iatom)
1677 CALL get_alist(sap_int(ibc), alist_bc, jatom)
1678 IF (.NOT.
ASSOCIATED(alist_ac)) cycle
1679 IF (.NOT.
ASSOCIATED(alist_bc)) cycle
1680 DO kac = 1, alist_ac%nclist
1681 DO kbc = 1, alist_bc%nclist
1682 IF (alist_ac%clist(kac)%catom /= alist_bc%clist(kbc)%catom) cycle
1692 IF (all(cell_b + alist_bc%clist(kbc)%cell - alist_ac%clist(kac)%cell == 0))
THEN
1693 IF (alist_ac%clist(kac)%maxac*alist_bc%clist(kbc)%maxach < eps_ppnl) cycle
1694 acint => alist_ac%clist(kac)%acint
1695 bcint => alist_bc%clist(kbc)%acint
1696 achint => alist_ac%clist(kac)%achint
1697 bchint => alist_bc%clist(kbc)%achint
1708 IF (direction_or)
THEN
1713 blocks_rvr(1, 1)%block(1:na, 1:nb) = blocks_rvr(1, 1)%block(1:na, 1:nb) + &
1714 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xx)))
1715 blocks_rvr(1, 2)%block(1:na, 1:nb) = blocks_rvr(1, 2)%block(1:na, 1:nb) + &
1716 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xy)))
1717 blocks_rvr(1, 3)%block(1:na, 1:nb) = blocks_rvr(1, 3)%block(1:na, 1:nb) + &
1718 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xz)))
1721 blocks_rvr(2, 1)%block(1:na, 1:nb) = blocks_rvr(2, 1)%block(1:na, 1:nb) + &
1722 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xy)))
1723 blocks_rvr(2, 2)%block(1:na, 1:nb) = blocks_rvr(2, 2)%block(1:na, 1:nb) + &
1724 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_yy)))
1725 blocks_rvr(2, 3)%block(1:na, 1:nb) = blocks_rvr(2, 3)%block(1:na, 1:nb) + &
1726 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_yz)))
1729 blocks_rvr(3, 1)%block(1:na, 1:nb) = blocks_rvr(3, 1)%block(1:na, 1:nb) + &
1730 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xz)))
1731 blocks_rvr(3, 2)%block(1:na, 1:nb) = blocks_rvr(3, 2)%block(1:na, 1:nb) + &
1732 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_yz)))
1733 blocks_rvr(3, 3)%block(1:na, 1:nb) = blocks_rvr(3, 3)%block(1:na, 1:nb) + &
1734 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_zz)))
1738 blocks_rvr(1, 1)%block(1:na, 1:nb) = blocks_rvr(1, 1)%block(1:na, 1:nb) - &
1739 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_x)))
1740 blocks_rvr(1, 2)%block(1:na, 1:nb) = blocks_rvr(1, 2)%block(1:na, 1:nb) - &
1741 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_y)))
1742 blocks_rvr(1, 3)%block(1:na, 1:nb) = blocks_rvr(1, 3)%block(1:na, 1:nb) - &
1743 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_z)))
1746 blocks_rvr(2, 1)%block(1:na, 1:nb) = blocks_rvr(2, 1)%block(1:na, 1:nb) - &
1747 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_x)))
1748 blocks_rvr(2, 2)%block(1:na, 1:nb) = blocks_rvr(2, 2)%block(1:na, 1:nb) - &
1749 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_y)))
1750 blocks_rvr(2, 3)%block(1:na, 1:nb) = blocks_rvr(2, 3)%block(1:na, 1:nb) - &
1751 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_z)))
1754 blocks_rvr(3, 1)%block(1:na, 1:nb) = blocks_rvr(3, 1)%block(1:na, 1:nb) - &
1755 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_x)))
1756 blocks_rvr(3, 2)%block(1:na, 1:nb) = blocks_rvr(3, 2)%block(1:na, 1:nb) - &
1757 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_y)))
1758 blocks_rvr(3, 3)%block(1:na, 1:nb) = blocks_rvr(3, 3)%block(1:na, 1:nb) - &
1759 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_z)))
1765 blocks_rvr(1, 1)%block(1:na, 1:nb) = blocks_rvr(1, 1)%block(1:na, 1:nb) + &
1766 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_x)))
1767 blocks_rvr(1, 2)%block(1:na, 1:nb) = blocks_rvr(1, 2)%block(1:na, 1:nb) + &
1768 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_x)))
1769 blocks_rvr(1, 3)%block(1:na, 1:nb) = blocks_rvr(1, 3)%block(1:na, 1:nb) + &
1770 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_x)))
1772 blocks_rvr(2, 1)%block(1:na, 1:nb) = blocks_rvr(2, 1)%block(1:na, 1:nb) + &
1773 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_y)))
1774 blocks_rvr(2, 2)%block(1:na, 1:nb) = blocks_rvr(2, 2)%block(1:na, 1:nb) + &
1775 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_y)))
1776 blocks_rvr(2, 3)%block(1:na, 1:nb) = blocks_rvr(2, 3)%block(1:na, 1:nb) + &
1777 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_y)))
1779 blocks_rvr(3, 1)%block(1:na, 1:nb) = blocks_rvr(3, 1)%block(1:na, 1:nb) + &
1780 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_z)))
1781 blocks_rvr(3, 2)%block(1:na, 1:nb) = blocks_rvr(3, 2)%block(1:na, 1:nb) + &
1782 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_z)))
1783 blocks_rvr(3, 3)%block(1:na, 1:nb) = blocks_rvr(3, 3)%block(1:na, 1:nb) + &
1784 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_z)))
1787 blocks_rvr(1, 1)%block(1:na, 1:nb) = blocks_rvr(1, 1)%block(1:na, 1:nb) - &
1788 matmul(achint(1:na, 1:np, bi_xx), transpose(bcint(1:nb, 1:np, bi_1)))
1789 blocks_rvr(1, 2)%block(1:na, 1:nb) = blocks_rvr(1, 2)%block(1:na, 1:nb) - &
1790 matmul(achint(1:na, 1:np, bi_xy), transpose(bcint(1:nb, 1:np, bi_1)))
1791 blocks_rvr(1, 3)%block(1:na, 1:nb) = blocks_rvr(1, 3)%block(1:na, 1:nb) - &
1792 matmul(achint(1:na, 1:np, bi_xz), transpose(bcint(1:nb, 1:np, bi_1)))
1794 blocks_rvr(2, 1)%block(1:na, 1:nb) = blocks_rvr(2, 1)%block(1:na, 1:nb) - &
1795 matmul(achint(1:na, 1:np, bi_xy), transpose(bcint(1:nb, 1:np, bi_1)))
1796 blocks_rvr(2, 2)%block(1:na, 1:nb) = blocks_rvr(2, 2)%block(1:na, 1:nb) - &
1797 matmul(achint(1:na, 1:np, bi_yy), transpose(bcint(1:nb, 1:np, bi_1)))
1798 blocks_rvr(2, 3)%block(1:na, 1:nb) = blocks_rvr(2, 3)%block(1:na, 1:nb) - &
1799 matmul(achint(1:na, 1:np, bi_yz), transpose(bcint(1:nb, 1:np, bi_1)))
1801 blocks_rvr(3, 1)%block(1:na, 1:nb) = blocks_rvr(3, 1)%block(1:na, 1:nb) - &
1802 matmul(achint(1:na, 1:np, bi_xz), transpose(bcint(1:nb, 1:np, bi_1)))
1803 blocks_rvr(3, 2)%block(1:na, 1:nb) = blocks_rvr(3, 2)%block(1:na, 1:nb) - &
1804 matmul(achint(1:na, 1:np, bi_yz), transpose(bcint(1:nb, 1:np, bi_1)))
1805 blocks_rvr(3, 3)%block(1:na, 1:nb) = blocks_rvr(3, 3)%block(1:na, 1:nb) - &
1806 matmul(achint(1:na, 1:np, bi_zz), transpose(bcint(1:nb, 1:np, bi_1)))
1816 NULLIFY (blocks_rvr(i, 1)%block)
1817 NULLIFY (blocks_rvr(i, 2)%block)
1818 NULLIFY (blocks_rvr(i, 3)%block)
1834 CALL release_sap_int(sap_int)
1836 DEALLOCATE (basis_set)
1838 CALL timestop(handle)
1853 SUBROUTINE build_dcom_rpnl(matrix_rv, qs_kind_set, sab_orb, sap_ppnl, eps_ppnl, particle_set, pseudoatom)
1855 TYPE(dbcsr_p_type),
DIMENSION(:, :) :: matrix_rv
1856 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1857 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
1858 POINTER :: sab_orb, sap_ppnl
1859 REAL(kind=dp),
INTENT(IN) :: eps_ppnl
1860 TYPE(particle_type),
DIMENSION(:),
INTENT(IN), &
1861 POINTER :: particle_set
1862 INTEGER,
INTENT(IN) :: pseudoatom
1864 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_dcom_rpnl'
1866 INTEGER :: handle, i, iab, iac, iatom, ibc, icol, &
1867 ikind, irow, j, jatom, jkind, kac, &
1868 kbc, kkind, na, natom, nb, nkind, np, &
1870 INTEGER,
DIMENSION(3) :: cell_b
1871 LOGICAL :: found, ppnl_present
1872 REAL(kind=dp),
DIMENSION(3) :: rab
1873 REAL(kind=dp),
DIMENSION(:, :, :),
POINTER :: achint, acint, bchint, bcint
1874 TYPE(alist_type),
POINTER :: alist_ac, alist_bc
1875 TYPE(block_p_type),
DIMENSION(3, 3) :: blocks_rv
1876 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set
1877 TYPE(gto_basis_set_type),
POINTER :: orb_basis_set
1878 TYPE(sap_int_type),
DIMENSION(:),
POINTER :: sap_int
1885 ppnl_present =
ASSOCIATED(sap_ppnl)
1886 IF (.NOT. ppnl_present)
RETURN
1888 CALL timeset(routinen, handle)
1889 nkind =
SIZE(qs_kind_set)
1890 natom =
SIZE(particle_set)
1894 ALLOCATE (sap_int(nkind*nkind))
1895 DO i = 1, nkind*nkind
1896 NULLIFY (sap_int(i)%alist, sap_int(i)%asort, sap_int(i)%aindex)
1897 sap_int(i)%nalist = 0
1901 CALL build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder=2, moment_mode=.true., &
1902 particle_set=particle_set, pseudoatom=pseudoatom)
1905 CALL sap_sort(sap_int)
1907 ALLOCATE (basis_set(nkind))
1909 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
1910 IF (
ASSOCIATED(orb_basis_set))
THEN
1911 basis_set(ikind)%gto_basis_set => orb_basis_set
1913 NULLIFY (basis_set(ikind)%gto_basis_set)
1942 DO slot = 1, sab_orb(1)%nl_size
1944 ikind = sab_orb(1)%nlist_task(slot)%ikind
1945 jkind = sab_orb(1)%nlist_task(slot)%jkind
1946 iatom = sab_orb(1)%nlist_task(slot)%iatom
1947 jatom = sab_orb(1)%nlist_task(slot)%jatom
1948 cell_b(:) = sab_orb(1)%nlist_task(slot)%cell(:)
1949 rab(1:3) = sab_orb(1)%nlist_task(slot)%r(1:3)
1951 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
1952 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
1953 iab = ikind + nkind*(jkind - 1)
1956 IF (iatom <= jatom)
THEN
1966 CALL dbcsr_get_block_p(matrix_rv(i, j)%matrix, irow, icol, blocks_rv(i, j)%block, found)
1967 blocks_rv(i, j)%block = 0._dp
1974 iac = ikind + nkind*(kkind - 1)
1975 ibc = jkind + nkind*(kkind - 1)
1976 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist)) cycle
1977 IF (.NOT.
ASSOCIATED(sap_int(ibc)%alist)) cycle
1978 CALL get_alist(sap_int(iac), alist_ac, iatom)
1979 CALL get_alist(sap_int(ibc), alist_bc, jatom)
1980 IF (.NOT.
ASSOCIATED(alist_ac)) cycle
1981 IF (.NOT.
ASSOCIATED(alist_bc)) cycle
1982 DO kac = 1, alist_ac%nclist
1983 DO kbc = 1, alist_bc%nclist
1984 IF (alist_ac%clist(kac)%catom /= alist_bc%clist(kbc)%catom) cycle
1985 IF (all(cell_b + alist_bc%clist(kbc)%cell - alist_ac%clist(kac)%cell == 0))
THEN
1986 IF (alist_ac%clist(kac)%maxac*alist_bc%clist(kbc)%maxach < eps_ppnl) cycle
1987 acint => alist_ac%clist(kac)%acint
1988 bcint => alist_bc%clist(kbc)%acint
1989 achint => alist_ac%clist(kac)%achint
1990 bchint => alist_bc%clist(kbc)%achint
1999 IF (iatom <= jatom)
THEN
2001 blocks_rv(1, 1)%block(1:na, 1:nb) = blocks_rv(1, 1)%block(1:na, 1:nb) + &
2002 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_x)))
2004 blocks_rv(1, 2)%block(1:na, 1:nb) = blocks_rv(1, 2)%block(1:na, 1:nb) + &
2005 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_y)))
2007 blocks_rv(1, 3)%block(1:na, 1:nb) = blocks_rv(1, 3)%block(1:na, 1:nb) + &
2008 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_z)))
2010 blocks_rv(2, 1)%block(1:na, 1:nb) = blocks_rv(2, 1)%block(1:na, 1:nb) + &
2011 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_x)))
2013 blocks_rv(2, 2)%block(1:na, 1:nb) = blocks_rv(2, 2)%block(1:na, 1:nb) + &
2014 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_y)))
2016 blocks_rv(2, 3)%block(1:na, 1:nb) = blocks_rv(2, 3)%block(1:na, 1:nb) + &
2017 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_z)))
2019 blocks_rv(3, 1)%block(1:na, 1:nb) = blocks_rv(3, 1)%block(1:na, 1:nb) + &
2020 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_x)))
2022 blocks_rv(3, 2)%block(1:na, 1:nb) = blocks_rv(3, 2)%block(1:na, 1:nb) + &
2023 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_y)))
2025 blocks_rv(3, 3)%block(1:na, 1:nb) = blocks_rv(3, 3)%block(1:na, 1:nb) + &
2026 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_z)))
2029 blocks_rv(1, 1)%block(1:na, 1:nb) = blocks_rv(1, 1)%block(1:na, 1:nb) - &
2030 matmul(achint(1:na, 1:np, bi_xx), transpose(bcint(1:nb, 1:np, bi_1)))
2032 blocks_rv(1, 2)%block(1:na, 1:nb) = blocks_rv(1, 2)%block(1:na, 1:nb) - &
2033 matmul(achint(1:na, 1:np, bi_xy), transpose(bcint(1:nb, 1:np, bi_1)))
2035 blocks_rv(1, 3)%block(1:na, 1:nb) = blocks_rv(1, 3)%block(1:na, 1:nb) - &
2036 matmul(achint(1:na, 1:np, bi_xz), transpose(bcint(1:nb, 1:np, bi_1)))
2038 blocks_rv(2, 1)%block(1:na, 1:nb) = blocks_rv(2, 1)%block(1:na, 1:nb) - &
2039 matmul(achint(1:na, 1:np, bi_xy), transpose(bcint(1:nb, 1:np, bi_1)))
2041 blocks_rv(2, 2)%block(1:na, 1:nb) = blocks_rv(2, 2)%block(1:na, 1:nb) - &
2042 matmul(achint(1:na, 1:np, bi_yy), transpose(bcint(1:nb, 1:np, bi_1)))
2044 blocks_rv(2, 3)%block(1:na, 1:nb) = blocks_rv(2, 3)%block(1:na, 1:nb) - &
2045 matmul(achint(1:na, 1:np, bi_yz), transpose(bcint(1:nb, 1:np, bi_1)))
2047 blocks_rv(3, 1)%block(1:na, 1:nb) = blocks_rv(3, 1)%block(1:na, 1:nb) - &
2048 matmul(achint(1:na, 1:np, bi_xz), transpose(bcint(1:nb, 1:np, bi_1)))
2050 blocks_rv(3, 2)%block(1:na, 1:nb) = blocks_rv(3, 2)%block(1:na, 1:nb) - &
2051 matmul(achint(1:na, 1:np, bi_yz), transpose(bcint(1:nb, 1:np, bi_1)))
2053 blocks_rv(3, 3)%block(1:na, 1:nb) = blocks_rv(3, 3)%block(1:na, 1:nb) - &
2054 matmul(achint(1:na, 1:np, bi_zz), transpose(bcint(1:nb, 1:np, bi_1)))
2057 blocks_rv(1, 1)%block(1:na, 1:nb) = blocks_rv(1, 1)%block(1:na, 1:nb) - &
2058 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xx)))
2060 blocks_rv(1, 2)%block(1:na, 1:nb) = blocks_rv(1, 2)%block(1:na, 1:nb) - &
2061 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xy)))
2063 blocks_rv(1, 3)%block(1:na, 1:nb) = blocks_rv(1, 3)%block(1:na, 1:nb) - &
2064 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xz)))
2066 blocks_rv(2, 1)%block(1:na, 1:nb) = blocks_rv(2, 1)%block(1:na, 1:nb) - &
2067 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xy)))
2069 blocks_rv(2, 2)%block(1:na, 1:nb) = blocks_rv(2, 2)%block(1:na, 1:nb) - &
2070 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_yy)))
2072 blocks_rv(2, 3)%block(1:na, 1:nb) = blocks_rv(2, 3)%block(1:na, 1:nb) - &
2073 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_yz)))
2075 blocks_rv(3, 1)%block(1:na, 1:nb) = blocks_rv(3, 1)%block(1:na, 1:nb) - &
2076 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_xz)))
2078 blocks_rv(3, 2)%block(1:na, 1:nb) = blocks_rv(3, 2)%block(1:na, 1:nb) - &
2079 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_yz)))
2081 blocks_rv(3, 3)%block(1:na, 1:nb) = blocks_rv(3, 3)%block(1:na, 1:nb) - &
2082 matmul(achint(1:na, 1:np, bi_1), transpose(bcint(1:nb, 1:np, bi_zz)))
2085 blocks_rv(1, 1)%block(1:na, 1:nb) = blocks_rv(1, 1)%block(1:na, 1:nb) + &
2086 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_x)))
2088 blocks_rv(1, 2)%block(1:na, 1:nb) = blocks_rv(1, 2)%block(1:na, 1:nb) + &
2089 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_x)))
2091 blocks_rv(1, 3)%block(1:na, 1:nb) = blocks_rv(1, 3)%block(1:na, 1:nb) + &
2092 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_x)))
2094 blocks_rv(2, 1)%block(1:na, 1:nb) = blocks_rv(2, 1)%block(1:na, 1:nb) + &
2095 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_y)))
2097 blocks_rv(2, 2)%block(1:na, 1:nb) = blocks_rv(2, 2)%block(1:na, 1:nb) + &
2098 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_y)))
2100 blocks_rv(2, 3)%block(1:na, 1:nb) = blocks_rv(2, 3)%block(1:na, 1:nb) + &
2101 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_y)))
2103 blocks_rv(3, 1)%block(1:na, 1:nb) = blocks_rv(3, 1)%block(1:na, 1:nb) + &
2104 matmul(achint(1:na, 1:np, bi_x), transpose(bcint(1:nb, 1:np, bi_z)))
2106 blocks_rv(3, 2)%block(1:na, 1:nb) = blocks_rv(3, 2)%block(1:na, 1:nb) + &
2107 matmul(achint(1:na, 1:np, bi_y), transpose(bcint(1:nb, 1:np, bi_z)))
2109 blocks_rv(3, 3)%block(1:na, 1:nb) = blocks_rv(3, 3)%block(1:na, 1:nb) + &
2110 matmul(achint(1:na, 1:np, bi_z), transpose(bcint(1:nb, 1:np, bi_z)))
2113 blocks_rv(1, 1)%block(1:nb, 1:na) = blocks_rv(1, 1)%block(1:nb, 1:na) + &
2114 matmul(bchint(1:nb, 1:np, bi_x), transpose(acint(1:na, 1:np, bi_x)))
2116 blocks_rv(1, 2)%block(1:nb, 1:na) = blocks_rv(1, 2)%block(1:nb, 1:na) + &
2117 matmul(bchint(1:nb, 1:np, bi_x), transpose(acint(1:na, 1:np, bi_y)))
2119 blocks_rv(1, 3)%block(1:nb, 1:na) = blocks_rv(1, 3)%block(1:nb, 1:na) + &
2120 matmul(bchint(1:nb, 1:np, bi_x), transpose(acint(1:na, 1:np, bi_z)))
2122 blocks_rv(2, 1)%block(1:nb, 1:na) = blocks_rv(2, 1)%block(1:nb, 1:na) + &
2123 matmul(bchint(1:nb, 1:np, bi_y), transpose(acint(1:na, 1:np, bi_x)))
2125 blocks_rv(2, 2)%block(1:nb, 1:na) = blocks_rv(2, 2)%block(1:nb, 1:na) + &
2126 matmul(bchint(1:nb, 1:np, bi_y), transpose(acint(1:na, 1:np, bi_y)))
2128 blocks_rv(2, 3)%block(1:nb, 1:na) = blocks_rv(2, 3)%block(1:nb, 1:na) + &
2129 matmul(bchint(1:nb, 1:np, bi_y), transpose(acint(1:na, 1:np, bi_z)))
2131 blocks_rv(3, 1)%block(1:nb, 1:na) = blocks_rv(3, 1)%block(1:nb, 1:na) + &
2132 matmul(bchint(1:nb, 1:np, bi_z), transpose(acint(1:na, 1:np, bi_x)))
2134 blocks_rv(3, 2)%block(1:nb, 1:na) = blocks_rv(3, 2)%block(1:nb, 1:na) + &
2135 matmul(bchint(1:nb, 1:np, bi_z), transpose(acint(1:na, 1:np, bi_y)))
2137 blocks_rv(3, 3)%block(1:nb, 1:na) = blocks_rv(3, 3)%block(1:nb, 1:na) + &
2138 matmul(bchint(1:nb, 1:np, bi_z), transpose(acint(1:na, 1:np, bi_z)))
2141 blocks_rv(1, 1)%block(1:nb, 1:na) = blocks_rv(1, 1)%block(1:nb, 1:na) - &
2142 matmul(bchint(1:nb, 1:np, bi_xx), transpose(acint(1:na, 1:np, bi_1)))
2144 blocks_rv(1, 2)%block(1:nb, 1:na) = blocks_rv(1, 2)%block(1:nb, 1:na) - &
2145 matmul(bchint(1:nb, 1:np, bi_xy), transpose(acint(1:na, 1:np, bi_1)))
2147 blocks_rv(1, 3)%block(1:nb, 1:na) = blocks_rv(1, 3)%block(1:nb, 1:na) - &
2148 matmul(bchint(1:nb, 1:np, bi_xz), transpose(acint(1:na, 1:np, bi_1)))
2150 blocks_rv(2, 1)%block(1:nb, 1:na) = blocks_rv(2, 1)%block(1:nb, 1:na) - &
2151 matmul(bchint(1:nb, 1:np, bi_xy), transpose(acint(1:na, 1:np, bi_1)))
2153 blocks_rv(2, 2)%block(1:nb, 1:na) = blocks_rv(2, 2)%block(1:nb, 1:na) - &
2154 matmul(bchint(1:nb, 1:np, bi_yy), transpose(acint(1:na, 1:np, bi_1)))
2156 blocks_rv(2, 3)%block(1:nb, 1:na) = blocks_rv(2, 3)%block(1:nb, 1:na) - &
2157 matmul(bchint(1:nb, 1:np, bi_yz), transpose(acint(1:na, 1:np, bi_1)))
2159 blocks_rv(3, 1)%block(1:nb, 1:na) = blocks_rv(3, 1)%block(1:nb, 1:na) - &
2160 matmul(bchint(1:nb, 1:np, bi_xz), transpose(acint(1:na, 1:np, bi_1)))
2162 blocks_rv(3, 2)%block(1:nb, 1:na) = blocks_rv(3, 2)%block(1:nb, 1:na) - &
2163 matmul(bchint(1:nb, 1:np, bi_yz), transpose(acint(1:na, 1:np, bi_1)))
2165 blocks_rv(3, 3)%block(1:nb, 1:na) = blocks_rv(3, 3)%block(1:nb, 1:na) - &
2166 matmul(bchint(1:nb, 1:np, bi_zz), transpose(acint(1:na, 1:np, bi_1)))
2169 blocks_rv(1, 1)%block(1:nb, 1:na) = blocks_rv(1, 1)%block(1:nb, 1:na) - &
2170 matmul(bchint(1:nb, 1:np, bi_1), transpose(acint(1:na, 1:np, bi_xx)))
2172 blocks_rv(1, 2)%block(1:nb, 1:na) = blocks_rv(1, 2)%block(1:nb, 1:na) - &
2173 matmul(bchint(1:nb, 1:np, bi_1), transpose(acint(1:na, 1:np, bi_xy)))
2175 blocks_rv(1, 3)%block(1:nb, 1:na) = blocks_rv(1, 3)%block(1:nb, 1:na) - &
2176 matmul(bchint(1:nb, 1:np, bi_1), transpose(acint(1:na, 1:np, bi_xz)))
2178 blocks_rv(2, 1)%block(1:nb, 1:na) = blocks_rv(2, 1)%block(1:nb, 1:na) - &
2179 matmul(bchint(1:nb, 1:np, bi_1), transpose(acint(1:na, 1:np, bi_xy)))
2181 blocks_rv(2, 2)%block(1:nb, 1:na) = blocks_rv(2, 2)%block(1:nb, 1:na) - &
2182 matmul(bchint(1:nb, 1:np, bi_1), transpose(acint(1:na, 1:np, bi_yy)))
2184 blocks_rv(2, 3)%block(1:nb, 1:na) = blocks_rv(2, 3)%block(1:nb, 1:na) - &
2185 matmul(bchint(1:nb, 1:np, bi_1), transpose(acint(1:na, 1:np, bi_yz)))
2187 blocks_rv(3, 1)%block(1:nb, 1:na) = blocks_rv(3, 1)%block(1:nb, 1:na) - &
2188 matmul(bchint(1:nb, 1:np, bi_1), transpose(acint(1:na, 1:np, bi_xz)))
2190 blocks_rv(3, 2)%block(1:nb, 1:na) = blocks_rv(3, 2)%block(1:nb, 1:na) - &
2191 matmul(bchint(1:nb, 1:np, bi_1), transpose(acint(1:na, 1:np, bi_yz)))
2193 blocks_rv(3, 3)%block(1:nb, 1:na) = blocks_rv(3, 3)%block(1:nb, 1:na) - &
2194 matmul(bchint(1:nb, 1:np, bi_1), transpose(acint(1:na, 1:np, bi_zz)))
2197 blocks_rv(1, 1)%block(1:nb, 1:na) = blocks_rv(1, 1)%block(1:nb, 1:na) + &
2198 matmul(bchint(1:nb, 1:np, bi_x), transpose(acint(1:na, 1:np, bi_x)))
2200 blocks_rv(1, 2)%block(1:nb, 1:na) = blocks_rv(1, 2)%block(1:nb, 1:na) + &
2201 matmul(bchint(1:nb, 1:np, bi_y), transpose(acint(1:na, 1:np, bi_x)))
2203 blocks_rv(1, 3)%block(1:nb, 1:na) = blocks_rv(1, 3)%block(1:nb, 1:na) + &
2204 matmul(bchint(1:nb, 1:np, bi_z), transpose(acint(1:na, 1:np, bi_x)))
2206 blocks_rv(2, 1)%block(1:nb, 1:na) = blocks_rv(2, 1)%block(1:nb, 1:na) + &
2207 matmul(bchint(1:nb, 1:np, bi_x), transpose(acint(1:na, 1:np, bi_y)))
2209 blocks_rv(2, 2)%block(1:nb, 1:na) = blocks_rv(2, 2)%block(1:nb, 1:na) + &
2210 matmul(bchint(1:nb, 1:np, bi_y), transpose(acint(1:na, 1:np, bi_y)))
2212 blocks_rv(2, 3)%block(1:nb, 1:na) = blocks_rv(2, 3)%block(1:nb, 1:na) + &
2213 matmul(bchint(1:nb, 1:np, bi_z), transpose(acint(1:na, 1:np, bi_y)))
2215 blocks_rv(3, 1)%block(1:nb, 1:na) = blocks_rv(3, 1)%block(1:nb, 1:na) + &
2216 matmul(bchint(1:nb, 1:np, bi_x), transpose(acint(1:na, 1:np, bi_z)))
2218 blocks_rv(3, 2)%block(1:nb, 1:na) = blocks_rv(3, 2)%block(1:nb, 1:na) + &
2219 matmul(bchint(1:nb, 1:np, bi_y), transpose(acint(1:na, 1:np, bi_z)))
2221 blocks_rv(3, 3)%block(1:nb, 1:na) = blocks_rv(3, 3)%block(1:nb, 1:na) + &
2222 matmul(bchint(1:nb, 1:np, bi_z), transpose(acint(1:na, 1:np, bi_z)))
2232 NULLIFY (blocks_rv(i, 1)%block)
2233 NULLIFY (blocks_rv(i, 2)%block)
2234 NULLIFY (blocks_rv(i, 3)%block)
2250 CALL release_sap_int(sap_int)
2252 DEALLOCATE (basis_set)
2254 CALL timestop(handle)
2299 SUBROUTINE ab_opr(la_max, npgfa, rpgfa, la_min, lb_max, npgfb, rpgfb, lb_min, &
2300 dab, ab, comabr, ra, rb, direction_Or)
2301 INTEGER,
INTENT(IN) :: la_max, npgfa
2302 REAL(kind=dp),
DIMENSION(:),
INTENT(IN) :: rpgfa
2303 INTEGER,
INTENT(IN) :: la_min, lb_max, npgfb
2304 REAL(kind=dp),
DIMENSION(:),
INTENT(IN) :: rpgfb
2305 INTEGER,
INTENT(IN) :: lb_min
2306 REAL(kind=dp),
INTENT(IN) :: dab
2307 REAL(kind=dp),
DIMENSION(:, :),
INTENT(IN) :: ab
2308 REAL(kind=dp),
DIMENSION(:, :, :),
INTENT(OUT) :: comabr
2309 REAL(kind=dp),
DIMENSION(1:3),
INTENT(IN) :: ra, rb
2310 LOGICAL :: direction_or
2312 INTEGER :: ax, ay, az, bx, by, bz, coa, coap, &
2313 coapx, coapy, coapz, cob, cobp, cobpx, &
2314 cobpy, cobpz, ipgf, jpgf, la, lb, na, &
2315 nap, nb, nbp, ofa, ofb
2328 IF (rpgfa(ipgf) + rpgfb(jpgf) > dab)
THEN
2329 DO la = la_min, la_max
2333 coa = na +
coset(ax, ay, az) - ofa
2334 coap = nap +
coset(ax, ay, az) - ofa
2335 coapx = nap +
coset(ax + 1, ay, az) - ofa
2336 coapy = nap +
coset(ax, ay + 1, az) - ofa
2337 coapz = nap +
coset(ax, ay, az + 1) - ofa
2338 DO lb = lb_min, lb_max
2342 cob = nb +
coset(bx, by, bz) - ofb
2343 cobp = nbp +
coset(bx, by, bz) - ofb
2344 cobpx = nbp +
coset(bx + 1, by, bz) - ofb
2345 cobpy = nbp +
coset(bx, by + 1, bz) - ofb
2346 cobpz = nbp +
coset(bx, by, bz + 1) - ofb
2347 IF (direction_or)
THEN
2352 comabr(coa, cob, 1) = ab(coap, cobpx) + ab(coap, cobp)*rb(1)
2353 comabr(coa, cob, 2) = ab(coap, cobpy) + ab(coap, cobp)*rb(2)
2354 comabr(coa, cob, 3) = ab(coap, cobpz) + ab(coap, cobp)*rb(3)
2356 comabr(coa, cob, 1) = ab(coapx, cobp) + ab(coap, cobp)*ra(1)
2357 comabr(coa, cob, 2) = ab(coapy, cobp) + ab(coap, cobp)*ra(2)
2358 comabr(coa, cob, 3) = ab(coapz, cobp) + ab(coap, cobp)*ra(3)
2367 nb = nb +
ncoset(lb_max) - ofb
2368 nbp = nbp +
ncoset(lb_max + 1) - ofb
2370 na = na +
ncoset(la_max) - ofa
2371 nap = nap +
ncoset(la_max + 1) - ofa
2374 END SUBROUTINE ab_opr
2389 TYPE(dbcsr_type) :: matrix
2390 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2391 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
2392 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
2394 INTEGER,
INTENT(IN) :: lambda
2395 LOGICAL :: direction_or
2397 CHARACTER(len=*),
PARAMETER :: routinen =
'hr_mult_by_delta_1d'
2399 INTEGER :: handle, iatom, icol, ikind, irow, jatom, &
2400 jkind, ldsab, mepos, nkind, nseta, &
2402 INTEGER,
DIMENSION(3) :: cell
2403 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
2405 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
2406 LOGICAL :: do_symmetric, found
2407 REAL(kind=dp),
DIMENSION(3) :: rab
2408 REAL(kind=dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
2409 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: k_block, rpgfa, rpgfb, scon_a, scon_b, &
2410 sphi_a, sphi_b, zeta, zetb
2411 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set_list
2412 TYPE(gto_basis_set_type),
POINTER :: basis_set_a, basis_set_b
2413 TYPE(neighbor_list_iterator_p_type), &
2414 DIMENSION(:),
POINTER :: nl_iterator
2416 CALL timeset(routinen, handle)
2418 nkind =
SIZE(qs_kind_set)
2421 cpassert(
SIZE(sab_nl) > 0)
2422 CALL get_neighbor_list_set_p(neighbor_list_sets=sab_nl, symmetric=do_symmetric)
2425 ALLOCATE (basis_set_list(nkind))
2426 CALL basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
2429 ldsab = get_memory_usage(qs_kind_set, basis_type)
2434 CALL neighbor_list_iterator_create(nl_iterator, sab_nl, nthread=nthread)
2449 DO WHILE (neighbor_list_iterate(nl_iterator, mepos=mepos) == 0)
2450 CALL get_iterator_info(nl_iterator, mepos=mepos, ikind=ikind, jkind=jkind, &
2451 iatom=iatom, jatom=jatom, r=rab, cell=cell)
2452 basis_set_a => basis_set_list(ikind)%gto_basis_set
2453 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
2454 basis_set_b => basis_set_list(jkind)%gto_basis_set
2455 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
2457 first_sgfa => basis_set_a%first_sgf
2458 la_max => basis_set_a%lmax
2459 la_min => basis_set_a%lmin
2460 npgfa => basis_set_a%npgf
2461 nsgfa => basis_set_a%nsgf_set
2462 rpgfa => basis_set_a%pgf_radius
2463 set_radius_a => basis_set_a%set_radius
2464 sphi_a => basis_set_a%sphi
2465 zeta => basis_set_a%zet
2466 scon_a => basis_set_a%scon
2468 first_sgfb => basis_set_b%first_sgf
2469 lb_max => basis_set_b%lmax
2470 lb_min => basis_set_b%lmin
2471 npgfb => basis_set_b%npgf
2472 nsgfb => basis_set_b%nsgf_set
2473 rpgfb => basis_set_b%pgf_radius
2474 set_radius_b => basis_set_b%set_radius
2475 sphi_b => basis_set_b%sphi
2476 zetb => basis_set_b%zet
2477 scon_b => basis_set_b%scon
2479 nseta = basis_set_a%nset
2480 nsetb = basis_set_b%nset
2482 IF (do_symmetric)
THEN
2483 IF (iatom <= jatom)
THEN
2496 CALL dbcsr_get_block_p(matrix, irow, icol, k_block, found)
2499 IF (direction_or)
THEN
2500 IF (jatom /= lambda) k_block(:, :) = 0._dp
2501 ELSE IF (.NOT. direction_or)
THEN
2502 IF (iatom /= lambda) k_block(:, :) = 0._dp
2506 CALL neighbor_list_iterator_release(nl_iterator)
2509 DEALLOCATE (basis_set_list)
2511 CALL timestop(handle)
2529 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_hr
2530 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2531 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
2532 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
2534 REAL(kind=dp),
DIMENSION(:, :) :: deltar
2535 LOGICAL :: direction_or
2537 CHARACTER(len=*),
PARAMETER :: routinen =
'hr_mult_by_delta_3d'
2539 INTEGER :: handle, iatom, icol, ikind, ir, irow, &
2540 jatom, jkind, ldsab, mepos, nkind, &
2541 nseta, nsetb, nthread
2542 INTEGER,
DIMENSION(3) :: cell
2543 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
2545 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
2546 LOGICAL :: do_symmetric, found
2547 REAL(kind=dp),
DIMENSION(3) :: rab
2548 REAL(kind=dp),
DIMENSION(:),
POINTER :: set_radius_a, set_radius_b
2549 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: kx_block, ky_block, kz_block, rpgfa, &
2550 rpgfb, scon_a, scon_b, sphi_a, sphi_b, &
2552 TYPE(gto_basis_set_p_type),
DIMENSION(:),
POINTER :: basis_set_list
2553 TYPE(gto_basis_set_type),
POINTER :: basis_set_a, basis_set_b
2554 TYPE(neighbor_list_iterator_p_type), &
2555 DIMENSION(:),
POINTER :: nl_iterator
2557 CALL timeset(routinen, handle)
2559 nkind =
SIZE(qs_kind_set)
2562 cpassert(
SIZE(sab_nl) > 0)
2563 CALL get_neighbor_list_set_p(neighbor_list_sets=sab_nl, symmetric=do_symmetric)
2566 ALLOCATE (basis_set_list(nkind))
2567 CALL basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
2570 ldsab = get_memory_usage(qs_kind_set, basis_type)
2575 CALL neighbor_list_iterator_create(nl_iterator, sab_nl, nthread=nthread)
2591 DO WHILE (neighbor_list_iterate(nl_iterator, mepos=mepos) == 0)
2592 CALL get_iterator_info(nl_iterator, mepos=mepos, ikind=ikind, jkind=jkind, &
2593 iatom=iatom, jatom=jatom, r=rab, cell=cell)
2594 basis_set_a => basis_set_list(ikind)%gto_basis_set
2595 IF (.NOT.
ASSOCIATED(basis_set_a)) cycle
2596 basis_set_b => basis_set_list(jkind)%gto_basis_set
2597 IF (.NOT.
ASSOCIATED(basis_set_b)) cycle
2599 first_sgfa => basis_set_a%first_sgf
2600 la_max => basis_set_a%lmax
2601 la_min => basis_set_a%lmin
2602 npgfa => basis_set_a%npgf
2603 nsgfa => basis_set_a%nsgf_set
2604 rpgfa => basis_set_a%pgf_radius
2605 set_radius_a => basis_set_a%set_radius
2606 sphi_a => basis_set_a%sphi
2607 zeta => basis_set_a%zet
2608 scon_a => basis_set_a%scon
2610 first_sgfb => basis_set_b%first_sgf
2611 lb_max => basis_set_b%lmax
2612 lb_min => basis_set_b%lmin
2613 npgfb => basis_set_b%npgf
2614 nsgfb => basis_set_b%nsgf_set
2615 rpgfb => basis_set_b%pgf_radius
2616 set_radius_b => basis_set_b%set_radius
2617 sphi_b => basis_set_b%sphi
2618 zetb => basis_set_b%zet
2619 scon_b => basis_set_b%scon
2621 nseta = basis_set_a%nset
2622 nsetb = basis_set_b%nset
2624 IF (do_symmetric)
THEN
2625 IF (iatom <= jatom)
THEN
2637 NULLIFY (kx_block, ky_block, kz_block)
2638 CALL dbcsr_get_block_p(matrix_hr(1)%matrix, irow, icol, kx_block, found)
2640 CALL dbcsr_get_block_p(matrix_hr(2)%matrix, irow, icol, ky_block, found)
2642 CALL dbcsr_get_block_p(matrix_hr(3)%matrix, irow, icol, kz_block, found)
2645 IF (direction_or)
THEN
2650 kx_block(:, :) = kx_block(:, :)*deltar(ir, jatom)
2652 ky_block(:, :) = ky_block(:, :)*deltar(ir, jatom)
2654 kz_block(:, :) = kz_block(:, :)*deltar(ir, jatom)
2663 kx_block(:, :) = kx_block(:, :)*deltar(ir, iatom)
2665 ky_block(:, :) = ky_block(:, :)*deltar(ir, iatom)
2667 kz_block(:, :) = kz_block(:, :)*deltar(ir, iatom)
2674 CALL neighbor_list_iterator_release(nl_iterator)
2677 DEALLOCATE (basis_set_list)
2679 CALL timestop(handle)
static GRID_HOST_DEVICE int coset(int lx, int ly, int lz)
Maps three angular momentum components to a single zero based index.
static GRID_HOST_DEVICE int ncoset(const int l)
Number of Cartesian orbitals up to given angular momentum quantum.
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Set of routines to: Contract integrals over primitive Gaussians Decontract (density) matrices Trace m...
Calculation of the kinetic energy integrals over Cartesian Gaussian-type functions.
subroutine, public kinetic(la_max, la_min, npgfa, rpgfa, zeta, lb_max, lb_min, npgfb, rpgfb, zetb, rab, kab, dab)
Calculation of the two-center kinetic energy integrals [a|T|b] over Cartesian Gaussian-type functions...
Calculation of three-center overlap integrals over Cartesian Gaussian-type functions for the second t...
subroutine, public ppl_integral(la_max_set, la_min_set, npgfa, rpgfa, zeta, lb_max_set, lb_min_set, npgfb, rpgfb, zetb, nexp_ppl, alpha_ppl, nct_ppl, cexp_ppl, rpgfc, rab, dab, rac, dac, rbc, dbc, vab, s, pab, force_a, force_b, fs, hab2, hab2_work, deltar, iatom, jatom, katom)
Calculation of three-center overlap integrals <a|c|b> over Cartesian Gaussian functions for the local...
All kind of helpful little routines.
real(kind=dp) function, public exp_radius_very_extended(la_min, la_max, lb_min, lb_max, pab, o1, o2, ra, rb, rp, zetp, eps, prefactor, cutoff, epsabs)
computes the radius of the Gaussian outside of which it is smaller than eps
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, ccon)
...
collect pointers to a block of reals
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_init_p(matrix)
...
subroutine, public dbcsr_work_create(matrix, nblks_guess, sizedata_guess, n, work_mutable)
...
subroutine, public dbcsr_finalize(matrix)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
DBCSR operations in CP2K.
Definition of the atomic potential types.
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
Utility routines for the memory handling.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :, :), allocatable, public coset
Define the data structure for the particle information.
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
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, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, 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, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
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.
Integrate single or product functions over a potential on a RS grid.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, do_mtlr_present, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
Type definitiona for linear response calculations.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>
subroutine, public build_dsdv_moments(qs_env, moments, nmoments, ref_point, ref_points, basis_type)
Builds the moments for the derivative of the overlap with respect to nuclear velocities.
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public nl_set_sub_iterator(iterator_set, ikind, jkind, iatom, mepos)
...
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)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public build_dcom_rpnl(matrix_rv, qs_kind_set, sab_orb, sap_ppnl, eps_ppnl, particle_set, pseudoatom)
Calculate the double commutator [[Vnl, r], r].
subroutine, public build_rpnl_matrix(matrix_rv, qs_kind_set, particle_set, sab_all, sap_ppnl, eps_ppnl, cell, ref_point, direction_or)
Product of r with V_nl. Adapted from build_com_rpnl.
subroutine, public hr_mult_by_delta_3d(matrix_hr, qs_kind_set, basis_type, sab_nl, deltar, direction_or)
Apply the operator \delta_\mu^\lambda to zero out all elements of the matrix which don't fulfill the ...
subroutine, public build_dsdv_matrix(qs_env, matrix_dsdv, deltar, rcc)
Builds the overlap derivative wrt nuclear velocities dS/dV = < mu | r | nu > * (nu - mu)
subroutine, public build_matrix_r_vhxc(matrix_rv, qs_env, rc)
Commutator of the Hartree+XC potentials with r.
subroutine, public build_rcore_matrix(matrix_rcore, qs_env, qs_kind_set, basis_type, sab_nl, rf)
Commutator of the of the local part of the pseudopotential with r.
subroutine, public build_com_rpnl_r(matrix_rv, qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_set, cell, direction_or)
Builds the [Vnl, r] * r from either side.
subroutine, public build_tr_matrix(matrix_tr, qs_env, qs_kind_set, basis_type, sab_nl, direction_or, rc)
Calculation of the product Tr or rT over Cartesian Gaussian functions.
subroutine, public build_matrix_hr_rh(vcd_env, qs_env, rc)
Build the matrix Hr*delta_nu^\lambda - rH*delta_mu^\lambda.
subroutine, public hr_mult_by_delta_1d(matrix, qs_kind_set, basis_type, sab_nl, lambda, direction_or)
Apply the operator \delta_\mu^\lambda to zero out all elements of the matrix which don't fulfill the ...
subroutine, public qs_vxc_create(ks_env, rho_struct, xc_section, vxc_rho, vxc_tau, exc, just_energy, edisp, dispersion_env, adiabatic_rescale_factor, pw_env_external, native_skala_atom_force, qs_env_external, native_gapw_composite_override, native_skala_defer_to_atom_composite)
calculates and allocates the xc potential, already reducing it to the dependence on rho and the one o...
Transfers densities from PW to RS grids and potentials from PW to RS.
subroutine, public potential_pw2rs(rs_v, v_rspace, pw_env)
transfers a potential from a pw_grid to a vector of realspace multigrids
General overlap type integrals containers.
subroutine, public build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder, moment_mode, refpoint, particle_set, cell, pseudoatom)
Calculate overlap and optionally momenta <a|x^n|p> between GTOs and nl. pseudo potential projectors a...
subroutine, public release_sap_int(sap_int)
...
subroutine, public sap_sort(sap_int)
...
subroutine, public get_alist(sap_int, alist, atom)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.