114#include "./base/base_uses.f90"
120 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_collocate_density'
140 MODULE PROCEDURE calculate_rho_core_r3d_rs
141 MODULE PROCEDURE calculate_rho_core_c1d_gs
145 MODULE PROCEDURE calculate_rho_resp_all_r3d_rs, calculate_rho_resp_all_c1d_gs
160 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_nlcc'
162 INTEGER :: atom_a, handle, iatom, iexp_nlcc, ikind, &
163 j, n, natom, nc, nexp_nlcc, &
164 ni, npme, subpatch_pattern
165 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nct_nlcc
166 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
167 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
168 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: alpha_nlcc
169 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: cval_nlcc
170 REAL(kind=
dp),
DIMENSION(3) :: ra
171 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
178 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
181 CALL timeset(routinen, handle)
183 NULLIFY (cell, dft_control, pab, particle_set, atomic_kind_set, &
184 qs_kind_set, atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
187 atomic_kind_set=atomic_kind_set, &
188 qs_kind_set=qs_kind_set, &
190 dft_control=dft_control, &
191 particle_set=particle_set, &
193 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
194 auxbas_pw_pool=auxbas_pw_pool)
198 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
200 DO ikind = 1,
SIZE(atomic_kind_set)
201 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
203 nexp_nlcc =
SIZE(alpha_nlcc)
205 DO iexp_nlcc = 1, nexp_nlcc
207 alpha = alpha_nlcc(iexp_nlcc)
208 nc = nct_nlcc(iexp_nlcc)
211 ALLOCATE (pab(ni, 1))
222 pab(1, 1) = cval_nlcc(1, iexp_nlcc)
225 pab(n, 1) = cval_nlcc(2, iexp_nlcc)/alpha**2
227 pab(n, 1) = cval_nlcc(2, iexp_nlcc)/alpha**2
229 pab(n, 1) = cval_nlcc(2, iexp_nlcc)/alpha**2
232 pab(n, 1) = cval_nlcc(3, iexp_nlcc)/alpha**4
234 pab(n, 1) = cval_nlcc(3, iexp_nlcc)/alpha**4
236 pab(n, 1) = cval_nlcc(3, iexp_nlcc)/alpha**4
238 pab(n, 1) = 2._dp*cval_nlcc(3, iexp_nlcc)/alpha**4
240 pab(n, 1) = 2._dp*cval_nlcc(3, iexp_nlcc)/alpha**4
242 pab(n, 1) = 2._dp*cval_nlcc(3, iexp_nlcc)/alpha**4
245 pab(n, 1) = cval_nlcc(4, iexp_nlcc)/alpha**6
247 pab(n, 1) = cval_nlcc(4, iexp_nlcc)/alpha**6
249 pab(n, 1) = cval_nlcc(4, iexp_nlcc)/alpha**6
251 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
253 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
255 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
257 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
259 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
261 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
263 pab(n, 1) = 6._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
265 CALL cp_abort(__location__, &
266 "Only 1, 2, 3, 4 are supported as the "// &
267 "value of j in calculate_rho_nlcc")
270 IF (dft_control%nspins == 2) pab = pab*0.5_dp
273 atom_a = atom_list(iatom)
274 ra(:) =
pbc(particle_set(atom_a)%r, cell)
275 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
277 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
290 atom_a = atom_list(iatom)
291 ra(:) =
pbc(particle_set(atom_a)%r, cell)
295 ra=ra, rb=ra, rp=ra, &
296 zetp=1/(2*alpha**2), eps=eps_rho_rspace, &
297 pab=pab, o1=0, o2=0, &
298 prefactor=1.0_dp, cutoff=0.0_dp)
301 [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, 0, 0, rs_rho, &
303 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
313 IF (
ASSOCIATED(cores))
THEN
319 CALL timestop(handle)
333 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_ppl_grid'
335 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
336 j, lppl, n, natom, ni, npme, nthread, &
338 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
339 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
340 REAL(kind=
dp),
DIMENSION(3) :: ra
341 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cexp_ppl
342 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
350 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
353 CALL timeset(routinen, handle)
355 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
356 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
359 atomic_kind_set=atomic_kind_set, &
360 qs_kind_set=qs_kind_set, &
362 dft_control=dft_control, &
363 particle_set=particle_set, &
365 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
366 auxbas_pw_pool=auxbas_pw_pool)
370 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
372 DO ikind = 1,
SIZE(atomic_kind_set)
373 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
374 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential)
376 IF (.NOT.
ASSOCIATED(gth_potential)) cycle
377 CALL get_potential(potential=gth_potential, alpha_ppl=alpha, nexp_ppl=lppl, cexp_ppl=cexp_ppl)
382 ALLOCATE (pab(ni, 1))
396 pab(1, 1) = cexp_ppl(1)
399 pab(n, 1) = cexp_ppl(2)
401 pab(n, 1) = cexp_ppl(2)
403 pab(n, 1) = cexp_ppl(2)
406 pab(n, 1) = cexp_ppl(3)
408 pab(n, 1) = cexp_ppl(3)
410 pab(n, 1) = cexp_ppl(3)
412 pab(n, 1) = 2._dp*cexp_ppl(3)
414 pab(n, 1) = 2._dp*cexp_ppl(3)
416 pab(n, 1) = 2._dp*cexp_ppl(3)
419 pab(n, 1) = cexp_ppl(4)
421 pab(n, 1) = cexp_ppl(4)
423 pab(n, 1) = cexp_ppl(4)
425 pab(n, 1) = 3._dp*cexp_ppl(4)
427 pab(n, 1) = 3._dp*cexp_ppl(4)
429 pab(n, 1) = 3._dp*cexp_ppl(4)
431 pab(n, 1) = 3._dp*cexp_ppl(4)
433 pab(n, 1) = 3._dp*cexp_ppl(4)
435 pab(n, 1) = 3._dp*cexp_ppl(4)
437 pab(n, 1) = 6._dp*cexp_ppl(4)
439 CALL cp_abort(__location__, &
440 "Only 1, 2, 3, 4 are supported as the "// &
441 "value of j in calculate_ppl_grid")
446 atom_a = atom_list(iatom)
447 ra(:) =
pbc(particle_set(atom_a)%r, cell)
448 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
450 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
464 atom_a = atom_list(iatom)
465 ra(:) =
pbc(particle_set(atom_a)%r, cell)
470 lb_min=0, lb_max=0, &
471 ra=ra, rb=ra, rp=ra, &
472 zetp=alpha, eps=eps_rho_rspace, &
473 pab=pab, o1=0, o2=0, &
474 prefactor=1.0_dp, cutoff=0.0_dp)
477 [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, 0, 0, rs_rho, &
479 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
488 IF (
ASSOCIATED(cores))
THEN
494 CALL timestop(handle)
514 lri_coef, total_rho, basis_type, exact_1c_terms, pmat, atomlist)
520 REAL(kind=
dp),
INTENT(OUT) :: total_rho
521 CHARACTER(len=*),
INTENT(IN) :: basis_type
522 LOGICAL,
INTENT(IN) :: exact_1c_terms
524 INTEGER,
DIMENSION(:),
OPTIONAL :: atomlist
526 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_lri_rho_elec'
528 INTEGER :: atom_a, group_size, handle, iatom, igrid_level, ikind, ipgf, iset, jpgf, jset, &
529 m1, maxco, maxsgf_set, my_pos, na1, natom, nb1, ncoa, ncob, nseta, offset, sgfa, sgfb
530 INTEGER,
DIMENSION(:),
POINTER :: atom_list, la_max, la_min, npgfa, nsgfa
531 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
533 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: map_it
534 LOGICAL,
ALLOCATABLE,
DIMENSION(:, :) :: map_it2
535 REAL(kind=
dp) :: eps_rho_rspace, radius, zetp
536 REAL(kind=
dp),
DIMENSION(3) :: ra
537 REAL(kind=
dp),
DIMENSION(:),
POINTER :: aci
538 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, pab, sphi_a, work, zeta
549 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
553 NULLIFY (aci, atomic_kind_set, qs_kind_set, atom_list, cell, &
554 dft_control, first_sgfa, gridlevel_info, la_max, &
555 la_min, lri_basis_set, npgfa, nsgfa, &
556 pab, particle_set, pw_env, pw_pools, rs_grid, rs_rho, sphi_a, &
559 CALL timeset(routinen, handle)
561 IF (exact_1c_terms)
THEN
562 cpassert(
PRESENT(pmat))
565 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, &
566 atomic_kind_set=atomic_kind_set, &
567 cell=cell, particle_set=particle_set, &
569 dft_control=dft_control)
571 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
572 gridlevel_info => pw_env%gridlevel_info
575 cpassert(
ASSOCIATED(pw_env))
576 CALL pw_env_get(pw_env=pw_env, rs_grids=rs_rho, pw_pools=pw_pools)
583 DO igrid_level = 1, gridlevel_info%ngrid_levels
589 maxco=maxco, basis_type=basis_type)
591 ALLOCATE (pab(maxco, 1))
593 my_pos = mgrid_rspace(1)%pw_grid%para%group%mepos
594 group_size = mgrid_rspace(1)%pw_grid%para%group%num_pe
596 DO ikind = 1,
SIZE(atomic_kind_set)
598 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
599 CALL get_qs_kind(qs_kind_set(ikind), basis_set=lri_basis_set, basis_type=basis_type)
603 lmin=la_min, zet=zeta, nset=nseta, npgf=npgfa, &
604 sphi=sphi_a, first_sgf=first_sgfa, nsgf_set=nsgfa)
607 atom_a = atom_list(iatom)
608 IF (
PRESENT(atomlist))
THEN
609 IF (atomlist(atom_a) == 0) cycle
611 ra(:) =
pbc(particle_set(atom_a)%r, cell)
612 aci => lri_coef(ikind)%acoef(iatom, :)
614 m1 = maxval(npgfa(1:nseta))
615 ALLOCATE (map_it(m1))
619 DO ipgf = 1, npgfa(iset)
621 rs_grid => rs_rho(igrid_level)
622 map_it(ipgf) =
map_gaussian_here(rs_grid, cell%h_inv, ra, offset, group_size, my_pos)
626 IF (any(map_it(1:npgfa(iset))))
THEN
627 sgfa = first_sgfa(1, iset)
628 ncoa = npgfa(iset)*
ncoset(la_max(iset))
629 m1 = sgfa + nsgfa(iset) - 1
630 ALLOCATE (work(nsgfa(iset), 1))
631 work(1:nsgfa(iset), 1) = aci(sgfa:m1)
634 CALL dgemm(
"N",
"N", ncoa, 1, nsgfa(iset), 1.0_dp, lri_basis_set%sphi(1, sgfa), &
635 SIZE(lri_basis_set%sphi, 1), work(1, 1),
SIZE(work, 1), 0.0_dp, pab(1, 1), &
638 DO ipgf = 1, npgfa(iset)
639 na1 = (ipgf - 1)*
ncoset(la_max(iset))
641 rs_grid => rs_rho(igrid_level)
642 IF (map_it(ipgf))
THEN
644 lb_min=0, lb_max=0, &
645 ra=ra, rb=ra, rp=ra, &
646 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
647 prefactor=1.0_dp, cutoff=1.0_dp)
650 zeta=zeta(ipgf, iset), &
651 la_min=la_min(iset), &
652 lb_max=0, zetb=0.0_dp, lb_min=0, &
653 ra=ra, rab=[0.0_dp, 0.0_dp, 0.0_dp], &
655 pab=pab, o1=na1, o2=0, &
671 IF (exact_1c_terms)
THEN
676 maxsgf_set=maxsgf_set, &
678 ALLOCATE (pab(maxco, maxco), work(maxco, maxsgf_set))
680 DO ikind = 1,
SIZE(atomic_kind_set)
681 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
682 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=
"ORB")
684 lmin=la_min, zet=zeta, nset=nseta, npgf=npgfa, &
685 sphi=sphi_a, first_sgf=first_sgfa, nsgf_set=nsgfa)
687 atom_a = atom_list(iatom)
688 ra(:) =
pbc(particle_set(atom_a)%r, cell)
689 CALL dbcsr_get_block_p(matrix=pmat, row=atom_a, col=atom_a, block=p_block, found=found)
690 m1 = maxval(npgfa(1:nseta))
691 ALLOCATE (map_it2(m1, m1))
696 DO ipgf = 1, npgfa(iset)
697 DO jpgf = 1, npgfa(jset)
698 zetp = zeta(ipgf, iset) + zeta(jpgf, jset)
700 rs_grid => rs_rho(igrid_level)
701 map_it2(ipgf, jpgf) =
map_gaussian_here(rs_grid, cell%h_inv, ra, offset, group_size, my_pos)
706 IF (any(map_it2(1:npgfa(iset), 1:npgfa(jset))))
THEN
707 ncoa = npgfa(iset)*
ncoset(la_max(iset))
708 sgfa = first_sgfa(1, iset)
709 ncob = npgfa(jset)*
ncoset(la_max(jset))
710 sgfb = first_sgfa(1, jset)
712 CALL dgemm(
"N",
"N", ncoa, nsgfa(jset), nsgfa(iset), &
713 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
714 p_block(sgfa, sgfb),
SIZE(p_block, 1), &
715 0.0_dp, work(1, 1), maxco)
716 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfa(jset), &
717 1.0_dp, work(1, 1), maxco, &
718 sphi_a(1, sgfb),
SIZE(sphi_a, 1), &
719 0.0_dp, pab(1, 1), maxco)
720 DO ipgf = 1, npgfa(iset)
721 DO jpgf = 1, npgfa(jset)
722 zetp = zeta(ipgf, iset) + zeta(jpgf, jset)
724 rs_grid => rs_rho(igrid_level)
726 na1 = (ipgf - 1)*
ncoset(la_max(iset))
727 nb1 = (jpgf - 1)*
ncoset(la_max(jset))
729 IF (map_it2(ipgf, jpgf))
THEN
731 la_max=la_max(iset), &
732 lb_min=la_min(jset), &
733 lb_max=la_max(jset), &
734 ra=ra, rb=ra, rp=ra, &
735 zetp=zetp, eps=eps_rho_rspace, &
736 prefactor=1.0_dp, cutoff=1.0_dp)
739 la_max(iset), zeta(ipgf, iset), la_min(iset), &
740 la_max(jset), zeta(jpgf, jset), la_min(jset), &
741 ra, [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, na1, nb1, &
754 DEALLOCATE (pab, work)
760 DO igrid_level = 1, gridlevel_info%ngrid_levels
761 CALL pw_zero(mgrid_rspace(igrid_level))
763 pw=mgrid_rspace(igrid_level))
766 DO igrid_level = 1, gridlevel_info%ngrid_levels
767 CALL pw_zero(mgrid_gspace(igrid_level))
769 mgrid_gspace(igrid_level))
770 CALL pw_axpy(mgrid_gspace(igrid_level), lri_rho_g)
779 CALL timestop(handle)
792 SUBROUTINE calculate_rho_core_r3d_rs (rho_core, total_rho, qs_env, calpha, ccore, only_nopaw)
795 REAL(KIND=
dp),
INTENT(OUT) :: total_rho
797 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: calpha, ccore
798 LOGICAL,
INTENT(IN),
OPTIONAL :: only_nopaw
800 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_core'
802 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
803 j, natom, npme, nthread, &
805 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
806 LOGICAL :: my_only_nopaw, paw_atom
807 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
808 REAL(kind=
dp),
DIMENSION(3) :: ra
809 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
817 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
820 CALL timeset(routinen, handle)
821 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
822 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
825 my_only_nopaw = .false.
826 IF (
PRESENT(only_nopaw)) my_only_nopaw = only_nopaw
827 IF (
PRESENT(calpha))
THEN
828 cpassert(
PRESENT(ccore))
832 atomic_kind_set=atomic_kind_set, &
833 qs_kind_set=qs_kind_set, &
835 dft_control=dft_control, &
836 particle_set=particle_set, &
838 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
839 auxbas_pw_pool=auxbas_pw_pool)
843 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
845 DO ikind = 1,
SIZE(atomic_kind_set)
846 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
847 IF (
PRESENT(calpha))
THEN
848 alpha = calpha(ikind)
849 pab(1, 1) = ccore(ikind)
851 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
852 IF (my_only_nopaw .AND. paw_atom) cycle
853 CALL get_qs_kind(qs_kind_set(ikind), alpha_core_charge=alpha, &
854 ccore_charge=pab(1, 1))
857 IF (my_only_nopaw .AND. paw_atom) cycle
858 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
868 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
870 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
884 atom_a = atom_list(iatom)
885 ra(:) =
pbc(particle_set(atom_a)%r, cell)
888 lb_min=0, lb_max=0, &
889 ra=ra, rb=ra, rp=ra, &
890 zetp=alpha, eps=eps_rho_rspace, &
891 pab=pab, o1=0, o2=0, &
892 prefactor=-1.0_dp, cutoff=0.0_dp)
895 [0.0_dp, 0.0_dp, 0.0_dp], -1.0_dp, pab, 0, 0, rs_rho, &
897 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
904 IF (
ASSOCIATED(cores))
THEN
909 CALL auxbas_pw_pool%create_pw(rhoc_r)
917 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
919 CALL timestop(handle)
921 END SUBROUTINE calculate_rho_core_r3d_rs
931 SUBROUTINE calculate_rho_core_c1d_gs (rho_core, total_rho, qs_env, calpha, ccore, only_nopaw)
934 REAL(KIND=
dp),
INTENT(OUT) :: total_rho
936 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: calpha, ccore
937 LOGICAL,
INTENT(IN),
OPTIONAL :: only_nopaw
939 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_core'
941 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
942 j, natom, npme, nthread, &
944 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
945 LOGICAL :: my_only_nopaw, paw_atom
946 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
947 REAL(kind=
dp),
DIMENSION(3) :: ra
948 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
956 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
959 CALL timeset(routinen, handle)
960 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
961 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
964 my_only_nopaw = .false.
965 IF (
PRESENT(only_nopaw)) my_only_nopaw = only_nopaw
966 IF (
PRESENT(calpha))
THEN
967 cpassert(
PRESENT(ccore))
971 atomic_kind_set=atomic_kind_set, &
972 qs_kind_set=qs_kind_set, &
974 dft_control=dft_control, &
975 particle_set=particle_set, &
977 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
978 auxbas_pw_pool=auxbas_pw_pool)
982 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
984 DO ikind = 1,
SIZE(atomic_kind_set)
985 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
986 IF (
PRESENT(calpha))
THEN
987 alpha = calpha(ikind)
988 pab(1, 1) = ccore(ikind)
990 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom)
991 IF (my_only_nopaw .AND. paw_atom) cycle
992 CALL get_qs_kind(qs_kind_set(ikind), alpha_core_charge=alpha, &
993 ccore_charge=pab(1, 1))
996 IF (my_only_nopaw .AND. paw_atom) cycle
997 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
1007 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1009 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1023 atom_a = atom_list(iatom)
1024 ra(:) =
pbc(particle_set(atom_a)%r, cell)
1025 subpatch_pattern = 0
1027 lb_min=0, lb_max=0, &
1028 ra=ra, rb=ra, rp=ra, &
1029 zetp=alpha, eps=eps_rho_rspace, &
1030 pab=pab, o1=0, o2=0, &
1031 prefactor=-1.0_dp, cutoff=0.0_dp)
1034 [0.0_dp, 0.0_dp, 0.0_dp], -1.0_dp, pab, 0, 0, rs_rho, &
1036 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1043 IF (
ASSOCIATED(cores))
THEN
1048 CALL auxbas_pw_pool%create_pw(rhoc_r)
1056 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1058 CALL timestop(handle)
1060 END SUBROUTINE calculate_rho_core_c1d_gs
1075 INTEGER,
INTENT(IN) :: beta, lambda
1077 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_drho_core'
1079 INTEGER :: atom_a, dabqadb_func, handle, iatom, &
1080 ikind, ithread, j, natom, npme, &
1081 nthread, subpatch_pattern
1082 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
1083 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
1084 REAL(kind=
dp),
DIMENSION(3) :: ra
1085 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1093 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1096 CALL timeset(routinen, handle)
1097 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
1098 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
1099 ALLOCATE (pab(1, 1))
1102 atomic_kind_set=atomic_kind_set, &
1103 qs_kind_set=qs_kind_set, &
1105 dft_control=dft_control, &
1106 particle_set=particle_set, &
1108 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1109 auxbas_pw_pool=auxbas_pw_pool)
1113 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1123 cpabort(
"invalid beta")
1125 DO ikind = 1,
SIZE(atomic_kind_set)
1126 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
1128 alpha_core_charge=alpha, ccore_charge=pab(1, 1))
1130 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
1140 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1142 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1156 atom_a = atom_list(iatom)
1157 IF (atom_a /= lambda) cycle
1158 ra(:) =
pbc(particle_set(atom_a)%r, cell)
1159 subpatch_pattern = 0
1161 lb_min=0, lb_max=0, &
1162 ra=ra, rb=ra, rp=ra, &
1163 zetp=alpha, eps=eps_rho_rspace, &
1164 pab=pab, o1=0, o2=0, &
1165 prefactor=-1.0_dp, cutoff=0.0_dp)
1168 [0.0_dp, 0.0_dp, 0.0_dp], -1.0_dp, pab, 0, 0, rs_rho, &
1169 radius=radius, ga_gb_function=dabqadb_func, &
1170 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1177 IF (
ASSOCIATED(cores))
THEN
1182 CALL auxbas_pw_pool%create_pw(rhoc_r)
1188 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1190 CALL timestop(handle)
1207 INTEGER,
INTENT(IN) :: iatom_in
1209 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_single_gaussian'
1211 INTEGER :: atom_a, handle, iatom, npme, &
1213 REAL(kind=
dp) :: eps_rho_rspace, radius
1214 REAL(kind=
dp),
DIMENSION(3) :: ra
1215 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1223 CALL timeset(routinen, handle)
1224 NULLIFY (cell, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool)
1226 ALLOCATE (pab(1, 1))
1230 dft_control=dft_control, &
1232 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1233 auxbas_pw_pool=auxbas_pw_pool)
1236 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1242 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1243 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1251 atom_a = qs_env%qmmm_env_qm%image_charge_pot%image_mm_list(iatom)
1252 ra(:) =
pbc(qs_env%qmmm_env_qm%image_charge_pot%particles_all(atom_a)%r, cell)
1253 subpatch_pattern = 0
1255 lb_min=0, lb_max=0, &
1256 ra=ra, rb=ra, rp=ra, &
1257 zetp=qs_env%qmmm_env_qm%image_charge_pot%eta, &
1258 eps=eps_rho_rspace, &
1259 pab=pab, o1=0, o2=0, &
1260 prefactor=1.0_dp, cutoff=0.0_dp)
1263 0, 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, 0, 0, rs_rho, &
1265 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1270 CALL auxbas_pw_pool%create_pw(rhoc_r)
1276 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1278 CALL timestop(handle)
1296 REAL(kind=
dp),
DIMENSION(:),
POINTER :: coeff
1297 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: total_rho_metal
1300 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_metal'
1302 INTEGER :: atom_a, handle, iatom, j, natom, npme, &
1304 INTEGER,
DIMENSION(:),
POINTER :: cores
1305 REAL(kind=
dp) :: eps_rho_rspace, radius
1306 REAL(kind=
dp),
DIMENSION(3) :: ra
1307 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1315 CALL timeset(routinen, handle)
1317 NULLIFY (cell, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, cores)
1319 ALLOCATE (pab(1, 1))
1323 dft_control=dft_control, &
1325 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1326 auxbas_pw_pool=auxbas_pw_pool)
1329 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1332 natom =
SIZE(qs_env%qmmm_env_qm%image_charge_pot%image_mm_list)
1339 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1340 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1353 atom_a = qs_env%qmmm_env_qm%image_charge_pot%image_mm_list(iatom)
1354 ra(:) =
pbc(qs_env%qmmm_env_qm%image_charge_pot%particles_all(atom_a)%r, cell)
1355 subpatch_pattern = 0
1357 lb_min=0, lb_max=0, &
1358 ra=ra, rb=ra, rp=ra, &
1359 zetp=qs_env%qmmm_env_qm%image_charge_pot%eta, &
1360 eps=eps_rho_rspace, &
1361 pab=pab, o1=0, o2=0, &
1362 prefactor=coeff(iatom), cutoff=0.0_dp)
1365 0, qs_env%qmmm_env_qm%image_charge_pot%eta, &
1366 0, 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], coeff(iatom), pab, 0, 0, rs_rho, &
1368 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1372 DEALLOCATE (pab, cores)
1374 CALL auxbas_pw_pool%create_pw(rhoc_r)
1378 IF (
PRESENT(total_rho_metal))
THEN
1384 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1386 CALL timestop(handle)
1404 REAL(kind=
dp),
INTENT(IN) :: eta
1405 INTEGER,
INTENT(IN) :: iatom_in
1407 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_resp_single'
1409 INTEGER :: handle, iatom, npme, subpatch_pattern
1410 REAL(kind=
dp) :: eps_rho_rspace, radius
1411 REAL(kind=
dp),
DIMENSION(3) :: ra
1412 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1421 CALL timeset(routinen, handle)
1422 NULLIFY (cell, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, &
1425 ALLOCATE (pab(1, 1))
1429 dft_control=dft_control, &
1430 particle_set=particle_set, &
1432 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1433 auxbas_pw_pool=auxbas_pw_pool)
1436 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1442 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1443 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1451 ra(:) =
pbc(particle_set(iatom)%r, cell)
1452 subpatch_pattern = 0
1454 lb_min=0, lb_max=0, &
1455 ra=ra, rb=ra, rp=ra, &
1456 zetp=eta, eps=eps_rho_rspace, &
1457 pab=pab, o1=0, o2=0, &
1458 prefactor=1.0_dp, cutoff=0.0_dp)
1461 [0.0_dp, 0.0_dp, 0.0_dp], 1.0_dp, pab, 0, 0, rs_rho, &
1463 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1468 CALL auxbas_pw_pool%create_pw(rhoc_r)
1474 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1476 CALL timestop(handle)
1492 SUBROUTINE calculate_rho_resp_all_r3d_rs (rho_resp, coeff, natom, eta, qs_env)
1495 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: coeff
1496 INTEGER,
INTENT(IN) :: natom
1497 REAL(KIND=
dp),
INTENT(IN) :: eta
1500 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_resp_all'
1502 INTEGER :: handle, iatom, j, npme, subpatch_pattern
1503 INTEGER,
DIMENSION(:),
POINTER :: cores
1504 REAL(kind=
dp) :: eps_rho_rspace, radius
1505 REAL(kind=
dp),
DIMENSION(3) :: ra
1506 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1515 CALL timeset(routinen, handle)
1517 NULLIFY (cell, cores, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, &
1520 ALLOCATE (pab(1, 1))
1524 dft_control=dft_control, &
1525 particle_set=particle_set, &
1527 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1528 auxbas_pw_pool=auxbas_pw_pool)
1531 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1539 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1540 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1553 ra(:) =
pbc(particle_set(iatom)%r, cell)
1554 subpatch_pattern = 0
1556 lb_min=0, lb_max=0, &
1557 ra=ra, rb=ra, rp=ra, &
1558 zetp=eta, eps=eps_rho_rspace, &
1559 pab=pab, o1=0, o2=0, &
1560 prefactor=coeff(iatom), cutoff=0.0_dp)
1564 0, 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], coeff(iatom), pab, 0, 0, rs_rho, &
1566 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1570 DEALLOCATE (pab, cores)
1572 CALL auxbas_pw_pool%create_pw(rhoc_r)
1577 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1579 CALL timestop(handle)
1581 END SUBROUTINE calculate_rho_resp_all_r3d_rs
1594 SUBROUTINE calculate_rho_resp_all_c1d_gs (rho_resp, coeff, natom, eta, qs_env)
1597 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: coeff
1598 INTEGER,
INTENT(IN) :: natom
1599 REAL(KIND=
dp),
INTENT(IN) :: eta
1602 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_resp_all'
1604 INTEGER :: handle, iatom, j, npme, subpatch_pattern
1605 INTEGER,
DIMENSION(:),
POINTER :: cores
1606 REAL(kind=
dp) :: eps_rho_rspace, radius
1607 REAL(kind=
dp),
DIMENSION(3) :: ra
1608 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1617 CALL timeset(routinen, handle)
1619 NULLIFY (cell, cores, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, &
1622 ALLOCATE (pab(1, 1))
1626 dft_control=dft_control, &
1627 particle_set=particle_set, &
1629 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1630 auxbas_pw_pool=auxbas_pw_pool)
1633 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1641 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1642 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1655 ra(:) =
pbc(particle_set(iatom)%r, cell)
1656 subpatch_pattern = 0
1658 lb_min=0, lb_max=0, &
1659 ra=ra, rb=ra, rp=ra, &
1660 zetp=eta, eps=eps_rho_rspace, &
1661 pab=pab, o1=0, o2=0, &
1662 prefactor=coeff(iatom), cutoff=0.0_dp)
1666 0, 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], coeff(iatom), pab, 0, 0, rs_rho, &
1668 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1672 DEALLOCATE (pab, cores)
1674 CALL auxbas_pw_pool%create_pw(rhoc_r)
1679 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1681 CALL timestop(handle)
1683 END SUBROUTINE calculate_rho_resp_all_c1d_gs
1711 ks_env, soft_valid, compute_tau, compute_grad, &
1712 basis_type, der_type, idir, task_list_external, pw_env_external)
1714 TYPE(
dbcsr_type),
OPTIONAL,
TARGET :: matrix_p
1716 POINTER :: matrix_p_kp
1719 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: total_rho
1721 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid, compute_tau, compute_grad
1722 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
1723 INTEGER,
INTENT(IN),
OPTIONAL :: der_type, idir
1725 TYPE(
pw_env_type),
OPTIONAL,
POINTER :: pw_env_external
1727 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_elec'
1729 CHARACTER(LEN=default_string_length) :: my_basis_type
1730 INTEGER :: ga_gb_function, handle, ilevel, img, &
1732 LOGICAL :: any_distributed, my_compute_grad, &
1733 my_compute_tau, my_soft_valid
1734 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_images
1741 CALL timeset(routinen, handle)
1743 NULLIFY (matrix_images, dft_control, pw_env, rs_rho, task_list)
1746 my_compute_tau = .false.
1747 IF (
PRESENT(compute_tau)) my_compute_tau = compute_tau
1748 my_compute_grad = .false.
1749 IF (
PRESENT(compute_grad)) my_compute_grad = compute_grad
1750 IF (
PRESENT(der_type))
THEN
1751 SELECT CASE (der_type)
1773 cpabort(
"Unknown der_type")
1775 ELSE IF (my_compute_tau)
THEN
1777 ELSE IF (my_compute_grad)
THEN
1778 cpassert(
PRESENT(idir))
1787 cpabort(
"invalid idir")
1794 my_basis_type =
"ORB"
1795 IF (
PRESENT(basis_type)) my_basis_type = basis_type
1796 cpassert(my_basis_type ==
"ORB" .OR.
PRESENT(task_list_external))
1799 my_soft_valid = .false.
1800 IF (
PRESENT(soft_valid)) my_soft_valid = soft_valid
1801 IF (
PRESENT(task_list_external))
THEN
1802 task_list => task_list_external
1803 ELSE IF (my_soft_valid)
THEN
1804 CALL get_ks_env(ks_env, task_list_soft=task_list)
1808 cpassert(
ASSOCIATED(task_list))
1811 IF (
PRESENT(pw_env_external))
THEN
1812 pw_env => pw_env_external
1816 cpassert(
ASSOCIATED(pw_env))
1820 nlevels =
SIZE(rs_rho)
1821 group = rs_rho(1)%desc%group
1824 any_distributed = .false.
1825 DO ilevel = 1, nlevels
1826 any_distributed = any_distributed .OR. rs_rho(ilevel)%desc%distributed
1830 CALL get_ks_env(ks_env, dft_control=dft_control)
1831 nimages = dft_control%nimages
1832 ALLOCATE (matrix_images(nimages))
1833 IF (
PRESENT(matrix_p_kp))
THEN
1834 cpassert(.NOT.
PRESENT(matrix_p))
1836 matrix_images(img)%matrix => matrix_p_kp(img)%matrix
1839 cpassert(
PRESENT(matrix_p) .AND. nimages == 1)
1840 matrix_images(1)%matrix => matrix_p
1844 IF (any_distributed)
THEN
1849 DEALLOCATE (matrix_images)
1853 ga_gb_function=ga_gb_function, &
1854 pab_blocks=task_list%pab_buffer, &
1861 CALL timestop(handle)
1878 soft_valid, basis_type)
1880 TYPE(
dbcsr_type),
OPTIONAL,
TARGET :: matrix_p
1882 POINTER :: matrix_p_kp
1886 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid
1887 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
1889 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_drho_elec'
1891 CHARACTER(LEN=default_string_length) :: my_basis_type
1892 INTEGER :: bcol, brow, dabqadb_func, handle, iatom, iatom_old, idir, igrid_level, ikind, &
1893 ikind_old, img, img_old, ipgf, iset, iset_old, itask, ithread, jatom, jatom_old, jkind, &
1894 jkind_old, jpgf, jset, jset_old, maxco, maxsgf_set, na1, na2, natoms, nb1, nb2, ncoa, &
1895 ncob, nimages, nseta, nsetb, ntasks, nthread, sgfa, sgfb
1896 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
1898 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
1899 LOGICAL :: atom_pair_changed, distributed_rs_grids, &
1900 do_kp, found, my_soft, use_subpatch
1901 REAL(kind=
dp) :: eps_rho_rspace, f, prefactor, radius, &
1903 REAL(kind=
dp),
DIMENSION(3) :: ra, rab, rab_inv, rb, rp
1904 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, pab, sphi_a, sphi_b, work, &
1906 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: pabt, workt
1907 TYPE(
atom_pair_type),
DIMENSION(:),
POINTER :: atom_pair_recv, atom_pair_send
1917 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1922 TYPE(
task_type),
DIMENSION(:),
POINTER :: tasks
1924 CALL timeset(routinen, handle)
1926 cpassert(
PRESENT(matrix_p) .OR.
PRESENT(matrix_p_kp))
1927 do_kp =
PRESENT(matrix_p_kp)
1929 NULLIFY (cell, dft_control, orb_basis_set, deltap, qs_kind_set, &
1930 sab_orb, particle_set, rs_rho, pw_env, rs_descs, la_max, la_min, &
1931 lb_max, lb_min, npgfa, npgfb, nsgfa, nsgfb, p_block, sphi_a, &
1932 sphi_b, zeta, zetb, first_sgfa, first_sgfb, tasks, pabt, workt)
1936 IF (
PRESENT(soft_valid)) my_soft = soft_valid
1938 IF (
PRESENT(basis_type))
THEN
1939 my_basis_type = basis_type
1941 my_basis_type =
"ORB"
1945 qs_kind_set=qs_kind_set, &
1947 dft_control=dft_control, &
1948 particle_set=particle_set, &
1952 SELECT CASE (my_basis_type)
1955 task_list=task_list, &
1956 task_list_soft=task_list_soft)
1959 task_list_soft=task_list_soft)
1960 CALL get_admm_env(qs_env%admm_env, task_list_aux_fit=task_list)
1964 gridlevel_info => pw_env%gridlevel_info
1970 maxsgf_set=maxsgf_set, &
1971 basis_type=my_basis_type)
1972 CALL reallocate(pabt, 1, maxco, 1, maxco, 0, nthread - 1)
1973 CALL reallocate(workt, 1, maxco, 1, maxsgf_set, 0, nthread - 1)
1976 nimages = dft_control%nimages
1977 cpassert(nimages == 1 .OR. do_kp)
1979 natoms =
SIZE(particle_set)
1982 IF (my_soft) task_list => task_list_soft
1983 cpassert(
ASSOCIATED(task_list))
1984 tasks => task_list%tasks
1985 atom_pair_send => task_list%atom_pair_send
1986 atom_pair_recv => task_list%atom_pair_recv
1987 ntasks = task_list%ntasks
1990 cpassert(
ASSOCIATED(pw_env))
1991 CALL pw_env_get(pw_env, rs_descs=rs_descs, rs_grids=rs_rho)
1992 DO igrid_level = 1, gridlevel_info%ngrid_levels
1993 distributed_rs_grids = rs_rho(igrid_level)%desc%distributed
1996 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
2001 ALLOCATE (deltap(nimages))
2002 IF (distributed_rs_grids)
THEN
2009 CALL dbcsr_copy(deltap(img)%matrix, matrix_p_kp(img)%matrix, &
2013 CALL dbcsr_copy(deltap(1)%matrix, matrix_p, name=
"DeltaP")
2018 deltap(img)%matrix => matrix_p_kp(img)%matrix
2021 deltap(1)%matrix => matrix_p
2026 IF (distributed_rs_grids)
THEN
2028 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
2029 nimages=nimages, scatter=.true.)
2035 pab => pabt(:, :, ithread)
2036 work => workt(:, :, ithread)
2038 loop_xyz:
DO idir = 1, 3
2040 DO igrid_level = 1, gridlevel_info%ngrid_levels
2044 iatom_old = -1; jatom_old = -1; iset_old = -1; jset_old = -1
2045 ikind_old = -1; jkind_old = -1; img_old = -1
2046 loop_tasks:
DO itask = 1, ntasks
2049 igrid_level = tasks(itask)%grid_level
2050 img = tasks(itask)%image
2051 iatom = tasks(itask)%iatom
2052 jatom = tasks(itask)%jatom
2053 iset = tasks(itask)%iset
2054 jset = tasks(itask)%jset
2055 ipgf = tasks(itask)%ipgf
2056 jpgf = tasks(itask)%jpgf
2058 ikind = particle_set(iatom)%atomic_kind%kind_number
2059 jkind = particle_set(jatom)%atomic_kind%kind_number
2061 IF (iatom /= iatom_old .OR. jatom /= jatom_old .OR. img /= img_old)
THEN
2063 IF (iatom /= iatom_old) ra(:) =
pbc(particle_set(iatom)%r, cell)
2065 IF (iatom <= jatom)
THEN
2073 IF (ikind /= ikind_old)
THEN
2075 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2076 basis_type=
"ORB_SOFT")
2078 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2079 basis_type=my_basis_type)
2082 first_sgf=first_sgfa, &
2092 IF (jkind /= jkind_old)
THEN
2094 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2095 basis_type=
"ORB_SOFT")
2097 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2098 basis_type=my_basis_type)
2101 first_sgf=first_sgfb, &
2112 row=brow, col=bcol, block=p_block, found=found)
2120 atom_pair_changed = .true.
2124 atom_pair_changed = .false.
2128 IF (atom_pair_changed .OR. iset_old /= iset .OR. jset_old /= jset)
THEN
2130 ncoa = npgfa(iset)*
ncoset(la_max(iset))
2131 sgfa = first_sgfa(1, iset)
2132 ncob = npgfb(jset)*
ncoset(lb_max(jset))
2133 sgfb = first_sgfb(1, jset)
2135 IF (iatom <= jatom)
THEN
2136 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
2137 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2138 p_block(sgfa, sgfb),
SIZE(p_block, 1), &
2139 0.0_dp, work(1, 1), maxco)
2140 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
2141 1.0_dp, work(1, 1), maxco, &
2142 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2143 0.0_dp, pab(1, 1), maxco)
2145 CALL dgemm(
"N",
"N", ncob, nsgfa(iset), nsgfb(jset), &
2146 1.0_dp, sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2147 p_block(sgfb, sgfa),
SIZE(p_block, 1), &
2148 0.0_dp, work(1, 1), maxco)
2149 CALL dgemm(
"N",
"T", ncob, ncoa, nsgfa(iset), &
2150 1.0_dp, work(1, 1), maxco, &
2151 sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2152 0.0_dp, pab(1, 1), maxco)
2160 rab(:) = tasks(itask)%rab
2161 rb(:) = ra(:) + rab(:)
2162 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
2164 f = zetb(jpgf, jset)/zetp
2165 rp(:) = ra(:) + f*rab(:)
2166 prefactor = exp(-zeta(ipgf, iset)*f*dot_product(rab, rab))
2168 lb_min=lb_min(jset), lb_max=lb_max(jset), &
2169 ra=ra, rb=rb, rp=rp, &
2170 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
2171 prefactor=prefactor, cutoff=1.0_dp)
2173 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
2174 na2 = ipgf*
ncoset(la_max(iset))
2175 nb1 = (jpgf - 1)*
ncoset(lb_max(jset)) + 1
2176 nb2 = jpgf*
ncoset(lb_max(jset))
2179 IF (iatom == jatom .AND. img == 1)
THEN
2186 IF (rs_rho(igrid_level)%desc%distributed)
THEN
2188 IF (tasks(itask)%dist_type == 2)
THEN
2189 use_subpatch = .true.
2191 use_subpatch = .false.
2194 use_subpatch = .false.
2205 cpabort(
"invalid idir")
2208 IF (iatom <= jatom)
THEN
2210 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2211 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2212 ra, rab, scale, pab, na1 - 1, nb1 - 1, &
2213 rs_rho(igrid_level), &
2214 radius=radius, ga_gb_function=dabqadb_func, &
2215 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern)
2219 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2220 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2221 rb, rab_inv, scale, pab, nb1 - 1, na1 - 1, &
2222 rs_rho(igrid_level), &
2223 radius=radius, ga_gb_function=dabqadb_func, &
2224 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern)
2229 CALL density_rs2pw(pw_env, rs_rho, drho(idir), drho_gspace(idir))
2234 IF (distributed_rs_grids)
THEN
2238 NULLIFY (deltap(img)%matrix)
2243 DEALLOCATE (pabt, workt)
2245 CALL timestop(handle)
2265 soft_valid, basis_type, beta, lambda)
2267 TYPE(
dbcsr_type),
OPTIONAL,
TARGET :: matrix_p
2269 POINTER :: matrix_p_kp
2273 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid
2274 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
2275 INTEGER,
INTENT(IN) :: beta, lambda
2277 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_drho_elec_dR'
2279 CHARACTER(LEN=default_string_length) :: my_basis_type
2280 INTEGER :: bcol, brow, dabqadb_func, handle, iatom, iatom_old, igrid_level, ikind, &
2281 ikind_old, img, img_old, ipgf, iset, iset_old, itask, ithread, jatom, jatom_old, jkind, &
2282 jkind_old, jpgf, jset, jset_old, maxco, maxsgf_set, na1, na2, natoms, nb1, nb2, ncoa, &
2283 ncob, nimages, nseta, nsetb, ntasks, nthread, sgfa, sgfb
2284 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
2286 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
2287 LOGICAL :: atom_pair_changed, distributed_rs_grids, &
2288 do_kp, found, my_soft, use_subpatch
2289 REAL(kind=
dp) :: eps_rho_rspace, f, prefactor, radius, &
2291 REAL(kind=
dp),
DIMENSION(3) :: ra, rab, rab_inv, rb, rp
2292 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, pab, sphi_a, sphi_b, work, &
2294 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: pabt, workt
2295 TYPE(
atom_pair_type),
DIMENSION(:),
POINTER :: atom_pair_recv, atom_pair_send
2303 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2308 TYPE(
task_type),
DIMENSION(:),
POINTER :: tasks
2310 CALL timeset(routinen, handle)
2312 cpassert(
PRESENT(matrix_p) .OR.
PRESENT(matrix_p_kp))
2313 do_kp =
PRESENT(matrix_p_kp)
2315 NULLIFY (cell, dft_control, orb_basis_set, deltap, qs_kind_set, &
2316 particle_set, rs_rho, pw_env, rs_descs, la_max, la_min, lb_max, &
2317 lb_min, npgfa, npgfb, nsgfa, nsgfb, p_block, sphi_a, sphi_b, &
2318 zeta, zetb, first_sgfa, first_sgfb, tasks, pabt, workt)
2322 IF (
PRESENT(soft_valid)) my_soft = soft_valid
2324 IF (
PRESENT(basis_type))
THEN
2325 my_basis_type = basis_type
2327 my_basis_type =
"ORB"
2331 qs_kind_set=qs_kind_set, &
2333 dft_control=dft_control, &
2334 particle_set=particle_set, &
2337 SELECT CASE (my_basis_type)
2340 task_list=task_list, &
2341 task_list_soft=task_list_soft)
2344 task_list_soft=task_list_soft)
2345 CALL get_admm_env(qs_env%admm_env, task_list_aux_fit=task_list)
2349 gridlevel_info => pw_env%gridlevel_info
2355 maxsgf_set=maxsgf_set, &
2356 basis_type=my_basis_type)
2357 CALL reallocate(pabt, 1, maxco, 1, maxco, 0, nthread - 1)
2358 CALL reallocate(workt, 1, maxco, 1, maxsgf_set, 0, nthread - 1)
2361 nimages = dft_control%nimages
2362 cpassert(nimages == 1 .OR. do_kp)
2364 natoms =
SIZE(particle_set)
2367 IF (my_soft) task_list => task_list_soft
2368 cpassert(
ASSOCIATED(task_list))
2369 tasks => task_list%tasks
2370 atom_pair_send => task_list%atom_pair_send
2371 atom_pair_recv => task_list%atom_pair_recv
2372 ntasks = task_list%ntasks
2375 cpassert(
ASSOCIATED(pw_env))
2376 CALL pw_env_get(pw_env, rs_descs=rs_descs, rs_grids=rs_rho)
2377 DO igrid_level = 1, gridlevel_info%ngrid_levels
2378 distributed_rs_grids = rs_rho(igrid_level)%desc%distributed
2381 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
2386 ALLOCATE (deltap(nimages))
2387 IF (distributed_rs_grids)
THEN
2394 CALL dbcsr_copy(deltap(img)%matrix, matrix_p_kp(img)%matrix, &
2398 CALL dbcsr_copy(deltap(1)%matrix, matrix_p, name=
"DeltaP")
2403 deltap(img)%matrix => matrix_p_kp(img)%matrix
2406 deltap(1)%matrix => matrix_p
2411 IF (distributed_rs_grids)
THEN
2413 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
2414 nimages=nimages, scatter=.true.)
2420 pab => pabt(:, :, ithread)
2421 work => workt(:, :, ithread)
2423 DO igrid_level = 1, gridlevel_info%ngrid_levels
2427 iatom_old = -1; jatom_old = -1; iset_old = -1; jset_old = -1
2428 ikind_old = -1; jkind_old = -1; img_old = -1
2429 loop_tasks:
DO itask = 1, ntasks
2432 igrid_level = tasks(itask)%grid_level
2433 img = tasks(itask)%image
2434 iatom = tasks(itask)%iatom
2435 jatom = tasks(itask)%jatom
2436 iset = tasks(itask)%iset
2437 jset = tasks(itask)%jset
2438 ipgf = tasks(itask)%ipgf
2439 jpgf = tasks(itask)%jpgf
2441 ikind = particle_set(iatom)%atomic_kind%kind_number
2442 jkind = particle_set(jatom)%atomic_kind%kind_number
2444 IF (iatom /= iatom_old .OR. jatom /= jatom_old .OR. img /= img_old)
THEN
2446 IF (iatom /= iatom_old) ra(:) =
pbc(particle_set(iatom)%r, cell)
2448 IF (iatom <= jatom)
THEN
2456 IF (ikind /= ikind_old)
THEN
2458 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2459 basis_type=
"ORB_SOFT")
2461 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2462 basis_type=my_basis_type)
2465 first_sgf=first_sgfa, &
2475 IF (jkind /= jkind_old)
THEN
2477 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2478 basis_type=
"ORB_SOFT")
2480 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2481 basis_type=my_basis_type)
2484 first_sgf=first_sgfb, &
2495 row=brow, col=bcol, block=p_block, found=found)
2502 atom_pair_changed = .true.
2506 atom_pair_changed = .false.
2511 IF (.NOT. found) cycle loop_tasks
2513 IF (atom_pair_changed .OR. iset_old /= iset .OR. jset_old /= jset)
THEN
2515 ncoa = npgfa(iset)*
ncoset(la_max(iset))
2516 sgfa = first_sgfa(1, iset)
2517 ncob = npgfb(jset)*
ncoset(lb_max(jset))
2518 sgfb = first_sgfb(1, jset)
2520 IF (iatom <= jatom)
THEN
2521 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
2522 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2523 p_block(sgfa, sgfb),
SIZE(p_block, 1), &
2524 0.0_dp, work(1, 1), maxco)
2525 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
2526 1.0_dp, work(1, 1), maxco, &
2527 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2528 0.0_dp, pab(1, 1), maxco)
2530 CALL dgemm(
"N",
"N", ncob, nsgfa(iset), nsgfb(jset), &
2531 1.0_dp, sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2532 p_block(sgfb, sgfa),
SIZE(p_block, 1), &
2533 0.0_dp, work(1, 1), maxco)
2534 CALL dgemm(
"N",
"T", ncob, ncoa, nsgfa(iset), &
2535 1.0_dp, work(1, 1), maxco, &
2536 sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2537 0.0_dp, pab(1, 1), maxco)
2545 rab(:) = tasks(itask)%rab
2546 rb(:) = ra(:) + rab(:)
2547 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
2549 f = zetb(jpgf, jset)/zetp
2550 rp(:) = ra(:) + f*rab(:)
2551 prefactor = exp(-zeta(ipgf, iset)*f*dot_product(rab, rab))
2553 lb_min=lb_min(jset), lb_max=lb_max(jset), &
2554 ra=ra, rb=rb, rp=rp, &
2555 zetp=zetp, eps=eps_rho_rspace, &
2556 prefactor=prefactor, cutoff=1.0_dp)
2558 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
2559 na2 = ipgf*
ncoset(la_max(iset))
2560 nb1 = (jpgf - 1)*
ncoset(lb_max(jset)) + 1
2561 nb2 = jpgf*
ncoset(lb_max(jset))
2564 IF (iatom == jatom .AND. img == 1)
THEN
2571 IF (rs_rho(igrid_level)%desc%distributed)
THEN
2573 IF (tasks(itask)%dist_type == 2)
THEN
2574 use_subpatch = .true.
2576 use_subpatch = .false.
2579 use_subpatch = .false.
2590 cpabort(
"invalid beta")
2593 IF (iatom <= jatom)
THEN
2594 IF (iatom == lambda)
THEN
2596 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2597 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2598 ra, rab, scale, pab, na1 - 1, nb1 - 1, &
2599 rsgrid=rs_rho(igrid_level), &
2600 ga_gb_function=dabqadb_func, radius=radius, &
2601 use_subpatch=use_subpatch, &
2602 subpatch_pattern=tasks(itask)%subpatch_pattern)
2604 IF (jatom == lambda)
THEN
2606 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2607 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2608 ra, rab, scale, pab, na1 - 1, nb1 - 1, &
2609 rsgrid=rs_rho(igrid_level), &
2610 ga_gb_function=dabqadb_func + 3, radius=radius, &
2611 use_subpatch=use_subpatch, &
2612 subpatch_pattern=tasks(itask)%subpatch_pattern)
2616 IF (jatom == lambda)
THEN
2618 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2619 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2620 rb, rab_inv, scale, pab, nb1 - 1, na1 - 1, &
2621 rs_rho(igrid_level), &
2622 ga_gb_function=dabqadb_func, radius=radius, &
2623 use_subpatch=use_subpatch, &
2624 subpatch_pattern=tasks(itask)%subpatch_pattern)
2626 IF (iatom == lambda)
THEN
2628 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2629 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2630 rb, rab_inv, scale, pab, nb1 - 1, na1 - 1, &
2631 rs_rho(igrid_level), &
2632 ga_gb_function=dabqadb_func + 3, radius=radius, &
2633 use_subpatch=use_subpatch, &
2634 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, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, do_mtlr_present, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
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_vhxc, 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.
Common Gaussian representation of nonlinear core densities.
subroutine, public get_nlcc_gaussians(qs_kind, alpha, nct, cval)
Return rho(r) = sum_i exp(-r**2/(2*alpha(i)**2)) * sum_j cval(j,i)*(r/alpha(i))**(2*j-2)....
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 ...