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