(git:c51e757)
Loading...
Searching...
No Matches
input_cp2k_hfx.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief function that builds the hartree fock exchange section of the input
10!> \par History
11!> 09.2007 created
12!> \author Manuel Guidon
13! **************************************************************************************************
15 USE bibliography, ONLY: guidon2008, &
16 guidon2009, &
22 USE input_constants, ONLY: &
36 USE input_val_types, ONLY: real_t
37 USE kinds, ONLY: dp
38 USE string_utilities, ONLY: s2a
39
40#include "./base/base_uses.f90"
41
42 IMPLICIT NONE
43 PRIVATE
44
45 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .false.
46 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_hfx'
47 INTEGER, PARAMETER, PUBLIC :: ri_mo = 1, ri_pmat = 2
48
49 PUBLIC :: create_hfx_section
50
51CONTAINS
52
53! **************************************************************************************************
54!> \brief creates the input section for the hf part
55!> \param section the section to create
56!> \author Manuel Guidon
57! **************************************************************************************************
58 SUBROUTINE create_hfx_section(section)
59 TYPE(section_type), POINTER :: section
60
61 TYPE(keyword_type), POINTER :: keyword
62 TYPE(section_type), POINTER :: print_key, subsection
63
64 cpassert(.NOT. ASSOCIATED(section))
65 CALL section_create(section, __location__, name="HF", &
66 description="Controls Hartree-Fock exchange for hybrid DFT, Hartree-Fock, "// &
67 "and related post-Hartree-Fock workflows.", &
68 n_keywords=5, n_subsections=2, repeats=.true., &
69 citations=[guidon2008, guidon2009])
70
71 NULLIFY (keyword, print_key, subsection)
72
73 CALL keyword_create(keyword, __location__, name="FRACTION", &
74 description="Fraction of Hartree-Fock exchange to add to the total energy. "// &
75 "1.0 implies standard Hartree-Fock if used with XC_FUNCTIONAL NONE. "// &
76 "NOTE: In a mixed potential calculation this should be set to 1.0, otherwise "// &
77 "all parts are multiplied with this factor. ", &
78 usage="FRACTION 1.0", default_r_val=1.0_dp)
79 CALL section_add_keyword(section, keyword)
80 CALL keyword_release(keyword)
81
82 CALL keyword_create(keyword, __location__, name="TREAT_LSD_IN_CORE", &
83 description="Determines how spin densities are taken into account. "// &
84 "If true, the beta spin density is included via a second in core call. "// &
85 "If false, alpha and beta spins are done in one shot ", &
86 usage="TREAT_LSD_IN_CORE TRUE", default_l_val=.false.)
87 CALL section_add_keyword(section, keyword)
88 CALL keyword_release(keyword)
89
90 CALL keyword_create( &
91 keyword, __location__, &
92 name="HFX_LIBRARY", &
93 description="Which library should be used in the calculation of the HF exchange "// &
94 "(Libint (cpu, default), libGint(gpu, cuda), both(debug,temporary)", &
95 usage="HFX_LIBRARY libGint", &
96 enum_c_vals=s2a("libint", "libGint", "both"), &
98 enum_desc=s2a("libint: use the libint library to compute the 2 electron integrals for HFX/r", &
99 "libGint: use the libGint library to accelerate the calculation of the HF "// &
100 "exchange on (cuda) GPUs /r", &
101 "both: temporary debug option, will run both libint and libGint and "// &
102 "check if the fock matrix is within tolerance"), &
103 default_i_val=hfx_library_is_libint)
104 CALL section_add_keyword(section, keyword)
105 CALL keyword_release(keyword)
106
107 CALL keyword_create(keyword, __location__, name="PW_HFX", &
108 description="Compute the Hartree-Fock energy also in the plane wave basis. "// &
109 "The value is ignored, and intended for debugging only.", &
110 usage="PW_HFX FALSE", default_l_val=.false., lone_keyword_l_val=.true.)
111 CALL section_add_keyword(section, keyword)
112 CALL keyword_release(keyword)
113
114 CALL keyword_create(keyword, __location__, name="PW_HFX_BLOCKSIZE", &
115 description="Improve the performance of pw_hfx at the cost of some additional memory "// &
116 "by storing the realspace representation of PW_HFX_BLOCKSIZE states.", &
117 usage="PW_HFX_BLOCKSIZE 20", default_i_val=20)
118 CALL section_add_keyword(section, keyword)
119 CALL keyword_release(keyword)
120
121 NULLIFY (print_key)
122 CALL cp_print_key_section_create(print_key, __location__, "HF_INFO", &
123 description="Controls the printing basic info about hf method", &
124 print_level=medium_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
125 CALL section_add_subsection(section, print_key)
126 CALL section_release(print_key)
127
128 CALL create_hf_pbc_section(subsection)
129 CALL section_add_subsection(section, subsection)
130 CALL section_release(subsection)
131
132 CALL create_hf_screening_section(subsection)
133 CALL section_add_subsection(section, subsection)
134 CALL section_release(subsection)
135
136 CALL create_hf_potential_section(subsection)
137 CALL section_add_subsection(section, subsection)
138 CALL section_release(subsection)
139
140 CALL create_hf_load_balance_section(subsection)
141 CALL section_add_subsection(section, subsection)
142 CALL section_release(subsection)
143
144 CALL create_hf_memory_section(subsection)
145 CALL section_add_subsection(section, subsection)
146 CALL section_release(subsection)
147
148 CALL create_hf_ri_section(subsection)
149 CALL section_add_subsection(section, subsection)
150 CALL section_release(subsection)
151
152 CALL create_hf_ace_section(subsection)
153 CALL section_add_subsection(section, subsection)
154 CALL section_release(subsection)
155
156 END SUBROUTINE create_hfx_section
157
158! **************************************************************************************************
159!> \brief !****f* input_cp2k_dft/create_hf_load_balance_section [1.0] *
160!>
161!> creates the input section for the hf potential part
162!> \param section the section to create
163!> \author Manuel Guidon
164! **************************************************************************************************
165 SUBROUTINE create_hf_load_balance_section(section)
166 TYPE(section_type), POINTER :: section
167
168 TYPE(keyword_type), POINTER :: keyword
169 TYPE(section_type), POINTER :: print_key
170
171 cpassert(.NOT. ASSOCIATED(section))
172 CALL section_create(section, __location__, name="LOAD_BALANCE", &
173 description="Parameters influencing the load balancing of the HF", &
174 n_keywords=1, n_subsections=0, repeats=.false., &
175 citations=[guidon2008])
176
177 NULLIFY (keyword)
178 CALL keyword_create( &
179 keyword, __location__, &
180 name="NBINS", &
181 description="Number of bins per process used to group atom quartets.", &
182 usage="NBINS 32", &
183 default_i_val=64)
184 CALL section_add_keyword(section, keyword)
185 CALL keyword_release(keyword)
186
187 CALL keyword_create( &
188 keyword, __location__, &
189 name="BLOCK_SIZE", &
190 description="Determines the blocking used for the atomic quartet loops. "// &
191 "A proper choice can speedup the calculation. The default (-1) is automatic.", &
192 usage="BLOCK_SIZE 4", &
193 default_i_val=-1)
194 CALL section_add_keyword(section, keyword)
195 CALL keyword_release(keyword)
196
197 NULLIFY (keyword)
198 CALL keyword_create( &
199 keyword, __location__, &
200 name="RANDOMIZE", &
201 description="This flag controls the randomization of the bin assignment to processes. "// &
202 "For highly ordered input structures with a bad load balance, setting "// &
203 "this flag to TRUE might improve.", &
204 usage="RANDOMIZE TRUE", &
205 default_l_val=.false.)
206 CALL section_add_keyword(section, keyword)
207 CALL keyword_release(keyword)
208
209 NULLIFY (print_key)
210 CALL cp_print_key_section_create(print_key, __location__, "PRINT", &
211 description="Controls the printing of info about load balance", &
212 print_level=medium_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
213 CALL section_add_subsection(section, print_key)
214
215 CALL keyword_release(keyword)
216 CALL keyword_create(keyword, __location__, &
217 name="LOAD_BALANCE_INFO", &
218 description="Activates the printing of load balance information ", &
219 default_l_val=.false., &
220 lone_keyword_l_val=.true.)
221 CALL section_add_keyword(print_key, keyword)
222 CALL keyword_release(keyword)
223 CALL section_release(print_key)
224
225 END SUBROUTINE create_hf_load_balance_section
226
227! **************************************************************************************************
228!> \brief !****f* input_cp2k_dft/create_hf_potential_section [1.0] *
229!>
230!> creates the input section for the hf potential part
231!> \param section the section to create
232!> \author Manuel Guidon
233! **************************************************************************************************
234 SUBROUTINE create_hf_potential_section(section)
235 TYPE(section_type), POINTER :: section
236
237 TYPE(keyword_type), POINTER :: keyword
238
239 cpassert(.NOT. ASSOCIATED(section))
240 CALL section_create(section, __location__, name="INTERACTION_POTENTIAL", &
241 description="Defines the Coulomb, range-separated, mixed, or truncated interaction "// &
242 "operator used for Hartree-Fock exchange.", &
243 n_keywords=1, n_subsections=0, repeats=.false., &
244 citations=[guidon2008, guidon2009])
245
246 NULLIFY (keyword)
247 CALL keyword_create( &
248 keyword, __location__, &
249 name="POTENTIAL_TYPE", &
250 description="Selects the interaction potential used for Hartree-Fock exchange. "// &
251 "Periodic hybrid calculations commonly use a short-range, truncated, or mixed potential.", &
252 usage="POTENTIAL_TYPE SHORTRANGE", &
253 enum_c_vals=s2a("COULOMB", "SHORTRANGE", "LONGRANGE", "MIX_CL", "GAUSSIAN", &
254 "MIX_LG", "IDENTITY", "TRUNCATED", "MIX_CL_TRUNC"), &
258 enum_desc=s2a("Coulomb potential: $\frac{1}{r}$", &
259 "Shortrange potential: $\frac{\mathrm{erfc}(\omega \cdot r)}{r}$", &
260 "Longrange potential: $\frac{\mathrm{erf}(\omega \cdot r)}{r}$", &
261 "Mix coulomb and longrange potential: $\frac{1}{r} + \frac{\mathrm{erf}(\omega \cdot r)}{r}$", &
262 "Damped Gaussian potential: $\exp{(-\omega^2 \cdot r^2)}$", &
263 "Mix Gaussian and longrange potential: "// &
264 "$\frac{\mathrm{erf}(\omega \cdot r)}{r} + \exp{(-\omega^2 \cdot r^2)}$", &
265 "Overlap", &
266 "Truncated coulomb potential: if (r &lt; R_c) 1/r else 0", &
267 "Truncated Mix coulomb and longrange potential, assumes/requires that the erf has fully decayed at R_c"), &
268 default_i_val=do_potential_coulomb)
269 CALL section_add_keyword(section, keyword)
270 CALL keyword_release(keyword)
271
272 NULLIFY (keyword)
273 CALL keyword_create( &
274 keyword, __location__, &
275 name="OMEGA", &
276 description="Parameter $\omega$ for short/longrange interaction", &
277 usage="OMEGA 0.5", &
278 default_r_val=0.0_dp)
279 CALL section_add_keyword(section, keyword)
280 CALL keyword_release(keyword)
281
282 CALL keyword_create(keyword, __location__, name="SCALE_COULOMB", &
283 description="Scales Hartree-Fock contribution arising from a coulomb potential. "// &
284 "Only valid when doing a mixed potential calculation", &
285 usage="SCALE_COULOMB 1.0", default_r_val=1.0_dp)
286 CALL section_add_keyword(section, keyword)
287 CALL keyword_release(keyword)
288
289 CALL keyword_create(keyword, __location__, name="SCALE_LONGRANGE", &
290 description="Scales Hartree-Fock contribution arising from a longrange potential. "// &
291 "Only valid when doing a mixed potential calculation", &
292 usage="SCALE_LONGRANGE 1.0", default_r_val=1.0_dp)
293 CALL section_add_keyword(section, keyword)
294 CALL keyword_release(keyword)
295
296 CALL keyword_create(keyword, __location__, name="SCALE_GAUSSIAN", &
297 description="Scales Hartree-Fock contribution arising from a gaussian potential. "// &
298 "Only valid when doing a mixed potential calculation", &
299 usage="SCALE_GAUSSIAN 1.0", default_r_val=1.0_dp)
300 CALL section_add_keyword(section, keyword)
301 CALL keyword_release(keyword)
302
303 CALL keyword_create(keyword, __location__, name="CUTOFF_RADIUS", &
304 description="Cutoff radius for the truncated $\frac{1}{r}$ potential or the short-range "// &
305 "$\frac{\mathrm{erfc}(\omega \cdot r)}{r}$ potential. For truncated Coulomb in a "// &
306 "periodic cell, choose a radius compatible with the cell dimensions. The default value "// &
307 "for short-range potentials when this keyword is omitted is solved from "// &
308 "$\frac{\mathrm{erfc}(\omega \cdot r)}{r} = \epsilon_{\mathrm{schwarz}}$ "// &
309 "by Newton-Raphson method, with $\epsilon_{\mathrm{schwarz}}$ set by SCREENING/EPS_SCHWARZ", &
310 usage="CUTOFF_RADIUS 10.0", type_of_var=real_t, & ! default_r_val=10.0_dp,&
311 unit_str="angstrom")
312 CALL section_add_keyword(section, keyword)
313 CALL keyword_release(keyword)
314
315 CALL keyword_create( &
316 keyword, __location__, &
317 name="T_C_G_DATA", &
318 description="Location of the file t_c_g.dat that contains the data for the "// &
319 "evaluation of the truncated gamma function ", &
320 usage="T_C_G_DATA /data/t_c_g.dat", &
321 default_c_val="t_c_g.dat")
322 CALL section_add_keyword(section, keyword)
323 CALL keyword_release(keyword)
324
325 END SUBROUTINE create_hf_potential_section
326
327!****f* input_cp2k_dft/create_hf_screening_section [1.0] *
328
329! **************************************************************************************************
330!> \brief creates the input section for the hf screening part
331!> \param section the section to create
332!> \author Manuel Guidon
333! **************************************************************************************************
334 SUBROUTINE create_hf_screening_section(section)
335 TYPE(section_type), POINTER :: section
336
337 TYPE(keyword_type), POINTER :: keyword
338
339 cpassert(.NOT. ASSOCIATED(section))
340 CALL section_create(section, __location__, name="SCREENING", &
341 description="Controls screening thresholds for Hartree-Fock exchange integrals.", &
342 n_keywords=1, n_subsections=0, repeats=.false., &
343 citations=[guidon2008, guidon2009])
344
345 NULLIFY (keyword)
346 CALL keyword_create( &
347 keyword, __location__, &
348 name="EPS_SCHWARZ", &
349 description="Schwarz inequality threshold for screening near-field electronic repulsion integrals. "// &
350 "Tighter values reduce screening error but increase cost.", &
351 usage="EPS_SCHWARZ 1.0E-6", &
352 default_r_val=1.0e-10_dp)
353 CALL section_add_keyword(section, keyword)
354 CALL keyword_release(keyword)
355
356 NULLIFY (keyword)
357 CALL keyword_create( &
358 keyword, __location__, &
359 name="EPS_SCHWARZ_FORCES", &
360 description="Schwarz threshold used for force-related electronic repulsion integrals. "// &
361 "This is approximately the force accuracy and should normally be similar to EPS_SCF. "// &
362 "Default value is 100*EPS_SCHWARZ.", &
363 usage="EPS_SCHWARZ_FORCES 1.0E-5", &
364 default_r_val=1.0e-6_dp)
365 CALL section_add_keyword(section, keyword)
366 CALL keyword_release(keyword)
367
368 NULLIFY (keyword)
369 CALL keyword_create( &
370 keyword, __location__, &
371 name="SCREEN_P_FORCES", &
372 description="Screens the electronic repulsion integrals for the forces "// &
373 "using the density matrix. Will be disabled for the "// &
374 "response part of forces in MP2/RPA/TDDFT. "// &
375 "This results in a significant speedup for large systems, "// &
376 "but might require a somewhat tigher EPS_SCHWARZ_FORCES.", &
377 usage="SCREEN_P_FORCES TRUE", &
378 default_l_val=.true.)
379 CALL section_add_keyword(section, keyword)
380 CALL keyword_release(keyword)
381
382 NULLIFY (keyword)
383 CALL keyword_create(keyword, __location__, name="SCREEN_ON_INITIAL_P", &
384 description="Screen on an initial density matrix. For the first MD step"// &
385 " this matrix must be provided by a Restart File.", &
386 usage="SCREEN_ON_INITIAL_P TRUE", default_l_val=.false.)
387 CALL section_add_keyword(section, keyword)
388 CALL keyword_release(keyword)
389
390 NULLIFY (keyword)
391 CALL keyword_create(keyword, __location__, name="P_SCREEN_CORRECTION_FACTOR", &
392 description="Recalculates integrals on the fly if the actual density matrix is"// &
393 " larger by a given factor than the initial one. If the factor is set"// &
394 " to 0.0_dp, this feature is disabled.", &
395 usage="P_SCREEN_CORRECTION_FACTOR 0.0_dp", default_r_val=0.0_dp)
396 CALL section_add_keyword(section, keyword)
397 CALL keyword_release(keyword)
398
399 END SUBROUTINE create_hf_screening_section
400
401! **************************************************************************************************
402!> \brief creates the input section for the hf-pbc part
403!> \param section the section to create
404!> \author Manuel Guidon
405! **************************************************************************************************
406 SUBROUTINE create_hf_pbc_section(section)
407 TYPE(section_type), POINTER :: section
408
409 TYPE(keyword_type), POINTER :: keyword
410
411 cpassert(.NOT. ASSOCIATED(section))
412 CALL section_create(section, __location__, name="PERIODIC", &
413 description="Sets up periodic boundary condition parameters if requested ", &
414 n_keywords=1, n_subsections=0, repeats=.false., &
415 citations=[guidon2008, guidon2009])
416 NULLIFY (keyword)
417 CALL keyword_create( &
418 keyword, __location__, &
419 name="NUMBER_OF_SHELLS", &
420 description="Number of shells taken into account for periodicity. "// &
421 "By default, cp2k tries to automatically evaluate this number. "// &
422 "This algorithm might be to conservative, resulting in some overhead. "// &
423 "You can try to adjust this number in order to make a calculation cheaper. ", &
424 usage="NUMBER_OF_SHELLS 2", &
425 default_i_val=-1)
426 CALL section_add_keyword(section, keyword)
427 CALL keyword_release(keyword)
428
429 END SUBROUTINE create_hf_pbc_section
430
431! **************************************************************************************************
432!> \brief creates the input section for the hf-memory part
433!> \param section the section to create
434!> \author Manuel Guidon
435! **************************************************************************************************
436 SUBROUTINE create_hf_memory_section(section)
437 TYPE(section_type), POINTER :: section
438
439 TYPE(keyword_type), POINTER :: keyword
440
441 cpassert(.NOT. ASSOCIATED(section))
442 CALL section_create(section, __location__, name="MEMORY", &
443 description="Sets up memory parameters for the storage of the ERI's if requested ", &
444 n_keywords=1, n_subsections=0, repeats=.false., &
445 citations=[guidon2008])
446 NULLIFY (keyword)
447 CALL keyword_create( &
448 keyword, __location__, &
449 name="EPS_STORAGE_SCALING", &
450 variants=["EPS_STORAGE"], &
451 description="Scaling factor to scale eps_schwarz. Storage threshold for compression "// &
452 "will be EPS_SCHWARZ*EPS_STORAGE_SCALING.", &
453 usage="EPS_STORAGE 1.0E-2", &
454 default_r_val=1.0e0_dp)
455 CALL section_add_keyword(section, keyword)
456 CALL keyword_release(keyword)
457
458 CALL keyword_create( &
459 keyword, __location__, &
460 name="MAX_MEMORY", &
461 description="Defines the maximum amount of memory [MiB] to be consumed by the full HFX module. "// &
462 "All temporary buffers and helper arrays are subtracted from this number. "// &
463 "What remains will be used for storage of integrals. NOTE: This number "// &
464 "is assumed to represent the memory available to one MPI process. "// &
465 "When running a threaded version, cp2k automatically takes care of "// &
466 "distributing the memory among all the threads within a process.", &
467 usage="MAX_MEMORY 256", &
468 default_i_val=512)
469 CALL section_add_keyword(section, keyword)
470 CALL keyword_release(keyword)
471
472 CALL keyword_create( &
473 keyword, __location__, &
474 name="STORAGE_LOCATION", &
475 description="Loaction where ERI's are stored if MAX_DISK_SPACE /=0 "// &
476 "Expects a path to a directory. ", &
477 usage="STORAGE_LOCATION /data/scratch", &
478 default_c_val=".")
479 CALL section_add_keyword(section, keyword)
480 CALL keyword_release(keyword)
481
482 CALL keyword_create( &
483 keyword, __location__, &
484 name="MAX_DISK_SPACE", &
485 description="Defines the maximum amount of disk space [MiB] used to store precomputed "// &
486 "compressed four-center integrals. If 0, nothing is stored to disk", &
487 usage="MAX_DISK_SPACE 256", &
488 default_i_val=0)
489 CALL section_add_keyword(section, keyword)
490 CALL keyword_release(keyword)
491
492 CALL keyword_create(keyword, __location__, name="TREAT_FORCES_IN_CORE", &
493 description="Determines whether the derivative ERI's should be stored to RAM or not. "// &
494 "Only meaningful when performing Ehrenfest MD. "// &
495 "Memory usage is defined via MAX_MEMORY, i.e. the memory is shared wit the energy ERI's.", &
496 usage="TREAT_FORCES_IN_CORE TRUE", default_l_val=.false.)
497 CALL section_add_keyword(section, keyword)
498 CALL keyword_release(keyword)
499
500 END SUBROUTINE create_hf_memory_section
501
502! **************************************************************************************************
503!> \brief ...
504!> \param section ...
505! **************************************************************************************************
506 SUBROUTINE create_hf_ri_section(section)
507 TYPE(section_type), POINTER :: section
508
509 TYPE(keyword_type), POINTER :: keyword
510 TYPE(section_type), POINTER :: print_key, subsection
511
512 NULLIFY (keyword, print_key, subsection)
513
514 cpassert(.NOT. ASSOCIATED(section))
515 CALL section_create(section, __location__, name="RI", &
516 description="Parameters for RI methods in HFX, including RI-HFXk with "// &
517 "k-point sampling. All keywords relevant to RI-HFXk have an "// &
518 "alias starting with KP_")
519
520 CALL keyword_create(keyword, __location__, name="_SECTION_PARAMETERS_", &
521 description="controls the activation of RI", &
522 usage="&RI T", &
523 default_l_val=.false., &
524 lone_keyword_l_val=.true.)
525 CALL section_add_keyword(section, keyword)
526 CALL keyword_release(keyword)
527
528 CALL keyword_create(keyword, __location__, name="EPS_FILTER", &
529 description="Filter threshold for DBT tensor contraction.", &
530 variants=["KP_EPS_FILTER"], &
531 default_r_val=1.0e-09_dp)
532 CALL section_add_keyword(section, keyword)
533 CALL keyword_release(keyword)
534
535 CALL keyword_create(keyword, __location__, name="EPS_FILTER_2C", &
536 description="Filter threshold for 2c integrals. Default should be kept.", &
537 default_r_val=1.0e-12_dp)
538 CALL section_add_keyword(section, keyword)
539 CALL keyword_release(keyword)
540
541 CALL keyword_create(keyword, __location__, &
542 name="EPS_STORAGE_SCALING", &
543 description="Scaling factor to scale EPS_FILTER for storage of 3-center integrals. Storage threshold "// &
544 "will be EPS_FILTER*EPS_STORAGE_SCALING.", &
545 default_r_val=0.01_dp)
546 CALL section_add_keyword(section, keyword)
547 CALL keyword_release(keyword)
548
549 CALL keyword_create(keyword, __location__, name="EPS_FILTER_MO", &
550 description="Filter threshold for contraction of 3-center integrals with MOs. "// &
551 "Default should be kept.", &
552 default_r_val=1.0e-12_dp)
553 CALL section_add_keyword(section, keyword)
554 CALL keyword_release(keyword)
555
556 CALL keyword_create(keyword, __location__, name="OMEGA", &
557 description="The range parameter for the short range operator (in 1/a0). "// &
558 "Default is OMEGA from INTERACTION_POTENTIAL. ", &
559 variants=["KP_OMEGA"], &
560 default_r_val=0.0_dp, &
561 repeats=.false.)
562 CALL section_add_keyword(section, keyword)
563 CALL keyword_release(keyword)
564
565 CALL keyword_create(keyword, __location__, name="CUTOFF_RADIUS", &
566 description="The cutoff radius (in Angstroms) for the truncated Coulomb operator. "// &
567 "Default is CUTOFF_RADIUS from INTERACTION_POTENTIAL. ", &
568 variants=["KP_CUTOFF_RADIUS"], &
569 default_r_val=0.0_dp, &
570 repeats=.false., &
571 unit_str="angstrom")
572 CALL section_add_keyword(section, keyword)
573 CALL keyword_release(keyword)
574
575 CALL keyword_create(keyword, __location__, name="SCALE_COULOMB", &
576 description="Scales Hartree-Fock contribution arising from a coulomb potential. "// &
577 "Only valid when doing a mixed potential calculation. "// &
578 "Default is SCALE_COULOMB from INTERACTION_POTENTIAL", &
579 usage="SCALE_COULOMB 1.0", default_r_val=1.0_dp)
580 CALL section_add_keyword(section, keyword)
581 CALL keyword_release(keyword)
582
583 CALL keyword_create(keyword, __location__, name="SCALE_LONGRANGE", &
584 description="Scales Hartree-Fock contribution arising from a longrange potential. "// &
585 "Only valid when doing a mixed potential calculation. "// &
586 "Default if SCALE_LONGRANGE from INTERACTION_POTENTIAL", &
587 usage="SCALE_LONGRANGE 1.0", default_r_val=1.0_dp)
588 CALL section_add_keyword(section, keyword)
589 CALL keyword_release(keyword)
590
591 CALL keyword_create(keyword, __location__, name="KP_NGROUPS", &
592 description="The number of MPI subgroup that work in parallel during the SCF. "// &
593 "The default value is 1. Using N subgroups should speed up the "// &
594 "calculation by a factor ~N, at the cost of N times more memory usage.", &
595 variants=["NGROUPS"], &
596 usage="KP_NGROUPS {int}", &
597 repeats=.false., &
598 default_i_val=1)
599 CALL section_add_keyword(section, keyword)
600 CALL keyword_release(keyword)
601
602 CALL keyword_create(keyword, __location__, name="KP_USE_DELTA_P", &
603 description="This kweyword controls whether the KS matrix at each SCF cycle "// &
604 "is built by adding the contribution of the denisty difference (wrt to previous step) "// &
605 "to the KS matrix of the previous step. As the SCF converges, the density fluctuations "// &
606 "get smaller and sparsity increases, leading to faster SCF steps. Not always "// &
607 "numerically stable => turn off if SCF struggles to converge.", &
608 variants=s2a("USE_DELTA_P", "KP_USE_P_DIFF", "USE_P_DIFF"), &
609 usage="KP_USE_DELTA_P {logical}", &
610 repeats=.false., &
611 default_l_val=.true.)
612 CALL section_add_keyword(section, keyword)
613 CALL keyword_release(keyword)
614
615 CALL keyword_create(keyword, __location__, name="KP_STACK_SIZE", &
616 description="When doing contraction over periodic cells of the type: "// &
617 "T_mu^a,nu^b,P^c = (mu^a nu^b | Q^d) * (Q^d | P^c), with "// &
618 "a,b,c,d labeling cells, there are in principle Ncells "// &
619 "contractions taking place. Because a smaller number of "// &
620 "contractions involving larger tensors is more efficient, "// &
621 "the tensors can be stacked along the d direction. STCK_SIZE "// &
622 "controls the size of this stack. Larger stacks are more efficient, "// &
623 "but required more memory.", &
624 variants=["STACK_SIZE"], &
625 usage="KP_STACK_SIZE {int}", &
626 repeats=.false., &
627 default_i_val=16)
628 CALL section_add_keyword(section, keyword)
629 CALL keyword_release(keyword)
630
631 CALL keyword_create(keyword, __location__, name="KP_RI_BUMP_FACTOR", &
632 variants=s2a("RI_BUMP", "BUMP", "BUMP_FACTOR"), &
633 description="In KP-RI-HFX, the extended RI basis set has a bump radius. "// &
634 "All basis elements within that radius contribute with full weight. "// &
635 "All basis elements beyond that radius have decaying weight, from "// &
636 "1 at the bump radius, to zero at the RI extension radius. The "// &
637 "bump radius is calculated as a fraction of the RI extension radius: "// &
638 "bump radius = KP_RI_NUMP_FACTOR * RI extension radius", &
639 default_r_val=0.85_dp, &
640 repeats=.false.)
641 CALL section_add_keyword(section, keyword)
642 CALL keyword_release(keyword)
643
644 CALL keyword_create(keyword, __location__, name="RI_METRIC", &
645 description="The type of RI operator. "// &
646 "Default is POTENTIAL_TYPE from INTERACTION_POTENTIAL. "// &
647 "The standard "// &
648 "Coulomb operator cannot be used in periodic systems.", &
649 usage="RI_METRIC {string}", &
650 repeats=.false., &
651 variants=["KP_RI_METRIC"], &
652 default_i_val=0, &
653 enum_c_vals=s2a("HFX", "COULOMB", "IDENTITY", "TRUNCATED", "SHORTRANGE"), &
654 enum_desc=s2a("Same as HFX operator", &
655 "Standard Coulomb operator: 1/r", &
656 "Overlap", &
657 "Truncated Coulomb operator: 1/r if (r<R_c), 0 otherwise ", &
658 "Short range: erfc(omega*r)/r"), &
661 CALL section_add_keyword(section, keyword)
662 CALL keyword_release(keyword)
663
664 CALL keyword_create(keyword, __location__, name="2C_MATRIX_FUNCTIONS", &
665 description="Methods for matrix inverse and matrix square root.", &
666 default_i_val=hfx_ri_do_2c_cholesky, &
667 enum_c_vals=s2a("DIAG", "CHOLESKY", "ITER"), &
668 enum_desc=s2a("Diagonalization with eigenvalue quenching: stable", &
669 "Cholesky: not stable in case of ill-conditioned RI basis", &
670 "Iterative algorithms: linear scaling "// &
671 "Hotelling's method for inverse and Newton-Schulz iteration for matrix square root"), &
673 CALL section_add_keyword(section, keyword)
674 CALL keyword_release(keyword)
675
676 CALL keyword_create(keyword, __location__, name="EPS_EIGVAL", &
677 description="Throw away linear combinations of RI basis functions with a small eigenvalue, "// &
678 "this is applied only if 2C_MATRIX_FUNCTIONS DIAG", &
679 default_r_val=1.0e-7_dp)
680 CALL section_add_keyword(section, keyword)
681 CALL keyword_release(keyword)
682
683 CALL keyword_create(keyword, __location__, name="CHECK_2C_MATRIX", &
684 description="Report accuracy for the inverse/sqrt of the 2-center integral matrix.", &
685 default_l_val=.false., lone_keyword_l_val=.true.)
686 CALL section_add_keyword(section, keyword)
687 CALL keyword_release(keyword)
688
689 CALL keyword_create( &
690 keyword, __location__, &
691 name="CALC_COND_NUM", &
692 variants=["CALC_CONDITION_NUMBER"], &
693 description="Calculate the condition number of integral matrices.", &
694 usage="CALC_COND_NUM", &
695 default_l_val=.false., &
696 lone_keyword_l_val=.true.)
697 CALL section_add_keyword(section, keyword)
698 CALL keyword_release(keyword)
699
700 CALL keyword_create(keyword, __location__, name="SQRT_ORDER", &
701 description="Order of the iteration method for the calculation of "// &
702 "the sqrt of 2-center integral matrix.", &
703 default_i_val=3)
704 CALL section_add_keyword(section, keyword)
705 CALL keyword_release(keyword)
706
707 CALL keyword_create(keyword, __location__, name="EPS_LANCZOS", &
708 description="Threshold used for lanczos estimates.", &
709 default_r_val=1.0e-3_dp)
710 CALL section_add_keyword(section, keyword)
711 CALL keyword_release(keyword)
712
713 CALL keyword_create(keyword, __location__, name="EPS_PGF_ORB", &
714 description="Sets precision of the integral tensors.", &
715 variants=["KP_EPS_PGF_ORB"], &
716 default_r_val=1.0e-5_dp)
717 CALL section_add_keyword(section, keyword)
718 CALL keyword_release(keyword)
719
720 CALL keyword_create(keyword, __location__, name="MAX_ITER_LANCZOS", &
721 description="Maximum number of lanczos iterations.", &
722 usage="MAX_ITER_LANCZOS ", default_i_val=500)
723 CALL section_add_keyword(section, keyword)
724 CALL keyword_release(keyword)
725
726 CALL keyword_create(keyword, __location__, name="RI_FLAVOR", &
727 description="Flavor of RI: how to contract 3-center integrals", &
728 enum_c_vals=s2a("MO", "RHO"), &
729 enum_desc=s2a("with MO coefficients", "with density matrix"), &
730 enum_i_vals=[ri_mo, ri_pmat], &
731 default_i_val=ri_pmat)
732 CALL section_add_keyword(section, keyword)
733 CALL keyword_release(keyword)
734
735 CALL keyword_create(keyword, __location__, name="MIN_BLOCK_SIZE", &
736 description="Minimum tensor block size.", &
737 default_i_val=4)
738 CALL section_add_keyword(section, keyword)
739 CALL keyword_release(keyword)
740
741 CALL keyword_create(keyword, __location__, name="MAX_BLOCK_SIZE_MO", &
742 description="Maximum tensor block size for MOs.", &
743 default_i_val=64)
744 CALL section_add_keyword(section, keyword)
745 CALL keyword_release(keyword)
746
747 CALL keyword_create(keyword, __location__, name="MEMORY_CUT", &
748 description="Memory reduction factor. This keyword controls the batching of tensor "// &
749 "contractions into smaller, more manageable chunks. The details vary "// &
750 "depending on the RI_FLAVOR.", &
751 default_i_val=3)
752 CALL section_add_keyword(section, keyword)
753 CALL keyword_release(keyword)
754
755 CALL keyword_create(keyword, __location__, name="FLAVOR_SWITCH_MEMORY_CUT", &
756 description="Memory reduction factor to be applied upon RI_FLAVOR switching "// &
757 "from MO to RHO. The RHO flavor typically requires more memory, "// &
758 "and depending on the ressources available, a higher MEMORY_CUT.", &
759 default_i_val=3)
760 CALL section_add_keyword(section, keyword)
761 CALL keyword_release(keyword)
762
763 CALL section_create(subsection, __location__, name="PRINT", &
764 description="Section of possible print options in the RI-HFX code.", &
765 n_keywords=0, n_subsections=1, repeats=.false.)
766
767 CALL keyword_create(keyword, __location__, name="KP_RI_PROGRESS_BAR", &
768 variants=s2a("PROGRESS_BAR", "PROGRESS", "KP_PROGRESS", "KP_PROGRESS_BAR"), &
769 description="Whether a progress bar for individual SCF steps should be printed. "// &
770 "In RI-HFXk, an expensive triple loop runs over periodic images and "// &
771 "atomic pairs. This printing option tracks the progress of this loop "// &
772 "in real time. Note that some work also takes place before the loop "// &
773 "starts, and the time spent doing it depends on the value of "// &
774 "KP_STACK_SIZE (larger = faster, but more memory used).", &
775 default_l_val=.false., lone_keyword_l_val=.true.)
776 CALL section_add_keyword(subsection, keyword)
777 CALL keyword_release(keyword)
778
779 !TODO: add a incentive to restart from GGA calculation? Test that it improves things
780 CALL keyword_create(keyword, __location__, name="KP_RI_MEMORY_ESTIMATE", &
781 variants=s2a("MEMORY_ESTIMATE"), &
782 description="Calculate and print a rough upper bound estimate of the memory "// &
783 "required to run a RI-HFXk ENERGY calculation. Note that a fair "// &
784 "amount of computing must take place before this estimate can be "// &
785 "produced. If the calculation runs out of memory beforehand, "// &
786 "use more resources, or change the value of memory related keywords "// &
787 "(e.g. KP_NGROUPS, interaction potential parameters, KP_STACK_SIZE). "// &
788 "The estimate is more accurate when restarting from a (GGA) wavefunction. "// &
789 "Calculations involving forces will require more memory than this estimate.", &
790 default_l_val=.false., lone_keyword_l_val=.true.)
791 CALL section_add_keyword(subsection, keyword)
792 CALL keyword_release(keyword)
793
794 CALL cp_print_key_section_create(print_key, __location__, "RI_INFO", &
795 description="Controls the printing of DBCSR tensor log in RI HFX.", &
796 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
797 CALL section_add_subsection(subsection, print_key)
798 CALL section_release(print_key)
799
800 CALL cp_print_key_section_create(print_key, __location__, "RI_DENSITY_COEFFS", &
801 description="Controls the printing of the projection of the elecontric "// &
802 "density on the RI_HFX basis. n(r) = sum_s c_s*phi_RI_s(r), "// &
803 "where c_s = sum_pqr P_pq (pq|r) (r|s)^-1 and | is the RI_METRIC", &
804 print_level=high_print_level, filename="RI_DENSITY_COEFFS", &
805 common_iter_levels=3)
806
807 CALL keyword_create(keyword, __location__, name="MULTIPLY_BY_RI_2C_INTEGRALS", &
808 variants=s2a("MULT_BY_RI", "MULT_BY_S", "MULT_BY_RI_INTS"), &
809 description="Whether the RI density coefficients to be printed should "// &
810 "be pre-multiplied by the RI_METRIC 2c-integrals: (r|s)*C_s. "// &
811 "Not compatible with the SKIP_RI_METRIC keyword.", &
812 default_l_val=.false., lone_keyword_l_val=.true.)
813 CALL section_add_keyword(print_key, keyword)
814 CALL keyword_release(keyword)
815
816 CALL keyword_create(keyword, __location__, name="SKIP_RI_METRIC", &
817 variants=s2a("SKIP_INVERSE", "SKIP_2C_INTS", "SKIP_2C_INTEGRALS"), &
818 description="Skip the calculation, inversion, and contraction of the 2-center RI "// &
819 "metric integrals. The printed coefficients are only the contraction of the "// &
820 "density matrix with the 3-center integrals, i.e. c_r = sum_pq P_pq (pq|r) "// &
821 "Allows for memory savings when printing the RI density coefficients.", &
822 default_l_val=.false., lone_keyword_l_val=.true.)
823 CALL section_add_keyword(print_key, keyword)
824 CALL keyword_release(keyword)
825
826 CALL keyword_create(keyword, __location__, name="FILE_FORMAT", &
827 description="Format of file containing density fitting coefficients: "// &
828 "BASIC(default)-original format; EXTENDED-format with basis set info.", &
829 default_c_val="BASIC")
830 CALL section_add_keyword(print_key, keyword)
831 CALL keyword_release(keyword)
832
833 CALL section_add_subsection(subsection, print_key)
834 CALL section_release(print_key)
835
836 CALL cp_print_key_section_create(print_key, __location__, "RI_METRIC_2C_INTS", &
837 description="Controls the printing of RI 2-center integrals for the "// &
838 "HFX potential.", &
839 print_level=high_print_level, filename="RI_2C_INTS", &
840 common_iter_levels=3)
841 CALL section_add_subsection(subsection, print_key)
842 CALL section_release(print_key)
843
844 CALL section_add_subsection(section, subsection)
845 CALL section_release(subsection)
846
847 END SUBROUTINE create_hf_ri_section
848
849 ! ACE Keyword section
850
851 SUBROUTINE create_hf_ace_section(section)
852 TYPE(section_type), POINTER :: section
853
854 TYPE(keyword_type), POINTER :: keyword
855
856 cpassert(.NOT. ASSOCIATED(section))
857 CALL section_create(section, __location__, &
858 name="ACE", &
859 description="Parameters for the Adaptively Compressed Exchange (ACE) "// &
860 "operator. ACE replaces the full exchange matrix with a "// &
861 "low-rank projector K_ACE = -W*W^T after an initial "// &
862 "full HFX build, reducing cost of subsequent SCF steps. "// &
863 "NOTE: ACE requires diagonalization-based SCF. "// &
864 "It is incompatible with orbital transformation (OT) methods "// &
865 "because OT does not construct MO coefficients.", &
866 n_keywords=2, &
867 n_subsections=0, &
868 repeats=.false., &
869 citations=[lin2016ace])
870
871 NULLIFY (keyword)
872
873 ! --- ACTIVE ---
874 CALL keyword_create(keyword, __location__, &
875 name="ACTIVE", &
876 description="Enable the ACE approximation for HFX. "// &
877 "When .TRUE., the exchange matrix is replaced by "// &
878 "the ACE projector after the first full build.", &
879 usage="ACTIVE .TRUE.", &
880 default_l_val=.false., &
881 lone_keyword_l_val=.true.)
882 CALL section_add_keyword(section, keyword)
883 CALL keyword_release(keyword)
884
885 ! --- REBUILD_FREQUENCY ---
886 CALL keyword_create(keyword, __location__, &
887 name="REBUILD_FREQUENCY", &
888 description="Rebuild the ACE projectors W every N SCF steps. "// &
889 "N=1 means rebuild every step (identical to full HFX, "// &
890 "use for testing only). N=10-20 is typical for production. "// &
891 "Projectors are always rebuilt when the structure changes.", &
892 usage="REBUILD_FREQUENCY 20", &
893 default_i_val=20)
894 CALL section_add_keyword(section, keyword)
895 CALL keyword_release(keyword)
896
897 END SUBROUTINE create_hf_ace_section
898
899END MODULE input_cp2k_hfx
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public guidon2008
integer, save, public guidon2009
integer, save, public lin2016ace
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public medium_print_level
integer, parameter, public high_print_level
integer, parameter, public add_last_numeric
subroutine, public cp_print_key_section_create(print_key_section, location, name, description, print_level, each_iter_names, each_iter_values, add_last, filename, common_iter_levels, citations, unit_str)
creates a print_key section
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public hfx_library_is_libint
integer, parameter, public hfx_library_is_both
integer, parameter, public hfx_ri_do_2c_cholesky
integer, parameter, public hfx_ri_do_2c_diag
integer, parameter, public ehrenfest
integer, parameter, public hfx_library_is_libgint
integer, parameter, public do_potential_mix_cl
integer, parameter, public do_potential_gaussian
integer, parameter, public do_potential_truncated
integer, parameter, public do_potential_mix_lg
integer, parameter, public do_potential_id
integer, parameter, public hfx_ri_do_2c_iter
integer, parameter, public do_potential_coulomb
integer, parameter, public gaussian
integer, parameter, public do_potential_short
integer, parameter, public do_potential_mix_cl_trunc
integer, parameter, public do_potential_long
function that builds the hartree fock exchange section of the input
integer, parameter, public ri_pmat
integer, parameter, public ri_mo
subroutine, public create_hfx_section(section)
creates the input section for the hf part
represents keywords in an input
subroutine, public keyword_release(keyword)
releases the given keyword (see doc/ReferenceCounting.html)
subroutine, public keyword_create(keyword, location, name, description, usage, type_of_var, n_var, repeats, variants, default_val, default_l_val, default_r_val, default_lc_val, default_c_val, default_i_val, default_l_vals, default_r_vals, default_c_vals, default_i_vals, lone_keyword_val, lone_keyword_l_val, lone_keyword_r_val, lone_keyword_c_val, lone_keyword_i_val, lone_keyword_l_vals, lone_keyword_r_vals, lone_keyword_c_vals, lone_keyword_i_vals, enum_c_vals, enum_i_vals, enum, enum_strict, enum_desc, unit_str, citations, deprecation_notice, removed)
creates a keyword object
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_create(section, location, name, description, n_keywords, n_subsections, repeats, citations, deprecation_notice)
creates a list of keywords
subroutine, public section_add_keyword(section, keyword)
adds a keyword to the given section
subroutine, public section_add_subsection(section, subsection)
adds a subsection to the given section
recursive subroutine, public section_release(section)
releases the given keyword list (see doc/ReferenceCounting.html)
a wrapper for basic fortran types.
integer, parameter, public real_t
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Utilities for string manipulations.
represent a keyword in the input
represent a section of the input file