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