21 USE dbcsr_api,
ONLY: dbcsr_p_type,&
73#include "./base/base_uses.f90"
79 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'mp2_eri_gpw'
108 pw_env_sub, external_vector, poisson_env, rho_r, pot_g, &
109 potential_parameter, mat_munu, qs_env, task_list_sub)
115 POINTER :: atomic_kind_set
117 POINTER :: qs_kind_set
118 TYPE(
cell_type),
INTENT(IN),
POINTER :: cell
121 POINTER :: particle_set
122 TYPE(
pw_env_type),
INTENT(IN),
POINTER :: pw_env_sub
123 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: external_vector
128 TYPE(dbcsr_p_type),
INTENT(INOUT) :: mat_munu
132 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mp2_eri_3c_integrate_gpw'
136 CALL timeset(routinen, handle)
140 qs_kind_set, cell, dft_control, particle_set, pw_env_sub, &
141 basis_type=
"RI_AUX", &
142 external_vector=external_vector)
147 CALL dbcsr_set(mat_munu%matrix, 0.0_dp)
148 CALL integrate_v_rspace(rho_r, hmat=mat_munu, qs_env=qs_env, &
149 calculate_forces=.false., compute_tau=.false., gapw=.false., &
150 pw_env_external=pw_env_sub, task_list_external=task_list_sub)
152 CALL timestop(handle)
169 natom, potential_parameter, sab_orb_sub, L_local_col, kind_of)
173 INTEGER,
INTENT(IN) :: my_group_l_start, my_group_l_end, natom
176 INTENT(IN),
POINTER :: sab_orb_sub
177 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(OUT) :: l_local_col
178 INTEGER,
DIMENSION(:),
INTENT(IN) :: kind_of
180 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mp2_eri_2c_integrate_gpw'
182 INTEGER :: dir, handle, handle2, i_counter, iatom, igrid_level, ikind, ipgf, iset, lb(3), &
183 lll, location(3), max_nseta, na1, na2, ncoa, nseta, offset, sgfa, tp(3), ub(3)
184 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: offset_2d
185 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nsgfa
186 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
187 LOGICAL :: map_it_here, use_subpatch
188 REAL(kind=
dp) :: cutoff_old, radius, relative_cutoff_old
189 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: e_cutoff_old
190 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: i_ab
191 REAL(kind=
dp),
DIMENSION(3) :: ra
192 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a
193 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: i_tmp2, rpgfa, sphi_a, zeta
204 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
210 CALL timeset(routinen, handle)
212 CALL prepare_gpw(qs_env, dft_control, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, &
213 auxbas_pw_pool, poisson_env, task_list_sub, rho_r, rho_g, pot_g, psi_l, sab_orb_sub)
215 CALL get_qs_env(qs_env, cell=cell, qs_kind_set=qs_kind_set, atomic_kind_set=atomic_kind_set, particle_set=particle_set)
220 DO lll = my_group_l_start, my_group_l_end
221 i_counter = i_counter + 1
225 qs_kind_set, cell, dft_control, particle_set, pw_env_sub, &
226 required_function=lll, basis_type=
"RI_AUX")
228 CALL timeset(routinen//
"_pot_lm", handle2)
234 CALL pw_env_get(pw_env_sub, rs_descs=rs_descs, rs_grids=rs_v)
237 CALL timestop(handle2)
241 CALL get_qs_kind_set(qs_kind_set=qs_kind_set, maxnset=max_nseta, basis_type=
"RI_AUX")
242 ALLOCATE (offset_2d(max_nseta, natom))
245 ikind = kind_of(iatom)
246 CALL get_qs_kind(qs_kind=qs_kind_set(ikind), basis_set=basis_set_a, basis_type=
"RI_AUX")
247 nseta = basis_set_a%nset
248 nsgfa => basis_set_a%nsgf_set
250 offset = offset + nsgfa(iset)
251 offset_2d(iset, iatom) = offset
266 ikind = kind_of(iatom)
267 CALL get_qs_kind(qs_kind=qs_kind_set(ikind), basis_set=basis_set_a, basis_type=
"RI_AUX")
269 first_sgfa => basis_set_a%first_sgf
270 la_max => basis_set_a%lmax
271 la_min => basis_set_a%lmin
272 npgfa => basis_set_a%npgf
273 nseta = basis_set_a%nset
274 nsgfa => basis_set_a%nsgf_set
275 rpgfa => basis_set_a%pgf_radius
276 set_radius_a => basis_set_a%set_radius
277 sphi_a => basis_set_a%sphi
278 zeta => basis_set_a%zet
280 ra(:) =
pbc(particle_set(iatom)%r, cell)
283 ncoa = npgfa(iset)*
ncoset(la_max(iset))
284 sgfa = first_sgfa(1, iset)
286 ALLOCATE (i_tmp2(ncoa, 1))
288 ALLOCATE (i_ab(nsgfa(iset), 1))
291 offset = offset_2d(iset, iatom)
294 use_subpatch = .NOT. all(rs_v(igrid_level)%desc%perd == 1)
297 offset, para_env_sub%num_pe, para_env_sub%mepos))
THEN
298 DO ipgf = 1, npgfa(iset)
299 sgfa = first_sgfa(1, iset)
300 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
301 na2 = ipgf*
ncoset(la_max(iset))
305 lb_min=0, lb_max=0, ra=ra, rb=ra, rp=ra, &
306 zetp=zeta(ipgf, iset), &
307 eps=dft_control%qs_control%eps_gvg_rspace, &
308 prefactor=1.0_dp, cutoff=1.0_dp)
310 CALL integrate_pgf_product( &
311 la_max=la_max(iset), zeta=zeta(ipgf, iset), la_min=la_min(iset), &
312 lb_max=0, zetb=0.0_dp, lb_min=0, &
313 ra=ra, rab=(/0.0_dp, 0.0_dp, 0.0_dp/), &
314 rsgrid=rs_v(igrid_level), &
319 calculate_forces=.false., &
320 use_subpatch=use_subpatch, &
324 CALL dgemm(
"T",
"N", nsgfa(iset), 1, ncoa, &
325 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
326 i_tmp2(1, 1),
SIZE(i_tmp2, 1), &
327 1.0_dp, i_ab(1, 1),
SIZE(i_ab, 1))
329 l_local_col(offset - nsgfa(iset) + 1:offset, i_counter) = i_ab(1:nsgfa(iset), 1)
338 DEALLOCATE (offset_2d)
342 CALL para_env_sub%sum(l_local_col)
344 CALL cleanup_gpw(qs_env, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, &
345 task_list_sub, auxbas_pw_pool, rho_r, rho_g, pot_g, psi_l)
347 CALL timestop(handle)
379 qs_kind_set, particle_set, cell, pw_env_sub, poisson_env, pot_g, &
380 potential_parameter, use_virial, rho_g_copy, dvg, &
381 kind_of, atom_of_kind, G_PQ_local, force, h_stress, para_env_sub, &
382 dft_control, psi_L, factor)
385 INTEGER,
INTENT(IN) :: lll
389 POINTER :: atomic_kind_set
391 POINTER :: qs_kind_set
393 POINTER :: particle_set
394 TYPE(
cell_type),
INTENT(IN),
POINTER :: cell
395 TYPE(
pw_env_type),
INTENT(IN),
POINTER :: pw_env_sub
399 LOGICAL,
INTENT(IN) :: use_virial
401 INTEGER,
DIMENSION(:),
INTENT(IN) :: kind_of, atom_of_kind
402 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: g_pq_local
405 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: h_stress
409 REAL(kind=
dp),
INTENT(IN) :: factor
411 CHARACTER(LEN=*),
PARAMETER :: routinen =
'integrate_potential_forces_2c'
413 INTEGER :: handle, handle2
415 CALL timeset(routinen, handle)
418 CALL timeset(routinen//
"_wf_pot", handle2)
423 qs_kind_set, cell, dft_control, particle_set, &
424 pw_env_sub, required_function=lll, basis_type=
'RI_AUX')
430 CALL timestop(handle2)
434 CALL pw_copy(rho_g, rho_g_copy)
443 qs_kind_set, cell, dft_control, particle_set, pw_env_sub, &
444 basis_type=
"RI_AUX", &
445 external_vector=0.5_dp*factor*g_pq_local)
447 CALL calc_potential_gpw(psi_l, rho_g, poisson_env, pot_g, potential_parameter, no_transfer=.true.)
449 CALL virial_gpw_potential(rho_g_copy, pot_g, rho_g, dvg, h_stress, potential_parameter, para_env_sub)
454 CALL integrate_potential(pw_env_sub, rho_r, kind_of, atom_of_kind, particle_set, qs_kind_set, &
455 -0.25_dp*factor*g_pq_local, cell, force, use_virial, h_stress, para_env_sub, dft_control)
457 CALL timestop(handle)
473 TYPE(dbcsr_p_type),
INTENT(INOUT) :: mat_munu
475 TYPE(dbcsr_p_type),
INTENT(IN) :: matrix_p_munu
477 TYPE(
pw_env_type),
INTENT(IN),
POINTER :: pw_env_sub
480 CHARACTER(LEN=*),
PARAMETER :: routinen =
'integrate_potential_forces_3c_1c'
484 CALL timeset(routinen, handle)
488 CALL dbcsr_set(mat_munu%matrix, 0.0_dp)
489 CALL integrate_v_rspace(rho_r, hmat=mat_munu, pmat=matrix_p_munu, &
490 qs_env=qs_env, calculate_forces=.true., compute_tau=.false., gapw=.false., &
491 pw_env_external=pw_env_sub, &
492 task_list_external=task_list_sub)
494 CALL timestop(handle)
523 potential_parameter, &
524 ks_env, poisson_env, pot_g, use_virial, rho_g_copy, dvg, &
525 h_stress, para_env_sub, kind_of, atom_of_kind, &
526 qs_kind_set, particle_set, cell, LLL, force, dft_control)
528 TYPE(dbcsr_p_type),
INTENT(IN) :: matrix_p_munu
532 TYPE(
pw_env_type),
INTENT(IN),
POINTER :: pw_env_sub
537 LOGICAL,
INTENT(IN) :: use_virial
540 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: h_stress
542 INTEGER,
DIMENSION(:),
INTENT(IN) :: kind_of, atom_of_kind
544 POINTER :: qs_kind_set
546 POINTER :: particle_set
547 TYPE(
cell_type),
INTENT(IN),
POINTER :: cell
548 INTEGER,
INTENT(IN) :: lll
553 CHARACTER(LEN=*),
PARAMETER :: routinen =
'integrate_potential_forces_3c_2c'
555 INTEGER :: atom_a, handle, handle2, iatom, &
556 igrid_level, ikind, iorb, ipgf, iset, &
557 na1, na2, ncoa, nseta, offset, sgfa
558 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nsgfa
559 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
560 LOGICAL :: map_it_here, skip_shell, use_subpatch
561 REAL(kind=
dp) :: radius
562 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: i_ab
563 REAL(kind=
dp),
DIMENSION(3) :: force_a, force_b, ra
564 REAL(kind=
dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
565 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a
566 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: i_tmp2, pab, rpgfa, sphi_a, zeta
572 CALL timeset(routinen, handle)
575 CALL timeset(routinen//
"_Gpot", handle2)
581 task_list_external=task_list_sub, &
582 pw_env_external=pw_env_sub, &
587 CALL timestop(handle2)
589 IF (use_virial)
CALL virial_gpw_potential(rho_g_copy, pot_g, rho_g, dvg, h_stress, potential_parameter, para_env_sub)
594 CALL pw_env_get(pw_env_sub, rs_descs=rs_descs, rs_grids=rs_v)
598 DO iatom = 1,
SIZE(kind_of)
599 ikind = kind_of(iatom)
600 atom_a = atom_of_kind(iatom)
601 CALL get_qs_kind(qs_kind=qs_kind_set(ikind), basis_set=basis_set_a, &
604 first_sgfa => basis_set_a%first_sgf
605 la_max => basis_set_a%lmax
606 la_min => basis_set_a%lmin
607 npgfa => basis_set_a%npgf
608 nseta = basis_set_a%nset
609 nsgfa => basis_set_a%nsgf_set
610 rpgfa => basis_set_a%pgf_radius
611 set_radius_a => basis_set_a%set_radius
612 sphi_a => basis_set_a%sphi
613 zeta => basis_set_a%zet
615 ra(:) =
pbc(particle_set(iatom)%r, cell)
625 ncoa = npgfa(iset)*
ncoset(la_max(iset))
626 sgfa = first_sgfa(1, iset)
628 ALLOCATE (i_tmp2(ncoa, 1))
630 ALLOCATE (i_ab(nsgfa(iset), 1))
632 ALLOCATE (pab(ncoa, 1))
636 DO iorb = 1, nsgfa(iset)
637 IF (iorb + offset == lll)
THEN
638 i_ab(iorb, 1) = 1.0_dp
644 offset = offset + nsgfa(iset)
651 CALL dgemm(
"N",
"N", ncoa, 1, nsgfa(iset), &
652 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
653 i_ab(1, 1),
SIZE(i_ab, 1), &
654 0.0_dp, pab(1, 1),
SIZE(pab, 1))
658 map_it_here = .false.
659 use_subpatch = .NOT. all(rs_v(igrid_level)%desc%perd == 1)
661 IF (
map_gaussian_here(rs_v(igrid_level), cell%h_inv, ra, offset, para_env_sub%num_pe, para_env_sub%mepos))
THEN
662 DO ipgf = 1, npgfa(iset)
663 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
664 na2 = ipgf*
ncoset(la_max(iset))
668 lb_min=0, lb_max=0, ra=ra, rb=ra, rp=ra, &
669 zetp=zeta(ipgf, iset), &
670 eps=dft_control%qs_control%eps_gvg_rspace, &
671 prefactor=1.0_dp, cutoff=1.0_dp)
673 CALL integrate_pgf_product(la_max=la_max(iset), zeta=zeta(ipgf, iset)/2.0_dp, la_min=la_min(iset), &
674 lb_max=0, zetb=zeta(ipgf, iset)/2.0_dp, lb_min=0, &
675 ra=ra, rab=(/0.0_dp, 0.0_dp, 0.0_dp/), &
676 rsgrid=rs_v(igrid_level), &
682 calculate_forces=.true., &
683 force_a=force_a, force_b=force_b, &
684 use_virial=use_virial, &
685 my_virial_a=my_virial_a, &
686 my_virial_b=my_virial_b, &
687 use_subpatch=use_subpatch, &
695 offset = offset + nsgfa(iset)
699 force(ikind)%rho_elec(:, atom_a) = &
700 force(ikind)%rho_elec(:, atom_a) + force_a(:) + force_b(:)
702 h_stress = h_stress + my_virial_a + my_virial_b
706 CALL timestop(handle)
725 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: h_stress
729 CHARACTER(LEN=*),
PARAMETER :: routinen =
'virial_gpw_potential'
731 INTEGER :: alpha, beta, handle
732 INTEGER,
DIMENSION(3) :: comp
733 REAL(kind=
dp) :: e_hartree
736 CALL timeset(routinen, handle)
745 CALL factor_virial_gpw(rho_g, potential_parameter)
746 h_stress(alpha, alpha) = h_stress(alpha, alpha) - e_hartree/real(para_env_sub%num_pe,
dp)
748 h_stress(alpha, beta) = h_stress(alpha, beta) &
750 h_stress(beta, alpha) = h_stress(alpha, beta)
754 CALL timestop(handle)
763 SUBROUTINE factor_virial_gpw(pw, potential_parameter)
767 SELECT CASE (potential_parameter%potential_type)
776 potential_parameter%scale_coulomb, potential_parameter%scale_longrange)
782 cpabort(
"Unknown potential type")
785 END SUBROUTINE factor_virial_gpw
803 SUBROUTINE integrate_potential(pw_env_sub, pot_r, kind_of, atom_of_kind, particle_set, qs_kind_set, &
804 G_PQ_local, cell, force, use_virial, h_stress, para_env_sub, dft_control)
806 TYPE(
pw_env_type),
INTENT(IN),
POINTER :: pw_env_sub
808 INTEGER,
DIMENSION(:),
INTENT(IN) :: kind_of, atom_of_kind
810 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
811 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: g_pq_local
812 TYPE(
cell_type),
INTENT(IN),
POINTER :: cell
814 LOGICAL,
INTENT(IN) :: use_virial
815 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: h_stress
819 CHARACTER(LEN=*),
PARAMETER :: routinen =
'integrate_potential'
821 INTEGER :: atom_a, handle, iatom, igrid_level, &
822 ikind, ipgf, iset, na1, na2, ncoa, &
824 INTEGER,
DIMENSION(:),
POINTER :: la_max, la_min, npgfa, nsgfa
825 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgfa
826 LOGICAL :: use_subpatch
827 REAL(kind=
dp) :: radius
828 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: i_ab
829 REAL(kind=
dp),
DIMENSION(3) :: force_a, force_b, ra
830 REAL(kind=
dp),
DIMENSION(3, 3) :: my_virial_a, my_virial_b
831 REAL(kind=
dp),
DIMENSION(:),
POINTER :: set_radius_a
832 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: i_tmp2, pab, rpgfa, sphi_a, zeta
838 CALL timeset(routinen, handle)
842 CALL pw_env_get(pw_env_sub, rs_descs=rs_descs, rs_grids=rs_v)
846 DO iatom = 1,
SIZE(kind_of)
847 ikind = kind_of(iatom)
848 atom_a = atom_of_kind(iatom)
849 CALL get_qs_kind(qs_kind=qs_kind_set(ikind), basis_set=basis_set_a, &
852 first_sgfa => basis_set_a%first_sgf
853 la_max => basis_set_a%lmax
854 la_min => basis_set_a%lmin
855 npgfa => basis_set_a%npgf
856 nseta = basis_set_a%nset
857 nsgfa => basis_set_a%nsgf_set
858 rpgfa => basis_set_a%pgf_radius
859 set_radius_a => basis_set_a%set_radius
860 sphi_a => basis_set_a%sphi
861 zeta => basis_set_a%zet
863 ra(:) =
pbc(particle_set(iatom)%r, cell)
873 ncoa = npgfa(iset)*
ncoset(la_max(iset))
874 sgfa = first_sgfa(1, iset)
876 ALLOCATE (i_tmp2(ncoa, 1))
878 ALLOCATE (i_ab(nsgfa(iset), 1))
880 ALLOCATE (pab(ncoa, 1))
883 i_ab(1:nsgfa(iset), 1) = -4.0_dp*g_pq_local(offset + 1:offset + nsgfa(iset))
885 CALL dgemm(
"N",
"N", ncoa, 1, nsgfa(iset), &
886 1.0_dp, sphi_a(1, sgfa),
SIZE(sphi_a, 1), &
887 i_ab(1, 1),
SIZE(i_ab, 1), &
888 0.0_dp, pab(1, 1),
SIZE(pab, 1))
893 use_subpatch = .NOT. all(rs_v(igrid_level)%desc%perd == 1)
895 IF (
map_gaussian_here(rs_v(igrid_level), cell%h_inv, ra, offset, para_env_sub%num_pe, para_env_sub%mepos))
THEN
896 DO ipgf = 1, npgfa(iset)
897 na1 = (ipgf - 1)*
ncoset(la_max(iset)) + 1
898 na2 = ipgf*
ncoset(la_max(iset))
902 lb_min=0, lb_max=0, ra=ra, rb=ra, rp=ra, &
903 zetp=zeta(ipgf, iset), &
904 eps=dft_control%qs_control%eps_gvg_rspace, &
905 prefactor=1.0_dp, cutoff=1.0_dp)
907 CALL integrate_pgf_product(la_max=la_max(iset), zeta=zeta(ipgf, iset)/2.0_dp, la_min=la_min(iset), &
908 lb_max=0, zetb=zeta(ipgf, iset)/2.0_dp, lb_min=0, &
909 ra=ra, rab=(/0.0_dp, 0.0_dp, 0.0_dp/), &
910 rsgrid=rs_v(igrid_level), &
916 calculate_forces=.true., &
917 force_a=force_a, force_b=force_b, &
918 use_virial=use_virial, &
919 my_virial_a=my_virial_a, &
920 my_virial_b=my_virial_b, &
921 use_subpatch=use_subpatch, &
932 offset = offset + nsgfa(iset)
936 force(ikind)%rho_elec(:, atom_a) = &
937 force(ikind)%rho_elec(:, atom_a) + force_a(:) + force_b
939 h_stress = h_stress + my_virial_a + my_virial_b
943 CALL timestop(handle)
965 SUBROUTINE prepare_gpw(qs_env, dft_control, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, &
966 auxbas_pw_pool, poisson_env, task_list_sub, rho_r, rho_g, pot_g, psi_L, sab_orb_sub)
969 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:), &
970 INTENT(OUT) :: e_cutoff_old
971 REAL(kind=
dp),
INTENT(OUT) :: cutoff_old, relative_cutoff_old
974 TYPE(
pw_pool_type),
INTENT(IN),
POINTER :: auxbas_pw_pool
981 INTENT(IN),
POINTER :: sab_orb_sub
983 CHARACTER(LEN=*),
PARAMETER :: routinen =
'prepare_gpw'
985 INTEGER :: handle, i_multigrid, n_multigrid
986 LOGICAL :: skip_load_balance_distributed
987 REAL(kind=
dp) :: progression_factor
990 CALL timeset(routinen, handle)
992 CALL get_qs_env(qs_env, dft_control=dft_control, ks_env=ks_env)
995 progression_factor = dft_control%qs_control%progression_factor
996 n_multigrid =
SIZE(dft_control%qs_control%e_cutoff)
997 ALLOCATE (e_cutoff_old(n_multigrid))
998 e_cutoff_old(:) = dft_control%qs_control%e_cutoff
999 cutoff_old = dft_control%qs_control%cutoff
1001 dft_control%qs_control%cutoff = qs_env%mp2_env%mp2_gpw%cutoff*0.5_dp
1002 dft_control%qs_control%e_cutoff(1) = dft_control%qs_control%cutoff
1003 DO i_multigrid = 2, n_multigrid
1004 dft_control%qs_control%e_cutoff(i_multigrid) = dft_control%qs_control%e_cutoff(i_multigrid - 1) &
1008 relative_cutoff_old = dft_control%qs_control%relative_cutoff
1009 dft_control%qs_control%relative_cutoff = qs_env%mp2_env%mp2_gpw%relative_cutoff*0.5_dp
1012 NULLIFY (pw_env_sub)
1016 CALL pw_env_get(pw_env_sub, auxbas_pw_pool=auxbas_pw_pool, &
1017 poisson_env=poisson_env)
1021 NULLIFY (task_list_sub)
1022 skip_load_balance_distributed = dft_control%qs_control%skip_load_balance_distributed
1025 reorder_rs_grid_ranks=.true., soft_valid=.false., &
1026 skip_load_balance_distributed=skip_load_balance_distributed, &
1027 pw_env_external=pw_env_sub, sab_orb_external=sab_orb_sub)
1030 CALL auxbas_pw_pool%create_pw(rho_r)
1031 CALL auxbas_pw_pool%create_pw(rho_g)
1032 CALL auxbas_pw_pool%create_pw(pot_g)
1033 CALL auxbas_pw_pool%create_pw(psi_l)
1039 CALL timestop(handle)
1058 SUBROUTINE cleanup_gpw(qs_env, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, &
1059 task_list_sub, auxbas_pw_pool, rho_r, rho_g, pot_g, psi_L)
1061 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:), &
1062 INTENT(IN) :: e_cutoff_old
1063 REAL(kind=
dp),
INTENT(IN) :: cutoff_old, relative_cutoff_old
1067 TYPE(
pw_pool_type),
INTENT(IN),
POINTER :: auxbas_pw_pool
1072 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cleanup_gpw'
1077 CALL timeset(routinen, handle)
1080 CALL auxbas_pw_pool%give_back_pw(rho_r)
1081 CALL auxbas_pw_pool%give_back_pw(rho_g)
1082 CALL auxbas_pw_pool%give_back_pw(pot_g)
1083 CALL auxbas_pw_pool%give_back_pw(psi_l)
1088 CALL get_qs_env(qs_env, dft_control=dft_control)
1091 dft_control%qs_control%e_cutoff = e_cutoff_old
1092 dft_control%qs_control%cutoff = cutoff_old
1093 dft_control%qs_control%relative_cutoff = relative_cutoff_old
1095 CALL timestop(handle)
1116 INTENT(INOUT),
OPTIONAL :: dvg
1117 LOGICAL,
INTENT(IN),
OPTIONAL :: no_transfer
1119 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_potential_gpw'
1121 INTEGER :: comp(3), handle, idir, my_potential_type
1122 LOGICAL :: my_transfer
1124 CALL timeset(routinen, handle)
1127 IF (
PRESENT(potential_parameter))
THEN
1128 my_potential_type = potential_parameter%potential_type
1131 my_transfer = .true.
1132 IF (
PRESENT(no_transfer)) my_transfer = .NOT. no_transfer
1137 IF (
PRESENT(dvg))
THEN
1146 potential_parameter%scale_coulomb, &
1147 potential_parameter%scale_longrange)
1152 IF (
PRESENT(dvg))
THEN
1154 CALL pw_copy(pot_g, dvg(idir))
1163 IF (my_transfer)
CALL pw_scale(pot_r, pot_r%pw_grid%dvol)
1164 CALL timestop(handle)
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.
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
represent a full matrix distributed on many processors
integer function, public gaussian_gridlevel(gridlevel_info, exponent)
...
Defines the basic variable types.
integer, parameter, public dp
2- and 3-center electron repulsion integral routines based on libint2 Currently available operators: ...
Definition of mathematical constants and functions.
real(kind=dp), parameter, public fourpi
Interface to the message passing library MPI.
Routines to calculate 2c- and 3c-integrals for RI with GPW.
subroutine, public integrate_potential_forces_3c_2c(matrix_p_munu, rho_r, rho_g, task_list_sub, pw_env_sub, potential_parameter, ks_env, poisson_env, pot_g, use_virial, rho_g_copy, dvg, h_stress, para_env_sub, kind_of, atom_of_kind, qs_kind_set, particle_set, cell, lll, force, dft_control)
Integrates potential of two Gaussians to a potential.
subroutine, public mp2_eri_2c_integrate_gpw(qs_env, para_env_sub, my_group_l_start, my_group_l_end, natom, potential_parameter, sab_orb_sub, l_local_col, kind_of)
Integrates the potential of an RI function.
subroutine, public prepare_gpw(qs_env, dft_control, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, auxbas_pw_pool, poisson_env, task_list_sub, rho_r, rho_g, pot_g, psi_l, sab_orb_sub)
Prepares GPW calculation for RI-MP2/RI-RPA.
subroutine, public virial_gpw_potential(rho_g_copy, pot_g, rho_g, dvg, h_stress, potential_parameter, para_env_sub)
Calculates stress tensor contribution from the operator.
subroutine, public mp2_eri_3c_integrate_gpw(mo_coeff, psi_l, rho_g, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env_sub, external_vector, poisson_env, rho_r, pot_g, potential_parameter, mat_munu, qs_env, task_list_sub)
...
subroutine, public integrate_potential_forces_2c(rho_r, lll, matrix, rho_g, atomic_kind_set, qs_kind_set, particle_set, cell, pw_env_sub, poisson_env, pot_g, potential_parameter, use_virial, rho_g_copy, dvg, kind_of, atom_of_kind, g_pq_local, force, h_stress, para_env_sub, dft_control, psi_l, factor)
Integrates the potential of a RI function obtaining the forces and stress tensor.
subroutine, public calc_potential_gpw(pot_r, rho_g, poisson_env, pot_g, potential_parameter, dvg, no_transfer)
Calculates potential from a given density in g-space.
subroutine, public integrate_potential_forces_3c_1c(mat_munu, rho_r, matrix_p_munu, qs_env, pw_env_sub, task_list_sub)
Takes the precomputed potential of an RI wave-function and determines matrix element and gradients wi...
subroutine, public cleanup_gpw(qs_env, e_cutoff_old, cutoff_old, relative_cutoff_old, para_env_sub, pw_env_sub, task_list_sub, auxbas_pw_pool, rho_r, rho_g, pot_g, psi_l)
Cleanup GPW integration for RI-MP2/RI-RPA.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
Define the data structure for the particle information.
methods of pw_env that have dependence on qs_env
subroutine, public pw_env_rebuild(pw_env, qs_env, external_para_env)
rebuilds the pw_env data (necessary if cell or cutoffs change)
subroutine, public pw_env_create(pw_env)
creates a pw_env, if qs_env is given calls pw_env_rebuild
container for various plainwaves related things
subroutine, public pw_env_release(pw_env, para_env)
releases the given pw_env (see doc/ReferenceCounting.html)
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 pw_log_deriv_trunc(pw, rcutoff)
Multiply all data points with the logarithmic derivative of the complementary cosine This function is...
subroutine, public pw_gauss_damp(pw, omega)
Multiply all data points with a Gaussian damping factor Needed for longrange Coulomb potential V(\vec...
subroutine, public pw_log_deriv_compl_gauss(pw, omega)
Multiply all data points with the logarithmic derivative of the complementary Gaussian damping factor...
subroutine, public pw_log_deriv_gauss(pw, omega)
Multiply all data points with the logarithmic derivative of a Gaussian.
subroutine, public pw_gauss_damp_mix(pw, omega, scale_coul, scale_long)
Multiply all data points with a Gaussian damping factor and mixes it with the original function Neede...
subroutine, public pw_truncated(pw, rcutoff)
Multiply all data points with a complementary cosine Needed for truncated Coulomb potential V(\vec r)...
subroutine, public pw_derive(pw, n)
Calculate the derivative of a plane wave vector.
subroutine, public pw_compl_gauss_damp(pw, omega)
Multiply all data points with a Gaussian damping factor Needed for longrange Coulomb potential V(\vec...
subroutine, public pw_log_deriv_mix_cl(pw, omega, scale_coul, scale_long)
Multiply all data points with the logarithmic derivative of the mixed longrange/Coulomb potential Nee...
functions related to the poisson solver on regular grids
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_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 calculate_wavefunction(mo_vectors, ivector, rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env, basis_type, external_vector)
maps a given wavefunction on the 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 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.
Integrate single or product functions over a potential on a RS grid.
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 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)
Get attributes of an atomic kind set.
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)
...
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
generate the tasks lists used by collocate and integrate routines
subroutine, public generate_qs_task_list(ks_env, task_list, reorder_rs_grid_ranks, skip_load_balance_distributed, soft_valid, basis_type, pw_env_external, sab_orb_external)
...
subroutine, public deallocate_task_list(task_list)
deallocates the components and the object itself
subroutine, public allocate_task_list(task_list)
allocates and initialised the components of the task_list_type
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
environment for the poisson solver
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 ...