Skip to content

Commit f439118

Browse files
committed
(implicit ps) bugfix in setting up arbitrary planar dirichlet regions, and improve tiling of such regions; consider forward fft scaling prefactor for smoothing via convolution with a mollifier function.
svn-origin-rev: 15268
1 parent e2f0567 commit f439118

File tree

6 files changed

+38
-11
lines changed

6 files changed

+38
-11
lines changed

src/pw/dirichlet_bc_methods.F

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ SUBROUTINE dirichlet_bc_partition(v_D, smooth, zeta, n_prtn, pw_pool, x_glbl, y_
279279
REAL(dp) :: phi1, phi2
280280
REAL(dp), DIMENSION(3) :: rot_axis1, rot_axis2
281281
TYPE(cp_logger_type), POINTER :: logger
282-
TYPE(cs_rectangle), POINTER :: rectangle_aa
282+
TYPE(cs_rectangle), POINTER :: rectangle_aa, rectangle_tmp
283283
TYPE(tile_p_type), DIMENSION(:), POINTER :: tiles
284284

285285
CALL timeset(routineN,handle)
@@ -315,7 +315,10 @@ SUBROUTINE dirichlet_bc_partition(v_D, smooth, zeta, n_prtn, pw_pool, x_glbl, y_
315315
DO k = 1, n_tiles
316316
ALLOCATE(dirichlet_bc%tiles(k)%tile)
317317
ALLOCATE(dirichlet_bc%tiles(k)%tile%rectangle)
318-
CALL rotate_rectangle(tiles(k)%tile%rectangle, phi1, rot_axis1, BWROT, &
318+
ALLOCATE(rectangle_tmp)
319+
CALL rotate_rectangle(tiles(k)%tile%rectangle, phi2, rot_axis2, BWROT, &
320+
rectangle_tmp, error)
321+
CALL rotate_rectangle(rectangle_tmp, phi1, rot_axis1, BWROT, &
319322
dirichlet_bc%tiles(k)%tile%rectangle, error)
320323

321324
dirichlet_bc%tiles(k)%tile%tile_id = 8000 + k
@@ -341,6 +344,7 @@ SUBROUTINE dirichlet_bc_partition(v_D, smooth, zeta, n_prtn, pw_pool, x_glbl, y_
341344
tile_npts = NINT(SUM(dirichlet_bc%tiles(k)%tile%tile_pw%cr3d),KIND=KIND(tile_npts))
342345
CALL mp_sum(tile_npts, pw_pool%pw_grid%para%group)
343346
dirichlet_bc%tiles(k)%tile%npts = tile_npts
347+
CALL cs_rectangle_release(rectangle_tmp, error)
344348
END DO
345349

346350
IF ((unit_nr .GT. 0) .AND. debug) WRITE(unit_nr, '(T3,A)') REPEAT('=', 78)

src/pw/dirichlet_bc_utils.F

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,10 @@ SUBROUTINE partition_aa_rectangle_into_tiles(rectangle, x_glbl, y_glbl, z_glbl,
878878
yprtn_ubind
879879
INTEGER, DIMENSION(n_prtn(3)) :: zprtn_lbind, zprtn_npts, &
880880
zprtn_ubind
881-
REAL(dp) :: step
882-
REAL(dp), ALLOCATABLE, DIMENSION(:) :: xglbl_sym, yglbl_sym, &
883-
zglbl_sym
881+
REAL(dp) :: dx, dy, dz, step
882+
REAL(dp), ALLOCATABLE, DIMENSION(:) :: xglbl_dbl, xglbl_sym, &
883+
yglbl_dbl, yglbl_sym, &
884+
zglbl_dbl, zglbl_sym
884885
REAL(dp), DIMENSION(2) :: x_xtnt, y_xtnt, z_xtnt
885886
REAL(dp), DIMENSION(3) :: A, B, C, D
886887
REAL(dp), DIMENSION(n_prtn(1)) :: xprtn_lb, xprtn_ub
@@ -889,12 +890,20 @@ SUBROUTINE partition_aa_rectangle_into_tiles(rectangle, x_glbl, y_glbl, z_glbl,
889890

890891
CALL timeset(routineN,handle)
891892

892-
ALLOCATE(xglbl_sym(2*SIZE(x_glbl)-1), yglbl_sym(2*SIZE(y_glbl)-1), zglbl_sym(2*SIZE(z_glbl)-1))
893+
ALLOCATE(xglbl_dbl(2*SIZE(x_glbl)), yglbl_dbl(2*SIZE(y_glbl)), zglbl_dbl(2*SIZE(z_glbl)))
894+
ALLOCATE(xglbl_sym(2*SIZE(xglbl_dbl)-1), yglbl_sym(2*SIZE(yglbl_dbl)-1), zglbl_sym(2*SIZE(zglbl_dbl)-1))
893895

894896
! extend the global axes and make them symmetric
895-
xglbl_sym(:) = (/ (- x_glbl(i), i = UBOUND(x_glbl,1), LBOUND(x_glbl,1)+1, -1), x_glbl /)
896-
yglbl_sym(:) = (/ (- y_glbl(i), i = UBOUND(y_glbl,1), LBOUND(y_glbl,1)+1, -1), y_glbl /)
897-
zglbl_sym(:) = (/ (- z_glbl(i), i = UBOUND(z_glbl,1), LBOUND(z_glbl,1)+1, -1), z_glbl /)
897+
dx = x_glbl(LBOUND(x_glbl,1)+1) - x_glbl(LBOUND(x_glbl,1))
898+
dy = y_glbl(LBOUND(y_glbl,1)+1) - y_glbl(LBOUND(y_glbl,1))
899+
dz = z_glbl(LBOUND(z_glbl,1)+1) - z_glbl(LBOUND(z_glbl,1))
900+
901+
xglbl_dbl(:) = (/ x_glbl, x_glbl+SIZE(x_glbl)*dx /)
902+
yglbl_dbl(:) = (/ y_glbl, y_glbl+SIZE(y_glbl)*dy /)
903+
zglbl_dbl(:) = (/ z_glbl, z_glbl+SIZE(z_glbl)*dz /)
904+
xglbl_sym(:) = (/ (- xglbl_dbl(i), i = UBOUND(xglbl_dbl,1), LBOUND(xglbl_dbl,1)+1, -1), xglbl_dbl /)
905+
yglbl_sym(:) = (/ (- yglbl_dbl(i), i = UBOUND(yglbl_dbl,1), LBOUND(yglbl_dbl,1)+1, -1), yglbl_dbl /)
906+
zglbl_sym(:) = (/ (- zglbl_dbl(i), i = UBOUND(zglbl_dbl,1), LBOUND(zglbl_dbl,1)+1, -1), zglbl_dbl /)
898907

899908
! find the extents of the rectangle in all three directions
900909
x_xtnt(1) = MINVAL(rectangle%vertices(1,:)); x_xtnt(2) = MAXVAL(rectangle%vertices(1,:))

src/pw/ps_implicit_methods.F

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ MODULE ps_implicit_methods
3434
pw_copy,&
3535
pw_derive,&
3636
pw_integral_ab,&
37+
pw_integrate_function,&
3738
pw_scale,&
3839
pw_transfer,&
3940
pw_zero
@@ -2279,15 +2280,19 @@ SUBROUTINE pw_mollifier(pw_pool, zeta, x_glbl, y_glbl, z_glbl, pw_in, pw_out, er
22792280
END DO
22802281
END DO
22812282
CALL pw_scale(G, (1.0_dp/zeta)**3, error)
2282-
normfact = SUM ( G%cr3d ( :, :, : ) )
2283-
CALL mp_sum(normfact, pw_pool%pw_grid%para%group)
2283+
normfact = pw_integrate_function(G,error=error)
22842284
CALL pw_scale(G, 1.0_dp/normfact, error)
22852285
22862286
CALL pw_transfer(G, G_gs, error=error)
22872287
CALL pw_transfer(pw_in, pw_in_gs, error=error)
22882288
pw_out_gs%cc = G_gs%cc * pw_in_gs%cc
22892289
CALL pw_transfer(pw_out_gs, pw_out, error=error)
22902290
2291+
! multiply by the reciprocal of the forward Fourier transform normalization prefactor (here 1/N, by convention)
2292+
CALL pw_scale(pw_out, REAL(pw_grid%ngpts,KIND=dp), error=error)
2293+
! from discrete convolution to continuous convolution
2294+
CALL pw_scale(pw_out, pw_grid%dvol, error=error)
2295+
22912296
DO k = lb3, ub3
22922297
DO j = lb2, ub2
22932298
DO i = lb1, ub1

tests/QS/regtest-ps-implicit-1-2/TEST_FILES_RESET

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ Ar_mixed_periodic_planar.inp
99
Ar_mixed_periodic_cuboidal.inp
1010
Ar_mixed_periodic_cylindrical.inp
1111
Ar_neumann.inp
12+
13+
# bugfix in constructing arbitrary planar regions and improve tiling of such regions.
14+
Ar_mixed_periodic_planar.inp

tests/QS/regtest-ps-implicit-1-3/TEST_FILES_RESET

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ Ar_mixed_aa_planar-ns_cell.inp
77
Ar_mixed_aa_planar.inp
88
Ar_mixed_planar.inp
99
Ar_mixed_aa_planar-ns_cell.inp
10+
11+
# bugfix in constructing arbitrary planar regions and improve tiling of such regions.
12+
Ar_mixed_planar.inp

tests/QS/regtest-ps-implicit-2-2/TEST_FILES_RESET

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ H2O_mixed_periodic_planar.inp
55
# properly include the dielectric contribution to the Hamiltonian, v_eps.
66
H2O_mixed_periodic_aa_planar.inp
77
H2O_mixed_periodic_planar.inp
8+
9+
# bugfix in constructing arbitrary planar regions and improve tiling of such regions.
10+
H2O_mixed_periodic_planar.inp

0 commit comments

Comments
 (0)