87 SUBROUTINE build_core_ppnl(matrix_h, matrix_p, force, virial, calculate_forces, use_virial, nder, &
88 qs_kind_set, atomic_kind_set, particle_set, sab_orb, sap_ppnl, eps_ppnl, &
89 nimages, cell_to_index, basis_type, deltaR, matrix_l, atcore)
91 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_h, matrix_p
94 LOGICAL,
INTENT(IN) :: calculate_forces
101 POINTER :: sab_orb, sap_ppnl
102 REAL(kind=
dp),
INTENT(IN) :: eps_ppnl
103 INTEGER,
INTENT(IN) :: nimages
104 INTEGER,
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: cell_to_index
105 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
106 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN), &
110 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT), &
113 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_core_ppnl'
115 INTEGER :: atom_a, first_col, handle, i, i_dim, iab, iac, iatom, ib, ibc, icol, ikind, &
116 ilist, img, irow, iset, j, jatom, jb, jkind, jneighbor, kac, katom, kbc, kkind, l, &
117 lc_max, lc_min, ldai, ldsab, lppnl, maxco, maxder, maxl, maxlgto, maxlppnl, maxppnl, &
118 maxsgf, na, natom, nb, ncoa, ncoc, nkind, nlist, nneighbor, nnl, np, nppnl, nprjc, nseta, &
119 nsgfa, prjc, sgfa, slot
120 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind, kind_of
121 INTEGER,
DIMENSION(3) :: cell_b, cell_c
122 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nprj_ppnl, &
124 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
125 LOGICAL :: do_dr, do_gth, do_kp, do_soc, doat, &
127 REAL(kind=
dp) :: atk, dac, f0, ppnl_radius
128 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: radp
129 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: sab, work
130 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ai_work, lab, work_l
131 REAL(kind=
dp),
DIMENSION(1) :: rprjc, zetc
132 REAL(kind=
dp),
DIMENSION(3) :: fa, fb, rab, rac, rbc
133 REAL(kind=
dp),
DIMENSION(3, 3) :: pv_thread
139 TYPE(
alist_type),
POINTER :: alist_ac, alist_bc
140 REAL(kind=
dp),
DIMENSION(SIZE(particle_set)) :: at_thread
141 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: achint, acint, alkint, bchint, bcint, &
143 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cprj, h_block, l_block_x, l_block_y, &
144 l_block_z, p_block, r_2block, &
145 r_3block, rpgfa, sphi_a, vprj_ppnl, &
147 REAL(kind=
dp),
DIMENSION(:),
POINTER :: a_nl, alpha_ppnl, hprj, set_radius_a
148 REAL(kind=
dp),
DIMENSION(3, SIZE(particle_set)) :: force_thread
162 IF (
PRESENT(deltar)) do_dr = .true.
164 IF (
PRESENT(atcore)) doat = .true.
165 IF ((calculate_forces .OR. doat) .AND. do_dr)
THEN
166 cpabort(
"core_ppl: incompatible options")
169 IF (calculate_forces)
THEN
170 CALL timeset(routinen//
"_forces", handle)
172 CALL timeset(routinen, handle)
175 do_soc =
PRESENT(matrix_l)
177 ppnl_present =
ASSOCIATED(sap_ppnl)
179 IF (ppnl_present)
THEN
181 nkind =
SIZE(atomic_kind_set)
182 natom =
SIZE(particle_set)
184 do_kp = (nimages > 1)
187 cpassert(
PRESENT(cell_to_index) .AND.
ASSOCIATED(cell_to_index))
190 IF (calculate_forces .OR. doat)
THEN
191 IF (
SIZE(matrix_p, 1) == 2)
THEN
193 CALL dbcsr_add(matrix_p(1, img)%matrix, matrix_p(2, img)%matrix, &
194 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
195 CALL dbcsr_add(matrix_p(2, img)%matrix, matrix_p(1, img)%matrix, &
196 alpha_scalar=-2.0_dp, beta_scalar=1.0_dp)
209 basis_type=basis_type)
211 maxl = max(maxlgto, maxlppnl)
214 ldsab = max(maxco,
ncoset(maxlppnl), maxsgf, maxppnl)
215 ldai =
ncoset(maxl + nder + 1)
218 ALLOCATE (sap_int(nkind*nkind))
219 DO i = 1, nkind*nkind
220 NULLIFY (sap_int(i)%alist, sap_int(i)%asort, sap_int(i)%aindex)
221 sap_int(i)%nalist = 0
225 ALLOCATE (basis_set(nkind), gpotential(nkind), spotential(nkind))
227 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=basis_type)
228 IF (
ASSOCIATED(orb_basis_set))
THEN
229 basis_set(ikind)%gto_basis_set => orb_basis_set
231 NULLIFY (basis_set(ikind)%gto_basis_set)
233 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential, sgp_potential=sgp_potential)
234 NULLIFY (gpotential(ikind)%gth_potential)
235 NULLIFY (spotential(ikind)%sgp_potential)
236 IF (
ASSOCIATED(gth_potential))
THEN
237 gpotential(ikind)%gth_potential => gth_potential
238 IF (do_soc .AND. (.NOT. gth_potential%soc))
THEN
239 cpabort(
"Spin-orbit coupling selected, but GTH potential without SOC parameters provided")
241 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
242 spotential(ikind)%sgp_potential => sgp_potential
247 DO slot = 1, sap_ppnl(1)%nl_size
249 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
250 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
251 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
252 katom = sap_ppnl(1)%nlist_task(slot)%jatom
253 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
254 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
255 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
257 iac = ikind + nkind*(kkind - 1)
258 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
259 IF (.NOT.
ASSOCIATED(gpotential(kkind)%gth_potential) .AND. &
260 .NOT.
ASSOCIATED(spotential(kkind)%sgp_potential)) cycle
261 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist))
THEN
262 sap_int(iac)%a_kind = ikind
263 sap_int(iac)%p_kind = kkind
264 sap_int(iac)%nalist = nlist
265 ALLOCATE (sap_int(iac)%alist(nlist))
267 NULLIFY (sap_int(iac)%alist(i)%clist)
268 sap_int(iac)%alist(i)%aatom = 0
269 sap_int(iac)%alist(i)%nclist = 0
272 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist(ilist)%clist))
THEN
273 sap_int(iac)%alist(ilist)%aatom = iatom
274 sap_int(iac)%alist(ilist)%nclist = nneighbor
275 ALLOCATE (sap_int(iac)%alist(ilist)%clist(nneighbor))
277 sap_int(iac)%alist(ilist)%clist(i)%catom = 0
295 ALLOCATE (sab(ldsab, ldsab*maxder), work(ldsab, ldsab*maxder))
297 ALLOCATE (ai_work(ldai, ldai,
ncoset(nder + 1)))
300 ALLOCATE (lab(ldsab, ldsab, 3), work_l(ldsab, ldsab, 3))
305 DO slot = 1, sap_ppnl(1)%nl_size
307 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
308 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
309 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
310 katom = sap_ppnl(1)%nlist_task(slot)%jatom
311 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
312 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
313 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
314 jneighbor = sap_ppnl(1)%nlist_task(slot)%inode
315 cell_c(:) = sap_ppnl(1)%nlist_task(slot)%cell(:)
316 rac(1:3) = sap_ppnl(1)%nlist_task(slot)%r(1:3)
318 iac = ikind + nkind*(kkind - 1)
319 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
321 first_sgfa => basis_set(ikind)%gto_basis_set%first_sgf
322 la_max => basis_set(ikind)%gto_basis_set%lmax
323 la_min => basis_set(ikind)%gto_basis_set%lmin
324 npgfa => basis_set(ikind)%gto_basis_set%npgf
325 nseta = basis_set(ikind)%gto_basis_set%nset
326 nsgfa = basis_set(ikind)%gto_basis_set%nsgf
327 nsgf_seta => basis_set(ikind)%gto_basis_set%nsgf_set
328 rpgfa => basis_set(ikind)%gto_basis_set%pgf_radius
329 set_radius_a => basis_set(ikind)%gto_basis_set%set_radius
330 sphi_a => basis_set(ikind)%gto_basis_set%sphi
331 zeta => basis_set(ikind)%gto_basis_set%zet
333 IF (
ASSOCIATED(gpotential(kkind)%gth_potential))
THEN
336 alpha_ppnl => gpotential(kkind)%gth_potential%alpha_ppnl
337 cprj => gpotential(kkind)%gth_potential%cprj
338 lppnl = gpotential(kkind)%gth_potential%lppnl
339 nppnl = gpotential(kkind)%gth_potential%nppnl
340 nprj_ppnl => gpotential(kkind)%gth_potential%nprj_ppnl
341 ppnl_radius = gpotential(kkind)%gth_potential%ppnl_radius
342 vprj_ppnl => gpotential(kkind)%gth_potential%vprj_ppnl
343 wprj_ppnl => gpotential(kkind)%gth_potential%wprj_ppnl
344 ELSE IF (
ASSOCIATED(spotential(kkind)%sgp_potential))
THEN
347 nprjc = spotential(kkind)%sgp_potential%nppnl
348 IF (nprjc == 0) cycle
349 nnl = spotential(kkind)%sgp_potential%n_nonlocal
350 lppnl = spotential(kkind)%sgp_potential%lmax
351 a_nl => spotential(kkind)%sgp_potential%a_nonlocal
352 ppnl_radius = spotential(kkind)%sgp_potential%ppnl_radius
354 radp(:) = ppnl_radius
355 cprj => spotential(kkind)%sgp_potential%cprj_ppnl
356 hprj => spotential(kkind)%sgp_potential%vprj_ppnl
357 nppnl =
SIZE(cprj, 2)
362 dac = sqrt(sum(rac*rac))
363 clist => sap_int(iac)%alist(ilist)%clist(jneighbor)
367 ALLOCATE (clist%acint(nsgfa, nppnl, maxder), &
368 clist%achint(nsgfa, nppnl, maxder), &
369 clist%alint(nsgfa, nppnl, 3), &
370 clist%alkint(nsgfa, nppnl, 3))
372 clist%achint = 0.0_dp
374 clist%alkint = 0.0_dp
377 NULLIFY (clist%sgf_list)
379 ncoa = npgfa(iset)*
ncoset(la_max(iset))
380 sgfa = first_sgfa(1, iset)
386 nprjc = nprj_ppnl(l)*
nco(l)
387 IF (nprjc == 0) cycle
388 rprjc(1) = ppnl_radius
389 IF (set_radius_a(iset) + rprjc(1) < dac) cycle
390 lc_max = l + 2*(nprj_ppnl(l) - 1)
392 zetc(1) = alpha_ppnl(l)
396 CALL overlap(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
397 lc_max, lc_min, 1, rprjc, zetc, rac, dac, sab, nder, .true., ai_work, ldai)
403 first_col = (i - 1)*ldsab
406 work(1:na, first_col + prjc:first_col + prjc + nb - 1) = &
407 matmul(sab(1:na, first_col + 1:first_col + np), cprj(1:np, prjc:prjc + nb - 1))
413 CALL angmom(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
414 lc_max, 1, zetc, rprjc, -rac, (/0._dp, 0._dp, 0._dp/), lab)
416 work_l(1:na, prjc:prjc + nb - 1, i_dim) = &
417 matmul(lab(1:na, 1:np, i_dim), cprj(1:np, prjc:prjc + nb - 1))
428 first_col = (i - 1)*ldsab + 1
432 clist%acint(sgfa:sgfa + na - 1, 1:nb, i) = &
433 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work(1:np, first_col:first_col + nb - 1))
437 clist%achint(sgfa:sgfa + na - 1, 1:nb, i) = &
438 matmul(clist%acint(sgfa:sgfa + na - 1, 1:nb, i), vprj_ppnl(1:nb, 1:nb))
442 clist%alint(sgfa:sgfa + na - 1, 1:nb, i_dim) = &
443 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work_l(1:np, 1:nb, i_dim))
444 clist%alkint(sgfa:sgfa + na - 1, 1:nb, i_dim) = &
445 matmul(clist%alint(sgfa:sgfa + na - 1, 1:nb, i_dim), wprj_ppnl(1:nb, 1:nb))
451 CALL overlap(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
452 lppnl, 0, nnl, radp, a_nl, rac, dac, sab, nder, .true., ai_work, ldai)
457 first_col = (i - 1)*ldsab + 1
461 work(1:np, 1:nb) = matmul(sab(1:np, first_col:first_col + nprjc - 1), cprj(1:nprjc, 1:nb))
465 clist%acint(sgfa:sgfa + na - 1, 1:nb, i) = &
466 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work(1:np, 1:nb))
468 ncoc = sgfa + nsgf_seta(iset) - 1
470 clist%achint(sgfa:ncoc, j, i) = clist%acint(sgfa:ncoc, j, i)*hprj(j)
475 clist%maxac = maxval(abs(clist%acint(:, :, 1)))
476 clist%maxach = maxval(abs(clist%achint(:, :, 1)))
477 IF (.NOT. do_gth)
DEALLOCATE (radp)
480 DEALLOCATE (sab, ai_work, work)
481 IF (do_soc)
DEALLOCATE (lab, work_l)
489 force_thread = 0.0_dp
520 DO slot = 1, sab_orb(1)%nl_size
522 ikind = sab_orb(1)%nlist_task(slot)%ikind
523 jkind = sab_orb(1)%nlist_task(slot)%jkind
524 iatom = sab_orb(1)%nlist_task(slot)%iatom
525 jatom = sab_orb(1)%nlist_task(slot)%jatom
526 cell_b(:) = sab_orb(1)%nlist_task(slot)%cell(:)
527 rab(1:3) = sab_orb(1)%nlist_task(slot)%r(1:3)
529 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
530 IF (.NOT.
ASSOCIATED(basis_set(jkind)%gto_basis_set)) cycle
532 iab = ikind + nkind*(jkind - 1)
535 IF (iatom == jatom)
THEN
542 img = cell_to_index(cell_b(1), cell_b(2), cell_b(3))
548 IF (iatom <= jatom)
THEN
558 NULLIFY (l_block_x, l_block_y, l_block_z)
565 NULLIFY (r_2block, r_3block)
570 IF (calculate_forces .OR. doat)
THEN
576 IF (
ASSOCIATED(h_block))
THEN
581 iac = ikind + nkind*(kkind - 1)
582 ibc = jkind + nkind*(kkind - 1)
583 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist)) cycle
584 IF (.NOT.
ASSOCIATED(sap_int(ibc)%alist)) cycle
585 CALL get_alist(sap_int(iac), alist_ac, iatom)
586 CALL get_alist(sap_int(ibc), alist_bc, jatom)
587 IF (.NOT.
ASSOCIATED(alist_ac)) cycle
588 IF (.NOT.
ASSOCIATED(alist_bc)) cycle
589 DO kac = 1, alist_ac%nclist
590 DO kbc = 1, alist_bc%nclist
591 IF (alist_ac%clist(kac)%catom /= alist_bc%clist(kbc)%catom) cycle
592 IF (all(cell_b + alist_bc%clist(kbc)%cell - alist_ac%clist(kac)%cell == 0))
THEN
593 IF (alist_ac%clist(kac)%maxac*alist_bc%clist(kbc)%maxach < eps_ppnl) cycle
594 acint => alist_ac%clist(kac)%acint
595 bcint => alist_bc%clist(kbc)%acint
596 achint => alist_ac%clist(kac)%achint
597 bchint => alist_bc%clist(kbc)%achint
599 alkint => alist_ac%clist(kac)%alkint
600 blkint => alist_bc%clist(kbc)%alkint
606 IF (.NOT. do_dr)
THEN
607 IF (iatom <= jatom)
THEN
608 h_block(1:na, 1:nb) = h_block(1:na, 1:nb) + &
609 matmul(achint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, 1)))
611 h_block(1:nb, 1:na) = h_block(1:nb, 1:na) + &
612 matmul(bchint(1:nb, 1:np, 1), transpose(acint(1:na, 1:np, 1)))
616 IF (iatom <= jatom)
THEN
617 l_block_x(1:na, 1:nb) = l_block_x(1:na, 1:nb) + &
618 matmul(alkint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, 1)))
619 l_block_y(1:na, 1:nb) = l_block_y(1:na, 1:nb) + &
620 matmul(alkint(1:na, 1:np, 2), transpose(bcint(1:nb, 1:np, 1)))
621 l_block_z(1:na, 1:nb) = l_block_z(1:na, 1:nb) + &
622 matmul(alkint(1:na, 1:np, 3), transpose(bcint(1:nb, 1:np, 1)))
625 l_block_x(1:nb, 1:na) = l_block_x(1:nb, 1:na) - &
626 matmul(blkint(1:nb, 1:np, 1), transpose(acint(1:na, 1:np, 1)))
627 l_block_y(1:nb, 1:na) = l_block_y(1:nb, 1:na) - &
628 matmul(blkint(1:nb, 1:np, 2), transpose(acint(1:na, 1:np, 1)))
629 l_block_z(1:nb, 1:na) = l_block_z(1:nb, 1:na) - &
630 matmul(blkint(1:nb, 1:np, 3), transpose(acint(1:na, 1:np, 1)))
634 IF (calculate_forces)
THEN
635 IF (
ASSOCIATED(p_block))
THEN
636 katom = alist_ac%clist(kac)%catom
639 IF (iatom <= jatom)
THEN
640 fa(i) = sum(p_block(1:na, 1:nb)* &
641 matmul(acint(1:na, 1:np, j), transpose(bchint(1:nb, 1:np, 1))))
642 fb(i) = sum(p_block(1:na, 1:nb)* &
643 matmul(achint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, j))))
645 fa(i) = sum(p_block(1:nb, 1:na)* &
646 matmul(bchint(1:nb, 1:np, 1), transpose(acint(1:na, 1:np, j))))
647 fb(i) = sum(p_block(1:nb, 1:na)* &
648 matmul(bcint(1:nb, 1:np, j), transpose(achint(1:na, 1:np, 1))))
650 force_thread(i, iatom) = force_thread(i, iatom) + f0*fa(i)
651 force_thread(i, katom) = force_thread(i, katom) - f0*fa(i)
652 force_thread(i, jatom) = force_thread(i, jatom) + f0*fb(i)
653 force_thread(i, katom) = force_thread(i, katom) - f0*fb(i)
657 rac = alist_ac%clist(kac)%rac
658 rbc = alist_bc%clist(kbc)%rac
667 katom = alist_ac%clist(kac)%catom
668 IF (iatom <= jatom)
THEN
669 h_block(1:na, 1:nb) = h_block(1:na, 1:nb) + &
670 (deltar(i, iatom) - deltar(i, katom))* &
671 matmul(acint(1:na, 1:np, j), transpose(bchint(1:nb, 1:np, 1)))
673 h_block(1:na, 1:nb) = h_block(1:na, 1:nb) + &
674 (deltar(i, jatom) - deltar(i, katom))* &
675 matmul(achint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, j)))
677 h_block(1:nb, 1:na) = h_block(1:nb, 1:na) + &
678 (deltar(i, iatom) - deltar(i, katom))* &
679 matmul(bchint(1:nb, 1:np, 1), transpose(acint(1:na, 1:np, j)))
680 h_block(1:nb, 1:na) = h_block(1:nb, 1:na) + &
681 (deltar(i, jatom) - deltar(i, katom))* &
682 matmul(bcint(1:nb, 1:np, j), transpose(achint(1:na, 1:np, 1)))
686 katom = alist_ac%clist(kac)%catom
687 IF (iatom <= jatom)
THEN
688 r_2block(1:na, 1:nb) = r_2block(1:na, 1:nb) + &
689 (deltar(i, iatom) - deltar(i, katom))* &
690 matmul(acint(1:na, 1:np, j), transpose(bchint(1:nb, 1:np, 1)))
692 r_2block(1:na, 1:nb) = r_2block(1:na, 1:nb) + &
693 (deltar(i, jatom) - deltar(i, katom))* &
694 matmul(achint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, j)))
696 r_2block(1:nb, 1:na) = r_2block(1:nb, 1:na) + &
697 (deltar(i, iatom) - deltar(i, katom))* &
698 matmul(bchint(1:nb, 1:np, 1), transpose(acint(1:na, 1:np, j)))
699 r_2block(1:nb, 1:na) = r_2block(1:nb, 1:na) + &
700 (deltar(i, jatom) - deltar(i, katom))* &
701 matmul(bcint(1:nb, 1:np, j), transpose(achint(1:na, 1:np, 1)))
705 katom = alist_ac%clist(kac)%catom
706 IF (iatom <= jatom)
THEN
707 r_3block(1:na, 1:nb) = r_3block(1:na, 1:nb) + &
708 (deltar(i, iatom) - deltar(i, katom))* &
709 matmul(acint(1:na, 1:np, j), transpose(bchint(1:nb, 1:np, 1)))
711 r_3block(1:na, 1:nb) = r_3block(1:na, 1:nb) + &
712 (deltar(i, jatom) - deltar(i, katom))* &
713 matmul(achint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, j)))
715 r_3block(1:nb, 1:na) = r_3block(1:nb, 1:na) + &
716 (deltar(i, iatom) - deltar(i, katom))* &
717 matmul(bchint(1:nb, 1:np, 1), transpose(acint(1:na, 1:np, j)))
718 r_3block(1:nb, 1:na) = r_3block(1:nb, 1:na) + &
719 (deltar(i, jatom) - deltar(i, katom))* &
720 matmul(bcint(1:nb, 1:np, j), transpose(achint(1:na, 1:np, 1)))
725 IF (
ASSOCIATED(p_block))
THEN
726 katom = alist_ac%clist(kac)%catom
727 IF (iatom <= jatom)
THEN
728 atk = sum(p_block(1:na, 1:nb)* &
729 matmul(achint(1:na, 1:np, 1), transpose(bcint(1:nb, 1:np, 1))))
731 atk = sum(p_block(1:nb, 1:na)* &
732 matmul(bchint(1:nb, 1:np, 1), transpose(acint(1:na, 1:np, 1))))
734 at_thread(katom) = at_thread(katom) + f0*atk
759 DEALLOCATE (basis_set, gpotential, spotential)
760 IF (calculate_forces)
THEN
764 atom_a = atom_of_kind(iatom)
765 ikind = kind_of(iatom)
766 force(ikind)%gth_ppnl(:, atom_a) = force(ikind)%gth_ppnl(:, atom_a) + force_thread(:, iatom)
769 DEALLOCATE (atom_of_kind, kind_of)
772 IF (calculate_forces .AND. use_virial)
THEN
773 virial%pv_ppnl = virial%pv_ppnl + pv_thread
774 virial%pv_virial = virial%pv_virial + pv_thread
778 atcore(1:natom) = atcore(1:natom) + at_thread
781 IF (calculate_forces .OR. doat)
THEN
784 IF (
SIZE(matrix_p, 1) == 2)
THEN
786 CALL dbcsr_add(matrix_p(1, img)%matrix, matrix_p(2, img)%matrix, &
787 alpha_scalar=0.5_dp, beta_scalar=0.5_dp)
788 CALL dbcsr_add(matrix_p(2, img)%matrix, matrix_p(1, img)%matrix, &
789 alpha_scalar=-1.0_dp, beta_scalar=1.0_dp)
796 CALL timestop(handle)