424 SUBROUTINE build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder, moment_mode, refpoint, particle_set, cell, pseudoatom)
428 INTENT(IN),
POINTER :: sap_ppnl
430 POINTER :: qs_kind_set
431 INTEGER,
INTENT(IN) :: nder
432 LOGICAL,
INTENT(IN),
OPTIONAL :: moment_mode
433 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN),
OPTIONAL :: refpoint
435 OPTIONAL,
POINTER :: particle_set
436 TYPE(
cell_type),
INTENT(IN),
OPTIONAL,
POINTER :: cell
437 INTEGER,
OPTIONAL :: pseudoatom
439 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_sap_ints'
441 INTEGER :: first_col, handle, i, iac, iatom, ikind, ilist, iset, j, jneighbor, katom, kkind, &
442 l, lc_max, lc_min, ldai, ldai_nl, ldsab, lppnl, maxco, maxder, maxl, maxlgto, maxlppnl, &
443 maxppnl, maxsgf, na, nb, ncoa, ncoc, nkind, nlist, nneighbor, nnl, np, nppnl, nprjc, &
444 nseta, nsgfa, prjc, sgfa, slot
445 INTEGER,
DIMENSION(3) :: cell_c
446 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nprj_ppnl, &
448 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
449 LOGICAL :: do_upf, dogth, my_momentmode, my_ref
450 LOGICAL,
DIMENSION(0:9) :: is_nonlocal
451 REAL(kind=
dp) :: dac, ppnl_radius
452 REAL(kind=
dp),
ALLOCATABLE :: upf_int(:, :, :)
453 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: radp
454 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: sab, work
455 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: ai_work
456 REAL(kind=
dp),
DIMENSION(1) :: rprjc, zetc
457 REAL(kind=
dp),
DIMENSION(3) :: rac, raf, rcf, rf
458 REAL(kind=
dp),
DIMENSION(:),
POINTER :: a_nl, alpha_ppnl, hprj, set_radius_a
459 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cprj, h_nl, rpgfa, sphi_a, vprj_ppnl, &
461 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: c_nl
466 DIMENSION(:) :: basis_set
472 CALL timeset(routinen, handle)
474 nkind =
SIZE(qs_kind_set)
478 my_momentmode = .false.
479 IF (
PRESENT(moment_mode))
THEN
480 my_momentmode = moment_mode
484 IF (
PRESENT(refpoint))
THEN
486 cpassert((
PRESENT(cell) .AND.
PRESENT(particle_set)))
498 maxl = max(maxlgto, maxlppnl)
501 ldsab = max(maxco,
ncoset(maxlppnl), maxsgf, maxppnl)
502 IF (.NOT. my_momentmode)
THEN
503 ldai =
ncoset(maxl + nder + 1)
510 NULLIFY (gpotential, spotential)
511 ALLOCATE (basis_set(nkind), gpotential(nkind), spotential(nkind))
513 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
514 IF (
ASSOCIATED(orb_basis_set))
THEN
515 basis_set(ikind)%gto_basis_set => orb_basis_set
517 NULLIFY (basis_set(ikind)%gto_basis_set)
519 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential, sgp_potential=sgp_potential)
520 NULLIFY (gpotential(ikind)%gth_potential)
521 NULLIFY (spotential(ikind)%sgp_potential)
522 IF (
ASSOCIATED(gth_potential))
THEN
523 gpotential(ikind)%gth_potential => gth_potential
524 ldai_nl = max(ldai_nl,
ncoset(gth_potential%lprj_ppnl_max))
525 ELSE IF (
ASSOCIATED(sgp_potential))
THEN
526 spotential(ikind)%sgp_potential => sgp_potential
527 IF (
ALLOCATED(sgp_potential%upf_data))
THEN
528 IF (sgp_potential%upf_data%number_of_proj > 0)
THEN
529 IF (sgp_potential%upf_projectors%degree < maxlgto + nder)
THEN
530 CALL upf_projector_init(sgp_potential%upf_data, maxlgto + nder, sgp_potential%upf_projectors)
534 ldai_nl = max(ldai_nl, sgp_potential%n_nonlocal*
ncoset(sgp_potential%lmax))
539 DO slot = 1, sap_ppnl(1)%nl_size
541 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
542 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
543 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
544 katom = sap_ppnl(1)%nlist_task(slot)%jatom
545 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
546 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
547 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
549 iac = ikind + nkind*(kkind - 1)
550 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
551 IF (.NOT.
ASSOCIATED(gpotential(kkind)%gth_potential) .AND. &
552 .NOT.
ASSOCIATED(spotential(kkind)%sgp_potential)) cycle
553 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist))
THEN
554 sap_int(iac)%a_kind = ikind
555 sap_int(iac)%p_kind = kkind
556 sap_int(iac)%nalist = nlist
557 ALLOCATE (sap_int(iac)%alist(nlist))
559 NULLIFY (sap_int(iac)%alist(i)%clist)
560 sap_int(iac)%alist(i)%aatom = 0
561 sap_int(iac)%alist(i)%nclist = 0
564 IF (.NOT.
ASSOCIATED(sap_int(iac)%alist(ilist)%clist))
THEN
565 sap_int(iac)%alist(ilist)%aatom = iatom
566 sap_int(iac)%alist(ilist)%nclist = nneighbor
567 ALLOCATE (sap_int(iac)%alist(ilist)%clist(nneighbor))
569 sap_int(iac)%alist(ilist)%clist(i)%catom = 0
589 ALLOCATE (sab(ldsab, ldsab*maxder), work(ldsab, ldsab*maxder))
591 IF (.NOT. my_momentmode)
THEN
592 ALLOCATE (ai_work(ldai, ldai,
ncoset(nder + 1)))
594 ALLOCATE (ai_work(ldai, ldai_nl,
ncoset(nder + 1)))
600 DO slot = 1, sap_ppnl(1)%nl_size
601 ikind = sap_ppnl(1)%nlist_task(slot)%ikind
602 kkind = sap_ppnl(1)%nlist_task(slot)%jkind
603 iatom = sap_ppnl(1)%nlist_task(slot)%iatom
604 katom = sap_ppnl(1)%nlist_task(slot)%jatom
605 nlist = sap_ppnl(1)%nlist_task(slot)%nlist
606 ilist = sap_ppnl(1)%nlist_task(slot)%ilist
607 nneighbor = sap_ppnl(1)%nlist_task(slot)%nnode
608 jneighbor = sap_ppnl(1)%nlist_task(slot)%inode
609 cell_c(:) = sap_ppnl(1)%nlist_task(slot)%cell(:)
610 rac(1:3) = sap_ppnl(1)%nlist_task(slot)%r(1:3)
612 iac = ikind + nkind*(kkind - 1)
613 IF (.NOT.
ASSOCIATED(basis_set(ikind)%gto_basis_set)) cycle
615 first_sgfa => basis_set(ikind)%gto_basis_set%first_sgf
616 la_max => basis_set(ikind)%gto_basis_set%lmax
617 la_min => basis_set(ikind)%gto_basis_set%lmin
618 npgfa => basis_set(ikind)%gto_basis_set%npgf
619 nseta = basis_set(ikind)%gto_basis_set%nset
620 nsgfa = basis_set(ikind)%gto_basis_set%nsgf
621 nsgf_seta => basis_set(ikind)%gto_basis_set%nsgf_set
622 rpgfa => basis_set(ikind)%gto_basis_set%pgf_radius
623 set_radius_a => basis_set(ikind)%gto_basis_set%set_radius
624 sphi_a => basis_set(ikind)%gto_basis_set%sphi
625 zeta => basis_set(ikind)%gto_basis_set%zet
628 IF (
ASSOCIATED(gpotential(kkind)%gth_potential))
THEN
631 alpha_ppnl => gpotential(kkind)%gth_potential%alpha_ppnl
632 cprj => gpotential(kkind)%gth_potential%cprj
633 lppnl = gpotential(kkind)%gth_potential%lppnl
634 nppnl = gpotential(kkind)%gth_potential%nppnl
635 nprj_ppnl => gpotential(kkind)%gth_potential%nprj_ppnl
636 ppnl_radius = gpotential(kkind)%gth_potential%ppnl_radius
637 vprj_ppnl => gpotential(kkind)%gth_potential%vprj_ppnl
638 ELSE IF (
ASSOCIATED(spotential(kkind)%sgp_potential))
THEN
641 nprjc = spotential(kkind)%sgp_potential%nppnl
642 IF (nprjc == 0) cycle
643 do_upf =
ALLOCATED(spotential(kkind)%sgp_potential%upf_data)
645 upf => spotential(kkind)%sgp_potential%upf_projectors
648 nnl = spotential(kkind)%sgp_potential%n_nonlocal
649 lppnl = spotential(kkind)%sgp_potential%lmax
650 is_nonlocal = .false.
651 is_nonlocal(0:lppnl) = spotential(kkind)%sgp_potential%is_nonlocal(0:lppnl)
652 a_nl => spotential(kkind)%sgp_potential%a_nonlocal
653 h_nl => spotential(kkind)%sgp_potential%h_nonlocal
654 c_nl => spotential(kkind)%sgp_potential%c_nonlocal
655 ppnl_radius = spotential(kkind)%sgp_potential%ppnl_radius
657 radp(:) = ppnl_radius
658 cprj => spotential(kkind)%sgp_potential%cprj_ppnl
659 hprj => spotential(kkind)%sgp_potential%vprj_ppnl
660 nppnl =
SIZE(cprj, 2)
667 raf(:) =
pbc(particle_set(iatom)%r(:) - rf, cell)
675 clist => sap_int(iac)%alist(ilist)%clist(jneighbor)
679 ALLOCATE (clist%acint(nsgfa, nppnl, maxder), &
680 clist%achint(nsgfa, nppnl, maxder))
684 NULLIFY (clist%sgf_list)
686 IF (
PRESENT(pseudoatom))
THEN
687 IF (pseudoatom /= katom)
THEN
688 clist%maxac = maxval(abs(clist%acint(:, :, 1)))
689 clist%maxach = maxval(abs(clist%achint(:, :, 1)))
690 IF (.NOT. dogth .AND. .NOT. do_upf)
DEALLOCATE (radp)
696 ncoa = npgfa(iset)*
ncoset(la_max(iset))
697 sgfa = first_sgfa(1, iset)
703 nprjc = nprj_ppnl(l)*
nco(l)
704 IF (nprjc == 0) cycle
705 rprjc(1) = ppnl_radius
706 IF (set_radius_a(iset) + rprjc(1) < dac) cycle
707 lc_max = l + 2*(nprj_ppnl(l) - 1)
709 zetc(1) = alpha_ppnl(l)
713 IF (my_momentmode)
THEN
714 CALL moment(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
715 lc_max, 1, zetc, rprjc, nder, raf, rcf, ai_work,
overlap=sab)
721 sab(1:na, first_col + 1:first_col + np) = ai_work(1:na, 1:np, i)
724 CALL overlap(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
725 lc_max, lc_min, 1, rprjc, zetc, rac, dac, sab, nder, .true., ai_work, ldai)
733 first_col = (i - 1)*ldsab
734 work(1:na, first_col + prjc:first_col + prjc + nb - 1) = &
735 matmul(sab(1:na, first_col + 1:first_col + np), cprj(1:np, prjc:prjc + nb - 1))
744 first_col = (i - 1)*ldsab + 1
747 clist%acint(sgfa:sgfa + na - 1, 1:nb, i) = &
748 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work(1:np, first_col:first_col + nb - 1))
751 clist%achint(sgfa:sgfa + na - 1, 1:nb, i) = &
752 matmul(clist%acint(sgfa:sgfa + na - 1, 1:nb, i), vprj_ppnl(1:nb, 1:nb))
754 ELSE IF (do_upf)
THEN
758 ALLOCATE (upf_int(np, nb, maxder))
759 IF (my_momentmode)
THEN
761 rac, nder, upf_int, moment_origin=raf)
767 clist%acint(sgfa:sgfa + na - 1, 1:nb, i) = &
768 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), upf_int(:, :, i))
769 clist%achint(sgfa:sgfa + na - 1, 1:nb, i) = &
770 matmul(clist%acint(sgfa:sgfa + na - 1, 1:nb, i), upf%d)
776 IF (my_momentmode)
THEN
777 CALL moment(la_max(iset), npgfa(iset), zeta(:, iset), rpgfa(:, iset), la_min(iset), &
778 lppnl, nnl, a_nl, radp, nder, raf, rcf, ai_work,
overlap=sab)
782 first_col = i*ldsab + 1
783 sab(1:na, first_col:first_col + nprjc - 1) = ai_work(1:na, 1:nprjc, i)
786 CALL overlap(la_max(iset), la_min(iset), npgfa(iset), rpgfa(:, iset), zeta(:, iset), &
787 lppnl, 0, nnl, radp, a_nl, rac, dac, sab, nder, .true., ai_work, ldai)
794 first_col = (i - 1)*ldsab + 1
796 work(1:np, 1:nb) = matmul(sab(1:np, first_col:first_col + nprjc - 1), cprj(1:nprjc, 1:nb))
799 clist%acint(sgfa:sgfa + na - 1, 1:nb, i) = &
800 matmul(transpose(sphi_a(1:np, sgfa:sgfa + na - 1)), work(1:np, 1:nb))
803 ncoc = sgfa + nsgf_seta(iset) - 1
805 clist%achint(sgfa:ncoc, j, i) = clist%acint(sgfa:ncoc, j, i)*hprj(j)
810 clist%maxac = maxval(abs(clist%acint(:, :, 1)))
811 clist%maxach = maxval(abs(clist%achint(:, :, 1)))
812 IF (.NOT. dogth .AND. .NOT. do_upf)
DEALLOCATE (radp)
816 DEALLOCATE (sab, ai_work, work)
820 DEALLOCATE (basis_set, gpotential, spotential)
822 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, 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.