281 SUBROUTINE build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder, moment_mode, refpoint, particle_set, cell, pseudoatom)
285 INTENT(IN),
POINTER :: sap_ppnl
287 POINTER :: qs_kind_set
288 INTEGER,
INTENT(IN) :: nder
289 LOGICAL,
INTENT(IN),
OPTIONAL :: moment_mode
290 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN),
OPTIONAL :: refpoint
292 OPTIONAL,
POINTER :: particle_set
293 TYPE(
cell_type),
INTENT(IN),
OPTIONAL,
POINTER :: cell
294 INTEGER,
OPTIONAL :: pseudoatom
296 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_sap_ints'
298 INTEGER :: first_col, handle, i, iac, iatom, ikind, ilist, iset, j, jneighbor, katom, kkind, &
299 l, lc_max, lc_min, ldai, ldai_nl, ldsab, lppnl, maxco, maxder, maxl, maxlgto, maxlppnl, &
300 maxppnl, maxsgf, na, nb, ncoa, ncoc, nkind, nlist, nneighbor, nnl, np, nppnl, nprjc, &
301 nseta, nsgfa, prjc, sgfa, slot
302 INTEGER,
DIMENSION(3) :: cell_c
303 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nprj_ppnl, &
305 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
306 LOGICAL :: dogth, my_momentmode, my_ref
307 LOGICAL,
DIMENSION(0:9) :: is_nonlocal
308 REAL(kind=
dp) :: dac, ppnl_radius
309 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: radp
310 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: sab, work
311 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ai_work
312 REAL(kind=
dp),
DIMENSION(1) :: rprjc, zetc
313 REAL(kind=
dp),
DIMENSION(3) :: ra, rac, raf, rc, rcf, rf
314 REAL(kind=
dp),
DIMENSION(:),
POINTER :: a_nl, alpha_ppnl, hprj, set_radius_a
315 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cprj, h_nl, rpgfa, sphi_a, vprj_ppnl, &
317 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: c_nl
322 DIMENSION(:) :: basis_set
327 CALL timeset(routinen, handle)
329 nkind =
SIZE(qs_kind_set)
333 my_momentmode = .false.
334 IF (
PRESENT(moment_mode))
THEN
335 my_momentmode = moment_mode
339 IF (
PRESENT(refpoint))
THEN
340 cpassert((
PRESENT(cell) .AND.
PRESENT(particle_set)))
352 maxl = max(maxlgto, maxlppnl)
355 ldsab = max(maxco,
ncoset(maxlppnl), maxsgf, maxppnl)
356 IF (.NOT. my_momentmode)
THEN
357 ldai =
ncoset(maxl + nder + 1)
364 NULLIFY (gpotential, spotential)
365 ALLOCATE (basis_set(nkind), gpotential(nkind), spotential(nkind))
367 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
368 IF (
ASSOCIATED(orb_basis_set))
THEN
369 basis_set(ikind)%gto_basis_set => orb_basis_set
371 NULLIFY (basis_set(ikind)%gto_basis_set)
373 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential, sgp_potential=sgp_potential)
374 NULLIFY (gpotential(ikind)%gth_potential)
375 NULLIFY (spotential(ikind)%sgp_potential)
376 IF (
ASSOCIATED(gth_potential))
THEN
377 gpotential(ikind)%gth_potential => gth_potential
378 ldai_nl = max(ldai_nl,
ncoset(gth_potential%lprj_ppnl_max))
379 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
380 spotential(ikind)%sgp_potential => sgp_potential
381 ldai_nl = max(ldai_nl, sgp_potential%n_nonlocal*
ncoset(sgp_potential%lmax))
386 DO slot = 1, sap_ppnl(1)%nl_size
388 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
389 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
390 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
391 katom = sap_ppnl(1)%nlist_task(slot)%jatom
392 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
393 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
394 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
396 iac = ikind + nkind*(kkind - 1)
397 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
398 IF (.NOT.
ASSOCIATED(gpotential(kkind)%gth_potential) .AND. &
399 .NOT.
ASSOCIATED(spotential(kkind)%sgp_potential)) cycle
400 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist))
THEN
401 sap_int(iac)%a_kind = ikind
402 sap_int(iac)%p_kind = kkind
403 sap_int(iac)%nalist = nlist
404 ALLOCATE (sap_int(iac)%alist(nlist))
406 NULLIFY (sap_int(iac)%alist(i)%clist)
407 sap_int(iac)%alist(i)%aatom = 0
408 sap_int(iac)%alist(i)%nclist = 0
411 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist(ilist)%clist))
THEN
412 sap_int(iac)%alist(ilist)%aatom = iatom
413 sap_int(iac)%alist(ilist)%nclist = nneighbor
414 ALLOCATE (sap_int(iac)%alist(ilist)%clist(nneighbor))
416 sap_int(iac)%alist(ilist)%clist(i)%catom = 0
435 ALLOCATE (sab(ldsab, ldsab*maxder), work(ldsab, ldsab*maxder))
437 IF (.NOT. my_momentmode)
THEN
438 ALLOCATE (ai_work(ldai, ldai,
ncoset(nder + 1)))
440 ALLOCATE (ai_work(ldai, ldai_nl,
ncoset(nder + 1)))
446 DO slot = 1, sap_ppnl(1)%nl_size
447 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
448 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
449 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
450 katom = sap_ppnl(1)%nlist_task(slot)%jatom
451 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
452 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
453 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
454 jneighbor = sap_ppnl(1)%nlist_task(slot)%inode
455 cell_c(:) = sap_ppnl(1)%nlist_task(slot)%cell(:)
456 rac(1:3) = sap_ppnl(1)%nlist_task(slot)%r(1:3)
458 iac = ikind + nkind*(kkind - 1)
459 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
461 first_sgfa => basis_set(ikind)%gto_basis_set%first_sgf
462 la_max => basis_set(ikind)%gto_basis_set%lmax
463 la_min => basis_set(ikind)%gto_basis_set%lmin
464 npgfa => basis_set(ikind)%gto_basis_set%npgf
465 nseta = basis_set(ikind)%gto_basis_set%nset
466 nsgfa = basis_set(ikind)%gto_basis_set%nsgf
467 nsgf_seta => basis_set(ikind)%gto_basis_set%nsgf_set
468 rpgfa => basis_set(ikind)%gto_basis_set%pgf_radius
469 set_radius_a => basis_set(ikind)%gto_basis_set%set_radius
470 sphi_a => basis_set(ikind)%gto_basis_set%sphi
471 zeta => basis_set(ikind)%gto_basis_set%zet
473 IF (
ASSOCIATED(gpotential(kkind)%gth_potential))
THEN
476 alpha_ppnl => gpotential(kkind)%gth_potential%alpha_ppnl
477 cprj => gpotential(kkind)%gth_potential%cprj
478 lppnl = gpotential(kkind)%gth_potential%lppnl
479 nppnl = gpotential(kkind)%gth_potential%nppnl
480 nprj_ppnl => gpotential(kkind)%gth_potential%nprj_ppnl
481 ppnl_radius = gpotential(kkind)%gth_potential%ppnl_radius
482 vprj_ppnl => gpotential(kkind)%gth_potential%vprj_ppnl
483 ELSE IF (
ASSOCIATED(spotential(kkind)%sgp_potential))
THEN
486 nprjc = spotential(kkind)%sgp_potential%nppnl
487 IF (nprjc == 0) cycle
488 nnl = spotential(kkind)%sgp_potential%n_nonlocal
489 lppnl = spotential(kkind)%sgp_potential%lmax
490 is_nonlocal = .false.
491 is_nonlocal(0:lppnl) = spotential(kkind)%sgp_potential%is_nonlocal(0:lppnl)
492 a_nl => spotential(kkind)%sgp_potential%a_nonlocal
493 h_nl => spotential(kkind)%sgp_potential%h_nonlocal
494 c_nl => spotential(kkind)%sgp_potential%c_nonlocal
495 ppnl_radius = spotential(kkind)%sgp_potential%ppnl_radius
497 radp(:) = ppnl_radius
498 cprj => spotential(kkind)%sgp_potential%cprj_ppnl
499 hprj => spotential(kkind)%sgp_potential%vprj_ppnl
500 nppnl =
SIZE(cprj, 2)
506 ra(:) =
pbc(particle_set(iatom)%r(:) - rf, cell) + rf
507 rc(:) =
pbc(particle_set(katom)%r(:) - rf, cell) + rf
508 raf(:) = ra(:) - rf(:)
509 rcf(:) = rc(:) - rf(:)
512 rcf(:) = (/0._dp, 0._dp, 0._dp/)
516 clist => sap_int(iac)%alist(ilist)%clist(jneighbor)
520 ALLOCATE (clist%acint(nsgfa, nppnl, maxder), &
521 clist%achint(nsgfa, nppnl, maxder))
525 NULLIFY (clist%sgf_list)
527 IF (
PRESENT(pseudoatom))
THEN
528 IF (pseudoatom /= katom)
THEN
529 clist%maxac = maxval(abs(clist%acint(:, :, 1)))
530 clist%maxach = maxval(abs(clist%achint(:, :, 1)))
531 IF (.NOT. dogth)
DEALLOCATE (radp)
537 ncoa = npgfa(iset)*
ncoset(la_max(iset))
538 sgfa = first_sgfa(1, iset)
544 nprjc = nprj_ppnl(l)*
nco(l)
545 IF (nprjc == 0) cycle
546 rprjc(1) = ppnl_radius
547 IF (set_radius_a(iset) + rprjc(1) < dac) cycle
548 lc_max = l + 2*(nprj_ppnl(l) - 1)
550 zetc(1) = alpha_ppnl(l)
554 IF (my_momentmode)
THEN
555 CALL overlap(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
556 lc_max, lc_min, 1, rprjc, zetc, rac, dac, sab, 0, .false., ai_work, ldai)
558 CALL overlap(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
559 lc_max, lc_min, 1, rprjc, zetc, rac, dac, sab, nder, .true., ai_work, ldai)
561 IF (my_momentmode .AND. nder >= 1)
THEN
562 CALL moment(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
563 lc_max, 1, zetc, rprjc, nder, raf, rcf, ai_work)
569 sab(1:na, first_col + 1:first_col + np) = ai_work(1:na, 1:np, i)
578 first_col = (i - 1)*ldsab
579 work(1:na, first_col + prjc:first_col + prjc + nb - 1) = &
580 matmul(sab(1:na, first_col + 1:first_col + np), cprj(1:np, prjc:prjc + nb - 1))
589 first_col = (i - 1)*ldsab + 1
592 clist%acint(sgfa:sgfa + na - 1, 1:nb, i) = &
593 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work(1:np, first_col:first_col + nb - 1))
596 clist%achint(sgfa:sgfa + na - 1, 1:nb, i) = &
597 matmul(clist%acint(sgfa:sgfa + na - 1, 1:nb, i), vprj_ppnl(1:nb, 1:nb))
602 IF (my_momentmode)
THEN
603 CALL overlap(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
604 lppnl, 0, nnl, radp, a_nl, rac, dac, sab, 0, .false., ai_work, ldai)
606 CALL overlap(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
607 lppnl, 0, nnl, radp, a_nl, rac, dac, sab, nder, .true., ai_work, ldai)
609 IF (my_momentmode .AND. nder >= 1)
THEN
610 CALL moment(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
611 lppnl, nnl, a_nl, radp, nder, raf, rcf, ai_work)
616 sab(1:na, first_col:first_col + nprjc - 1) = ai_work(1:na, 1:nprjc, i)
624 first_col = (i - 1)*ldsab + 1
626 work(1:np, 1:nb) = matmul(sab(1:np, first_col:first_col + nprjc - 1), cprj(1:nprjc, 1:nb))
629 clist%acint(sgfa:sgfa + na - 1, 1:nb, i) = &
630 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work(1:np, 1:nb))
633 ncoc = sgfa + nsgf_seta(iset) - 1
635 clist%achint(sgfa:ncoc, j, i) = clist%acint(sgfa:ncoc, j, i)*hprj(j)
640 clist%maxac = maxval(abs(clist%acint(:, :, 1)))
641 clist%maxach = maxval(abs(clist%achint(:, :, 1)))
642 IF (.NOT. dogth)
DEALLOCATE (radp)
646 DEALLOCATE (sab, ai_work, work)
650 DEALLOCATE (basis_set, gpotential, spotential)
652 CALL timestop(handle)
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_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, 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, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.