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