68#include "./base/base_uses.f90"
74 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .false.
76 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'accint_weights_forces'
95 INTEGER,
INTENT(IN) :: order
97 LOGICAL,
INTENT(IN),
OPTIONAL :: triplet
98 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: force_scale
100 CHARACTER(len=*),
PARAMETER :: routinen =
'accint_weight_force'
102 INTEGER :: atom_a, handle, i, iatom, ikind, natom, &
103 natom_of_kind, nkind, ounit, oweight
104 INTEGER,
DIMENSION(:),
POINTER :: atom_list
105 LOGICAL :: composite_reference, lr_triplet, &
106 native_grid_diagnostics, &
107 native_skala_grid, uf_grid, use_virial
108 REAL(kind=
dp) :: my_force_scale
109 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: calpha, cvalue
110 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: aforce
111 REAL(kind=
dp),
DIMENSION(3) :: tforce
112 REAL(kind=
dp),
DIMENSION(3, 3) :: avirial
117 TYPE(
pw_pool_type),
POINTER :: auxbas_pw_pool, xc_pw_pool
120 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
124 CALL timeset(routinen, handle)
126 CALL get_qs_env(qs_env, dft_control=dft_control, qs_kind_set=qs_kind_set)
133 IF (.NOT. composite_reference)
THEN
141 IF (composite_reference)
THEN
142 CALL timestop(handle)
146 IF (dft_control%qs_control%gapw_control%accurate_xcint)
THEN
148 CALL get_qs_env(qs_env=qs_env, force=force, virial=virial)
149 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
153 CALL get_qs_env(qs_env, natom=natom, nkind=nkind)
154 ALLOCATE (aforce(3, natom))
155 ALLOCATE (calpha(nkind), cvalue(nkind))
157 calpha(1:nkind) = dft_control%qs_control%gapw_control%aw(1:nkind)
158 oweight = dft_control%qs_control%gapw_control%oweights
160 CALL get_qs_env(qs_env, ks_env=ks_env, pw_env=pw_env)
161 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, xc_pw_pool=xc_pw_pool)
162 uf_grid = .NOT.
pw_grid_compare(auxbas_pw_pool%pw_grid, xc_pw_pool%pw_grid)
164 CALL xc_pw_pool%create_pw(e_rspace)
166 CALL auxbas_pw_pool%create_pw(e_rspace)
170 IF (
PRESENT(triplet)) lr_triplet = triplet
171 my_force_scale = 1.0_dp
172 IF (
PRESENT(force_scale)) my_force_scale = force_scale
174 CALL xc_density(qs_env, rho, rho1, order, xc_section, lr_triplet, e_rspace)
177 CALL auxbas_pw_pool%create_pw(e_force_rspace)
180 CALL xc_pw_pool%create_pw(e_g_xc)
181 CALL auxbas_pw_pool%create_pw(e_g_aux)
185 CALL auxbas_pw_pool%give_back_pw(e_g_aux)
186 CALL xc_pw_pool%give_back_pw(e_g_xc)
188 CALL pw_scale(e_force_rspace, e_force_rspace%pw_grid%dvol)
190 CALL gauss_grid_force(e_force_rspace, qs_env, oweight, calpha, cvalue, aforce, avirial)
192 CALL auxbas_pw_pool%give_back_pw(e_force_rspace)
194 CALL pw_scale(e_rspace, e_rspace%pw_grid%dvol)
195 CALL gauss_grid_force(e_rspace, qs_env, oweight, calpha, cvalue, aforce, avirial)
199 CALL xc_pw_pool%give_back_pw(e_rspace)
201 CALL auxbas_pw_pool%give_back_pw(e_rspace)
204 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set)
206 native_grid_diagnostics = .false.
207 IF (native_skala_grid)
THEN
209 l_val=native_grid_diagnostics)
212 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom_of_kind, atom_list=atom_list)
213 DO iatom = 1, natom_of_kind
214 atom_a = atom_list(iatom)
215 IF (native_grid_diagnostics)
THEN
217 WRITE (unit=ounit, fmt=
"(T2,A,1X,I0,3(1X,ES20.12))") &
218 "SKALA_GPW| Accurate-XCINT atom force", atom_a, my_force_scale*aforce(:, atom_a)
221 force(ikind)%rho_elec(1:3, iatom) = &
222 force(ikind)%rho_elec(1:3, iatom) + my_force_scale*aforce(1:3, atom_a)
226 virial%pv_exc = virial%pv_exc + my_force_scale*avirial
227 virial%pv_virial = virial%pv_virial + my_force_scale*avirial
230 IF (debug_this_module)
THEN
232 CALL para_env%sum(aforce)
234 WRITE (unit=ounit, fmt=
"(/,T2,A)")
"ACCINT| Debug Accurate-XCINT atom force [a.u.]"
236 tforce(i) = my_force_scale*sum(aforce(i, :))
239 WRITE (unit=ounit, fmt=
"(T2,A,1X,I0,T24,3(1X,F18.12))") &
240 "ACCINT| ", iatom, my_force_scale*aforce(1:3, iatom)
242 WRITE (unit=ounit, fmt=
"(T2,A,T24,3(1X,F18.12))") &
243 "ACCINT| Total force ", tforce(1:3)
246 CALL para_env%sum(avirial)
248 WRITE (unit=ounit, fmt=
"(/,T2,A)")
"ACCINT| Debug Accurate-XCINT virial"
250 WRITE (unit=ounit, fmt=
"(T2,A,T24,3(1X,F18.8))") &
251 "ACCINT| [a.u.] ", my_force_scale*avirial(i, 1:3)
257 DEALLOCATE (aforce, calpha, cvalue)
261 CALL timestop(handle)
275 SUBROUTINE gauss_grid_force(e_rspace, qs_env, order, calpha, cvalue, aforce, avirial)
276 TYPE(pw_r3d_rs_type),
INTENT(IN) :: e_rspace
277 TYPE(qs_environment_type),
POINTER :: qs_env
278 INTEGER,
INTENT(IN) :: order
279 REAL(kind=dp),
DIMENSION(:),
INTENT(IN) :: calpha, cvalue
280 REAL(kind=dp),
DIMENSION(:, :),
INTENT(OUT) :: aforce
281 REAL(kind=dp),
DIMENSION(3, 3),
INTENT(OUT) :: avirial
283 CHARACTER(len=*),
PARAMETER :: routinen =
'gauss_grid_force'
285 INTEGER :: atom_a, handle, iatom, igrid, ikind, j, &
286 natom_of_kind, ni, npme, on
287 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cores
288 INTEGER,
DIMENSION(:),
POINTER :: atom_list
289 LOGICAL :: use_virial
290 REAL(kind=dp) :: alpha, eps_rho_rspace, radius
291 REAL(kind=dp),
DIMENSION(3) :: force_a, force_b, ra
292 REAL(kind=dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
293 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: hab, pab
294 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
295 TYPE(cell_type),
POINTER :: cell
296 TYPE(dft_control_type),
POINTER :: dft_control
297 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
298 TYPE(pw_env_type),
POINTER :: pw_env
299 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: pw_pools
300 TYPE(realspace_grid_type),
DIMENSION(:),
POINTER :: rs_grids
301 TYPE(realspace_grid_type),
POINTER :: rs_v
303 CALL timeset(routinen, handle)
307 ALLOCATE (hab(ni, 1))
308 ALLOCATE (pab(ni, 1))
310 NULLIFY (pw_pools, rs_grids, rs_v)
312 CALL get_qs_env(qs_env, pw_env=pw_env)
313 CALL pw_env_get(pw_env, pw_pools=pw_pools, rs_grids=rs_grids)
314 DO igrid = 1,
SIZE(pw_pools)
315 IF (pw_grid_compare(e_rspace%pw_grid, pw_pools(igrid)%pool%pw_grid))
THEN
316 rs_v => rs_grids(igrid)
320 IF (.NOT.
ASSOCIATED(rs_v))
THEN
321 cpabort(
"No realspace grid for Accurate-XCINT weight force")
324 CALL transfer_pw2rs(rs_v, e_rspace)
326 CALL get_qs_env(qs_env, &
327 atomic_kind_set=atomic_kind_set, &
329 dft_control=dft_control, &
330 particle_set=particle_set)
336 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
338 DO ikind = 1,
SIZE(atomic_kind_set)
340 alpha = calpha(ikind)
341 IF (alpha == 0.0_dp) cycle
343 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom_of_kind, atom_list=atom_list)
345 CALL set_polynom_coefs(pab(:, 1), order, alpha)
346 pab(:, 1) = -cvalue(ikind)*pab(:, 1)
348 ALLOCATE (cores(natom_of_kind))
352 DO iatom = 1, natom_of_kind
353 atom_a = atom_list(iatom)
354 ra(:) = pbc(particle_set(atom_a)%r, cell)
355 IF (rs_v%desc%parallel .AND. .NOT. rs_v%desc%distributed)
THEN
357 IF (
modulo(iatom, rs_v%desc%group_size) == rs_v%desc%my_pos)
THEN
370 atom_a = atom_list(iatom)
371 ra(:) = pbc(particle_set(atom_a)%r, cell)
378 radius = exp_radius_very_extended(la_min=0, la_max=on, lb_min=0, lb_max=0, &
379 ra=ra, rb=ra, rp=ra, &
380 zetp=alpha, eps=eps_rho_rspace, &
381 pab=pab, o1=0, o2=0, &
382 prefactor=1.0_dp, cutoff=1.0_dp)
384 CALL integrate_pgf_product(on, alpha, 0, &
385 0, 0.0_dp, 0, ra, [0.0_dp, 0.0_dp, 0.0_dp], &
386 rs_v, hab, pab=pab, o1=0, o2=0, &
388 calculate_forces=.true., force_a=force_a, &
389 force_b=force_b, use_virial=use_virial, my_virial_a=my_virial_a, &
390 my_virial_b=my_virial_b, use_subpatch=.true., subpatch_pattern=0)
392 aforce(1:3, atom_a) = aforce(1:3, atom_a) + force_a(1:3)
393 avirial = avirial + my_virial_a
400 DEALLOCATE (hab, pab)
402 CALL timestop(handle)
404 END SUBROUTINE gauss_grid_force
415 TYPE(pw_r3d_rs_type),
INTENT(INOUT) :: rho_core
416 TYPE(qs_environment_type),
POINTER :: qs_env
417 INTEGER,
INTENT(IN) :: order
418 REAL(kind=dp),
DIMENSION(:) :: calpha, ccore
420 CHARACTER(len=*),
PARAMETER :: routinen =
'weight_function_pwgrid'
422 INTEGER :: atom_a, handle, iatom, ikind, ithread, &
423 j, natom, ni, npme, nthread, on, &
425 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cores
426 INTEGER,
DIMENSION(:),
POINTER :: atom_list
427 REAL(kind=dp) :: alpha, eps_rho_rspace, radius
428 REAL(kind=dp),
DIMENSION(3) :: ra
429 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: pab
430 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
431 TYPE(cell_type),
POINTER :: cell
432 TYPE(dft_control_type),
POINTER :: dft_control
433 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
434 TYPE(pw_env_type),
POINTER :: pw_env
435 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
436 TYPE(pw_r3d_rs_type) :: rhoc_r
437 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
438 TYPE(realspace_grid_type),
POINTER :: rs_rho
440 CALL timeset(routinen, handle)
444 ALLOCATE (pab(ni, 1))
446 CALL get_qs_env(qs_env=qs_env, &
447 atomic_kind_set=atomic_kind_set, &
448 qs_kind_set=qs_kind_set, &
450 dft_control=dft_control, &
451 particle_set=particle_set, &
453 CALL pw_env_get(pw_env, auxbas_rs_grid=rs_rho, &
454 auxbas_pw_pool=auxbas_pw_pool)
456 CALL rs_grid_zero(rs_rho)
458 eps_rho_rspace = dft_control%qs_control%eps_rho_rspace
460 DO ikind = 1,
SIZE(atomic_kind_set)
461 alpha = calpha(ikind)
462 IF (alpha == 0.0_dp) cycle
464 CALL get_atomic_kind(atomic_kind_set(ikind), natom=natom, atom_list=atom_list)
466 CALL set_polynom_coefs(pab(:, 1), order, alpha)
467 pab(:, 1) = ccore(ikind)*pab(:, 1)
472 ALLOCATE (cores(natom))
477 IF (rs_rho%desc%parallel .AND. .NOT. rs_rho%desc%distributed)
THEN
479 IF (
modulo(iatom, rs_rho%desc%group_size) == rs_rho%desc%my_pos)
THEN
493 atom_a = atom_list(iatom)
494 ra(:) = pbc(particle_set(atom_a)%r, cell)
496 radius = exp_radius_very_extended(la_min=0, la_max=on, &
497 lb_min=0, lb_max=0, &
498 ra=ra, rb=ra, rp=ra, &
499 zetp=alpha, eps=eps_rho_rspace, &
500 pab=pab, o1=0, o2=0, &
501 prefactor=-1.0_dp, cutoff=0.0_dp)
503 CALL collocate_pgf_product(on, alpha, 0, 0, 0.0_dp, 0, ra, &
504 [0.0_dp, 0.0_dp, 0.0_dp], -1.0_dp, pab, 0, 0, rs_rho, &
505 radius=radius, ga_gb_function=grid_func_ab, &
506 use_subpatch=.true., subpatch_pattern=subpatch_pattern)
516 CALL auxbas_pw_pool%create_pw(rhoc_r)
518 CALL transfer_rs2pw(rs_rho, rhoc_r)
520 CALL pw_transfer(rhoc_r, rho_core)
522 CALL auxbas_pw_pool%give_back_pw(rhoc_r)
524 CALL timestop(handle)
535 SUBROUTINE set_polynom_coefs(pf, order, alpha)
536 REAL(kind=dp),
DIMENSION(:),
INTENT(OUT) :: pf
537 INTEGER,
INTENT(IN) :: order
538 REAL(kind=dp),
INTENT(IN) :: alpha
551 pf(
coset(2, 0, 0)) = ap
552 pf(
coset(0, 2, 0)) = ap
553 pf(
coset(0, 0, 2)) = ap
556 pf(
coset(4, 0, 0)) = ap
557 pf(
coset(0, 4, 0)) = ap
558 pf(
coset(0, 0, 4)) = ap
559 pf(
coset(2, 2, 0)) = 2._dp*ap
560 pf(
coset(2, 0, 2)) = 2._dp*ap
561 pf(
coset(0, 2, 2)) = 2._dp*ap
564 pf(
coset(6, 0, 0)) = ap
565 pf(
coset(0, 6, 0)) = ap
566 pf(
coset(0, 0, 6)) = ap
567 pf(
coset(4, 2, 0)) = 3._dp*ap
568 pf(
coset(4, 0, 2)) = 3._dp*ap
569 pf(
coset(2, 4, 0)) = 3._dp*ap
570 pf(
coset(2, 0, 4)) = 3._dp*ap
571 pf(
coset(0, 4, 2)) = 3._dp*ap
572 pf(
coset(0, 2, 4)) = 3._dp*ap
573 pf(
coset(2, 2, 2)) = 6._dp*ap
575 CALL cp_abort(__location__, &
576 "Only 0, 1, 2, 3 are supported as the "// &
577 "polynomial order value in accuarte XC integration.")
581 END SUBROUTINE set_polynom_coefs
600 SUBROUTINE xc_density(qs_env, rho_struct, rho1_struct, order, xc_section, triplet, exc)
602 TYPE(qs_environment_type),
POINTER :: qs_env
603 TYPE(qs_rho_type),
POINTER :: rho_struct, rho1_struct
604 INTEGER,
INTENT(IN) :: order
605 TYPE(section_vals_type),
POINTER :: xc_section
606 LOGICAL,
INTENT(IN) :: triplet
607 TYPE(pw_r3d_rs_type) :: exc
609 CHARACTER(len=*),
PARAMETER :: routinen =
'xc_density'
611 INTEGER :: handle, ispin, myfun, nspins
612 LOGICAL :: native_skala_grid, rho1_g_valid, &
613 rho_g_valid, tau1_valid, tau_valid, &
615 REAL(kind=dp) :: excint, factor
616 REAL(kind=dp),
DIMENSION(3, 3) :: vdum
617 TYPE(cell_type),
POINTER :: cell
618 TYPE(dft_control_type),
POINTER :: dft_control
619 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
620 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho1_g, rho1_g_xc, rho_g, rho_g_xc
621 TYPE(pw_c1d_gs_type),
POINTER :: rho_nlcc_g
622 TYPE(pw_env_type),
POINTER :: pw_env
623 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool, xc_pw_pool
624 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho1_r, rho1_r_xc, rho_r, rho_r_xc, &
625 tau1_r, tau1_r_xc, tau_r, tau_r_xc, &
627 TYPE(pw_r3d_rs_type),
POINTER :: rho_nlcc, weights
628 TYPE(rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set, rho1_atom_set
630 CALL timeset(routinen, handle)
632 cpassert(
ASSOCIATED(rho_struct))
634 cpassert(
ASSOCIATED(rho1_struct))
638 CALL get_qs_env(qs_env, &
639 dft_control=dft_control, &
642 particle_set=particle_set, &
644 rho_nlcc_g=rho_nlcc_g)
646 nspins = dft_control%nspins
647 cpassert(dft_control%sic_method_id == sic_none)
649 CALL section_vals_val_get(xc_section,
"XC_FUNCTIONAL%_SECTION_PARAMETERS_", i_val=myfun)
650 native_skala_grid = xc_section_uses_native_skala_grid(xc_section)
654 IF (myfun /= xc_none)
THEN
657 NULLIFY (rho_r, rho_g, tau_r)
658 CALL qs_rho_get(rho_struct, rho_r=rho_r, rho_g=rho_g, tau_r=tau_r, &
659 rho_g_valid=rho_g_valid, tau_r_valid=tau_valid)
661 CALL pw_env_get(pw_env, xc_pw_pool=xc_pw_pool, auxbas_pw_pool=auxbas_pw_pool)
662 uf_grid = .NOT. pw_grid_compare(auxbas_pw_pool%pw_grid, xc_pw_pool%pw_grid)
665 IF (
ASSOCIATED(rho_nlcc) .AND. order <= 1)
THEN
668 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
669 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
673 NULLIFY (rho_r_xc, rho_g_xc, tau_r_xc)
674 IF (uf_grid .AND. order <= 1)
THEN
675 IF (rho_g_valid)
THEN
676 CALL create_density_on_pool(xc_pw_pool, rho_g, rho_r_xc, rho_g_xc)
678 CALL create_density_on_pool_from_r(auxbas_pw_pool, xc_pw_pool, rho_r, rho_r_xc, rho_g_xc)
681 CALL create_density_on_pool_from_r(auxbas_pw_pool, xc_pw_pool, tau_r, tau_r_xc)
689 NULLIFY (rho1_r_xc, rho1_g_xc, tau1_r_xc)
691 CALL qs_rho_get(rho1_struct, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r, &
692 rho_g_valid=rho1_g_valid, tau_r_valid=tau1_valid)
694 IF (rho1_g_valid)
THEN
695 CALL create_density_on_pool(xc_pw_pool, rho1_g, rho1_r_xc, rho1_g_xc)
697 CALL create_density_on_pool_from_r(auxbas_pw_pool, xc_pw_pool, rho1_r, rho1_r_xc, rho1_g_xc)
700 CALL create_density_on_pool_from_r(auxbas_pw_pool, xc_pw_pool, tau1_r, tau1_r_xc)
709 NULLIFY (vxc_rho, vxc_tau)
712 IF (native_skala_grid)
THEN
713 CALL skala_gpw_weight_derivative(exc, rho_r, rho_g, tau_r, xc_section, weights, &
714 xc_pw_pool, particle_set, cell)
716 CALL xc_exc_pw_create(rho_r_xc, rho_g_xc, tau_r_xc, xc_section, weights, xc_pw_pool, exc)
719 IF (native_skala_grid)
THEN
720 CALL cp_abort(__location__, &
721 "Native SKALA GAPW accurate-XCINT response forces are not implemented.")
723 CALL xc_vxc_pw_create(vxc_rho, vxc_tau, exc=excint, &
724 rho_r=rho_r_xc, rho_g=rho_g_xc, tau=tau_r_xc, &
725 xc_section=xc_section, weights=weights, pw_pool=xc_pw_pool, &
726 compute_virial=.false., virial_xc=vdum)
729 IF (native_skala_grid)
THEN
730 CALL cp_abort(__location__, &
731 "Native SKALA GAPW accurate-XCINT response forces are not implemented.")
733 CALL qs_fxc_create(qs_env, rho_struct, rho1_struct, rho0_atom_set, xc_section, .false., &
734 vxc_rho, vxc_tau, rho1_atom_set, is_triplet=triplet, &
735 no_weights=.true., uf_grid_results=uf_grid)
738 cpabort(
"Derivative order not available in xc_density")
743 IF (
ASSOCIATED(vxc_rho))
THEN
745 CALL pw_multiply_with(vxc_rho(ispin), rho1_r_xc(ispin))
746 CALL pw_axpy(vxc_rho(ispin), exc, 1.0_dp)
747 CALL vxc_rho(ispin)%release()
751 IF (
ASSOCIATED(vxc_tau))
THEN
753 CALL pw_multiply_with(vxc_tau(ispin), tau1_r_xc(ispin))
754 CALL pw_axpy(vxc_tau(ispin), exc, 1.0_dp)
755 CALL vxc_tau(ispin)%release()
762 CALL pw_scale(exc, 0.5_dp)
765 IF (uf_grid .AND. order <= 1)
THEN
766 CALL give_back_density_on_pool(xc_pw_pool, rho_r_xc, rho_g_xc)
768 CALL give_back_density_on_pool(xc_pw_pool, tau_r_xc)
772 IF (uf_grid .AND. order >= 1)
THEN
773 CALL give_back_density_on_pool(xc_pw_pool, rho1_r_xc, rho1_g_xc)
775 CALL give_back_density_on_pool(xc_pw_pool, tau1_r_xc)
780 IF (
ASSOCIATED(rho_nlcc) .AND. order <= 1)
THEN
783 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
784 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
790 CALL timestop(handle)
792 END SUBROUTINE xc_density
800 SUBROUTINE create_density_on_pool(pw_pool, rho_g_in, rho_r_out, rho_g_out)
801 TYPE(pw_pool_type),
POINTER :: pw_pool
802 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g_in
803 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r_out
804 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g_out
806 INTEGER :: ispin, nspins
808 cpassert(
ASSOCIATED(pw_pool))
809 cpassert(
ASSOCIATED(rho_g_in))
811 nspins =
SIZE(rho_g_in)
812 ALLOCATE (rho_r_out(nspins), rho_g_out(nspins))
814 CALL pw_pool%create_pw(rho_g_out(ispin))
815 CALL pw_pool%create_pw(rho_r_out(ispin))
816 CALL pw_transfer(rho_g_in(ispin), rho_g_out(ispin))
817 CALL pw_transfer(rho_g_out(ispin), rho_r_out(ispin))
820 END SUBROUTINE create_density_on_pool
830 SUBROUTINE create_density_on_pool_from_r(source_pw_pool, target_pw_pool, rho_r_in, rho_r_out, rho_g_out)
831 TYPE(pw_pool_type),
POINTER :: source_pw_pool, target_pw_pool
832 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r_in, rho_r_out
833 TYPE(pw_c1d_gs_type),
DIMENSION(:),
OPTIONAL, &
836 INTEGER :: ispin, nspins
837 TYPE(pw_c1d_gs_type) :: rho_g_aux, rho_g_in
839 cpassert(
ASSOCIATED(source_pw_pool))
840 cpassert(
ASSOCIATED(target_pw_pool))
841 cpassert(
ASSOCIATED(rho_r_in))
843 nspins =
SIZE(rho_r_in)
844 IF (
PRESENT(rho_g_out))
THEN
845 ALLOCATE (rho_r_out(nspins), rho_g_out(nspins))
847 CALL source_pw_pool%create_pw(rho_g_in)
848 CALL target_pw_pool%create_pw(rho_g_out(ispin))
849 CALL target_pw_pool%create_pw(rho_r_out(ispin))
850 CALL pw_transfer(rho_r_in(ispin), rho_g_in)
851 CALL pw_transfer(rho_g_in, rho_g_out(ispin))
852 CALL pw_transfer(rho_g_out(ispin), rho_r_out(ispin))
853 CALL source_pw_pool%give_back_pw(rho_g_in)
856 ALLOCATE (rho_r_out(nspins))
858 CALL source_pw_pool%create_pw(rho_g_in)
859 CALL target_pw_pool%create_pw(rho_g_aux)
860 CALL target_pw_pool%create_pw(rho_r_out(ispin))
861 CALL pw_transfer(rho_r_in(ispin), rho_g_in)
862 CALL pw_transfer(rho_g_in, rho_g_aux)
863 CALL pw_transfer(rho_g_aux, rho_r_out(ispin))
864 CALL source_pw_pool%give_back_pw(rho_g_in)
865 CALL source_pw_pool%give_back_pw(rho_g_aux)
869 END SUBROUTINE create_density_on_pool_from_r
877 SUBROUTINE give_back_density_on_pool(pw_pool, rho_r, rho_g)
878 TYPE(pw_pool_type),
POINTER :: pw_pool
879 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r
880 TYPE(pw_c1d_gs_type),
DIMENSION(:),
OPTIONAL, &
885 cpassert(
ASSOCIATED(pw_pool))
887 IF (
ASSOCIATED(rho_r))
THEN
888 DO ispin = 1,
SIZE(rho_r)
889 CALL pw_pool%give_back_pw(rho_r(ispin))
893 IF (
PRESENT(rho_g))
THEN
894 IF (
ASSOCIATED(rho_g))
THEN
895 DO ispin = 1,
SIZE(rho_g)
896 CALL pw_pool%give_back_pw(rho_g(ispin))
902 END SUBROUTINE give_back_density_on_pool
static GRID_HOST_DEVICE int coset(int lx, int ly, int lz)
Maps three angular momentum components to a single zero based index.
static GRID_HOST_DEVICE int ncoset(const int l)
Number of Cartesian orbitals up to given angular momentum quantum.
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
subroutine, public weight_function_pwgrid(rho_core, qs_env, order, calpha, ccore)
computes the weight function on the PW grid
subroutine, public accint_weight_force(qs_env, rho, rho1, order, xc_section, triplet, force_scale)
...
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.
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
Fortran API for the grid package, which is written in C.
integer, parameter, public grid_func_ab
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
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
Defines the basic variable types.
integer, parameter, public dp
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
This module defines the grid data type and some basic operations on it.
logical function, public pw_grid_compare(grida, gridb)
Check if two pw_grids are equal.
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Setup Routine for Fxc Potentials.
subroutine, public qs_fxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, do_onecenter, fxc_rho, fxc_tau, rho1_atom_set, do_scale, is_triplet, spinflip, no_weights, uf_grid_results, pw_env_ext, kind_set_external, para_env_external, dispersion_env, compute_virial, virial_xc)
...
Define the quickstep kind type and their sub types.
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
subroutine, public transfer_pw2rs(rs, pw)
...
subroutine, public transfer_rs2pw(rs, pw)
...
subroutine, public rs_grid_zero(rs)
Initialize grid to zero.
Experimental CP2K-native GPW real-space-grid path for SKALA TorchScript models.
subroutine, public skala_gpw_weight_derivative(weight_deriv_r, rho_r, rho_g, tau, xc_section, weights, pw_pool, particle_set, cell)
Evaluate the derivative of native SKALA XC energy with respect to CP2K's external real-space integrat...
logical function, public native_skala_uses_atom_composite_grid(xc_section)
Return true when native Skala uses atom-centered grids.
integer function, public skala_gapw_representation(xc_section)
Return the pseudopotential GAPW representation selected for an active model.
logical function, public native_skala_gapw_atom_composite_requested(xc_section)
Return true when the explicit atom-centered composite reference is requested.
logical function, public native_skala_gapw_composite_reference(xc_section)
Return true if native SKALA should use the full GAPW ORB density on one common grid.
logical function, public xc_section_uses_native_skala_grid(xc_section)
Return true if the GAUXC subsection requests the CP2K-native GPW grid path.
logical function, public gauxc_gapw_has_paw_pseudopotentials(qs_kind_set)
Return whether GauXC GAPW mode sees pseudopotential one-center GAPW kinds.
Exchange and Correlation functional calculations.
subroutine, public xc_vxc_pw_create(vxc_rho, vxc_tau, exc, rho_r, rho_g, tau, xc_section, weights, pw_pool, compute_virial, virial_xc, exc_r)
Exchange and Correlation functional calculations.
subroutine, public xc_exc_pw_create(rho_r, rho_g, tau, xc_section, weights, pw_pool, exc)
calculates just the exchange and correlation energy density
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
stores all the informations relevant to an mpi environment
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 ...
keeps the density in various representations, keeping track of which ones are valid.