(git:ec11232)
Loading...
Searching...
No Matches
pw_poisson_types.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief functions related to the poisson solver on regular grids
10!> \par History
11!> greens_fn: JGH (9-Mar-2001) : include influence_fn into
12!> greens_fn_type add cell volume
13!> as indicator for updates
14!> greens_fn: JGH (30-Mar-2001) : Added B-spline routines
15!> pws : JGH (13-Mar-2001) : new pw_poisson_solver, delete
16!> pw_greens_fn
17!> 12.2004 condensed from pws, greens_fn and green_fns, by apsi and JGH,
18!> made thread safe, new input [fawzi]
19!> 14-Mar-2006 : added short range screening function for SE codes
20!> \author fawzi
21! **************************************************************************************************
23 USE bessel_lib, ONLY: bessk0,&
24 bessk1
27 USE kinds, ONLY: dp
28 USE mathconstants, ONLY: fourpi,&
29 twopi,&
30 z_zero
31 USE mt_util, ONLY: mt0d,&
32 mt1d,&
33 mt2d,&
35 USE ps_implicit_types, ONLY: mixed_bc,&
40 USE ps_wavelet_types, ONLY: wavelet0d,&
44 USE pw_grids, ONLY: pw_grid_release
45 USE pw_pool_types, ONLY: pw_pool_create,&
50 USE pw_types, ONLY: pw_c1d_gs_type,&
54#include "../base/base_uses.f90"
55
56 IMPLICIT NONE
57 PRIVATE
58
59 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
60 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'pw_poisson_types'
61
62 PUBLIC :: pw_poisson_type
66
67 INTEGER, PARAMETER, PUBLIC :: pw_poisson_none = 0, &
70 pw_poisson_mt = 3, &
75 ! EWALD methods
76 INTEGER, PARAMETER, PUBLIC :: do_ewald_none = 1, &
77 do_ewald_ewald = 2, &
78 do_ewald_pme = 3, &
80
81 INTEGER, PARAMETER, PUBLIC :: periodic3d = 1000, &
82 analytic2d = 1001, &
83 analytic1d = 1002, &
84 analytic0d = 1003, &
85 hockney2d = 1201, &
86 hockney1d = 1202, &
87 hockney0d = 1203, &
88 multipole2d = 1301, &
89 multipole1d = 1302, &
90 multipole0d = 1303, &
91 ps_implicit = 1400
92
93! **************************************************************************************************
94!> \brief parameters for the poisson solver independet of input_section
95!> \author Ole Schuett
96! **************************************************************************************************
98 INTEGER :: solver = pw_poisson_none
99
100 INTEGER, DIMENSION(3) :: periodic = 0
101 INTEGER :: ewald_type = do_ewald_none
102 INTEGER :: ewald_o_spline = 0
103 REAL(kind=dp) :: ewald_alpha = 0.0_dp
104
105 REAL(kind=dp) :: mt_rel_cutoff = 0.0_dp
106 REAL(kind=dp) :: mt_alpha = 0.0_dp
107
108 INTEGER :: wavelet_scf_type = 0
109 INTEGER :: wavelet_method = wavelet0d
110 INTEGER :: wavelet_special_dimension = 0
111 CHARACTER(LEN=1) :: wavelet_geocode = "S"
112
113 LOGICAL :: has_dielectric = .false.
114 TYPE(dielectric_parameters) :: dielectric_params = dielectric_parameters()
115 TYPE(ps_implicit_parameters) :: ps_implicit_params = ps_implicit_parameters()
118
119! **************************************************************************************************
120!> \brief environment for the poisson solver
121!> \author fawzi
122! **************************************************************************************************
124 INTEGER :: pw_level = 0
125 INTEGER :: method = pw_poisson_none
126 INTEGER :: used_grid = 0
127 LOGICAL :: rebuild = .true.
128 TYPE(greens_fn_type), POINTER :: green_fft => null()
129 TYPE(ps_wavelet_type), POINTER :: wavelet => null()
131 REAL(kind=dp), DIMENSION(3, 3) :: cell_hmat = 0.0_dp
132 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools => null()
133 TYPE(pw_grid_type), POINTER :: mt_super_ref_pw_grid => null()
134 TYPE(ps_implicit_type), POINTER :: implicit_env => null()
135 TYPE(pw_grid_type), POINTER :: dct_pw_grid => null()
136 TYPE(realspace_grid_type), POINTER :: diel_rs_grid => null()
137 CONTAINS
138 PROCEDURE, PUBLIC, non_overridable :: create => pw_poisson_create
139 PROCEDURE, PUBLIC, non_overridable :: release => pw_poisson_release
140 END TYPE pw_poisson_type
141
142! **************************************************************************************************
143!> \brief contains all the informations needed by the fft based poisson solvers
144!> \author JGH,Teo,fawzi
145! **************************************************************************************************
147 INTEGER :: method = periodic3d
148 INTEGER :: special_dimension = 0
149 REAL(kind=dp) :: radius = 0.0_dp
150 REAL(kind=dp) :: mt_alpha = 1.0_dp
151 REAL(kind=dp) :: mt_rel_cutoff = 1.0_dp
152 REAL(kind=dp) :: slab_size = 0.0_dp
153 REAL(kind=dp) :: alpha = 0.0_dp
154 LOGICAL :: p3m = .false.
155 INTEGER :: p3m_order = 0
156 REAL(kind=dp) :: p3m_alpha = 0.0_dp
157 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: p3m_coeff
158 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: p3m_bm2
159 LOGICAL :: sr_screening = .false.
160 REAL(kind=dp) :: sr_alpha = 1.0_dp
161 REAL(kind=dp) :: sr_rc = 0.0_dp
162 TYPE(pw_c1d_gs_type) :: influence_fn = pw_c1d_gs_type()
163 TYPE(pw_c1d_gs_type), POINTER :: dct_influence_fn => null()
164 TYPE(pw_c1d_gs_type), POINTER :: screen_fn => null()
165 TYPE(pw_r1d_gs_type), POINTER :: p3m_charge => null()
166 END TYPE greens_fn_type
167
168CONTAINS
169
170! **************************************************************************************************
171!> \brief Allocates and sets up the green functions for the fft based poisson
172!> solvers
173!> \param green ...
174!> \param poisson_params ...
175!> \param cell_hmat ...
176!> \param pw_pool ...
177!> \param mt_super_ref_pw_grid ...
178!> \param dct_pw_grid ...
179!> \author Fawzi, based on previous functions by JGH and Teo
180! **************************************************************************************************
181 SUBROUTINE pw_green_create(green, poisson_params, cell_hmat, pw_pool, &
182 mt_super_ref_pw_grid, dct_pw_grid)
183 TYPE(greens_fn_type), INTENT(OUT) :: green
184 TYPE(pw_poisson_parameter_type), INTENT(IN) :: poisson_params
185 REAL(kind=dp), DIMENSION(3, 3), INTENT(IN) :: cell_hmat
186 TYPE(pw_pool_type), POINTER :: pw_pool
187 TYPE(pw_grid_type), POINTER :: mt_super_ref_pw_grid, dct_pw_grid
188
189 INTEGER :: dim, i, ig, iz, n, nz
190 REAL(kind=dp) :: g2, g3d, gg, gxy, gz, j0g, j1g, k0g, &
191 k1g, rlength, zlength
192 REAL(kind=dp), DIMENSION(3) :: abc
193 TYPE(pw_c1d_gs_type), POINTER :: dct_gf
194 TYPE(pw_grid_type), POINTER :: dct_grid
195 TYPE(pw_pool_type), POINTER :: pw_pool_xpndd
196
197 !CPASSERT(cell%orthorhombic)
198 DO i = 1, 3
199 abc(i) = cell_hmat(i, i)
200 END DO
201 dim = count(poisson_params%periodic == 1)
202
203 SELECT CASE (poisson_params%solver)
205 green%method = periodic3d
206 IF (dim /= 3) THEN
207 cpabort("Illegal combination of periodicity and Poisson solver periodic3d")
208 END IF
210 green%method = multipole0d
211 IF (dim /= 0) THEN
212 cpabort("Illegal combination of periodicity and Poisson solver mulipole0d")
213 END IF
215 SELECT CASE (dim)
216 CASE (0)
217 green%method = analytic0d
218 green%radius = 0.5_dp*minval(abc)
219 CASE (1)
220 green%method = analytic1d
221 green%special_dimension = maxloc(poisson_params%periodic(1:3), 1)
222 green%radius = maxval(abc(1:3))
223 DO i = 1, 3
224 IF (i == green%special_dimension) cycle
225 green%radius = min(green%radius, 0.5_dp*abc(i))
226 END DO
227 CASE (2)
228 green%method = analytic2d
229 i = minloc(poisson_params%periodic, 1)
230 green%special_dimension = i
231 green%slab_size = abc(i)
232 CASE (3)
233 green%method = periodic3d
234 CASE DEFAULT
235 cpabort("")
236 END SELECT
237 CASE (pw_poisson_mt)
238 green%MT_rel_cutoff = poisson_params%mt_rel_cutoff
239 green%MT_alpha = poisson_params%mt_alpha
240 green%MT_alpha = green%MT_alpha/minval(abc)
241 SELECT CASE (dim)
242 CASE (0)
243 green%method = mt0d
244 green%radius = 0.5_dp*minval(abc)
245 CASE (1)
246 green%method = mt1d
247 green%special_dimension = maxloc(poisson_params%periodic(1:3), 1)
248 green%radius = maxval(abc(1:3))
249 DO i = 1, 3
250 IF (i == green%special_dimension) cycle
251 green%radius = min(green%radius, 0.5_dp*abc(i))
252 END DO
253 CASE (2)
254 green%method = mt2d
255 i = minloc(poisson_params%periodic, 1)
256 green%special_dimension = i
257 green%slab_size = abc(i)
258 CASE (3)
259 cpabort("Illegal combination of periodicity and Poisson solver (MT)")
260 CASE DEFAULT
261 cpabort("")
262 END SELECT
264 green%method = ps_implicit
265 CASE DEFAULT
266 cpabort("An unknown Poisson solver was specified")
267 END SELECT
268
269 ! allocate influence function,...
270 SELECT CASE (green%method)
272 CALL pw_pool%create_pw(green%influence_fn)
273
274 IF (poisson_params%ewald_type == do_ewald_spme) THEN
275 green%p3m = .true.
276 green%p3m_order = poisson_params%ewald_o_spline
277 green%p3m_alpha = poisson_params%ewald_alpha
278 n = green%p3m_order
279 ALLOCATE (green%p3m_coeff(-(n - 1):n - 1, 0:n - 1))
280 CALL spme_coeff_calculate(n, green%p3m_coeff)
281 NULLIFY (green%p3m_charge)
282 ALLOCATE (green%p3m_charge)
283 CALL pw_pool%create_pw(green%p3m_charge)
284 CALL influence_factor(green)
285 CALL calc_p3m_charge(green)
286 ELSE
287 green%p3m = .false.
288 END IF
289 !
290 SELECT CASE (green%method)
291 CASE (mt0d, mt1d, mt2d)
292 CALL mtin_create_screen_fn(green%screen_fn, pw_pool=pw_pool, method=green%method, &
293 alpha=green%MT_alpha, &
294 special_dimension=green%special_dimension, slab_size=green%slab_size, &
295 super_ref_pw_grid=mt_super_ref_pw_grid)
296 CASE (ps_implicit)
297 IF ((poisson_params%ps_implicit_params%boundary_condition == mixed_bc) .OR. &
298 (poisson_params%ps_implicit_params%boundary_condition == neumann_bc)) THEN
299 CALL pw_pool_create(pw_pool_xpndd, pw_grid=dct_pw_grid)
300 NULLIFY (green%dct_influence_fn)
301 ALLOCATE (green%dct_influence_fn)
302 CALL pw_pool_xpndd%create_pw(green%dct_influence_fn)
303 CALL pw_pool_release(pw_pool_xpndd)
304 END IF
305 END SELECT
306
307 CASE DEFAULT
308 cpabort("")
309 END SELECT
310
311 ! initialize influence function
312 associate(gf => green%influence_fn, grid => green%influence_fn%pw_grid)
313 SELECT CASE (green%method)
314 CASE (periodic3d, multipole0d)
315
316 DO ig = grid%first_gne0, grid%ngpts_cut_local
317 g2 = grid%gsq(ig)
318 gf%array(ig) = fourpi/g2
319 END DO
320 IF (grid%have_g0) gf%array(1) = 0.0_dp
321
322 CASE (analytic2d)
323
324 iz = green%special_dimension ! iz is the direction with NO PBC
325 zlength = green%slab_size ! zlength is the thickness of the cell
326 DO ig = grid%first_gne0, grid%ngpts_cut_local
327 nz = grid%g_hat(iz, ig)
328 g2 = grid%gsq(ig)
329 g3d = fourpi/g2
330 gxy = max(0.0_dp, g2 - grid%g(iz, ig)*grid%g(iz, ig))
331 gg = 0.5_dp*sqrt(gxy)
332 gf%array(ig) = g3d*(1.0_dp - (-1.0_dp)**nz*exp(-gg*zlength))
333 END DO
334 IF (grid%have_g0) gf%array(1) = 0.0_dp
335
336 CASE (analytic1d)
337 ! see 'ab initio molecular dynamics' table 3.1
338 ! iz is the direction of the PBC ( can be 1,2,3 -> x,y,z )
339 iz = green%special_dimension
340 ! rlength is the radius of the tube
341 rlength = green%radius
342 DO ig = grid%first_gne0, grid%ngpts_cut_local
343 g2 = grid%gsq(ig)
344 g3d = fourpi/g2
345 gxy = sqrt(max(0.0_dp, g2 - grid%g(iz, ig)*grid%g(iz, ig)))
346 gz = abs(grid%g(iz, ig))
347 j0g = bessel_j0(rlength*gxy)
348 j1g = bessel_j1(rlength*gxy)
349 IF (gz > 0) THEN
350 k0g = bessk0(rlength*gz)
351 k1g = bessk1(rlength*gz)
352 ELSE
353 k0g = 0
354 k1g = 0
355 END IF
356 gf%array(ig) = g3d*(1.0_dp + rlength* &
357 (gxy*j1g*k0g - gz*j0g*k1g))
358 END DO
359 IF (grid%have_g0) gf%array(1) = 0.0_dp
360
361 CASE (analytic0d)
362
363 rlength = green%radius ! rlength is the radius of the sphere
364 DO ig = grid%first_gne0, grid%ngpts_cut_local
365 g2 = grid%gsq(ig)
366 gg = sqrt(g2)
367 g3d = fourpi/g2
368 gf%array(ig) = g3d*(1.0_dp - cos(rlength*gg))
369 END DO
370 IF (grid%have_g0) &
371 gf%array(1) = 0.5_dp*fourpi*rlength*rlength
372
373 CASE (mt2d, mt1d, mt0d)
374
375 DO ig = grid%first_gne0, grid%ngpts_cut_local
376 g2 = grid%gsq(ig)
377 g3d = fourpi/g2
378 gf%array(ig) = g3d + green%screen_fn%array(ig)
379 END DO
380 IF (grid%have_g0) &
381 gf%array(1) = green%screen_fn%array(1)
382
383 CASE (ps_implicit)
384
385 DO ig = grid%first_gne0, grid%ngpts_cut_local
386 g2 = grid%gsq(ig)
387 gf%array(ig) = fourpi/g2
388 END DO
389 IF (grid%have_g0) gf%array(1) = 0.0_dp
390
391 IF (ASSOCIATED(green%dct_influence_fn)) THEN
392 dct_gf => green%dct_influence_fn
393 dct_grid => green%dct_influence_fn%pw_grid
394
395 DO ig = dct_grid%first_gne0, dct_grid%ngpts_cut_local
396 g2 = dct_grid%gsq(ig)
397 dct_gf%array(ig) = fourpi/g2
398 END DO
399 IF (dct_grid%have_g0) dct_gf%array(1) = 0.0_dp
400 END IF
401
402 CASE DEFAULT
403 cpabort("")
404 END SELECT
405 END associate
406
407 END SUBROUTINE pw_green_create
408
409! **************************************************************************************************
410!> \brief destroys the type (deallocates data)
411!> \param gftype ...
412!> \param pw_pool ...
413!> \par History
414!> none
415!> \author Joost VandeVondele
416!> Teodoro Laino
417! **************************************************************************************************
418 SUBROUTINE pw_green_release(gftype, pw_pool)
419 TYPE(greens_fn_type), INTENT(INOUT) :: gftype
420 TYPE(pw_pool_type), OPTIONAL, POINTER :: pw_pool
421
422 LOGICAL :: can_give_back
423
424 can_give_back = PRESENT(pw_pool)
425 IF (can_give_back) can_give_back = ASSOCIATED(pw_pool)
426 IF (can_give_back) THEN
427 CALL pw_pool%give_back_pw(gftype%influence_fn)
428 IF (ASSOCIATED(gftype%dct_influence_fn)) THEN
429 CALL pw_pool%give_back_pw(gftype%dct_influence_fn)
430 DEALLOCATE (gftype%dct_influence_fn)
431 END IF
432 IF (ASSOCIATED(gftype%screen_fn)) THEN
433 CALL pw_pool%give_back_pw(gftype%screen_fn)
434 DEALLOCATE (gftype%screen_fn)
435 END IF
436 IF (ASSOCIATED(gftype%p3m_charge)) THEN
437 CALL pw_pool%give_back_pw(gftype%p3m_charge)
438 DEALLOCATE (gftype%p3m_charge)
439 END IF
440 ELSE
441 CALL gftype%influence_fn%release()
442 IF (ASSOCIATED(gftype%dct_influence_fn)) THEN
443 CALL gftype%dct_influence_fn%release()
444 DEALLOCATE (gftype%dct_influence_fn)
445 END IF
446 IF (ASSOCIATED(gftype%screen_fn)) THEN
447 CALL gftype%screen_fn%release()
448 DEALLOCATE (gftype%screen_fn)
449 END IF
450 IF (ASSOCIATED(gftype%p3m_charge)) THEN
451 CALL gftype%p3m_charge%release()
452 DEALLOCATE (gftype%p3m_charge)
453 END IF
454 END IF
455 IF (ALLOCATED(gftype%p3m_bm2)) &
456 DEALLOCATE (gftype%p3m_bm2)
457 IF (ALLOCATED(gftype%p3m_coeff)) &
458 DEALLOCATE (gftype%p3m_coeff)
459 END SUBROUTINE pw_green_release
460
461! **************************************************************************************************
462!> \brief Calculates the influence_factor for the
463!> SPME Green's function in reciprocal space'''
464!> \param gftype ...
465!> \par History
466!> none
467!> \author DH (29-Mar-2001)
468! **************************************************************************************************
469 SUBROUTINE influence_factor(gftype)
470 TYPE(greens_fn_type), INTENT(INOUT) :: gftype
471
472 COMPLEX(KIND=dp) :: b_m, exp_m, sum_m
473 INTEGER :: dim, j, k, l, n, pt
474 INTEGER, DIMENSION(3) :: npts
475 INTEGER, DIMENSION(:), POINTER :: lb, ub
476 REAL(kind=dp) :: l_arg, prod_arg, val
477 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: m_assign
478
479 n = gftype%p3m_order
480
481 ! calculate the assignment function values
482
483 lb => gftype%influence_fn%pw_grid%bounds(1, :)
484 ub => gftype%influence_fn%pw_grid%bounds(2, :)
485 IF (ALLOCATED(gftype%p3m_bm2)) THEN
486 IF (lbound(gftype%p3m_bm2, 2) /= minval(lb(:)) .OR. &
487 ubound(gftype%p3m_bm2, 2) /= maxval(ub(:))) THEN
488 DEALLOCATE (gftype%p3m_bm2)
489 END IF
490 END IF
491 IF (.NOT. ALLOCATED(gftype%p3m_bm2)) THEN
492 ALLOCATE (gftype%p3m_bm2(3, minval(lb(:)):maxval(ub(:))))
493 END IF
494
495 ALLOCATE (m_assign(0:n - 2))
496 m_assign = 0.0_dp
497 DO k = 0, n - 2
498 j = -(n - 1) + 2*k
499 DO l = 0, n - 1
500 l_arg = 0.5_dp**l
501 prod_arg = gftype%p3m_coeff(j, l)*l_arg
502 m_assign(k) = m_assign(k) + prod_arg
503 END DO
504 END DO
505
506 ! calculate the absolute b values
507
508 npts(:) = ub(:) - lb(:) + 1
509 DO dim = 1, 3
510 DO pt = lb(dim), ub(dim)
511 val = twopi*(real(pt, kind=dp)/real(npts(dim), kind=dp))
512 exp_m = cmplx(cos(val), -sin(val), kind=dp)
513 sum_m = z_zero
514 DO k = 0, n - 2
515 sum_m = sum_m + m_assign(k)*exp_m**k
516 END DO
517 b_m = exp_m**(n - 1)/sum_m
518 gftype%p3m_bm2(dim, pt) = sqrt(real(b_m*conjg(b_m), kind=dp))
519 END DO
520 END DO
521
522 DEALLOCATE (m_assign)
523 END SUBROUTINE influence_factor
524
525! **************************************************************************************************
526!> \brief ...
527!> \param gf ...
528! **************************************************************************************************
529 PURE SUBROUTINE calc_p3m_charge(gf)
530
531 TYPE(greens_fn_type), INTENT(INOUT) :: gf
532
533 INTEGER :: ig, l, m, n
534 REAL(kind=dp) :: arg, novol
535
536 ! check if charge function is consistent with current box volume
537
538 associate(grid => gf%influence_fn%pw_grid, bm2 => gf%p3m_bm2)
539 arg = 1.0_dp/(8.0_dp*gf%p3m_alpha**2)
540 novol = real(grid%ngpts, kind=dp)/grid%vol
541 DO ig = 1, grid%ngpts_cut_local
542 l = grid%g_hat(1, ig)
543 m = grid%g_hat(2, ig)
544 n = grid%g_hat(3, ig)
545 gf%p3m_charge%array(ig) = novol*exp(-arg*grid%gsq(ig))* &
546 bm2(1, l)*bm2(2, m)*bm2(3, n)
547 END DO
548 END associate
549
550 END SUBROUTINE calc_p3m_charge
551
552! **************************************************************************************************
553!> \brief Initialize the poisson solver
554!> You should call this just before calling the work routine
555!> pw_poisson_solver
556!> Call pw_poisson_release when you have finished
557!> \param poisson_env ...
558!> \par History
559!> none
560!> \author JGH (12-Mar-2001)
561! **************************************************************************************************
562 SUBROUTINE pw_poisson_create(poisson_env)
563
564 CLASS(pw_poisson_type), INTENT(INOUT) :: poisson_env
565
566 ! Cleanup a potential previous poisson_env
567 CALL poisson_env%release()
568
569 END SUBROUTINE pw_poisson_create
570
571! **************************************************************************************************
572!> \brief releases the poisson solver
573!> \param poisson_env ...
574!> \par History
575!> none
576!> \author fawzi (11.2002)
577! **************************************************************************************************
578 SUBROUTINE pw_poisson_release(poisson_env)
579
580 CLASS(pw_poisson_type), INTENT(INOUT) :: poisson_env
581
582 IF (ASSOCIATED(poisson_env%pw_pools)) THEN
583 CALL pw_pools_dealloc(poisson_env%pw_pools)
584 END IF
585
586 IF (ASSOCIATED(poisson_env%green_fft)) THEN
587 CALL pw_green_release(poisson_env%green_fft)
588 DEALLOCATE (poisson_env%green_fft)
589 END IF
590 CALL pw_grid_release(poisson_env%mt_super_ref_pw_grid)
591 CALL ps_wavelet_release(poisson_env%wavelet)
592 CALL ps_implicit_release(poisson_env%implicit_env, &
593 poisson_env%parameters%ps_implicit_params)
594 CALL pw_grid_release(poisson_env%dct_pw_grid)
595 IF (ASSOCIATED(poisson_env%diel_rs_grid)) THEN
596 CALL rs_grid_release(poisson_env%diel_rs_grid)
597 DEALLOCATE (poisson_env%diel_rs_grid)
598 END IF
599
600 END SUBROUTINE pw_poisson_release
601
602! **************************************************************************************************
603!> \brief Calculates the coefficients for the charge assignment function
604!> \param n ...
605!> \param coeff ...
606!> \par History
607!> none
608!> \author DG (29-Mar-2001)
609! **************************************************************************************************
610 SUBROUTINE spme_coeff_calculate(n, coeff)
611
612 INTEGER, INTENT(IN) :: n
613 REAL(kind=dp), DIMENSION(-(n-1):n-1, 0:n-1), &
614 INTENT(OUT) :: coeff
615
616 INTEGER :: i, j, l, m
617 REAL(kind=dp) :: b
618 REAL(kind=dp), DIMENSION(n, -n:n, 0:n-1) :: a
619
620 a = 0.0_dp
621 a(1, 0, 0) = 1.0_dp
622
623 DO i = 2, n
624 m = i - 1
625 DO j = -m, m, 2
626 DO l = 0, m - 1
627 b = (a(m, j - 1, l) + &
628 REAL((-1)**l, kind=dp)*a(m, j + 1, l))/ &
629 REAL((l + 1)*2**(l + 1), kind=dp)
630 a(i, j, 0) = a(i, j, 0) + b
631 END DO
632 DO l = 0, m - 1
633 a(i, j, l + 1) = (a(m, j + 1, l) - &
634 a(m, j - 1, l))/real(l + 1, kind=dp)
635 END DO
636 END DO
637 END DO
638
639 coeff = 0.0_dp
640 DO i = 0, n - 1
641 DO j = -(n - 1), n - 1, 2
642 coeff(j, i) = a(n, j, i)
643 END DO
644 END DO
645
646 END SUBROUTINE spme_coeff_calculate
647
648END MODULE pw_poisson_types
Calculates Bessel functions.
Definition bessel_lib.F:16
elemental real(kind=dp) function, public bessk1(x)
...
Definition bessel_lib.F:65
elemental real(kind=dp) function, public bessk0(x)
...
Definition bessel_lib.F:36
dielectric constant data type
Dirichlet boundary condition data types.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Definition of mathematical constants and functions.
real(kind=dp), parameter, public fourpi
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
integer, parameter, public mt0d
Definition mt_util.F:33
integer, parameter, public mt2d
Definition mt_util.F:33
subroutine, public mtin_create_screen_fn(screen_function, pw_pool, method, alpha, special_dimension, slab_size, super_ref_pw_grid)
Initialize the Martyna && Tuckerman Poisson Solver.
Definition mt_util.F:53
integer, parameter, public mt1d
Definition mt_util.F:33
Types containing essential information for running implicit (iterative) Poisson solver.
integer, parameter, public neumann_bc
subroutine, public ps_implicit_release(ps_implicit_env, ps_implicit_params, pw_pool)
Deallocates ps_implicit.
integer, parameter, public mixed_bc
Definition and initialisation of the ps_wavelet data type.
integer, parameter, public wavelet0d
subroutine, public ps_wavelet_release(wavelet)
...
This module defines the grid data type and some basic operations on it.
Definition pw_grids.F:36
subroutine, public pw_grid_release(pw_grid)
releases the given pw grid
Definition pw_grids.F:2163
functions related to the poisson solver on regular grids
integer, parameter, public pw_poisson_wavelet
subroutine, public pw_green_create(green, poisson_params, cell_hmat, pw_pool, mt_super_ref_pw_grid, dct_pw_grid)
Allocates and sets up the green functions for the fft based poisson solvers.
integer, parameter, public pw_poisson_periodic
integer, parameter, public multipole1d
subroutine, public pw_green_release(gftype, pw_pool)
destroys the type (deallocates data)
integer, parameter, public pw_poisson_none
integer, parameter, public pw_poisson_mt
integer, parameter, public hockney0d
integer, parameter, public multipole2d
integer, parameter, public pw_poisson_hockney
integer, parameter, public hockney2d
integer, parameter, public do_ewald_pme
integer, parameter, public do_ewald_ewald
integer, parameter, public analytic2d
integer, parameter, public analytic1d
integer, parameter, public periodic3d
integer, parameter, public hockney1d
integer, parameter, public ps_implicit
integer, parameter, public analytic0d
integer, parameter, public multipole0d
integer, parameter, public pw_poisson_implicit
integer, parameter, public do_ewald_none
integer, parameter, public pw_poisson_analytic
integer, parameter, public do_ewald_spme
integer, parameter, public pw_poisson_multipole
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public pw_pools_dealloc(pools)
deallocates the given pools (releasing each of the underlying pools)
subroutine, public pw_pool_release(pool)
releases the given pool (see cp2k/doc/ReferenceCounting.html)
subroutine, public pw_pool_create(pool, pw_grid, max_cache)
creates a pool for pw
subroutine, public rs_grid_release(rs_grid)
releases the given rs grid (see doc/ReferenceCounting.html)
contains all the informations needed by the fft based poisson solvers
parameters for the poisson solver independet of input_section
environment for the poisson solver
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 ...