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