113#include "./base/base_uses.f90"
119 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_collocate_density'
139 MODULE PROCEDURE calculate_rho_core_r3d_rs
140 MODULE PROCEDURE calculate_rho_core_c1d_gs
144 MODULE PROCEDURE calculate_rho_resp_all_r3d_rs, calculate_rho_resp_all_c1d_gs
159 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_nlcc'
161 INTEGER :: atom_a, handle, iatom, iexp_nlcc, ikind, &
162 ithread, j, n, natom, nc, nexp_nlcc, &
163 ni, npme, nthread, subpatch_pattern
164 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores, nct_nlcc
166 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
167 REAL(kind=
dp),
DIMENSION(3) :: ra
168 REAL(kind=
dp),
DIMENSION(:),
POINTER :: alpha_nlcc
169 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cval_nlcc, pab
177 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
180 CALL timeset(routinen, handle)
182 NULLIFY (cell, dft_control, pab, particle_set, atomic_kind_set, &
183 qs_kind_set, atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
186 atomic_kind_set=atomic_kind_set, &
187 qs_kind_set=qs_kind_set, &
189 dft_control=dft_control, &
190 particle_set=particle_set, &
192 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
193 auxbas_pw_pool=auxbas_pw_pool)
197 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
199 DO ikind = 1,
SIZE(atomic_kind_set)
200 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
201 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential)
203 IF (.NOT.
ASSOCIATED(gth_potential)) cycle
204 CALL get_potential(potential=gth_potential, nlcc_present=nlcc, nexp_nlcc=nexp_nlcc, &
205 alpha_nlcc=alpha_nlcc, nct_nlcc=nct_nlcc, cval_nlcc=cval_nlcc)
207 IF (.NOT. nlcc) cycle
209 DO iexp_nlcc = 1, nexp_nlcc
211 alpha = alpha_nlcc(iexp_nlcc)
212 nc = nct_nlcc(iexp_nlcc)
215 ALLOCATE (pab(ni, 1))
229 pab(1, 1) = cval_nlcc(1, iexp_nlcc)
232 pab(n, 1) = cval_nlcc(2, iexp_nlcc)/alpha**2
234 pab(n, 1) = cval_nlcc(2, iexp_nlcc)/alpha**2
236 pab(n, 1) = cval_nlcc(2, iexp_nlcc)/alpha**2
239 pab(n, 1) = cval_nlcc(3, iexp_nlcc)/alpha**4
241 pab(n, 1) = cval_nlcc(3, iexp_nlcc)/alpha**4
243 pab(n, 1) = cval_nlcc(3, iexp_nlcc)/alpha**4
245 pab(n, 1) = 2._dp*cval_nlcc(3, iexp_nlcc)/alpha**4
247 pab(n, 1) = 2._dp*cval_nlcc(3, iexp_nlcc)/alpha**4
249 pab(n, 1) = 2._dp*cval_nlcc(3, iexp_nlcc)/alpha**4
252 pab(n, 1) = cval_nlcc(4, iexp_nlcc)/alpha**6
254 pab(n, 1) = cval_nlcc(4, iexp_nlcc)/alpha**6
256 pab(n, 1) = cval_nlcc(4, iexp_nlcc)/alpha**6
258 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
260 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
262 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
264 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
266 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
268 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
270 pab(n, 1) = 6._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
272 CALL cp_abort(__location__, &
273 "Only 1, 2, 3, 4 are supported as the "// &
274 "value of j in calculate_rho_nlcc")
277 IF (dft_control%nspins == 2) pab = pab*0.5_dp
280 atom_a = atom_list(iatom)
281 ra(:) =
pbc(particle_set(atom_a)%r, cell)
282 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
284 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
297 atom_a = atom_list(iatom)
298 ra(:) =
pbc(particle_set(atom_a)%r, cell)
302 ra=ra, rb=ra, rp=ra, &
303 zetp=1/(2*alpha**2), eps=eps_rho_rspace, &
304 pab=pab, o1=0, o2=0, &
305 prefactor=1.0_dp, cutoff=0.0_dp)
308 [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, 0, 0, rs_rho, &
310 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
320 IF (
ASSOCIATED(cores))
THEN
326 CALL timestop(handle)
340 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_ppl_grid'
342 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
343 j, lppl, n, natom, ni, npme, nthread, &
345 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
346 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
347 REAL(kind=
dp),
DIMENSION(3) :: ra
348 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cexp_ppl
349 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
357 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
360 CALL timeset(routinen, handle)
362 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
363 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
366 atomic_kind_set=atomic_kind_set, &
367 qs_kind_set=qs_kind_set, &
369 dft_control=dft_control, &
370 particle_set=particle_set, &
372 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
373 auxbas_pw_pool=auxbas_pw_pool)
377 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
379 DO ikind = 1,
SIZE(atomic_kind_set)
380 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
381 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential)
383 IF (.NOT.
ASSOCIATED(gth_potential)) cycle
384 CALL get_potential(potential=gth_potential, alpha_ppl=alpha, nexp_ppl=lppl, cexp_ppl=cexp_ppl)
389 ALLOCATE (pab(ni, 1))
403 pab(1, 1) = cexp_ppl(1)
406 pab(n, 1) = cexp_ppl(2)
408 pab(n, 1) = cexp_ppl(2)
410 pab(n, 1) = cexp_ppl(2)
413 pab(n, 1) = cexp_ppl(3)
415 pab(n, 1) = cexp_ppl(3)
417 pab(n, 1) = cexp_ppl(3)
419 pab(n, 1) = 2._dp*cexp_ppl(3)
421 pab(n, 1) = 2._dp*cexp_ppl(3)
423 pab(n, 1) = 2._dp*cexp_ppl(3)
426 pab(n, 1) = cexp_ppl(4)
428 pab(n, 1) = cexp_ppl(4)
430 pab(n, 1) = cexp_ppl(4)
432 pab(n, 1) = 3._dp*cexp_ppl(4)
434 pab(n, 1) = 3._dp*cexp_ppl(4)
436 pab(n, 1) = 3._dp*cexp_ppl(4)
438 pab(n, 1) = 3._dp*cexp_ppl(4)
440 pab(n, 1) = 3._dp*cexp_ppl(4)
442 pab(n, 1) = 3._dp*cexp_ppl(4)
444 pab(n, 1) = 6._dp*cexp_ppl(4)
446 CALL cp_abort(__location__, &
447 "Only 1, 2, 3, 4 are supported as the "// &
448 "value of j in calculate_ppl_grid")
453 atom_a = atom_list(iatom)
454 ra(:) =
pbc(particle_set(atom_a)%r, cell)
455 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
457 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
471 atom_a = atom_list(iatom)
472 ra(:) =
pbc(particle_set(atom_a)%r, cell)
477 lb_min=0, lb_max=0, &
478 ra=ra, rb=ra, rp=ra, &
479 zetp=alpha, eps=eps_rho_rspace, &
480 pab=pab, o1=0, o2=0, &
481 prefactor=1.0_dp, cutoff=0.0_dp)
484 [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, 0, 0, rs_rho, &
486 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
495 IF (
ASSOCIATED(cores))
THEN
501 CALL timestop(handle)
521 lri_coef, total_rho, basis_type, exact_1c_terms, pmat, atomlist)
527 REAL(kind=
dp),
INTENT(OUT) :: total_rho
528 CHARACTER(len=*),
INTENT(IN) :: basis_type
529 LOGICAL,
INTENT(IN) :: exact_1c_terms
531 INTEGER,
DIMENSION(:),
OPTIONAL :: atomlist
533 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_lri_rho_elec'
535 INTEGER :: atom_a, group_size, handle, iatom, igrid_level, ikind, ipgf, iset, jpgf, jset, &
536 m1, maxco, maxsgf_set, my_pos, na1, natom, nb1, ncoa, ncob, nseta, offset, sgfa, sgfb
537 INTEGER,
DIMENSION(:),
POINTER :: atom_list, la_max, la_min, npgfa, nsgfa
538 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
540 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: map_it
541 LOGICAL,
ALLOCATABLE,
DIMENSION(:, :) :: map_it2
542 REAL(kind=
dp) :: eps_rho_rspace, radius, zetp
543 REAL(kind=
dp),
DIMENSION(3) :: ra
544 REAL(kind=
dp),
DIMENSION(:),
POINTER :: aci
545 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, pab, sphi_a, work, zeta
556 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
560 NULLIFY (aci, atomic_kind_set, qs_kind_set, atom_list, cell, &
561 dft_control, first_sgfa, gridlevel_info, la_max, &
562 la_min, lri_basis_set, npgfa, nsgfa, &
563 pab, particle_set, pw_env, pw_pools, rs_grid, rs_rho, sphi_a, &
566 CALL timeset(routinen, handle)
568 IF (exact_1c_terms)
THEN
569 cpassert(
PRESENT(pmat))
572 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, &
573 atomic_kind_set=atomic_kind_set, &
574 cell=cell, particle_set=particle_set, &
576 dft_control=dft_control)
578 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
579 gridlevel_info => pw_env%gridlevel_info
582 cpassert(
ASSOCIATED(pw_env))
583 CALL pw_env_get(pw_env=pw_env, rs_grids=rs_rho, pw_pools=pw_pools)
590 DO igrid_level = 1, gridlevel_info%ngrid_levels
596 maxco=maxco, basis_type=basis_type)
598 ALLOCATE (pab(maxco, 1))
600 my_pos = mgrid_rspace(1)%pw_grid%para%group%mepos
601 group_size = mgrid_rspace(1)%pw_grid%para%group%num_pe
603 DO ikind = 1,
SIZE(atomic_kind_set)
605 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
606 CALL get_qs_kind(qs_kind_set(ikind), basis_set=lri_basis_set, basis_type=basis_type)
610 lmin=la_min, zet=zeta, nset=nseta, npgf=npgfa, &
611 sphi=sphi_a, first_sgf=first_sgfa, nsgf_set=nsgfa)
614 atom_a = atom_list(iatom)
615 IF (
PRESENT(atomlist))
THEN
616 IF (atomlist(atom_a) == 0) cycle
618 ra(:) =
pbc(particle_set(atom_a)%r, cell)
619 aci => lri_coef(ikind)%acoef(iatom, :)
621 m1 = maxval(npgfa(1:nseta))
622 ALLOCATE (map_it(m1))
626 DO ipgf = 1, npgfa(iset)
628 rs_grid => rs_rho(igrid_level)
629 map_it(ipgf) =
map_gaussian_here(rs_grid, cell%h_inv, ra, offset, group_size, my_pos)
633 IF (any(map_it(1:npgfa(iset))))
THEN
634 sgfa = first_sgfa(1, iset)
635 ncoa = npgfa(iset)*
ncoset(la_max(iset))
636 m1 = sgfa + nsgfa(iset) - 1
637 ALLOCATE (work(nsgfa(iset), 1))
638 work(1:nsgfa(iset), 1) = aci(sgfa:m1)
641 CALL dgemm(
"N",
"N", ncoa, 1, nsgfa(iset), 1.0_dp, lri_basis_set%sphi(1, sgfa), &
642 SIZE(lri_basis_set%sphi, 1), work(1, 1),
SIZE(work, 1), 0.0_dp, pab(1, 1), &
645 DO ipgf = 1, npgfa(iset)
646 na1 = (ipgf - 1)*
ncoset(la_max(iset))
648 rs_grid => rs_rho(igrid_level)
649 IF (map_it(ipgf))
THEN
651 lb_min=0, lb_max=0, &
652 ra=ra, rb=ra, rp=ra, &
653 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
654 prefactor=1.0_dp, cutoff=1.0_dp)
657 zeta=zeta(ipgf, iset), &
658 la_min=la_min(iset), &
659 lb_max=0, zetb=0.0_dp, lb_min=0, &
660 ra=ra, rab=[0.0_dp, 0.0_dp, 0.0_dp], &
662 pab=pab, o1=na1, o2=0, &
678 IF (exact_1c_terms)
THEN
683 maxsgf_set=maxsgf_set, &
685 ALLOCATE (pab(maxco, maxco), work(maxco, maxsgf_set))
687 DO ikind = 1,
SIZE(atomic_kind_set)
688 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
689 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=
"ORB")
691 lmin=la_min, zet=zeta, nset=nseta, npgf=npgfa, &
692 sphi=sphi_a, first_sgf=first_sgfa, nsgf_set=nsgfa)
694 atom_a = atom_list(iatom)
695 ra(:) =
pbc(particle_set(atom_a)%r, cell)
696 CALL dbcsr_get_block_p(matrix=pmat, row=atom_a, col=atom_a, block=p_block, found=found)
697 m1 = maxval(npgfa(1:nseta))
698 ALLOCATE (map_it2(m1, m1))
703 DO ipgf = 1, npgfa(iset)
704 DO jpgf = 1, npgfa(jset)
705 zetp = zeta(ipgf, iset) + zeta(jpgf, jset)
707 rs_grid => rs_rho(igrid_level)
708 map_it2(ipgf, jpgf) =
map_gaussian_here(rs_grid, cell%h_inv, ra, offset, group_size, my_pos)
713 IF (any(map_it2(1:npgfa(iset), 1:npgfa(jset))))
THEN
714 ncoa = npgfa(iset)*
ncoset(la_max(iset))
715 sgfa = first_sgfa(1, iset)
716 ncob = npgfa(jset)*
ncoset(la_max(jset))
717 sgfb = first_sgfa(1, jset)
719 CALL dgemm(
"N",
"N", ncoa, nsgfa(jset), nsgfa(iset), &
720 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
721 p_block(sgfa, sgfb),
SIZE(p_block, 1), &
722 0.0_dp, work(1, 1), maxco)
723 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfa(jset), &
724 1.0_dp, work(1, 1), maxco, &
725 sphi_a(1, sgfb),
SIZE(sphi_a, 1), &
726 0.0_dp, pab(1, 1), maxco)
727 DO ipgf = 1, npgfa(iset)
728 DO jpgf = 1, npgfa(jset)
729 zetp = zeta(ipgf, iset) + zeta(jpgf, jset)
731 rs_grid => rs_rho(igrid_level)
733 na1 = (ipgf - 1)*
ncoset(la_max(iset))
734 nb1 = (jpgf - 1)*
ncoset(la_max(jset))
736 IF (map_it2(ipgf, jpgf))
THEN
738 la_max=la_max(iset), &
739 lb_min=la_min(jset), &
740 lb_max=la_max(jset), &
741 ra=ra, rb=ra, rp=ra, &
742 zetp=zetp, eps=eps_rho_rspace, &
743 prefactor=1.0_dp, cutoff=1.0_dp)
746 la_max(iset), zeta(ipgf, iset), la_min(iset), &
747 la_max(jset), zeta(jpgf, jset), la_min(jset), &
748 ra, [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, na1, nb1, &
761 DEALLOCATE (pab, work)
767 DO igrid_level = 1, gridlevel_info%ngrid_levels
768 CALL pw_zero(mgrid_rspace(igrid_level))
770 pw=mgrid_rspace(igrid_level))
773 DO igrid_level = 1, gridlevel_info%ngrid_levels
774 CALL pw_zero(mgrid_gspace(igrid_level))
776 mgrid_gspace(igrid_level))
777 CALL pw_axpy(mgrid_gspace(igrid_level), lri_rho_g)
786 CALL timestop(handle)
799 SUBROUTINE calculate_rho_core_r3d_rs (rho_core, total_rho, qs_env, calpha, ccore, only_nopaw)
802 REAL(KIND=
dp),
INTENT(OUT) :: total_rho
804 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: calpha, ccore
805 LOGICAL,
INTENT(IN),
OPTIONAL :: only_nopaw
807 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_core'
809 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
810 j, natom, npme, nthread, &
812 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
813 LOGICAL :: my_only_nopaw, paw_atom
814 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
815 REAL(kind=
dp),
DIMENSION(3) :: ra
816 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
824 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
827 CALL timeset(routinen, handle)
828 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
829 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
832 my_only_nopaw = .false.
833 IF (
PRESENT(only_nopaw)) my_only_nopaw = only_nopaw
834 IF (
PRESENT(calpha))
THEN
835 cpassert(
PRESENT(ccore))
839 atomic_kind_set=atomic_kind_set, &
840 qs_kind_set=qs_kind_set, &
842 dft_control=dft_control, &
843 particle_set=particle_set, &
845 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
846 auxbas_pw_pool=auxbas_pw_pool)
850 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
852 DO ikind = 1,
SIZE(atomic_kind_set)
853 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
854 IF (
PRESENT(calpha))
THEN
855 alpha = calpha(ikind)
856 pab(1, 1) = ccore(ikind)
858 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
859 IF (my_only_nopaw .AND. paw_atom) cycle
860 CALL get_qs_kind(qs_kind_set(ikind), alpha_core_charge=alpha, &
861 ccore_charge=pab(1, 1))
864 IF (my_only_nopaw .AND. paw_atom) cycle
865 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
875 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
877 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
891 atom_a = atom_list(iatom)
892 ra(:) =
pbc(particle_set(atom_a)%r, cell)
895 lb_min=0, lb_max=0, &
896 ra=ra, rb=ra, rp=ra, &
897 zetp=alpha, eps=eps_rho_rspace, &
898 pab=pab, o1=0, o2=0, &
899 prefactor=-1.0_dp, cutoff=0.0_dp)
902 [0.0_dp, 0.0_dp, 0.0_dp], -1.0_dp, pab, 0, 0, rs_rho, &
904 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
911 IF (
ASSOCIATED(cores))
THEN
916 CALL auxbas_pw_pool%create_pw(rhoc_r)
924 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
926 CALL timestop(handle)
928 END SUBROUTINE calculate_rho_core_r3d_rs
938 SUBROUTINE calculate_rho_core_c1d_gs (rho_core, total_rho, qs_env, calpha, ccore, only_nopaw)
941 REAL(KIND=
dp),
INTENT(OUT) :: total_rho
943 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: calpha, ccore
944 LOGICAL,
INTENT(IN),
OPTIONAL :: only_nopaw
946 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_core'
948 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
949 j, natom, npme, nthread, &
951 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
952 LOGICAL :: my_only_nopaw, paw_atom
953 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
954 REAL(kind=
dp),
DIMENSION(3) :: ra
955 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
963 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
966 CALL timeset(routinen, handle)
967 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
968 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
971 my_only_nopaw = .false.
972 IF (
PRESENT(only_nopaw)) my_only_nopaw = only_nopaw
973 IF (
PRESENT(calpha))
THEN
974 cpassert(
PRESENT(ccore))
978 atomic_kind_set=atomic_kind_set, &
979 qs_kind_set=qs_kind_set, &
981 dft_control=dft_control, &
982 particle_set=particle_set, &
984 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
985 auxbas_pw_pool=auxbas_pw_pool)
989 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
991 DO ikind = 1,
SIZE(atomic_kind_set)
992 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
993 IF (
PRESENT(calpha))
THEN
994 alpha = calpha(ikind)
995 pab(1, 1) = ccore(ikind)
997 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
998 IF (my_only_nopaw .AND. paw_atom) cycle
999 CALL get_qs_kind(qs_kind_set(ikind), alpha_core_charge=alpha, &
1000 ccore_charge=pab(1, 1))
1003 IF (my_only_nopaw .AND. paw_atom) cycle
1004 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
1014 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1016 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1030 atom_a = atom_list(iatom)
1031 ra(:) =
pbc(particle_set(atom_a)%r, cell)
1032 subpatch_pattern = 0
1034 lb_min=0, lb_max=0, &
1035 ra=ra, rb=ra, rp=ra, &
1036 zetp=alpha, eps=eps_rho_rspace, &
1037 pab=pab, o1=0, o2=0, &
1038 prefactor=-1.0_dp, cutoff=0.0_dp)
1041 [0.0_dp, 0.0_dp, 0.0_dp], -1.0_dp, pab, 0, 0, rs_rho, &
1043 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1050 IF (
ASSOCIATED(cores))
THEN
1055 CALL auxbas_pw_pool%create_pw(rhoc_r)
1063 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1065 CALL timestop(handle)
1067 END SUBROUTINE calculate_rho_core_c1d_gs
1082 INTEGER,
INTENT(IN) :: beta, lambda
1084 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_drho_core'
1086 INTEGER :: atom_a, dabqadb_func, handle, iatom, &
1087 ikind, ithread, j, natom, npme, &
1088 nthread, subpatch_pattern
1089 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
1090 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
1091 REAL(kind=
dp),
DIMENSION(3) :: ra
1092 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1100 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1103 CALL timeset(routinen, handle)
1104 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
1105 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
1106 ALLOCATE (pab(1, 1))
1109 atomic_kind_set=atomic_kind_set, &
1110 qs_kind_set=qs_kind_set, &
1112 dft_control=dft_control, &
1113 particle_set=particle_set, &
1115 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1116 auxbas_pw_pool=auxbas_pw_pool)
1120 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1130 cpabort(
"invalid beta")
1132 DO ikind = 1,
SIZE(atomic_kind_set)
1133 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
1135 alpha_core_charge=alpha, ccore_charge=pab(1, 1))
1137 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
1147 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1149 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1163 atom_a = atom_list(iatom)
1164 IF (atom_a /= lambda) cycle
1165 ra(:) =
pbc(particle_set(atom_a)%r, cell)
1166 subpatch_pattern = 0
1168 lb_min=0, lb_max=0, &
1169 ra=ra, rb=ra, rp=ra, &
1170 zetp=alpha, eps=eps_rho_rspace, &
1171 pab=pab, o1=0, o2=0, &
1172 prefactor=-1.0_dp, cutoff=0.0_dp)
1175 [0.0_dp, 0.0_dp, 0.0_dp], -1.0_dp, pab, 0, 0, rs_rho, &
1176 radius=radius, ga_gb_function=dabqadb_func, &
1177 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1184 IF (
ASSOCIATED(cores))
THEN
1189 CALL auxbas_pw_pool%create_pw(rhoc_r)
1195 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1197 CALL timestop(handle)
1214 INTEGER,
INTENT(IN) :: iatom_in
1216 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_single_gaussian'
1218 INTEGER :: atom_a, handle, iatom, npme, &
1220 REAL(kind=
dp) :: eps_rho_rspace, radius
1221 REAL(kind=
dp),
DIMENSION(3) :: ra
1222 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1230 CALL timeset(routinen, handle)
1231 NULLIFY (cell, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool)
1233 ALLOCATE (pab(1, 1))
1237 dft_control=dft_control, &
1239 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1240 auxbas_pw_pool=auxbas_pw_pool)
1243 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1249 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1250 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1258 atom_a = qs_env%qmmm_env_qm%image_charge_pot%image_mm_list(iatom)
1259 ra(:) =
pbc(qs_env%qmmm_env_qm%image_charge_pot%particles_all(atom_a)%r, cell)
1260 subpatch_pattern = 0
1262 lb_min=0, lb_max=0, &
1263 ra=ra, rb=ra, rp=ra, &
1264 zetp=qs_env%qmmm_env_qm%image_charge_pot%eta, &
1265 eps=eps_rho_rspace, &
1266 pab=pab, o1=0, o2=0, &
1267 prefactor=1.0_dp, cutoff=0.0_dp)
1270 0, 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, 0, 0, rs_rho, &
1272 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1277 CALL auxbas_pw_pool%create_pw(rhoc_r)
1283 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1285 CALL timestop(handle)
1303 REAL(kind=
dp),
DIMENSION(:),
POINTER :: coeff
1304 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: total_rho_metal
1307 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_metal'
1309 INTEGER :: atom_a, handle, iatom, j, natom, npme, &
1311 INTEGER,
DIMENSION(:),
POINTER :: cores
1312 REAL(kind=
dp) :: eps_rho_rspace, radius
1313 REAL(kind=
dp),
DIMENSION(3) :: ra
1314 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1322 CALL timeset(routinen, handle)
1324 NULLIFY (cell, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, cores)
1326 ALLOCATE (pab(1, 1))
1330 dft_control=dft_control, &
1332 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1333 auxbas_pw_pool=auxbas_pw_pool)
1336 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1339 natom =
SIZE(qs_env%qmmm_env_qm%image_charge_pot%image_mm_list)
1346 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1347 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1360 atom_a = qs_env%qmmm_env_qm%image_charge_pot%image_mm_list(iatom)
1361 ra(:) =
pbc(qs_env%qmmm_env_qm%image_charge_pot%particles_all(atom_a)%r, cell)
1362 subpatch_pattern = 0
1364 lb_min=0, lb_max=0, &
1365 ra=ra, rb=ra, rp=ra, &
1366 zetp=qs_env%qmmm_env_qm%image_charge_pot%eta, &
1367 eps=eps_rho_rspace, &
1368 pab=pab, o1=0, o2=0, &
1369 prefactor=coeff(iatom), cutoff=0.0_dp)
1372 0, qs_env%qmmm_env_qm%image_charge_pot%eta, &
1373 0, 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], coeff(iatom), pab, 0, 0, rs_rho, &
1375 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1379 DEALLOCATE (pab, cores)
1381 CALL auxbas_pw_pool%create_pw(rhoc_r)
1385 IF (
PRESENT(total_rho_metal)) &
1390 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1392 CALL timestop(handle)
1410 REAL(kind=
dp),
INTENT(IN) :: eta
1411 INTEGER,
INTENT(IN) :: iatom_in
1413 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_resp_single'
1415 INTEGER :: handle, iatom, npme, subpatch_pattern
1416 REAL(kind=
dp) :: eps_rho_rspace, radius
1417 REAL(kind=
dp),
DIMENSION(3) :: ra
1418 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1427 CALL timeset(routinen, handle)
1428 NULLIFY (cell, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, &
1431 ALLOCATE (pab(1, 1))
1435 dft_control=dft_control, &
1436 particle_set=particle_set, &
1438 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1439 auxbas_pw_pool=auxbas_pw_pool)
1442 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1448 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1449 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1457 ra(:) =
pbc(particle_set(iatom)%r, cell)
1458 subpatch_pattern = 0
1460 lb_min=0, lb_max=0, &
1461 ra=ra, rb=ra, rp=ra, &
1462 zetp=eta, eps=eps_rho_rspace, &
1463 pab=pab, o1=0, o2=0, &
1464 prefactor=1.0_dp, cutoff=0.0_dp)
1467 [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, 0, 0, rs_rho, &
1469 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1474 CALL auxbas_pw_pool%create_pw(rhoc_r)
1480 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1482 CALL timestop(handle)
1498 SUBROUTINE calculate_rho_resp_all_r3d_rs (rho_resp, coeff, natom, eta, qs_env)
1501 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: coeff
1502 INTEGER,
INTENT(IN) :: natom
1503 REAL(KIND=
dp),
INTENT(IN) :: eta
1506 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_resp_all'
1508 INTEGER :: handle, iatom, j, npme, subpatch_pattern
1509 INTEGER,
DIMENSION(:),
POINTER :: cores
1510 REAL(kind=
dp) :: eps_rho_rspace, radius
1511 REAL(kind=
dp),
DIMENSION(3) :: ra
1512 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1521 CALL timeset(routinen, handle)
1523 NULLIFY (cell, cores, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, &
1526 ALLOCATE (pab(1, 1))
1530 dft_control=dft_control, &
1531 particle_set=particle_set, &
1533 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1534 auxbas_pw_pool=auxbas_pw_pool)
1537 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1545 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1546 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1559 ra(:) =
pbc(particle_set(iatom)%r, cell)
1560 subpatch_pattern = 0
1562 lb_min=0, lb_max=0, &
1563 ra=ra, rb=ra, rp=ra, &
1564 zetp=eta, eps=eps_rho_rspace, &
1565 pab=pab, o1=0, o2=0, &
1566 prefactor=coeff(iatom), cutoff=0.0_dp)
1570 0, 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], coeff(iatom), pab, 0, 0, rs_rho, &
1572 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1576 DEALLOCATE (pab, cores)
1578 CALL auxbas_pw_pool%create_pw(rhoc_r)
1583 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1585 CALL timestop(handle)
1587 END SUBROUTINE calculate_rho_resp_all_r3d_rs
1600 SUBROUTINE calculate_rho_resp_all_c1d_gs (rho_resp, coeff, natom, eta, qs_env)
1603 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: coeff
1604 INTEGER,
INTENT(IN) :: natom
1605 REAL(KIND=
dp),
INTENT(IN) :: eta
1608 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_resp_all'
1610 INTEGER :: handle, iatom, j, npme, subpatch_pattern
1611 INTEGER,
DIMENSION(:),
POINTER :: cores
1612 REAL(kind=
dp) :: eps_rho_rspace, radius
1613 REAL(kind=
dp),
DIMENSION(3) :: ra
1614 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1623 CALL timeset(routinen, handle)
1625 NULLIFY (cell, cores, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, &
1628 ALLOCATE (pab(1, 1))
1632 dft_control=dft_control, &
1633 particle_set=particle_set, &
1635 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1636 auxbas_pw_pool=auxbas_pw_pool)
1639 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1647 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1648 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1661 ra(:) =
pbc(particle_set(iatom)%r, cell)
1662 subpatch_pattern = 0
1664 lb_min=0, lb_max=0, &
1665 ra=ra, rb=ra, rp=ra, &
1666 zetp=eta, eps=eps_rho_rspace, &
1667 pab=pab, o1=0, o2=0, &
1668 prefactor=coeff(iatom), cutoff=0.0_dp)
1672 0, 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], coeff(iatom), pab, 0, 0, rs_rho, &
1674 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1678 DEALLOCATE (pab, cores)
1680 CALL auxbas_pw_pool%create_pw(rhoc_r)
1685 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1687 CALL timestop(handle)
1689 END SUBROUTINE calculate_rho_resp_all_c1d_gs
1717 ks_env, soft_valid, compute_tau, compute_grad, &
1718 basis_type, der_type, idir, task_list_external, pw_env_external)
1720 TYPE(
dbcsr_type),
OPTIONAL,
TARGET :: matrix_p
1722 POINTER :: matrix_p_kp
1725 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: total_rho
1727 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid, compute_tau, compute_grad
1728 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
1729 INTEGER,
INTENT(IN),
OPTIONAL :: der_type, idir
1731 TYPE(
pw_env_type),
OPTIONAL,
POINTER :: pw_env_external
1733 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_elec'
1735 CHARACTER(LEN=default_string_length) :: my_basis_type
1736 INTEGER :: ga_gb_function, handle, ilevel, img, &
1738 LOGICAL :: any_distributed, my_compute_grad, &
1739 my_compute_tau, my_soft_valid
1740 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_images
1747 CALL timeset(routinen, handle)
1749 NULLIFY (matrix_images, dft_control, pw_env, rs_rho, task_list)
1752 my_compute_tau = .false.
1753 IF (
PRESENT(compute_tau)) my_compute_tau = compute_tau
1754 my_compute_grad = .false.
1755 IF (
PRESENT(compute_grad)) my_compute_grad = compute_grad
1756 IF (
PRESENT(der_type))
THEN
1757 SELECT CASE (der_type)
1779 cpabort(
"Unknown der_type")
1781 ELSE IF (my_compute_tau)
THEN
1783 ELSE IF (my_compute_grad)
THEN
1784 cpassert(
PRESENT(idir))
1793 cpabort(
"invalid idir")
1800 my_basis_type =
"ORB"
1801 IF (
PRESENT(basis_type)) my_basis_type = basis_type
1802 cpassert(my_basis_type ==
"ORB" .OR.
PRESENT(task_list_external))
1805 my_soft_valid = .false.
1806 IF (
PRESENT(soft_valid)) my_soft_valid = soft_valid
1807 IF (
PRESENT(task_list_external))
THEN
1808 task_list => task_list_external
1809 ELSEIF (my_soft_valid)
THEN
1810 CALL get_ks_env(ks_env, task_list_soft=task_list)
1814 cpassert(
ASSOCIATED(task_list))
1817 IF (
PRESENT(pw_env_external))
THEN
1818 pw_env => pw_env_external
1822 cpassert(
ASSOCIATED(pw_env))
1826 nlevels =
SIZE(rs_rho)
1827 group = rs_rho(1)%desc%group
1830 any_distributed = .false.
1831 DO ilevel = 1, nlevels
1832 any_distributed = any_distributed .OR. rs_rho(ilevel)%desc%distributed
1836 CALL get_ks_env(ks_env, dft_control=dft_control)
1837 nimages = dft_control%nimages
1838 ALLOCATE (matrix_images(nimages))
1839 IF (
PRESENT(matrix_p_kp))
THEN
1840 cpassert(.NOT.
PRESENT(matrix_p))
1842 matrix_images(img)%matrix => matrix_p_kp(img)%matrix
1845 cpassert(
PRESENT(matrix_p) .AND. nimages == 1)
1846 matrix_images(1)%matrix => matrix_p
1850 IF (any_distributed)
THEN
1855 DEALLOCATE (matrix_images)
1859 ga_gb_function=ga_gb_function, &
1860 pab_blocks=task_list%pab_buffer, &
1867 CALL timestop(handle)
1884 soft_valid, basis_type)
1886 TYPE(
dbcsr_type),
OPTIONAL,
TARGET :: matrix_p
1888 POINTER :: matrix_p_kp
1892 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid
1893 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
1895 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_drho_elec'
1897 CHARACTER(LEN=default_string_length) :: my_basis_type
1898 INTEGER :: bcol, brow, dabqadb_func, handle, iatom, iatom_old, idir, igrid_level, ikind, &
1899 ikind_old, img, img_old, ipgf, iset, iset_old, itask, ithread, jatom, jatom_old, jkind, &
1900 jkind_old, jpgf, jset, jset_old, maxco, maxsgf_set, na1, na2, natoms, nb1, nb2, ncoa, &
1901 ncob, nimages, nseta, nsetb, ntasks, nthread, sgfa, sgfb
1902 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
1904 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
1905 LOGICAL :: atom_pair_changed, distributed_rs_grids, &
1906 do_kp, found, my_soft, use_subpatch
1907 REAL(kind=
dp) :: eps_rho_rspace, f, prefactor, radius, &
1909 REAL(kind=
dp),
DIMENSION(3) :: ra, rab, rab_inv, rb, rp
1910 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, pab, sphi_a, sphi_b, work, &
1912 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: pabt, workt
1913 TYPE(
atom_pair_type),
DIMENSION(:),
POINTER :: atom_pair_recv, atom_pair_send
1923 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1928 TYPE(
task_type),
DIMENSION(:),
POINTER :: tasks
1930 CALL timeset(routinen, handle)
1932 cpassert(
PRESENT(matrix_p) .OR.
PRESENT(matrix_p_kp))
1933 do_kp =
PRESENT(matrix_p_kp)
1935 NULLIFY (cell, dft_control, orb_basis_set, deltap, qs_kind_set, &
1936 sab_orb, particle_set, rs_rho, pw_env, rs_descs, la_max, la_min, &
1937 lb_max, lb_min, npgfa, npgfb, nsgfa, nsgfb, p_block, sphi_a, &
1938 sphi_b, zeta, zetb, first_sgfa, first_sgfb, tasks, pabt, workt)
1942 IF (
PRESENT(soft_valid)) my_soft = soft_valid
1944 IF (
PRESENT(basis_type))
THEN
1945 my_basis_type = basis_type
1947 my_basis_type =
"ORB"
1951 qs_kind_set=qs_kind_set, &
1953 dft_control=dft_control, &
1954 particle_set=particle_set, &
1958 SELECT CASE (my_basis_type)
1961 task_list=task_list, &
1962 task_list_soft=task_list_soft)
1965 task_list_soft=task_list_soft)
1966 CALL get_admm_env(qs_env%admm_env, task_list_aux_fit=task_list)
1970 gridlevel_info => pw_env%gridlevel_info
1976 maxsgf_set=maxsgf_set, &
1977 basis_type=my_basis_type)
1978 CALL reallocate(pabt, 1, maxco, 1, maxco, 0, nthread - 1)
1979 CALL reallocate(workt, 1, maxco, 1, maxsgf_set, 0, nthread - 1)
1982 nimages = dft_control%nimages
1983 cpassert(nimages == 1 .OR. do_kp)
1985 natoms =
SIZE(particle_set)
1988 IF (my_soft) task_list => task_list_soft
1989 cpassert(
ASSOCIATED(task_list))
1990 tasks => task_list%tasks
1991 atom_pair_send => task_list%atom_pair_send
1992 atom_pair_recv => task_list%atom_pair_recv
1993 ntasks = task_list%ntasks
1996 cpassert(
ASSOCIATED(pw_env))
1997 CALL pw_env_get(pw_env, rs_descs=rs_descs, rs_grids=rs_rho)
1998 DO igrid_level = 1, gridlevel_info%ngrid_levels
1999 distributed_rs_grids = rs_rho(igrid_level)%desc%distributed
2002 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
2007 ALLOCATE (deltap(nimages))
2008 IF (distributed_rs_grids)
THEN
2015 CALL dbcsr_copy(deltap(img)%matrix, matrix_p_kp(img)%matrix, &
2019 CALL dbcsr_copy(deltap(1)%matrix, matrix_p, name=
"DeltaP")
2024 deltap(img)%matrix => matrix_p_kp(img)%matrix
2027 deltap(1)%matrix => matrix_p
2032 IF (distributed_rs_grids)
THEN
2034 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
2035 nimages=nimages, scatter=.true.)
2041 pab => pabt(:, :, ithread)
2042 work => workt(:, :, ithread)
2044 loop_xyz:
DO idir = 1, 3
2046 DO igrid_level = 1, gridlevel_info%ngrid_levels
2050 iatom_old = -1; jatom_old = -1; iset_old = -1; jset_old = -1
2051 ikind_old = -1; jkind_old = -1; img_old = -1
2052 loop_tasks:
DO itask = 1, ntasks
2055 igrid_level = tasks(itask)%grid_level
2056 img = tasks(itask)%image
2057 iatom = tasks(itask)%iatom
2058 jatom = tasks(itask)%jatom
2059 iset = tasks(itask)%iset
2060 jset = tasks(itask)%jset
2061 ipgf = tasks(itask)%ipgf
2062 jpgf = tasks(itask)%jpgf
2064 ikind = particle_set(iatom)%atomic_kind%kind_number
2065 jkind = particle_set(jatom)%atomic_kind%kind_number
2067 IF (iatom /= iatom_old .OR. jatom /= jatom_old .OR. img /= img_old)
THEN
2069 IF (iatom /= iatom_old) ra(:) =
pbc(particle_set(iatom)%r, cell)
2071 IF (iatom <= jatom)
THEN
2079 IF (ikind /= ikind_old)
THEN
2081 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2082 basis_type=
"ORB_SOFT")
2084 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2085 basis_type=my_basis_type)
2088 first_sgf=first_sgfa, &
2098 IF (jkind /= jkind_old)
THEN
2100 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2101 basis_type=
"ORB_SOFT")
2103 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2104 basis_type=my_basis_type)
2107 first_sgf=first_sgfb, &
2118 row=brow, col=bcol, block=p_block, found=found)
2126 atom_pair_changed = .true.
2130 atom_pair_changed = .false.
2134 IF (atom_pair_changed .OR. iset_old /= iset .OR. jset_old /= jset)
THEN
2136 ncoa = npgfa(iset)*
ncoset(la_max(iset))
2137 sgfa = first_sgfa(1, iset)
2138 ncob = npgfb(jset)*
ncoset(lb_max(jset))
2139 sgfb = first_sgfb(1, jset)
2141 IF (iatom <= jatom)
THEN
2142 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
2143 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2144 p_block(sgfa, sgfb),
SIZE(p_block, 1), &
2145 0.0_dp, work(1, 1), maxco)
2146 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
2147 1.0_dp, work(1, 1), maxco, &
2148 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2149 0.0_dp, pab(1, 1), maxco)
2151 CALL dgemm(
"N",
"N", ncob, nsgfa(iset), nsgfb(jset), &
2152 1.0_dp, sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2153 p_block(sgfb, sgfa),
SIZE(p_block, 1), &
2154 0.0_dp, work(1, 1), maxco)
2155 CALL dgemm(
"N",
"T", ncob, ncoa, nsgfa(iset), &
2156 1.0_dp, work(1, 1), maxco, &
2157 sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2158 0.0_dp, pab(1, 1), maxco)
2166 rab(:) = tasks(itask)%rab
2167 rb(:) = ra(:) + rab(:)
2168 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
2170 f = zetb(jpgf, jset)/zetp
2171 rp(:) = ra(:) + f*rab(:)
2172 prefactor = exp(-zeta(ipgf, iset)*f*dot_product(rab, rab))
2174 lb_min=lb_min(jset), lb_max=lb_max(jset), &
2175 ra=ra, rb=rb, rp=rp, &
2176 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
2177 prefactor=prefactor, cutoff=1.0_dp)
2179 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
2180 na2 = ipgf*
ncoset(la_max(iset))
2181 nb1 = (jpgf - 1)*
ncoset(lb_max(jset)) + 1
2182 nb2 = jpgf*
ncoset(lb_max(jset))
2185 IF (iatom == jatom .AND. img == 1)
THEN
2192 IF (rs_rho(igrid_level)%desc%distributed)
THEN
2194 IF (tasks(itask)%dist_type == 2)
THEN
2195 use_subpatch = .true.
2197 use_subpatch = .false.
2200 use_subpatch = .false.
2211 cpabort(
"invalid idir")
2214 IF (iatom <= jatom)
THEN
2216 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2217 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2218 ra, rab, scale, pab, na1 - 1, nb1 - 1, &
2219 rs_rho(igrid_level), &
2220 radius=radius, ga_gb_function=dabqadb_func, &
2221 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern)
2225 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2226 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2227 rb, rab_inv, scale, pab, nb1 - 1, na1 - 1, &
2228 rs_rho(igrid_level), &
2229 radius=radius, ga_gb_function=dabqadb_func, &
2230 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern)
2235 CALL density_rs2pw(pw_env, rs_rho, drho(idir), drho_gspace(idir))
2240 IF (distributed_rs_grids)
THEN
2244 NULLIFY (deltap(img)%matrix)
2249 DEALLOCATE (pabt, workt)
2251 CALL timestop(handle)
2271 soft_valid, basis_type, beta, lambda)
2273 TYPE(
dbcsr_type),
OPTIONAL,
TARGET :: matrix_p
2275 POINTER :: matrix_p_kp
2279 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid
2280 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
2281 INTEGER,
INTENT(IN) :: beta, lambda
2283 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_drho_elec_dR'
2285 CHARACTER(LEN=default_string_length) :: my_basis_type
2286 INTEGER :: bcol, brow, dabqadb_func, handle, iatom, iatom_old, igrid_level, ikind, &
2287 ikind_old, img, img_old, ipgf, iset, iset_old, itask, ithread, jatom, jatom_old, jkind, &
2288 jkind_old, jpgf, jset, jset_old, maxco, maxsgf_set, na1, na2, natoms, nb1, nb2, ncoa, &
2289 ncob, nimages, nseta, nsetb, ntasks, nthread, sgfa, sgfb
2290 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
2292 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
2293 LOGICAL :: atom_pair_changed, distributed_rs_grids, &
2294 do_kp, found, my_soft, use_subpatch
2295 REAL(kind=
dp) :: eps_rho_rspace, f, prefactor, radius, &
2297 REAL(kind=
dp),
DIMENSION(3) :: ra, rab, rab_inv, rb, rp
2298 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, pab, sphi_a, sphi_b, work, &
2300 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: pabt, workt
2301 TYPE(
atom_pair_type),
DIMENSION(:),
POINTER :: atom_pair_recv, atom_pair_send
2309 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2314 TYPE(
task_type),
DIMENSION(:),
POINTER :: tasks
2316 CALL timeset(routinen, handle)
2318 cpassert(
PRESENT(matrix_p) .OR.
PRESENT(matrix_p_kp))
2319 do_kp =
PRESENT(matrix_p_kp)
2321 NULLIFY (cell, dft_control, orb_basis_set, deltap, qs_kind_set, &
2322 particle_set, rs_rho, pw_env, rs_descs, la_max, la_min, lb_max, &
2323 lb_min, npgfa, npgfb, nsgfa, nsgfb, p_block, sphi_a, sphi_b, &
2324 zeta, zetb, first_sgfa, first_sgfb, tasks, pabt, workt)
2328 IF (
PRESENT(soft_valid)) my_soft = soft_valid
2330 IF (
PRESENT(basis_type))
THEN
2331 my_basis_type = basis_type
2333 my_basis_type =
"ORB"
2337 qs_kind_set=qs_kind_set, &
2339 dft_control=dft_control, &
2340 particle_set=particle_set, &
2343 SELECT CASE (my_basis_type)
2346 task_list=task_list, &
2347 task_list_soft=task_list_soft)
2350 task_list_soft=task_list_soft)
2351 CALL get_admm_env(qs_env%admm_env, task_list_aux_fit=task_list)
2355 gridlevel_info => pw_env%gridlevel_info
2361 maxsgf_set=maxsgf_set, &
2362 basis_type=my_basis_type)
2363 CALL reallocate(pabt, 1, maxco, 1, maxco, 0, nthread - 1)
2364 CALL reallocate(workt, 1, maxco, 1, maxsgf_set, 0, nthread - 1)
2367 nimages = dft_control%nimages
2368 cpassert(nimages == 1 .OR. do_kp)
2370 natoms =
SIZE(particle_set)
2373 IF (my_soft) task_list => task_list_soft
2374 cpassert(
ASSOCIATED(task_list))
2375 tasks => task_list%tasks
2376 atom_pair_send => task_list%atom_pair_send
2377 atom_pair_recv => task_list%atom_pair_recv
2378 ntasks = task_list%ntasks
2381 cpassert(
ASSOCIATED(pw_env))
2382 CALL pw_env_get(pw_env, rs_descs=rs_descs, rs_grids=rs_rho)
2383 DO igrid_level = 1, gridlevel_info%ngrid_levels
2384 distributed_rs_grids = rs_rho(igrid_level)%desc%distributed
2387 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
2392 ALLOCATE (deltap(nimages))
2393 IF (distributed_rs_grids)
THEN
2400 CALL dbcsr_copy(deltap(img)%matrix, matrix_p_kp(img)%matrix, &
2404 CALL dbcsr_copy(deltap(1)%matrix, matrix_p, name=
"DeltaP")
2409 deltap(img)%matrix => matrix_p_kp(img)%matrix
2412 deltap(1)%matrix => matrix_p
2417 IF (distributed_rs_grids)
THEN
2419 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
2420 nimages=nimages, scatter=.true.)
2426 pab => pabt(:, :, ithread)
2427 work => workt(:, :, ithread)
2429 DO igrid_level = 1, gridlevel_info%ngrid_levels
2433 iatom_old = -1; jatom_old = -1; iset_old = -1; jset_old = -1
2434 ikind_old = -1; jkind_old = -1; img_old = -1
2435 loop_tasks:
DO itask = 1, ntasks
2438 igrid_level = tasks(itask)%grid_level
2439 img = tasks(itask)%image
2440 iatom = tasks(itask)%iatom
2441 jatom = tasks(itask)%jatom
2442 iset = tasks(itask)%iset
2443 jset = tasks(itask)%jset
2444 ipgf = tasks(itask)%ipgf
2445 jpgf = tasks(itask)%jpgf
2447 ikind = particle_set(iatom)%atomic_kind%kind_number
2448 jkind = particle_set(jatom)%atomic_kind%kind_number
2450 IF (iatom /= iatom_old .OR. jatom /= jatom_old .OR. img /= img_old)
THEN
2452 IF (iatom /= iatom_old) ra(:) =
pbc(particle_set(iatom)%r, cell)
2454 IF (iatom <= jatom)
THEN
2462 IF (ikind /= ikind_old)
THEN
2464 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2465 basis_type=
"ORB_SOFT")
2467 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2468 basis_type=my_basis_type)
2471 first_sgf=first_sgfa, &
2481 IF (jkind /= jkind_old)
THEN
2483 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2484 basis_type=
"ORB_SOFT")
2486 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2487 basis_type=my_basis_type)
2490 first_sgf=first_sgfb, &
2501 row=brow, col=bcol, block=p_block, found=found)
2509 atom_pair_changed = .true.
2513 atom_pair_changed = .false.
2517 IF (atom_pair_changed .OR. iset_old /= iset .OR. jset_old /= jset)
THEN
2519 ncoa = npgfa(iset)*
ncoset(la_max(iset))
2520 sgfa = first_sgfa(1, iset)
2521 ncob = npgfb(jset)*
ncoset(lb_max(jset))
2522 sgfb = first_sgfb(1, jset)
2524 IF (iatom <= jatom)
THEN
2525 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
2526 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2527 p_block(sgfa, sgfb),
SIZE(p_block, 1), &
2528 0.0_dp, work(1, 1), maxco)
2529 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
2530 1.0_dp, work(1, 1), maxco, &
2531 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2532 0.0_dp, pab(1, 1), maxco)
2534 CALL dgemm(
"N",
"N", ncob, nsgfa(iset), nsgfb(jset), &
2535 1.0_dp, sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2536 p_block(sgfb, sgfa),
SIZE(p_block, 1), &
2537 0.0_dp, work(1, 1), maxco)
2538 CALL dgemm(
"N",
"T", ncob, ncoa, nsgfa(iset), &
2539 1.0_dp, work(1, 1), maxco, &
2540 sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2541 0.0_dp, pab(1, 1), maxco)
2549 rab(:) = tasks(itask)%rab
2550 rb(:) = ra(:) + rab(:)
2551 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
2553 f = zetb(jpgf, jset)/zetp
2554 rp(:) = ra(:) + f*rab(:)
2555 prefactor = exp(-zeta(ipgf, iset)*f*dot_product(rab, rab))
2557 lb_min=lb_min(jset), lb_max=lb_max(jset), &
2558 ra=ra, rb=rb, rp=rp, &
2559 zetp=zetp, eps=eps_rho_rspace, &
2560 prefactor=prefactor, cutoff=1.0_dp)
2562 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
2563 na2 = ipgf*
ncoset(la_max(iset))
2564 nb1 = (jpgf - 1)*
ncoset(lb_max(jset)) + 1
2565 nb2 = jpgf*
ncoset(lb_max(jset))
2568 IF (iatom == jatom .AND. img == 1)
THEN
2575 IF (rs_rho(igrid_level)%desc%distributed)
THEN
2577 IF (tasks(itask)%dist_type == 2)
THEN
2578 use_subpatch = .true.
2580 use_subpatch = .false.
2583 use_subpatch = .false.
2594 cpabort(
"invalid beta")
2597 IF (iatom <= jatom)
THEN
2598 IF (iatom == lambda) &
2600 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2601 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2602 ra, rab, scale, pab, na1 - 1, nb1 - 1, &
2603 rsgrid=rs_rho(igrid_level), &
2604 ga_gb_function=dabqadb_func, radius=radius, &
2605 use_subpatch=use_subpatch, &
2606 subpatch_pattern=tasks(itask)%subpatch_pattern)
2607 IF (jatom == lambda) &
2609 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2610 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2611 ra, rab, scale, pab, na1 - 1, nb1 - 1, &
2612 rsgrid=rs_rho(igrid_level), &
2613 ga_gb_function=dabqadb_func + 3, radius=radius, &
2614 use_subpatch=use_subpatch, &
2615 subpatch_pattern=tasks(itask)%subpatch_pattern)
2618 IF (jatom == lambda) &
2620 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2621 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2622 rb, rab_inv, scale, pab, nb1 - 1, na1 - 1, &
2623 rs_rho(igrid_level), &
2624 ga_gb_function=dabqadb_func, radius=radius, &
2625 use_subpatch=use_subpatch, &
2626 subpatch_pattern=tasks(itask)%subpatch_pattern)
2627 IF (iatom == lambda) &
2629 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2630 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2631 rb, rab_inv, scale, pab, nb1 - 1, na1 - 1, &
2632 rs_rho(igrid_level), &
2633 ga_gb_function=dabqadb_func + 3, radius=radius, &
2634 use_subpatch=use_subpatch, &
2635 subpatch_pattern=tasks(itask)%subpatch_pattern)
2643 IF (distributed_rs_grids)
THEN
2647 NULLIFY (deltap(img)%matrix)
2652 DEALLOCATE (pabt, workt)
2654 CALL timestop(handle)
2677 atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, &
2678 pw_env, required_function, basis_type)
2683 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2688 INTEGER,
INTENT(IN) :: required_function
2689 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
2691 CHARACTER(LEN=*),
PARAMETER :: routinen =
'collocate_single_gaussian'
2693 CHARACTER(LEN=default_string_length) :: my_basis_type
2694 INTEGER :: group_size, handle, i, iatom, igrid_level, ikind, ipgf, iset, maxco, maxsgf_set, &
2695 my_index, my_pos, na1, na2, natom, ncoa, nseta, offset, sgfa
2696 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: where_is_the_point
2697 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nsgfa
2698 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
2700 REAL(kind=
dp) :: dab, eps_rho_rspace, radius, scale
2701 REAL(kind=
dp),
DIMENSION(3) :: ra
2702 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab, sphi_a, zeta
2711 IF (
PRESENT(basis_type))
THEN
2712 my_basis_type = basis_type
2714 my_basis_type =
"ORB"
2717 CALL timeset(routinen, handle)
2719 NULLIFY (orb_basis_set, pab, la_max, la_min, npgfa, nsgfa, sphi_a, &
2720 zeta, first_sgfa, rs_rho, pw_pools)
2723 cpassert(
ASSOCIATED(pw_env))
2724 CALL pw_env_get(pw_env, rs_grids=rs_rho, pw_pools=pw_pools, &
2725 gridlevel_info=gridlevel_info)
2731 DO igrid_level = 1, gridlevel_info%ngrid_levels
2735 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
2740 maxsgf_set=maxsgf_set, &
2741 basis_type=my_basis_type)
2743 ALLOCATE (pab(maxco, 1))
2746 group = mgrid_rspace(1)%pw_grid%para%group
2747 my_pos = mgrid_rspace(1)%pw_grid%para%group%mepos
2748 group_size = mgrid_rspace(1)%pw_grid%para%group%num_pe
2749 ALLOCATE (where_is_the_point(0:group_size - 1))
2752 ikind = particle_set(iatom)%atomic_kind%kind_number
2753 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=my_basis_type)
2755 first_sgf=first_sgfa, &
2763 ra(:) =
pbc(particle_set(iatom)%r, cell)
2768 ncoa = npgfa(iset)*
ncoset(la_max(iset))
2769 sgfa = first_sgfa(1, iset)
2773 DO i = 1, nsgfa(iset)
2774 IF (offset + i == required_function)
THEN
2783 pab(1:ncoa, 1) = sphi_a(1:ncoa, sgfa + my_index - 1)
2785 DO ipgf = 1, npgfa(iset)
2787 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
2788 na2 = ipgf*
ncoset(la_max(iset))
2793 IF (
map_gaussian_here(rs_rho(igrid_level), cell%h_inv, ra, offset, group_size, my_pos))
THEN
2795 lb_min=0, lb_max=0, ra=ra, rb=ra, rp=ra, &
2796 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
2797 prefactor=1.0_dp, cutoff=1.0_dp)
2801 ra, [0.0_dp, 0.0_dp, 0.0_dp], &
2802 scale, pab, na1 - 1, 0, rs_rho(igrid_level), &
2810 offset = offset + nsgfa(iset)
2816 DO igrid_level = 1, gridlevel_info%ngrid_levels
2818 mgrid_rspace(igrid_level))
2822 DO igrid_level = 1, gridlevel_info%ngrid_levels
2824 mgrid_gspace(igrid_level))
2825 CALL pw_axpy(mgrid_gspace(igrid_level), rho_gspace)
2837 CALL timestop(handle)
2860 atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, &
2863 INTEGER,
INTENT(IN) :: ivector
2867 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2872 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
2874 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_wavefunction'
2876 INTEGER :: handle, i, nao
2878 REAL(kind=
dp) :: eps_rho_rspace
2879 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvector
2881 CALL timeset(routinen, handle)
2884 ALLOCATE (eigenvector(nao))
2889 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
2892 atomic_kind_set, qs_kind_set, cell, particle_set, pw_env, &
2893 eps_rho_rspace, basis_type)
2895 DEALLOCATE (eigenvector)
2897 CALL timestop(handle)
2922 atomic_kind_set, qs_kind_set, cell, particle_set, pw_env, &
2923 eps_rho_rspace, basis_type)
2924 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: vector
2928 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2932 REAL(kind=
dp),
INTENT(IN) :: eps_rho_rspace
2933 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
2935 CHARACTER(LEN=*),
PARAMETER :: routinen =
'collocate_function'
2937 CHARACTER(LEN=default_string_length) :: my_basis_type
2938 INTEGER :: group_size, handle, i, iatom, igrid_level, ikind, ipgf, iset, maxco, maxsgf_set, &
2939 my_pos, na1, na2, natom, ncoa, nseta, offset, sgfa
2940 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: where_is_the_point
2941 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nsgfa
2942 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
2943 REAL(kind=
dp) :: dab, radius, scale
2944 REAL(kind=
dp),
DIMENSION(3) :: ra
2945 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab, sphi_a, work, zeta
2954 CALL timeset(routinen, handle)
2956 IF (
PRESENT(basis_type))
THEN
2957 my_basis_type = basis_type
2959 my_basis_type =
"ORB"
2962 NULLIFY (orb_basis_set, pab, work, la_max, la_min, &
2963 npgfa, nsgfa, sphi_a, zeta, first_sgfa, rs_rho, pw_pools)
2966 cpassert(
ASSOCIATED(pw_env))
2967 CALL pw_env_get(pw_env, rs_grids=rs_rho, pw_pools=pw_pools, &
2968 gridlevel_info=gridlevel_info)
2974 DO igrid_level = 1, gridlevel_info%ngrid_levels
2982 maxsgf_set=maxsgf_set, &
2983 basis_type=my_basis_type)
2985 ALLOCATE (pab(maxco, 1))
2986 ALLOCATE (work(maxco, 1))
2989 group = mgrid_rspace(1)%pw_grid%para%group
2990 my_pos = mgrid_rspace(1)%pw_grid%para%group%mepos
2991 group_size = mgrid_rspace(1)%pw_grid%para%group%num_pe
2992 ALLOCATE (where_is_the_point(0:group_size - 1))
2995 ikind = particle_set(iatom)%atomic_kind%kind_number
2996 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=my_basis_type)
2998 first_sgf=first_sgfa, &
3006 ra(:) =
pbc(particle_set(iatom)%r, cell)
3011 ncoa = npgfa(iset)*
ncoset(la_max(iset))
3012 sgfa = first_sgfa(1, iset)
3014 DO i = 1, nsgfa(iset)
3015 work(i, 1) = vector(offset + i)
3018 CALL dgemm(
"N",
"N", ncoa, 1, nsgfa(iset), &
3019 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
3020 work(1, 1),
SIZE(work, 1), &
3021 0.0_dp, pab(1, 1),
SIZE(pab, 1))
3023 DO ipgf = 1, npgfa(iset)
3025 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
3026 na2 = ipgf*
ncoset(la_max(iset))
3031 IF (
map_gaussian_here(rs_rho(igrid_level), cell%h_inv, ra, offset, group_size, my_pos))
THEN
3033 lb_min=0, lb_max=0, ra=ra, rb=ra, rp=ra, &
3034 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
3035 prefactor=1.0_dp, cutoff=1.0_dp)
3039 ra, [0.0_dp, 0.0_dp, 0.0_dp], &
3040 scale, pab, na1 - 1, 0, rs_rho(igrid_level), &
3046 offset = offset + nsgfa(iset)
3052 DO igrid_level = 1, gridlevel_info%ngrid_levels
3054 mgrid_rspace(igrid_level))
3058 DO igrid_level = 1, gridlevel_info%ngrid_levels
3060 mgrid_gspace(igrid_level))
3061 CALL pw_axpy(mgrid_gspace(igrid_level), rho_gspace)
3074 CALL timestop(handle)
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
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.
Types and set/get functions for auxiliary density matrix methods.
subroutine, public get_admm_env(admm_env, mo_derivs_aux_fit, mos_aux_fit, sab_aux_fit, sab_aux_fit_asymm, sab_aux_fit_vs_orb, matrix_s_aux_fit, matrix_s_aux_fit_kp, matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp, task_list_aux_fit, matrix_ks_aux_fit, matrix_ks_aux_fit_kp, matrix_ks_aux_fit_im, matrix_ks_aux_fit_dft, matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_dft_kp, matrix_ks_aux_fit_hfx_kp, rho_aux_fit, rho_aux_fit_buffer, admm_dm)
Get routine for the ADMM env.
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_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
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)
...
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_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)
...
DBCSR operations in CP2K.
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_get_element(matrix, irow_global, icol_global, alpha, local)
returns an element of a fm this value is valid on every cpu using this call is expensive
Definition of the atomic potential types.
integer function, public gaussian_gridlevel(gridlevel_info, exponent)
...
Fortran API for the grid package, which is written in C.
integer, parameter, public grid_func_core_x
integer, parameter, public grid_func_dab_z
subroutine, public grid_collocate_task_list(task_list, ga_gb_function, pab_blocks, rs_grids)
Collocate all tasks of in given list onto given grids.
integer, parameter, public grid_func_dzdx
integer, parameter, public grid_func_dzdz
integer, parameter, public grid_func_dydz
integer, parameter, public grid_func_dxdy
integer, parameter, public grid_func_dabpadb_y
integer, parameter, public grid_func_dab_y
integer, parameter, public grid_func_dxdx
integer, parameter, public grid_func_dadb
integer, parameter, public grid_func_dydy
integer, parameter, public grid_func_dabpadb_z
integer, parameter, public grid_func_dabpadb_x
integer, parameter, public grid_func_dx
integer, parameter, public grid_func_dz
integer, parameter, public grid_func_ab
integer, parameter, public grid_func_core_y
integer, parameter, public grid_func_dab_x
subroutine, public collocate_pgf_product(la_max, zeta, la_min, lb_max, zetb, lb_min, ra, rab, scale, pab, o1, o2, rsgrid, ga_gb_function, radius, use_subpatch, subpatch_pattern)
low level collocation of primitive gaussian functions
integer, parameter, public grid_func_core_z
integer, parameter, public grid_func_dy
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
contains the types and subroutines for dealing with the lri_env lri : local resolution of the identit...
Utility routines for the memory handling.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
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 ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_drho_elec_dr(matrix_p, matrix_p_kp, drho, drho_gspace, qs_env, soft_valid, basis_type, beta, lambda)
Computes the gradient wrt. nuclear coordinates of a density on the grid The density is given in terms...
subroutine, public calculate_drho_elec(matrix_p, matrix_p_kp, drho, drho_gspace, qs_env, soft_valid, basis_type)
computes the gradient of the density corresponding to a given density matrix on the grid
subroutine, public calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho, ks_env, soft_valid, compute_tau, compute_grad, basis_type, der_type, idir, task_list_external, pw_env_external)
computes the density corresponding to a given density matrix on the grid
subroutine, public collocate_function(vector, rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, particle_set, pw_env, eps_rho_rspace, basis_type)
maps a given function on the grid
subroutine, public calculate_rho_metal(rho_metal, coeff, total_rho_metal, qs_env)
computes the image charge density on the grid (including coeffcients)
subroutine, public calculate_rho_resp_single(rho_gb, qs_env, eta, iatom_in)
collocate a single Gaussian on the grid for periodic RESP fitting
subroutine, public calculate_rho_nlcc(rho_nlcc, qs_env)
computes the density of the non-linear core correction on the grid
subroutine, public calculate_lri_rho_elec(lri_rho_g, lri_rho_r, qs_env, lri_coef, total_rho, basis_type, exact_1c_terms, pmat, atomlist)
Collocates the fitted lri density on a grid.
subroutine, public collocate_single_gaussian(rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env, required_function, basis_type)
maps a single gaussian on the grid
subroutine, public calculate_rho_single_gaussian(rho_gb, qs_env, iatom_in)
collocate a single Gaussian on the grid
subroutine, public calculate_ppl_grid(vppl, qs_env)
computes the local pseudopotential (without erf term) on the grid
subroutine, public calculate_wavefunction(mo_vectors, ivector, rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env, basis_type)
maps a given wavefunction on the grid
subroutine, public calculate_drho_core(drho_core, qs_env, beta, lambda)
Computes the derivative of the density of the core charges with respect to the nuclear coordinates on...
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, 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.
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, 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, 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, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
Define the neighbor list data types and the corresponding functionality.
pure logical function, public map_gaussian_here(rs_grid, h_inv, ra, offset, group_size, my_pos)
...
subroutine, public transfer_rs2pw(rs, pw)
...
subroutine, public rs_grid_zero(rs)
Initialize grid to zero.
Transfers densities from PW to RS grids and potentials from PW to RS.
subroutine, public density_rs2pw(pw_env, rs_rho, rho, rho_gspace)
given partial densities on the realspace multigrids, computes the full density on the plane wave grid...
generate the tasks lists used by collocate and integrate routines
subroutine, public rs_scatter_matrices(src_matrices, dest_buffer, task_list, group)
Scatters dbcsr matrix blocks and receives them into a buffer as needed before collocation.
subroutine, public rs_distribute_matrix(rs_descs, pmats, atom_pair_send, atom_pair_recv, nimages, scatter, hmats)
redistributes the matrix so that it can be used in realspace operations i.e. according to the task li...
subroutine, public rs_copy_to_buffer(src_matrices, dest_buffer, task_list)
Copies the DBCSR blocks into buffer, replaces rs_scatter_matrix for non-distributed grids.
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
contained for different pw related things
to create arrays of pools
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 ...