25 ewald_environment_type
43 pw_poisson_parameter_type,&
50 realspace_grid_desc_type, realspace_grid_input_type, realspace_grid_type,
rs_grid_create, &
53 #include "./base/base_uses.f90"
58 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'ewald_pw_types'
66 TYPE(pw_pool_type),
POINTER :: pw_small_pool => null()
67 TYPE(pw_pool_type),
POINTER :: pw_big_pool => null()
68 TYPE(realspace_grid_desc_type),
POINTER :: rs_desc => null()
69 TYPE(pw_poisson_type),
POINTER :: poisson_env => null()
70 TYPE(dg_type),
POINTER :: dg => null()
71 END TYPE ewald_pw_type
84 TYPE(ewald_pw_type),
INTENT(OUT) :: ewald_pw
85 TYPE(ewald_environment_type),
POINTER :: ewald_env
86 TYPE(cell_type),
POINTER :: cell, cell_ref
87 TYPE(section_vals_type),
POINTER :: print_section
89 NULLIFY (ewald_pw%pw_big_pool)
90 NULLIFY (ewald_pw%pw_small_pool)
91 NULLIFY (ewald_pw%rs_desc)
92 NULLIFY (ewald_pw%poisson_env)
93 ALLOCATE (ewald_pw%dg)
95 CALL ewald_pw_init(ewald_pw, ewald_env, cell, cell_ref, print_section)
103 TYPE(ewald_pw_type),
INTENT(INOUT) :: ewald_pw
108 IF (
ASSOCIATED(ewald_pw%poisson_env))
THEN
109 CALL ewald_pw%poisson_env%release()
110 DEALLOCATE (ewald_pw%poisson_env)
113 DEALLOCATE (ewald_pw%dg)
130 SUBROUTINE ewald_pw_init(ewald_pw, ewald_env, cell, cell_ref, print_section)
131 TYPE(ewald_pw_type),
INTENT(INOUT) :: ewald_pw
132 TYPE(ewald_environment_type),
POINTER :: ewald_env
133 TYPE(cell_type),
POINTER :: cell, cell_ref
134 TYPE(section_vals_type),
POINTER :: print_section
136 CHARACTER(len=*),
PARAMETER :: routinen =
'ewald_pw_init'
138 INTEGER :: bo(2, 3), ewald_type, gmax(3), handle, &
139 npts_s(3), ns_max, o_spline, &
141 REAL(kind=
dp) :: alpha, alphasq, cutoff_radius, epsilon, &
143 TYPE(cp_logger_type),
POINTER :: logger
144 TYPE(mp_para_env_type),
POINTER :: para_env
145 TYPE(pw_grid_type),
POINTER :: pw_big_grid, pw_small_grid
146 TYPE(pw_poisson_parameter_type) :: poisson_params
147 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: pw_pools
148 TYPE(pw_pool_type),
POINTER :: pw_pool
149 TYPE(realspace_grid_desc_type),
POINTER :: rs_desc
150 TYPE(realspace_grid_input_type) :: input_settings
151 TYPE(section_vals_type),
POINTER :: poisson_section, rs_grid_section
153 CALL timeset(routinen, handle)
155 NULLIFY (pw_big_grid)
156 NULLIFY (pw_small_grid, poisson_section)
158 cpassert(
ASSOCIATED(ewald_env))
159 cpassert(
ASSOCIATED(cell))
162 gmax=gmax, alpha=alpha, &
164 ewald_type=ewald_type, &
166 poisson_section=poisson_section, &
171 SELECT CASE (ewald_type)
178 IF (any(gmax == 2*(gmax/2)))
THEN
179 cpabort(
"gmax has to be odd.")
184 fft_usage=.false., iounit=output_unit)
187 ewald_pw%pw_big_pool => pw_pool
195 IF (.NOT.
ASSOCIATED(ewald_pw%poisson_env))
THEN
196 ALLOCATE (ewald_pw%poisson_env)
197 CALL ewald_pw%poisson_env%create()
201 IF (ns_max == 2*(ns_max/2))
THEN
202 cpabort(
"ns_max has to be odd.")
207 norm = (2.0_dp*alphasq/
pi)**(1.5_dp)
208 cutoff_radius =
exp_radius(0, 2.0_dp*alphasq, epsilon, norm)
211 pw_small_grid, pw_big_grid, rs_dims=(/para_env%num_pe, 1/), &
212 iounit=output_unit, fft_usage=.true.)
214 IF (output_unit > 0)
THEN
215 WRITE (output_unit,
'( A,T71,E10.4 )') &
216 ' EWALD| Gaussian tolerance (effective) ', epsilon
217 WRITE (output_unit,
'( A,T63,3I6 )') &
218 ' EWALD| Small box grid ', pw_small_grid%npts
219 WRITE (output_unit,
'( A,T63,3I6 )') &
220 ' EWALD| Full box grid ', pw_big_grid%npts
226 ewald_pw%pw_big_pool => pw_pool
230 ewald_pw%pw_small_pool => pw_pool
233 CALL init_input_type(input_settings, nsmax=maxval(pw_small_grid%npts(1:3)), &
234 rs_grid_section=rs_grid_section, ilevel=1, &
235 higher_grid_layout=(/-1, -1, -1/))
239 TYPE(realspace_grid_type) :: rs
247 ewald_pw%rs_desc => rs_desc
259 IF (.NOT.
ASSOCIATED(ewald_pw%poisson_env))
THEN
260 ALLOCATE (ewald_pw%poisson_env)
261 CALL ewald_pw%poisson_env%create()
266 rs_dims=(/para_env%num_pe, 1/), iounit=output_unit, fft_usage=.true.)
271 ewald_pw%pw_big_pool => pw_pool
275 rs_grid_section=rs_grid_section, ilevel=1, &
276 higher_grid_layout=(/-1, -1, -1/))
280 TYPE(realspace_grid_type) :: rs
286 CALL cp_print_key_finished_output(output_unit, logger, print_section,
"")
288 ewald_pw%rs_desc => rs_desc
290 CALL rs_grid_retain_descriptor(ewald_pw%rs_desc)
291 CALL rs_grid_release_descriptor(rs_desc)
293 CALL pw_grid_release(pw_big_grid)
300 IF (
ASSOCIATED(ewald_pw%poisson_env))
THEN
301 ALLOCATE (pw_pools(1))
302 pw_pools(1)%pool => ewald_pw%pw_big_pool
303 CALL pw_poisson_read_parameters(poisson_section, poisson_params)
304 poisson_params%ewald_type = ewald_type
305 poisson_params%ewald_o_spline = o_spline
306 poisson_params%ewald_alpha = alpha
307 CALL pw_poisson_set(ewald_pw%poisson_env, cell_hmat=cell%hmat, parameters=poisson_params, &
308 use_level=1, pw_pools=pw_pools)
309 DEALLOCATE (pw_pools)
311 CALL timestop(handle)
312 END SUBROUTINE ewald_pw_init
324 SUBROUTINE ewald_pw_get(ewald_pw, pw_big_pool, pw_small_pool, rs_desc, poisson_env, dg)
326 TYPE(ewald_pw_type),
INTENT(IN) :: ewald_pw
327 TYPE(pw_pool_type),
OPTIONAL,
POINTER :: pw_big_pool, pw_small_pool
328 TYPE(realspace_grid_desc_type),
OPTIONAL,
POINTER :: rs_desc
329 TYPE(pw_poisson_type),
OPTIONAL,
POINTER :: poisson_env
330 TYPE(dg_type),
OPTIONAL,
POINTER :: dg
332 IF (
PRESENT(poisson_env)) poisson_env => ewald_pw%poisson_env
333 IF (
PRESENT(pw_big_pool)) pw_big_pool => ewald_pw%pw_big_pool
334 IF (
PRESENT(pw_small_pool)) pw_small_pool => ewald_pw%pw_small_pool
335 IF (
PRESENT(rs_desc)) rs_desc => ewald_pw%rs_desc
336 IF (
PRESENT(dg)) dg => ewald_pw%dg
350 SUBROUTINE ewald_pw_set(ewald_pw, pw_big_pool, pw_small_pool, rs_desc, dg, &
353 TYPE(ewald_pw_type),
INTENT(INOUT) :: ewald_pw
354 TYPE(pw_pool_type),
OPTIONAL,
POINTER :: pw_big_pool, pw_small_pool
355 TYPE(realspace_grid_desc_type),
OPTIONAL,
POINTER :: rs_desc
356 TYPE(dg_type),
OPTIONAL,
POINTER :: dg
357 TYPE(pw_poisson_type),
OPTIONAL,
POINTER :: poisson_env
359 IF (
PRESENT(pw_big_pool))
THEN
360 CALL pw_big_pool%retain()
361 CALL pw_pool_release(ewald_pw%pw_big_pool)
362 ewald_pw%pw_big_pool => pw_big_pool
364 IF (
PRESENT(pw_small_pool))
THEN
365 CALL pw_small_pool%retain()
366 CALL pw_pool_release(ewald_pw%pw_small_pool)
367 ewald_pw%pw_small_pool => pw_small_pool
369 IF (
PRESENT(rs_desc))
THEN
370 CALL rs_grid_retain_descriptor(rs_desc)
371 CALL rs_grid_release_descriptor(ewald_pw%rs_desc)
372 ewald_pw%rs_desc => rs_desc
374 IF (
PRESENT(dg))
THEN
375 CALL dg_release(ewald_pw%dg)
378 IF (
PRESENT(poisson_env))
THEN
379 IF (
ASSOCIATED(ewald_pw%poisson_env))
THEN
380 IF (.NOT.
ASSOCIATED(ewald_pw%poisson_env, poisson_env))
THEN
381 CALL ewald_pw%poisson_env%release()
382 DEALLOCATE (ewald_pw%poisson_env)
385 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, 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_grid_setup(cell_hmat, pw_grid, grid_span, cutoff, bounds, bounds_local, npts, spherical, odd, fft_usage, ncommensurate, icommensurate, blocked, ref_grid, rs_dims, iounit)
sets up a pw_grid
subroutine, public pw_grid_create(pw_grid, pe_group, local)
Initialize a PW grid with all defaults.
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)