45#include "./base/base_uses.f90"
50 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'input_cp2k_ec'
67 cpassert(.NOT.
ASSOCIATED(section))
70 CALL section_create(section, __location__, name=
"ENERGY_CORRECTION", &
71 description=
"Sets the various options for the Energy Correction", &
72 n_keywords=0, n_subsections=2, repeats=.false.)
74 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
75 description=
"Controls the activation of the energy_correction", &
76 usage=
"&ENERGY_CORRECTION T", &
77 default_l_val=.false., &
78 lone_keyword_l_val=.true.)
90 CALL create_ec_solver_section(subsection)
96 CALL create_ec_print_section(subsection)
100 CALL keyword_create(keyword, __location__, name=
"ENERGY_FUNCTIONAL", &
101 description=
"Functional used in energy correction", &
102 usage=
"ENERGY_FUNCTIONAL HARRIS", &
104 enum_c_vals=
s2a(
"HARRIS",
"DCDFT"), &
105 enum_desc=
s2a(
"Harris functional", &
106 "Density-corrected DFT"), &
112 description=
"Specifies the type of basis to be used for the KG energy correction. "// &
113 "Options are: (1) the default orbital basis (ORBITAL); "// &
114 "(2) the primitive functions of the default orbital basis (PRIMITIVE); "// &
115 "(3) the basis set labeled in Kind section (HARRIS)", &
116 usage=
"HARRIS_BASIS ORBITAL", &
117 type_of_var=
char_t, default_c_val=
"ORBITAL", n_var=-1)
122 description=
"Additional output to debug energy correction forces.", &
123 usage=
"DEBUG_FORCES T", default_l_val=.false., lone_keyword_l_val=.true.)
127 description=
"Additional output to debug energy correction forces.", &
128 usage=
"DEBUG_STRESS T", default_l_val=.false., lone_keyword_l_val=.true.)
133 description=
"Skip EC calculation if ground-state calculation has not converged.", &
134 usage=
"SKIP_EC T", default_l_val=.false., lone_keyword_l_val=.true.)
139 description=
"Use modified atomic orbitals (MAO) to solve Harris equation", &
140 usage=
"MAO T", default_l_val=.false., lone_keyword_l_val=.true.)
145 description=
"Maximum iterations in MAO optimization. ", &
146 usage=
"MAO_MAX_ITER 100 ", default_i_val=0)
151 description=
"Threshold used for MAO iterations. ", &
152 usage=
"MAO_EPS_GRAD 1.0E-4 ", default_r_val=1.0e-5_dp)
157 description=
"Occupation threshold used to determine number of MAOs."// &
158 " KIND section MAO keyword sets the minimum.", &
159 usage=
"MAO_EPS1 0.001 ", default_r_val=1000.0_dp)
164 description=
"Verbosity of MAO output: (0) no output ... (3) fully verbose", &
165 usage=
"MAO_IOLEVEL 0 ", default_i_val=1)
170 description=
"Algorithm used to solve KS equation", &
171 usage=
"ALGORITHM DIAGONALIZATION", &
173 enum_c_vals=
s2a(
"DIAGONALIZATION",
"MATRIX_SIGN", &
174 "TRS4",
"TC2",
"OT_DIAG"), &
175 enum_desc=
s2a(
"Diagonalization of KS matrix.", &
176 "Matrix Sign algorithm", &
177 "Trace resetting trs4 algorithm", &
178 "Trace resetting tc2 algorithm", &
179 "OT diagonalization"), &
185 CALL keyword_create(keyword, __location__, name=
"FACTORIZATION", &
186 description=
"Algorithm used to calculate factorization of overlap matrix", &
187 usage=
"FACTORIZATION CHOLESKY", &
189 enum_c_vals=
s2a(
"CHOLESKY"), &
190 enum_desc=
s2a(
"Cholesky factorization of overlap matrix"), &
196 description=
"Threshold used for accuracy estimates within energy correction. ", &
197 usage=
"EPS_DEFAULT 1.0E-7 ", default_r_val=1.0e-7_dp)
203 description=
"Threshold used for filtering matrix operations.", &
204 usage=
"EPS_FILTER 1.0E-12", default_r_val=1.0e-12_dp)
209 description=
"Threshold used for lanczos estimates.", &
210 usage=
"EPS_LANCZOS 1.0E-4", default_r_val=1.0e-3_dp)
214 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LANCZOS", &
215 description=
"Maximum number of lanczos iterations.", &
216 usage=
"MAX_ITER_LANCZOS ", default_i_val=128)
221 description=
"Value (or initial guess) for the chemical potential,"// &
222 " i.e. some suitable energy between HOMO and LUMO energy.", &
223 usage=
"MU 0.0", default_r_val=-0.1_dp)
228 description=
"Should the calculation be performed at fixed chemical potential,"// &
229 " or should it be found fixing the number of electrons", &
230 usage=
"FIXED_MU .TRUE.", default_l_val=.false., lone_keyword_l_val=.true.)
234 CALL keyword_create(keyword, __location__, name=
"S_PRECONDITIONER", &
235 description=
"Preconditions S with some appropriate form.", &
236 usage=
"S_PRECONDITIONER MOLECULAR", &
238 enum_c_vals=
s2a(
"NONE",
"ATOMIC",
"MOLECULAR"), &
239 enum_desc=
s2a(
"No preconditioner", &
240 "Using atomic blocks", &
241 "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
246 CALL keyword_create(keyword, __location__, name=
"S_SQRT_METHOD", &
247 description=
"Method for the caclulation of the sqrt of S.", &
248 usage=
"S_SQRT_METHOD NEWTONSCHULZ", &
250 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
251 enum_desc=
s2a(
"Using a Newton-Schulz-like iteration", &
252 "Using the p-th root method."), &
258 variants=
s2a(
"SIGN_SQRT_ORDER"), &
259 description=
"Order of the iteration method for the calculation of the sqrt of S.", &
260 usage=
"S_SQRT_ORDER 3", default_i_val=3)
265 description=
"Method used for the computation of the sign matrix.", &
266 usage=
"SIGN_METHOD NEWTONSCHULZ", &
269 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
270 enum_desc=
s2a(
"Newton-Schulz iteration.", &
271 "p-th order root iteration"), &
277 description=
"Order of the method used for the computation of the sign matrix.", &
278 usage=
"SIGN_ORDER 2", &
283 CALL keyword_create(keyword, __location__, name=
"DYNAMIC_THRESHOLD", &
284 description=
"Should the threshold for the purification be chosen dynamically", &
285 usage=
"DYNAMIC_THRESHOLD .TRUE.", default_l_val=.false., lone_keyword_l_val=.true.)
289 CALL keyword_create(keyword, __location__, name=
"NON_MONOTONIC", &
290 description=
"Should the purification be performed non-monotonically. Relevant for TC2 only.", &
291 usage=
"NON_MONOTONIC .TRUE.", default_l_val=.true., lone_keyword_l_val=.true.)
296 keyword, __location__, name=
"MATRIX_CLUSTER_TYPE", &
297 description=
"Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
298 "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
299 "Furthermore, since screening is on matrix blocks, "// &
300 "slightly more accurate results can be expected with molecular.", &
301 usage=
"MATRIX_CLUSTER_TYPE MOLECULAR", &
303 enum_c_vals=
s2a(
"ATOMIC",
"MOLECULAR"), &
304 enum_desc=
s2a(
"Using atomic blocks", &
305 "Using molecular blocks."), &
311 description=
"Method used to compute the inverse of S.", &
312 usage=
"S_PRECONDITIONER MOLECULAR", &
314 enum_c_vals=
s2a(
"SIGN_SQRT",
"HOTELLING"), &
315 enum_desc=
s2a(
"Using the inverse sqrt as obtained from sign function iterations.", &
316 "Using the Hotellign iteration."), &
321 CALL keyword_create(keyword, __location__, name=
"REPORT_ALL_SPARSITIES", &
322 description=
"Run the sparsity report at the end of the SCF", &
323 usage=
"REPORT_ALL_SPARSITIES", default_l_val=.false., lone_keyword_l_val=.true.)
328 description=
"Perform an accuracy check on the inverse/sqrt of the s matrix.", &
329 usage=
"CHECK_S_INV", default_l_val=.false., lone_keyword_l_val=.true.)
333 CALL keyword_create(keyword, __location__, name=
"OT_INITIAL_GUESS", &
334 description=
"Initial guess of density matrix used for OT Diagonalization", &
335 usage=
"OT_INITIAL_GUESS ATOMIC", &
337 enum_c_vals=
s2a(
"ATOMIC",
"GROUND_STATE"), &
338 enum_desc=
s2a(
"Generate an atomic density using the atomic code", &
339 "Using the ground-state density."), &
345 keyword, __location__, &
347 description=
"Decide whether to perform ADMM in the exact exchange calc. for DC-DFT. "// &
348 "The ADMM XC correction is governed by the AUXILIARY_DENSITY_MATRIX_METHOD section in &DFT. "// &
349 "In most cases, the Hartree-Fock exchange is not too expensive and there is no need for ADMM, "// &
350 "ADMM can however provide significant speedup and memory savings in case of diffuse basis sets. ", &
352 default_l_val=.false., &
353 lone_keyword_l_val=.true.)
364 SUBROUTINE create_ec_solver_section(section)
369 cpassert(.NOT.
ASSOCIATED(section))
370 CALL section_create(section, __location__, name=
"RESPONSE_SOLVER", &
371 description=
"Specifies the parameters of the linear scaling solver routines", &
372 n_keywords=24, n_subsections=3, repeats=.false., &
378 description=
"Target accuracy for the convergence of the conjugate gradient.", &
379 usage=
"EPS 1.e-10", default_r_val=1.e-12_dp)
384 description=
"Threshold used for filtering matrix operations.", &
385 usage=
"EPS_FILTER 1.0E-10", default_r_val=1.0e-10_dp)
390 description=
"Threshold used for lanczos estimates.", &
391 usage=
"EPS_LANCZOS 1.0E-4", default_r_val=1.0e-3_dp)
396 description=
"Maximum number of conjugate gradient iteration "// &
397 "to be performed for one optimization.", &
398 usage=
"MAX_ITER 200", default_i_val=50)
402 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LANCZOS", &
403 description=
"Maximum number of lanczos iterations.", &
404 usage=
"MAX_ITER_LANCZOS 128", default_i_val=128)
409 description=
"Algorithm used to solve response equation. "// &
410 "Both solver are conjugate gradient based, but use either a vector (MO-coefficient) "// &
411 "or density matrix formalism in the orthonormal AO-basis to obtain response density", &
412 usage=
"METHOD SOLVER", &
414 enum_c_vals=
s2a(
"MO_SOLVER",
"AO_ORTHO"), &
415 enum_desc=
s2a(
"Solver based on MO (vector) formalism", &
416 "Solver based on density matrix formalism"), &
422 keyword, __location__, name=
"PRECONDITIONER", &
423 description=
"Type of preconditioner to be used with MO conjugate gradient solver. "// &
424 "They differ in effectiveness, cost of construction, cost of application. "// &
425 "Properly preconditioned minimization can be orders of magnitude faster than doing nothing. "// &
426 "Only multi-level conjugate gradient preconditioner (MULTI_LEVEL) available for AO response solver (AO_ORTHO). ", &
427 usage=
"PRECONDITIONER FULL_ALL", &
429 enum_c_vals=
s2a(
"FULL_ALL",
"FULL_SINGLE_INVERSE",
"FULL_SINGLE",
"FULL_KINETIC",
"FULL_S_INVERSE", &
430 "MULTI_LEVEL",
"NONE"), &
431 enum_desc=
s2a(
"Most effective state selective preconditioner based on diagonalization, "// &
432 "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
433 "This preconditioner is recommended for almost all systems, except very large systems where "// &
434 "make_preconditioner would dominate the total computational cost.", &
435 "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
436 "but cheaper to construct, "// &
437 "might be somewhat less robust. Recommended for large systems.", &
438 "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
439 "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
440 "use for very large systems.", &
441 "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
442 "Based on same CG as AO-solver itself, but uses cheaper linear transformation", &
443 "skip preconditioning"), &
449 CALL keyword_create(keyword, __location__, name=
"S_PRECONDITIONER", &
450 description=
"Preconditions S with some appropriate form.", &
451 usage=
"S_PRECONDITIONER MOLECULAR", &
453 enum_c_vals=
s2a(
"NONE",
"ATOMIC",
"MOLECULAR"), &
454 enum_desc=
s2a(
"No preconditioner", &
455 "Using atomic blocks", &
456 "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
461 CALL keyword_create(keyword, __location__, name=
"S_SQRT_METHOD", &
462 description=
"Method for the caclulation of the sqrt of S.", &
463 usage=
"S_SQRT_METHOD NEWTONSCHULZ", &
465 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
466 enum_desc=
s2a(
"Using a Newton-Schulz-like iteration", &
467 "Using the p-th root method."), &
473 variants=
s2a(
"SIGN_SQRT_ORDER"), &
474 description=
"Order of the iteration method for the calculation of the sqrt of S.", &
475 usage=
"S_SQRT_ORDER 3", default_i_val=3)
480 keyword, __location__, name=
"MATRIX_CLUSTER_TYPE", &
481 description=
"Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
482 "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
483 "Furthermore, since screening is on matrix blocks, "// &
484 "slightly more accurate results can be expected with molecular.", &
485 usage=
"MATRIX_CLUSTER_TYPE MOLECULAR", &
487 enum_c_vals=
s2a(
"ATOMIC",
"MOLECULAR"), &
488 enum_desc=
s2a(
"Using atomic blocks", &
489 "Using molecular blocks."), &
495 description=
"Method used to compute the inverse of S.", &
496 usage=
"S_PRECONDITIONER MOLECULAR", &
498 enum_c_vals=
s2a(
"SIGN_SQRT",
"HOTELLING"), &
499 enum_desc=
s2a(
"Using the inverse sqrt as obtained from sign function iterations.", &
500 "Using the Hotellign iteration."), &
506 description=
"Restart the response calculation if the restart file exists", &
508 default_l_val=.false., lone_keyword_l_val=.true.)
512 CALL keyword_create(keyword, __location__, name=
"RESTART_EVERY", &
513 description=
"Restart the conjugate gradient after the specified number of iterations.", &
514 usage=
"RESTART_EVERY 50", default_i_val=50)
518 END SUBROUTINE create_ec_solver_section
525 SUBROUTINE create_ec_print_section(section)
531 cpassert(.NOT.
ASSOCIATED(section))
533 description=
"Section of possible print options in EC code.", &
534 n_keywords=0, n_subsections=1, repeats=.false.)
536 NULLIFY (print_key, keyword)
540 description=
"Controls the output of the electron density to the losslessly"// &
541 " compressed BQB file format, see [Brehm2018]"// &
542 " (via LibBQB see <https://brehm-research.de/bqb>)."// &
543 " Currently does not work with changing cell vector (NpT ensemble).", &
548 description=
"Skips the first step of a MD run (avoids duplicate step if restarted).", &
549 usage=
"SKIP_FIRST T", default_l_val=.false., lone_keyword_l_val=.true.)
553 CALL keyword_create(keyword, __location__, name=
"STORE_STEP_NUMBER", &
554 description=
"Stores the step number and simulation time in the comment line of each BQB"// &
555 " frame. Switch it off for binary compatibility with original CP2k CUBE files.", &
556 usage=
"STORE_STEP_NUMBER F", default_l_val=.true., lone_keyword_l_val=.true.)
561 description=
"Performs an on-the-fly decompression of each compressed BQB frame to check"// &
562 " whether the volumetric data exactly matches, and aborts the run if not so.", &
563 usage=
"CHECK T", default_l_val=.false., lone_keyword_l_val=.true.)
568 description=
"Specify this keyword to overwrite the output BQB file if"// &
569 " it already exists. By default, the data is appended to an existing file.", &
570 usage=
"OVERWRITE T", default_l_val=.false., lone_keyword_l_val=.true.)
575 description=
"Controls how many previous steps are taken into account for extrapolation in"// &
576 " compression. Use a value of 1 to compress the frames independently.", &
577 usage=
"HISTORY 10", n_var=1, default_i_val=10, type_of_var=
integer_t)
581 CALL keyword_create(keyword, __location__, name=
"PARAMETER_KEY", &
582 description=
"Allows to supply previously optimized compression parameters via a"// &
583 " parameter key (alphanumeric character sequence starting with 'at')."// &
584 " Just leave away the 'at' sign here, because CP2k will otherwise"// &
585 " assume it is a variable name in the input", &
586 usage=
"PARAMETER_KEY <KEY>", n_var=1, default_c_val=
"", type_of_var=
char_t)
591 description=
"Controls the time spent to optimize the parameters for compression efficiency.", &
592 usage=
"OPTIMIZE {OFF,QUICK,NORMAL,PATIENT,EXHAUSTIVE}", repeats=.false., n_var=1, &
594 enum_c_vals=
s2a(
"OFF",
"QUICK",
"NORMAL",
"PATIENT",
"EXHAUSTIVE"), &
595 enum_desc=
s2a(
"No optimization (use defaults)",
"Quick optimization", &
596 "Standard optimization",
"Precise optimization",
"Exhaustive optimization"), &
613 keyword, __location__, &
615 description=
"Maximum moment to be calculated. Values higher than 1 not implemented under periodic boundaries.", &
616 usage=
"MAX_MOMENT {integer}", &
625 description=
"Calculate also magnetic moments, only implemented without periodic boundaries", &
626 usage=
"MAGNETIC yes", &
629 default_l_val=.false., &
630 lone_keyword_l_val=.true.)
636 END SUBROUTINE create_ec_print_section
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public vandevondele2012
integer, save, public niklasson2003
integer, save, public brehm2018
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public debug_print_level
integer, parameter, public high_print_level
subroutine, public cp_print_key_section_create(print_key_section, location, name, description, print_level, each_iter_names, each_iter_values, add_last, filename, common_iter_levels, citations, unit_str)
creates a print_key section
Defines the basic variable types.
integer, parameter, public dp
Utilities for string manipulations.