52#include "./base/base_uses.f90"
57 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'ewald_pw_types'
65 TYPE(pw_pool_type),
POINTER :: pw_small_pool => null()
85 TYPE(
cell_type),
POINTER :: cell, cell_ref
88 NULLIFY (ewald_pw%pw_big_pool)
89 NULLIFY (ewald_pw%pw_small_pool)
90 NULLIFY (ewald_pw%rs_desc)
91 NULLIFY (ewald_pw%poisson_env)
92 ALLOCATE (ewald_pw%dg)
94 CALL ewald_pw_init(ewald_pw, ewald_env, cell, cell_ref, print_section)
107 IF (
ASSOCIATED(ewald_pw%poisson_env))
THEN
108 CALL ewald_pw%poisson_env%release()
109 DEALLOCATE (ewald_pw%poisson_env)
112 DEALLOCATE (ewald_pw%dg)
129 SUBROUTINE ewald_pw_init(ewald_pw, ewald_env, cell, cell_ref, print_section)
132 TYPE(
cell_type),
POINTER :: cell, cell_ref
135 CHARACTER(len=*),
PARAMETER :: routinen =
'ewald_pw_init'
137 INTEGER :: bo(2, 3), ewald_type, gmax(3), handle, &
138 npts_s(3), ns_max, o_spline, &
140 REAL(kind=
dp) :: alpha, alphasq, cutoff_radius, epsilon, &
144 TYPE(
pw_grid_type),
POINTER :: pw_big_grid, pw_small_grid
152 CALL timeset(routinen, handle)
154 NULLIFY (pw_big_grid)
155 NULLIFY (pw_small_grid, poisson_section)
157 cpassert(
ASSOCIATED(ewald_env))
158 cpassert(
ASSOCIATED(cell))
161 gmax=gmax, alpha=alpha, &
163 ewald_type=ewald_type, &
165 poisson_section=poisson_section, &
170 SELECT CASE (ewald_type)
176 IF (any(gmax == 2*(gmax/2)))
THEN
177 cpabort(
"gmax has to be odd.")
182 fft_usage=.false., iounit=output_unit)
185 ewald_pw%pw_big_pool => pw_pool
193 IF (.NOT.
ASSOCIATED(ewald_pw%poisson_env))
THEN
194 ALLOCATE (ewald_pw%poisson_env)
195 CALL ewald_pw%poisson_env%create()
197 IF (ns_max == 2*(ns_max/2))
THEN
198 cpabort(
"ns_max has to be odd.")
203 norm = (2.0_dp*alphasq/
pi)**(1.5_dp)
204 cutoff_radius =
exp_radius(0, 2.0_dp*alphasq, epsilon, norm)
207 pw_small_grid, pw_big_grid, para_env, rs_dims=(/para_env%num_pe, 1/), &
208 iounit=output_unit, fft_usage=.true.)
210 IF (output_unit > 0)
THEN
211 WRITE (output_unit,
'( A,T71,E10.4 )') &
212 ' EWALD| Gaussian tolerance (effective) ', epsilon
213 WRITE (output_unit,
'( A,T63,3I6 )') &
214 ' EWALD| Small box grid ', pw_small_grid%npts
215 WRITE (output_unit,
'( A,T63,3I6 )') &
216 ' EWALD| Full box grid ', pw_big_grid%npts
222 ewald_pw%pw_big_pool => pw_pool
226 ewald_pw%pw_small_pool => pw_pool
229 CALL init_input_type(input_settings, nsmax=maxval(pw_small_grid%npts(1:3)), &
230 rs_grid_section=rs_grid_section, ilevel=1, &
231 higher_grid_layout=(/-1, -1, -1/))
243 ewald_pw%rs_desc => rs_desc
255 IF (.NOT.
ASSOCIATED(ewald_pw%poisson_env))
THEN
256 ALLOCATE (ewald_pw%poisson_env)
257 CALL ewald_pw%poisson_env%create()
260 CALL pw_grid_create(pw_big_grid, para_env, cell_ref%hmat, grid_span=
halfspace, npts=npts_s, spherical=.true., &
261 rs_dims=(/para_env%num_pe, 1/), iounit=output_unit, fft_usage=.true.)
266 ewald_pw%pw_big_pool => pw_pool
270 rs_grid_section=rs_grid_section, ilevel=1, &
271 higher_grid_layout=(/-1, -1, -1/))
281 CALL cp_print_key_finished_output(output_unit, logger, print_section,
"")
283 ewald_pw%rs_desc => rs_desc
285 CALL rs_grid_retain_descriptor(ewald_pw%rs_desc)
286 CALL rs_grid_release_descriptor(rs_desc)
288 CALL pw_grid_release(pw_big_grid)
295 IF (
ASSOCIATED(ewald_pw%poisson_env))
THEN
296 ALLOCATE (pw_pools(1))
297 pw_pools(1)%pool => ewald_pw%pw_big_pool
298 CALL pw_poisson_read_parameters(poisson_section, poisson_params)
299 poisson_params%ewald_type = ewald_type
300 poisson_params%ewald_o_spline = o_spline
301 poisson_params%ewald_alpha = alpha
302 CALL pw_poisson_set(ewald_pw%poisson_env, cell_hmat=cell%hmat, parameters=poisson_params, &
303 use_level=1, pw_pools=pw_pools)
304 DEALLOCATE (pw_pools)
306 CALL timestop(handle)
307 END SUBROUTINE ewald_pw_init
319 SUBROUTINE ewald_pw_get(ewald_pw, pw_big_pool, pw_small_pool, rs_desc, poisson_env, dg)
322 TYPE(pw_pool_type),
OPTIONAL,
POINTER :: pw_big_pool, pw_small_pool
323 TYPE(realspace_grid_desc_type),
OPTIONAL,
POINTER :: rs_desc
324 TYPE(pw_poisson_type),
OPTIONAL,
POINTER :: poisson_env
325 TYPE(dg_type),
OPTIONAL,
POINTER :: dg
327 IF (
PRESENT(poisson_env)) poisson_env => ewald_pw%poisson_env
328 IF (
PRESENT(pw_big_pool)) pw_big_pool => ewald_pw%pw_big_pool
329 IF (
PRESENT(pw_small_pool)) pw_small_pool => ewald_pw%pw_small_pool
330 IF (
PRESENT(rs_desc)) rs_desc => ewald_pw%rs_desc
331 IF (
PRESENT(dg)) dg => ewald_pw%dg
345 SUBROUTINE ewald_pw_set(ewald_pw, pw_big_pool, pw_small_pool, rs_desc, dg, &
349 TYPE(pw_pool_type),
OPTIONAL,
POINTER :: pw_big_pool, pw_small_pool
350 TYPE(realspace_grid_desc_type),
OPTIONAL,
POINTER :: rs_desc
351 TYPE(dg_type),
OPTIONAL,
POINTER :: dg
352 TYPE(pw_poisson_type),
OPTIONAL,
POINTER :: poisson_env
354 IF (
PRESENT(pw_big_pool))
THEN
355 CALL pw_big_pool%retain()
356 CALL pw_pool_release(ewald_pw%pw_big_pool)
357 ewald_pw%pw_big_pool => pw_big_pool
359 IF (
PRESENT(pw_small_pool))
THEN
360 CALL pw_small_pool%retain()
361 CALL pw_pool_release(ewald_pw%pw_small_pool)
362 ewald_pw%pw_small_pool => pw_small_pool
364 IF (
PRESENT(rs_desc))
THEN
365 CALL rs_grid_retain_descriptor(rs_desc)
366 CALL rs_grid_release_descriptor(ewald_pw%rs_desc)
367 ewald_pw%rs_desc => rs_desc
369 IF (
PRESENT(dg))
THEN
370 CALL dg_release(ewald_pw%dg)
373 IF (
PRESENT(poisson_env))
THEN
374 IF (
ASSOCIATED(ewald_pw%poisson_env))
THEN
375 IF (.NOT.
ASSOCIATED(ewald_pw%poisson_env, poisson_env))
THEN
376 CALL ewald_pw%poisson_env%release()
377 DEALLOCATE (ewald_pw%poisson_env)
380 ewald_pw%poisson_env => poisson_env
All kind of helpful little routines.
real(kind=dp) function, public exp_radius(l, alpha, threshold, prefactor, epsabs, epsrel, rlow)
The radius of a primitive Gaussian function for a given threshold is calculated. g(r) = prefactor*r**...
Handles all functions related to the CELL.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
subroutine, public init_input_type(input_settings, nsmax, rs_grid_section, ilevel, higher_grid_layout)
parses an input section to assign the proper values to the input type
subroutine, public dg_create(dg)
create the dg structure
subroutine, public dg_release(dg)
releases the given dg_type
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 ewald_env_get(ewald_env, ewald_type, alpha, eps_pol, epsilon, gmax, ns_max, o_spline, group, para_env, poisson_section, precs, rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, interaction_cutoffs, cell_hmat)
Purpose: Get the EWALD environment.
subroutine, public ewald_pw_set(ewald_pw, pw_big_pool, pw_small_pool, rs_desc, dg, poisson_env)
set the ewald_pw environment to the correct program.
subroutine, public ewald_pw_get(ewald_pw, pw_big_pool, pw_small_pool, rs_desc, poisson_env, dg)
get the ewald_pw environment to the correct program.
subroutine, public ewald_pw_release(ewald_pw)
releases the memory used by the ewald_pw
subroutine, public ewald_pw_create(ewald_pw, ewald_env, cell, cell_ref, print_section)
creates the structure ewald_pw_type
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Interface to the message passing library MPI.
type(mp_comm_type), parameter, public mp_comm_self
integer, parameter, public halfspace
This module defines the grid data type and some basic operations on it.
subroutine, public pw_grid_release(pw_grid)
releases the given pw grid
subroutine, public pw_poisson_set(poisson_env, cell_hmat, parameters, pw_pools, use_level, mt_super_ref_pw_grid, dct_pw_grid, force_rebuild)
sets cell, grids and parameters used by the poisson solver You should call this at least once (and se...
functions related to the poisson solver on regular grids
integer, parameter, public do_ewald_pme
integer, parameter, public do_ewald_ewald
integer, parameter, public do_ewald_none
integer, parameter, public do_ewald_spme
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
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_print(rs, iounit)
Print information on grids to output.
subroutine, public rs_grid_create(rs, desc)
...
subroutine, public rs_grid_create_descriptor(desc, pw_grid, input_settings, border_points)
Determine the setup of real space grids - this is divided up into the creation of a descriptor and th...
subroutine, public rs_grid_retain_descriptor(rs_desc)
retains the given rs grid descriptor (see doc/ReferenceCounting.html)
subroutine, public rs_grid_release_descriptor(rs_desc)
releases the given rs grid descriptor (see doc/ReferenceCounting.html)
subroutine, public rs_grid_release(rs_grid)
releases the given rs grid (see doc/ReferenceCounting.html)
Type defining parameters related to the simulation cell.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
to build arrays of pointers
stores all the informations relevant to an mpi environment
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 ...