(git:d18deda)
Loading...
Searching...
No Matches
ewald_environment_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!> \par History
10!> JGH FEB-13-2007 : Distributed/replicated realspace grids
11!> Teodoro Laino [tlaino] - University of Zurich - 12.2007
12!> \author CJM NOV-30-2003
13! **************************************************************************************************
33 USE kinds, ONLY: dp
34 USE mathconstants, ONLY: twopi
35 USE mathlib, ONLY: det_3x3
36 USE message_passing, ONLY: mp_comm_type,&
44#include "./base/base_uses.f90"
45
46 IMPLICIT NONE
47 PRIVATE
48
49! **************************************************************************************************
50!> \brief to build arrays of pointers
51!> \param ewald_env the pointer to the ewald_env
52!> \par History
53!> 11/03
54!> \author CJM
55! **************************************************************************************************
57 PRIVATE
58 LOGICAL :: do_multipoles = .false. ! Flag for using the multipole code
59 INTEGER :: do_ipol = -1 ! Solver for induced dipoles
60 INTEGER :: max_multipole = -1 ! max expansion in the multipoles
61 INTEGER :: max_ipol_iter = -1 ! max number of interaction for induced dipoles
62 INTEGER :: ewald_type = -1 ! type of ewald
63 INTEGER :: gmax(3) = -1 ! max Miller index
64 INTEGER :: ns_max = -1 ! # grid points for small grid (PME)
65 INTEGER :: o_spline = -1 ! order of spline (SPME)
66 REAL(kind=dp) :: precs = 0.0_dp ! precision achieved when evaluating the real-space part
67 REAL(kind=dp) :: alpha = 0.0_dp, rcut = 0.0_dp ! ewald alpha and real-space cutoff
68 REAL(kind=dp) :: epsilon = 0.0_dp ! tolerance for small grid (PME)
69 REAL(kind=dp) :: eps_pol = 0.0_dp ! tolerance for convergence of induced dipoles
70 TYPE(mp_para_env_type), POINTER :: para_env => null()
71 TYPE(section_vals_type), POINTER :: poisson_section => null()
72 ! interaction cutoff is required to make the electrostatic interaction
73 ! continuous at a pair distance equal to rcut. this is ignored by the
74 ! multipole code and is otherwise only active when SHIFT_CUTOFF is used.
75 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: interaction_cutoffs => null()
76 ! store current cell, used to rebuild lazily.
77 REAL(kind=dp), DIMENSION(3, 3) :: cell_hmat = -1.0_dp
79
80! *** Public data types ***
82
83! *** Public subroutines ***
84 PUBLIC :: ewald_env_get, &
90
91 CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'ewald_environment_types'
92
93CONTAINS
94
95! **************************************************************************************************
96!> \brief Purpose: Get the EWALD environment.
97!> \param ewald_env the pointer to the ewald_env
98!> \param ewald_type ...
99!> \param alpha ...
100!> \param eps_pol ...
101!> \param epsilon ...
102!> \param gmax ...
103!> \param ns_max ...
104!> \param o_spline ...
105!> \param group ...
106!> \param para_env ...
107!> \param poisson_section ...
108!> \param precs ...
109!> \param rcut ...
110!> \param do_multipoles ...
111!> \param max_multipole ...
112!> \param do_ipol ...
113!> \param max_ipol_iter ...
114!> \param interaction_cutoffs ...
115!> \param cell_hmat ...
116!> \par History
117!> 11/03
118!> \author CJM
119! **************************************************************************************************
120 SUBROUTINE ewald_env_get(ewald_env, ewald_type, alpha, eps_pol, epsilon, &
121 gmax, ns_max, o_spline, group, para_env, poisson_section, precs, &
122 rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, &
123 interaction_cutoffs, cell_hmat)
124 TYPE(ewald_environment_type), INTENT(IN) :: ewald_env
125 INTEGER, OPTIONAL :: ewald_type
126 REAL(kind=dp), OPTIONAL :: alpha, eps_pol, epsilon
127 INTEGER, OPTIONAL :: gmax(3), ns_max, o_spline
128 TYPE(mp_comm_type), INTENT(OUT), OPTIONAL :: group
129 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env
130 TYPE(section_vals_type), OPTIONAL, POINTER :: poisson_section
131 REAL(kind=dp), OPTIONAL :: precs, rcut
132 LOGICAL, INTENT(OUT), OPTIONAL :: do_multipoles
133 INTEGER, INTENT(OUT), OPTIONAL :: max_multipole, do_ipol, max_ipol_iter
134 REAL(kind=dp), DIMENSION(:, :, :), OPTIONAL, &
135 POINTER :: interaction_cutoffs
136 REAL(kind=dp), DIMENSION(3, 3), OPTIONAL :: cell_hmat
137
138 IF (PRESENT(ewald_type)) ewald_type = ewald_env%ewald_type
139 IF (PRESENT(do_multipoles)) do_multipoles = ewald_env%do_multipoles
140 IF (PRESENT(do_ipol)) do_ipol = ewald_env%do_ipol
141 IF (PRESENT(max_multipole)) max_multipole = ewald_env%max_multipole
142 IF (PRESENT(max_ipol_iter)) max_ipol_iter = ewald_env%max_ipol_iter
143 IF (PRESENT(alpha)) alpha = ewald_env%alpha
144 IF (PRESENT(precs)) precs = ewald_env%precs
145 IF (PRESENT(rcut)) rcut = ewald_env%rcut
146 IF (PRESENT(epsilon)) epsilon = ewald_env%epsilon
147 IF (PRESENT(eps_pol)) eps_pol = ewald_env%eps_pol
148 IF (PRESENT(gmax)) gmax = ewald_env%gmax
149 IF (PRESENT(ns_max)) ns_max = ewald_env%ns_max
150 IF (PRESENT(o_spline)) o_spline = ewald_env%o_spline
151 IF (PRESENT(group)) group = ewald_env%para_env
152 IF (PRESENT(para_env)) para_env => ewald_env%para_env
153 IF (PRESENT(poisson_section)) poisson_section => ewald_env%poisson_section
154 IF (PRESENT(interaction_cutoffs)) interaction_cutoffs => &
155 ewald_env%interaction_cutoffs
156 IF (PRESENT(cell_hmat)) cell_hmat = ewald_env%cell_hmat
157 END SUBROUTINE ewald_env_get
158
159! **************************************************************************************************
160!> \brief Purpose: Set the EWALD environment.
161!> \param ewald_env the pointer to the ewald_env
162!> \param ewald_type ...
163!> \param alpha ...
164!> \param epsilon ...
165!> \param eps_pol ...
166!> \param gmax ...
167!> \param ns_max ...
168!> \param precs ...
169!> \param o_spline ...
170!> \param para_env ...
171!> \param poisson_section ...
172!> \param interaction_cutoffs ...
173!> \param cell_hmat ...
174!> \par History
175!> 11/03
176!> \author CJM
177! **************************************************************************************************
178 SUBROUTINE ewald_env_set(ewald_env, ewald_type, alpha, epsilon, eps_pol, &
179 gmax, ns_max, precs, o_spline, para_env, poisson_section, &
180 interaction_cutoffs, cell_hmat)
181
182 TYPE(ewald_environment_type), INTENT(INOUT) :: ewald_env
183 INTEGER, OPTIONAL :: ewald_type
184 REAL(kind=dp), OPTIONAL :: alpha, epsilon, eps_pol
185 INTEGER, OPTIONAL :: gmax(3), ns_max
186 REAL(kind=dp), OPTIONAL :: precs
187 INTEGER, OPTIONAL :: o_spline
188 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env
189 TYPE(section_vals_type), OPTIONAL, POINTER :: poisson_section
190 REAL(kind=dp), DIMENSION(:, :, :), OPTIONAL, &
191 POINTER :: interaction_cutoffs
192 REAL(kind=dp), DIMENSION(3, 3), OPTIONAL :: cell_hmat
193
194 IF (PRESENT(ewald_type)) ewald_env%ewald_type = ewald_type
195 IF (PRESENT(alpha)) ewald_env%alpha = alpha
196 IF (PRESENT(precs)) ewald_env%precs = precs
197 IF (PRESENT(epsilon)) ewald_env%epsilon = epsilon
198 IF (PRESENT(eps_pol)) ewald_env%eps_pol = eps_pol
199 IF (PRESENT(gmax)) ewald_env%gmax = gmax
200 IF (PRESENT(ns_max)) ewald_env%ns_max = ns_max
201 IF (PRESENT(o_spline)) ewald_env%o_spline = o_spline
202 IF (PRESENT(para_env)) ewald_env%para_env => para_env
203 IF (PRESENT(poisson_section)) THEN
204 CALL section_vals_retain(poisson_section)
205 CALL section_vals_release(ewald_env%poisson_section)
206 ewald_env%poisson_section => poisson_section
207 END IF
208 IF (PRESENT(interaction_cutoffs)) ewald_env%interaction_cutoffs => &
209 interaction_cutoffs
210 IF (PRESENT(cell_hmat)) ewald_env%cell_hmat = cell_hmat
211 END SUBROUTINE ewald_env_set
212
213! **************************************************************************************************
214!> \brief allocates and intitializes a ewald_env
215!> \param ewald_env the object to create
216!> \param para_env ...
217!> \par History
218!> 12.2002 created [fawzi]
219!> \author Fawzi Mohamed
220! **************************************************************************************************
221 SUBROUTINE ewald_env_create(ewald_env, para_env)
222 TYPE(ewald_environment_type), INTENT(OUT) :: ewald_env
223 TYPE(mp_para_env_type), POINTER :: para_env
224
225 NULLIFY (ewald_env%poisson_section)
226 CALL para_env%retain()
227 ewald_env%para_env => para_env
228 NULLIFY (ewald_env%interaction_cutoffs) ! allocated and initialized later
229 END SUBROUTINE ewald_env_create
230
231! **************************************************************************************************
232!> \brief releases the given ewald_env (see doc/ReferenceCounting.html)
233!> \param ewald_env the object to release
234!> \par History
235!> 12.2002 created [fawzi]
236!> \author Fawzi Mohamed
237! **************************************************************************************************
238 SUBROUTINE ewald_env_release(ewald_env)
239 TYPE(ewald_environment_type), INTENT(INOUT) :: ewald_env
240
241 CALL mp_para_env_release(ewald_env%para_env)
242 CALL section_vals_release(ewald_env%poisson_section)
243 IF (ASSOCIATED(ewald_env%interaction_cutoffs)) THEN
244 DEALLOCATE (ewald_env%interaction_cutoffs)
245 END IF
246
247 END SUBROUTINE ewald_env_release
248
249! **************************************************************************************************
250!> \brief Purpose: read the EWALD section
251!> \param ewald_env the pointer to the ewald_env
252!> \param ewald_section ...
253!> \author Teodoro Laino [tlaino] -University of Zurich - 2005
254! **************************************************************************************************
255 SUBROUTINE read_ewald_section(ewald_env, ewald_section)
256 TYPE(ewald_environment_type), INTENT(INOUT) :: ewald_env
257 TYPE(section_vals_type), POINTER :: ewald_section
258
259 INTEGER :: iw
260 INTEGER, DIMENSION(:), POINTER :: gmax_read
261 LOGICAL :: explicit
262 REAL(kind=dp) :: dummy
263 TYPE(cp_logger_type), POINTER :: logger
264 TYPE(enumeration_type), POINTER :: enum
265 TYPE(keyword_type), POINTER :: keyword
266 TYPE(section_type), POINTER :: section
267 TYPE(section_vals_type), POINTER :: multipole_section
268
269 NULLIFY (enum, keyword, section, multipole_section)
270 logger => cp_get_default_logger()
271 CALL section_vals_val_get(ewald_section, "EWALD_TYPE", i_val=ewald_env%ewald_type)
272 CALL section_vals_val_get(ewald_section, "ALPHA", r_val=ewald_env%alpha)
273 CALL section_vals_val_get(ewald_section, "EWALD_ACCURACY", r_val=ewald_env%precs)
274
275 IF (ewald_env%ewald_type == do_ewald_none) THEN
276 ewald_env%rcut = 0.0_dp
277 ELSE
278 CALL section_vals_val_get(ewald_section, "RCUT", explicit=explicit)
279 IF (explicit) THEN
280 CALL section_vals_val_get(ewald_section, "RCUT", r_val=ewald_env%rcut)
281 ELSE
282 ewald_env%rcut = find_ewald_optimal_value(ewald_env%precs)/ewald_env%alpha
283 END IF
284 END IF
285 ! we have no defaults for gmax, gmax is only needed for ewald and spme
286 SELECT CASE (ewald_env%ewald_type)
288 CALL section_vals_val_get(ewald_section, "GMAX", i_vals=gmax_read)
289 SELECT CASE (SIZE(gmax_read, 1))
290 CASE (1)
291 ewald_env%gmax = gmax_read(1)
292 CASE (3)
293 ewald_env%gmax = gmax_read
294 CASE DEFAULT
295 cpabort("")
296 END SELECT
297 IF (ewald_env%ewald_type == do_ewald_spme) THEN
298 CALL section_vals_val_get(ewald_section, "O_SPLINE", i_val=ewald_env%o_spline)
299 END IF
300 CASE (do_ewald_pme)
301 CALL section_vals_val_get(ewald_section, "NS_MAX", i_val=ewald_env%ns_max)
302 CALL section_vals_val_get(ewald_section, "EPSILON", r_val=ewald_env%epsilon)
303 CASE DEFAULT
304 ! this should not be used for do_ewald_none
305 ewald_env%gmax = huge(0)
306 ewald_env%ns_max = huge(0)
307 END SELECT
308
309 ! Multipoles
310 multipole_section => section_vals_get_subs_vals(ewald_section, "MULTIPOLES")
311 CALL section_vals_val_get(multipole_section, "_SECTION_PARAMETERS_", l_val=ewald_env%do_multipoles)
312 CALL section_vals_val_get(multipole_section, "POL_SCF", i_val=ewald_env%do_ipol)
313 CALL section_vals_val_get(multipole_section, "EPS_POL", r_val=ewald_env%eps_pol)
314 IF (ewald_env%do_multipoles) THEN
315 SELECT CASE (ewald_env%ewald_type)
316 CASE (do_ewald_ewald)
317 CALL section_vals_val_get(multipole_section, "MAX_MULTIPOLE_EXPANSION", &
318 i_val=ewald_env%max_multipole)
319 CALL section_vals_val_get(multipole_section, "MAX_IPOL_ITER", i_val=ewald_env%max_ipol_iter)
320 CASE DEFAULT
321 cpabort("Multipole code works at the moment only with standard EWALD sums.")
322 END SELECT
323 END IF
324
325 iw = cp_print_key_unit_nr(logger, ewald_section, "PRINT%PROGRAM_RUN_INFO", &
326 extension=".log")
327 IF (iw > 0) THEN
328 NULLIFY (keyword, enum)
329 CALL create_ewald_section(section)
330 IF (ewald_env%ewald_type /= do_ewald_none) THEN
331 keyword => section_get_keyword(section, "EWALD_TYPE")
332 CALL keyword_get(keyword, enum=enum)
333 WRITE (iw, '(/,T2,"EWALD| ",A,T67,A14 )') 'Summation is done by:', &
334 adjustr(trim(enum_i2c(enum, ewald_env%ewald_type)))
335 IF (ewald_env%do_multipoles) THEN
336 NULLIFY (keyword, enum)
337 keyword => section_get_keyword(section, "MULTIPOLES%MAX_MULTIPOLE_EXPANSION")
338 CALL keyword_get(keyword, enum=enum)
339 WRITE (iw, '( T2,"EWALD| ",A )') 'Enabled Multipole Method'
340 WRITE (iw, '( T2,"EWALD| ",A,T67,A14 )') 'Max Term in Multipole Expansion :', &
341 adjustr(trim(enum_i2c(enum, ewald_env%max_multipole)))
342 WRITE (iw, '( T2,"EWALD| ",A,T67,3I10 )') 'Max number Iterations for IPOL :', &
343 ewald_env%max_ipol_iter
344 END IF
345 dummy = cp_unit_from_cp2k(ewald_env%alpha, "angstrom^-1")
346 WRITE (iw, '( T2,"EWALD| ",A,A18,A,T71,F10.4 )') &
347 'Alpha parameter [', 'ANGSTROM^-1', ']', dummy
348 dummy = cp_unit_from_cp2k(ewald_env%rcut, "angstrom")
349 WRITE (iw, '( T2,"EWALD| ",A,A18,A,T71,F10.4 )') &
350 'Real Space Cutoff [', 'ANGSTROM', ']', dummy
351
352 SELECT CASE (ewald_env%ewald_type)
353 CASE (do_ewald_ewald)
354 WRITE (iw, '( T2,"EWALD| ",A,T51,3I10 )') &
355 'G-space max. Miller index', ewald_env%gmax
356 CASE (do_ewald_pme)
357 WRITE (iw, '( T2,"EWALD| ",A,T71,I10 )') &
358 'Max small-grid points (input) ', ewald_env%ns_max
359 WRITE (iw, '( T2,"EWALD| ",A,T71,E10.4 )') &
360 'Gaussian tolerance (input) ', ewald_env%epsilon
361 CASE (do_ewald_spme)
362 WRITE (iw, '( T2,"EWALD| ",A,T51,3I10 )') &
363 'G-space max. Miller index', ewald_env%gmax
364 WRITE (iw, '( T2,"EWALD| ",A,T71,I10 )') &
365 'Spline interpolation order ', ewald_env%o_spline
366 CASE DEFAULT
367 cpabort("")
368 END SELECT
369 ELSE
370 WRITE (iw, '( T2,"EWALD| ",T73, A )') 'not used'
371 END IF
372 CALL section_release(section)
373 END IF
374 CALL cp_print_key_finished_output(iw, logger, ewald_section, &
375 "PRINT%PROGRAM_RUN_INFO")
376
377 END SUBROUTINE read_ewald_section
378
379! **************************************************************************************************
380!> \brief Purpose: read the EWALD section for TB methods
381!> \param ewald_env the pointer to the ewald_env
382!> \param ewald_section ...
383!> \param hmat ...
384!> \param silent ...
385!> \param pset ...
386!> \author JGH
387! **************************************************************************************************
388 SUBROUTINE read_ewald_section_tb(ewald_env, ewald_section, hmat, silent, pset)
389 TYPE(ewald_environment_type), INTENT(INOUT) :: ewald_env
390 TYPE(section_vals_type), POINTER :: ewald_section
391 REAL(kind=dp), DIMENSION(3, 3), INTENT(IN) :: hmat
392 LOGICAL, INTENT(IN), OPTIONAL :: silent
393 CHARACTER(LEN=*), OPTIONAL :: pset
394
395 CHARACTER(LEN=5) :: param
396 INTEGER :: i, iw, n(3)
397 INTEGER, DIMENSION(:), POINTER :: gmax_read
398 LOGICAL :: do_print, explicit
399 REAL(kind=dp) :: alat, cutoff, dummy, omega
400 TYPE(cp_logger_type), POINTER :: logger
401
402 logger => cp_get_default_logger()
403 do_print = .true.
404 IF (PRESENT(silent)) do_print = .NOT. silent
405 param = "none"
406 IF (PRESENT(pset)) param = pset
407
408 ewald_env%do_multipoles = .false.
409 ewald_env%do_ipol = 0
410 ewald_env%eps_pol = 1.e-12_dp
411 ewald_env%max_multipole = 0
412 ewald_env%max_ipol_iter = 0
413 ewald_env%epsilon = 1.e-12_dp
414 ewald_env%ns_max = huge(0)
415
416 CALL section_vals_val_get(ewald_section, "EWALD_TYPE", explicit=explicit)
417 IF (explicit) THEN
418 CALL section_vals_val_get(ewald_section, "EWALD_TYPE", i_val=ewald_env%ewald_type)
419 IF (ewald_env%ewald_type /= do_ewald_spme) THEN
420 cpabort("TB needs EWALD_TYPE SPME")
421 END IF
422 ELSE
423 ewald_env%ewald_type = do_ewald_spme
424 END IF
425
426 CALL section_vals_val_get(ewald_section, "ALPHA", explicit=explicit)
427 IF (explicit) THEN
428 CALL section_vals_val_get(ewald_section, "ALPHA", r_val=ewald_env%alpha)
429 ELSE
430 SELECT CASE (param)
431 CASE DEFAULT
432 ewald_env%alpha = 1.0_dp
433 CASE ("EEQ")
434 omega = abs(det_3x3(hmat))
435 ewald_env%alpha = sqrt(twopi)/omega**(1./3.)
436 END SELECT
437 END IF
438
439 CALL section_vals_val_get(ewald_section, "EWALD_ACCURACY", explicit=explicit)
440 IF (explicit) THEN
441 CALL section_vals_val_get(ewald_section, "EWALD_ACCURACY", r_val=ewald_env%precs)
442 ELSE
443 CALL section_vals_val_get(ewald_section, "EWALD_ACCURACY", r_val=ewald_env%precs)
444 END IF
445
446 CALL section_vals_val_get(ewald_section, "O_SPLINE", explicit=explicit)
447 IF (explicit) THEN
448 CALL section_vals_val_get(ewald_section, "O_SPLINE", i_val=ewald_env%o_spline)
449 ELSE
450 SELECT CASE (param)
451 CASE DEFAULT
452 ewald_env%o_spline = 6
453 CASE ("EEQ")
454 ewald_env%o_spline = 4
455 END SELECT
456 END IF
457
458 CALL section_vals_val_get(ewald_section, "RCUT", explicit=explicit)
459 IF (explicit) THEN
460 CALL section_vals_val_get(ewald_section, "RCUT", r_val=ewald_env%rcut)
461 ELSE
462 ewald_env%rcut = find_ewald_optimal_value(ewald_env%precs)/ewald_env%alpha
463 END IF
464
465 CALL section_vals_val_get(ewald_section, "GMAX", explicit=explicit)
466 IF (explicit) THEN
467 CALL section_vals_val_get(ewald_section, "GMAX", i_vals=gmax_read)
468 SELECT CASE (SIZE(gmax_read, 1))
469 CASE (1)
470 ewald_env%gmax = gmax_read(1)
471 CASE (3)
472 ewald_env%gmax = gmax_read
473 CASE DEFAULT
474 cpabort("")
475 END SELECT
476 ELSE
477 SELECT CASE (param)
478 CASE DEFAULT
479 ! set GMAX using ECUT=alpha*45 Ry
480 cutoff = 45._dp*ewald_env%alpha
481 CASE ("EEQ")
482 ! set GMAX using ECUT=alpha*45 Ry
483 cutoff = 30._dp*ewald_env%alpha
484 END SELECT
485 DO i = 1, 3
486 alat = sum(hmat(:, i)**2)
487 cpassert(alat /= 0._dp)
488 ewald_env%gmax(i) = 2*floor(sqrt(2.0_dp*cutoff*alat)/twopi) + 1
489 END DO
490 END IF
491 n = ewald_env%gmax
492 ewald_env%gmax = pw_grid_n_for_fft(n, odd=.true.)
493
494 iw = cp_print_key_unit_nr(logger, ewald_section, "PRINT%PROGRAM_RUN_INFO", &
495 extension=".log")
496 IF (iw > 0 .AND. do_print) THEN
497 WRITE (iw, '(/,T2,"EWALD| ",A,T67,A14 )') 'Summation is done by:', adjustr("SPME")
498 dummy = cp_unit_from_cp2k(ewald_env%alpha, "angstrom^-1")
499 WRITE (iw, '( T2,"EWALD| ",A,A18,A,T71,F10.4 )') &
500 'Alpha parameter [', 'ANGSTROM^-1', ']', dummy
501 dummy = cp_unit_from_cp2k(ewald_env%rcut, "angstrom")
502 WRITE (iw, '( T2,"EWALD| ",A,A18,A,T71,F10.4 )') &
503 'Real Space Cutoff [', 'ANGSTROM', ']', dummy
504 WRITE (iw, '( T2,"EWALD| ",A,T51,3I10 )') &
505 'G-space max. Miller index', ewald_env%gmax
506 WRITE (iw, '( T2,"EWALD| ",A,T71,I10 )') &
507 'Spline interpolation order ', ewald_env%o_spline
508 END IF
509 CALL cp_print_key_finished_output(iw, logger, ewald_section, &
510 "PRINT%PROGRAM_RUN_INFO")
511
512 END SUBROUTINE read_ewald_section_tb
513
514! **************************************************************************************************
515!> \brief triggers (by bisection) the optimal value for EWALD parameter x
516!> EXP(-x^2)/x^2 = EWALD_ACCURACY
517!> \param precs ...
518!> \return ...
519!> \author Teodoro Laino [tlaino] - University of Zurich - 12.2007
520! **************************************************************************************************
521 FUNCTION find_ewald_optimal_value(precs) RESULT(value)
522 REAL(kind=dp) :: precs, value
523
524 REAL(kind=dp) :: func, func1, func2, s, s1, s2
525
526 s = 0.1_dp
527 func = exp(-s**2)/s**2 - precs
528 cpassert(func > 0.0_dp)
529 DO WHILE (func > 0.0_dp)
530 s = s + 0.1_dp
531 func = exp(-s**2)/s**2 - precs
532 END DO
533 s2 = s
534 s1 = s - 0.1_dp
535 ! Start bisection
536 DO WHILE (.true.)
537 func2 = exp(-s2**2)/s2**2 - precs
538 func1 = exp(-s1**2)/s1**2 - precs
539 cpassert(func1 >= 0)
540 cpassert(func2 <= 0)
541 s = 0.5_dp*(s1 + s2)
542 func = exp(-s**2)/s**2 - precs
543 IF (func > 0.0_dp) THEN
544 s1 = s
545 ELSE IF (func < 0.0_dp) THEN
546 s2 = s
547 END IF
548 IF (abs(func) < 100.0_dp*epsilon(0.0_dp)) EXIT
549 END DO
550 value = s
551 END FUNCTION find_ewald_optimal_value
552
554
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,...
unit conversion facility
Definition cp_units.F:30
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Definition cp_units.F:1179
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(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 read_ewald_section_tb(ewald_env, ewald_section, hmat, silent, pset)
Purpose: read the EWALD section for TB methods.
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.
function that build the poisson section of the input
subroutine, public create_ewald_section(section)
...
represents an enumeration, i.e. a mapping between integers and strings
character(len=default_string_length) function, public enum_i2c(enum, i)
maps an integer to a string
represents keywords in an input
subroutine, public keyword_get(keyword, names, usage, description, type_of_var, n_var, default_value, lone_keyword_value, repeats, enum, citations)
...
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_retain(section_vals)
retains the given section values (see doc/ReferenceCounting.html)
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
recursive subroutine, public section_release(section)
releases the given keyword list (see doc/ReferenceCounting.html)
recursive type(keyword_type) function, pointer, public section_get_keyword(section, keyword_name)
returns the requested keyword
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
recursive subroutine, public section_vals_release(section_vals)
releases the given object
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 twopi
Collection of simple mathematical functions and subroutines.
Definition mathlib.F:15
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
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represent a keyword in the input
represent a section of the input file
stores all the informations relevant to an mpi environment