41 USE dbcsr_api,
ONLY: dbcsr_get_block_p,&
69 #include "./base/base_uses.f90"
75 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .false.
77 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_integrate_potential_single'
98 TYPE(pw_r3d_rs_type),
INTENT(IN) :: rho_rspace
99 TYPE(qs_environment_type),
POINTER :: qs_env
101 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_ppl_rspace'
103 INTEGER :: atom_a, handle, iatom, ikind, j, lppl, &
104 n, natom_of_kind, ni, npme
105 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
106 LOGICAL :: use_virial
107 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
108 REAL(kind=
dp),
DIMENSION(3) :: force_a, force_b, ra
109 REAL(kind=
dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
110 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cexp_ppl
111 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: hab, pab
112 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
113 TYPE(cell_type),
POINTER :: cell
114 TYPE(dft_control_type),
POINTER :: dft_control
115 TYPE(gth_potential_type),
POINTER :: gth_potential
116 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
117 TYPE(pw_env_type),
POINTER :: pw_env
118 TYPE(qs_force_type),
DIMENSION(:),
POINTER :: force
119 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
120 TYPE(realspace_grid_type),
POINTER :: rs_v
121 TYPE(virial_type),
POINTER :: virial
123 CALL timeset(routinen, handle)
125 NULLIFY (pw_env, cores)
128 CALL pw_env_get(pw_env=pw_env, auxbas_rs_grid=rs_v)
133 atomic_kind_set=atomic_kind_set, &
134 qs_kind_set=qs_kind_set, &
136 dft_control=dft_control, &
137 particle_set=particle_set, &
139 force=force, virial=virial)
141 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
143 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
145 DO ikind = 1,
SIZE(atomic_kind_set)
147 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom_of_kind, atom_list=atom_list)
148 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential)
150 IF (.NOT.
ASSOCIATED(gth_potential)) cycle
151 CALL get_potential(potential=gth_potential, alpha_ppl=alpha, nexp_ppl=lppl, cexp_ppl=cexp_ppl)
156 ALLOCATE (hab(ni, 1), pab(ni, 1))
159 CALL reallocate(cores, 1, natom_of_kind)
167 pab(1, 1) = cexp_ppl(1)
170 pab(n, 1) = cexp_ppl(2)
172 pab(n, 1) = cexp_ppl(2)
174 pab(n, 1) = cexp_ppl(2)
177 pab(n, 1) = cexp_ppl(3)
179 pab(n, 1) = cexp_ppl(3)
181 pab(n, 1) = cexp_ppl(3)
183 pab(n, 1) = 2._dp*cexp_ppl(3)
185 pab(n, 1) = 2._dp*cexp_ppl(3)
187 pab(n, 1) = 2._dp*cexp_ppl(3)
190 pab(n, 1) = cexp_ppl(4)
192 pab(n, 1) = cexp_ppl(4)
194 pab(n, 1) = cexp_ppl(4)
196 pab(n, 1) = 3._dp*cexp_ppl(4)
198 pab(n, 1) = 3._dp*cexp_ppl(4)
200 pab(n, 1) = 3._dp*cexp_ppl(4)
202 pab(n, 1) = 3._dp*cexp_ppl(4)
204 pab(n, 1) = 3._dp*cexp_ppl(4)
206 pab(n, 1) = 3._dp*cexp_ppl(4)
208 pab(n, 1) = 6._dp*cexp_ppl(4)
214 DO iatom = 1, natom_of_kind
215 atom_a = atom_list(iatom)
216 ra(:) =
pbc(particle_set(atom_a)%r, cell)
217 IF (rs_v%desc%parallel .AND. .NOT. rs_v%desc%distributed)
THEN
219 IF (
modulo(iatom, rs_v%desc%group_size) == rs_v%desc%my_pos)
THEN
232 atom_a = atom_list(iatom)
233 ra(:) =
pbc(particle_set(atom_a)%r, cell)
244 ra=ra, rb=ra, rp=ra, &
245 zetp=alpha, eps=eps_rho_rspace, &
246 pab=pab, o1=0, o2=0, &
247 prefactor=1.0_dp, cutoff=1.0_dp)
250 0, 0.0_dp, 0, ra, (/0.0_dp, 0.0_dp, 0.0_dp/), &
251 rs_v, hab, pab=pab, o1=0, o2=0, &
253 calculate_forces=.true., force_a=force_a, &
254 force_b=force_b, use_virial=use_virial, my_virial_a=my_virial_a, &
255 my_virial_b=my_virial_b, use_subpatch=.true., subpatch_pattern=0)
257 force(ikind)%gth_ppl(:, iatom) = &
258 force(ikind)%gth_ppl(:, iatom) + force_a(:)*rho_rspace%pw_grid%dvol
261 virial%pv_ppl = virial%pv_ppl + my_virial_a*rho_rspace%pw_grid%dvol
262 virial%pv_virial = virial%pv_virial + my_virial_a*rho_rspace%pw_grid%dvol
263 cpabort(
"Virial not debuged for CORE_PPL")
267 DEALLOCATE (hab, pab)
273 CALL timestop(handle)
283 TYPE(pw_r3d_rs_type),
INTENT(IN) :: rho_rspace
284 TYPE(qs_environment_type),
POINTER :: qs_env
286 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_rho_nlcc'
288 INTEGER :: atom_a, handle, iatom, iexp_nlcc, ikind, &
289 ithread, j, n, natom, nc, nexp_nlcc, &
291 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores, nct_nlcc
292 LOGICAL :: nlcc, use_virial
293 REAL(kind=
dp) :: alpha, eps_rho_rspace, radius
294 REAL(kind=
dp),
DIMENSION(3) :: force_a, force_b, ra
295 REAL(kind=
dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
296 REAL(kind=
dp),
DIMENSION(:),
POINTER :: alpha_nlcc
297 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cval_nlcc, hab, pab
298 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
299 TYPE(cell_type),
POINTER :: cell
300 TYPE(dft_control_type),
POINTER :: dft_control
301 TYPE(gth_potential_type),
POINTER :: gth_potential
302 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
303 TYPE(pw_env_type),
POINTER :: pw_env
304 TYPE(qs_force_type),
DIMENSION(:),
POINTER :: force
305 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
306 TYPE(realspace_grid_type),
POINTER :: rs_v
307 TYPE(virial_type),
POINTER :: virial
309 CALL timeset(routinen, handle)
311 NULLIFY (pw_env, cores)
314 CALL pw_env_get(pw_env=pw_env, auxbas_rs_grid=rs_v)
319 atomic_kind_set=atomic_kind_set, &
320 qs_kind_set=qs_kind_set, &
322 dft_control=dft_control, &
323 particle_set=particle_set, &
325 force=force, virial=virial)
327 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
329 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
331 DO ikind = 1,
SIZE(atomic_kind_set)
333 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
334 CALL get_qs_kind(qs_kind_set(ikind), gth_potential=gth_potential)
336 IF (.NOT.
ASSOCIATED(gth_potential)) cycle
337 CALL get_potential(potential=gth_potential, nlcc_present=nlcc, nexp_nlcc=nexp_nlcc, &
338 alpha_nlcc=alpha_nlcc, nct_nlcc=nct_nlcc, cval_nlcc=cval_nlcc)
340 IF (.NOT. nlcc) cycle
342 DO iexp_nlcc = 1, nexp_nlcc
344 alpha = alpha_nlcc(iexp_nlcc)
345 nc = nct_nlcc(iexp_nlcc)
352 ALLOCATE (hab(ni, 1), pab(ni, 1))
355 CALL reallocate(cores, 1, natom)
363 pab(1, 1) = cval_nlcc(1, iexp_nlcc)
366 pab(n, 1) = cval_nlcc(2, iexp_nlcc)/alpha**2
368 pab(n, 1) = cval_nlcc(2, iexp_nlcc)/alpha**2
370 pab(n, 1) = cval_nlcc(2, iexp_nlcc)/alpha**2
373 pab(n, 1) = cval_nlcc(3, iexp_nlcc)/alpha**4
375 pab(n, 1) = cval_nlcc(3, iexp_nlcc)/alpha**4
377 pab(n, 1) = cval_nlcc(3, iexp_nlcc)/alpha**4
379 pab(n, 1) = 2._dp*cval_nlcc(3, iexp_nlcc)/alpha**4
381 pab(n, 1) = 2._dp*cval_nlcc(3, iexp_nlcc)/alpha**4
383 pab(n, 1) = 2._dp*cval_nlcc(3, iexp_nlcc)/alpha**4
386 pab(n, 1) = cval_nlcc(4, iexp_nlcc)/alpha**6
388 pab(n, 1) = cval_nlcc(4, iexp_nlcc)/alpha**6
390 pab(n, 1) = cval_nlcc(4, iexp_nlcc)/alpha**6
392 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
394 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
396 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
398 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
400 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
402 pab(n, 1) = 3._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
404 pab(n, 1) = 6._dp*cval_nlcc(4, iexp_nlcc)/alpha**6
409 IF (dft_control%nspins == 2) pab = pab*0.5_dp
412 atom_a = atom_list(iatom)
413 ra(:) =
pbc(particle_set(atom_a)%r, cell)
414 IF (rs_v%desc%parallel .AND. .NOT. rs_v%desc%distributed)
THEN
416 IF (
modulo(iatom, rs_v%desc%group_size) == rs_v%desc%my_pos)
THEN
429 atom_a = atom_list(iatom)
430 ra(:) =
pbc(particle_set(atom_a)%r, cell)
441 ra=ra, rb=ra, rp=ra, &
442 zetp=1/(2*alpha**2), eps=eps_rho_rspace, &
443 pab=pab, o1=0, o2=0, &
444 prefactor=1.0_dp, cutoff=1.0_dp)
447 0, 0.0_dp, 0, ra, (/0.0_dp, 0.0_dp, 0.0_dp/), &
448 rs_v, hab, pab=pab, o1=0, o2=0, &
450 calculate_forces=.true., force_a=force_a, &
451 force_b=force_b, use_virial=use_virial, my_virial_a=my_virial_a, &
452 my_virial_b=my_virial_b, use_subpatch=.true., subpatch_pattern=0)
454 force(ikind)%gth_nlcc(:, iatom) = &
455 force(ikind)%gth_nlcc(:, iatom) + force_a(:)*rho_rspace%pw_grid%dvol
458 virial%pv_nlcc = virial%pv_nlcc + my_virial_a*rho_rspace%pw_grid%dvol
459 virial%pv_virial = virial%pv_virial + my_virial_a*rho_rspace%pw_grid%dvol
463 DEALLOCATE (hab, pab)
471 CALL timestop(handle)
483 TYPE(pw_r3d_rs_type),
INTENT(IN) :: v_rspace
484 TYPE(qs_environment_type),
POINTER :: qs_env
485 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: atecc
487 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_v_core_rspace'
489 INTEGER :: atom_a, handle, iatom, ikind, j, natom, &
491 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
492 LOGICAL :: paw_atom, skip_fcore, use_virial
493 REAL(kind=
dp) :: alpha_core_charge, ccore_charge, &
494 eps_rho_rspace, radius
495 REAL(kind=
dp),
DIMENSION(3) :: force_a, force_b, ra
496 REAL(kind=
dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
497 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: hab, pab
498 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
499 TYPE(atprop_type),
POINTER :: atprop
500 TYPE(cell_type),
POINTER :: cell
501 TYPE(dft_control_type),
POINTER :: dft_control
502 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
503 TYPE(pw_env_type),
POINTER :: pw_env
504 TYPE(qs_force_type),
DIMENSION(:),
POINTER :: force
505 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
506 TYPE(realspace_grid_type),
POINTER :: rs_v
507 TYPE(virial_type),
POINTER :: virial
509 CALL timeset(routinen, handle)
510 NULLIFY (virial, force, atprop, dft_control)
512 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
516 IF (dft_control%qs_control%gapw)
THEN
517 IF (.NOT. dft_control%qs_control%gapw_control%nopaw_as_gpw) skip_fcore = .true.
520 IF (.NOT. skip_fcore)
THEN
527 CALL pw_env_get(pw_env=pw_env, auxbas_rs_grid=rs_v)
532 atomic_kind_set=atomic_kind_set, &
533 qs_kind_set=qs_kind_set, &
535 dft_control=dft_control, &
536 particle_set=particle_set, &
543 natom =
SIZE(particle_set)
544 IF (
ASSOCIATED(atprop))
THEN
548 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
550 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
552 DO ikind = 1,
SIZE(atomic_kind_set)
554 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom_of_kind, atom_list=atom_list)
555 CALL get_qs_kind(qs_kind_set(ikind), paw_atom=paw_atom, &
556 alpha_core_charge=alpha_core_charge, &
557 ccore_charge=ccore_charge)
559 IF (dft_control%qs_control%gapw .AND. paw_atom) cycle
561 pab(1, 1) = -ccore_charge
562 IF (alpha_core_charge == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
564 CALL reallocate(cores, 1, natom_of_kind)
568 DO iatom = 1, natom_of_kind
569 atom_a = atom_list(iatom)
570 ra(:) =
pbc(particle_set(atom_a)%r, cell)
571 IF (rs_v%desc%parallel .AND. .NOT. rs_v%desc%distributed)
THEN
573 IF (
modulo(iatom, rs_v%desc%group_size) == rs_v%desc%my_pos)
THEN
586 atom_a = atom_list(iatom)
587 ra(:) =
pbc(particle_set(atom_a)%r, cell)
597 ra=ra, rb=ra, rp=ra, &
598 zetp=alpha_core_charge, eps=eps_rho_rspace, &
599 pab=pab, o1=0, o2=0, &
600 prefactor=1.0_dp, cutoff=1.0_dp)
603 0, 0.0_dp, 0, ra, (/0.0_dp, 0.0_dp, 0.0_dp/), &
604 rs_v, hab, pab=pab, o1=0, o2=0, &
606 calculate_forces=.true., force_a=force_a, &
607 force_b=force_b, use_virial=use_virial, my_virial_a=my_virial_a, &
608 my_virial_b=my_virial_b, use_subpatch=.true., subpatch_pattern=0)
610 IF (
ASSOCIATED(force))
THEN
611 force(ikind)%rho_core(:, iatom) = force(ikind)%rho_core(:, iatom) + force_a(:)
614 virial%pv_ehartree = virial%pv_ehartree + my_virial_a
615 virial%pv_virial = virial%pv_virial + my_virial_a
617 IF (
ASSOCIATED(atprop))
THEN
618 atprop%ateb(atom_a) = atprop%ateb(atom_a) + 0.5_dp*hab(1, 1)*pab(1, 1)
620 IF (
PRESENT(atecc))
THEN
621 atecc(atom_a) = atecc(atom_a) + 0.5_dp*hab(1, 1)*pab(1, 1)
628 DEALLOCATE (hab, pab, cores)
632 CALL timestop(handle)
645 TYPE(pw_r3d_rs_type),
INTENT(IN) :: v_rspace
646 TYPE(qs_environment_type),
POINTER :: qs_env
647 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: alpha, ccore
648 REAL(kind=
dp),
DIMENSION(:) :: atecc
650 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_v_gaussian_rspace'
652 INTEGER :: atom_a, handle, iatom, ikind, j, natom, &
654 INTEGER,
DIMENSION(:),
POINTER :: atom_list, cores
655 REAL(kind=
dp) :: alpha_core_charge, eps_rho_rspace, radius
656 REAL(kind=
dp),
DIMENSION(3) :: ra
657 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: hab, pab
658 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
659 TYPE(cell_type),
POINTER :: cell
660 TYPE(dft_control_type),
POINTER :: dft_control
661 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
662 TYPE(pw_env_type),
POINTER :: pw_env
663 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
664 TYPE(realspace_grid_type),
POINTER :: rs_v
666 CALL timeset(routinen, handle)
668 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
671 cpassert(.NOT. dft_control%qs_control%gapw)
679 CALL pw_env_get(pw_env=pw_env, auxbas_rs_grid=rs_v)
684 atomic_kind_set=atomic_kind_set, &
685 qs_kind_set=qs_kind_set, &
687 dft_control=dft_control, &
688 particle_set=particle_set, &
692 natom =
SIZE(particle_set)
693 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
695 DO ikind = 1,
SIZE(atomic_kind_set)
697 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom_of_kind, atom_list=atom_list)
698 pab(1, 1) = -ccore(ikind)
699 alpha_core_charge = alpha(ikind)
700 IF (alpha_core_charge == 0.0_dp .OR. pab(1, 1) == 0.0_dp) cycle
702 CALL reallocate(cores, 1, natom_of_kind)
706 DO iatom = 1, natom_of_kind
707 atom_a = atom_list(iatom)
708 ra(:) =
pbc(particle_set(atom_a)%r, cell)
709 IF (rs_v%desc%parallel .AND. .NOT. rs_v%desc%distributed)
THEN
711 IF (
modulo(iatom, rs_v%desc%group_size) == rs_v%desc%my_pos)
THEN
724 atom_a = atom_list(iatom)
725 ra(:) =
pbc(particle_set(atom_a)%r, cell)
729 ra=ra, rb=ra, rp=ra, &
730 zetp=alpha_core_charge, eps=eps_rho_rspace, &
731 pab=pab, o1=0, o2=0, &
732 prefactor=1.0_dp, cutoff=1.0_dp)
735 0, 0.0_dp, 0, ra, (/0.0_dp, 0.0_dp, 0.0_dp/), &
736 rs_v, hab, pab=pab, o1=0, o2=0, &
737 radius=radius, calculate_forces=.false., &
738 use_subpatch=.true., subpatch_pattern=0)
739 atecc(atom_a) = atecc(atom_a) + 0.5_dp*hab(1, 1)*pab(1, 1)
745 DEALLOCATE (hab, pab, cores)
747 CALL timestop(handle)
762 calculate_forces, basis_type, atomlist)
763 TYPE(pw_r3d_rs_type),
INTENT(IN) :: v_rspace
764 TYPE(qs_environment_type),
POINTER :: qs_env
765 TYPE(lri_kind_type),
DIMENSION(:),
POINTER :: int_res
766 LOGICAL,
INTENT(IN) :: calculate_forces
767 CHARACTER(len=*),
INTENT(IN) :: basis_type
768 INTEGER,
DIMENSION(:),
OPTIONAL :: atomlist
770 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_v_rspace_one_center'
772 INTEGER :: atom_a, group_size, handle, i, iatom, igrid_level, ikind, ipgf, iset, m1, maxco, &
773 maxsgf_set, my_pos, na1, natom_of_kind, ncoa, nkind, nseta, offset, sgfa
774 INTEGER,
DIMENSION(:),
POINTER :: atom_list, la_max, la_min, npgfa, &
776 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
777 LOGICAL :: use_virial
778 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: map_it
779 REAL(kind=
dp) :: eps_rho_rspace, radius
780 REAL(kind=
dp),
DIMENSION(3) :: force_a, force_b, ra
781 REAL(kind=
dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
782 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a
783 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: hab, pab, rpgfa, sphi_a, work_f, work_i, &
785 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
786 TYPE(cell_type),
POINTER :: cell
787 TYPE(dft_control_type),
POINTER :: dft_control
788 TYPE(gridlevel_info_type),
POINTER :: gridlevel_info
789 TYPE(gto_basis_set_type),
POINTER :: lri_basis_set
790 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
791 TYPE(pw_env_type),
POINTER :: pw_env
792 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
793 TYPE(realspace_grid_type),
DIMENSION(:),
POINTER :: rs_v
794 TYPE(realspace_grid_type),
POINTER :: rs_grid
795 TYPE(virial_type),
POINTER :: virial
797 CALL timeset(routinen, handle)
799 NULLIFY (atomic_kind_set, qs_kind_set, atom_list, cell, dft_control, &
800 first_sgfa, gridlevel_info, hab, la_max, la_min, lri_basis_set, &
801 npgfa, nsgf_seta, pab, particle_set, pw_env, rpgfa, &
802 rs_grid, rs_v, virial, set_radius_a, sphi_a, work_f, &
812 gridlevel_info => pw_env%gridlevel_info
817 atomic_kind_set=atomic_kind_set, &
818 qs_kind_set=qs_kind_set, &
820 dft_control=dft_control, &
822 particle_set=particle_set, &
826 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
828 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
831 my_pos = v_rspace%pw_grid%para%my_pos
832 group_size = v_rspace%pw_grid%para%group_size
836 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom_of_kind, atom_list=atom_list)
837 CALL get_qs_kind(qs_kind_set(ikind), basis_set=lri_basis_set, basis_type=basis_type)
839 first_sgf=first_sgfa, &
843 maxsgf_set=maxsgf_set, &
846 nsgf_set=nsgf_seta, &
848 set_radius=set_radius_a, &
852 ALLOCATE (hab(maxco, 1), pab(maxco, 1))
856 DO iatom = 1, natom_of_kind
858 atom_a = atom_list(iatom)
859 IF (
PRESENT(atomlist))
THEN
860 IF (atomlist(atom_a) == 0) cycle
862 ra(:) =
pbc(particle_set(atom_a)%r, cell)
865 my_virial_a(:, :) = 0._dp
866 my_virial_b(:, :) = 0._dp
868 m1 = maxval(npgfa(1:nseta))
869 ALLOCATE (map_it(m1))
874 DO ipgf = 1, npgfa(iset)
876 rs_grid => rs_v(igrid_level)
877 map_it(ipgf) =
map_gaussian_here(rs_grid, cell%h_inv, ra, offset, group_size, my_pos)
881 IF (any(map_it(1:npgfa(iset))))
THEN
882 sgfa = first_sgfa(1, iset)
883 ncoa = npgfa(iset)*
ncoset(la_max(iset))
885 ALLOCATE (work_i(nsgf_seta(iset), 1))
889 IF (calculate_forces)
THEN
890 m1 = sgfa + nsgf_seta(iset) - 1
891 ALLOCATE (work_f(nsgf_seta(iset), 1))
892 work_f(1:nsgf_seta(iset), 1) = int_res(ikind)%acoef(iatom, sgfa:m1)
893 CALL dgemm(
"N",
"N", ncoa, 1, nsgf_seta(iset), 1.0_dp, sphi_a(1, sgfa), &
894 SIZE(sphi_a, 1), work_f(1, 1),
SIZE(work_f, 1), 0.0_dp, pab(1, 1), &
899 DO ipgf = 1, npgfa(iset)
900 na1 = (ipgf - 1)*
ncoset(la_max(iset))
902 rs_grid => rs_v(igrid_level)
905 lb_min=0, lb_max=0, ra=ra, rb=ra, rp=ra, &
906 zetp=zeta(ipgf, iset), eps=eps_rho_rspace, &
907 prefactor=1.0_dp, cutoff=1.0_dp)
909 IF (map_it(ipgf))
THEN
910 IF (.NOT. calculate_forces)
THEN
912 zeta=zeta(ipgf, iset), la_min=la_min(iset), &
913 lb_max=0, zetb=0.0_dp, lb_min=0, &
914 ra=ra, rab=(/0.0_dp, 0.0_dp, 0.0_dp/), &
916 hab=hab, o1=na1, o2=0, radius=radius, &
917 calculate_forces=calculate_forces)
920 zeta=zeta(ipgf, iset), la_min=la_min(iset), &
921 lb_max=0, zetb=0.0_dp, lb_min=0, &
922 ra=ra, rab=(/0.0_dp, 0.0_dp, 0.0_dp/), &
924 hab=hab, pab=pab, o1=na1, o2=0, radius=radius, &
925 calculate_forces=calculate_forces, &
926 force_a=force_a, force_b=force_b, &
927 use_virial=use_virial, &
928 my_virial_a=my_virial_a, my_virial_b=my_virial_b)
933 CALL dgemm(
"T",
"N", nsgf_seta(iset), 1, ncoa, 1.0_dp, sphi_a(1, sgfa), &
934 SIZE(sphi_a, 1), hab(1, 1),
SIZE(hab, 1), 0.0_dp, work_i(1, 1),
SIZE(work_i, 1))
936 int_res(ikind)%v_int(iatom, sgfa:sgfa - 1 + nsgf_seta(iset)) = &
937 int_res(ikind)%v_int(iatom, sgfa:sgfa - 1 + nsgf_seta(iset)) + work_i(1:nsgf_seta(iset), 1)
942 IF (calculate_forces)
THEN
943 int_res(ikind)%v_dfdr(iatom, :) = int_res(ikind)%v_dfdr(iatom, :) + force_a(:)
945 virial%pv_lrigpw = virial%pv_lrigpw + my_virial_a
946 virial%pv_virial = virial%pv_virial + my_virial_a
954 DEALLOCATE (hab, pab)
957 CALL timestop(handle)
973 TYPE(pw_r3d_rs_type),
INTENT(IN) :: v_rspace
974 TYPE(dbcsr_type),
INTENT(INOUT) :: ksmat, pmat
975 TYPE(qs_environment_type),
POINTER :: qs_env
976 LOGICAL,
INTENT(IN) :: calculate_forces
977 CHARACTER(len=*),
INTENT(IN) :: basis_type
979 CHARACTER(len=*),
PARAMETER :: routinen =
'integrate_v_rspace_diagonal'
981 INTEGER :: atom_a, group_size, handle, iatom, igrid_level, ikind, ipgf, iset, jpgf, jset, &
982 m1, maxco, maxsgf_set, my_pos, na1, na2, natom_of_kind, nb1, nb2, ncoa, ncob, nkind, &
983 nseta, nsgfa, offset, sgfa, sgfb
984 INTEGER,
DIMENSION(:),
POINTER :: atom_list, la_max, la_min, npgfa, &
986 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
987 LOGICAL :: found, use_virial
988 LOGICAL,
ALLOCATABLE,
DIMENSION(:, :) :: map_it2
989 REAL(kind=
dp) :: eps_rho_rspace, radius, zetp
990 REAL(kind=
dp),
DIMENSION(3) :: force_a, force_b, ra
991 REAL(kind=
dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
992 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a
993 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: h_block, hab, hmat, p_block, pab, pblk, &
994 rpgfa, sphi_a, work, zeta
995 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
996 TYPE(cell_type),
POINTER :: cell
997 TYPE(dft_control_type),
POINTER :: dft_control
998 TYPE(gridlevel_info_type),
POINTER :: gridlevel_info
999 TYPE(gto_basis_set_type),
POINTER :: orb_basis_set
1000 TYPE(mp_para_env_type),
POINTER :: para_env
1001 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1002 TYPE(pw_env_type),
POINTER :: pw_env
1003 TYPE(qs_force_type),
DIMENSION(:),
POINTER :: force
1004 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1005 TYPE(realspace_grid_type),
DIMENSION(:),
POINTER :: rs_v
1006 TYPE(realspace_grid_type),
POINTER :: rs_grid
1007 TYPE(virial_type),
POINTER :: virial
1009 CALL timeset(routinen, handle)
1011 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
1015 gridlevel_info => pw_env%gridlevel_info
1018 atomic_kind_set=atomic_kind_set, &
1019 qs_kind_set=qs_kind_set, &
1021 dft_control=dft_control, &
1023 particle_set=particle_set, &
1028 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
1029 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
1032 my_pos = v_rspace%pw_grid%para%my_pos
1033 group_size = v_rspace%pw_grid%para%group_size
1037 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom_of_kind, atom_list=atom_list)
1038 CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set, basis_type=basis_type)
1040 lmax=la_max, lmin=la_min, maxco=maxco, maxsgf_set=maxsgf_set, &
1041 npgf=npgfa, nset=nseta, nsgf_set=nsgf_seta, nsgf=nsgfa, &
1042 first_sgf=first_sgfa, pgf_radius=rpgfa, set_radius=set_radius_a, &
1043 sphi=sphi_a, zet=zeta)
1045 ALLOCATE (hab(maxco, maxco), work(maxco, maxsgf_set), hmat(nsgfa, nsgfa))
1046 IF (calculate_forces)
ALLOCATE (pab(maxco, maxco), pblk(nsgfa, nsgfa))
1048 DO iatom = 1, natom_of_kind
1049 atom_a = atom_list(iatom)
1050 ra(:) =
pbc(particle_set(atom_a)%r, cell)
1052 IF (calculate_forces)
THEN
1053 CALL dbcsr_get_block_p(matrix=pmat, row=atom_a, col=atom_a, block=p_block, found=found)
1055 pblk(1:nsgfa, 1:nsgfa) = p_block(1:nsgfa, 1:nsgfa)
1059 CALL para_env%sum(pblk)
1062 IF (use_virial)
THEN
1063 my_virial_a = 0.0_dp
1064 my_virial_b = 0.0_dp
1067 m1 = maxval(npgfa(1:nseta))
1068 ALLOCATE (map_it2(m1, m1))
1070 sgfa = first_sgfa(1, iset)
1071 ncoa = npgfa(iset)*
ncoset(la_max(iset))
1073 sgfb = first_sgfa(1, jset)
1074 ncob = npgfa(jset)*
ncoset(la_max(jset))
1077 DO ipgf = 1, npgfa(iset)
1078 DO jpgf = 1, npgfa(jset)
1079 zetp = zeta(ipgf, iset) + zeta(jpgf, jset)
1081 rs_grid => rs_v(igrid_level)
1082 map_it2(ipgf, jpgf) =
map_gaussian_here(rs_grid, cell%h_inv, ra, offset, group_size, my_pos)
1087 IF (any(map_it2(1:npgfa(iset), 1:npgfa(jset))))
THEN
1089 IF (calculate_forces)
THEN
1090 CALL dgemm(
"N",
"N", ncoa, nsgf_seta(jset), nsgf_seta(iset), &
1091 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
1092 pblk(sgfa, sgfb),
SIZE(pblk, 1), &
1093 0.0_dp, work(1, 1),
SIZE(work, 1))
1094 CALL dgemm(
"N",
"T", ncoa, ncob, nsgf_seta(jset), &
1095 1.0_dp, work(1, 1),
SIZE(work, 1), &
1096 sphi_a(1, sgfb),
SIZE(sphi_a, 1), &
1097 0.0_dp, pab(1, 1),
SIZE(pab, 1))
1100 DO ipgf = 1, npgfa(iset)
1101 na1 = (ipgf - 1)*
ncoset(la_max(iset))
1102 na2 = ipgf*
ncoset(la_max(iset))
1103 DO jpgf = 1, npgfa(jset)
1104 nb1 = (jpgf - 1)*
ncoset(la_max(jset))
1105 nb2 = jpgf*
ncoset(la_max(jset))
1106 zetp = zeta(ipgf, iset) + zeta(jpgf, jset)
1108 rs_grid => rs_v(igrid_level)
1111 lb_min=la_min(jset), lb_max=la_max(jset), &
1112 ra=ra, rb=ra, rp=ra, &
1113 zetp=zetp, eps=eps_rho_rspace, &
1114 prefactor=1.0_dp, cutoff=1.0_dp)
1116 IF (map_it2(ipgf, jpgf))
THEN
1117 IF (calculate_forces)
THEN
1119 la_max(iset), zeta(ipgf, iset), la_min(iset), &
1120 la_max(jset), zeta(jpgf, jset), la_min(jset), &
1121 ra=ra, rab=(/0.0_dp, 0.0_dp, 0.0_dp/), &
1122 rsgrid=rs_v(igrid_level), &
1123 hab=hab, pab=pab, o1=na1, o2=nb1, &
1125 calculate_forces=.true., &
1126 force_a=force_a, force_b=force_b, &
1127 use_virial=use_virial, my_virial_a=my_virial_a, my_virial_b=my_virial_b)
1130 la_max(iset), zeta(ipgf, iset), la_min(iset), &
1131 la_max(jset), zeta(jpgf, jset), la_min(jset), &
1132 ra=ra, rab=(/0.0_dp, 0.0_dp, 0.0_dp/), &
1133 rsgrid=rs_v(igrid_level), &
1134 hab=hab, o1=na1, o2=nb1, &
1136 calculate_forces=.false.)
1142 CALL dgemm(
"N",
"N", ncoa, nsgf_seta(jset), ncob, &
1143 1.0_dp, hab(1, 1),
SIZE(hab, 1), &
1144 sphi_a(1, sgfb),
SIZE(sphi_a, 1), &
1145 0.0_dp, work(1, 1),
SIZE(work, 1))
1146 CALL dgemm(
"T",
"N", nsgf_seta(iset), nsgf_seta(jset), ncoa, &
1147 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
1148 work(1, 1),
SIZE(work, 1), &
1149 1.0_dp, hmat(sgfa, sgfb),
SIZE(hmat, 1))
1153 DEALLOCATE (map_it2)
1155 CALL para_env%sum(hmat)
1156 CALL dbcsr_get_block_p(matrix=ksmat, row=atom_a, col=atom_a, block=h_block, found=found)
1158 h_block(1:nsgfa, 1:nsgfa) = h_block(1:nsgfa, 1:nsgfa) + hmat(1:nsgfa, 1:nsgfa)
1160 IF (calculate_forces)
THEN
1161 force(ikind)%rho_elec(:, iatom) = force(ikind)%rho_elec(:, iatom) + 2.0_dp*force_a(:)
1162 IF (use_virial)
THEN
1163 IF (use_virial .AND. calculate_forces)
THEN
1164 virial%pv_lrigpw = virial%pv_lrigpw + 2.0_dp*my_virial_a
1165 virial%pv_virial = virial%pv_virial + 2.0_dp*my_virial_a
1170 DEALLOCATE (hab, work, hmat)
1171 IF (calculate_forces)
DEALLOCATE (pab, pblk)
1174 CALL timestop(handle)
subroutine pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
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.
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(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.
Holds information on atomic properties.
subroutine, public atprop_array_init(atarray, natom)
...
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)
...
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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.
subroutine, public integrate_pgf_product(la_max, zeta, la_min, lb_max, zetb, lb_min, ra, rab, rsgrid, hab, pab, o1, o2, radius, calculate_forces, force_a, force_b, compute_tau, use_virial, my_virial_a, my_virial_b, hdab, hadb, a_hdab, use_subpatch, subpatch_pattern)
low level function to compute matrix elements of primitive gaussian functions
Defines the basic variable types.
integer, parameter, public dp
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
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_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, 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, rhs)
Get the QUICKSTEP environment.
Build up the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public integrate_v_gaussian_rspace(v_rspace, qs_env, alpha, ccore, atecc)
computes the overlap of a set of Gaussians with a potential on grid
subroutine, public integrate_v_rspace_diagonal(v_rspace, ksmat, pmat, qs_env, calculate_forces, basis_type)
computes integrals of product of v_rspace times the diagonal block basis functions required for LRIGP...
subroutine, public integrate_v_core_rspace(v_rspace, qs_env, atecc)
computes the forces/virial due to the ionic cores with a potential on grid
subroutine, public integrate_v_rspace_one_center(v_rspace, qs_env, int_res, calculate_forces, basis_type, atomlist)
computes integrals of product of v_rspace times a one-center function required for LRIGPW
subroutine, public integrate_ppl_rspace(rho_rspace, qs_env)
computes the forces/virial due to the local pseudopotential
subroutine, public integrate_rho_nlcc(rho_rspace, qs_env)
computes the forces/virial due to the nlcc pseudopotential
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, 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_r3d_rs_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_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public transfer_pw2rs(rs, pw)
...
pure logical function, public map_gaussian_here(rs_grid, h_inv, ra, offset, group_size, my_pos)
...
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 potential_pw2rs(rs_v, v_rspace, pw_env)
transfers a potential from a pw_grid to a vector of realspace multigrids