39#include "../base/base_uses.f90"
45 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'dgs'
53 MODULE PROCEDURE dg_sum_patch_coef, dg_sum_patch_arr
57 MODULE PROCEDURE dg_sum_patch_force_coef_3d, dg_sum_patch_force_arr_3d
61 MODULE PROCEDURE dg_sum_patch_force_coef_1d, dg_sum_patch_force_arr_1d
65 MODULE PROCEDURE dg_get_patch_1, dg_get_patch_2
68 INTERFACE dg_add_patch
69 MODULE PROCEDURE dg_add_patch_simple, dg_add_patch_folded
72 INTERFACE dg_int_patch_3d
73 MODULE PROCEDURE dg_int_patch_simple_3d, dg_int_patch_folded_3d
76 INTERFACE dg_int_patch_1d
77 MODULE PROCEDURE dg_int_patch_simple_1d, dg_int_patch_folded_1d
96 mp_comm, grid_ref, rs_dims, iounit, fft_usage)
98 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: b_cell_hmat
99 INTEGER,
DIMENSION(:),
INTENT(IN) :: npts_s
100 REAL(kind=
dp),
INTENT(IN) :: cutoff_radius
105 INTEGER,
DIMENSION(2),
INTENT(in),
OPTIONAL :: rs_dims
106 INTEGER,
INTENT(IN),
OPTIONAL :: iounit
107 LOGICAL,
INTENT(IN),
OPTIONAL :: fft_usage
109 INTEGER,
DIMENSION(2, 3) :: bounds_b, bounds_s
110 REAL(kind=
dp) :: cutoff, ecut
111 REAL(kind=
dp),
DIMENSION(3, 3) :: s_cell_hmat, unit_cell_hmat
113 CALL dg_find_cutoff(b_cell_hmat, npts_s, cutoff_radius, bounds_s, bounds_b, cutoff)
115 ecut = 0.5_dp*cutoff*cutoff
116 IF (
PRESENT(grid_ref))
THEN
117 CALL pw_grid_create(grid_b, mp_comm, b_cell_hmat, bounds=bounds_b, grid_span=
halfspace, cutoff=ecut, spherical=.true., &
118 ref_grid=grid_ref, rs_dims=rs_dims, iounit=iounit, fft_usage=fft_usage)
120 CALL pw_grid_create(grid_b, mp_comm, b_cell_hmat, bounds=bounds_b, grid_span=
halfspace, cutoff=ecut, spherical=.true., &
121 rs_dims=rs_dims, iounit=iounit, fft_usage=fft_usage)
124 CALL dg_find_basis(grid_b%npts, b_cell_hmat, unit_cell_hmat)
126 CALL dg_set_cell(bounds_s(2, :) - bounds_s(1, :) + 1, unit_cell_hmat, s_cell_hmat)
129 cutoff=ecut, iounit=iounit, fft_usage=fft_usage)
140 PURE FUNCTION get_cell_lengths(cell_hmat)
RESULT(abc)
141 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: cell_hmat
142 REAL(kind=
dp),
DIMENSION(3) :: abc
144 abc(1) = sqrt(cell_hmat(1, 1)*cell_hmat(1, 1) + &
145 cell_hmat(2, 1)*cell_hmat(2, 1) + &
146 cell_hmat(3, 1)*cell_hmat(3, 1))
147 abc(2) = sqrt(cell_hmat(1, 2)*cell_hmat(1, 2) + &
148 cell_hmat(2, 2)*cell_hmat(2, 2) + &
149 cell_hmat(3, 2)*cell_hmat(3, 2))
150 abc(3) = sqrt(cell_hmat(1, 3)*cell_hmat(1, 3) + &
151 cell_hmat(2, 3)*cell_hmat(2, 3) + &
152 cell_hmat(3, 3)*cell_hmat(3, 3))
153 END FUNCTION get_cell_lengths
164 SUBROUTINE dg_find_cutoff(b_cell_hmat, npts_s, cutoff_radius, &
165 bounds_s, bounds_b, cutoff)
167 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: b_cell_hmat
168 INTEGER,
DIMENSION(:),
INTENT(IN) :: npts_s
169 REAL(kind=
dp),
INTENT(IN) :: cutoff_radius
170 INTEGER,
DIMENSION(2, 3),
INTENT(OUT) :: bounds_s, bounds_b
171 REAL(kind=
dp),
INTENT(OUT) :: cutoff
173 INTEGER,
DIMENSION(3) :: nout, npts_b
174 REAL(kind=
dp) :: b_cell_deth, cell_lengths(3), dr(3)
175 REAL(kind=
dp),
DIMENSION(3, 3) :: b_cell_h_inv
177 b_cell_deth = abs(
det_3x3(b_cell_hmat))
178 IF (b_cell_deth < 1.0e-10_dp)
THEN
179 CALL cp_abort(__location__, &
180 "An invalid set of cell vectors was specified. "// &
181 "The determinant det(h) is too small")
183 b_cell_h_inv =
inv_3x3(b_cell_hmat)
192 cell_lengths = get_cell_lengths(b_cell_hmat)
194 CALL dg_get_spacing(nout, cutoff_radius, dr)
195 CALL dg_find_radix(dr, cell_lengths, npts_b)
198 IF (nout(1) > npts_b(1))
THEN
200 dr(1) = cell_lengths(1)/real(nout(1), kind=
dp)
202 IF (nout(2) > npts_b(2))
THEN
204 dr(2) = cell_lengths(2)/real(nout(2), kind=
dp)
206 IF (nout(3) > npts_b(3))
THEN
208 dr(3) = cell_lengths(3)/real(nout(3), kind=
dp)
212 bounds_b(1, :) = -npts_b/2
213 bounds_b(2, :) = +(npts_b - 1)/2
215 bounds_s(1, :) = -nout(:)/2
216 bounds_s(2, :) = (+nout(:) - 1)/2
220 END SUBROUTINE dg_find_cutoff
228 SUBROUTINE dg_get_spacing(npts, cutoff_radius, dr)
230 INTEGER,
DIMENSION(:),
INTENT(IN) :: npts
231 REAL(kind=
dp),
INTENT(IN) :: cutoff_radius
232 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: dr
234 dr(:) = cutoff_radius/(real(npts(:), kind=
dp)/2.0_dp)
236 END SUBROUTINE dg_get_spacing
245 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: b_cell_hmat
248 REAL(kind=
dp),
DIMENSION(3, 3) :: s_cell_hmat, unit_cell_hmat
250 CALL dg_find_basis(grid_b%npts, b_cell_hmat, unit_cell_hmat)
251 CALL dg_set_cell(grid_s%npts, unit_cell_hmat, s_cell_hmat)
261 SUBROUTINE dg_find_radix(dr, cell_lengths, npts)
263 REAL(kind=
dp),
INTENT(INOUT) :: dr(3)
264 REAL(kind=
dp),
INTENT(IN) :: cell_lengths(3)
265 INTEGER,
DIMENSION(:),
INTENT(OUT) :: npts
267 INTEGER,
DIMENSION(3) :: nin
269 nin(:) = nint(cell_lengths(:)/dr(:))
276 dr(:) = cell_lengths(:)/real(npts(:), kind=
dp)
278 END SUBROUTINE dg_find_radix
286 PURE SUBROUTINE dg_find_basis(npts, cell_hmat, unit_cell_hmat)
287 INTEGER,
DIMENSION(:),
INTENT(IN) :: npts
288 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: cell_hmat
289 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(OUT) :: unit_cell_hmat
294 unit_cell_hmat(:, i) = cell_hmat(:, i)/real(npts(:), kind=
dp)
297 END SUBROUTINE dg_find_basis
307 PURE SUBROUTINE dg_set_cell(npts, unit_cell_hmat, cell_hmat)
308 INTEGER,
DIMENSION(:),
INTENT(IN) :: npts
309 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: unit_cell_hmat
310 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(OUT) :: cell_hmat
314 cell_hmat(:, 1) = unit_cell_hmat(:, 1)*npts(1)
315 cell_hmat(:, 2) = unit_cell_hmat(:, 2)*npts(2)
316 cell_hmat(:, 3) = unit_cell_hmat(:, 3)*npts(3)
318 END SUBROUTINE dg_set_cell
333 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: cell_hmat
334 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: r
335 INTEGER,
DIMENSION(:),
INTENT(IN) :: npts_s, npts_b
336 INTEGER,
INTENT(OUT) :: centre(3)
337 INTEGER,
INTENT(IN) :: lb(3)
338 COMPLEX(KIND=dp),
DIMENSION(lb(1):),
INTENT(OUT) :: ex
339 COMPLEX(KIND=dp),
DIMENSION(lb(2):),
INTENT(OUT) :: ey
340 COMPLEX(KIND=dp),
DIMENSION(lb(3):),
INTENT(OUT) :: ez
342 REAL(kind=
dp) :: delta(3)
344 CALL dg_get_delta(cell_hmat, r, npts_s, npts_b, centre, delta)
359 SUBROUTINE dg_get_delta(cell_hmat, r, npts_s, npts_b, centre, delta)
360 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: cell_hmat
361 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: r
362 INTEGER,
DIMENSION(:),
INTENT(IN) :: npts_s, npts_b
363 INTEGER,
DIMENSION(:),
INTENT(OUT) :: centre
364 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: delta
366 REAL(kind=
dp) :: cell_deth
367 REAL(kind=
dp),
DIMENSION(3) :: grid_i, s
368 REAL(kind=
dp),
DIMENSION(3, 3) :: cell_h_inv
370 cell_deth = abs(
det_3x3(cell_hmat))
371 IF (cell_deth < 1.0e-10_dp)
THEN
372 CALL cp_abort(__location__, &
373 "An invalid set of cell vectors was specified. "// &
374 "The determinant det(h) is too small")
377 cell_h_inv =
inv_3x3(cell_hmat)
380 s = matmul(cell_h_inv, r)
384 grid_i(1:3) = real(npts_b(1:3), kind=
dp)*s(1:3)
387 centre(:) = nint(grid_i(:))
390 delta(:) = (grid_i(:) - centre(:))/real(npts_s(:), kind=
dp)
392 centre(:) = centre(:) + npts_b(:)/2
393 centre(:) =
modulo(centre(:), npts_b(:))
394 centre(:) = centre(:) - npts_b(:)/2
396 END SUBROUTINE dg_get_delta
404 PURE SUBROUTINE dg_sum_patch_coef(rs, rhos, center)
408 INTEGER,
DIMENSION(3),
INTENT(IN) :: center
411 INTEGER,
DIMENSION(3) :: nc
416 DO i = rhos%pw_grid%bounds(1, 1), rhos%pw_grid%bounds(2, 1)
417 ia = i - rhos%pw_grid%bounds(1, 1) + 1
418 ii = center(1) + i - rs%lb_local(1)
420 rs%px(ia) = ii + rs%npts_local(1) + 1
422 ELSEIF (ii >= rs%npts_local(1))
THEN
423 rs%px(ia) = ii - rs%npts_local(1) + 1
429 DO i = rhos%pw_grid%bounds(1, 2), rhos%pw_grid%bounds(2, 2)
430 ia = i - rhos%pw_grid%bounds(1, 2) + 1
431 ii = center(2) + i - rs%lb_local(2)
433 rs%py(ia) = ii + rs%npts_local(2) + 1
435 ELSEIF (ii >= rs%npts_local(2))
THEN
436 rs%py(ia) = ii - rs%npts_local(2) + 1
442 DO i = rhos%pw_grid%bounds(1, 3), rhos%pw_grid%bounds(2, 3)
443 ia = i - rhos%pw_grid%bounds(1, 3) + 1
444 ii = center(3) + i - rs%lb_local(3)
446 rs%pz(ia) = ii + rs%npts_local(3) + 1
448 ELSEIF (ii >= rs%npts_local(3))
THEN
449 rs%pz(ia) = ii - rs%npts_local(3) + 1
457 CALL dg_add_patch(rs%r, rhos%array, rhos%pw_grid%npts, &
463 CALL dg_add_patch(rs%r, rhos%array, rhos%pw_grid%npts, nc)
466 END SUBROUTINE dg_sum_patch_coef
474 PURE SUBROUTINE dg_sum_patch_arr(rs, rhos, center)
477 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: rhos
478 INTEGER,
DIMENSION(3),
INTENT(IN) :: center
481 INTEGER,
DIMENSION(3) :: lb, nc, ns, ub
484 ns(1) =
SIZE(rhos, 1)
485 ns(2) =
SIZE(rhos, 2)
486 ns(3) =
SIZE(rhos, 3)
493 ii = center(1) + i - rs%lb_local(1)
495 rs%px(ia) = ii + rs%npts_local(1) + 1
497 ELSEIF (ii >= rs%npts_local(1))
THEN
498 rs%px(ia) = ii - rs%npts_local(1) + 1
506 ii = center(2) + i - rs%lb_local(2)
508 rs%py(ia) = ii + rs%npts_local(2) + 1
510 ELSEIF (ii >= rs%npts_local(2))
THEN
511 rs%py(ia) = ii - rs%npts_local(2) + 1
519 ii = center(3) + i - rs%lb_local(3)
521 rs%pz(ia) = ii + rs%npts_local(3) + 1
523 ELSEIF (ii >= rs%npts_local(3))
THEN
524 rs%pz(ia) = ii - rs%npts_local(3) + 1
532 CALL dg_add_patch(rs%r, rhos, ns, rs%px, rs%py, rs%pz)
537 CALL dg_add_patch(rs%r, rhos, ns, nc)
540 END SUBROUTINE dg_sum_patch_arr
549 PURE SUBROUTINE dg_sum_patch_force_arr_3d(drpot, rhos, center, force)
552 INTENT(INOUT) :: drpot
553 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: rhos
554 INTEGER,
DIMENSION(3),
INTENT(IN) :: center
555 REAL(kind=
dp),
DIMENSION(3),
INTENT(OUT) :: force
558 INTEGER,
DIMENSION(3) :: lb, nc, ns, ub
561 ns(1) =
SIZE(rhos, 1)
562 ns(2) =
SIZE(rhos, 2)
563 ns(3) =
SIZE(rhos, 3)
570 ii = center(1) + i - drpot(1)%lb_local(1)
572 drpot(1)%px(ia) = ii + drpot(1)%npts_local(1) + 1
574 ELSEIF (ii >= drpot(1)%npts_local(1))
THEN
575 drpot(1)%px(ia) = ii - drpot(1)%npts_local(1) + 1
578 drpot(1)%px(ia) = ii + 1
583 ii = center(2) + i - drpot(1)%lb_local(2)
585 drpot(1)%py(ia) = ii + drpot(1)%npts_local(2) + 1
587 ELSEIF (ii >= drpot(1)%npts_local(2))
THEN
588 drpot(1)%py(ia) = ii - drpot(1)%npts_local(2) + 1
591 drpot(1)%py(ia) = ii + 1
596 ii = center(3) + i - drpot(1)%lb_local(3)
598 drpot(1)%pz(ia) = ii + drpot(1)%npts_local(3) + 1
600 ELSEIF (ii >= drpot(1)%npts_local(3))
THEN
601 drpot(1)%pz(ia) = ii - drpot(1)%npts_local(3) + 1
604 drpot(1)%pz(ia) = ii + 1
609 CALL dg_int_patch_3d(drpot(1)%r, drpot(2)%r, &
610 drpot(3)%r, rhos, force, ns, &
611 drpot(1)%px, drpot(1)%py, drpot(1)%pz)
613 nc(1) = drpot(1)%px(1) - 1
614 nc(2) = drpot(1)%py(1) - 1
615 nc(3) = drpot(1)%pz(1) - 1
616 CALL dg_int_patch_3d(drpot(1)%r, drpot(2)%r, &
617 drpot(3)%r, rhos, force, ns, nc)
620 END SUBROUTINE dg_sum_patch_force_arr_3d
629 PURE SUBROUTINE dg_sum_patch_force_arr_1d(drpot, rhos, center, force)
632 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: rhos
633 INTEGER,
DIMENSION(3),
INTENT(IN) :: center
634 REAL(kind=
dp),
INTENT(OUT) :: force
637 INTEGER,
DIMENSION(3) :: lb, nc, ns, ub
640 ns(1) =
SIZE(rhos, 1)
641 ns(2) =
SIZE(rhos, 2)
642 ns(3) =
SIZE(rhos, 3)
649 ii = center(1) + i - drpot%lb_local(1)
651 drpot%px(ia) = ii + drpot%npts_local(1) + 1
653 ELSEIF (ii >= drpot%desc%npts(1))
THEN
654 drpot%px(ia) = ii - drpot%npts_local(1) + 1
657 drpot%px(ia) = ii + 1
662 ii = center(2) + i - drpot%lb_local(2)
664 drpot%py(ia) = ii + drpot%npts_local(2) + 1
666 ELSEIF (ii >= drpot%desc%npts(2))
THEN
667 drpot%py(ia) = ii - drpot%npts_local(2) + 1
670 drpot%py(ia) = ii + 1
675 ii = center(3) + i - drpot%lb_local(3)
677 drpot%pz(ia) = ii + drpot%npts_local(3) + 1
679 ELSEIF (ii >= drpot%desc%npts(3))
THEN
680 drpot%pz(ia) = ii - drpot%npts_local(3) + 1
683 drpot%pz(ia) = ii + 1
688 CALL dg_int_patch_1d(drpot%r, rhos, force, ns, &
689 drpot%px, drpot%py, drpot%pz)
691 nc(1) = drpot%px(1) - 1
692 nc(2) = drpot%py(1) - 1
693 nc(3) = drpot%pz(1) - 1
694 CALL dg_int_patch_1d(drpot%r, rhos, force, ns, nc)
697 END SUBROUTINE dg_sum_patch_force_arr_1d
706 PURE SUBROUTINE dg_sum_patch_force_coef_3d(drpot, rhos, center, force)
709 INTENT(INOUT) :: drpot
711 INTEGER,
DIMENSION(3),
INTENT(IN) :: center
712 REAL(kind=
dp),
DIMENSION(3),
INTENT(OUT) :: force
715 INTEGER,
DIMENSION(3) :: nc
720 DO i = rhos%pw_grid%bounds(1, 1), rhos%pw_grid%bounds(2, 1)
721 ia = i - rhos%pw_grid%bounds(1, 1) + 1
722 ii = center(1) + i - drpot(1)%lb_local(1)
724 drpot(1)%px(ia) = ii + drpot(1)%desc%npts(1) + 1
726 ELSEIF (ii >= drpot(1)%desc%npts(1))
THEN
727 drpot(1)%px(ia) = ii - drpot(1)%desc%npts(1) + 1
730 drpot(1)%px(ia) = ii + 1
733 DO i = rhos%pw_grid%bounds(1, 2), rhos%pw_grid%bounds(2, 2)
734 ia = i - rhos%pw_grid%bounds(1, 2) + 1
735 ii = center(2) + i - drpot(1)%lb_local(2)
737 drpot(1)%py(ia) = ii + drpot(1)%desc%npts(2) + 1
739 ELSEIF (ii >= drpot(1)%desc%npts(2))
THEN
740 drpot(1)%py(ia) = ii - drpot(1)%desc%npts(2) + 1
743 drpot(1)%py(ia) = ii + 1
746 DO i = rhos%pw_grid%bounds(1, 3), rhos%pw_grid%bounds(2, 3)
747 ia = i - rhos%pw_grid%bounds(1, 3) + 1
748 ii = center(3) + i - drpot(1)%lb_local(3)
750 drpot(1)%pz(ia) = ii + drpot(1)%desc%npts(3) + 1
752 ELSEIF (ii >= drpot(1)%desc%npts(3))
THEN
753 drpot(1)%pz(ia) = ii - drpot(1)%desc%npts(3) + 1
756 drpot(1)%pz(ia) = ii + 1
761 CALL dg_int_patch_3d(drpot(1)%r, drpot(2)%r, &
762 drpot(3)%r, rhos%array, force, rhos%pw_grid%npts, &
763 drpot(1)%px, drpot(1)%py, drpot(1)%pz)
765 nc(1) = drpot(1)%px(1) - 1
766 nc(2) = drpot(1)%py(1) - 1
767 nc(3) = drpot(1)%pz(1) - 1
768 CALL dg_int_patch_3d(drpot(1)%r, drpot(2)%r, &
769 drpot(3)%r, rhos%array, force, rhos%pw_grid%npts, nc)
772 END SUBROUTINE dg_sum_patch_force_coef_3d
781 PURE SUBROUTINE dg_sum_patch_force_coef_1d(drpot, rhos, center, force)
785 INTEGER,
DIMENSION(3),
INTENT(IN) :: center
786 REAL(kind=
dp),
INTENT(OUT) :: force
789 INTEGER,
DIMENSION(3) :: nc
794 DO i = rhos%pw_grid%bounds(1, 1), rhos%pw_grid%bounds(2, 1)
795 ia = i - rhos%pw_grid%bounds(1, 1) + 1
796 ii = center(1) + i - drpot%lb_local(1)
798 drpot%px(ia) = ii + drpot%desc%npts(1) + 1
800 ELSEIF (ii >= drpot%desc%npts(1))
THEN
801 drpot%px(ia) = ii - drpot%desc%npts(1) + 1
804 drpot%px(ia) = ii + 1
807 DO i = rhos%pw_grid%bounds(1, 2), rhos%pw_grid%bounds(2, 2)
808 ia = i - rhos%pw_grid%bounds(1, 2) + 1
809 ii = center(2) + i - drpot%lb_local(2)
811 drpot%py(ia) = ii + drpot%desc%npts(2) + 1
813 ELSEIF (ii >= drpot%desc%npts(2))
THEN
814 drpot%py(ia) = ii - drpot%desc%npts(2) + 1
817 drpot%py(ia) = ii + 1
820 DO i = rhos%pw_grid%bounds(1, 3), rhos%pw_grid%bounds(2, 3)
821 ia = i - rhos%pw_grid%bounds(1, 3) + 1
822 ii = center(3) + i - drpot%lb_local(3)
824 drpot%pz(ia) = ii + drpot%desc%npts(3) + 1
826 ELSEIF (ii >= drpot%desc%npts(3))
THEN
827 drpot%pz(ia) = ii - drpot%desc%npts(3) + 1
830 drpot%pz(ia) = ii + 1
835 CALL dg_int_patch_1d(drpot%r, rhos%array, force, &
836 rhos%pw_grid%npts, drpot%px, drpot%py, drpot%pz)
838 nc(1) = drpot%px(1) - 1
839 nc(2) = drpot%py(1) - 1
840 nc(3) = drpot%pz(1) - 1
841 CALL dg_int_patch_1d(drpot%r, rhos%array, force, rhos%pw_grid%npts, nc)
844 END SUBROUTINE dg_sum_patch_force_coef_1d
855 SUBROUTINE dg_get_patch_1(rho0, rhos1, charge1, ex1, ey1, ez1)
859 REAL(KIND=
dp),
INTENT(IN) :: charge1
860 COMPLEX(KIND=dp),
DIMENSION(:),
INTENT(IN) :: ex1, ey1, ez1
862 COMPLEX(KIND=dp) :: za, zb
863 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: zs
867 nd = rhos1%pw_grid%npts
869 ALLOCATE (zs(nd(1)*nd(2)))
871 CALL cd%create(rho0%pw_grid)
874 za = cmplx(0.0_dp, 0.0_dp, kind=
dp)
875 zb = cmplx(charge1, 0.0_dp, kind=
dp)
876 CALL rankup(nd, za, cd%array, zb, ex1, ey1, ez1, zs)
884 END SUBROUTINE dg_get_patch_1
900 SUBROUTINE dg_get_patch_2(rho0, rhos1, rhos2, charge1, charge2, &
901 ex1, ey1, ez1, ex2, ey2, ez2)
905 REAL(KIND=
dp),
INTENT(IN) :: charge1, charge2
906 COMPLEX(KIND=dp),
DIMENSION(:),
INTENT(IN) :: ex1, ey1, ez1, ex2, ey2, ez2
908 COMPLEX(KIND=dp) :: za, zb
909 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: zs
913 nd = rhos1%pw_grid%npts
915 ALLOCATE (zs(nd(1)*nd(2)))
917 CALL cd%create(rhos1%pw_grid)
920 za = cmplx(0.0_dp, 0.0_dp, kind=
dp)
921 zb = cmplx(charge2, 0.0_dp, kind=
dp)
922 CALL rankup(nd, za, cd%array, zb, ex2, ey2, ez2, zs)
923 za = cmplx(0.0_dp, 1.0_dp, kind=
dp)
924 zb = cmplx(charge1, 0.0_dp, kind=
dp)
925 CALL rankup(nd, za, cd%array, zb, ex1, ey1, ez1, zs)
928 CALL copy_cri(cd%array, rhos1%array, rhos2%array)
933 END SUBROUTINE dg_get_patch_2
942 PURE SUBROUTINE dg_add_patch_simple(rb, rs, ns, nc)
944 REAL(KIND=
dp),
INTENT(INOUT) :: rb(:, :, :)
945 REAL(KIND=
dp),
INTENT(IN) :: rs(:, :, :)
946 INTEGER,
INTENT(IN) :: ns(3), nc(3)
948 INTEGER :: i, ii, j, jj, k, kk
956 rb(ii, jj, kk) = rb(ii, jj, kk) + rs(i, j, k)
961 END SUBROUTINE dg_add_patch_simple
972 PURE SUBROUTINE dg_add_patch_folded(rb, rs, ns, px, py, pz)
974 REAL(KIND=
dp),
INTENT(INOUT) :: rb(:, :, :)
975 REAL(KIND=
dp),
INTENT(IN) :: rs(:, :, :)
976 INTEGER,
INTENT(IN) :: ns(:)
977 INTEGER,
DIMENSION(:),
INTENT(IN) :: px, py, pz
979 INTEGER :: i, ii, j, jj, k, kk
987 rb(ii, jj, kk) = rb(ii, jj, kk) + rs(i, j, k)
992 END SUBROUTINE dg_add_patch_folded
1004 PURE SUBROUTINE dg_int_patch_simple_3d(rbx, rby, rbz, rs, f, ns, nc)
1006 REAL(KIND=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: rbx, rby, rbz, rs
1007 REAL(KIND=
dp),
DIMENSION(3),
INTENT(OUT) :: f
1008 INTEGER,
INTENT(IN) :: ns(3), nc(3)
1010 INTEGER :: i, ii, j, jj, k, kk
1021 f(1) = f(1) + s*rbx(ii, jj, kk)
1022 f(2) = f(2) + s*rby(ii, jj, kk)
1023 f(3) = f(3) + s*rbz(ii, jj, kk)
1028 END SUBROUTINE dg_int_patch_simple_3d
1038 PURE SUBROUTINE dg_int_patch_simple_1d(rb, rs, f, ns, nc)
1040 REAL(KIND=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: rb, rs
1041 REAL(KIND=
dp),
INTENT(OUT) :: f
1042 INTEGER,
INTENT(IN) :: ns(3), nc(3)
1044 INTEGER :: i, ii, j, jj, k, kk
1055 f = f + s*rb(ii, jj, kk)
1060 END SUBROUTINE dg_int_patch_simple_1d
1074 PURE SUBROUTINE dg_int_patch_folded_3d(rbx, rby, rbz, rs, f, ns, px, py, pz)
1076 REAL(KIND=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: rbx, rby, rbz, rs
1077 REAL(KIND=
dp),
DIMENSION(3),
INTENT(INOUT) :: f
1078 INTEGER,
INTENT(IN) :: ns(3)
1079 INTEGER,
DIMENSION(:),
INTENT(IN) :: px, py, pz
1081 INTEGER :: i, ii, j, jj, k, kk
1092 f(1) = f(1) + s*rbx(ii, jj, kk)
1093 f(2) = f(2) + s*rby(ii, jj, kk)
1094 f(3) = f(3) + s*rbz(ii, jj, kk)
1099 END SUBROUTINE dg_int_patch_folded_3d
1111 PURE SUBROUTINE dg_int_patch_folded_1d(rb, rs, f, ns, px, py, pz)
1113 REAL(KIND=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: rb, rs
1114 REAL(KIND=
dp),
INTENT(INOUT) :: f
1115 INTEGER,
INTENT(IN) :: ns(3)
1116 INTEGER,
DIMENSION(:),
INTENT(IN) :: px, py, pz
1118 INTEGER :: i, ii, j, jj, k, kk
1129 f = f + s*rb(ii, jj, kk)
1134 END SUBROUTINE dg_int_patch_folded_1d
1147 SUBROUTINE rankup(n, za, cmat, zb, ex, ey, ez, scr)
1152 INTEGER,
DIMENSION(3),
INTENT(IN) :: n
1153 COMPLEX(KIND=dp),
INTENT(IN) :: za
1154 COMPLEX(KIND=dp),
DIMENSION(:, :, :), &
1155 INTENT(INOUT) :: cmat
1156 COMPLEX(KIND=dp),
INTENT(IN) :: zb
1157 COMPLEX(KIND=dp),
DIMENSION(:),
INTENT(IN) :: ex, ey, ez
1158 COMPLEX(KIND=dp),
DIMENSION(:),
INTENT(INOUT) :: scr
1165 CALL zgeru(n(1), n(2), zb, ex, 1, ey, 1, scr, n(1))
1166 CALL zscal(n3, za, cmat, 1)
1167 CALL zgeru(n2, n(3),
z_one, scr, 1, ez, 1, cmat, n2)
1169 END SUBROUTINE rankup
1177 SUBROUTINE copy_cri(z, r1, r2)
1183 COMPLEX(KIND=dp),
INTENT(IN) :: z(:, :, :)
1184 REAL(KIND=
dp),
INTENT(INOUT) :: r1(:, :, :), r2(:, :, :)
1187 r1(:, :, :) = real(z(:, :, :), kind=
dp)
1188 r2(:, :, :) = aimag(z(:, :, :))
1191 END SUBROUTINE copy_cri
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 dg_pme_grid_setup(b_cell_hmat, npts_s, cutoff_radius, grid_s, grid_b, mp_comm, grid_ref, rs_dims, iounit, fft_usage)
...
subroutine, public dg_grid_change(b_cell_hmat, grid_b, grid_s)
...
subroutine, public dg_get_strucfac(cell_hmat, r, npts_s, npts_b, centre, lb, ex, ey, ez)
...
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public z_zero
Collection of simple mathematical functions and subroutines.
pure real(kind=dp) function, dimension(3, 3), public inv_3x3(a)
Returns the inverse of the 3 x 3 matrix a.
Interface to the message passing library MPI.
type(mp_comm_type), parameter, public mp_comm_self
This module returns additional info on PW grids.
real(kind=dp) function, public pw_find_cutoff(npts, h_inv)
Given a grid and a box, calculate the corresponding cutoff *** This routine calculates the cutoff in ...
integer, parameter, public halfspace
This module defines the grid data type and some basic operations on it.
subroutine, public pw_grid_change(cell_hmat, pw_grid)
Recalculate the g-vectors after a change of the box.
subroutine, public structure_factor_evaluate(delta, lb, ex, ey, ez)
...