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