49#include "./base/base_uses.f90"
54 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'input_cp2k_ec'
71 cpassert(.NOT.
ASSOCIATED(section))
74 CALL section_create(section, __location__, name=
"ENERGY_CORRECTION", &
75 description=
"Sets the various options for the Energy Correction", &
76 n_keywords=0, n_subsections=2, repeats=.false.)
78 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
79 description=
"Controls the activation of the energy_correction", &
80 usage=
"&ENERGY_CORRECTION T", &
81 default_l_val=.false., &
82 lone_keyword_l_val=.true.)
100 CALL create_ec_solver_section(subsection)
106 CALL create_ec_print_section(subsection)
110 CALL keyword_create(keyword, __location__, name=
"ENERGY_FUNCTIONAL", &
111 description=
"Functional used in energy correction", &
112 usage=
"ENERGY_FUNCTIONAL HARRIS", &
114 enum_c_vals=
s2a(
"HARRIS",
"DCDFT",
"EXTERNAL"), &
115 enum_desc=
s2a(
"Harris functional", &
116 "Density-corrected DFT", &
117 "External calculated energy"), &
123 description=
"Specifies the type of basis to be used for the KG energy correction. "// &
124 "Options are: (1) the default orbital basis (ORBITAL); "// &
125 "(2) the primitive functions of the default orbital basis (PRIMITIVE); "// &
126 "(3) the basis set labeled in Kind section (HARRIS)", &
127 usage=
"HARRIS_BASIS ORBITAL", &
128 type_of_var=
char_t, default_c_val=
"ORBITAL", n_var=-1)
133 description=
"Additional output to debug energy correction forces.", &
134 usage=
"DEBUG_FORCES T", default_l_val=.false., lone_keyword_l_val=.true.)
138 description=
"Additional output to debug energy correction forces.", &
139 usage=
"DEBUG_STRESS T", default_l_val=.false., lone_keyword_l_val=.true.)
142 CALL keyword_create(keyword, __location__, name=
"DEBUG_EXTERNAL_METHOD", &
143 description=
"Uses an internal pseudo-energy to test EXTERNAL energy method.", &
144 usage=
"DEBUG_EXTERNAL_METHOD T", default_l_val=.false., lone_keyword_l_val=.true.)
149 description=
"Skip EC calculation if ground-state calculation has not converged.", &
150 usage=
"SKIP_EC T", default_l_val=.false., lone_keyword_l_val=.true.)
155 description=
"Use modified atomic orbitals (MAO) to solve Harris equation", &
156 usage=
"MAO T", default_l_val=.false., lone_keyword_l_val=.true.)
161 description=
"Maximum iterations in MAO optimization. ", &
162 usage=
"MAO_MAX_ITER 100 ", default_i_val=0)
167 description=
"Threshold used for MAO iterations. ", &
168 usage=
"MAO_EPS_GRAD 1.0E-4 ", default_r_val=1.0e-5_dp)
173 description=
"Occupation threshold used to determine number of MAOs."// &
174 " KIND section MAO keyword sets the minimum.", &
175 usage=
"MAO_EPS1 0.001 ", default_r_val=1000.0_dp)
180 description=
"Verbosity of MAO output: (0) no output ... (3) fully verbose", &
181 usage=
"MAO_IOLEVEL 0 ", default_i_val=1)
186 name=
"ELECTRONIC_TEMPERATURE", &
187 variants=
s2a(
"ELEC_TEMP",
"FD_TEMP"), &
188 description=
"Electronic temperature for Harris functional with "// &
189 "Fermi-Dirac smearing.", &
195 usage=
"ELECTRONIC_TEMPERATURE [K] 300")
200 description=
"Algorithm used to solve KS equation", &
201 usage=
"ALGORITHM DIAGONALIZATION", &
203 enum_c_vals=
s2a(
"DIAGONALIZATION",
"MATRIX_SIGN", &
204 "TRS4",
"TC2",
"OT_DIAG"), &
205 enum_desc=
s2a(
"Diagonalization of KS matrix.", &
206 "Matrix Sign algorithm", &
207 "Trace resetting trs4 algorithm", &
208 "Trace resetting tc2 algorithm", &
209 "OT diagonalization"), &
215 CALL keyword_create(keyword, __location__, name=
"FACTORIZATION", &
216 description=
"Algorithm used to calculate factorization of overlap matrix", &
217 usage=
"FACTORIZATION CHOLESKY", &
219 enum_c_vals=
s2a(
"CHOLESKY"), &
220 enum_desc=
s2a(
"Cholesky factorization of overlap matrix"), &
226 description=
"Threshold used for accuracy estimates within energy correction. ", &
227 usage=
"EPS_DEFAULT 1.0E-7 ", default_r_val=1.0e-7_dp)
233 description=
"Threshold used for filtering matrix operations.", &
234 usage=
"EPS_FILTER 1.0E-12", default_r_val=1.0e-12_dp)
239 description=
"Threshold used for lanczos estimates.", &
240 usage=
"EPS_LANCZOS 1.0E-4", default_r_val=1.0e-3_dp)
244 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LANCZOS", &
245 description=
"Maximum number of lanczos iterations.", &
246 usage=
"MAX_ITER_LANCZOS ", default_i_val=128)
251 description=
"Value (or initial guess) for the chemical potential,"// &
252 " i.e. some suitable energy between HOMO and LUMO energy.", &
253 usage=
"MU 0.0", default_r_val=-0.1_dp)
258 description=
"Should the calculation be performed at fixed chemical potential,"// &
259 " or should it be found fixing the number of electrons", &
260 usage=
"FIXED_MU .TRUE.", default_l_val=.false., lone_keyword_l_val=.true.)
264 CALL keyword_create(keyword, __location__, name=
"S_PRECONDITIONER", &
265 description=
"Preconditions S with some appropriate form.", &
266 usage=
"S_PRECONDITIONER MOLECULAR", &
268 enum_c_vals=
s2a(
"NONE",
"ATOMIC",
"MOLECULAR"), &
269 enum_desc=
s2a(
"No preconditioner", &
270 "Using atomic blocks", &
271 "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
276 CALL keyword_create(keyword, __location__, name=
"S_SQRT_METHOD", &
277 description=
"Method for the caclulation of the sqrt of S.", &
278 usage=
"S_SQRT_METHOD NEWTONSCHULZ", &
280 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
281 enum_desc=
s2a(
"Using a Newton-Schulz-like iteration", &
282 "Using the p-th root method."), &
288 variants=
s2a(
"SIGN_SQRT_ORDER"), &
289 description=
"Order of the iteration method for the calculation of the sqrt of S.", &
290 usage=
"S_SQRT_ORDER 3", default_i_val=3)
295 description=
"Method used for the computation of the sign matrix.", &
296 usage=
"SIGN_METHOD NEWTONSCHULZ", &
299 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
300 enum_desc=
s2a(
"Newton-Schulz iteration.", &
301 "p-th order root iteration"), &
307 description=
"Order of the method used for the computation of the sign matrix.", &
308 usage=
"SIGN_ORDER 2", &
313 CALL keyword_create(keyword, __location__, name=
"DYNAMIC_THRESHOLD", &
314 description=
"Should the threshold for the purification be chosen dynamically", &
315 usage=
"DYNAMIC_THRESHOLD .TRUE.", default_l_val=.false., lone_keyword_l_val=.true.)
319 CALL keyword_create(keyword, __location__, name=
"NON_MONOTONIC", &
320 description=
"Should the purification be performed non-monotonically. Relevant for TC2 only.", &
321 usage=
"NON_MONOTONIC .TRUE.", default_l_val=.true., lone_keyword_l_val=.true.)
326 keyword, __location__, name=
"MATRIX_CLUSTER_TYPE", &
327 description=
"Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
328 "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
329 "Furthermore, since screening is on matrix blocks, "// &
330 "slightly more accurate results can be expected with molecular.", &
331 usage=
"MATRIX_CLUSTER_TYPE MOLECULAR", &
333 enum_c_vals=
s2a(
"ATOMIC",
"MOLECULAR"), &
334 enum_desc=
s2a(
"Using atomic blocks", &
335 "Using molecular blocks."), &
341 description=
"Method used to compute the inverse of S.", &
342 usage=
"S_INVERSION MOLECULAR", &
344 enum_c_vals=
s2a(
"SIGN_SQRT",
"HOTELLING"), &
345 enum_desc=
s2a(
"Using the inverse sqrt as obtained from sign function iterations.", &
346 "Using the Hotellign iteration."), &
351 CALL keyword_create(keyword, __location__, name=
"REPORT_ALL_SPARSITIES", &
352 description=
"Run the sparsity report at the end of the SCF", &
353 usage=
"REPORT_ALL_SPARSITIES", default_l_val=.false., lone_keyword_l_val=.true.)
358 description=
"Perform an accuracy check on the inverse/sqrt of the s matrix.", &
359 usage=
"CHECK_S_INV", default_l_val=.false., lone_keyword_l_val=.true.)
363 CALL keyword_create(keyword, __location__, name=
"OT_INITIAL_GUESS", &
364 description=
"Initial guess of density matrix used for OT Diagonalization", &
365 usage=
"OT_INITIAL_GUESS ATOMIC", &
367 enum_c_vals=
s2a(
"ATOMIC",
"GROUND_STATE"), &
368 enum_desc=
s2a(
"Generate an atomic density using the atomic code", &
369 "Using the ground-state density."), &
375 keyword, __location__, &
377 description=
"Decide whether to perform ADMM in the exact exchange calc. for DC-DFT. "// &
378 "The ADMM XC correction is governed by the AUXILIARY_DENSITY_MATRIX_METHOD section in &DFT. "// &
379 "In most cases, the Hartree-Fock exchange is not too expensive and there is no need for ADMM, "// &
380 "ADMM can however provide significant speedup and memory savings in case of diffuse basis sets. ", &
382 default_l_val=.false., &
383 lone_keyword_l_val=.true.)
387 CALL keyword_create(keyword, __location__, name=
"EXTERNAL_RESPONSE_FILENAME", &
388 description=
"Name of the file that contains response information.", &
389 usage=
"EXTERNAL_RESPONSE_FILENAME <FILENAME>", &
390 default_c_val=
"TREXIO")
394 CALL keyword_create(keyword, __location__, name=
"EXTERNAL_RESPONSE_ERROR_FILENAME", &
395 description=
"Name of the file that contains response error information.", &
396 usage=
"EXTERNAL_RESPONSE_ERROR_FILENAME <FILENAME>", &
397 default_c_val=
"TREXIO")
401 CALL keyword_create(keyword, __location__, name=
"EXTERNAL_RESULT_FILENAME", &
402 description=
"Name of the file that contains results from external response calculation.", &
403 usage=
"EXTERNAL_RESULT_FILENAME <FILENAME>", &
404 default_c_val=
"CP2K_EXRESP.result")
409 keyword, __location__, &
410 name=
"ERROR_ESTIMATION", &
411 description=
"Perform an error estimation for the response forces/stress. "// &
412 "Requires error estimates for the RHS of the response equation from input. ", &
413 usage=
"ERROR_ESTIMATION", &
414 default_l_val=.false., &
415 lone_keyword_l_val=.true.)
419 CALL keyword_create(keyword, __location__, name=
"ERROR_ESTIMATION_METHOD", &
420 description=
"Method used for error estimation: F(ull); D(ifferenc); E(xtrapolate).", &
421 usage=
"ERROR_ESTIMATION_METHOD E", &
427 description=
"Cutoff value for error estimation.", &
428 usage=
"ERROR_CUTOFF 1.E-6", &
429 default_r_val=1.e-5_dp)
433 CALL keyword_create(keyword, __location__, name=
"ERROR_SUBSPACE_SIZE", &
434 description=
"MAX. size of subspace for response vector extrapolation.", &
435 usage=
"ERROR_SUBSPACE_SIZE 100", &
447 SUBROUTINE create_ec_solver_section(section)
452 cpassert(.NOT.
ASSOCIATED(section))
453 CALL section_create(section, __location__, name=
"RESPONSE_SOLVER", &
454 description=
"Specifies the parameters of the linear scaling solver routines", &
455 n_keywords=24, n_subsections=3, repeats=.false., &
461 description=
"Target accuracy for the convergence of the conjugate gradient.", &
462 usage=
"EPS 1.e-10", default_r_val=1.e-12_dp)
467 description=
"Threshold used for filtering matrix operations.", &
468 usage=
"EPS_FILTER 1.0E-10", default_r_val=1.0e-10_dp)
473 description=
"Threshold used for lanczos estimates.", &
474 usage=
"EPS_LANCZOS 1.0E-4", default_r_val=1.0e-3_dp)
479 description=
"Maximum number of conjugate gradient iteration "// &
480 "to be performed for one optimization.", &
481 usage=
"MAX_ITER 200", default_i_val=50)
485 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LANCZOS", &
486 description=
"Maximum number of lanczos iterations.", &
487 usage=
"MAX_ITER_LANCZOS 128", default_i_val=128)
492 description=
"Algorithm used to solve response equation. "// &
493 "Both solver are conjugate gradient based, but use either a vector (MO-coefficient) "// &
494 "or density matrix formalism in the orthonormal AO-basis to obtain response density", &
495 usage=
"METHOD SOLVER", &
497 enum_c_vals=
s2a(
"MO_SOLVER",
"AO_ORTHO"), &
498 enum_desc=
s2a(
"Solver based on MO (vector) formalism", &
499 "Solver based on density matrix formalism"), &
505 keyword, __location__, name=
"PRECONDITIONER", &
506 description=
"Type of preconditioner to be used with MO conjugate gradient solver. "// &
507 "They differ in effectiveness, cost of construction, cost of application. "// &
508 "Properly preconditioned minimization can be orders of magnitude faster than doing nothing. "// &
509 "Only multi-level conjugate gradient preconditioner (MULTI_LEVEL) available for AO response solver (AO_ORTHO). ", &
510 usage=
"PRECONDITIONER FULL_ALL", &
512 enum_c_vals=
s2a(
"FULL_ALL",
"FULL_SINGLE_INVERSE",
"FULL_SINGLE",
"FULL_KINETIC",
"FULL_S_INVERSE", &
513 "MULTI_LEVEL",
"NONE"), &
514 enum_desc=
s2a(
"Most effective state selective preconditioner based on diagonalization, "// &
515 "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
516 "This preconditioner is recommended for almost all systems, except very large systems where "// &
517 "make_preconditioner would dominate the total computational cost.", &
518 "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
519 "but cheaper to construct, "// &
520 "might be somewhat less robust. Recommended for large systems.", &
521 "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
522 "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
523 "use for very large systems.", &
524 "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
525 "Based on same CG as AO-solver itself, but uses cheaper linear transformation", &
526 "skip preconditioning"), &
532 CALL keyword_create(keyword, __location__, name=
"S_PRECONDITIONER", &
533 description=
"Preconditions S with some appropriate form.", &
534 usage=
"S_PRECONDITIONER MOLECULAR", &
536 enum_c_vals=
s2a(
"NONE",
"ATOMIC",
"MOLECULAR"), &
537 enum_desc=
s2a(
"No preconditioner", &
538 "Using atomic blocks", &
539 "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
544 CALL keyword_create(keyword, __location__, name=
"S_SQRT_METHOD", &
545 description=
"Method for the caclulation of the sqrt of S.", &
546 usage=
"S_SQRT_METHOD NEWTONSCHULZ", &
548 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
549 enum_desc=
s2a(
"Using a Newton-Schulz-like iteration", &
550 "Using the p-th root method."), &
556 variants=
s2a(
"SIGN_SQRT_ORDER"), &
557 description=
"Order of the iteration method for the calculation of the sqrt of S.", &
558 usage=
"S_SQRT_ORDER 3", default_i_val=3)
563 keyword, __location__, name=
"MATRIX_CLUSTER_TYPE", &
564 description=
"Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
565 "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
566 "Furthermore, since screening is on matrix blocks, "// &
567 "slightly more accurate results can be expected with molecular.", &
568 usage=
"MATRIX_CLUSTER_TYPE MOLECULAR", &
570 enum_c_vals=
s2a(
"ATOMIC",
"MOLECULAR"), &
571 enum_desc=
s2a(
"Using atomic blocks", &
572 "Using molecular blocks."), &
578 description=
"Method used to compute the inverse of S.", &
579 usage=
"S_INVERSION MOLECULAR", &
581 enum_c_vals=
s2a(
"SIGN_SQRT",
"HOTELLING"), &
582 enum_desc=
s2a(
"Using the inverse sqrt as obtained from sign function iterations.", &
583 "Using the Hotellign iteration."), &
589 description=
"Restart the response calculation if the restart file exists", &
591 default_l_val=.false., lone_keyword_l_val=.true.)
595 CALL keyword_create(keyword, __location__, name=
"RESTART_EVERY", &
596 description=
"Restart the conjugate gradient after the specified number of iterations.", &
597 usage=
"RESTART_EVERY 50", default_i_val=50)
601 END SUBROUTINE create_ec_solver_section
608 SUBROUTINE create_ec_print_section(section)
614 cpassert(.NOT.
ASSOCIATED(section))
616 description=
"Section of possible print options in EC code.", &
617 n_keywords=0, n_subsections=1, repeats=.false.)
619 NULLIFY (print_key, keyword)
623 description=
"Controls the output of the electron density to the losslessly"// &
624 " compressed BQB file format, see [Brehm2018]"// &
625 " (via LibBQB see <https://brehm-research.de/bqb>)."// &
626 " Currently does not work with changing cell vector (NpT ensemble).", &
631 description=
"Skips the first step of a MD run (avoids duplicate step if restarted).", &
632 usage=
"SKIP_FIRST T", default_l_val=.false., lone_keyword_l_val=.true.)
636 CALL keyword_create(keyword, __location__, name=
"STORE_STEP_NUMBER", &
637 description=
"Stores the step number and simulation time in the comment line of each BQB"// &
638 " frame. Switch it off for binary compatibility with original CP2k CUBE files.", &
639 usage=
"STORE_STEP_NUMBER F", default_l_val=.true., lone_keyword_l_val=.true.)
644 description=
"Performs an on-the-fly decompression of each compressed BQB frame to check"// &
645 " whether the volumetric data exactly matches, and aborts the run if not so.", &
646 usage=
"CHECK T", default_l_val=.false., lone_keyword_l_val=.true.)
651 description=
"Specify this keyword to overwrite the output BQB file if"// &
652 " it already exists. By default, the data is appended to an existing file.", &
653 usage=
"OVERWRITE T", default_l_val=.false., lone_keyword_l_val=.true.)
658 description=
"Controls how many previous steps are taken into account for extrapolation in"// &
659 " compression. Use a value of 1 to compress the frames independently.", &
660 usage=
"HISTORY 10", n_var=1, default_i_val=10, type_of_var=
integer_t)
664 CALL keyword_create(keyword, __location__, name=
"PARAMETER_KEY", &
665 description=
"Allows to supply previously optimized compression parameters via a"// &
666 " parameter key (alphanumeric character sequence starting with 'at')."// &
667 " Just leave away the 'at' sign here, because CP2k will otherwise"// &
668 " assume it is a variable name in the input", &
669 usage=
"PARAMETER_KEY <KEY>", n_var=1, default_c_val=
"", type_of_var=
char_t)
674 description=
"Controls the time spent to optimize the parameters for compression efficiency.", &
675 usage=
"OPTIMIZE {OFF,QUICK,NORMAL,PATIENT,EXHAUSTIVE}", repeats=.false., n_var=1, &
677 enum_c_vals=
s2a(
"OFF",
"QUICK",
"NORMAL",
"PATIENT",
"EXHAUSTIVE"), &
678 enum_desc=
s2a(
"No optimization (use defaults)",
"Quick optimization", &
679 "Standard optimization",
"Precise optimization",
"Exhaustive optimization"), &
696 keyword, __location__, &
698 description=
"Maximum moment to be calculated. Values higher than 1 not implemented under periodic boundaries.", &
699 usage=
"MAX_MOMENT {integer}", &
708 description=
"Calculate also magnetic moments, only implemented without periodic boundaries", &
709 usage=
"MAGNETIC yes", &
712 default_l_val=.false., &
713 lone_keyword_l_val=.true.)
719 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
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Defines the basic variable types.
integer, parameter, public dp
Utilities for string manipulations.