Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief function that build the dft section of the input
10 : !> \par History
11 : !> 10.2005 moved out of input_cp2k [fawzi]
12 : !> \author fawzi
13 : ! **************************************************************************************************
14 : MODULE input_cp2k_ec
15 : USE bibliography, ONLY: Niklasson2003,&
16 : VandeVondele2012,&
17 : brehm2018
18 : USE cp_output_handling, ONLY: cp_print_key_section_create,&
19 : debug_print_level,&
20 : high_print_level
21 : USE input_constants, ONLY: &
22 : bqb_opt_exhaustive, bqb_opt_normal, bqb_opt_off, bqb_opt_patient, bqb_opt_quick, &
23 : ec_diagonalization, ec_functional_dc, ec_functional_ext, ec_functional_harris, &
24 : ec_ls_solver, ec_matrix_sign, ec_matrix_tc2, ec_matrix_trs4, ec_mo_solver, ec_ot_atomic, &
25 : ec_ot_diag, ec_ot_gs, kg_cholesky, ls_cluster_atomic, ls_cluster_molecular, &
26 : ls_s_inversion_hotelling, ls_s_inversion_sign_sqrt, ls_s_preconditioner_atomic, &
27 : ls_s_preconditioner_molecular, ls_s_preconditioner_none, ls_s_sqrt_ns, ls_s_sqrt_proot, &
28 : ls_scf_sign_ns, ls_scf_sign_proot, ot_precond_full_all, ot_precond_full_kinetic, &
29 : ot_precond_full_single, ot_precond_full_single_inverse, ot_precond_none, &
30 : ot_precond_s_inverse, precond_mlp
31 : USE input_cp2k_mm, ONLY: create_dipoles_section
32 : USE input_cp2k_voronoi, ONLY: create_print_voronoi_section
33 : USE input_cp2k_xc, ONLY: create_xc_section
34 : USE input_keyword_types, ONLY: keyword_create,&
35 : keyword_release,&
36 : keyword_type
37 : USE input_section_types, ONLY: section_add_keyword,&
38 : section_add_subsection,&
39 : section_create,&
40 : section_release,&
41 : section_type
42 : USE input_val_types, ONLY: char_t,&
43 : integer_t
44 : USE kinds, ONLY: dp
45 : USE string_utilities, ONLY: s2a
46 : #include "./base/base_uses.f90"
47 :
48 : IMPLICIT NONE
49 : PRIVATE
50 :
51 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'input_cp2k_ec'
52 :
53 : PUBLIC :: create_ec_section
54 :
55 : CONTAINS
56 :
57 : ! **************************************************************************************************
58 : !> \brief creates the ENERGY CORRECTION section
59 : !> \param section ...
60 : !> \author JGH
61 : ! **************************************************************************************************
62 8546 : SUBROUTINE create_ec_section(section)
63 : TYPE(section_type), POINTER :: section
64 :
65 : TYPE(keyword_type), POINTER :: keyword
66 : TYPE(section_type), POINTER :: subsection
67 :
68 8546 : CPASSERT(.NOT. ASSOCIATED(section))
69 :
70 8546 : NULLIFY (keyword)
71 : CALL section_create(section, __LOCATION__, name="ENERGY_CORRECTION", &
72 : description="Sets the various options for the Energy Correction", &
73 8546 : n_keywords=0, n_subsections=2, repeats=.FALSE.)
74 :
75 : CALL keyword_create(keyword, __LOCATION__, name="_SECTION_PARAMETERS_", &
76 : description="Controls the activation of the energy_correction", &
77 : usage="&ENERGY_CORRECTION T", &
78 : default_l_val=.FALSE., &
79 8546 : lone_keyword_l_val=.TRUE.)
80 8546 : CALL section_add_keyword(section, keyword)
81 8546 : CALL keyword_release(keyword)
82 :
83 : ! add a special XC section
84 8546 : NULLIFY (subsection)
85 8546 : CALL create_xc_section(subsection)
86 8546 : CALL section_add_subsection(section, subsection)
87 8546 : CALL section_release(subsection)
88 :
89 : ! add a section for solver keywords
90 8546 : NULLIFY (subsection)
91 8546 : CALL create_ec_solver_section(subsection)
92 8546 : CALL section_add_subsection(section, subsection)
93 8546 : CALL section_release(subsection)
94 :
95 : ! add a print section for properties
96 8546 : NULLIFY (subsection)
97 8546 : CALL create_ec_print_section(subsection)
98 8546 : CALL section_add_subsection(section, subsection)
99 8546 : CALL section_release(subsection)
100 :
101 : CALL keyword_create(keyword, __LOCATION__, name="ENERGY_FUNCTIONAL", &
102 : description="Functional used in energy correction", &
103 : usage="ENERGY_FUNCTIONAL HARRIS", &
104 : default_i_val=ec_functional_harris, &
105 : enum_c_vals=s2a("HARRIS", "DCDFT", "EXTERNAL"), &
106 : enum_desc=s2a("Harris functional", &
107 : "Density-corrected DFT", &
108 : "External calculated energy"), &
109 8546 : enum_i_vals=(/ec_functional_harris, ec_functional_dc, ec_functional_ext/))
110 8546 : CALL section_add_keyword(section, keyword)
111 8546 : CALL keyword_release(keyword)
112 :
113 : CALL keyword_create(keyword, __LOCATION__, name="HARRIS_BASIS", &
114 : description="Specifies the type of basis to be used for the KG energy correction. "// &
115 : "Options are: (1) the default orbital basis (ORBITAL); "// &
116 : "(2) the primitive functions of the default orbital basis (PRIMITIVE); "// &
117 : "(3) the basis set labeled in Kind section (HARRIS)", &
118 : usage="HARRIS_BASIS ORBITAL", &
119 8546 : type_of_var=char_t, default_c_val="ORBITAL", n_var=-1)
120 8546 : CALL section_add_keyword(section, keyword)
121 8546 : CALL keyword_release(keyword)
122 :
123 : CALL keyword_create(keyword, __LOCATION__, name="DEBUG_FORCES", &
124 : description="Additional output to debug energy correction forces.", &
125 8546 : usage="DEBUG_FORCES T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
126 8546 : CALL section_add_keyword(section, keyword)
127 8546 : CALL keyword_release(keyword)
128 : CALL keyword_create(keyword, __LOCATION__, name="DEBUG_STRESS", &
129 : description="Additional output to debug energy correction forces.", &
130 8546 : usage="DEBUG_STRESS T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
131 8546 : CALL section_add_keyword(section, keyword)
132 8546 : CALL keyword_release(keyword)
133 : CALL keyword_create(keyword, __LOCATION__, name="DEBUG_EXTERNAL_METHOD", &
134 : description="Uses an internal pseudo-energy to test EXTERNAL energy method.", &
135 8546 : usage="DEBUG_EXTERNAL_METHOD T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
136 8546 : CALL section_add_keyword(section, keyword)
137 8546 : CALL keyword_release(keyword)
138 :
139 : CALL keyword_create(keyword, __LOCATION__, name="SKIP_EC", &
140 : description="Skip EC calculation if ground-state calculation has not converged.", &
141 8546 : usage="SKIP_EC T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
142 8546 : CALL section_add_keyword(section, keyword)
143 8546 : CALL keyword_release(keyword)
144 :
145 : CALL keyword_create(keyword, __LOCATION__, name="MAO", &
146 : description="Use modified atomic orbitals (MAO) to solve Harris equation", &
147 8546 : usage="MAO T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
148 8546 : CALL section_add_keyword(section, keyword)
149 8546 : CALL keyword_release(keyword)
150 :
151 : CALL keyword_create(keyword, __LOCATION__, name="MAO_MAX_ITER", &
152 : description="Maximum iterations in MAO optimization. ", &
153 8546 : usage="MAO_MAX_ITER 100 ", default_i_val=0)
154 8546 : CALL section_add_keyword(section, keyword)
155 8546 : CALL keyword_release(keyword)
156 :
157 : CALL keyword_create(keyword, __LOCATION__, name="MAO_EPS_GRAD", &
158 : description="Threshold used for MAO iterations. ", &
159 8546 : usage="MAO_EPS_GRAD 1.0E-4 ", default_r_val=1.0E-5_dp)
160 8546 : CALL section_add_keyword(section, keyword)
161 8546 : CALL keyword_release(keyword)
162 :
163 : CALL keyword_create(keyword, __LOCATION__, name="MAO_EPS1", &
164 : description="Occupation threshold used to determine number of MAOs."// &
165 : " KIND section MAO keyword sets the minimum.", &
166 8546 : usage="MAO_EPS1 0.001 ", default_r_val=1000.0_dp)
167 8546 : CALL section_add_keyword(section, keyword)
168 8546 : CALL keyword_release(keyword)
169 :
170 : CALL keyword_create(keyword, __LOCATION__, name="MAO_IOLEVEL", &
171 : description="Verbosity of MAO output: (0) no output ... (3) fully verbose", &
172 8546 : usage="MAO_IOLEVEL 0 ", default_i_val=1)
173 8546 : CALL section_add_keyword(section, keyword)
174 8546 : CALL keyword_release(keyword)
175 :
176 : CALL keyword_create(keyword, __LOCATION__, name="ALGORITHM", &
177 : description="Algorithm used to solve KS equation", &
178 : usage="ALGORITHM DIAGONALIZATION", &
179 : default_i_val=ec_diagonalization, &
180 : enum_c_vals=s2a("DIAGONALIZATION", "MATRIX_SIGN", &
181 : "TRS4", "TC2", "OT_DIAG"), &
182 : enum_desc=s2a("Diagonalization of KS matrix.", &
183 : "Matrix Sign algorithm", &
184 : "Trace resetting trs4 algorithm", &
185 : "Trace resetting tc2 algorithm", &
186 : "OT diagonalization"), &
187 : enum_i_vals=(/ec_diagonalization, ec_matrix_sign, &
188 8546 : ec_matrix_trs4, ec_matrix_tc2, ec_ot_diag/))
189 8546 : CALL section_add_keyword(section, keyword)
190 8546 : CALL keyword_release(keyword)
191 :
192 : CALL keyword_create(keyword, __LOCATION__, name="FACTORIZATION", &
193 : description="Algorithm used to calculate factorization of overlap matrix", &
194 : usage="FACTORIZATION CHOLESKY", &
195 : default_i_val=kg_cholesky, &
196 : enum_c_vals=s2a("CHOLESKY"), &
197 : enum_desc=s2a("Cholesky factorization of overlap matrix"), &
198 8546 : enum_i_vals=(/kg_cholesky/))
199 8546 : CALL section_add_keyword(section, keyword)
200 8546 : CALL keyword_release(keyword)
201 :
202 : CALL keyword_create(keyword, __LOCATION__, name="EPS_DEFAULT", &
203 : description="Threshold used for accuracy estimates within energy correction. ", &
204 8546 : usage="EPS_DEFAULT 1.0E-7 ", default_r_val=1.0E-7_dp)
205 8546 : CALL section_add_keyword(section, keyword)
206 8546 : CALL keyword_release(keyword)
207 :
208 : ! Keywords for LS solver of Harris functional
209 : CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
210 : description="Threshold used for filtering matrix operations.", &
211 8546 : usage="EPS_FILTER 1.0E-12", default_r_val=1.0E-12_dp)
212 8546 : CALL section_add_keyword(section, keyword)
213 8546 : CALL keyword_release(keyword)
214 :
215 : CALL keyword_create(keyword, __LOCATION__, name="EPS_LANCZOS", &
216 : description="Threshold used for lanczos estimates.", &
217 8546 : usage="EPS_LANCZOS 1.0E-4", default_r_val=1.0E-3_dp)
218 8546 : CALL section_add_keyword(section, keyword)
219 8546 : CALL keyword_release(keyword)
220 :
221 : CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER_LANCZOS", &
222 : description="Maximum number of lanczos iterations.", &
223 8546 : usage="MAX_ITER_LANCZOS ", default_i_val=128)
224 8546 : CALL section_add_keyword(section, keyword)
225 8546 : CALL keyword_release(keyword)
226 :
227 : CALL keyword_create(keyword, __LOCATION__, name="MU", &
228 : description="Value (or initial guess) for the chemical potential,"// &
229 : " i.e. some suitable energy between HOMO and LUMO energy.", &
230 8546 : usage="MU 0.0", default_r_val=-0.1_dp)
231 8546 : CALL section_add_keyword(section, keyword)
232 8546 : CALL keyword_release(keyword)
233 :
234 : CALL keyword_create(keyword, __LOCATION__, name="FIXED_MU", &
235 : description="Should the calculation be performed at fixed chemical potential,"// &
236 : " or should it be found fixing the number of electrons", &
237 8546 : usage="FIXED_MU .TRUE.", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
238 8546 : CALL section_add_keyword(section, keyword)
239 8546 : CALL keyword_release(keyword)
240 :
241 : CALL keyword_create(keyword, __LOCATION__, name="S_PRECONDITIONER", &
242 : description="Preconditions S with some appropriate form.", &
243 : usage="S_PRECONDITIONER MOLECULAR", &
244 : default_i_val=ls_s_preconditioner_atomic, &
245 : enum_c_vals=s2a("NONE", "ATOMIC", "MOLECULAR"), &
246 : enum_desc=s2a("No preconditioner", &
247 : "Using atomic blocks", &
248 : "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
249 8546 : enum_i_vals=(/ls_s_preconditioner_none, ls_s_preconditioner_atomic, ls_s_preconditioner_molecular/))
250 8546 : CALL section_add_keyword(section, keyword)
251 8546 : CALL keyword_release(keyword)
252 :
253 : CALL keyword_create(keyword, __LOCATION__, name="S_SQRT_METHOD", &
254 : description="Method for the caclulation of the sqrt of S.", &
255 : usage="S_SQRT_METHOD NEWTONSCHULZ", &
256 : default_i_val=ls_s_sqrt_ns, &
257 : enum_c_vals=s2a("NEWTONSCHULZ", "PROOT"), &
258 : enum_desc=s2a("Using a Newton-Schulz-like iteration", &
259 : "Using the p-th root method."), &
260 8546 : enum_i_vals=(/ls_s_sqrt_ns, ls_s_sqrt_proot/))
261 8546 : CALL section_add_keyword(section, keyword)
262 8546 : CALL keyword_release(keyword)
263 :
264 : CALL keyword_create(keyword, __LOCATION__, name="S_SQRT_ORDER", &
265 : variants=s2a("SIGN_SQRT_ORDER"), &
266 : description="Order of the iteration method for the calculation of the sqrt of S.", &
267 8546 : usage="S_SQRT_ORDER 3", default_i_val=3)
268 8546 : CALL section_add_keyword(section, keyword)
269 8546 : CALL keyword_release(keyword)
270 :
271 : CALL keyword_create(keyword, __LOCATION__, name="SIGN_METHOD", &
272 : description="Method used for the computation of the sign matrix.", &
273 : usage="SIGN_METHOD NEWTONSCHULZ", &
274 : default_i_val=ls_scf_sign_ns, &
275 : citations=(/VandeVondele2012, Niklasson2003/), &
276 : enum_c_vals=s2a("NEWTONSCHULZ", "PROOT"), &
277 : enum_desc=s2a("Newton-Schulz iteration.", &
278 : "p-th order root iteration"), &
279 25638 : enum_i_vals=(/ls_scf_sign_ns, ls_scf_sign_proot/))
280 8546 : CALL section_add_keyword(section, keyword)
281 8546 : CALL keyword_release(keyword)
282 :
283 : CALL keyword_create(keyword, __LOCATION__, name="SIGN_ORDER", &
284 : description="Order of the method used for the computation of the sign matrix.", &
285 : usage="SIGN_ORDER 2", &
286 8546 : default_i_val=2)
287 8546 : CALL section_add_keyword(section, keyword)
288 8546 : CALL keyword_release(keyword)
289 :
290 : CALL keyword_create(keyword, __LOCATION__, name="DYNAMIC_THRESHOLD", &
291 : description="Should the threshold for the purification be chosen dynamically", &
292 8546 : usage="DYNAMIC_THRESHOLD .TRUE.", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
293 8546 : CALL section_add_keyword(section, keyword)
294 8546 : CALL keyword_release(keyword)
295 :
296 : CALL keyword_create(keyword, __LOCATION__, name="NON_MONOTONIC", &
297 : description="Should the purification be performed non-monotonically. Relevant for TC2 only.", &
298 8546 : usage="NON_MONOTONIC .TRUE.", default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
299 8546 : CALL section_add_keyword(section, keyword)
300 8546 : CALL keyword_release(keyword)
301 :
302 : CALL keyword_create( &
303 : keyword, __LOCATION__, name="MATRIX_CLUSTER_TYPE", &
304 : description="Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
305 : "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
306 : "Furthermore, since screening is on matrix blocks, "// &
307 : "slightly more accurate results can be expected with molecular.", &
308 : usage="MATRIX_CLUSTER_TYPE MOLECULAR", &
309 : default_i_val=ls_cluster_atomic, &
310 : enum_c_vals=s2a("ATOMIC", "MOLECULAR"), &
311 : enum_desc=s2a("Using atomic blocks", &
312 : "Using molecular blocks."), &
313 8546 : enum_i_vals=(/ls_cluster_atomic, ls_cluster_molecular/))
314 8546 : CALL section_add_keyword(section, keyword)
315 8546 : CALL keyword_release(keyword)
316 :
317 : CALL keyword_create(keyword, __LOCATION__, name="S_INVERSION", &
318 : description="Method used to compute the inverse of S.", &
319 : usage="S_PRECONDITIONER MOLECULAR", &
320 : default_i_val=ls_s_inversion_sign_sqrt, &
321 : enum_c_vals=s2a("SIGN_SQRT", "HOTELLING"), &
322 : enum_desc=s2a("Using the inverse sqrt as obtained from sign function iterations.", &
323 : "Using the Hotellign iteration."), &
324 8546 : enum_i_vals=(/ls_s_inversion_sign_sqrt, ls_s_inversion_hotelling/))
325 8546 : CALL section_add_keyword(section, keyword)
326 8546 : CALL keyword_release(keyword)
327 :
328 : CALL keyword_create(keyword, __LOCATION__, name="REPORT_ALL_SPARSITIES", &
329 : description="Run the sparsity report at the end of the SCF", &
330 8546 : usage="REPORT_ALL_SPARSITIES", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
331 8546 : CALL section_add_keyword(section, keyword)
332 8546 : CALL keyword_release(keyword)
333 :
334 : CALL keyword_create(keyword, __LOCATION__, name="CHECK_S_INV", &
335 : description="Perform an accuracy check on the inverse/sqrt of the s matrix.", &
336 8546 : usage="CHECK_S_INV", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
337 8546 : CALL section_add_keyword(section, keyword)
338 8546 : CALL keyword_release(keyword)
339 :
340 : CALL keyword_create(keyword, __LOCATION__, name="OT_INITIAL_GUESS", &
341 : description="Initial guess of density matrix used for OT Diagonalization", &
342 : usage="OT_INITIAL_GUESS ATOMIC", &
343 : default_i_val=ec_ot_atomic, &
344 : enum_c_vals=s2a("ATOMIC", "GROUND_STATE"), &
345 : enum_desc=s2a("Generate an atomic density using the atomic code", &
346 : "Using the ground-state density."), &
347 8546 : enum_i_vals=(/ec_ot_atomic, ec_ot_gs/))
348 8546 : CALL section_add_keyword(section, keyword)
349 8546 : CALL keyword_release(keyword)
350 :
351 : CALL keyword_create( &
352 : keyword, __LOCATION__, &
353 : name="ADMM", &
354 : description="Decide whether to perform ADMM in the exact exchange calc. for DC-DFT. "// &
355 : "The ADMM XC correction is governed by the AUXILIARY_DENSITY_MATRIX_METHOD section in &DFT. "// &
356 : "In most cases, the Hartree-Fock exchange is not too expensive and there is no need for ADMM, "// &
357 : "ADMM can however provide significant speedup and memory savings in case of diffuse basis sets. ", &
358 : usage="ADMM", &
359 : default_l_val=.FALSE., &
360 8546 : lone_keyword_l_val=.TRUE.)
361 8546 : CALL section_add_keyword(section, keyword)
362 8546 : CALL keyword_release(keyword)
363 :
364 8546 : END SUBROUTINE create_ec_section
365 :
366 : ! **************************************************************************************************
367 : !> \brief creates the linear scaling solver section
368 : !> \param section ...
369 : !> \author Joost VandeVondele [2010-10], JGH [2019-12]
370 : ! **************************************************************************************************
371 8546 : SUBROUTINE create_ec_solver_section(section)
372 : TYPE(section_type), POINTER :: section
373 :
374 : TYPE(keyword_type), POINTER :: keyword
375 :
376 8546 : CPASSERT(.NOT. ASSOCIATED(section))
377 : CALL section_create(section, __LOCATION__, name="RESPONSE_SOLVER", &
378 : description="Specifies the parameters of the linear scaling solver routines", &
379 : n_keywords=24, n_subsections=3, repeats=.FALSE., &
380 17092 : citations=(/VandeVondele2012/))
381 :
382 8546 : NULLIFY (keyword)
383 :
384 : CALL keyword_create(keyword, __LOCATION__, name="EPS", &
385 : description="Target accuracy for the convergence of the conjugate gradient.", &
386 8546 : usage="EPS 1.e-10", default_r_val=1.e-12_dp)
387 8546 : CALL section_add_keyword(section, keyword)
388 8546 : CALL keyword_release(keyword)
389 :
390 : CALL keyword_create(keyword, __LOCATION__, name="EPS_FILTER", &
391 : description="Threshold used for filtering matrix operations.", &
392 8546 : usage="EPS_FILTER 1.0E-10", default_r_val=1.0E-10_dp)
393 8546 : CALL section_add_keyword(section, keyword)
394 8546 : CALL keyword_release(keyword)
395 :
396 : CALL keyword_create(keyword, __LOCATION__, name="EPS_LANCZOS", &
397 : description="Threshold used for lanczos estimates.", &
398 8546 : usage="EPS_LANCZOS 1.0E-4", default_r_val=1.0E-3_dp)
399 8546 : CALL section_add_keyword(section, keyword)
400 8546 : CALL keyword_release(keyword)
401 :
402 : CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER", &
403 : description="Maximum number of conjugate gradient iteration "// &
404 : "to be performed for one optimization.", &
405 8546 : usage="MAX_ITER 200", default_i_val=50)
406 8546 : CALL section_add_keyword(section, keyword)
407 8546 : CALL keyword_release(keyword)
408 :
409 : CALL keyword_create(keyword, __LOCATION__, name="MAX_ITER_LANCZOS", &
410 : description="Maximum number of lanczos iterations.", &
411 8546 : usage="MAX_ITER_LANCZOS 128", default_i_val=128)
412 8546 : CALL section_add_keyword(section, keyword)
413 8546 : CALL keyword_release(keyword)
414 :
415 : CALL keyword_create(keyword, __LOCATION__, name="METHOD", &
416 : description="Algorithm used to solve response equation. "// &
417 : "Both solver are conjugate gradient based, but use either a vector (MO-coefficient) "// &
418 : "or density matrix formalism in the orthonormal AO-basis to obtain response density", &
419 : usage="METHOD SOLVER", &
420 : default_i_val=ec_ls_solver, &
421 : enum_c_vals=s2a("MO_SOLVER", "AO_ORTHO"), &
422 : enum_desc=s2a("Solver based on MO (vector) formalism", &
423 : "Solver based on density matrix formalism"), &
424 8546 : enum_i_vals=(/ec_mo_solver, ec_ls_solver/))
425 8546 : CALL section_add_keyword(section, keyword)
426 8546 : CALL keyword_release(keyword)
427 :
428 : CALL keyword_create( &
429 : keyword, __LOCATION__, name="PRECONDITIONER", &
430 : description="Type of preconditioner to be used with MO conjugate gradient solver. "// &
431 : "They differ in effectiveness, cost of construction, cost of application. "// &
432 : "Properly preconditioned minimization can be orders of magnitude faster than doing nothing. "// &
433 : "Only multi-level conjugate gradient preconditioner (MULTI_LEVEL) available for AO response solver (AO_ORTHO). ", &
434 : usage="PRECONDITIONER FULL_ALL", &
435 : default_i_val=precond_mlp, &
436 : enum_c_vals=s2a("FULL_ALL", "FULL_SINGLE_INVERSE", "FULL_SINGLE", "FULL_KINETIC", "FULL_S_INVERSE", &
437 : "MULTI_LEVEL", "NONE"), &
438 : enum_desc=s2a("Most effective state selective preconditioner based on diagonalization, "// &
439 : "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
440 : "This preconditioner is recommended for almost all systems, except very large systems where "// &
441 : "make_preconditioner would dominate the total computational cost.", &
442 : "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
443 : "but cheaper to construct, "// &
444 : "might be somewhat less robust. Recommended for large systems.", &
445 : "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
446 : "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
447 : "use for very large systems.", &
448 : "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
449 : "Based on same CG as AO-solver itself, but uses cheaper linear transformation", &
450 : "skip preconditioning"), &
451 : enum_i_vals=(/ot_precond_full_all, ot_precond_full_single_inverse, ot_precond_full_single, &
452 8546 : ot_precond_full_kinetic, ot_precond_s_inverse, precond_mlp, ot_precond_none/))
453 8546 : CALL section_add_keyword(section, keyword)
454 8546 : CALL keyword_release(keyword)
455 :
456 : CALL keyword_create(keyword, __LOCATION__, name="S_PRECONDITIONER", &
457 : description="Preconditions S with some appropriate form.", &
458 : usage="S_PRECONDITIONER MOLECULAR", &
459 : default_i_val=ls_s_preconditioner_atomic, &
460 : enum_c_vals=s2a("NONE", "ATOMIC", "MOLECULAR"), &
461 : enum_desc=s2a("No preconditioner", &
462 : "Using atomic blocks", &
463 : "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
464 8546 : enum_i_vals=(/ls_s_preconditioner_none, ls_s_preconditioner_atomic, ls_s_preconditioner_molecular/))
465 8546 : CALL section_add_keyword(section, keyword)
466 8546 : CALL keyword_release(keyword)
467 :
468 : CALL keyword_create(keyword, __LOCATION__, name="S_SQRT_METHOD", &
469 : description="Method for the caclulation of the sqrt of S.", &
470 : usage="S_SQRT_METHOD NEWTONSCHULZ", &
471 : default_i_val=ls_s_sqrt_ns, &
472 : enum_c_vals=s2a("NEWTONSCHULZ", "PROOT"), &
473 : enum_desc=s2a("Using a Newton-Schulz-like iteration", &
474 : "Using the p-th root method."), &
475 8546 : enum_i_vals=(/ls_s_sqrt_ns, ls_s_sqrt_proot/))
476 8546 : CALL section_add_keyword(section, keyword)
477 8546 : CALL keyword_release(keyword)
478 :
479 : CALL keyword_create(keyword, __LOCATION__, name="S_SQRT_ORDER", &
480 : variants=s2a("SIGN_SQRT_ORDER"), &
481 : description="Order of the iteration method for the calculation of the sqrt of S.", &
482 8546 : usage="S_SQRT_ORDER 3", default_i_val=3)
483 8546 : CALL section_add_keyword(section, keyword)
484 8546 : CALL keyword_release(keyword)
485 :
486 : CALL keyword_create( &
487 : keyword, __LOCATION__, name="MATRIX_CLUSTER_TYPE", &
488 : description="Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
489 : "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
490 : "Furthermore, since screening is on matrix blocks, "// &
491 : "slightly more accurate results can be expected with molecular.", &
492 : usage="MATRIX_CLUSTER_TYPE MOLECULAR", &
493 : default_i_val=ls_cluster_atomic, &
494 : enum_c_vals=s2a("ATOMIC", "MOLECULAR"), &
495 : enum_desc=s2a("Using atomic blocks", &
496 : "Using molecular blocks."), &
497 8546 : enum_i_vals=(/ls_cluster_atomic, ls_cluster_molecular/))
498 8546 : CALL section_add_keyword(section, keyword)
499 8546 : CALL keyword_release(keyword)
500 :
501 : CALL keyword_create(keyword, __LOCATION__, name="S_INVERSION", &
502 : description="Method used to compute the inverse of S.", &
503 : usage="S_PRECONDITIONER MOLECULAR", &
504 : default_i_val=ls_s_inversion_sign_sqrt, &
505 : enum_c_vals=s2a("SIGN_SQRT", "HOTELLING"), &
506 : enum_desc=s2a("Using the inverse sqrt as obtained from sign function iterations.", &
507 : "Using the Hotellign iteration."), &
508 8546 : enum_i_vals=(/ls_s_inversion_sign_sqrt, ls_s_inversion_hotelling/))
509 8546 : CALL section_add_keyword(section, keyword)
510 8546 : CALL keyword_release(keyword)
511 :
512 : CALL keyword_create(keyword, __LOCATION__, name="RESTART", &
513 : description="Restart the response calculation if the restart file exists", &
514 : usage="RESTART", &
515 8546 : default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
516 8546 : CALL section_add_keyword(section, keyword)
517 8546 : CALL keyword_release(keyword)
518 :
519 : CALL keyword_create(keyword, __LOCATION__, name="RESTART_EVERY", &
520 : description="Restart the conjugate gradient after the specified number of iterations.", &
521 8546 : usage="RESTART_EVERY 50", default_i_val=50)
522 8546 : CALL section_add_keyword(section, keyword)
523 8546 : CALL keyword_release(keyword)
524 :
525 8546 : END SUBROUTINE create_ec_solver_section
526 :
527 : ! **************************************************************************************************
528 : !> \brief Create the print dft section
529 : !> \param section the section to create
530 : !> \author fbelle - from create_print_dft_section
531 : ! **************************************************************************************************
532 8546 : SUBROUTINE create_ec_print_section(section)
533 : TYPE(section_type), POINTER :: section
534 :
535 : TYPE(keyword_type), POINTER :: keyword
536 : TYPE(section_type), POINTER :: print_key
537 :
538 8546 : CPASSERT(.NOT. ASSOCIATED(section))
539 : CALL section_create(section, __LOCATION__, name="PRINT", &
540 : description="Section of possible print options in EC code.", &
541 8546 : n_keywords=0, n_subsections=1, repeats=.FALSE.)
542 :
543 8546 : NULLIFY (print_key, keyword)
544 :
545 : ! Output of BQB volumetric files
546 : CALL cp_print_key_section_create(print_key, __LOCATION__, name="E_DENSITY_BQB", &
547 : description="Controls the output of the electron density to the losslessly"// &
548 : " compressed BQB file format, see [Brehm2018]"// &
549 : " (via LibBQB see <https://brehm-research.de/bqb>)."// &
550 : " Currently does not work with changing cell vector (NpT ensemble).", &
551 : print_level=debug_print_level + 1, filename="", &
552 17092 : citations=(/Brehm2018/))
553 :
554 : CALL keyword_create(keyword, __LOCATION__, name="SKIP_FIRST", &
555 : description="Skips the first step of a MD run (avoids duplicate step if restarted).", &
556 8546 : usage="SKIP_FIRST T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
557 8546 : CALL section_add_keyword(print_key, keyword)
558 8546 : CALL keyword_release(keyword)
559 :
560 : CALL keyword_create(keyword, __LOCATION__, name="STORE_STEP_NUMBER", &
561 : description="Stores the step number and simulation time in the comment line of each BQB"// &
562 : " frame. Switch it off for binary compatibility with original CP2k CUBE files.", &
563 8546 : usage="STORE_STEP_NUMBER F", default_l_val=.TRUE., lone_keyword_l_val=.TRUE.)
564 8546 : CALL section_add_keyword(print_key, keyword)
565 8546 : CALL keyword_release(keyword)
566 :
567 : CALL keyword_create(keyword, __LOCATION__, name="CHECK", &
568 : description="Performs an on-the-fly decompression of each compressed BQB frame to check"// &
569 : " whether the volumetric data exactly matches, and aborts the run if not so.", &
570 8546 : usage="CHECK T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
571 8546 : CALL section_add_keyword(print_key, keyword)
572 8546 : CALL keyword_release(keyword)
573 :
574 : CALL keyword_create(keyword, __LOCATION__, name="OVERWRITE", &
575 : description="Specify this keyword to overwrite the output BQB file if"// &
576 : " it already exists. By default, the data is appended to an existing file.", &
577 8546 : usage="OVERWRITE T", default_l_val=.FALSE., lone_keyword_l_val=.TRUE.)
578 8546 : CALL section_add_keyword(print_key, keyword)
579 8546 : CALL keyword_release(keyword)
580 :
581 : CALL keyword_create(keyword, __LOCATION__, name="HISTORY", &
582 : description="Controls how many previous steps are taken into account for extrapolation in"// &
583 : " compression. Use a value of 1 to compress the frames independently.", &
584 8546 : usage="HISTORY 10", n_var=1, default_i_val=10, type_of_var=integer_t)
585 8546 : CALL section_add_keyword(print_key, keyword)
586 8546 : CALL keyword_release(keyword)
587 :
588 : CALL keyword_create(keyword, __LOCATION__, name="PARAMETER_KEY", &
589 : description="Allows to supply previously optimized compression parameters via a"// &
590 : " parameter key (alphanumeric character sequence starting with 'at')."// &
591 : " Just leave away the 'at' sign here, because CP2k will otherwise"// &
592 : " assume it is a variable name in the input", &
593 8546 : usage="PARAMETER_KEY <KEY>", n_var=1, default_c_val="", type_of_var=char_t)
594 8546 : CALL section_add_keyword(print_key, keyword)
595 8546 : CALL keyword_release(keyword)
596 :
597 : CALL keyword_create(keyword, __LOCATION__, name="OPTIMIZE", &
598 : description="Controls the time spent to optimize the parameters for compression efficiency.", &
599 : usage="OPTIMIZE {OFF,QUICK,NORMAL,PATIENT,EXHAUSTIVE}", repeats=.FALSE., n_var=1, &
600 : default_i_val=bqb_opt_quick, &
601 : enum_c_vals=s2a("OFF", "QUICK", "NORMAL", "PATIENT", "EXHAUSTIVE"), &
602 : enum_desc=s2a("No optimization (use defaults)", "Quick optimization", &
603 : "Standard optimization", "Precise optimization", "Exhaustive optimization"), &
604 8546 : enum_i_vals=(/bqb_opt_off, bqb_opt_quick, bqb_opt_normal, bqb_opt_patient, bqb_opt_exhaustive/))
605 8546 : CALL section_add_keyword(print_key, keyword)
606 8546 : CALL keyword_release(keyword)
607 :
608 8546 : CALL section_add_subsection(section, print_key)
609 8546 : CALL section_release(print_key)
610 :
611 : ! Voronoi Integration via LibVori
612 8546 : NULLIFY (print_key)
613 8546 : CALL create_print_voronoi_section(print_key)
614 8546 : CALL section_add_subsection(section, print_key)
615 8546 : CALL section_release(print_key)
616 :
617 : !Printing of Moments
618 8546 : CALL create_dipoles_section(print_key, "MOMENTS", high_print_level)
619 : CALL keyword_create( &
620 : keyword, __LOCATION__, &
621 : name="MAX_MOMENT", &
622 : description="Maximum moment to be calculated. Values higher than 1 not implemented under periodic boundaries.", &
623 : usage="MAX_MOMENT {integer}", &
624 : repeats=.FALSE., &
625 : n_var=1, &
626 : type_of_var=integer_t, &
627 8546 : default_i_val=1)
628 8546 : CALL section_add_keyword(print_key, keyword)
629 8546 : CALL keyword_release(keyword)
630 : CALL keyword_create(keyword, __LOCATION__, &
631 : name="MAGNETIC", &
632 : description="Calculate also magnetic moments, only implemented without periodic boundaries", &
633 : usage="MAGNETIC yes", &
634 : repeats=.FALSE., &
635 : n_var=1, &
636 : default_l_val=.FALSE., &
637 8546 : lone_keyword_l_val=.TRUE.)
638 8546 : CALL section_add_keyword(print_key, keyword)
639 8546 : CALL keyword_release(keyword)
640 8546 : CALL section_add_subsection(section, print_key)
641 8546 : CALL section_release(print_key)
642 :
643 8546 : END SUBROUTINE create_ec_print_section
644 :
645 : END MODULE input_cp2k_ec
|