(git:9111030)
Loading...
Searching...
No Matches
input_cp2k_scf.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 build the scf section of the input
10!> \par History
11!> 10.2005 moved out of input_cp2k [fawzi]
12!> 07.2024 moved out of input_cp2k_dft [JGH]
13!> \author fawzi
14! **************************************************************************************************
16 USE bibliography, ONLY: &
23 USE cp_units, ONLY: cp_unit_to_cp2k
24 USE input_constants, ONLY: &
56 USE input_val_types, ONLY: integer_t,&
57 real_t
58 USE kinds, ONLY: dp
62 USE string_utilities, ONLY: newline,&
63 s2a
64#include "./base/base_uses.f90"
65
66 IMPLICIT NONE
67 PRIVATE
68
69 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_scf'
70
72
73CONTAINS
74
75! **************************************************************************************************
76!> \brief creates the structure of the section with the DFT SCF parameters
77!> \param section will contain the SCF section
78!> \author fawzi
79! **************************************************************************************************
80 SUBROUTINE create_scf_section(section)
81 TYPE(section_type), POINTER :: section
82
83 TYPE(keyword_type), POINTER :: keyword
84 TYPE(section_type), POINTER :: print_key, subsection
85
86 NULLIFY (print_key)
87
88 cpassert(.NOT. ASSOCIATED(section))
89 CALL section_create(section, __location__, name="scf", &
90 description="Parameters needed to perform an SCF run.", &
91 n_keywords=18, n_subsections=7, repeats=.false.)
92
93 NULLIFY (subsection)
94
95 CALL create_ot_section(subsection)
96 CALL section_add_subsection(section, subsection)
97 CALL section_release(subsection)
98
99 CALL create_diagonalization_section(subsection)
100 CALL section_add_subsection(section, subsection)
101 CALL section_release(subsection)
102
103 CALL create_outer_scf_section(subsection)
104 CALL section_add_subsection(section, subsection)
105 CALL section_release(subsection)
106
107 CALL create_smear_section(subsection)
108 CALL section_add_subsection(section, subsection)
109 CALL section_release(subsection)
110
111 CALL create_mixing_section(subsection)
112 CALL section_add_subsection(section, subsection)
113 CALL section_release(subsection)
114
115 CALL create_mom_section(subsection)
116 CALL section_add_subsection(section, subsection)
117 CALL section_release(subsection)
118
119 CALL create_gce_section(subsection)
120 CALL section_add_subsection(section, subsection)
121 CALL section_release(subsection)
122
123 NULLIFY (keyword)
124
125 CALL keyword_create(keyword, __location__, name="MAX_ITER_LUMO", &
126 variants=["MAX_ITER_LUMOS"], &
127 description="Maximum number of iterations for the calculation of the LUMO energies "// &
128 "with the OT eigensolver.", &
129 usage="MAX_ITER_LUMO 100", default_i_val=299)
130 CALL section_add_keyword(section, keyword)
131 CALL keyword_release(keyword)
132
133 CALL keyword_create(keyword, __location__, name="EPS_LUMO", &
134 variants=["EPS_LUMOS"], &
135 description="Target accuracy for the calculation of the LUMO energies with the OT eigensolver.", &
136 usage="EPS_LUMO 1.0E-6", default_r_val=1.0e-5_dp)
137 CALL section_add_keyword(section, keyword)
138 CALL keyword_release(keyword)
139
140 CALL keyword_create(keyword, __location__, name="MAX_SCF", &
141 description="Maximum number of inner SCF iterations for one electronic optimization.", &
142 usage="MAX_SCF 200", default_i_val=50)
143 CALL section_add_keyword(section, keyword)
144 CALL keyword_release(keyword)
145
146 CALL keyword_create(keyword, __location__, name="MAX_SCF_HISTORY", variants=["MAX_SCF_HIST"], &
147 description="Maximum number of SCF iterations after the history pipeline is filled", &
148 usage="MAX_SCF_HISTORY 1", default_i_val=0, lone_keyword_i_val=1)
149 CALL section_add_keyword(section, keyword)
150 CALL keyword_release(keyword)
151
152 CALL keyword_create(keyword, __location__, name="MAX_DIIS", &
153 variants=["MAX_DIIS_BUFFER_SIZE"], &
154 description="Maximum number of DIIS vectors to be used", &
155 usage="MAX_DIIS 3", default_i_val=4)
156 CALL section_add_keyword(section, keyword)
157 CALL keyword_release(keyword)
158
159 CALL keyword_create(keyword, __location__, name="LEVEL_SHIFT", &
160 variants=["LSHIFT"], &
161 description="Use level shifting to improve convergence", &
162 unit_str="au_e", &
163 usage="LEVEL_SHIFT 0.1", &
164 default_r_val=0.0_dp)
165 CALL section_add_keyword(section, keyword)
166 CALL keyword_release(keyword)
167
168 CALL keyword_create(keyword, __location__, name="EPS_SCF", &
169 description="Target convergence threshold for the inner SCF cycle.", &
170 usage="EPS_SCF 1.e-6", default_r_val=1.e-5_dp)
171 CALL section_add_keyword(section, keyword)
172 CALL keyword_release(keyword)
173
174 CALL keyword_create(keyword, __location__, name="EPS_SCF_HISTORY", variants=["EPS_SCF_HIST"], &
175 description="Target accuracy for the SCF convergence after the history pipeline is filled.", &
176 usage="EPS_SCF_HISTORY 1.e-5", default_r_val=0.0_dp, lone_keyword_r_val=1.0e-5_dp)
177 CALL section_add_keyword(section, keyword)
178 CALL keyword_release(keyword)
179
180 CALL keyword_create(keyword, __location__, name="CHOLESKY", &
181 description="If the cholesky method should be used for computing "// &
182 "the inverse of S, and in this case calling which Lapack routines", &
183 usage="CHOLESKY REDUCE", default_i_val=cholesky_restore, &
184 enum_c_vals=s2a("OFF", "REDUCE", "RESTORE", "INVERSE", "INVERSE_DBCSR"), &
185 enum_desc=s2a("The cholesky algorithm is not used", "Reduce is called", &
186 "Reduce is replaced by two restore", &
187 "Restore uses operator multiply by inverse of the triangular matrix", &
188 "Like inverse, but matrix stored as dbcsr, sparce matrix algebra used when possible"), &
190 CALL section_add_keyword(section, keyword)
191 CALL keyword_release(keyword)
192
193 CALL keyword_create(keyword, __location__, name="EPS_EIGVAL", &
194 description="Throw away linear combinations of basis functions with a small eigenvalue in S", &
195 usage="EPS_EIGVAL 1.0", default_r_val=1.0e-5_dp)
196 CALL section_add_keyword(section, keyword)
197 CALL keyword_release(keyword)
198
199 CALL keyword_create(keyword, __location__, name="EPS_DIIS", &
200 description="Threshold on the convergence to start using DIAG/DIIS or OT/DIIS."// &
201 " Default for OT/DIIS is never to switch.", &
202 usage="EPS_DIIS 5.0e-2", default_r_val=0.1_dp)
203 CALL section_add_keyword(section, keyword)
204 CALL keyword_release(keyword)
205
206 CALL keyword_create( &
207 keyword, __location__, name="SCF_GUESS", &
208 description="Selects how the initial wavefunction or density matrix is generated.", &
209 usage="SCF_GUESS RESTART", default_i_val=atomic_guess, &
210 enum_c_vals=s2a("ATOMIC", "RESTART", "RANDOM", "CORE", &
211 "HISTORY_RESTART", "MOPAC", "EHT", "SPARSE", "NONE"), &
212 enum_desc=s2a("Generate an atomic density using the atomic code and internal default values", &
213 "Use the RESTART file as an initial guess (and ATOMIC if not present).", &
214 "Use random wavefunction coefficients.", &
215 "Diagonalize the core hamiltonian for an initial guess.", &
216 "Extrapolated from previous RESTART files.", &
217 "Use same guess as MOPAC for semi-empirical methods or a simple diagonal density matrix for other methods", &
218 "Use the EHT (gfn0-xTB) code to generate an initial wavefunction.", &
219 "Generate a sparse wavefunction using the atomic code (for OT based methods)", &
220 "Skip initial guess (only for non-self consistent methods)."), &
223 CALL section_add_keyword(section, keyword)
224 CALL keyword_release(keyword)
225
226 CALL keyword_create(keyword, __location__, name="NROW_BLOCK", &
227 description="sets the number of rows in a scalapack block", &
228 usage="NROW_BLOCK 31", default_i_val=32)
229 CALL section_add_keyword(section, keyword)
230 CALL keyword_release(keyword)
231
232 CALL keyword_create(keyword, __location__, name="NCOL_BLOCK", &
233 description="Sets the number of columns in a scalapack block", &
234 usage="NCOL_BLOCK 31", default_i_val=32)
235 CALL section_add_keyword(section, keyword)
236 CALL keyword_release(keyword)
237
238 CALL keyword_create(keyword, __location__, name="ADDED_MOS", &
239 description="Number of additional molecular orbitals added for each spin channel. "// &
240 "This is commonly needed for smearing, excited-state, or post-Hartree-Fock calculations. "// &
241 "Use -1 to add all available orbitals.", &
242 usage="ADDED_MOS", default_i_val=0, n_var=-1)
243 CALL section_add_keyword(section, keyword)
244 CALL keyword_release(keyword)
245
246 CALL keyword_create(keyword, __location__, &
247 name="ROKS_SCHEME", &
248 description="Selects the ROKS scheme when ROKS is applied.", &
249 usage="ROKS_SCHEME HIGH-SPIN", &
250 repeats=.false., &
251 n_var=1, &
252 enum_c_vals=s2a("GENERAL", "HIGH-SPIN"), &
253 enum_i_vals=[general_roks, high_spin_roks], &
254 default_i_val=high_spin_roks)
255 CALL section_add_keyword(section, keyword)
256 CALL keyword_release(keyword)
257
258 CALL keyword_create(keyword, __location__, &
259 name="ROKS_F", &
260 variants=["F_ROKS"], &
261 description="Allows to define the parameter f for the "// &
262 "general ROKS scheme.", &
263 usage="ROKS_F 1/2", &
264 repeats=.false., &
265 n_var=1, &
266 type_of_var=real_t, &
267 default_r_val=0.5_dp)
268 CALL section_add_keyword(section, keyword)
269 CALL keyword_release(keyword)
270
271 CALL keyword_create(keyword, __location__, &
272 name="ROKS_PARAMETERS", &
273 variants=["ROKS_PARAMETER"], &
274 description="Allows to define all parameters for the high-spin "// &
275 "ROKS scheme explicitly. "// &
276 "The full set of 6 parameters has to be specified "// &
277 "in the order acc, bcc, aoo, boo, avv, bvv", &
278 usage="ROKS_PARAMETERS 1/2 1/2 1/2 1/2 1/2 1/2", &
279 repeats=.false., &
280 n_var=6, &
281 type_of_var=real_t, &
282 default_r_vals=[-0.5_dp, 1.5_dp, 0.5_dp, 0.5_dp, 1.5_dp, -0.5_dp])
283 CALL section_add_keyword(section, keyword)
284 CALL keyword_release(keyword)
285
286 CALL keyword_create(keyword, __location__, name="IGNORE_CONVERGENCE_FAILURE", &
287 description="If true, only a warning is issued if an SCF "// &
288 "iteration has not converged. By default, a run is aborted "// &
289 "if the required convergence criteria have not been achieved.", &
290 usage="IGNORE_CONVERGENCE_FAILURE logical_value", &
291 default_l_val=.false., &
292 lone_keyword_l_val=.true.)
293 CALL section_add_keyword(section, keyword)
294 CALL keyword_release(keyword)
295
296 CALL keyword_create(keyword, __location__, name="FORCE_SCF_CALCULATION", &
297 description="Request a SCF type solution even for nonSCF methods. ", &
298 usage="FORCE_SCF_CALCULATION logical_value", &
299 default_l_val=.false., &
300 lone_keyword_l_val=.true.)
301 CALL section_add_keyword(section, keyword)
302 CALL keyword_release(keyword)
303
304 CALL section_create(subsection, __location__, name="PRINT", &
305 description="Printing of information during the SCF.", repeats=.false.)
306
307 CALL cp_print_key_section_create(print_key, __location__, "RESTART", &
308 description="Controls the dumping of the MO restart file during SCF. "// &
309 "By default keeps a short history of three restarts. "// &
310 "See also RESTART_HISTORY", &
311 print_level=low_print_level, common_iter_levels=3, &
312 each_iter_names=s2a("QS_SCF"), each_iter_values=[20], &
313 add_last=add_last_numeric, filename="RESTART")
314 CALL keyword_create(keyword, __location__, name="BACKUP_COPIES", &
315 description="Specifies the maximum number of backup copies.", &
316 usage="BACKUP_COPIES {int}", &
317 default_i_val=1)
318 CALL section_add_keyword(print_key, keyword)
319 CALL keyword_release(keyword)
320 CALL section_add_subsection(subsection, print_key)
321 CALL section_release(print_key)
322
324 print_key, __location__, "RESTART_HISTORY", &
325 description="Dumps unique MO restart files during the run keeping all of them.", &
326 print_level=low_print_level, common_iter_levels=0, &
327 each_iter_names=s2a("__ROOT__", "MD", "GEO_OPT", "ROT_OPT", "NEB", "METADYNAMICS", "QS_SCF"), &
328 each_iter_values=[500, 500, 500, 500, 500, 500, 500], &
329 filename="RESTART")
330 CALL keyword_create(keyword, __location__, name="BACKUP_COPIES", &
331 description="Specifies the maximum number of backup copies.", &
332 usage="BACKUP_COPIES {int}", &
333 default_i_val=1)
334 CALL section_add_keyword(print_key, keyword)
335 CALL keyword_release(keyword)
336 CALL section_add_subsection(subsection, print_key)
337 CALL section_release(print_key)
338
339 CALL cp_print_key_section_create(print_key, __location__, "iteration_info", &
340 description="Controls the printing of basic iteration information during the SCF.", &
341 print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
342 CALL keyword_create(keyword, __location__, name="time_cumul", &
343 description="If the printkey is activated switches the printing of timings"// &
344 " to cumulative (over the SCF).", &
345 default_l_val=.false., lone_keyword_l_val=.true.)
346 CALL section_add_keyword(print_key, keyword)
347 CALL keyword_release(keyword)
348 CALL section_add_subsection(subsection, print_key)
349 CALL section_release(print_key)
350
351 CALL cp_print_key_section_create(print_key, __location__, "program_run_info", &
352 description="Controls the printing of basic information during the SCF.", &
353 print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
354 CALL section_add_subsection(subsection, print_key)
355 CALL section_release(print_key)
356
357 CALL cp_print_key_section_create(print_key, __location__, "MO_ORTHONORMALITY", &
358 description="Controls the printing relative to the orthonormality of MOs (CT S C).", &
359 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
360 CALL section_add_subsection(subsection, print_key)
361 CALL section_release(print_key)
362
363 CALL cp_print_key_section_create(print_key, __location__, "MO_MAGNITUDE", &
364 description="Prints the min/max eigenvalues of the overlap of the MOs without S (CT C).", &
365 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
366 CALL section_add_subsection(subsection, print_key)
367 CALL section_release(print_key)
368
369 CALL cp_print_key_section_create(print_key, __location__, "detailed_energy", &
370 description="Controls the printing of detailed energy information.", &
371 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
372 CALL section_add_subsection(subsection, print_key)
373 CALL section_release(print_key)
374
375 CALL cp_print_key_section_create(print_key, __location__, "diis_info", &
376 description="Controls the printing of DIIS information.", &
377 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
378 CALL section_add_subsection(subsection, print_key)
379 CALL section_release(print_key)
380
381 CALL cp_print_key_section_create(print_key, __location__, "total_densities", &
382 description="Controls the printing of total densities.", &
383 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
384 CALL section_add_subsection(subsection, print_key)
385 CALL section_release(print_key)
386
387 CALL cp_print_key_section_create(print_key, __location__, "Lanczos", &
388 description="Controls the printing of information on Lanczos refinement iterations.", &
389 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
390 CALL section_add_subsection(subsection, print_key)
391 CALL section_release(print_key)
392
394 print_key, __location__, "DIAG_SUB_SCF", &
395 description="Controls the printing of information on subspace diagonalization internal loop. ", &
396 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
397 CALL section_add_subsection(subsection, print_key)
398 CALL section_release(print_key)
399
400 CALL cp_print_key_section_create(print_key, __location__, "Davidson", &
401 description="Controls the printing of information on Davidson iterations.", &
402 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
403 CALL section_add_subsection(subsection, print_key)
404 CALL section_release(print_key)
405
406 CALL cp_print_key_section_create(print_key, __location__, "FILTER_MATRIX", &
407 description="Controls the printing of information on Filter Matrix method.", &
408 print_level=high_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
409 CALL section_add_subsection(subsection, print_key)
410 CALL section_release(print_key)
411
412 CALL keyword_create(keyword, __location__, name="DM_RESTART_WRITE", &
413 description="Write the density matrix into a binary file at the end of the SCF.", &
414 usage="DM_RESTART_WRITE", default_l_val=.false., lone_keyword_l_val=.true.)
415 CALL section_add_keyword(subsection, keyword)
416 CALL keyword_release(keyword)
417
418 CALL section_add_subsection(section, subsection)
419 CALL section_release(subsection)
420
421 END SUBROUTINE create_scf_section
422
423! **************************************************************************************************
424!> \brief creates the structure of the section with SCF parameters
425!> controlling an other loop
426!> \param section will contain the SCF section
427!> \author Joost VandeVondele [2006.03]
428! **************************************************************************************************
429 SUBROUTINE create_outer_scf_section(section)
430 TYPE(section_type), POINTER :: section
431
432 TYPE(keyword_type), POINTER :: keyword
433 TYPE(section_type), POINTER :: subsection
434
435 cpassert(.NOT. ASSOCIATED(section))
436 CALL section_create(section, __location__, name="OUTER_SCF", &
437 description="Controls an outer SCF loop, often used to stabilize difficult OT convergence, "// &
438 "constraints, or other variables wrapped around the inner SCF cycle.", &
439 n_keywords=13, n_subsections=1, repeats=.false.)
440
441 NULLIFY (keyword)
442
443 CALL keyword_create(keyword, __location__, name="_SECTION_PARAMETERS_", &
444 description="Activates the outer SCF loop.", &
445 usage="&OUTER_SCF ON", default_l_val=.false., lone_keyword_l_val=.true.)
446 CALL section_add_keyword(section, keyword)
447 CALL keyword_release(keyword)
448
449 ! add CDFT_OPT section
450 NULLIFY (subsection)
451 CALL create_cdft_opt_section(subsection)
452 CALL section_add_subsection(section, subsection)
453 CALL section_release(subsection)
454
455 CALL keyword_create(keyword, __location__, name="TYPE", &
456 description="Specifies which kind of outer SCF should be employed", &
457 usage="TYPE DDAPC_CONSTRAINT ", &
458 default_i_val=outer_scf_none, &
459 enum_c_vals=s2a("DDAPC_CONSTRAINT", "S2_CONSTRAINT", &
460 "BASIS_CENTER_OPT", "CDFT_CONSTRAINT", "NONE"), &
461 enum_desc=s2a("Enforce a constraint on the DDAPC, requires the corresponding section", &
462 "Enforce a constraint on the S2, requires the corresponding section", &
463 "Optimize positions of basis functions, if atom types FLOATING_BASIS_CENTER "// &
464 "are defined", &
465 "Enforce a constraint on a generic CDFT weight population. "// &
466 "Requires the corresponding section QS&CDFT"// &
467 " which determines the type of weight used.", &
468 "Do nothing in the outer loop, useful for resetting the inner loop,"), &
471 CALL section_add_keyword(section, keyword)
472 CALL keyword_release(keyword)
473
474 CALL keyword_create(keyword, __location__, name="OPTIMIZER", &
475 description="Method used to bring the outer loop to a stationary point", &
476 usage="OPTIMIZER SD", &
477 default_i_val=outer_scf_optimizer_none, &
478 enum_c_vals=s2a("SD", "DIIS", "NONE", "BISECT", "BROYDEN", "NEWTON", "SECANT", "NEWTON_LS"), &
479 enum_desc=s2a("Takes steps in the direction of the gradient, multiplied by step_size", &
480 "Uses a Direct Inversion in the Iterative Subspace method", &
481 "Do nothing, useful only with the none type", &
482 "Bisection of the gradient, useful for difficult one dimensional cases", &
483 "Broyden's method. Variant defined in BROYDEN_TYPE.", &
484 "Newton's method. Only compatible with CDFT constraints.", &
485 "Secant method. Only for one dimensional cases. See Broyden for "// &
486 "multidimensional cases.", &
487 "Newton's method with backtracking line search to find the optimal step size. "// &
488 "Only compatible with CDFT constraints. Starts from the regular Newton solution "// &
489 "and successively reduces the step size until the L2 norm of the CDFT gradient "// &
490 "decreases or MAX_LS steps is reached. Potentially very expensive because "// &
491 "each iteration performs a full SCF calculation."), &
496 CALL section_add_keyword(section, keyword)
497 CALL keyword_release(keyword)
498
499 CALL keyword_create(keyword, __location__, name="BISECT_TRUST_COUNT", &
500 description="Maximum number of times the same point will be used in bisection,"// &
501 " a small number guards against the effect of wrongly converged states.", &
502 usage="BISECT_TRUST_COUNT 5", default_i_val=10)
503 CALL section_add_keyword(section, keyword)
504 CALL keyword_release(keyword)
505
506 CALL keyword_create(keyword, __location__, name="EPS_SCF", &
507 description="The target gradient of the outer SCF variables. "// &
508 "Notice that the EPS_SCF of the inner loop also determines "// &
509 "the value that can be reached in the outer loop, "// &
510 "typically EPS_SCF of the outer loop must be smaller "// &
511 "than or equal to EPS_SCF of the inner loop.", &
512 usage="EPS_SCF 1.0E-6 ", default_r_val=1.0e-5_dp)
513 CALL section_add_keyword(section, keyword)
514 CALL keyword_release(keyword)
515
516 CALL keyword_create(keyword, __location__, name="DIIS_BUFFER_LENGTH", &
517 description="Maximum number of DIIS vectors used ", &
518 usage="DIIS_BUFFER_LENGTH 5", default_i_val=3)
519 CALL section_add_keyword(section, keyword)
520 CALL keyword_release(keyword)
521
522 CALL keyword_create(keyword, __location__, name="EXTRAPOLATION_ORDER", &
523 description="Number of past states used in the extrapolation of the variables during e.g. MD", &
524 usage="EXTRAPOLATION_ORDER 5", default_i_val=3)
525 CALL section_add_keyword(section, keyword)
526 CALL keyword_release(keyword)
527
528 CALL keyword_create(keyword, __location__, name="MAX_SCF", &
529 description="Maximum number of outer SCF loops.", &
530 usage="MAX_SCF 20", default_i_val=50)
531 CALL section_add_keyword(section, keyword)
532 CALL keyword_release(keyword)
533
534 CALL keyword_create(keyword, __location__, name="STEP_SIZE", &
535 description="The initial step_size used in the optimizer (currently steepest descent). "// &
536 "Note that in cases where a sadle point is sought for (constrained DFT),"// &
537 " this can be negative. For Newton and Broyden optimizers, use a value less/higher than "// &
538 "the default 1.0 (in absolute value, the sign is not significant) to active an under/overrelaxed "// &
539 "optimizer.", &
540 usage="STEP_SIZE -1.0", default_r_val=0.5_dp)
541 CALL section_add_keyword(section, keyword)
542 CALL keyword_release(keyword)
543
544 END SUBROUTINE create_outer_scf_section
545
546! **************************************************************************************************
547!> \brief makes the orbital transformation section
548!> \param section ...
549!> \par History
550!> 11.2004 created [Joost VandeVondele]
551! **************************************************************************************************
552 SUBROUTINE create_ot_section(section)
553 TYPE(section_type), POINTER :: section
554
555 TYPE(keyword_type), POINTER :: keyword
556
557 cpassert(.NOT. ASSOCIATED(section))
558 CALL section_create(section, __location__, name="OT", &
559 description="Sets the various options for the orbital transformation (OT) method. "// &
560 "Default settings already provide an efficient, yet robust method. "// &
561 "Most systems benefit from using the FULL_ALL preconditioner "// &
562 "combined with a small value (0.001) of ENERGY_GAP. "// &
563 "Well-behaved systems might benefit from using a DIIS minimizer. "//newline//newline// &
564 "**Advantages:** "// &
565 "It's fast, because no expensive diagonalisation is performed. "// &
566 "If preconditioned correctly, method guaranteed to find minimum. "//newline//newline// &
567 "**Disadvantages:** "// &
568 "Sensitive to preconditioning. A good preconditioner can be expensive. "// &
569 "No smearing, or advanced SCF mixing possible: POOR convergence for metallic systems.", &
570 n_keywords=27, n_subsections=0, repeats=.false., &
571 citations=[vandevondele2003, weber2008])
572
573 NULLIFY (keyword)
574
575 CALL keyword_create(keyword, __location__, name="_SECTION_PARAMETERS_", &
576 description="controls the activation of the ot method", &
577 usage="&OT T", &
578 default_l_val=.false., &
579 lone_keyword_l_val=.true.)
580 CALL section_add_keyword(section, keyword)
581 CALL keyword_release(keyword)
582
583 CALL keyword_create(keyword, __location__, name="ALGORITHM", &
584 description="Algorithm to be used for OT", &
585 usage="ALGORITHM STRICT", &
586 default_i_val=ot_algo_taylor_or_diag, &
587 enum_c_vals=s2a("STRICT", "IRAC"), &
588 enum_desc=s2a("Strict orthogonality: Taylor or diagonalization based algorithm.", &
589 "Orbital Transformation based Iterative Refinement "// &
590 "of the Approximative Congruence transformation (OT/IR)."), &
591 enum_i_vals=[ot_algo_taylor_or_diag, ot_algo_irac], &
593 CALL section_add_keyword(section, keyword)
594 CALL keyword_release(keyword)
595
596 CALL keyword_create(keyword, __location__, name="IRAC_DEGREE", &
597 description="The refinement polynomial degree (2, 3 or 4).", &
598 usage="IRAC_DEGREE 4", &
599 default_i_val=4)
600 CALL section_add_keyword(section, keyword)
601 CALL keyword_release(keyword)
602
603 CALL keyword_create(keyword, __location__, name="MAX_IRAC", &
604 description="Maximum allowed refinement iteration.", &
605 usage="MAX_IRAC 5", &
606 default_i_val=50)
607 CALL section_add_keyword(section, keyword)
608 CALL keyword_release(keyword)
609
610 CALL keyword_create(keyword, __location__, name="ORTHO_IRAC", &
611 description="The orthogonality method.", &
612 usage="ORTHO_IRAC POLY", &
613 default_i_val=ot_chol_irac, &
614 enum_c_vals=s2a("CHOL", "POLY", "LWDN"), &
615 enum_desc=s2a("Cholesky.", "Polynomial.", "Loewdin."), &
616 enum_i_vals=[ot_chol_irac, ot_poly_irac, ot_lwdn_irac])
617 CALL section_add_keyword(section, keyword)
618 CALL keyword_release(keyword)
619
620 CALL keyword_create(keyword, __location__, name="EPS_IRAC_FILTER_MATRIX", &
621 description="Sets the threshold for filtering the matrices.", &
622 usage="EPS_IRAC_FILTER_MATRIX 1.0E-5", &
623 default_r_val=0.0_dp)
624 CALL section_add_keyword(section, keyword)
625 CALL keyword_release(keyword)
626
627 CALL keyword_create(keyword, __location__, name="EPS_IRAC", &
628 description="Targeted accuracy during the refinement iteration.", &
629 usage="EPS_IRAC 1.0E-5", &
630 default_r_val=1.0e-10_dp)
631 CALL section_add_keyword(section, keyword)
632 CALL keyword_release(keyword)
633
634 CALL keyword_create(keyword, __location__, name="EPS_IRAC_QUICK_EXIT", &
635 description="Only one extra refinement iteration is "// &
636 "done when the norm is below this value.", &
637 usage="EPS_IRAC_QUICK_EXIT 1.0E-2", &
638 default_r_val=1.0e-5_dp)
639 CALL section_add_keyword(section, keyword)
640 CALL keyword_release(keyword)
641
642 CALL keyword_create(keyword, __location__, name="EPS_IRAC_SWITCH", &
643 description="The algorithm switches to the polynomial "// &
644 "refinement when the norm is below this value.", &
645 usage="EPS_IRAC_SWITCH 1.0E-3", &
646 default_r_val=1.0e-2_dp)
647 CALL section_add_keyword(section, keyword)
648 CALL keyword_release(keyword)
649
650 CALL keyword_create(keyword, __location__, name="ON_THE_FLY_LOC", &
651 description="On the fly localization of the molecular orbitals. "// &
652 "Can only be used with OT/IRAC.", &
653 usage="ON_THE_FLY_LOC T", &
654 default_l_val=.false.)
655 CALL section_add_keyword(section, keyword)
656 CALL keyword_release(keyword)
657
658 CALL keyword_create( &
659 keyword, __location__, name="MINIMIZER", &
660 description="Minimizer to be used with the OT method", &
661 usage="MINIMIZER DIIS", &
662 default_i_val=ot_mini_cg, &
663 enum_c_vals=s2a("SD", "CG", "DIIS", "BROYDEN"), &
664 enum_desc=s2a("Steepest descent: not recommended", "Conjugate Gradients: most reliable, use for difficult systems."// &
665 " The total energy should decrease at every OT CG step if the line search is appropriate.", &
666 "Direct inversion in the iterative subspace: less reliable than CG, but sometimes about 50% faster", &
667 "Broyden mixing approximating the inverse Hessian"), &
669 CALL section_add_keyword(section, keyword)
670 CALL keyword_release(keyword)
671
672 CALL keyword_create(keyword, __location__, name="SAFE_DIIS", &
673 variants=["SAFER_DIIS"], &
674 description="Reject DIIS steps if they point away from the"// &
675 " minimum, do SD in that case.", &
676 usage="SAFE_DIIS ON", default_l_val=.true.)
677 CALL section_add_keyword(section, keyword)
678 CALL keyword_release(keyword)
679
680 CALL keyword_create(keyword, __location__, name="MAX_SCF_DIIS", &
681 description="Maximum DIIS SCF inner loop cycles. This can be used to extend"// &
682 " SCF cycles after a switch to DIIS (see eps_diis).", &
683 usage="MAX_SCF_DIIS 20", &
684 default_i_val=0)
685 CALL section_add_keyword(section, keyword)
686 CALL keyword_release(keyword)
687
688 CALL keyword_create(keyword, __location__, name="N_HISTORY_VEC", &
689 variants=s2a("NDIIS", "N_DIIS", "N_BROYDEN"), &
690 description="Number of history vectors to be used with DIIS or BROYDEN", &
691 usage="N_DIIS 4", &
692 default_i_val=7)
693 CALL section_add_keyword(section, keyword)
694 CALL keyword_release(keyword)
695
696 CALL keyword_create(keyword, __location__, name="BROYDEN_BETA", &
697 description="Underrelaxation for the broyden mixer", &
698 usage="BROYDEN_BETA 0.9", &
699 default_r_val=0.9_dp)
700 CALL section_add_keyword(section, keyword)
701 CALL keyword_release(keyword)
702
703 CALL keyword_create(keyword, __location__, name="BROYDEN_GAMMA", &
704 description="Backtracking parameter", &
705 usage="BROYDEN_GAMMA 0.5", &
706 default_r_val=0.5_dp)
707 CALL section_add_keyword(section, keyword)
708 CALL keyword_release(keyword)
709
710 CALL keyword_create(keyword, __location__, name="BROYDEN_SIGMA", &
711 description="Curvature of energy functional.", &
712 usage="BROYDEN_SIGMA 0.25", &
713 default_r_val=0.25_dp)
714 CALL section_add_keyword(section, keyword)
715 CALL keyword_release(keyword)
716
717 CALL keyword_create(keyword, __location__, name="BROYDEN_ETA", &
718 description="Dampening of estimated energy curvature.", &
719 usage="BROYDEN_ETA 0.7", &
720 default_r_val=0.7_dp)
721 CALL section_add_keyword(section, keyword)
722 CALL keyword_release(keyword)
723
724 CALL keyword_create(keyword, __location__, name="BROYDEN_OMEGA", &
725 description="Growth limit of curvature.", &
726 usage="BROYDEN_OMEGA 1.1", &
727 default_r_val=1.1_dp)
728 CALL section_add_keyword(section, keyword)
729 CALL keyword_release(keyword)
730
731 CALL keyword_create(keyword, __location__, name="BROYDEN_SIGMA_DECREASE", &
732 description="Reduction of curvature on bad approximation.", &
733 usage="BROYDEN_SIGMA_DECREASE 0.7", &
734 default_r_val=0.7_dp)
735 CALL section_add_keyword(section, keyword)
736 CALL keyword_release(keyword)
737
738 CALL keyword_create(keyword, __location__, name="BROYDEN_SIGMA_MIN", &
739 description="Minimum adaptive curvature.", &
740 usage="BROYDEN_SIGMA_MIN 0.05", &
741 default_r_val=0.05_dp)
742 CALL section_add_keyword(section, keyword)
743 CALL keyword_release(keyword)
744
745 CALL keyword_create(keyword, __location__, name="BROYDEN_FORGET_HISTORY", &
746 description="Forget history on bad approximation", &
747 usage="BROYDEN_FORGET_HISTORY OFF", default_l_val=.false., &
748 lone_keyword_l_val=.true.)
749 CALL section_add_keyword(section, keyword)
750 CALL keyword_release(keyword)
751
752 CALL keyword_create(keyword, __location__, name="BROYDEN_ADAPTIVE_SIGMA", &
753 description="Enable adaptive curvature estimation", &
754 usage="BROYDEN_ADAPTIVE_SIGMA ON", default_l_val=.true., &
755 lone_keyword_l_val=.true.)
756 CALL section_add_keyword(section, keyword)
757 CALL keyword_release(keyword)
758
759 CALL keyword_create(keyword, __location__, name="BROYDEN_ENABLE_FLIP", &
760 description="Ensure positive definite update", &
761 usage="BROYDEN_ENABLE_FLIP ON", default_l_val=.true., &
762 lone_keyword_l_val=.true.)
763 CALL section_add_keyword(section, keyword)
764 CALL keyword_release(keyword)
765
766 CALL keyword_create(keyword, __location__, name="LINESEARCH", &
767 variants=["LINE_SEARCH"], &
768 description="1D line search algorithm to be used with the OT minimizer,"// &
769 " in increasing order of robustness and cost. MINIMIZER CG combined with"// &
770 " LINESEARCH GOLD should always find an electronic minimum."// &
771 " Whereas the 2PNT minimizer is almost always OK, 3PNT might be needed for systems"// &
772 " in which successive OT CG steps do not decrease the total energy.", &
773 usage="LINESEARCH GOLD", &
774 default_i_val=ls_2pnt, &
775 enum_c_vals=s2a("ADAPT", "NONE", "2PNT", "3PNT", "GOLD"), &
776 enum_desc=s2a("extrapolates usually based on 3 points, "// &
777 "uses additional points on demand, very robust.", &
778 "always take steps of fixed length", &
779 "extrapolate based on 2 points", &
780 "extrapolate based on 3 points", &
781 "perform 1D golden section search of the minimum (very expensive)"), &
782 enum_i_vals=[ls_adapt, ls_none, ls_2pnt, ls_3pnt, ls_gold])
783 CALL section_add_keyword(section, keyword)
784 CALL keyword_release(keyword)
785
786 CALL keyword_create( &
787 keyword, __location__, name="STEPSIZE", &
788 description="Initial stepsize used for the line search, sometimes this parameter can be reduced to stabilize DIIS"// &
789 " or to improve the CG behavior in the first few steps."// &
790 " The optimal value depends on the quality of the preconditioner."// &
791 " A negative values leaves the choice to CP2K depending on the preconditioner.", &
792 usage="STEPSIZE 0.4", &
793 default_r_val=-1.0_dp)
794 CALL section_add_keyword(section, keyword)
795 CALL keyword_release(keyword)
796
797 CALL keyword_create(keyword, __location__, name="GOLD_TARGET", &
798 description="Target relative uncertainty in the location of the minimum for LINESEARCH GOLD", &
799 usage="GOLD_TARGET 0.1", &
800 default_r_val=0.01_dp)
801 CALL section_add_keyword(section, keyword)
802 CALL keyword_release(keyword)
803
804 CALL keyword_create( &
805 keyword, __location__, name="PRECONDITIONER", &
806 description="Type of preconditioner to be used with all minimization schemes. "// &
807 "They differ in effectiveness, cost of construction, cost of application. "// &
808 "Properly preconditioned minimization can be orders of magnitude faster than doing nothing.", &
809 usage="PRECONDITIONER FULL_ALL", &
810 default_i_val=ot_precond_full_kinetic, &
811 enum_c_vals=s2a("FULL_ALL", "FULL_SINGLE_INVERSE", "FULL_SINGLE", "FULL_KINETIC", "FULL_S_INVERSE", &
812 "NONE"), &
813 enum_desc=s2a("Most effective state selective preconditioner based on diagonalization, "// &
814 "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
815 "This preconditioner is recommended for almost all systems, except very large systems where "// &
816 "make_preconditioner would dominate the total computational cost.", &
817 "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
818 "but cheaper to construct, "// &
819 "might be somewhat less robust. Recommended for large systems.", &
820 "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
821 "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
822 "use for very large systems.", &
823 "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
824 "skip preconditioning"), &
828 CALL section_add_keyword(section, keyword)
829 CALL keyword_release(keyword)
830
831 CALL keyword_create(keyword, __location__, name="CHOLESKY", &
832 description="If FULL_ALL the cholesky decomposition of the S matrix is used. "// &
833 "Options on the algorithm to be used.", &
834 usage="CHOLESKY REDUCE", default_i_val=cholesky_reduce, &
835 enum_c_vals=s2a("OFF", "REDUCE", "RESTORE", "INVERSE", "INVERSE_DBCSR"), &
836 enum_desc=s2a("The cholesky algorithm is not used", "Reduce is called", &
837 "Reduce is replaced by two restore", &
838 "Restore uses operator multiply by inverse of the triangular matrix", &
839 "Like inverse, but matrix stored as dbcsr, sparce matrix algebra used when possible"), &
841 CALL section_add_keyword(section, keyword)
842 CALL keyword_release(keyword)
843
844 CALL keyword_create( &
845 keyword, __location__, name="PRECOND_SOLVER", &
846 description="How the preconditioner is applied to the residual.", &
847 usage="PRECOND_SOLVER DIRECT", &
848 default_i_val=ot_precond_solver_default, &
849 enum_c_vals=s2a("DEFAULT", "DIRECT", "INVERSE_CHOLESKY", "INVERSE_UPDATE"), &
850 enum_desc=s2a("the default", "Cholesky decomposition followed by triangular solve "// &
851 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
852 "Cholesky decomposition followed by explicit inversion "// &
853 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
854 "Performs a Hotelling update of the inverse if a previous preconditioner is present. "// &
855 "Mainly useful for GPU accelerated systems (works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)"), &
856 enum_i_vals=[ot_precond_solver_default, &
860 CALL section_add_keyword(section, keyword)
861 CALL keyword_release(keyword)
862
863 CALL keyword_create( &
864 keyword, __location__, name="ENERGY_GAP", &
865 description="Should be an estimate for the energy gap [a.u.] (HOMO-LUMO) and is used in preconditioning, "// &
866 "especially effective with the FULL_ALL preconditioner, in which case it should be an underestimate "// &
867 "of the gap (can be a small number, e.g. 0.002)."// &
868 " FULL_SINGLE_INVERSE takes it as lower bound (values below 0.05 can cause stability issues)."// &
869 " In general, higher values will tame the preconditioner in case of poor initial guesses."// &
870 " A negative value will leave the choice to CP2K depending on type of preconditioner.", &
871 usage="ENERGY_GAP 0.001", &
872 default_r_val=-1.0_dp)
873 CALL section_add_keyword(section, keyword)
874 CALL keyword_release(keyword)
875
876 CALL keyword_create( &
877 keyword, __location__, name="EPS_TAYLOR", &
878 variants=["EPSTAYLOR"], &
879 description="Target accuracy of the taylor expansion for the matrix functions, should normally be kept as is.", &
880 usage="EPS_TAYLOR 1.0E-15", &
881 default_r_val=1.0e-16_dp)
882 CALL section_add_keyword(section, keyword)
883 CALL keyword_release(keyword)
884
885 CALL keyword_create( &
886 keyword, __location__, name="MAX_TAYLOR", &
887 description="Maximum order of the Taylor expansion before diagonalisation is preferred, for large parallel runs"// &
888 " a slightly higher order could sometimes result in a small speedup.", &
889 usage="MAX_TAYLOR 5", &
890 default_i_val=4)
891 CALL section_add_keyword(section, keyword)
892 CALL keyword_release(keyword)
893
894 CALL keyword_create(keyword, __location__, name="ROTATION", &
895 description="Introduce additional variables so that rotations of the occupied"// &
896 " subspace are allowed as well, only needed for cases where the energy is not invariant under"// &
897 " a rotation of the occupied subspace such as non-singlet restricted calculations"// &
898 " or fractional occupations.", &
899 usage="ROTATION", lone_keyword_l_val=.true., &
900 default_l_val=.false.)
901 CALL section_add_keyword(section, keyword)
902 CALL keyword_release(keyword)
903
904 CALL keyword_create(keyword, __location__, name="ENERGIES", &
905 description="Optimize orbital energies for use in Fermi-Dirac smearing "// &
906 "(requires ROTATION and FD smearing to be active).", &
907 usage="ENERGIES", lone_keyword_l_val=.true., &
908 default_l_val=.false.)
909 CALL section_add_keyword(section, keyword)
910 CALL keyword_release(keyword)
911
912 CALL keyword_create(keyword, __location__, name="OCCUPATION_PRECONDITIONER", &
913 description="Preconditioner with the occupation numbers (FD smearing)", &
914 usage="OCCUPATION_PRECONDITIONER", lone_keyword_l_val=.true., &
915 default_l_val=.false.)
916 CALL section_add_keyword(section, keyword)
917 CALL keyword_release(keyword)
918
919 CALL keyword_create(keyword, __location__, name="NONDIAG_ENERGY", &
920 description="Add a non-diagonal energy penalty (FD smearing)", &
921 usage="NONDIAG_ENERGY", lone_keyword_l_val=.true., &
922 default_l_val=.false.)
923 CALL section_add_keyword(section, keyword)
924 CALL keyword_release(keyword)
925
926 CALL keyword_create(keyword, __location__, name="NONDIAG_ENERGY_STRENGTH", &
927 description="The prefactor for the non-diagonal energy penalty (FD smearing)", &
928 usage="NONDIAG_ENERGY_STRENGTH", default_r_val=1.0_dp)
929 CALL section_add_keyword(section, keyword)
930 CALL keyword_release(keyword)
931
932 END SUBROUTINE create_ot_section
933
934! **************************************************************************************************
935!> \brief creates the diagonalization section
936!> \param section ...
937!> \par History
938!> 10.2008 created [JGH]
939! **************************************************************************************************
940 SUBROUTINE create_diagonalization_section(section)
941 TYPE(section_type), POINTER :: section
942
943 TYPE(keyword_type), POINTER :: keyword
944 TYPE(section_type), POINTER :: subsection
945
946 cpassert(.NOT. ASSOCIATED(section))
947 CALL section_create(section, __location__, name="DIAGONALIZATION", &
948 description="Set up type and parameters for Kohn-Sham matrix diagonalization.", &
949 n_keywords=0, n_subsections=1, repeats=.false.)
950
951 NULLIFY (keyword)
952
953 CALL keyword_create(keyword, __location__, name="_SECTION_PARAMETERS_", &
954 description="controls the activation of the diagonalization method", &
955 usage="&DIAGONALIZATION T", &
956 default_l_val=.false., &
957 lone_keyword_l_val=.true.)
958 CALL section_add_keyword(section, keyword)
959 CALL keyword_release(keyword)
960
961 CALL keyword_create(keyword, __location__, name="ALGORITHM", &
962 description="Algorithm to be used for diagonalization", &
963 usage="ALGORITHM STANDARD", &
964 default_i_val=diag_standard, &
965 enum_c_vals=s2a("STANDARD", "OT", "LANCZOS", "DAVIDSON", "FILTER_MATRIX"), &
966 enum_desc=s2a("Standard diagonalization: LAPACK methods or Jacobi.", &
967 "Iterative diagonalization using OT method", &
968 "Block Krylov-space approach to self-consistent diagonalisation", &
969 "Preconditioned blocked Davidson", &
970 "Filter matrix diagonalization"), &
973 CALL section_add_keyword(section, keyword)
974 CALL keyword_release(keyword)
975
976 CALL keyword_create(keyword, __location__, name="JACOBI_THRESHOLD", &
977 description="Controls the accuracy of the pseudo-diagonalization method using Jacobi rotations", &
978 usage="JACOBI_THRESHOLD 1.0E-6", &
979 default_r_val=1.0e-7_dp, &
980 citations=[stewart1982])
981 CALL section_add_keyword(section, keyword)
982 CALL keyword_release(keyword)
983
984 CALL keyword_create(keyword, __location__, name="EPS_JACOBI", &
985 description="Below this threshold value for the SCF convergence the pseudo-diagonalization "// &
986 "method using Jacobi rotations is activated. This method is much faster than a "// &
987 "real diagonalization and it is even speeding up while achieving full convergence. "// &
988 "However, it needs a pre-converged wavefunction obtained by at least one real "// &
989 "diagonalization which is further optimized while keeping the original eigenvalue "// &
990 "spectrum. The MO eigenvalues are NOT updated. The method might be useful to speed "// &
991 "up calculations for large systems e.g. using a semi-empirical method.", &
992 usage="EPS_JACOBI 1.0E-5", &
993 default_r_val=0.0_dp, &
994 citations=[stewart1982])
995 CALL section_add_keyword(section, keyword)
996 CALL keyword_release(keyword)
997
998 CALL keyword_create(keyword, __location__, name="EPS_ADAPT", &
999 description="Required accuracy in iterative diagonalization as compared to current SCF convergence", &
1000 usage="EPS_ADAPT 0.01", &
1001 default_r_val=0._dp)
1002 CALL section_add_keyword(section, keyword)
1003 CALL keyword_release(keyword)
1004
1005 CALL keyword_create(keyword, __location__, name="MAX_ITER", &
1006 description="Maximum number of iterations in iterative diagonalization", &
1007 usage="MAX_ITER 20", &
1008 default_i_val=2)
1009 CALL section_add_keyword(section, keyword)
1010 CALL keyword_release(keyword)
1011
1012 CALL keyword_create(keyword, __location__, name="EPS_ITER", &
1013 description="Required accuracy in iterative diagonalization", &
1014 usage="EPS_ITER 1.e-8", &
1015 default_r_val=1.e-8_dp)
1016 CALL section_add_keyword(section, keyword)
1017 CALL keyword_release(keyword)
1018
1019 NULLIFY (subsection)
1020 CALL create_ot_section(subsection)
1021 CALL section_add_subsection(section, subsection)
1022 CALL section_release(subsection)
1023
1024 NULLIFY (subsection)
1025 CALL create_krylov_section(subsection)
1026 CALL section_add_subsection(section, subsection)
1027 CALL section_release(subsection)
1028
1029 NULLIFY (subsection)
1030 CALL create_diag_subspace_section(subsection)
1031 CALL section_add_subsection(section, subsection)
1032 CALL section_release(subsection)
1033
1034 NULLIFY (subsection)
1035 CALL create_davidson_section(subsection)
1036 CALL section_add_subsection(section, subsection)
1037 CALL section_release(subsection)
1038
1039 NULLIFY (subsection)
1040 CALL create_filtermatrix_section(subsection)
1041 CALL section_add_subsection(section, subsection)
1042 CALL section_release(subsection)
1043
1044 END SUBROUTINE create_diagonalization_section
1045
1046! **************************************************************************************************
1047!> \brief ...
1048!> \param section ...
1049! **************************************************************************************************
1050 SUBROUTINE create_davidson_section(section)
1051 TYPE(section_type), POINTER :: section
1052
1053 TYPE(keyword_type), POINTER :: keyword
1054
1055 cpassert(.NOT. ASSOCIATED(section))
1056 CALL section_create(section, __location__, name="DAVIDSON", &
1057 description=" ", &
1058 n_keywords=2, n_subsections=0, repeats=.false.)
1059
1060 NULLIFY (keyword)
1061
1062 CALL keyword_create( &
1063 keyword, __location__, name="PRECONDITIONER", &
1064 description="Type of preconditioner to be used with all minimization schemes. ", &
1065 usage="PRECONDITIONER FULL_ALL", &
1066 default_i_val=ot_precond_full_all, &
1067 enum_c_vals=s2a("FULL_ALL", "FULL_SINGLE_INVERSE", "NONE"), &
1068 enum_desc=s2a("Most effective state selective preconditioner based on diagonalization ", &
1069 "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
1070 "but cheaper to construct, might be somewhat less robust. Recommended for large systems.", &
1071 "skip preconditioning"), &
1073 citations=[vandevondele2003])
1074 CALL section_add_keyword(section, keyword)
1075 CALL keyword_release(keyword)
1076
1077 CALL keyword_create(keyword, __location__, name="PRECOND_SOLVER", &
1078 description="How the preconditioner is applied to the residual.", &
1079 usage="PRECOND_SOLVER DIRECT", &
1080 default_i_val=ot_precond_solver_default, &
1081 enum_c_vals=s2a("DEFAULT", "DIRECT", "INVERSE_CHOLESKY"), &
1082 enum_desc=s2a("the default", "Cholesky decomposition followed by triangular solve "// &
1083 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
1084 "Cholesky decomposition followed by explicit inversion "// &
1085 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)"), &
1086 enum_i_vals=[ot_precond_solver_default, &
1089 CALL section_add_keyword(section, keyword)
1090 CALL keyword_release(keyword)
1091
1092 CALL keyword_create( &
1093 keyword, __location__, name="ENERGY_GAP", &
1094 description="Should be an estimate for the energy gap [a.u.] (HOMO-LUMO) and is used in preconditioning, "// &
1095 "especially effective with the FULL_ALL preconditioner, in which case it should be an underestimate "// &
1096 "of the gap (0.001 doing normally fine). For the other preconditioners, making this value larger (0.2)"// &
1097 " will tame the preconditioner in case of poor initial guesses.", &
1098 usage="ENERGY_GAP 0.001", &
1099 default_r_val=0.2_dp)
1100 CALL section_add_keyword(section, keyword)
1101 CALL keyword_release(keyword)
1102
1103 CALL keyword_create(keyword, __location__, name="NEW_PREC_EACH", &
1104 description="Number of SCF iterations after which a new Preconditioner is computed", &
1105 usage="NEW_PREC_EACH 10", default_i_val=20)
1106 CALL section_add_keyword(section, keyword)
1107 CALL keyword_release(keyword)
1108
1109 CALL keyword_create(keyword, __location__, name="FIRST_PREC", &
1110 description="First SCF iteration at which a Preconditioner is employed", &
1111 usage="FIRST_PREC 1", default_i_val=1)
1112 CALL section_add_keyword(section, keyword)
1113 CALL keyword_release(keyword)
1114
1115 CALL keyword_create(keyword, __location__, name="CONV_MOS_PERCENT", &
1116 description="Minimal percent of MOS that have to converge within the Davidson loop"// &
1117 " before the SCF iteration is completed and a new Hamiltonian is computed", &
1118 usage="CONV_MOS_PERCENT 0.8", default_r_val=0.5_dp)
1119 CALL section_add_keyword(section, keyword)
1120 CALL keyword_release(keyword)
1121
1122 CALL keyword_create(keyword, __location__, name="SPARSE_MOS", &
1123 description="Use MOS as sparse matrix and avoid as much as possible multiplications with full matrices", &
1124 usage="SPARSE_MOS", default_l_val=.true., &
1125 lone_keyword_l_val=.true.)
1126 CALL section_add_keyword(section, keyword)
1127 CALL keyword_release(keyword)
1128
1129 END SUBROUTINE create_davidson_section
1130
1131! **************************************************************************************************
1132!> \brief ...
1133!> \param section ...
1134! **************************************************************************************************
1135 SUBROUTINE create_krylov_section(section)
1136 TYPE(section_type), POINTER :: section
1137
1138 TYPE(keyword_type), POINTER :: keyword
1139
1140 cpassert(.NOT. ASSOCIATED(section))
1141 CALL section_create(section, __location__, name="KRYLOV", &
1142 description=" ", &
1143 n_keywords=2, n_subsections=0, repeats=.false.)
1144
1145 NULLIFY (keyword)
1146
1147 CALL keyword_create(keyword, __location__, name="NKRYLOV", &
1148 description="Dimension of the Krylov space used for the Lanczos refinement", &
1149 usage="NKRYLOV 20", &
1150 default_i_val=4)
1151 CALL section_add_keyword(section, keyword)
1152 CALL keyword_release(keyword)
1153
1154 CALL keyword_create(keyword, __location__, name="NBLOCK", &
1155 description="Size of the block of vectors refined simultaneously by the Lanczos procedure", &
1156 usage="NBLOCK 1", &
1157 default_i_val=32)
1158 CALL section_add_keyword(section, keyword)
1159 CALL keyword_release(keyword)
1160
1161 CALL keyword_create(keyword, __location__, name="EPS_KRYLOV", &
1162 description="Convergence criterion for the MOs", &
1163 usage="EPS_KRYLOV 0.00001", &
1164 default_r_val=0.0000001_dp)
1165 CALL section_add_keyword(section, keyword)
1166 CALL keyword_release(keyword)
1167
1168 CALL keyword_create(keyword, __location__, name="EPS_STD_DIAG", &
1169 description="Level of convergence to be reached before starting the Lanczos procedure."// &
1170 " Above this threshold a standard diagonalization method is used."// &
1171 " If negative Lanczos is started at the first iteration", &
1172 usage="EPS_STD_DIAG 0.001", &
1173 default_r_val=-1.0_dp)
1174 CALL section_add_keyword(section, keyword)
1175 CALL keyword_release(keyword)
1176
1177 CALL keyword_create(keyword, __location__, name="CHECK_MOS_CONV", &
1178 description="This requires to check the convergence of MOS also when standard "// &
1179 "diagonalization steps are performed, if the block krylov approach is active.", &
1180 usage="CHECK_MOS_CONV T", &
1181 default_l_val=.false., &
1182 lone_keyword_l_val=.true.)
1183 CALL section_add_keyword(section, keyword)
1184 CALL keyword_release(keyword)
1185
1186 END SUBROUTINE create_krylov_section
1187
1188! **************************************************************************************************
1189!> \brief ...
1190!> \param section ...
1191! **************************************************************************************************
1192 SUBROUTINE create_diag_subspace_section(section)
1193 TYPE(section_type), POINTER :: section
1194
1195 TYPE(keyword_type), POINTER :: keyword
1196 TYPE(section_type), POINTER :: subsection
1197
1198 cpassert(.NOT. ASSOCIATED(section))
1199 CALL section_create(section, __location__, name="DIAG_SUB_SCF", &
1200 description="Activation of self-consistenf subspace refinement by diagonalization "// &
1201 "of H by adjusting the occupation but keeping the MOS unchanged.", &
1202 n_keywords=2, n_subsections=1, repeats=.false.)
1203
1204 NULLIFY (keyword, subsection)
1205
1206 CALL keyword_create(keyword, __location__, name="_SECTION_PARAMETERS_", &
1207 description="controls the activation of inner SCF loop to refine occupations in MOS subspace", &
1208 usage="&DIAG_SUB_SCF T", &
1209 default_l_val=.false., &
1210 lone_keyword_l_val=.true.)
1211 CALL section_add_keyword(section, keyword)
1212 CALL keyword_release(keyword)
1213
1214 CALL keyword_create(keyword, __location__, name="MAX_ITER", &
1215 description="Maximum number of iterations for the SCF inner loop", &
1216 usage="MAX_ITER 20", &
1217 default_i_val=2)
1218 CALL section_add_keyword(section, keyword)
1219 CALL keyword_release(keyword)
1220
1221 CALL keyword_create(keyword, __location__, name="EPS_ENE", &
1222 description="Required energy accuracy for convergence of subspace diagonalization", &
1223 usage="EPS_ENE 1.e-8", &
1224 default_r_val=1.e-4_dp)
1225 CALL section_add_keyword(section, keyword)
1226 CALL keyword_release(keyword)
1227
1228 CALL keyword_create(keyword, __location__, name="EPS_ADAPT_SCF", &
1229 description="Required density matrix accuracy as compared to current SCF convergence", &
1230 usage="EPS_ADAPT_SCF 1.e-1", &
1231 default_r_val=1._dp)
1232 CALL section_add_keyword(section, keyword)
1233 CALL keyword_release(keyword)
1234
1235 CALL keyword_create( &
1236 keyword, __location__, name="EPS_SKIP_SUB_DIAG", &
1237 description="Level of convergence to be reached before starting the internal loop of subspace rotations."// &
1238 " Above this threshold only the outer diagonalization method is used."// &
1239 " If negative the subspace rotation is started at the first iteration", &
1240 usage="EPS_SKIP_SUB_DIAG 0.001", &
1241 default_r_val=-1.0_dp)
1242 CALL section_add_keyword(section, keyword)
1243 CALL keyword_release(keyword)
1244
1245 CALL create_mixing_section(subsection)
1246 CALL section_add_subsection(section, subsection)
1247 CALL section_release(subsection)
1248 END SUBROUTINE create_diag_subspace_section
1249
1250! **************************************************************************************************
1251!> \brief Create CP2K input section for the smearing of occupation numbers
1252!> \param section ...
1253!> \date 27.08.2008
1254!> \author Matthias Krack (MK)
1255!> \version 1.0
1256! **************************************************************************************************
1257 SUBROUTINE create_smear_section(section)
1258
1259 TYPE(section_type), POINTER :: section
1260
1261 TYPE(keyword_type), POINTER :: keyword
1262
1263 cpassert(.NOT. ASSOCIATED(section))
1264
1265 CALL section_create(section, __location__, &
1266 name="SMEAR", &
1267 description="Controls smearing of MO occupation numbers for systems with small or zero gaps.", &
1268 n_keywords=6, &
1269 n_subsections=0, &
1270 repeats=.false.)
1271
1272 NULLIFY (keyword)
1273
1274 CALL keyword_create(keyword, __location__, &
1275 name="_SECTION_PARAMETERS_", &
1276 description="Controls the activation of smearing", &
1277 usage="&SMEAR ON", &
1278 default_l_val=.false., &
1279 lone_keyword_l_val=.true.)
1280 CALL section_add_keyword(section, keyword)
1281 CALL keyword_release(keyword)
1282
1283 CALL keyword_create(keyword, __location__, &
1284 name="METHOD", &
1285 description="Selects the smearing method to apply.", &
1286 usage="METHOD Fermi_Dirac", &
1287 default_i_val=smear_gaussian, &
1288 enum_c_vals=s2a("FERMI_DIRAC", "ENERGY_WINDOW", "LIST", "GAUSSIAN", &
1289 "METHFESSEL_PAXTON", "MARZARI_VANDERBILT"), &
1292 enum_desc=s2a("Fermi-Dirac distribution defined by the keyword ELECTRONIC_TEMPERATURE. "// &
1293 "Use this method if the temperature equivalence is important for you, "// &
1294 "e.g. if you want to compute some properties based on the occupations. "// &
1295 "If you use this method without interest in electronic temperature, "// &
1296 "it's suggested to use extrapolated result from finite ELECTRONIC_TEMPERATURE "// &
1297 "to ELECTRONIC_TEMPERATURE = 0. Note the forces and stress are consistent "// &
1298 "with the free energy and not with the extrapolated energy.", &
1299 "Energy window defined by the keyword WINDOW_SIZE.", &
1300 "Use a fixed list of occupations.", &
1301 "Gaussian broadening with width SIGMA; should work well in most cases. "// &
1302 "With this method you have to use extrapolated results from finite "// &
1303 "SIGMA results to SIGMA = 0, but usually this value would not be quite "// &
1304 "accurate without systematically reducing SIGMA. Note the forces and stress "// &
1305 "are consistent with the free energy and not with the extrapolated energy.", &
1306 "First-order Methfessel-Paxton distribution with width SIGMA. Don't "// &
1307 "use it for semiconductors and insulators because the partial "// &
1308 "occupancies can be unphysical and thus lead to wrong results.", &
1309 "Marzari-Vanderbilt cold smearing with width SIGMA."))
1310 CALL section_add_keyword(section, keyword)
1311 CALL keyword_release(keyword)
1312
1313 CALL keyword_create(keyword, __location__, &
1314 name="LIST", &
1315 description="A list of fractional occupations to use. Must match the number of states "// &
1316 "and sum up to the correct number of electrons", &
1317 repeats=.false., &
1318 n_var=-1, &
1319 type_of_var=real_t, &
1320 usage="LIST 2.0 0.6666 0.6666 0.66666 0.0 0.0")
1321 CALL section_add_keyword(section, keyword)
1322 CALL keyword_release(keyword)
1323
1324 CALL keyword_create(keyword, __location__, &
1325 name="ELECTRONIC_TEMPERATURE", &
1326 variants=s2a("ELEC_TEMP", "TELEC"), &
1327 description="Electronic temperature used for Fermi-Dirac smearing.", &
1328 repeats=.false., &
1329 n_var=1, &
1330 type_of_var=real_t, &
1331 default_r_val=cp_unit_to_cp2k(value=300.0_dp, unit_str="K"), &
1332 unit_str="K", &
1333 usage="ELECTRONIC_TEMPERATURE [K] 300")
1334 CALL section_add_keyword(section, keyword)
1335 CALL keyword_release(keyword)
1336
1337 CALL keyword_create(keyword, __location__, &
1338 name="EPS_FERMI_DIRAC", &
1339 description="Accuracy checks on occupation numbers use this as a tolerance", &
1340 repeats=.false., &
1341 n_var=1, &
1342 type_of_var=real_t, &
1343 default_r_val=1.0e-10_dp, &
1344 usage="EPS_FERMI_DIRAC 1.0E-6")
1345 CALL section_add_keyword(section, keyword)
1346 CALL keyword_release(keyword)
1347
1348 CALL keyword_create(keyword, __location__, &
1349 name="SIGMA", &
1350 description="Smearing width sigma (in energy units) in the case of "// &
1351 "Gaussian, Methfessel-Paxton or Marzari-Vanderbilt smearing.", &
1352 repeats=.false., &
1353 n_var=1, &
1354 type_of_var=real_t, &
1355 default_r_val=0.002_dp, &
1356 unit_str="au_e", &
1357 usage="SIGMA [eV] 0.2")
1358 CALL section_add_keyword(section, keyword)
1359 CALL keyword_release(keyword)
1360
1361 CALL keyword_create(keyword, __location__, &
1362 name="WINDOW_SIZE", &
1363 description="Size of the energy window centred at the Fermi level", &
1364 repeats=.false., &
1365 n_var=1, &
1366 type_of_var=real_t, &
1367 default_r_val=0.0_dp, &
1368 unit_str="au_e", &
1369 usage="WINDOW_SIZE [eV] 0.3")
1370 CALL section_add_keyword(section, keyword)
1371 CALL keyword_release(keyword)
1372
1373 CALL keyword_create(keyword, __location__, name="FIXED_MAGNETIC_MOMENT", &
1374 description="Imposed difference between the numbers of electrons of spin up "// &
1375 "and spin down: m = n(up) - n(down). A negative value (default) allows "// &
1376 "for a change of the magnetic moment. -1 specifically keeps an integer "// &
1377 "number of spin up and spin down electrons.", &
1378 repeats=.false., &
1379 n_var=1, &
1380 type_of_var=real_t, &
1381 default_r_val=-100.0_dp, &
1382 usage="FIXED_MAGNETIC_MOMENT 1.5")
1383 CALL section_add_keyword(section, keyword)
1384 CALL keyword_release(keyword)
1385
1386 END SUBROUTINE create_smear_section
1387
1388! **************************************************************************************************
1389!> \brief Creates the input section for defining CDFT constraints.
1390!> \param section the section to create
1391! **************************************************************************************************
1393 TYPE(section_type), POINTER :: section
1394
1395 TYPE(keyword_type), POINTER :: keyword
1396 TYPE(section_type), POINTER :: group_section, print_key, subsection
1397
1398 NULLIFY (keyword, subsection, group_section, print_key)
1399
1400 cpassert(.NOT. ASSOCIATED(section))
1401 CALL section_create(section, __location__, name="CDFT", &
1402 description="Parameters needed to set up a constrained DFT calculation."// &
1403 " Each repetition of the ATOM_GROUP section defines a new constraint."// &
1404 " The constraint(s) is (are) converged in a separate external SCF loop with settings"// &
1405 " read from the OUTER_SCF section. Supported constraints: Becke and Gaussian"// &
1406 " Hirshfeld (partial).", n_keywords=8, n_subsections=2, &
1407 repeats=.false., citations=[holmberg2017, holmberg2018])
1408
1409 NULLIFY (subsection, keyword)
1410 CALL create_outer_scf_section(subsection)
1411 CALL section_add_subsection(section, subsection)
1412 CALL section_release(subsection)
1413
1414 CALL create_becke_constraint_section(subsection)
1415 CALL section_add_subsection(section, subsection)
1416 CALL section_release(subsection)
1417
1418 CALL create_hirshfeld_constraint_section(subsection)
1419 CALL section_add_subsection(section, subsection)
1420 CALL section_release(subsection)
1421
1422 CALL keyword_create(keyword, __location__, name="TYPE_OF_CONSTRAINT", &
1423 description="Specifies the type of constraint used.", &
1424 usage="TYPE_OF_CONSTRAINT (NONE|HIRSHFELD|BECKE)", &
1425 enum_c_vals=s2a("NONE", "HIRSHFELD", "BECKE"), &
1428 enum_desc=s2a("No constraint (disables section).", &
1429 "Gaussian Hirshfeld constraint. Partial implementation: no forces. "// &
1430 "Requires corresponding section. Not as extensively tested.", &
1431 "Becke constraint. Requires corresponding section."), &
1432 citations=[becke1988b], &
1433 default_i_val=outer_scf_none)
1434 CALL section_add_keyword(section, keyword)
1435 CALL keyword_release(keyword)
1436
1437 CALL keyword_create(keyword, __location__, name="STRENGTH", &
1438 description="Constraint force constants (Lagrange multipliers). "// &
1439 "Give one value per constraint group.", &
1440 type_of_var=real_t, n_var=-1, &
1441 default_r_val=0.0_dp)
1442 CALL section_add_keyword(section, keyword)
1443 CALL keyword_release(keyword)
1444
1445 CALL keyword_create(keyword, __location__, name="TARGET", &
1446 description="Constraint target values. Give one value per constraint group. "// &
1447 "The target value is the desired number of valence electrons, spin moment, or the number of "// &
1448 "alpha or beta electrons on the atoms that define the constraint, suitably multiplied by "// &
1449 "atomic coefficients in case a relative constraint between two sets of atoms is employed. "// &
1450 "Note that core charges are not subtracted from the target value.", &
1451 usage="TARGET {real}", repeats=.false., &
1452 type_of_var=real_t, n_var=-1, &
1453 default_r_val=0.0_dp)
1454 CALL section_add_keyword(section, keyword)
1455 CALL keyword_release(keyword)
1456
1457 CALL keyword_create(keyword, __location__, name="ATOMIC_CHARGES", &
1458 description="Calculate atomic CDFT charges with selected weight function"// &
1459 " (Z = Z_core - Z_CDFT). With fragment based constraints, charges are"// &
1460 " relative to the fragment reference state i.e. Z = Z_CDFT -"// &
1461 " Z_frag_reference. Note: if the number of atoms is greater than the"// &
1462 " default pw_pool max cache, calculation of atomic CDFT charges"// &
1463 " will prompt harmless warnings during deallocation of atomic grids.", &
1464 usage="ATOMIC_CHARGES", &
1465 default_l_val=.false., lone_keyword_l_val=.true.)
1466 CALL section_add_keyword(section, keyword)
1467 CALL keyword_release(keyword)
1468
1469 CALL keyword_create(keyword, __location__, name="FRAGMENT_A_FILE_NAME", variants=["FRAGMENT_A_FILE"], &
1470 description="Name of the reference total electron density cube file for fragment A."// &
1471 " May include a path. The reference electron density needs to be outputted"// &
1472 " on the same grid as the full system (same cutoff and cell, output stride 1).", &
1473 usage="FRAGMENT_A_FILE_NAME <FILENAME>", &
1474 default_lc_val="fragment_a.cube")
1475 CALL section_add_keyword(section, keyword)
1476 CALL keyword_release(keyword)
1477
1478 CALL keyword_create(keyword, __location__, name="FRAGMENT_B_FILE_NAME", variants=["FRAGMENT_B_FILE"], &
1479 description="Name of the reference total electron density cube file for fragment B."// &
1480 " May include a path. The reference electron density needs to be outputted"// &
1481 " on the same grid as the full system (same cutoff and cell, output stride 1).", &
1482 usage="FRAGMENT_B_FILE_NAME <FILENAME>", &
1483 default_lc_val="fragment_b.cube")
1484 CALL section_add_keyword(section, keyword)
1485 CALL keyword_release(keyword)
1486
1487 CALL keyword_create(keyword, __location__, name="FRAGMENT_A_SPIN_FILE", &
1488 variants=["FRAGMENT_A_SPIN_FILE_NAME"], &
1489 description="Name of the reference spin density cube file for fragment A."// &
1490 " May include a path. The reference spin density needs to be outputted"// &
1491 " on the same grid as the full system (same cutoff and cell, output stride 1).", &
1492 usage="FRAGMENT_A_SPIN_FILE <FILENAME>", &
1493 default_lc_val="fragment_a_spin.cube")
1494 CALL section_add_keyword(section, keyword)
1495 CALL keyword_release(keyword)
1496
1497 CALL keyword_create(keyword, __location__, name="FRAGMENT_B_SPIN_FILE", &
1498 variants=["FRAGMENT_B_SPIN_FILE_NAME"], &
1499 description="Name of the reference spin density cube file for fragment B."// &
1500 " May include a path. The reference spin density needs to be outputted"// &
1501 " on the same grid as the full system (same cutoff and cell, output stride 1).", &
1502 usage="FRAGMENT_B_SPIN_FILE <FILENAME>", &
1503 default_lc_val="fragment_b_spin.cube")
1504 CALL section_add_keyword(section, keyword)
1505 CALL keyword_release(keyword)
1506
1507 CALL keyword_create(keyword, __location__, name="FLIP_FRAGMENT_A", &
1508 description="Logical which determines if the reference spin difference density "// &
1509 "(rho_alpha-rho_beta) for fragment A should be flipped. With default (off) "// &
1510 "value, the fragment is constrained to have more alpha than beta electrons "// &
1511 "if the isolated fragment has unpaired electrons. Useful in conjunction with "// &
1512 "FLIP_FRAGMENT_B.", &
1513 usage="FLIP_FRAGMENT_A", &
1514 default_l_val=.false., lone_keyword_l_val=.true.)
1515 CALL section_add_keyword(section, keyword)
1516 CALL keyword_release(keyword)
1517
1518 CALL keyword_create(keyword, __location__, name="FLIP_FRAGMENT_B", &
1519 description="Logical which determines if the reference spin difference density "// &
1520 "(rho_alpha-rho_beta) for fragment B should be flipped. With default (off) "// &
1521 "value, the fragment is constrained to have more alpha than beta electrons "// &
1522 "if the isolated fragment has unpaired electrons. Useful in conjunction with "// &
1523 "FLIP_FRAGMENT_A.", &
1524 usage="FLIP_FRAGMENT_B", &
1525 default_l_val=.false., lone_keyword_l_val=.true.)
1526 CALL section_add_keyword(section, keyword)
1527 CALL keyword_release(keyword)
1528
1529 CALL cp_print_key_section_create(print_key, __location__, "PROGRAM_RUN_INFO", &
1530 description="Controls the printing of basic info about the method.", &
1531 print_level=low_print_level, add_last=add_last_numeric, filename="__STD_OUT__")
1532
1533 CALL section_create(subsection, __location__, name="WEIGHT_FUNCTION", &
1534 description="Controls the printing of cube files with "// &
1535 "the CDFT weight function(s). Intended for single-point testing. "// &
1536 "In multistep simulations, generated cube files are overwritten each step.", &
1537 n_keywords=1, n_subsections=0, repeats=.false.)
1538
1539 CALL keyword_create(keyword, __location__, name="STRIDE", &
1540 description="The stride (X,Y,Z) used to write the cube file "// &
1541 "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
1542 " 1 number valid for all components.", &
1543 usage="STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=integer_t)
1544 CALL section_add_keyword(subsection, keyword)
1545 CALL keyword_release(keyword)
1546
1547 CALL section_add_subsection(print_key, subsection)
1548 CALL section_release(subsection)
1549
1550 CALL section_add_subsection(section, print_key)
1551 CALL section_release(print_key)
1552
1553 CALL section_create(group_section, __location__, name="ATOM_GROUP", &
1554 description="Define a group of atoms for use in a CDFT constraint. Each repetition of "// &
1555 "this section creates a new constraint.", &
1556 n_keywords=4, n_subsections=0, repeats=.true.)
1557
1558 CALL keyword_create(keyword, __location__, name="ATOMS", &
1559 description="Specifies the list of atoms that are included in the constraint group.", &
1560 usage="ATOMS {integer} {integer} .. {integer}", &
1561 n_var=-1, type_of_var=integer_t)
1562 CALL section_add_keyword(group_section, keyword)
1563 CALL keyword_release(keyword)
1564
1565 CALL keyword_create(keyword, __location__, name="COEFF", &
1566 description="Defines coefficients for the atoms in the list of atoms. Accepts values +/-1.0.", &
1567 usage="COEFF 1.0 -1.0", repeats=.true., &
1568 type_of_var=real_t, n_var=-1)
1569 CALL section_add_keyword(group_section, keyword)
1570 CALL keyword_release(keyword)
1571
1572 CALL keyword_create(keyword, __location__, name="CONSTRAINT_TYPE ", &
1573 description="Determines what type of constraint to apply. ", &
1574 usage="CONSTRAINT_TYPE (CHARGE|MAGNETIZATION|ALPHA|BETA)", &
1575 enum_c_vals=s2a("CHARGE", "MAGNETIZATION", "ALPHA", "BETA"), &
1578 enum_desc=s2a("Total charge density constraint (rho_alpha + rho_beta).", &
1579 "Magnetization density constraint (rho_alpha - rho_beta).", &
1580 "Alpha spin density constraint.", &
1581 "Beta spin density constraint."), &
1582 default_i_val=cdft_charge_constraint)
1583 CALL section_add_keyword(group_section, keyword)
1584 CALL keyword_release(keyword)
1585
1586 CALL keyword_create(keyword, __location__, name="FRAGMENT_CONSTRAINT", &
1587 description="Use a fragment based constraint. "// &
1588 "Takes as input the electron densities of two isolated fragments in the "// &
1589 "same geometry that they have in the full system. "// &
1590 "The isolated fragment densities are read from cube files defined in FRAGMENT_{A,B}_FILE. "// &
1591 "For magnetization density constraints, additional files containing the spin difference "// &
1592 "densities must be defined with the keywords FRAGMENT_{A,B}_SPIN_FILE. "// &
1593 "With this keyword active, the target value of the constraint is calculated from the "// &
1594 "the superposition of the isolated fragment densities. Supports only static calculations.", &
1595 usage="FRAGMENT_CONSTRAINT", &
1596 default_l_val=.false., lone_keyword_l_val=.true.)
1597 CALL section_add_keyword(group_section, keyword)
1598 CALL keyword_release(keyword)
1599
1600 CALL section_add_subsection(section, group_section)
1601 CALL section_release(group_section)
1602
1603 CALL section_create(group_section, __location__, name="DUMMY_ATOMS", &
1604 description="Define an extra group of atoms for which only atomic CDFT charges "// &
1605 "should be computed. The section cannot contain any constraint "// &
1606 "atoms that were included in section ATOM_GROUP.", &
1607 n_keywords=1, n_subsections=0, repeats=.true.)
1608
1609 CALL keyword_create(keyword, __location__, name="ATOMS", &
1610 description="Specifies the list of atoms that are included in the DUMMY_ATOMS group.", &
1611 usage="ATOMS {integer} {integer} .. {integer}", &
1612 n_var=-1, type_of_var=integer_t)
1613 CALL section_add_keyword(group_section, keyword)
1614 CALL keyword_release(keyword)
1615
1616 CALL section_add_subsection(section, group_section)
1617 CALL section_release(group_section)
1618
1619 CALL keyword_create(keyword, __location__, name="REUSE_PRECOND", &
1620 description="Reuse a previously built OT preconditioner between subsequent CDFT SCF iterations "// &
1621 "if the inner OT SCF loop converged in PRECOND_FREQ steps or less. Intended mainly for MD "// &
1622 "simulations with the FULL_ALL preconditioner to speed up the final iterations of the CDFT SCF loop.", &
1623 usage="REUSE_PRECOND yes", repeats=.false., n_var=1, &
1624 default_l_val=.false., lone_keyword_l_val=.true.)
1625 CALL section_add_keyword(section, keyword)
1626 CALL keyword_release(keyword)
1627
1628 CALL keyword_create(keyword, __location__, name="PRECOND_FREQ", &
1629 description="See REUSE_PRECOND.", &
1630 usage="PRECOND_FREQ {int}", default_i_val=0)
1631 CALL section_add_keyword(section, keyword)
1632 CALL keyword_release(keyword)
1633
1634 CALL keyword_create(keyword, __location__, name="MAX_REUSE", &
1635 description="Determines how many times a previously built preconditioner can be reused.", &
1636 usage="MAX_REUSE {int}", default_i_val=0)
1637 CALL section_add_keyword(section, keyword)
1638 CALL keyword_release(keyword)
1639
1640 CALL keyword_create(keyword, __location__, name="PURGE_HISTORY", &
1641 description="Purge wavefunction and constraint history to improve SCF convergence during MD."// &
1642 " Counts how often the convergence of the first CDFT SCF iteration takes 2 or more outer SCF"// &
1643 " iterations and purges the history if the counter exceeds PURGE_FREQ, and PURGE_OFFSET"// &
1644 " MD steps have passed since the last purge."// &
1645 " The counter is zeroed after each purge.", &
1646 usage="PURGE_HISTORY yes", repeats=.false., n_var=1, &
1647 default_l_val=.false., lone_keyword_l_val=.true.)
1648 CALL section_add_keyword(section, keyword)
1649 CALL keyword_release(keyword)
1650
1651 CALL keyword_create(keyword, __location__, name="PURGE_FREQ", &
1652 description="See PURGE_HISTORY.", &
1653 usage="PURGE_FREQ {int} ", default_i_val=1)
1654 CALL section_add_keyword(section, keyword)
1655 CALL keyword_release(keyword)
1656
1657 CALL keyword_create(keyword, __location__, name="PURGE_OFFSET", &
1658 description="See PURGE_HISTORY.", &
1659 usage="PURGE_OFFSET {int} ", default_i_val=1)
1660 CALL section_add_keyword(section, keyword)
1661 CALL keyword_release(keyword)
1662
1663 CALL keyword_create(keyword, __location__, name="COUNTER", &
1664 description="A counter to track the total number of energy evaluations. Needed by"// &
1665 " some optimizers to print information. Useful mainly for restarts.", &
1666 usage="COUNTER {int} ", default_i_val=0)
1667 CALL section_add_keyword(section, keyword)
1668 CALL keyword_release(keyword)
1669
1670 CALL keyword_create(keyword, __location__, name="IN_MEMORY", &
1671 description="Precompute gradients due to constraint during"// &
1672 " initial formation of constraint and store them in memory. Does"// &
1673 " nothing if forces are not calculated.", &
1674 usage="IN_MEMORY", &
1675 default_l_val=.false., lone_keyword_l_val=.true.)
1676 CALL section_add_keyword(section, keyword)
1677 CALL keyword_release(keyword)
1678
1679 END SUBROUTINE create_cdft_control_section
1680
1681! **************************************************************************************************
1682!> \brief Creates the input section for defining Gaussian Hirshfeld CDFT constraints.
1683!> \param section the section to create
1684! **************************************************************************************************
1685 SUBROUTINE create_hirshfeld_constraint_section(section)
1686 TYPE(section_type), POINTER :: section
1687
1688 TYPE(keyword_type), POINTER :: keyword
1689
1690 NULLIFY (keyword)
1691
1692 cpassert(.NOT. ASSOCIATED(section))
1693 CALL section_create(section, __location__, name="HIRSHFELD_CONSTRAINT", &
1694 description="Parameters for CDFT with a Gaussian Hirshfeld constraint.", &
1695 n_keywords=11, n_subsections=0, repeats=.false.)
1696
1697 CALL keyword_create(keyword, __location__, name="SHAPE_FUNCTION", &
1698 description="Type of shape function used for Hirshfeld partitioning.", &
1699 usage="SHAPE_FUNCTION {Gaussian,Density}", repeats=.false., n_var=1, &
1700 default_i_val=shape_function_gaussian, &
1701 enum_c_vals=s2a("GAUSSIAN", "DENSITY"), &
1702 enum_desc=s2a("One Gaussian per atom with radius determined by the keyword GAUSSIAN_SHAPE.", &
1703 "Atomic density expanded in terms of multiple Gaussians."), &
1705 CALL section_add_keyword(section, keyword)
1706 CALL keyword_release(keyword)
1707
1708 CALL keyword_create(keyword, __location__, name="GAUSSIAN_SHAPE", &
1709 description="Specifies the type of Gaussian used for SHAPE_FUNCTION GAUSSIAN.", &
1710 usage="GAUSSIAN_SHAPE (SINGLE|VDW|COVALENT|USER)", &
1711 enum_c_vals=s2a("DEFAULT", "SINGLE", "VDW", "COVALENT", "USER"), &
1713 enum_desc=s2a("Use covalent radii (in angstrom) to construct Gaussians, but fixed"// &
1714 " 1.0_dp radius for elements with a radius larger than this value.", &
1715 "Single Gaussian for all atom types with radius given by GAUSSIAN_RADIUS.", &
1716 "Use van der Waals radii to construct Gaussians.", &
1717 "Use covalent radii to construct Gaussians.", &
1718 "Use user defined radii (keyword ATOMIC_RADII) to construct Gaussians."), &
1719 default_i_val=radius_default)
1720 CALL section_add_keyword(section, keyword)
1721 CALL keyword_release(keyword)
1722
1723 CALL keyword_create(keyword, __location__, name="GAUSSIAN_RADIUS", &
1724 description="Radius parameter controlling the creation of Gaussians.", &
1725 usage="GAUSSIAN_RADIUS <REAL>", &
1726 unit_str="angstrom", &
1727 default_r_val=cp_unit_to_cp2k(3.0_dp, "angstrom"), &
1728 type_of_var=real_t, n_var=1)
1729 CALL section_add_keyword(section, keyword)
1730 CALL keyword_release(keyword)
1731
1732 CALL keyword_create(keyword, __location__, name="ATOMIC_RADII", &
1733 description="Defines custom radii to setup the spherical Gaussians. "// &
1734 "Give one value per element in the same order as they "// &
1735 "appear in the input coordinates.", &
1736 usage="ATOMIC_RADII {real} {real} {real}", repeats=.false., &
1737 unit_str="angstrom", &
1738 type_of_var=real_t, n_var=-1)
1739 CALL section_add_keyword(section, keyword)
1740 CALL keyword_release(keyword)
1741
1742 CALL keyword_create(keyword, __location__, name="USE_BOHR", &
1743 description="Convert the Gaussian radius from angstrom to bohr. This results in a larger "// &
1744 "Gaussian than without unit conversion.", &
1745 usage="USE_BOHR .TRUE.", &
1746 default_l_val=.false., lone_keyword_l_val=.true.)
1747 CALL section_add_keyword(section, keyword)
1748 CALL keyword_release(keyword)
1749
1750 CALL keyword_create(keyword, __location__, name="PRINT_DENSITY", &
1751 description="Logical to control printing of Hirshfeld densities to .cube file.", &
1752 usage="PRINT_DENSITY TRUE", &
1753 default_l_val=.false., lone_keyword_l_val=.true.)
1754 CALL section_add_keyword(section, keyword)
1755 CALL keyword_release(keyword)
1756
1757 CALL keyword_create(keyword, __location__, name="ATOMS_MEMORY", &
1758 description="Number of atomic gradients to store in memory.", &
1759 usage="ATOMS_MEMORY", &
1760 n_var=1, type_of_var=integer_t, &
1761 default_i_val=80)
1762 CALL section_add_keyword(section, keyword)
1763 CALL keyword_release(keyword)
1764
1765 CALL keyword_create(keyword, __location__, name="USE_ATOMIC_CUTOFF", &
1766 description="Logical to control use of ATOMIC_CUTOFF.", &
1767 usage="USE_ATOMIC_CUTOFF TRUE", &
1768 default_l_val=.true., lone_keyword_l_val=.true.)
1769 CALL section_add_keyword(section, keyword)
1770 CALL keyword_release(keyword)
1771
1772 CALL keyword_create(keyword, __location__, name="EPS_CUTOFF", &
1773 description="Numerical cutoff for calculation of weight function.", &
1774 usage="EPS_CUTOFF {real} ", default_r_val=1.0e-12_dp)
1775 CALL section_add_keyword(section, keyword)
1776 CALL keyword_release(keyword)
1777
1778 CALL keyword_create(keyword, __location__, name="ATOMIC_CUTOFF", &
1779 description="Numerical cutoff for calculation of Hirshfeld densities.", &
1780 usage="ATOMIC_CUTOFF {real} ", default_r_val=1.0e-12_dp)
1781 CALL section_add_keyword(section, keyword)
1782 CALL keyword_release(keyword)
1783
1784 END SUBROUTINE create_hirshfeld_constraint_section
1785
1786! **************************************************************************************************
1787!> \brief Create input section to define CDFT constraint settings specific to Becke weight function.
1788!> \param section the section to create
1789! **************************************************************************************************
1790 SUBROUTINE create_becke_constraint_section(section)
1791 TYPE(section_type), POINTER :: section
1792
1793 TYPE(keyword_type), POINTER :: keyword
1794
1795 NULLIFY (keyword)
1796 cpassert(.NOT. ASSOCIATED(section))
1797 CALL section_create(section, __location__, name="BECKE_CONSTRAINT", &
1798 description="Define settings influencing the construction of the Becke weight function.", &
1799 n_keywords=13, repeats=.false., citations=[becke1988b])
1800
1801 CALL keyword_create(keyword, __location__, name="ADJUST_SIZE", &
1802 description="Adjust Becke cell boundaries with atomic"// &
1803 " radii to generate a heteronuclear cutoff profile. These"// &
1804 " radii are defined with the keyword ATOMIC_RADII.", &
1805 usage="ADJUST_SIZE", &
1806 default_l_val=.false., lone_keyword_l_val=.true.)
1807 CALL section_add_keyword(section, keyword)
1808 CALL keyword_release(keyword)
1809
1810 CALL keyword_create(keyword, __location__, name="ATOMIC_RADII", &
1811 description="Defines atomic radii to generate a heteronuclear cutoff profile."// &
1812 " Give one value per element in the same order as they"// &
1813 " appear in the input coordinates.", &
1814 usage="ATOMIC_RADII {real} {real} {real}", repeats=.false., &
1815 unit_str="angstrom", &
1816 type_of_var=real_t, n_var=-1)
1817 CALL section_add_keyword(section, keyword)
1818 CALL keyword_release(keyword)
1819
1820 CALL keyword_create(keyword, __location__, name="SHOULD_SKIP", &
1821 description="If grid point is farther than GLOBAL_CUTOFF from all constraint atoms, "// &
1822 "move directly to next grid point, thus saving computational resources.", &
1823 usage="SHOULD_SKIP", &
1824 default_l_val=.false., lone_keyword_l_val=.true.)
1825 CALL section_add_keyword(section, keyword)
1826 CALL keyword_release(keyword)
1827
1828 CALL keyword_create(keyword, __location__, name="CAVITY_CONFINE", &
1829 description="Activates Gaussian cavity confinement. The constraint is evaluated only inside "// &
1830 "the cavity. The cavity is formed by summing spherical Gaussians centered on the constraint atoms.", &
1831 usage="CAVITY_CONFINE", &
1832 default_l_val=.false., lone_keyword_l_val=.true.)
1833 CALL section_add_keyword(section, keyword)
1834 CALL keyword_release(keyword)
1835
1836 CALL keyword_create(keyword, __location__, name="CAVITY_SHAPE", &
1837 description="Specifies the type of Gaussian cavity used.", &
1838 usage="CAVITY_SHAPE (SINGLE|VDW|COVALENT|USER)", &
1839 enum_c_vals=s2a("DEFAULT", "SINGLE", "VDW", "COVALENT", "USER"), &
1841 enum_desc=s2a("Use covalent radii (in angstrom) to construct Gaussians, but fixed"// &
1842 " 1.0_dp radius for elements with a radius larger than this value.", &
1843 "Single Gaussian for all atom types with radius given by CAVITY_RADIUS.", &
1844 "Use van der Waals radii to construct Gaussians.", &
1845 "Use covalent radii to construct Gaussians.", &
1846 "Use user defined radii (keyword ATOMIC_RADII) to construct Gaussians."), &
1847 default_i_val=radius_default)
1848 CALL section_add_keyword(section, keyword)
1849 CALL keyword_release(keyword)
1850
1851 CALL keyword_create(keyword, __location__, name="CAVITY_USE_BOHR", &
1852 description="Convert the cavity radius from angstrom to bohr. This results in a larger"// &
1853 " confinement cavity than without unit conversion.", &
1854 usage="CAVITY_USE_BOHR TRUE", &
1855 default_l_val=.false., lone_keyword_l_val=.true.)
1856 CALL section_add_keyword(section, keyword)
1857 CALL keyword_release(keyword)
1858
1859 CALL keyword_create(keyword, __location__, name="CAVITY_PRINT", &
1860 description="Print cavity in Gaussian cube file format. Currently, printing options"// &
1861 " are hardcoded.", &
1862 usage="CAVITY_PRINT", &
1863 default_l_val=.false., lone_keyword_l_val=.true.)
1864 CALL section_add_keyword(section, keyword)
1865 CALL keyword_release(keyword)
1866
1867 CALL keyword_create(keyword, __location__, name="CAVITY_RADIUS", &
1868 description="Radius parameter controlling the creation of Gaussian cavity confinement.", &
1869 usage="CAVITY_RADIUS <REAL>", &
1870 unit_str="angstrom", &
1871 default_r_val=cp_unit_to_cp2k(3.0_dp, "angstrom"), &
1872 type_of_var=real_t, n_var=1)
1873 CALL section_add_keyword(section, keyword)
1874 CALL keyword_release(keyword)
1875
1876 CALL keyword_create(keyword, __location__, name="EPS_CAVITY", &
1877 description="Density threshold for cavity creation. Grid points where the Gaussian"// &
1878 " density falls below the threshold are ignored.", &
1879 usage="EPS_CAVITY {real} ", default_r_val=1.0e-6_dp)
1880 CALL section_add_keyword(section, keyword)
1881 CALL keyword_release(keyword)
1882
1883 CALL keyword_create(keyword, __location__, name="CUTOFF_TYPE", &
1884 description="Specifies the type of cutoff used when building the Becke weight function.", &
1885 usage="CUTOFF_TYPE (GLOBAL|ELEMENT)", &
1886 enum_c_vals=s2a("GLOBAL", "ELEMENT"), &
1888 enum_desc=s2a("Use a single value for all elements. Read from GLOBAL_CUTOFF.", &
1889 "Use a different value for all elements. Values read from ELEMENT_CUTOFF."), &
1890 default_i_val=becke_cutoff_global)
1891 CALL section_add_keyword(section, keyword)
1892 CALL keyword_release(keyword)
1893
1894 CALL keyword_create(keyword, __location__, name="GLOBAL_CUTOFF", &
1895 description="Parameter used to select which atoms contribute to the"// &
1896 " weight function at each real space grid point.", &
1897 usage="GLOBAL_CUTOFF <REAL>", &
1898 unit_str="angstrom", &
1899 default_r_val=cp_unit_to_cp2k(3.1750632515_dp, "angstrom"), &
1900 type_of_var=real_t, n_var=1)
1901 CALL section_add_keyword(section, keyword)
1902 CALL keyword_release(keyword)
1903
1904 CALL keyword_create(keyword, __location__, name="ELEMENT_CUTOFF", &
1905 description="Defines element specific cutoffs to decide which atoms contribute to the"// &
1906 " weight function at each real space grid point. Give one value per element in the same"// &
1907 " order as they appear in the coordinates.", &
1908 usage="ELEMENT_CUTOFF {real} {real} {real}", repeats=.false., &
1909 unit_str="angstrom", &
1910 type_of_var=real_t, n_var=-1)
1911 CALL section_add_keyword(section, keyword)
1912 CALL keyword_release(keyword)
1913
1914 CALL keyword_create(keyword, __location__, name="IN_MEMORY", &
1915 description="Precompute gradients due to Becke constraint during"// &
1916 " initial formation of constraint and store them in memory. Useful"// &
1917 " in combination with confinement, memory intensive otherwise. Does"// &
1918 " nothing if forces are not calculated.", &
1919 usage="IN_MEMORY", &
1920 default_l_val=.false., lone_keyword_l_val=.true.)
1921 CALL section_add_keyword(section, keyword)
1922 CALL keyword_release(keyword)
1923
1924 END SUBROUTINE create_becke_constraint_section
1925
1926! **************************************************************************************************
1927!> \brief creates the input section for parameters related to CDFT specific optimizers
1928!> \param section the section to be created
1929!> \par History
1930!> 03.2018 separated from create_outer_scf_section [Nico Holmberg]
1931!> \author Nico Holmberg
1932! **************************************************************************************************
1933 SUBROUTINE create_cdft_opt_section(section)
1934 TYPE(section_type), POINTER :: section
1935
1936 TYPE(keyword_type), POINTER :: keyword
1937
1938 cpassert(.NOT. ASSOCIATED(section))
1939 CALL section_create(section, __location__, name="CDFT_OPT", &
1940 description="Parameters controlling optimization methods that are compatible "// &
1941 "only with CDFT based constraints (i.e. CDFT SCF is active). Specifically, "// &
1942 "the control parameters for the Broyden and Newton optimizers are defined in this "// &
1943 "section.", &
1944 n_keywords=10, n_subsections=0, repeats=.false.)
1945
1946 NULLIFY (keyword)
1947
1948 CALL keyword_create(keyword, __location__, name="BROYDEN_TYPE", &
1949 description="Specifies the Broyden optimizer variant to use.", &
1950 usage="BROYDEN_TYPE BT1", &
1951 default_i_val=broyden_type_1, &
1952 enum_c_vals=s2a("BT1", "BT1_EXPLICIT", "BT2", "BT2_EXPLICIT", &
1953 "BT1_LS", "BT1_EXPLICIT_LS", "BT2_LS", "BT2_EXPLICIT_LS"), &
1954 enum_desc=s2a("Broyden's first method, also known as the good method. The initial Jacobian"// &
1955 " is built from MD history if available. Otherwise switches to SD for one"// &
1956 " SCF iteration until a Jacobian can be built from the SCF history.", &
1957 "Same as BT1, but computes the explicit Jacobian with finite differences. "// &
1958 "Requires a CDFT SCF procedure to be active.", &
1959 "Same as BT1, but uses Broyden's second method, also known as the bad method.", &
1960 "Same as BT1_EXPLICIT, but using Broyden's second method.", &
1961 "Same as BT1, but uses backtracking line search for optimizing the step size "// &
1962 "(see optimizer NEWTON_LS).", &
1963 "Same as BT1_EXPLICIT, but uses backtracking line search for optimizing the step size.", &
1964 "Same as BT2, but uses backtracking line search for optimizing the step size.", &
1965 "Same as BT2_EXPLICIT, but uses backtracking line search for optimizing the step size."), &
1969 CALL section_add_keyword(section, keyword)
1970 CALL keyword_release(keyword)
1971
1972 CALL keyword_create(keyword, __location__, name="JACOBIAN_TYPE", &
1973 description="Finite difference method used to calculate the inverse Jacobian "// &
1974 "needed by some optimizers. Compatible only with CDFT constraints.", &
1975 usage="JACOBIAN_TYPE FD1", &
1976 default_i_val=jacobian_fd1, &
1977 enum_c_vals=s2a("FD1", "FD1_BACKWARD", "FD2", "FD2_BACKWARD", "FD1_CENTRAL"), &
1978 enum_desc=s2a("First order forward difference (one extra energy evaluation per constraint).", &
1979 "First order backward difference (one extra energy evaluation per constraint).", &
1980 "Second order forward difference (two extra energy evaluations per constraint).", &
1981 "Second order backward difference (two extra energy evaluations per constraint).", &
1982 "First order central difference (two extra energy evaluations per constraint)."), &
1985 CALL section_add_keyword(section, keyword)
1986 CALL keyword_release(keyword)
1987
1988 CALL keyword_create(keyword, __location__, name="JACOBIAN_STEP", &
1989 description="Step size to use in the calculation of the inverse Jacobian with finite differences. "// &
1990 "Expects one value for all constraints, or one value per constraint.", &
1991 usage="JACOBIAN_STEP 5.0E-3 ", n_var=-1, default_r_val=5.0e-3_dp)
1992 CALL section_add_keyword(section, keyword)
1993 CALL keyword_release(keyword)
1994
1995 CALL keyword_create(keyword, __location__, name="JACOBIAN_FREQ", &
1996 description="Defines parameters that control how often the explicit Jacobian is built,"// &
1997 " which is needed by some optimizers. Expects two values. The first value"// &
1998 " determines how many consecutive CDFT SCF iterations should skip a rebuild,"// &
1999 " whereas the latter how many MD steps. The values can be zero (meaning never"// &
2000 " rebuild) or positive. Both values cannot be zero.", &
2001 usage="JACOBIAN_FREQ 1 1", n_var=2, &
2002 default_i_vals=[1, 1], type_of_var=integer_t)
2003 CALL section_add_keyword(section, keyword)
2004 CALL keyword_release(keyword)
2005
2006 CALL keyword_create(keyword, __location__, name="JACOBIAN_RESTART", &
2007 description="Restart the inverse Jacobian using the vector defined with keyword JACOBIAN_VECTOR.", &
2008 usage="JACOBIAN_RESTART TRUE", &
2009 default_l_val=.false., lone_keyword_l_val=.true.)
2010 CALL section_add_keyword(section, keyword)
2011 CALL keyword_release(keyword)
2012
2013 CALL keyword_create(keyword, __location__, name="JACOBIAN_VECTOR", &
2014 description="Defines the inverse Jacobian matrix. Useful for restarting calculations. "// &
2015 "Expects n^2 values where n is the total number of constraints. "// &
2016 "The matrix should be given in row major order.", &
2017 usage="JACOBIAN_VECTOR 1.0 0.0", n_var=-1, type_of_var=real_t)
2018 CALL section_add_keyword(section, keyword)
2019 CALL keyword_release(keyword)
2020
2021 CALL keyword_create(keyword, __location__, name="MAX_LS", &
2022 description="The maximum number of backtracking line search steps to perform.", &
2023 usage="MAX_LS 5", default_i_val=5)
2024 CALL section_add_keyword(section, keyword)
2025 CALL keyword_release(keyword)
2026
2027 CALL keyword_create(keyword, __location__, name="FACTOR_LS", &
2028 description="Control parameter for backtracking line search. The step size is reduced by "// &
2029 "this factor on every line search iteration. Value must be between 0 and 1 (exclusive).", &
2030 usage="FACTOR_LS 0.5", default_r_val=0.5_dp)
2031 CALL section_add_keyword(section, keyword)
2032 CALL keyword_release(keyword)
2033
2034 CALL keyword_create(keyword, __location__, name="CONTINUE_LS", &
2035 description="Continue backtracking line search until MAX_LS steps are reached or the "// &
2036 "norm of the CDFT gradient no longer decreases. Default (false) behavior exits the "// &
2037 "line search procedure on the first step that the gradient decreases.", &
2038 usage="CONTINUE_LS TRUE", &
2039 default_l_val=.false., lone_keyword_l_val=.true.)
2040 CALL section_add_keyword(section, keyword)
2041 CALL keyword_release(keyword)
2042
2043 END SUBROUTINE create_cdft_opt_section
2044
2045! **************************************************************************************************
2046!> \brief Create CP2K input section for the grand canonical SCF
2047!> \param section ...
2048!> \date
2049!> \author Ziwei Chai
2050!> \version 1.0
2051! **************************************************************************************************
2052 SUBROUTINE create_gce_section(section)
2053
2054 TYPE(section_type), POINTER :: section
2055
2056 TYPE(keyword_type), POINTER :: keyword
2057
2058 cpassert(.NOT. ASSOCIATED(section))
2059
2060 CALL section_create(section, __location__, &
2061 name="GCE", &
2062 description="Enables grand canonical SCF calculations for "// &
2063 "slab models with a target work function specified by the "// &
2064 "user. The current implementation is intended for three "// &
2065 "dimensional periodic calculations and should be used "// &
2066 "together with the planar counter charge model. The planar "// &
2067 "counter charge screens the net charge of the DFT slab, so "// &
2068 "that the work function can be obtained from the planar "// &
2069 "averaged Hartree potential in the implicit solvent region "// &
2070 "or vacuum region. During the SCF iterations, the work "// &
2071 "function is mixed toward the target value. "// &
2072 "The reported GCE charges during SCF iterations are the "// &
2073 "current net charge of the DFT system excluding the planar "// &
2074 "counter charge. A positive value means electron deficiency. "// &
2075 "The input CHARGE value in the DFT section defines the "// &
2076 "reference charge state. The quantity N_e^(abs,alpha) is "// &
2077 "evaluated as the input CHARGE value minus the reported GCE "// &
2078 "charge. The reported GCE free energy is the sum of the DFT "// &
2079 "total energy and the product of the target work function "// &
2080 "and N_e^(abs,alpha).", &
2081 citations=[chai2024a], &
2082 n_keywords=3, &
2083 n_subsections=0, &
2084 repeats=.false.)
2085
2086 NULLIFY (keyword)
2087
2088 CALL keyword_create(keyword, __location__, &
2089 name="_SECTION_PARAMETERS_", &
2090 description="Controls the activation of grand canonical SCF", &
2091 usage="&GCE ON", &
2092 default_l_val=.false., &
2093 lone_keyword_l_val=.true.)
2094 CALL section_add_keyword(section, keyword)
2095 CALL keyword_release(keyword)
2096
2097 CALL keyword_create(keyword, __location__, &
2098 name="TARGET_WORKFUNCTION", &
2099 description="The user input target work function of the symmetric slab model", &
2100 repeats=.false., &
2101 n_var=1, &
2102 type_of_var=real_t, &
2103 default_r_val=0.16_dp, &
2104 unit_str="au_e", &
2105 usage="TARGET_WORKFUNCTION [eV] 0.16")
2106 CALL section_add_keyword(section, keyword)
2107 CALL keyword_release(keyword)
2108
2109 CALL keyword_create(keyword, __location__, &
2110 name="MIXING_COEF", &
2111 description="The proportion of the target work function mixed with the "// &
2112 "work function of the previous SCF iteration", &
2113 repeats=.false., &
2114 n_var=1, &
2115 type_of_var=real_t, &
2116 default_r_val=0.3_dp, &
2117 usage="MIXING_COEF 0.3")
2118 CALL section_add_keyword(section, keyword)
2119 CALL keyword_release(keyword)
2120
2121 END SUBROUTINE create_gce_section
2122
2123END MODULE input_cp2k_scf
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public vandevondele2003
integer, save, public holmberg2017
integer, save, public vandevondele2005a
integer, save, public schiffmann2015
integer, save, public weber2008
integer, save, public holmberg2018
integer, save, public becke1988b
integer, save, public stewart1982
integer, save, public chai2024a
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public low_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
unit conversion facility
Definition cp_units.F:30
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Definition cp_units.F:1222
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public jacobian_fd1_central
integer, parameter, public smear_fermi_dirac
integer, parameter, public core_guess
integer, parameter, public mopac_guess
integer, parameter, public ls_adapt
integer, parameter, public radius_vdw
integer, parameter, public outer_scf_optimizer_sd
integer, parameter, public cholesky_restore
integer, parameter, public ot_chol_irac
integer, parameter, public cdft_beta_constraint
integer, parameter, public broyden_type_2_explicit_ls
integer, parameter, public cdft_magnetization_constraint
integer, parameter, public outer_scf_optimizer_bisect
integer, parameter, public outer_scf_optimizer_secant
integer, parameter, public smear_energy_window
integer, parameter, public ls_3pnt
integer, parameter, public diag_block_krylov
integer, parameter, public becke_cutoff_element
integer, parameter, public outer_scf_cdft_constraint
integer, parameter, public broyden_type_1_explicit
integer, parameter, public no_guess
integer, parameter, public broyden_type_2_ls
integer, parameter, public jacobian_fd2
integer, parameter, public broyden_type_1
integer, parameter, public radius_default
integer, parameter, public outer_scf_optimizer_broyden
integer, parameter, public atomic_guess
integer, parameter, public broyden_type_1_explicit_ls
integer, parameter, public ot_algo_irac
integer, parameter, public outer_scf_basis_center_opt
integer, parameter, public cholesky_dbcsr
integer, parameter, public broyden_type_2_explicit
integer, parameter, public outer_scf_s2_constraint
integer, parameter, public ot_algo_taylor_or_diag
integer, parameter, public ot_poly_irac
integer, parameter, public history_guess
integer, parameter, public cholesky_off
integer, parameter, public cdft_charge_constraint
integer, parameter, public smear_list
integer, parameter, public jacobian_fd1
integer, parameter, public broyden_type_2
integer, parameter, public ot_mini_cg
integer, parameter, public ot_precond_full_kinetic
integer, parameter, public cholesky_reduce
integer, parameter, public high_spin_roks
integer, parameter, public cholesky_inverse
integer, parameter, public ot_mini_diis
integer, parameter, public diag_ot
integer, parameter, public outer_scf_ddapc_constraint
integer, parameter, public ot_precond_solver_default
integer, parameter, public outer_scf_becke_constraint
integer, parameter, public radius_user
integer, parameter, public random_guess
integer, parameter, public ot_precond_full_single
integer, parameter, public smear_gaussian
integer, parameter, public ot_precond_solver_inv_chol
integer, parameter, public shape_function_density
integer, parameter, public outer_scf_hirshfeld_constraint
integer, parameter, public radius_covalent
integer, parameter, public jacobian_fd1_backward
integer, parameter, public ot_precond_none
integer, parameter, public jacobian_fd2_backward
integer, parameter, public ls_2pnt
integer, parameter, public smear_mv
integer, parameter, public ls_none
integer, parameter, public ot_precond_full_single_inverse
integer, parameter, public ot_lwdn_irac
integer, parameter, public diag_filter_matrix
integer, parameter, public ls_gold
integer, parameter, public sparse_guess
integer, parameter, public diag_block_davidson
integer, parameter, public shape_function_gaussian
integer, parameter, public radius_single
integer, parameter, public outer_scf_optimizer_newton_ls
integer, parameter, public gaussian
integer, parameter, public outer_scf_optimizer_none
integer, parameter, public outer_scf_optimizer_newton
integer, parameter, public general_roks
integer, parameter, public outer_scf_none
integer, parameter, public diag_standard
integer, parameter, public smear_mp
integer, parameter, public becke_cutoff_global
integer, parameter, public cdft_alpha_constraint
integer, parameter, public broyden_type_1_ls
integer, parameter, public restart_guess
integer, parameter, public ot_precond_s_inverse
integer, parameter, public ot_mini_broyden
integer, parameter, public ot_precond_solver_update
integer, parameter, public outer_scf_optimizer_diis
integer, parameter, public ot_mini_sd
integer, parameter, public numerical
integer, parameter, public ot_precond_full_all
integer, parameter, public ot_precond_solver_direct
integer, parameter, public eht_guess
function that build the scf section of the input
subroutine, public create_scf_section(section)
creates the structure of the section with the DFT SCF parameters
subroutine, public create_cdft_control_section(section)
Creates the input section for defining CDFT constraints.
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
integer, parameter, public integer_t
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
module that contains the definitions of the scf types
subroutine, public create_mixing_section(section, ls_scf)
Create CP2K input section for the mixing of the density matrix to be used only with diagonalization m...
subroutine, public create_filtermatrix_section(section)
Input section for filter matrix diagonalisation method.
Definition qs_fb_input.F:37
manage control variables for the maximum overlap method
subroutine, public create_mom_section(section)
Create CP2K input section for variable occupancy using the Maximum Overlap Method....
Utilities for string manipulations.
character(len=1), parameter, public newline
represent a keyword in the input
represent a section of the input file