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