43 #include "./base/base_uses.f90"
55 TYPE ewald_environment_type
57 LOGICAL :: do_multipoles
59 INTEGER :: max_multipole
60 INTEGER :: max_ipol_iter
65 REAL(KIND=
dp) :: precs
66 REAL(KIND=
dp) :: alpha, rcut
67 REAL(KIND=
dp) :: epsilon
68 REAL(KIND=
dp) :: eps_pol
69 TYPE(mp_para_env_type),
POINTER :: para_env
70 TYPE(section_vals_type),
POINTER :: poisson_section
74 REAL(KIND=
dp),
DIMENSION(:, :, :),
POINTER :: interaction_cutoffs
76 REAL(KIND=
dp),
DIMENSION(3, 3) :: cell_hmat = -1.0_dp
77 END TYPE ewald_environment_type
80 PUBLIC :: ewald_environment_type
90 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'ewald_environment_types'
120 gmax, ns_max, o_spline, group, para_env, poisson_section, precs, &
121 rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, &
122 interaction_cutoffs, cell_hmat)
123 TYPE(ewald_environment_type),
INTENT(IN) :: ewald_env
124 INTEGER,
OPTIONAL :: ewald_type
125 REAL(kind=
dp),
OPTIONAL :: alpha, eps_pol, epsilon
126 INTEGER,
OPTIONAL :: gmax(3), ns_max, o_spline
127 TYPE(mp_comm_type),
INTENT(OUT),
OPTIONAL :: group
128 TYPE(mp_para_env_type),
OPTIONAL,
POINTER :: para_env
129 TYPE(section_vals_type),
OPTIONAL,
POINTER :: poisson_section
130 REAL(kind=
dp),
OPTIONAL :: precs, rcut
131 LOGICAL,
INTENT(OUT),
OPTIONAL :: do_multipoles
132 INTEGER,
INTENT(OUT),
OPTIONAL :: max_multipole, do_ipol, max_ipol_iter
133 REAL(kind=
dp),
DIMENSION(:, :, :),
OPTIONAL, &
134 POINTER :: interaction_cutoffs
135 REAL(kind=
dp),
DIMENSION(3, 3),
OPTIONAL :: cell_hmat
137 IF (
PRESENT(ewald_type)) ewald_type = ewald_env%ewald_type
138 IF (
PRESENT(do_multipoles)) do_multipoles = ewald_env%do_multipoles
139 IF (
PRESENT(do_ipol)) do_ipol = ewald_env%do_ipol
140 IF (
PRESENT(max_multipole)) max_multipole = ewald_env%max_multipole
141 IF (
PRESENT(max_ipol_iter)) max_ipol_iter = ewald_env%max_ipol_iter
142 IF (
PRESENT(alpha)) alpha = ewald_env%alpha
143 IF (
PRESENT(precs)) precs = ewald_env%precs
144 IF (
PRESENT(rcut)) rcut = ewald_env%rcut
145 IF (
PRESENT(epsilon)) epsilon = ewald_env%epsilon
146 IF (
PRESENT(eps_pol)) eps_pol = ewald_env%eps_pol
147 IF (
PRESENT(gmax)) gmax = ewald_env%gmax
148 IF (
PRESENT(ns_max)) ns_max = ewald_env%ns_max
149 IF (
PRESENT(o_spline)) o_spline = ewald_env%o_spline
150 IF (
PRESENT(group)) group = ewald_env%para_env
151 IF (
PRESENT(para_env)) para_env => ewald_env%para_env
152 IF (
PRESENT(poisson_section)) poisson_section => ewald_env%poisson_section
153 IF (
PRESENT(interaction_cutoffs)) interaction_cutoffs => &
154 ewald_env%interaction_cutoffs
155 IF (
PRESENT(cell_hmat)) cell_hmat = ewald_env%cell_hmat
178 gmax, ns_max, precs, o_spline, para_env, poisson_section, &
179 interaction_cutoffs, cell_hmat)
181 TYPE(ewald_environment_type),
INTENT(INOUT) :: ewald_env
182 INTEGER,
OPTIONAL :: ewald_type
183 REAL(kind=
dp),
OPTIONAL :: alpha, epsilon, eps_pol
184 INTEGER,
OPTIONAL :: gmax(3), ns_max
185 REAL(kind=
dp),
OPTIONAL :: precs
186 INTEGER,
OPTIONAL :: o_spline
187 TYPE(mp_para_env_type),
OPTIONAL,
POINTER :: para_env
188 TYPE(section_vals_type),
OPTIONAL,
POINTER :: poisson_section
189 REAL(kind=
dp),
DIMENSION(:, :, :),
OPTIONAL, &
190 POINTER :: interaction_cutoffs
191 REAL(kind=
dp),
DIMENSION(3, 3),
OPTIONAL :: cell_hmat
193 IF (
PRESENT(ewald_type)) ewald_env%ewald_type = ewald_type
194 IF (
PRESENT(alpha)) ewald_env%alpha = alpha
195 IF (
PRESENT(precs)) ewald_env%precs = precs
196 IF (
PRESENT(epsilon)) ewald_env%epsilon = epsilon
197 IF (
PRESENT(eps_pol)) ewald_env%eps_pol = eps_pol
198 IF (
PRESENT(gmax)) ewald_env%gmax = gmax
199 IF (
PRESENT(ns_max)) ewald_env%ns_max = ns_max
200 IF (
PRESENT(o_spline)) ewald_env%o_spline = o_spline
201 IF (
PRESENT(para_env)) ewald_env%para_env => para_env
202 IF (
PRESENT(poisson_section))
THEN
205 ewald_env%poisson_section => poisson_section
207 IF (
PRESENT(interaction_cutoffs)) ewald_env%interaction_cutoffs => &
209 IF (
PRESENT(cell_hmat)) ewald_env%cell_hmat = cell_hmat
221 TYPE(ewald_environment_type),
INTENT(OUT) :: ewald_env
222 TYPE(mp_para_env_type),
POINTER :: para_env
224 NULLIFY (ewald_env%poisson_section)
225 CALL para_env%retain()
226 ewald_env%para_env => para_env
227 NULLIFY (ewald_env%interaction_cutoffs)
238 TYPE(ewald_environment_type),
INTENT(INOUT) :: ewald_env
242 IF (
ASSOCIATED(ewald_env%interaction_cutoffs))
THEN
243 DEALLOCATE (ewald_env%interaction_cutoffs)
255 TYPE(ewald_environment_type),
INTENT(INOUT) :: ewald_env
256 TYPE(section_vals_type),
POINTER :: ewald_section
259 INTEGER,
DIMENSION(:),
POINTER :: gmax_read
261 REAL(kind=
dp) :: dummy
262 TYPE(cp_logger_type),
POINTER :: logger
263 TYPE(enumeration_type),
POINTER :: enum
264 TYPE(keyword_type),
POINTER :: keyword
265 TYPE(section_type),
POINTER :: section
266 TYPE(section_vals_type),
POINTER :: multipole_section
268 NULLIFY (enum, keyword, section, multipole_section)
275 ewald_env%rcut = 0.0_dp
281 ewald_env%rcut = find_ewald_optimal_value(ewald_env%precs)/ewald_env%alpha
285 SELECT CASE (ewald_env%ewald_type)
288 SELECT CASE (
SIZE(gmax_read, 1))
290 ewald_env%gmax = gmax_read(1)
292 ewald_env%gmax = gmax_read
304 ewald_env%gmax = huge(0)
305 ewald_env%ns_max = huge(0)
310 CALL section_vals_val_get(multipole_section,
"_SECTION_PARAMETERS_", l_val=ewald_env%do_multipoles)
313 IF (ewald_env%do_multipoles)
THEN
314 SELECT CASE (ewald_env%ewald_type)
317 i_val=ewald_env%max_multipole)
320 cpabort(
"Multipole code works at the moment only with standard EWALD sums.")
327 NULLIFY (keyword, enum)
332 WRITE (iw,
'(/,T2,"EWALD| ",A,T67,A14 )')
'Summation is done by:', &
333 adjustr(trim(
enum_i2c(enum, ewald_env%ewald_type)))
334 IF (ewald_env%do_multipoles)
THEN
335 NULLIFY (keyword, enum)
338 WRITE (iw,
'( T2,"EWALD| ",A )')
'Enabled Multipole Method'
339 WRITE (iw,
'( T2,"EWALD| ",A,T67,A14 )')
'Max Term in Multipole Expansion :', &
340 adjustr(trim(
enum_i2c(enum, ewald_env%max_multipole)))
341 WRITE (iw,
'( T2,"EWALD| ",A,T67,3I10 )')
'Max number Iterations for IPOL :', &
342 ewald_env%max_ipol_iter
345 WRITE (iw,
'( T2,"EWALD| ",A,A18,A,T71,F10.4 )') &
346 'Alpha parameter [',
'ANGSTROM^-1',
']', dummy
348 WRITE (iw,
'( T2,"EWALD| ",A,A18,A,T71,F10.4 )') &
349 'Real Space Cutoff [',
'ANGSTROM',
']', dummy
351 SELECT CASE (ewald_env%ewald_type)
353 WRITE (iw,
'( T2,"EWALD| ",A,T51,3I10 )') &
354 'G-space max. Miller index', ewald_env%gmax
356 WRITE (iw,
'( T2,"EWALD| ",A,T71,I10 )') &
357 'Max small-grid points (input) ', ewald_env%ns_max
358 WRITE (iw,
'( T2,"EWALD| ",A,T71,E10.4 )') &
359 'Gaussian tolerance (input) ', ewald_env%epsilon
361 WRITE (iw,
'( T2,"EWALD| ",A,T51,3I10 )') &
362 'G-space max. Miller index', ewald_env%gmax
363 WRITE (iw,
'( T2,"EWALD| ",A,T71,I10 )') &
364 'Spline interpolation order ', ewald_env%o_spline
369 WRITE (iw,
'( T2,"EWALD| ",T73, A )')
'not used'
374 "PRINT%PROGRAM_RUN_INFO")
386 TYPE(ewald_environment_type),
INTENT(INOUT) :: ewald_env
387 TYPE(section_vals_type),
POINTER :: ewald_section
388 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: hmat
390 INTEGER :: i, iw, n(3)
391 INTEGER,
DIMENSION(:),
POINTER :: gmax_read
393 REAL(kind=
dp) :: alat, cutoff, dummy
394 TYPE(cp_logger_type),
POINTER :: logger
398 ewald_env%do_multipoles = .false.
399 ewald_env%do_ipol = 0
400 ewald_env%eps_pol = 1.e-12_dp
401 ewald_env%max_multipole = 0
402 ewald_env%max_ipol_iter = 0
403 ewald_env%epsilon = 1.e-12_dp
404 ewald_env%ns_max = huge(0)
410 cpabort(
"TB needs EWALD_TYPE SPME")
420 ewald_env%alpha = 1.0_dp
430 ewald_env%rcut = find_ewald_optimal_value(ewald_env%precs)/ewald_env%alpha
436 SELECT CASE (
SIZE(gmax_read, 1))
438 ewald_env%gmax = gmax_read(1)
440 ewald_env%gmax = gmax_read
446 cutoff = 45._dp*ewald_env%alpha
448 alat = sum(hmat(:, i)**2)
449 cpassert(alat /= 0._dp)
450 ewald_env%gmax(i) = 2*floor(sqrt(2.0_dp*cutoff*alat)/
twopi) + 1
459 WRITE (iw,
'(/,T2,"EWALD| ",A,T67,A14 )')
'Summation is done by:', adjustr(
"SPME")
461 WRITE (iw,
'( T2,"EWALD| ",A,A18,A,T71,F10.4 )') &
462 'Alpha parameter [',
'ANGSTROM^-1',
']', dummy
464 WRITE (iw,
'( T2,"EWALD| ",A,A18,A,T71,F10.4 )') &
465 'Real Space Cutoff [',
'ANGSTROM',
']', dummy
466 WRITE (iw,
'( T2,"EWALD| ",A,T51,3I10 )') &
467 'G-space max. Miller index', ewald_env%gmax
468 WRITE (iw,
'( T2,"EWALD| ",A,T71,I10 )') &
469 'Spline interpolation order ', ewald_env%o_spline
472 "PRINT%PROGRAM_RUN_INFO")
483 FUNCTION find_ewald_optimal_value(precs)
RESULT(value)
484 REAL(kind=
dp) :: precs,
value
486 REAL(kind=
dp) :: func, func1, func2, s, s1, s2
489 func = exp(-s**2)/s**2 - precs
490 cpassert(func > 0.0_dp)
491 DO WHILE (func > 0.0_dp)
493 func = exp(-s**2)/s**2 - precs
499 func2 = exp(-s2**2)/s2**2 - precs
500 func1 = exp(-s1**2)/s1**2 - precs
504 func = exp(-s**2)/s**2 - precs
505 IF (func > 0.0_dp)
THEN
507 ELSE IF (func < 0.0_dp)
THEN
510 IF (abs(func) < 100.0_dp*epsilon(0.0_dp))
EXIT
513 END FUNCTION find_ewald_optimal_value
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,...
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
subroutine, public ewald_env_set(ewald_env, ewald_type, alpha, epsilon, eps_pol, gmax, ns_max, precs, o_spline, para_env, poisson_section, interaction_cutoffs, cell_hmat)
Purpose: Set the EWALD environment.
subroutine, public ewald_env_create(ewald_env, para_env)
allocates and intitializes a ewald_env
subroutine, public read_ewald_section_tb(ewald_env, ewald_section, hmat)
Purpose: read the EWALD section for TB methods.
subroutine, public read_ewald_section(ewald_env, ewald_section)
Purpose: read the EWALD section.
subroutine, public ewald_env_release(ewald_env)
releases the given ewald_env (see doc/ReferenceCounting.html)
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.
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
This module returns additional info on PW grids.
integer function, dimension(3), public pw_grid_n_for_fft(n, odd)
returns the closest number of points >= n, on which you can perform ffts
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