46#include "./base/base_uses.f90"
51 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'input_cp2k_ec'
68 cpassert(.NOT.
ASSOCIATED(section))
71 CALL section_create(section, __location__, name=
"ENERGY_CORRECTION", &
72 description=
"Sets the various options for the Energy Correction", &
73 n_keywords=0, n_subsections=2, repeats=.false.)
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 lone_keyword_l_val=.true.)
91 CALL create_ec_solver_section(subsection)
97 CALL create_ec_print_section(subsection)
101 CALL keyword_create(keyword, __location__, name=
"ENERGY_FUNCTIONAL", &
102 description=
"Functional used in energy correction", &
103 usage=
"ENERGY_FUNCTIONAL HARRIS", &
105 enum_c_vals=
s2a(
"HARRIS",
"DCDFT",
"EXTERNAL"), &
106 enum_desc=
s2a(
"Harris functional", &
107 "Density-corrected DFT", &
108 "External calculated energy"), &
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 type_of_var=
char_t, default_c_val=
"ORBITAL", n_var=-1)
124 description=
"Additional output to debug energy correction forces.", &
125 usage=
"DEBUG_FORCES T", default_l_val=.false., lone_keyword_l_val=.true.)
129 description=
"Additional output to debug energy correction forces.", &
130 usage=
"DEBUG_STRESS T", default_l_val=.false., lone_keyword_l_val=.true.)
133 CALL keyword_create(keyword, __location__, name=
"DEBUG_EXTERNAL_METHOD", &
134 description=
"Uses an internal pseudo-energy to test EXTERNAL energy method.", &
135 usage=
"DEBUG_EXTERNAL_METHOD T", default_l_val=.false., lone_keyword_l_val=.true.)
140 description=
"Skip EC calculation if ground-state calculation has not converged.", &
141 usage=
"SKIP_EC T", default_l_val=.false., lone_keyword_l_val=.true.)
146 description=
"Use modified atomic orbitals (MAO) to solve Harris equation", &
147 usage=
"MAO T", default_l_val=.false., lone_keyword_l_val=.true.)
152 description=
"Maximum iterations in MAO optimization. ", &
153 usage=
"MAO_MAX_ITER 100 ", default_i_val=0)
158 description=
"Threshold used for MAO iterations. ", &
159 usage=
"MAO_EPS_GRAD 1.0E-4 ", default_r_val=1.0e-5_dp)
164 description=
"Occupation threshold used to determine number of MAOs."// &
165 " KIND section MAO keyword sets the minimum.", &
166 usage=
"MAO_EPS1 0.001 ", default_r_val=1000.0_dp)
171 description=
"Verbosity of MAO output: (0) no output ... (3) fully verbose", &
172 usage=
"MAO_IOLEVEL 0 ", default_i_val=1)
177 description=
"Algorithm used to solve KS equation", &
178 usage=
"ALGORITHM 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"), &
192 CALL keyword_create(keyword, __location__, name=
"FACTORIZATION", &
193 description=
"Algorithm used to calculate factorization of overlap matrix", &
194 usage=
"FACTORIZATION CHOLESKY", &
196 enum_c_vals=
s2a(
"CHOLESKY"), &
197 enum_desc=
s2a(
"Cholesky factorization of overlap matrix"), &
203 description=
"Threshold used for accuracy estimates within energy correction. ", &
204 usage=
"EPS_DEFAULT 1.0E-7 ", default_r_val=1.0e-7_dp)
210 description=
"Threshold used for filtering matrix operations.", &
211 usage=
"EPS_FILTER 1.0E-12", default_r_val=1.0e-12_dp)
216 description=
"Threshold used for lanczos estimates.", &
217 usage=
"EPS_LANCZOS 1.0E-4", default_r_val=1.0e-3_dp)
221 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LANCZOS", &
222 description=
"Maximum number of lanczos iterations.", &
223 usage=
"MAX_ITER_LANCZOS ", default_i_val=128)
228 description=
"Value (or initial guess) for the chemical potential,"// &
229 " i.e. some suitable energy between HOMO and LUMO energy.", &
230 usage=
"MU 0.0", default_r_val=-0.1_dp)
235 description=
"Should the calculation be performed at fixed chemical potential,"// &
236 " or should it be found fixing the number of electrons", &
237 usage=
"FIXED_MU .TRUE.", default_l_val=.false., lone_keyword_l_val=.true.)
241 CALL keyword_create(keyword, __location__, name=
"S_PRECONDITIONER", &
242 description=
"Preconditions S with some appropriate form.", &
243 usage=
"S_PRECONDITIONER MOLECULAR", &
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."), &
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", &
257 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
258 enum_desc=
s2a(
"Using a Newton-Schulz-like iteration", &
259 "Using the p-th root method."), &
265 variants=
s2a(
"SIGN_SQRT_ORDER"), &
266 description=
"Order of the iteration method for the calculation of the sqrt of S.", &
267 usage=
"S_SQRT_ORDER 3", default_i_val=3)
272 description=
"Method used for the computation of the sign matrix.", &
273 usage=
"SIGN_METHOD NEWTONSCHULZ", &
276 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
277 enum_desc=
s2a(
"Newton-Schulz iteration.", &
278 "p-th order root iteration"), &
284 description=
"Order of the method used for the computation of the sign matrix.", &
285 usage=
"SIGN_ORDER 2", &
290 CALL keyword_create(keyword, __location__, name=
"DYNAMIC_THRESHOLD", &
291 description=
"Should the threshold for the purification be chosen dynamically", &
292 usage=
"DYNAMIC_THRESHOLD .TRUE.", default_l_val=.false., lone_keyword_l_val=.true.)
296 CALL keyword_create(keyword, __location__, name=
"NON_MONOTONIC", &
297 description=
"Should the purification be performed non-monotonically. Relevant for TC2 only.", &
298 usage=
"NON_MONOTONIC .TRUE.", default_l_val=.true., lone_keyword_l_val=.true.)
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", &
310 enum_c_vals=
s2a(
"ATOMIC",
"MOLECULAR"), &
311 enum_desc=
s2a(
"Using atomic blocks", &
312 "Using molecular blocks."), &
318 description=
"Method used to compute the inverse of S.", &
319 usage=
"S_INVERSION MOLECULAR", &
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."), &
328 CALL keyword_create(keyword, __location__, name=
"REPORT_ALL_SPARSITIES", &
329 description=
"Run the sparsity report at the end of the SCF", &
330 usage=
"REPORT_ALL_SPARSITIES", default_l_val=.false., lone_keyword_l_val=.true.)
335 description=
"Perform an accuracy check on the inverse/sqrt of the s matrix.", &
336 usage=
"CHECK_S_INV", default_l_val=.false., lone_keyword_l_val=.true.)
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", &
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."), &
352 keyword, __location__, &
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. ", &
359 default_l_val=.false., &
360 lone_keyword_l_val=.true.)
364 CALL keyword_create(keyword, __location__, name=
"EXTERNAL_RESPONSE_FILENAME", &
365 description=
"Name of the file that contains response information.", &
366 usage=
"EXTERNAL_RESPONSE_FILENAME <FILENAME>", &
367 default_c_val=
"TREXIO")
371 CALL keyword_create(keyword, __location__, name=
"EXTERNAL_RESPONSE_ERROR_FILENAME", &
372 description=
"Name of the file that contains response error information.", &
373 usage=
"EXTERNAL_RESPONSE_ERROR_FILENAME <FILENAME>", &
374 default_c_val=
"TREXIO")
378 CALL keyword_create(keyword, __location__, name=
"EXTERNAL_RESULT_FILENAME", &
379 description=
"Name of the file that contains results from external response calculation.", &
380 usage=
"EXTERNAL_RESULT_FILENAME <FILENAME>", &
381 default_c_val=
"CP2K_EXRESP.result")
386 keyword, __location__, &
387 name=
"ERROR_ESTIMATION", &
388 description=
"Perform an error estimation for the response forces/stress. "// &
389 "Requires error estimates for the RHS of the response equation from input. ", &
390 usage=
"ERROR_ESTIMATION", &
391 default_l_val=.false., &
392 lone_keyword_l_val=.true.)
396 CALL keyword_create(keyword, __location__, name=
"ERROR_ESTIMATION_METHOD", &
397 description=
"Method used for error estimation: F(ull); D(ifferenc); E(xtrapolate).", &
398 usage=
"ERROR_ESTIMATION_METHOD E", &
404 description=
"Cutoff value for error estimation.", &
405 usage=
"ERROR_CUTOFF 1.E-6", &
406 default_r_val=1.e-5_dp)
410 CALL keyword_create(keyword, __location__, name=
"ERROR_SUBSPACE_SIZE", &
411 description=
"MAX. size of subspace for response vector extrapolation.", &
412 usage=
"ERROR_SUBSPACE_SIZE 100", &
424 SUBROUTINE create_ec_solver_section(section)
429 cpassert(.NOT.
ASSOCIATED(section))
430 CALL section_create(section, __location__, name=
"RESPONSE_SOLVER", &
431 description=
"Specifies the parameters of the linear scaling solver routines", &
432 n_keywords=24, n_subsections=3, repeats=.false., &
438 description=
"Target accuracy for the convergence of the conjugate gradient.", &
439 usage=
"EPS 1.e-10", default_r_val=1.e-12_dp)
444 description=
"Threshold used for filtering matrix operations.", &
445 usage=
"EPS_FILTER 1.0E-10", default_r_val=1.0e-10_dp)
450 description=
"Threshold used for lanczos estimates.", &
451 usage=
"EPS_LANCZOS 1.0E-4", default_r_val=1.0e-3_dp)
456 description=
"Maximum number of conjugate gradient iteration "// &
457 "to be performed for one optimization.", &
458 usage=
"MAX_ITER 200", default_i_val=50)
462 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LANCZOS", &
463 description=
"Maximum number of lanczos iterations.", &
464 usage=
"MAX_ITER_LANCZOS 128", default_i_val=128)
469 description=
"Algorithm used to solve response equation. "// &
470 "Both solver are conjugate gradient based, but use either a vector (MO-coefficient) "// &
471 "or density matrix formalism in the orthonormal AO-basis to obtain response density", &
472 usage=
"METHOD SOLVER", &
474 enum_c_vals=
s2a(
"MO_SOLVER",
"AO_ORTHO"), &
475 enum_desc=
s2a(
"Solver based on MO (vector) formalism", &
476 "Solver based on density matrix formalism"), &
482 keyword, __location__, name=
"PRECONDITIONER", &
483 description=
"Type of preconditioner to be used with MO conjugate gradient solver. "// &
484 "They differ in effectiveness, cost of construction, cost of application. "// &
485 "Properly preconditioned minimization can be orders of magnitude faster than doing nothing. "// &
486 "Only multi-level conjugate gradient preconditioner (MULTI_LEVEL) available for AO response solver (AO_ORTHO). ", &
487 usage=
"PRECONDITIONER FULL_ALL", &
489 enum_c_vals=
s2a(
"FULL_ALL",
"FULL_SINGLE_INVERSE",
"FULL_SINGLE",
"FULL_KINETIC",
"FULL_S_INVERSE", &
490 "MULTI_LEVEL",
"NONE"), &
491 enum_desc=
s2a(
"Most effective state selective preconditioner based on diagonalization, "// &
492 "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
493 "This preconditioner is recommended for almost all systems, except very large systems where "// &
494 "make_preconditioner would dominate the total computational cost.", &
495 "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
496 "but cheaper to construct, "// &
497 "might be somewhat less robust. Recommended for large systems.", &
498 "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
499 "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
500 "use for very large systems.", &
501 "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
502 "Based on same CG as AO-solver itself, but uses cheaper linear transformation", &
503 "skip preconditioning"), &
509 CALL keyword_create(keyword, __location__, name=
"S_PRECONDITIONER", &
510 description=
"Preconditions S with some appropriate form.", &
511 usage=
"S_PRECONDITIONER MOLECULAR", &
513 enum_c_vals=
s2a(
"NONE",
"ATOMIC",
"MOLECULAR"), &
514 enum_desc=
s2a(
"No preconditioner", &
515 "Using atomic blocks", &
516 "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
521 CALL keyword_create(keyword, __location__, name=
"S_SQRT_METHOD", &
522 description=
"Method for the caclulation of the sqrt of S.", &
523 usage=
"S_SQRT_METHOD NEWTONSCHULZ", &
525 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
526 enum_desc=
s2a(
"Using a Newton-Schulz-like iteration", &
527 "Using the p-th root method."), &
533 variants=
s2a(
"SIGN_SQRT_ORDER"), &
534 description=
"Order of the iteration method for the calculation of the sqrt of S.", &
535 usage=
"S_SQRT_ORDER 3", default_i_val=3)
540 keyword, __location__, name=
"MATRIX_CLUSTER_TYPE", &
541 description=
"Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
542 "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
543 "Furthermore, since screening is on matrix blocks, "// &
544 "slightly more accurate results can be expected with molecular.", &
545 usage=
"MATRIX_CLUSTER_TYPE MOLECULAR", &
547 enum_c_vals=
s2a(
"ATOMIC",
"MOLECULAR"), &
548 enum_desc=
s2a(
"Using atomic blocks", &
549 "Using molecular blocks."), &
555 description=
"Method used to compute the inverse of S.", &
556 usage=
"S_INVERSION MOLECULAR", &
558 enum_c_vals=
s2a(
"SIGN_SQRT",
"HOTELLING"), &
559 enum_desc=
s2a(
"Using the inverse sqrt as obtained from sign function iterations.", &
560 "Using the Hotellign iteration."), &
566 description=
"Restart the response calculation if the restart file exists", &
568 default_l_val=.false., lone_keyword_l_val=.true.)
572 CALL keyword_create(keyword, __location__, name=
"RESTART_EVERY", &
573 description=
"Restart the conjugate gradient after the specified number of iterations.", &
574 usage=
"RESTART_EVERY 50", default_i_val=50)
578 END SUBROUTINE create_ec_solver_section
585 SUBROUTINE create_ec_print_section(section)
591 cpassert(.NOT.
ASSOCIATED(section))
593 description=
"Section of possible print options in EC code.", &
594 n_keywords=0, n_subsections=1, repeats=.false.)
596 NULLIFY (print_key, keyword)
600 description=
"Controls the output of the electron density to the losslessly"// &
601 " compressed BQB file format, see [Brehm2018]"// &
602 " (via LibBQB see <https://brehm-research.de/bqb>)."// &
603 " Currently does not work with changing cell vector (NpT ensemble).", &
608 description=
"Skips the first step of a MD run (avoids duplicate step if restarted).", &
609 usage=
"SKIP_FIRST T", default_l_val=.false., lone_keyword_l_val=.true.)
613 CALL keyword_create(keyword, __location__, name=
"STORE_STEP_NUMBER", &
614 description=
"Stores the step number and simulation time in the comment line of each BQB"// &
615 " frame. Switch it off for binary compatibility with original CP2k CUBE files.", &
616 usage=
"STORE_STEP_NUMBER F", default_l_val=.true., lone_keyword_l_val=.true.)
621 description=
"Performs an on-the-fly decompression of each compressed BQB frame to check"// &
622 " whether the volumetric data exactly matches, and aborts the run if not so.", &
623 usage=
"CHECK T", default_l_val=.false., lone_keyword_l_val=.true.)
628 description=
"Specify this keyword to overwrite the output BQB file if"// &
629 " it already exists. By default, the data is appended to an existing file.", &
630 usage=
"OVERWRITE T", default_l_val=.false., lone_keyword_l_val=.true.)
635 description=
"Controls how many previous steps are taken into account for extrapolation in"// &
636 " compression. Use a value of 1 to compress the frames independently.", &
637 usage=
"HISTORY 10", n_var=1, default_i_val=10, type_of_var=
integer_t)
641 CALL keyword_create(keyword, __location__, name=
"PARAMETER_KEY", &
642 description=
"Allows to supply previously optimized compression parameters via a"// &
643 " parameter key (alphanumeric character sequence starting with 'at')."// &
644 " Just leave away the 'at' sign here, because CP2k will otherwise"// &
645 " assume it is a variable name in the input", &
646 usage=
"PARAMETER_KEY <KEY>", n_var=1, default_c_val=
"", type_of_var=
char_t)
651 description=
"Controls the time spent to optimize the parameters for compression efficiency.", &
652 usage=
"OPTIMIZE {OFF,QUICK,NORMAL,PATIENT,EXHAUSTIVE}", repeats=.false., n_var=1, &
654 enum_c_vals=
s2a(
"OFF",
"QUICK",
"NORMAL",
"PATIENT",
"EXHAUSTIVE"), &
655 enum_desc=
s2a(
"No optimization (use defaults)",
"Quick optimization", &
656 "Standard optimization",
"Precise optimization",
"Exhaustive optimization"), &
673 keyword, __location__, &
675 description=
"Maximum moment to be calculated. Values higher than 1 not implemented under periodic boundaries.", &
676 usage=
"MAX_MOMENT {integer}", &
685 description=
"Calculate also magnetic moments, only implemented without periodic boundaries", &
686 usage=
"MAGNETIC yes", &
689 default_l_val=.false., &
690 lone_keyword_l_val=.true.)
696 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.