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