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
275 IF (dft_control%nspins == 2) pab = pab*0.5_dp
278 atom_a = atom_list(iatom)
279 ra(:) =
pbc(particle_set(atom_a)%r, cell)
280 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
282 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
295 atom_a = atom_list(iatom)
296 ra(:) =
pbc(particle_set(atom_a)%r, cell)
300 ra=ra, rb=ra, rp=ra, &
301 zetp=1/(2*alpha**2), eps=eps_rho_rspace, &
302 pab=pab, o1=0, o2=0, &
303 prefactor=1.0_dp, cutoff=0.0_dp)
306 (/0.0_dp, 0.0_dp, 0.0_dp/), 1.0_dp, pab, 0, 0, rs_rho, &
308 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
318 IF (
ASSOCIATED(cores))
THEN
324 CALL timestop(handle)
338 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_ppl_grid'
340 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
341 j, lppl, n, natom, ni, npme, nthread, &
343 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
344 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
345 REAL(kind=
dp),
DIMENSION(3) :: ra
346 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cexp_ppl
347 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
355 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
358 CALL timeset(routinen, handle)
360 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
361 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
364 atomic_kind_set=atomic_kind_set, &
365 qs_kind_set=qs_kind_set, &
367 dft_control=dft_control, &
368 particle_set=particle_set, &
370 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
371 auxbas_pw_pool=auxbas_pw_pool)
375 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
377 DO ikind = 1,
SIZE(atomic_kind_set)
378 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
379 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential)
381 IF (.NOT.
ASSOCIATED(gth_potential)) cycle
382 CALL get_potential(potential=gth_potential, alpha_ppl=alpha, nexp_ppl=lppl, cexp_ppl=cexp_ppl)
387 ALLOCATE (pab(ni, 1))
401 pab(1, 1) = cexp_ppl(1)
404 pab(n, 1) = cexp_ppl(2)
406 pab(n, 1) = cexp_ppl(2)
408 pab(n, 1) = cexp_ppl(2)
411 pab(n, 1) = cexp_ppl(3)
413 pab(n, 1) = cexp_ppl(3)
415 pab(n, 1) = cexp_ppl(3)
417 pab(n, 1) = 2._dp*cexp_ppl(3)
419 pab(n, 1) = 2._dp*cexp_ppl(3)
421 pab(n, 1) = 2._dp*cexp_ppl(3)
424 pab(n, 1) = cexp_ppl(4)
426 pab(n, 1) = cexp_ppl(4)
428 pab(n, 1) = cexp_ppl(4)
430 pab(n, 1) = 3._dp*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) = 6._dp*cexp_ppl(4)
449 atom_a = atom_list(iatom)
450 ra(:) =
pbc(particle_set(atom_a)%r, cell)
451 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
453 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
463 IF (npme .GT. 0)
THEN
467 atom_a = atom_list(iatom)
468 ra(:) =
pbc(particle_set(atom_a)%r, cell)
473 lb_min=0, lb_max=0, &
474 ra=ra, rb=ra, rp=ra, &
475 zetp=alpha, eps=eps_rho_rspace, &
476 pab=pab, o1=0, o2=0, &
477 prefactor=1.0_dp, cutoff=0.0_dp)
480 (/0.0_dp, 0.0_dp, 0.0_dp/), 1.0_dp, pab, 0, 0, rs_rho, &
482 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
491 IF (
ASSOCIATED(cores))
THEN
497 CALL timestop(handle)
517 lri_coef, total_rho, basis_type, exact_1c_terms, pmat, atomlist)
523 REAL(kind=
dp),
INTENT(OUT) :: total_rho
524 CHARACTER(len=*),
INTENT(IN) :: basis_type
525 LOGICAL,
INTENT(IN) :: exact_1c_terms
527 INTEGER,
DIMENSION(:),
OPTIONAL :: atomlist
529 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_lri_rho_elec'
531 INTEGER :: atom_a, group_size, handle, iatom, igrid_level, ikind, ipgf, iset, jpgf, jset, &
532 m1, maxco, maxsgf_set, my_pos, na1, natom, nb1, ncoa, ncob, nseta, offset, sgfa, sgfb
533 INTEGER,
DIMENSION(:),
POINTER :: atom_list, la_max, la_min, npgfa, nsgfa
534 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
536 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: map_it
537 LOGICAL,
ALLOCATABLE,
DIMENSION(:, :) :: map_it2
538 REAL(kind=
dp) :: eps_rho_rspace, radius, zetp
539 REAL(kind=
dp),
DIMENSION(3) :: ra
540 REAL(kind=
dp),
DIMENSION(:),
POINTER :: aci
541 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, pab, sphi_a, work, zeta
552 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
556 NULLIFY (aci, atomic_kind_set, qs_kind_set, atom_list, cell, &
557 dft_control, first_sgfa, gridlevel_info, la_max, &
558 la_min, lri_basis_set, npgfa, nsgfa, &
559 pab, particle_set, pw_env, pw_pools, rs_grid, rs_rho, sphi_a, &
562 CALL timeset(routinen, handle)
564 IF (exact_1c_terms)
THEN
565 cpassert(
PRESENT(pmat))
568 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, &
569 atomic_kind_set=atomic_kind_set, &
570 cell=cell, particle_set=particle_set, &
572 dft_control=dft_control)
574 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
575 gridlevel_info => pw_env%gridlevel_info
578 cpassert(
ASSOCIATED(pw_env))
579 CALL pw_env_get(pw_env=pw_env, rs_grids=rs_rho, pw_pools=pw_pools)
586 DO igrid_level = 1, gridlevel_info%ngrid_levels
592 maxco=maxco, basis_type=basis_type)
594 ALLOCATE (pab(maxco, 1))
596 my_pos = mgrid_rspace(1)%pw_grid%para%group%mepos
597 group_size = mgrid_rspace(1)%pw_grid%para%group%num_pe
599 DO ikind = 1,
SIZE(atomic_kind_set)
601 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
602 CALL get_qs_kind(qs_kind_set(ikind), basis_set=lri_basis_set, basis_type=basis_type)
606 lmin=la_min, zet=zeta, nset=nseta, npgf=npgfa, &
607 sphi=sphi_a, first_sgf=first_sgfa, nsgf_set=nsgfa)
610 atom_a = atom_list(iatom)
611 IF (
PRESENT(atomlist))
THEN
612 IF (atomlist(atom_a) == 0) cycle
614 ra(:) =
pbc(particle_set(atom_a)%r, cell)
615 aci => lri_coef(ikind)%acoef(iatom, :)
617 m1 = maxval(npgfa(1:nseta))
618 ALLOCATE (map_it(m1))
622 DO ipgf = 1, npgfa(iset)
624 rs_grid => rs_rho(igrid_level)
625 map_it(ipgf) =
map_gaussian_here(rs_grid, cell%h_inv, ra, offset, group_size, my_pos)
629 IF (any(map_it(1:npgfa(iset))))
THEN
630 sgfa = first_sgfa(1, iset)
631 ncoa = npgfa(iset)*
ncoset(la_max(iset))
632 m1 = sgfa + nsgfa(iset) - 1
633 ALLOCATE (work(nsgfa(iset), 1))
634 work(1:nsgfa(iset), 1) = aci(sgfa:m1)
637 CALL dgemm(
"N",
"N", ncoa, 1, nsgfa(iset), 1.0_dp, lri_basis_set%sphi(1, sgfa), &
638 SIZE(lri_basis_set%sphi, 1), work(1, 1),
SIZE(work, 1), 0.0_dp, pab(1, 1), &
641 DO ipgf = 1, npgfa(iset)
642 na1 = (ipgf - 1)*
ncoset(la_max(iset))
644 rs_grid => rs_rho(igrid_level)
645 IF (map_it(ipgf))
THEN
647 lb_min=0, lb_max=0, &
648 ra=ra, rb=ra, rp=ra, &
649 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
650 prefactor=1.0_dp, cutoff=1.0_dp)
653 zeta=zeta(ipgf, iset), &
654 la_min=la_min(iset), &
655 lb_max=0, zetb=0.0_dp, lb_min=0, &
656 ra=ra, rab=(/0.0_dp, 0.0_dp, 0.0_dp/), &
658 pab=pab, o1=na1, o2=0, &
674 IF (exact_1c_terms)
THEN
679 maxsgf_set=maxsgf_set, &
681 ALLOCATE (pab(maxco, maxco), work(maxco, maxsgf_set))
683 DO ikind = 1,
SIZE(atomic_kind_set)
684 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
685 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=
"ORB")
687 lmin=la_min, zet=zeta, nset=nseta, npgf=npgfa, &
688 sphi=sphi_a, first_sgf=first_sgfa, nsgf_set=nsgfa)
690 atom_a = atom_list(iatom)
691 ra(:) =
pbc(particle_set(atom_a)%r, cell)
692 CALL dbcsr_get_block_p(matrix=pmat, row=atom_a, col=atom_a, block=p_block, found=found)
693 m1 = maxval(npgfa(1:nseta))
694 ALLOCATE (map_it2(m1, m1))
699 DO ipgf = 1, npgfa(iset)
700 DO jpgf = 1, npgfa(jset)
701 zetp = zeta(ipgf, iset) + zeta(jpgf, jset)
703 rs_grid => rs_rho(igrid_level)
704 map_it2(ipgf, jpgf) =
map_gaussian_here(rs_grid, cell%h_inv, ra, offset, group_size, my_pos)
709 IF (any(map_it2(1:npgfa(iset), 1:npgfa(jset))))
THEN
710 ncoa = npgfa(iset)*
ncoset(la_max(iset))
711 sgfa = first_sgfa(1, iset)
712 ncob = npgfa(jset)*
ncoset(la_max(jset))
713 sgfb = first_sgfa(1, jset)
715 CALL dgemm(
"N",
"N", ncoa, nsgfa(jset), nsgfa(iset), &
716 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
717 p_block(sgfa, sgfb),
SIZE(p_block, 1), &
718 0.0_dp, work(1, 1), maxco)
719 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfa(jset), &
720 1.0_dp, work(1, 1), maxco, &
721 sphi_a(1, sgfb),
SIZE(sphi_a, 1), &
722 0.0_dp, pab(1, 1), maxco)
723 DO ipgf = 1, npgfa(iset)
724 DO jpgf = 1, npgfa(jset)
725 zetp = zeta(ipgf, iset) + zeta(jpgf, jset)
727 rs_grid => rs_rho(igrid_level)
729 na1 = (ipgf - 1)*
ncoset(la_max(iset))
730 nb1 = (jpgf - 1)*
ncoset(la_max(jset))
732 IF (map_it2(ipgf, jpgf))
THEN
734 la_max=la_max(iset), &
735 lb_min=la_min(jset), &
736 lb_max=la_max(jset), &
737 ra=ra, rb=ra, rp=ra, &
738 zetp=zetp, eps=eps_rho_rspace, &
739 prefactor=1.0_dp, cutoff=1.0_dp)
742 la_max(iset), zeta(ipgf, iset), la_min(iset), &
743 la_max(jset), zeta(jpgf, jset), la_min(jset), &
744 ra, (/0.0_dp, 0.0_dp, 0.0_dp/), 1.0_dp, pab, na1, nb1, &
757 DEALLOCATE (pab, work)
763 DO igrid_level = 1, gridlevel_info%ngrid_levels
764 CALL pw_zero(mgrid_rspace(igrid_level))
766 pw=mgrid_rspace(igrid_level))
769 DO igrid_level = 1, gridlevel_info%ngrid_levels
770 CALL pw_zero(mgrid_gspace(igrid_level))
772 mgrid_gspace(igrid_level))
773 CALL pw_axpy(mgrid_gspace(igrid_level), lri_rho_g)
782 CALL timestop(handle)
795 SUBROUTINE calculate_rho_core_r3d_rs (rho_core, total_rho, qs_env, calpha, ccore, only_nopaw)
798 REAL(KIND=
dp),
INTENT(OUT) :: total_rho
800 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: calpha, ccore
801 LOGICAL,
INTENT(IN),
OPTIONAL :: only_nopaw
803 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_core'
805 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
806 j, natom, npme, nthread, &
808 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
809 LOGICAL :: my_only_nopaw, paw_atom
810 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
811 REAL(kind=
dp),
DIMENSION(3) :: ra
812 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
820 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
823 CALL timeset(routinen, handle)
824 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
825 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
828 my_only_nopaw = .false.
829 IF (
PRESENT(only_nopaw)) my_only_nopaw = only_nopaw
830 IF (
PRESENT(calpha))
THEN
831 cpassert(
PRESENT(ccore))
835 atomic_kind_set=atomic_kind_set, &
836 qs_kind_set=qs_kind_set, &
838 dft_control=dft_control, &
839 particle_set=particle_set, &
841 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
842 auxbas_pw_pool=auxbas_pw_pool)
846 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
848 DO ikind = 1,
SIZE(atomic_kind_set)
849 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
850 IF (
PRESENT(calpha))
THEN
851 alpha = calpha(ikind)
852 pab(1, 1) = ccore(ikind)
854 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom, &
855 alpha_core_charge=alpha, ccore_charge=pab(1, 1))
858 IF (my_only_nopaw .AND. paw_atom) cycle
859 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
869 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
871 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
881 IF (npme .GT. 0)
THEN
885 atom_a = atom_list(iatom)
886 ra(:) =
pbc(particle_set(atom_a)%r, cell)
889 lb_min=0, lb_max=0, &
890 ra=ra, rb=ra, rp=ra, &
891 zetp=alpha, eps=eps_rho_rspace, &
892 pab=pab, o1=0, o2=0, &
893 prefactor=-1.0_dp, cutoff=0.0_dp)
896 (/0.0_dp, 0.0_dp, 0.0_dp/), -1.0_dp, pab, 0, 0, rs_rho, &
898 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
905 IF (
ASSOCIATED(cores))
THEN
910 CALL auxbas_pw_pool%create_pw(rhoc_r)
918 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
920 CALL timestop(handle)
922 END SUBROUTINE calculate_rho_core_r3d_rs
932 SUBROUTINE calculate_rho_core_c1d_gs (rho_core, total_rho, qs_env, calpha, ccore, only_nopaw)
935 REAL(KIND=
dp),
INTENT(OUT) :: total_rho
937 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: calpha, ccore
938 LOGICAL,
INTENT(IN),
OPTIONAL :: only_nopaw
940 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_core'
942 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
943 j, natom, npme, nthread, &
945 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
946 LOGICAL :: my_only_nopaw, paw_atom
947 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
948 REAL(kind=
dp),
DIMENSION(3) :: ra
949 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
957 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
960 CALL timeset(routinen, handle)
961 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
962 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
965 my_only_nopaw = .false.
966 IF (
PRESENT(only_nopaw)) my_only_nopaw = only_nopaw
967 IF (
PRESENT(calpha))
THEN
968 cpassert(
PRESENT(ccore))
972 atomic_kind_set=atomic_kind_set, &
973 qs_kind_set=qs_kind_set, &
975 dft_control=dft_control, &
976 particle_set=particle_set, &
978 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
979 auxbas_pw_pool=auxbas_pw_pool)
983 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
985 DO ikind = 1,
SIZE(atomic_kind_set)
986 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
987 IF (
PRESENT(calpha))
THEN
988 alpha = calpha(ikind)
989 pab(1, 1) = ccore(ikind)
991 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom, &
992 alpha_core_charge=alpha, ccore_charge=pab(1, 1))
995 IF (my_only_nopaw .AND. paw_atom) cycle
996 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
1006 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1008 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1018 IF (npme .GT. 0)
THEN
1022 atom_a = atom_list(iatom)
1023 ra(:) =
pbc(particle_set(atom_a)%r, cell)
1024 subpatch_pattern = 0
1026 lb_min=0, lb_max=0, &
1027 ra=ra, rb=ra, rp=ra, &
1028 zetp=alpha, eps=eps_rho_rspace, &
1029 pab=pab, o1=0, o2=0, &
1030 prefactor=-1.0_dp, cutoff=0.0_dp)
1033 (/0.0_dp, 0.0_dp, 0.0_dp/), -1.0_dp, pab, 0, 0, rs_rho, &
1035 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1042 IF (
ASSOCIATED(cores))
THEN
1047 CALL auxbas_pw_pool%create_pw(rhoc_r)
1055 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1057 CALL timestop(handle)
1059 END SUBROUTINE calculate_rho_core_c1d_gs
1074 INTEGER,
INTENT(IN) :: beta, lambda
1076 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_drho_core'
1078 INTEGER :: atom_a, dabqadb_func, handle, iatom, &
1079 ikind, ithread, j, natom, npme, &
1080 nthread, subpatch_pattern
1081 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
1082 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
1083 REAL(kind=
dp),
DIMENSION(3) :: ra
1084 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1092 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1095 CALL timeset(routinen, handle)
1096 NULLIFY (cell, dft_control, pab, atomic_kind_set, qs_kind_set, particle_set, &
1097 atom_list, pw_env, rs_rho, auxbas_pw_pool, cores)
1098 ALLOCATE (pab(1, 1))
1101 atomic_kind_set=atomic_kind_set, &
1102 qs_kind_set=qs_kind_set, &
1104 dft_control=dft_control, &
1105 particle_set=particle_set, &
1107 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1108 auxbas_pw_pool=auxbas_pw_pool)
1112 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1122 cpabort(
"invalid beta")
1124 DO ikind = 1,
SIZE(atomic_kind_set)
1125 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
1127 alpha_core_charge=alpha, ccore_charge=pab(1, 1))
1129 IF (alpha == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
1139 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1141 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1151 IF (npme .GT. 0)
THEN
1155 atom_a = atom_list(iatom)
1156 IF (atom_a /= lambda) cycle
1157 ra(:) =
pbc(particle_set(atom_a)%r, cell)
1158 subpatch_pattern = 0
1160 lb_min=0, lb_max=0, &
1161 ra=ra, rb=ra, rp=ra, &
1162 zetp=alpha, eps=eps_rho_rspace, &
1163 pab=pab, o1=0, o2=0, &
1164 prefactor=-1.0_dp, cutoff=0.0_dp)
1167 (/0.0_dp, 0.0_dp, 0.0_dp/), -1.0_dp, pab, 0, 0, rs_rho, &
1168 radius=radius, ga_gb_function=dabqadb_func, &
1169 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1176 IF (
ASSOCIATED(cores))
THEN
1181 CALL auxbas_pw_pool%create_pw(rhoc_r)
1187 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1189 CALL timestop(handle)
1206 INTEGER,
INTENT(IN) :: iatom_in
1208 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_single_gaussian'
1210 INTEGER :: atom_a, handle, iatom, npme, &
1212 REAL(kind=
dp) :: eps_rho_rspace, radius
1213 REAL(kind=
dp),
DIMENSION(3) :: ra
1214 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1222 CALL timeset(routinen, handle)
1223 NULLIFY (cell, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool)
1225 ALLOCATE (pab(1, 1))
1229 dft_control=dft_control, &
1231 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1232 auxbas_pw_pool=auxbas_pw_pool)
1235 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1241 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1242 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1249 IF (npme .GT. 0)
THEN
1250 atom_a = qs_env%qmmm_env_qm%image_charge_pot%image_mm_list(iatom)
1251 ra(:) =
pbc(qs_env%qmmm_env_qm%image_charge_pot%particles_all(atom_a)%r, cell)
1252 subpatch_pattern = 0
1254 lb_min=0, lb_max=0, &
1255 ra=ra, rb=ra, rp=ra, &
1256 zetp=qs_env%qmmm_env_qm%image_charge_pot%eta, &
1257 eps=eps_rho_rspace, &
1258 pab=pab, o1=0, o2=0, &
1259 prefactor=1.0_dp, cutoff=0.0_dp)
1262 0, 0, 0.0_dp, 0, ra, (/0.0_dp, 0.0_dp, 0.0_dp/), 1.0_dp, pab, 0, 0, rs_rho, &
1264 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1269 CALL auxbas_pw_pool%create_pw(rhoc_r)
1275 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1277 CALL timestop(handle)
1295 REAL(kind=
dp),
DIMENSION(:),
POINTER :: coeff
1296 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: total_rho_metal
1299 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_metal'
1301 INTEGER :: atom_a, handle, iatom, j, natom, npme, &
1303 INTEGER,
DIMENSION(:),
POINTER :: cores
1304 REAL(kind=
dp) :: eps_rho_rspace, radius
1305 REAL(kind=
dp),
DIMENSION(3) :: ra
1306 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1314 CALL timeset(routinen, handle)
1316 NULLIFY (cell, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, cores)
1318 ALLOCATE (pab(1, 1))
1322 dft_control=dft_control, &
1324 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1325 auxbas_pw_pool=auxbas_pw_pool)
1328 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1331 natom =
SIZE(qs_env%qmmm_env_qm%image_charge_pot%image_mm_list)
1338 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1339 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1349 IF (npme .GT. 0)
THEN
1352 atom_a = qs_env%qmmm_env_qm%image_charge_pot%image_mm_list(iatom)
1353 ra(:) =
pbc(qs_env%qmmm_env_qm%image_charge_pot%particles_all(atom_a)%r, cell)
1354 subpatch_pattern = 0
1356 lb_min=0, lb_max=0, &
1357 ra=ra, rb=ra, rp=ra, &
1358 zetp=qs_env%qmmm_env_qm%image_charge_pot%eta, &
1359 eps=eps_rho_rspace, &
1360 pab=pab, o1=0, o2=0, &
1361 prefactor=coeff(iatom), cutoff=0.0_dp)
1364 0, qs_env%qmmm_env_qm%image_charge_pot%eta, &
1365 0, 0, 0.0_dp, 0, ra, (/0.0_dp, 0.0_dp, 0.0_dp/), coeff(iatom), pab, 0, 0, rs_rho, &
1367 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1371 DEALLOCATE (pab, cores)
1373 CALL auxbas_pw_pool%create_pw(rhoc_r)
1377 IF (
PRESENT(total_rho_metal)) &
1382 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1384 CALL timestop(handle)
1402 REAL(kind=
dp),
INTENT(IN) :: eta
1403 INTEGER,
INTENT(IN) :: iatom_in
1405 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_resp_single'
1407 INTEGER :: handle, iatom, npme, subpatch_pattern
1408 REAL(kind=
dp) :: eps_rho_rspace, radius
1409 REAL(kind=
dp),
DIMENSION(3) :: ra
1410 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1419 CALL timeset(routinen, handle)
1420 NULLIFY (cell, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, &
1423 ALLOCATE (pab(1, 1))
1427 dft_control=dft_control, &
1428 particle_set=particle_set, &
1430 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1431 auxbas_pw_pool=auxbas_pw_pool)
1434 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1440 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1441 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1448 IF (npme .GT. 0)
THEN
1449 ra(:) =
pbc(particle_set(iatom)%r, cell)
1450 subpatch_pattern = 0
1452 lb_min=0, lb_max=0, &
1453 ra=ra, rb=ra, rp=ra, &
1454 zetp=eta, eps=eps_rho_rspace, &
1455 pab=pab, o1=0, o2=0, &
1456 prefactor=1.0_dp, cutoff=0.0_dp)
1459 (/0.0_dp, 0.0_dp, 0.0_dp/), 1.0_dp, pab, 0, 0, rs_rho, &
1461 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1466 CALL auxbas_pw_pool%create_pw(rhoc_r)
1472 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1474 CALL timestop(handle)
1490 SUBROUTINE calculate_rho_resp_all_r3d_rs (rho_resp, coeff, natom, eta, qs_env)
1493 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: coeff
1494 INTEGER,
INTENT(IN) :: natom
1495 REAL(KIND=
dp),
INTENT(IN) :: eta
1498 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_resp_all'
1500 INTEGER :: handle, iatom, j, npme, subpatch_pattern
1501 INTEGER,
DIMENSION(:),
POINTER :: cores
1502 REAL(kind=
dp) :: eps_rho_rspace, radius
1503 REAL(kind=
dp),
DIMENSION(3) :: ra
1504 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1513 CALL timeset(routinen, handle)
1515 NULLIFY (cell, cores, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, &
1518 ALLOCATE (pab(1, 1))
1522 dft_control=dft_control, &
1523 particle_set=particle_set, &
1525 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1526 auxbas_pw_pool=auxbas_pw_pool)
1529 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1537 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1538 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1548 IF (npme .GT. 0)
THEN
1551 ra(:) =
pbc(particle_set(iatom)%r, cell)
1552 subpatch_pattern = 0
1554 lb_min=0, lb_max=0, &
1555 ra=ra, rb=ra, rp=ra, &
1556 zetp=eta, eps=eps_rho_rspace, &
1557 pab=pab, o1=0, o2=0, &
1558 prefactor=coeff(iatom), cutoff=0.0_dp)
1562 0, 0, 0.0_dp, 0, ra, (/0.0_dp, 0.0_dp, 0.0_dp/), coeff(iatom), pab, 0, 0, rs_rho, &
1564 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1568 DEALLOCATE (pab, cores)
1570 CALL auxbas_pw_pool%create_pw(rhoc_r)
1575 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1577 CALL timestop(handle)
1579 END SUBROUTINE calculate_rho_resp_all_r3d_rs
1592 SUBROUTINE calculate_rho_resp_all_c1d_gs (rho_resp, coeff, natom, eta, qs_env)
1595 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: coeff
1596 INTEGER,
INTENT(IN) :: natom
1597 REAL(KIND=
dp),
INTENT(IN) :: eta
1600 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_resp_all'
1602 INTEGER :: handle, iatom, j, npme, subpatch_pattern
1603 INTEGER,
DIMENSION(:),
POINTER :: cores
1604 REAL(kind=
dp) :: eps_rho_rspace, radius
1605 REAL(kind=
dp),
DIMENSION(3) :: ra
1606 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab
1615 CALL timeset(routinen, handle)
1617 NULLIFY (cell, cores, dft_control, pab, pw_env, rs_rho, auxbas_pw_pool, &
1620 ALLOCATE (pab(1, 1))
1624 dft_control=dft_control, &
1625 particle_set=particle_set, &
1627 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
1628 auxbas_pw_pool=auxbas_pw_pool)
1631 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1639 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
1640 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
1650 IF (npme .GT. 0)
THEN
1653 ra(:) =
pbc(particle_set(iatom)%r, cell)
1654 subpatch_pattern = 0
1656 lb_min=0, lb_max=0, &
1657 ra=ra, rb=ra, rp=ra, &
1658 zetp=eta, eps=eps_rho_rspace, &
1659 pab=pab, o1=0, o2=0, &
1660 prefactor=coeff(iatom), cutoff=0.0_dp)
1664 0, 0, 0.0_dp, 0, ra, (/0.0_dp, 0.0_dp, 0.0_dp/), coeff(iatom), pab, 0, 0, rs_rho, &
1666 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
1670 DEALLOCATE (pab, cores)
1672 CALL auxbas_pw_pool%create_pw(rhoc_r)
1677 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
1679 CALL timestop(handle)
1681 END SUBROUTINE calculate_rho_resp_all_c1d_gs
1709 ks_env, soft_valid, compute_tau, compute_grad, &
1710 basis_type, der_type, idir, task_list_external, pw_env_external)
1712 TYPE(
dbcsr_type),
OPTIONAL,
TARGET :: matrix_p
1714 POINTER :: matrix_p_kp
1717 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: total_rho
1719 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid, compute_tau, compute_grad
1720 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
1721 INTEGER,
INTENT(IN),
OPTIONAL :: der_type, idir
1723 TYPE(
pw_env_type),
OPTIONAL,
POINTER :: pw_env_external
1725 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_rho_elec'
1727 CHARACTER(LEN=default_string_length) :: my_basis_type
1728 INTEGER :: ga_gb_function, handle, ilevel, img, &
1730 LOGICAL :: any_distributed, my_compute_grad, &
1731 my_compute_tau, my_soft_valid
1732 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_images
1739 CALL timeset(routinen, handle)
1741 NULLIFY (matrix_images, dft_control, pw_env, rs_rho, task_list)
1744 my_compute_tau = .false.
1745 IF (
PRESENT(compute_tau)) my_compute_tau = compute_tau
1746 my_compute_grad = .false.
1747 IF (
PRESENT(compute_grad)) my_compute_grad = compute_grad
1748 IF (
PRESENT(der_type))
THEN
1749 SELECT CASE (der_type)
1771 cpabort(
"Unknown der_type")
1773 ELSE IF (my_compute_tau)
THEN
1775 ELSE IF (my_compute_grad)
THEN
1776 cpassert(
PRESENT(idir))
1785 cpabort(
"invalid idir")
1792 my_basis_type =
"ORB"
1793 IF (
PRESENT(basis_type)) my_basis_type = basis_type
1794 cpassert(my_basis_type ==
"ORB" .OR.
PRESENT(task_list_external))
1797 my_soft_valid = .false.
1798 IF (
PRESENT(soft_valid)) my_soft_valid = soft_valid
1799 IF (
PRESENT(task_list_external))
THEN
1800 task_list => task_list_external
1801 ELSEIF (my_soft_valid)
THEN
1802 CALL get_ks_env(ks_env, task_list_soft=task_list)
1806 cpassert(
ASSOCIATED(task_list))
1809 IF (
PRESENT(pw_env_external))
THEN
1810 pw_env => pw_env_external
1814 cpassert(
ASSOCIATED(pw_env))
1818 nlevels =
SIZE(rs_rho)
1819 group = rs_rho(1)%desc%group
1822 any_distributed = .false.
1823 DO ilevel = 1, nlevels
1824 any_distributed = any_distributed .OR. rs_rho(ilevel)%desc%distributed
1828 CALL get_ks_env(ks_env, dft_control=dft_control)
1829 nimages = dft_control%nimages
1830 ALLOCATE (matrix_images(nimages))
1831 IF (
PRESENT(matrix_p_kp))
THEN
1832 cpassert(.NOT.
PRESENT(matrix_p))
1834 matrix_images(img)%matrix => matrix_p_kp(img)%matrix
1837 cpassert(
PRESENT(matrix_p) .AND. nimages == 1)
1838 matrix_images(1)%matrix => matrix_p
1842 IF (any_distributed)
THEN
1847 DEALLOCATE (matrix_images)
1851 ga_gb_function=ga_gb_function, &
1852 pab_blocks=task_list%pab_buffer, &
1859 CALL timestop(handle)
1876 soft_valid, basis_type)
1878 TYPE(
dbcsr_type),
OPTIONAL,
TARGET :: matrix_p
1880 POINTER :: matrix_p_kp
1884 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid
1885 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
1887 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_drho_elec'
1889 CHARACTER(LEN=default_string_length) :: my_basis_type
1890 INTEGER :: bcol, brow, dabqadb_func, handle, iatom, iatom_old, idir, igrid_level, ikind, &
1891 ikind_old, img, img_old, ipgf, iset, iset_old, itask, ithread, jatom, jatom_old, jkind, &
1892 jkind_old, jpgf, jset, jset_old, maxco, maxsgf_set, na1, na2, natoms, nb1, nb2, ncoa, &
1893 ncob, nimages, nseta, nsetb, ntasks, nthread, sgfa, sgfb
1894 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
1896 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
1897 LOGICAL :: atom_pair_changed, distributed_rs_grids, &
1898 do_kp, found, my_soft, use_subpatch
1899 REAL(kind=
dp) :: eps_rho_rspace, f, prefactor, radius, &
1901 REAL(kind=
dp),
DIMENSION(3) :: ra, rab, rab_inv, rb, rp
1902 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, pab, sphi_a, sphi_b, work, &
1904 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: pabt, workt
1905 TYPE(
atom_pair_type),
DIMENSION(:),
POINTER :: atom_pair_recv, atom_pair_send
1915 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1920 TYPE(
task_type),
DIMENSION(:),
POINTER :: tasks
1922 CALL timeset(routinen, handle)
1924 cpassert(
PRESENT(matrix_p) .OR.
PRESENT(matrix_p_kp))
1925 do_kp =
PRESENT(matrix_p_kp)
1927 NULLIFY (cell, dft_control, orb_basis_set, deltap, qs_kind_set, &
1928 sab_orb, particle_set, rs_rho, pw_env, rs_descs, la_max, la_min, &
1929 lb_max, lb_min, npgfa, npgfb, nsgfa, nsgfb, p_block, sphi_a, &
1930 sphi_b, zeta, zetb, first_sgfa, first_sgfb, tasks, pabt, workt)
1934 IF (
PRESENT(soft_valid)) my_soft = soft_valid
1936 IF (
PRESENT(basis_type))
THEN
1937 my_basis_type = basis_type
1939 my_basis_type =
"ORB"
1943 qs_kind_set=qs_kind_set, &
1945 dft_control=dft_control, &
1946 particle_set=particle_set, &
1950 SELECT CASE (my_basis_type)
1953 task_list=task_list, &
1954 task_list_soft=task_list_soft)
1957 task_list_soft=task_list_soft)
1958 CALL get_admm_env(qs_env%admm_env, task_list_aux_fit=task_list)
1962 gridlevel_info => pw_env%gridlevel_info
1968 maxsgf_set=maxsgf_set, &
1969 basis_type=my_basis_type)
1970 CALL reallocate(pabt, 1, maxco, 1, maxco, 0, nthread - 1)
1971 CALL reallocate(workt, 1, maxco, 1, maxsgf_set, 0, nthread - 1)
1974 nimages = dft_control%nimages
1975 cpassert(nimages == 1 .OR. do_kp)
1977 natoms =
SIZE(particle_set)
1980 IF (my_soft) task_list => task_list_soft
1981 cpassert(
ASSOCIATED(task_list))
1982 tasks => task_list%tasks
1983 atom_pair_send => task_list%atom_pair_send
1984 atom_pair_recv => task_list%atom_pair_recv
1985 ntasks = task_list%ntasks
1988 cpassert(
ASSOCIATED(pw_env))
1989 CALL pw_env_get(pw_env, rs_descs=rs_descs, rs_grids=rs_rho)
1990 DO igrid_level = 1, gridlevel_info%ngrid_levels
1991 distributed_rs_grids = rs_rho(igrid_level)%desc%distributed
1994 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1999 ALLOCATE (deltap(nimages))
2000 IF (distributed_rs_grids)
THEN
2007 CALL dbcsr_copy(deltap(img)%matrix, matrix_p_kp(img)%matrix, &
2011 CALL dbcsr_copy(deltap(1)%matrix, matrix_p, name=
"DeltaP")
2016 deltap(img)%matrix => matrix_p_kp(img)%matrix
2019 deltap(1)%matrix => matrix_p
2024 IF (distributed_rs_grids)
THEN
2026 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
2027 nimages=nimages, scatter=.true.)
2033 pab => pabt(:, :, ithread)
2034 work => workt(:, :, ithread)
2036 loop_xyz:
DO idir = 1, 3
2038 DO igrid_level = 1, gridlevel_info%ngrid_levels
2042 iatom_old = -1; jatom_old = -1; iset_old = -1; jset_old = -1
2043 ikind_old = -1; jkind_old = -1; img_old = -1
2044 loop_tasks:
DO itask = 1, ntasks
2047 igrid_level = tasks(itask)%grid_level
2048 img = tasks(itask)%image
2049 iatom = tasks(itask)%iatom
2050 jatom = tasks(itask)%jatom
2051 iset = tasks(itask)%iset
2052 jset = tasks(itask)%jset
2053 ipgf = tasks(itask)%ipgf
2054 jpgf = tasks(itask)%jpgf
2056 ikind = particle_set(iatom)%atomic_kind%kind_number
2057 jkind = particle_set(jatom)%atomic_kind%kind_number
2059 IF (iatom .NE. iatom_old .OR. jatom .NE. jatom_old .OR. img .NE. img_old)
THEN
2061 IF (iatom .NE. iatom_old) ra(:) =
pbc(particle_set(iatom)%r, cell)
2063 IF (iatom <= jatom)
THEN
2071 IF (ikind .NE. ikind_old)
THEN
2073 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2074 basis_type=
"ORB_SOFT")
2076 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2077 basis_type=my_basis_type)
2080 first_sgf=first_sgfa, &
2090 IF (jkind .NE. jkind_old)
THEN
2092 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2093 basis_type=
"ORB_SOFT")
2095 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2096 basis_type=my_basis_type)
2099 first_sgf=first_sgfb, &
2110 row=brow, col=bcol, block=p_block, found=found)
2118 atom_pair_changed = .true.
2122 atom_pair_changed = .false.
2126 IF (atom_pair_changed .OR. iset_old .NE. iset .OR. jset_old .NE. jset)
THEN
2128 ncoa = npgfa(iset)*
ncoset(la_max(iset))
2129 sgfa = first_sgfa(1, iset)
2130 ncob = npgfb(jset)*
ncoset(lb_max(jset))
2131 sgfb = first_sgfb(1, jset)
2133 IF (iatom <= jatom)
THEN
2134 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
2135 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2136 p_block(sgfa, sgfb),
SIZE(p_block, 1), &
2137 0.0_dp, work(1, 1), maxco)
2138 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
2139 1.0_dp, work(1, 1), maxco, &
2140 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2141 0.0_dp, pab(1, 1), maxco)
2143 CALL dgemm(
"N",
"N", ncob, nsgfa(iset), nsgfb(jset), &
2144 1.0_dp, sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2145 p_block(sgfb, sgfa),
SIZE(p_block, 1), &
2146 0.0_dp, work(1, 1), maxco)
2147 CALL dgemm(
"N",
"T", ncob, ncoa, nsgfa(iset), &
2148 1.0_dp, work(1, 1), maxco, &
2149 sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2150 0.0_dp, pab(1, 1), maxco)
2158 rab(:) = tasks(itask)%rab
2159 rb(:) = ra(:) + rab(:)
2160 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
2162 f = zetb(jpgf, jset)/zetp
2163 rp(:) = ra(:) + f*rab(:)
2164 prefactor = exp(-zeta(ipgf, iset)*f*dot_product(rab, rab))
2166 lb_min=lb_min(jset), lb_max=lb_max(jset), &
2167 ra=ra, rb=rb, rp=rp, &
2168 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
2169 prefactor=prefactor, cutoff=1.0_dp)
2171 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
2172 na2 = ipgf*
ncoset(la_max(iset))
2173 nb1 = (jpgf - 1)*
ncoset(lb_max(jset)) + 1
2174 nb2 = jpgf*
ncoset(lb_max(jset))
2177 IF (iatom == jatom .AND. img == 1)
THEN
2184 IF (rs_rho(igrid_level)%desc%distributed)
THEN
2186 IF (tasks(itask)%dist_type .EQ. 2)
THEN
2187 use_subpatch = .true.
2189 use_subpatch = .false.
2192 use_subpatch = .false.
2203 cpabort(
"invalid idir")
2206 IF (iatom <= jatom)
THEN
2208 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2209 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2210 ra, rab, scale, pab, na1 - 1, nb1 - 1, &
2211 rs_rho(igrid_level), &
2212 radius=radius, ga_gb_function=dabqadb_func, &
2213 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern)
2217 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2218 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2219 rb, rab_inv, scale, pab, nb1 - 1, na1 - 1, &
2220 rs_rho(igrid_level), &
2221 radius=radius, ga_gb_function=dabqadb_func, &
2222 use_subpatch=use_subpatch, subpatch_pattern=tasks(itask)%subpatch_pattern)
2227 CALL density_rs2pw(pw_env, rs_rho, drho(idir), drho_gspace(idir))
2232 IF (distributed_rs_grids)
THEN
2236 NULLIFY (deltap(img)%matrix)
2241 DEALLOCATE (pabt, workt)
2243 CALL timestop(handle)
2263 soft_valid, basis_type, beta, lambda)
2265 TYPE(
dbcsr_type),
OPTIONAL,
TARGET :: matrix_p
2267 POINTER :: matrix_p_kp
2271 LOGICAL,
INTENT(IN),
OPTIONAL :: soft_valid
2272 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
2273 INTEGER,
INTENT(IN) :: beta, lambda
2275 CHARACTER(len=*),
PARAMETER :: routinen =
'calculate_drho_elec_dR'
2277 CHARACTER(LEN=default_string_length) :: my_basis_type
2278 INTEGER :: bcol, brow, dabqadb_func, handle, iatom, iatom_old, igrid_level, ikind, &
2279 ikind_old, img, img_old, ipgf, iset, iset_old, itask, ithread, jatom, jatom_old, jkind, &
2280 jkind_old, jpgf, jset, jset_old, maxco, maxsgf_set, na1, na2, natoms, nb1, nb2, ncoa, &
2281 ncob, nimages, nseta, nsetb, ntasks, nthread, sgfa, sgfb
2282 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, lb_max, lb_min, npgfa, &
2284 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa, first_sgfb
2285 LOGICAL :: atom_pair_changed, distributed_rs_grids, &
2286 do_kp, found, my_soft, use_subpatch
2287 REAL(kind=
dp) :: eps_rho_rspace, f, prefactor, radius, &
2289 REAL(kind=
dp),
DIMENSION(3) :: ra, rab, rab_inv, rb, rp
2290 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: p_block, pab, sphi_a, sphi_b, work, &
2292 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: pabt, workt
2293 TYPE(
atom_pair_type),
DIMENSION(:),
POINTER :: atom_pair_recv, atom_pair_send
2301 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2306 TYPE(
task_type),
DIMENSION(:),
POINTER :: tasks
2308 CALL timeset(routinen, handle)
2310 cpassert(
PRESENT(matrix_p) .OR.
PRESENT(matrix_p_kp))
2311 do_kp =
PRESENT(matrix_p_kp)
2313 NULLIFY (cell, dft_control, orb_basis_set, deltap, qs_kind_set, &
2314 particle_set, rs_rho, pw_env, rs_descs, la_max, la_min, lb_max, &
2315 lb_min, npgfa, npgfb, nsgfa, nsgfb, p_block, sphi_a, sphi_b, &
2316 zeta, zetb, first_sgfa, first_sgfb, tasks, pabt, workt)
2320 IF (
PRESENT(soft_valid)) my_soft = soft_valid
2322 IF (
PRESENT(basis_type))
THEN
2323 my_basis_type = basis_type
2325 my_basis_type =
"ORB"
2329 qs_kind_set=qs_kind_set, &
2331 dft_control=dft_control, &
2332 particle_set=particle_set, &
2335 SELECT CASE (my_basis_type)
2338 task_list=task_list, &
2339 task_list_soft=task_list_soft)
2342 task_list_soft=task_list_soft)
2343 CALL get_admm_env(qs_env%admm_env, task_list_aux_fit=task_list)
2347 gridlevel_info => pw_env%gridlevel_info
2353 maxsgf_set=maxsgf_set, &
2354 basis_type=my_basis_type)
2355 CALL reallocate(pabt, 1, maxco, 1, maxco, 0, nthread - 1)
2356 CALL reallocate(workt, 1, maxco, 1, maxsgf_set, 0, nthread - 1)
2359 nimages = dft_control%nimages
2360 cpassert(nimages == 1 .OR. do_kp)
2362 natoms =
SIZE(particle_set)
2365 IF (my_soft) task_list => task_list_soft
2366 cpassert(
ASSOCIATED(task_list))
2367 tasks => task_list%tasks
2368 atom_pair_send => task_list%atom_pair_send
2369 atom_pair_recv => task_list%atom_pair_recv
2370 ntasks = task_list%ntasks
2373 cpassert(
ASSOCIATED(pw_env))
2374 CALL pw_env_get(pw_env, rs_descs=rs_descs, rs_grids=rs_rho)
2375 DO igrid_level = 1, gridlevel_info%ngrid_levels
2376 distributed_rs_grids = rs_rho(igrid_level)%desc%distributed
2379 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
2384 ALLOCATE (deltap(nimages))
2385 IF (distributed_rs_grids)
THEN
2392 CALL dbcsr_copy(deltap(img)%matrix, matrix_p_kp(img)%matrix, &
2396 CALL dbcsr_copy(deltap(1)%matrix, matrix_p, name=
"DeltaP")
2401 deltap(img)%matrix => matrix_p_kp(img)%matrix
2404 deltap(1)%matrix => matrix_p
2409 IF (distributed_rs_grids)
THEN
2411 atom_pair_send=atom_pair_send, atom_pair_recv=atom_pair_recv, &
2412 nimages=nimages, scatter=.true.)
2418 pab => pabt(:, :, ithread)
2419 work => workt(:, :, ithread)
2421 DO igrid_level = 1, gridlevel_info%ngrid_levels
2425 iatom_old = -1; jatom_old = -1; iset_old = -1; jset_old = -1
2426 ikind_old = -1; jkind_old = -1; img_old = -1
2427 loop_tasks:
DO itask = 1, ntasks
2430 igrid_level = tasks(itask)%grid_level
2431 img = tasks(itask)%image
2432 iatom = tasks(itask)%iatom
2433 jatom = tasks(itask)%jatom
2434 iset = tasks(itask)%iset
2435 jset = tasks(itask)%jset
2436 ipgf = tasks(itask)%ipgf
2437 jpgf = tasks(itask)%jpgf
2439 ikind = particle_set(iatom)%atomic_kind%kind_number
2440 jkind = particle_set(jatom)%atomic_kind%kind_number
2442 IF (iatom .NE. iatom_old .OR. jatom .NE. jatom_old .OR. img .NE. img_old)
THEN
2444 IF (iatom .NE. iatom_old) ra(:) =
pbc(particle_set(iatom)%r, cell)
2446 IF (iatom <= jatom)
THEN
2454 IF (ikind .NE. ikind_old)
THEN
2456 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2457 basis_type=
"ORB_SOFT")
2459 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, &
2460 basis_type=my_basis_type)
2463 first_sgf=first_sgfa, &
2473 IF (jkind .NE. jkind_old)
THEN
2475 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2476 basis_type=
"ORB_SOFT")
2478 CALL get_qs_kind(qs_kind_set(jkind), basis_set=orb_basis_set, &
2479 basis_type=my_basis_type)
2482 first_sgf=first_sgfb, &
2493 row=brow, col=bcol, block=p_block, found=found)
2501 atom_pair_changed = .true.
2505 atom_pair_changed = .false.
2509 IF (atom_pair_changed .OR. iset_old .NE. iset .OR. jset_old .NE. jset)
THEN
2511 ncoa = npgfa(iset)*
ncoset(la_max(iset))
2512 sgfa = first_sgfa(1, iset)
2513 ncob = npgfb(jset)*
ncoset(lb_max(jset))
2514 sgfb = first_sgfb(1, jset)
2516 IF (iatom <= jatom)
THEN
2517 CALL dgemm(
"N",
"N", ncoa, nsgfb(jset), nsgfa(iset), &
2518 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2519 p_block(sgfa, sgfb),
SIZE(p_block, 1), &
2520 0.0_dp, work(1, 1), maxco)
2521 CALL dgemm(
"N",
"T", ncoa, ncob, nsgfb(jset), &
2522 1.0_dp, work(1, 1), maxco, &
2523 sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2524 0.0_dp, pab(1, 1), maxco)
2526 CALL dgemm(
"N",
"N", ncob, nsgfa(iset), nsgfb(jset), &
2527 1.0_dp, sphi_b(1, sgfb),
SIZE(sphi_b, 1), &
2528 p_block(sgfb, sgfa),
SIZE(p_block, 1), &
2529 0.0_dp, work(1, 1), maxco)
2530 CALL dgemm(
"N",
"T", ncob, ncoa, nsgfa(iset), &
2531 1.0_dp, work(1, 1), maxco, &
2532 sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
2533 0.0_dp, pab(1, 1), maxco)
2541 rab(:) = tasks(itask)%rab
2542 rb(:) = ra(:) + rab(:)
2543 zetp = zeta(ipgf, iset) + zetb(jpgf, jset)
2545 f = zetb(jpgf, jset)/zetp
2546 rp(:) = ra(:) + f*rab(:)
2547 prefactor = exp(-zeta(ipgf, iset)*f*dot_product(rab, rab))
2549 lb_min=lb_min(jset), lb_max=lb_max(jset), &
2550 ra=ra, rb=rb, rp=rp, &
2551 zetp=zetp, eps=eps_rho_rspace, &
2552 prefactor=prefactor, cutoff=1.0_dp)
2554 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
2555 na2 = ipgf*
ncoset(la_max(iset))
2556 nb1 = (jpgf - 1)*
ncoset(lb_max(jset)) + 1
2557 nb2 = jpgf*
ncoset(lb_max(jset))
2560 IF (iatom == jatom .AND. img == 1)
THEN
2567 IF (rs_rho(igrid_level)%desc%distributed)
THEN
2569 IF (tasks(itask)%dist_type .EQ. 2)
THEN
2570 use_subpatch = .true.
2572 use_subpatch = .false.
2575 use_subpatch = .false.
2586 cpabort(
"invalid beta")
2589 IF (iatom <= jatom)
THEN
2590 IF (iatom == lambda) &
2592 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2593 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2594 ra, rab, scale, pab, na1 - 1, nb1 - 1, &
2595 rsgrid=rs_rho(igrid_level), &
2596 ga_gb_function=dabqadb_func, radius=radius, &
2597 use_subpatch=use_subpatch, &
2598 subpatch_pattern=tasks(itask)%subpatch_pattern)
2599 IF (jatom == lambda) &
2601 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2602 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2603 ra, rab, scale, pab, na1 - 1, nb1 - 1, &
2604 rsgrid=rs_rho(igrid_level), &
2605 ga_gb_function=dabqadb_func + 3, radius=radius, &
2606 use_subpatch=use_subpatch, &
2607 subpatch_pattern=tasks(itask)%subpatch_pattern)
2610 IF (jatom == lambda) &
2612 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2613 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2614 rb, rab_inv, scale, pab, nb1 - 1, na1 - 1, &
2615 rs_rho(igrid_level), &
2616 ga_gb_function=dabqadb_func, radius=radius, &
2617 use_subpatch=use_subpatch, &
2618 subpatch_pattern=tasks(itask)%subpatch_pattern)
2619 IF (iatom == lambda) &
2621 lb_max(jset), zetb(jpgf, jset), lb_min(jset), &
2622 la_max(iset), zeta(ipgf, iset), la_min(iset), &
2623 rb, rab_inv, scale, pab, nb1 - 1, na1 - 1, &
2624 rs_rho(igrid_level), &
2625 ga_gb_function=dabqadb_func + 3, radius=radius, &
2626 use_subpatch=use_subpatch, &
2627 subpatch_pattern=tasks(itask)%subpatch_pattern)
2635 IF (distributed_rs_grids)
THEN
2639 NULLIFY (deltap(img)%matrix)
2644 DEALLOCATE (pabt, workt)
2646 CALL timestop(handle)
2669 atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, &
2670 pw_env, required_function, basis_type)
2675 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2680 INTEGER,
INTENT(IN) :: required_function
2681 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
2683 CHARACTER(LEN=*),
PARAMETER :: routinen =
'collocate_single_gaussian'
2685 CHARACTER(LEN=default_string_length) :: my_basis_type
2686 INTEGER :: group_size, handle, i, iatom, igrid_level, ikind, ipgf, iset, maxco, maxsgf_set, &
2687 my_index, my_pos, na1, na2, natom, ncoa, nseta, offset, sgfa
2688 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: where_is_the_point
2689 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nsgfa
2690 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
2692 REAL(kind=
dp) :: dab, eps_rho_rspace, radius, scale
2693 REAL(kind=
dp),
DIMENSION(3) :: ra
2694 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab, sphi_a, zeta
2703 IF (
PRESENT(basis_type))
THEN
2704 my_basis_type = basis_type
2706 my_basis_type =
"ORB"
2709 CALL timeset(routinen, handle)
2711 NULLIFY (orb_basis_set, pab, la_max, la_min, npgfa, nsgfa, sphi_a, &
2712 zeta, first_sgfa, rs_rho, pw_pools)
2715 cpassert(
ASSOCIATED(pw_env))
2716 CALL pw_env_get(pw_env, rs_grids=rs_rho, pw_pools=pw_pools, &
2717 gridlevel_info=gridlevel_info)
2723 DO igrid_level = 1, gridlevel_info%ngrid_levels
2727 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
2732 maxsgf_set=maxsgf_set, &
2733 basis_type=my_basis_type)
2735 ALLOCATE (pab(maxco, 1))
2738 group = mgrid_rspace(1)%pw_grid%para%group
2739 my_pos = mgrid_rspace(1)%pw_grid%para%group%mepos
2740 group_size = mgrid_rspace(1)%pw_grid%para%group%num_pe
2741 ALLOCATE (where_is_the_point(0:group_size - 1))
2744 ikind = particle_set(iatom)%atomic_kind%kind_number
2745 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=my_basis_type)
2747 first_sgf=first_sgfa, &
2755 ra(:) =
pbc(particle_set(iatom)%r, cell)
2760 ncoa = npgfa(iset)*
ncoset(la_max(iset))
2761 sgfa = first_sgfa(1, iset)
2765 DO i = 1, nsgfa(iset)
2766 IF (offset + i == required_function)
THEN
2775 pab(1:ncoa, 1) = sphi_a(1:ncoa, sgfa + my_index - 1)
2777 DO ipgf = 1, npgfa(iset)
2779 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
2780 na2 = ipgf*
ncoset(la_max(iset))
2785 IF (
map_gaussian_here(rs_rho(igrid_level), cell%h_inv, ra, offset, group_size, my_pos))
THEN
2787 lb_min=0, lb_max=0, ra=ra, rb=ra, rp=ra, &
2788 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
2789 prefactor=1.0_dp, cutoff=1.0_dp)
2793 ra, (/0.0_dp, 0.0_dp, 0.0_dp/), &
2794 scale, pab, na1 - 1, 0, rs_rho(igrid_level), &
2802 offset = offset + nsgfa(iset)
2808 DO igrid_level = 1, gridlevel_info%ngrid_levels
2810 mgrid_rspace(igrid_level))
2814 DO igrid_level = 1, gridlevel_info%ngrid_levels
2816 mgrid_gspace(igrid_level))
2817 CALL pw_axpy(mgrid_gspace(igrid_level), rho_gspace)
2829 CALL timestop(handle)
2852 atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, &
2855 INTEGER,
INTENT(IN) :: ivector
2859 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2864 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
2866 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_wavefunction'
2868 INTEGER :: handle, i, nao
2870 REAL(kind=
dp) :: eps_rho_rspace
2871 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvector
2873 CALL timeset(routinen, handle)
2876 ALLOCATE (eigenvector(nao))
2881 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
2884 atomic_kind_set, qs_kind_set, cell, particle_set, pw_env, &
2885 eps_rho_rspace, basis_type)
2887 DEALLOCATE (eigenvector)
2889 CALL timestop(handle)
2914 atomic_kind_set, qs_kind_set, cell, particle_set, pw_env, &
2915 eps_rho_rspace, basis_type)
2916 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: vector
2920 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2924 REAL(kind=
dp),
INTENT(IN) :: eps_rho_rspace
2925 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
2927 CHARACTER(LEN=*),
PARAMETER :: routinen =
'collocate_function'
2929 CHARACTER(LEN=default_string_length) :: my_basis_type
2930 INTEGER :: group_size, handle, i, iatom, igrid_level, ikind, ipgf, iset, maxco, maxsgf_set, &
2931 my_pos, na1, na2, natom, ncoa, nseta, offset, sgfa
2932 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: where_is_the_point
2933 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nsgfa
2934 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
2935 REAL(kind=
dp) :: dab, radius, scale
2936 REAL(kind=
dp),
DIMENSION(3) :: ra
2937 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: pab, sphi_a, work, zeta
2946 CALL timeset(routinen, handle)
2948 IF (
PRESENT(basis_type))
THEN
2949 my_basis_type = basis_type
2951 my_basis_type =
"ORB"
2954 NULLIFY (orb_basis_set, pab, work, la_max, la_min, &
2955 npgfa, nsgfa, sphi_a, zeta, first_sgfa, rs_rho, pw_pools)
2958 cpassert(
ASSOCIATED(pw_env))
2959 CALL pw_env_get(pw_env, rs_grids=rs_rho, pw_pools=pw_pools, &
2960 gridlevel_info=gridlevel_info)
2966 DO igrid_level = 1, gridlevel_info%ngrid_levels
2974 maxsgf_set=maxsgf_set, &
2975 basis_type=my_basis_type)
2977 ALLOCATE (pab(maxco, 1))
2978 ALLOCATE (work(maxco, 1))
2981 group = mgrid_rspace(1)%pw_grid%para%group
2982 my_pos = mgrid_rspace(1)%pw_grid%para%group%mepos
2983 group_size = mgrid_rspace(1)%pw_grid%para%group%num_pe
2984 ALLOCATE (where_is_the_point(0:group_size - 1))
2987 ikind = particle_set(iatom)%atomic_kind%kind_number
2988 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=my_basis_type)
2990 first_sgf=first_sgfa, &
2998 ra(:) =
pbc(particle_set(iatom)%r, cell)
3003 ncoa = npgfa(iset)*
ncoset(la_max(iset))
3004 sgfa = first_sgfa(1, iset)
3006 DO i = 1, nsgfa(iset)
3007 work(i, 1) = vector(offset + i)
3010 CALL dgemm(
"N",
"N", ncoa, 1, nsgfa(iset), &
3011 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
3012 work(1, 1),
SIZE(work, 1), &
3013 0.0_dp, pab(1, 1),
SIZE(pab, 1))
3015 DO ipgf = 1, npgfa(iset)
3017 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
3018 na2 = ipgf*
ncoset(la_max(iset))
3023 IF (
map_gaussian_here(rs_rho(igrid_level), cell%h_inv, ra, offset, group_size, my_pos))
THEN
3025 lb_min=0, lb_max=0, ra=ra, rb=ra, rp=ra, &
3026 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
3027 prefactor=1.0_dp, cutoff=1.0_dp)
3031 ra, (/0.0_dp, 0.0_dp, 0.0_dp/), &
3032 scale, pab, na1 - 1, 0, rs_rho(igrid_level), &
3038 offset = offset + nsgfa(iset)
3044 DO igrid_level = 1, gridlevel_info%ngrid_levels
3046 mgrid_rspace(igrid_level))
3050 DO igrid_level = 1, gridlevel_info%ngrid_levels
3052 mgrid_gspace(igrid_level))
3053 CALL pw_axpy(mgrid_gspace(igrid_level), rho_gspace)
3066 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)
...
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, 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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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)
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, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
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)
Get attributes of an atomic kind set.
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, 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, 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, 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 ...