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