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