64#include "./base/base_uses.f90"
69 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'input_cp2k_scf'
88 cpassert(.NOT.
ASSOCIATED(section))
90 description=
"Parameters needed to perform an SCF run.", &
91 n_keywords=18, n_subsections=7, repeats=.false.)
95 CALL create_ot_section(subsection)
99 CALL create_diagonalization_section(subsection)
103 CALL create_outer_scf_section(subsection)
107 CALL create_smear_section(subsection)
119 CALL create_gce_section(subsection)
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 usage=
"MAX_ITER_LUMO 100", default_i_val=299)
134 variants=[
"EPS_LUMOS"], &
135 description=
"Target accuracy for the calculation of the LUMO energies with the OT eigensolver.", &
136 usage=
"EPS_LUMO 1.0E-6", default_r_val=1.0e-5_dp)
141 description=
"Maximum number of inner SCF iterations for one electronic optimization.", &
142 usage=
"MAX_SCF 200", default_i_val=50)
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 usage=
"MAX_SCF_HISTORY 1", default_i_val=0, lone_keyword_i_val=1)
153 variants=[
"MAX_DIIS_BUFFER_SIZE"], &
154 description=
"Maximum number of DIIS vectors to be used", &
155 usage=
"MAX_DIIS 3", default_i_val=4)
160 variants=[
"LSHIFT"], &
161 description=
"Use level shifting to improve convergence", &
163 usage=
"LEVEL_SHIFT 0.1", &
164 default_r_val=0.0_dp)
169 description=
"Target convergence threshold for the inner SCF cycle.", &
170 usage=
"EPS_SCF 1.e-6", default_r_val=1.e-5_dp)
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 usage=
"EPS_SCF_HISTORY 1.e-5", default_r_val=0.0_dp, lone_keyword_r_val=1.0e-5_dp)
181 description=
"If the cholesky method should be used for computing "// &
182 "the inverse of S, and in this case calling which Lapack routines", &
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"), &
194 description=
"Throw away linear combinations of basis functions with a small eigenvalue in S", &
195 usage=
"EPS_EIGVAL 1.0", default_r_val=1.0e-5_dp)
200 description=
"Threshold on the convergence to start using DIAG/DIIS or OT/DIIS."// &
201 " Default for OT/DIIS is never to switch.", &
202 usage=
"EPS_DIIS 5.0e-2", default_r_val=0.1_dp)
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)."), &
227 description=
"sets the number of rows in a scalapack block", &
228 usage=
"NROW_BLOCK 31", default_i_val=32)
233 description=
"Sets the number of columns in a scalapack block", &
234 usage=
"NCOL_BLOCK 31", default_i_val=32)
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 usage=
"ADDED_MOS", default_i_val=0, n_var=-1)
247 name=
"ROKS_SCHEME", &
248 description=
"Selects the ROKS scheme when ROKS is applied.", &
249 usage=
"ROKS_SCHEME HIGH-SPIN", &
252 enum_c_vals=
s2a(
"GENERAL",
"HIGH-SPIN"), &
260 variants=[
"F_ROKS"], &
261 description=
"Allows to define the parameter f for the "// &
262 "general ROKS scheme.", &
263 usage=
"ROKS_F 1/2", &
267 default_r_val=0.5_dp)
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", &
282 default_r_vals=[-0.5_dp, 1.5_dp, 0.5_dp, 0.5_dp, 1.5_dp, -0.5_dp])
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 lone_keyword_l_val=.true.)
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 lone_keyword_l_val=.true.)
305 description=
"Printing of information during the SCF.", repeats=.false.)
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", &
312 each_iter_names=
s2a(
"QS_SCF"), each_iter_values=[20], &
314 CALL keyword_create(keyword, __location__, name=
"BACKUP_COPIES", &
315 description=
"Specifies the maximum number of backup copies.", &
316 usage=
"BACKUP_COPIES {int}", &
324 print_key, __location__,
"RESTART_HISTORY", &
325 description=
"Dumps unique MO restart files during the run keeping all of them.", &
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], &
330 CALL keyword_create(keyword, __location__, name=
"BACKUP_COPIES", &
331 description=
"Specifies the maximum number of backup copies.", &
332 usage=
"BACKUP_COPIES {int}", &
340 description=
"Controls the printing of basic iteration information during the SCF.", &
343 description=
"If the printkey is activated switches the printing of timings"// &
344 " to cumulative (over the SCF).", &
345 default_l_val=.false., lone_keyword_l_val=.true.)
352 description=
"Controls the printing of basic information during the SCF.", &
358 description=
"Controls the printing relative to the orthonormality of MOs (CT S C).", &
364 description=
"Prints the min/max eigenvalues of the overlap of the MOs without S (CT C).", &
370 description=
"Controls the printing of detailed energy information.", &
376 description=
"Controls the printing of DIIS information.", &
382 description=
"Controls the printing of total densities.", &
388 description=
"Controls the printing of information on Lanczos refinement iterations.", &
394 print_key, __location__,
"DIAG_SUB_SCF", &
395 description=
"Controls the printing of information on subspace diagonalization internal loop. ", &
401 description=
"Controls the printing of information on Davidson iterations.", &
407 description=
"Controls the printing of information on Filter Matrix method.", &
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 usage=
"DM_RESTART_WRITE", default_l_val=.false., lone_keyword_l_val=.true.)
429 SUBROUTINE create_outer_scf_section(section)
435 cpassert(.NOT.
ASSOCIATED(section))
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 n_keywords=13, n_subsections=1, repeats=.false.)
443 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
444 description=
"Activates the outer SCF loop.", &
445 usage=
"&OUTER_SCF ON", default_l_val=.false., lone_keyword_l_val=.true.)
451 CALL create_cdft_opt_section(subsection)
456 description=
"Specifies which kind of outer SCF should be employed", &
457 usage=
"TYPE DDAPC_CONSTRAINT ", &
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 "// &
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,"), &
475 description=
"Method used to bring the outer loop to a stationary point", &
476 usage=
"OPTIMIZER SD", &
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."), &
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 usage=
"BISECT_TRUST_COUNT 5", default_i_val=10)
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 usage=
"EPS_SCF 1.0E-6 ", default_r_val=1.0e-5_dp)
516 CALL keyword_create(keyword, __location__, name=
"DIIS_BUFFER_LENGTH", &
517 description=
"Maximum number of DIIS vectors used ", &
518 usage=
"DIIS_BUFFER_LENGTH 5", default_i_val=3)
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 usage=
"EXTRAPOLATION_ORDER 5", default_i_val=3)
529 description=
"Maximum number of outer SCF loops.", &
530 usage=
"MAX_SCF 20", default_i_val=50)
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 "// &
540 usage=
"STEP_SIZE -1.0", default_r_val=0.5_dp)
544 END SUBROUTINE create_outer_scf_section
552 SUBROUTINE create_ot_section(section)
557 cpassert(.NOT.
ASSOCIATED(section))
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., &
575 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
576 description=
"controls the activation of the ot method", &
578 default_l_val=.false., &
579 lone_keyword_l_val=.true.)
584 description=
"Algorithm to be used for OT", &
585 usage=
"ALGORITHM STRICT", &
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)."), &
597 description=
"The refinement polynomial degree (2, 3 or 4).", &
598 usage=
"IRAC_DEGREE 4", &
604 description=
"Maximum allowed refinement iteration.", &
605 usage=
"MAX_IRAC 5", &
611 description=
"The orthogonality method.", &
612 usage=
"ORTHO_IRAC POLY", &
614 enum_c_vals=
s2a(
"CHOL",
"POLY",
"LWDN"), &
615 enum_desc=
s2a(
"Cholesky.",
"Polynomial.",
"Loewdin."), &
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 default_r_val=0.0_dp)
628 description=
"Targeted accuracy during the refinement iteration.", &
629 usage=
"EPS_IRAC 1.0E-5", &
630 default_r_val=1.0e-10_dp)
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 default_r_val=1.0e-5_dp)
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 default_r_val=1.0e-2_dp)
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 default_l_val=.false.)
659 keyword, __location__, name=
"MINIMIZER", &
660 description=
"Minimizer to be used with the OT method", &
661 usage=
"MINIMIZER DIIS", &
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"), &
673 variants=[
"SAFER_DIIS"], &
674 description=
"Reject DIIS steps if they point away from the"// &
675 " minimum, do SD in that case.", &
676 usage=
"SAFE_DIIS ON", default_l_val=.true.)
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", &
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", &
697 description=
"Underrelaxation for the broyden mixer", &
698 usage=
"BROYDEN_BETA 0.9", &
699 default_r_val=0.9_dp)
703 CALL keyword_create(keyword, __location__, name=
"BROYDEN_GAMMA", &
704 description=
"Backtracking parameter", &
705 usage=
"BROYDEN_GAMMA 0.5", &
706 default_r_val=0.5_dp)
710 CALL keyword_create(keyword, __location__, name=
"BROYDEN_SIGMA", &
711 description=
"Curvature of energy functional.", &
712 usage=
"BROYDEN_SIGMA 0.25", &
713 default_r_val=0.25_dp)
718 description=
"Dampening of estimated energy curvature.", &
719 usage=
"BROYDEN_ETA 0.7", &
720 default_r_val=0.7_dp)
724 CALL keyword_create(keyword, __location__, name=
"BROYDEN_OMEGA", &
725 description=
"Growth limit of curvature.", &
726 usage=
"BROYDEN_OMEGA 1.1", &
727 default_r_val=1.1_dp)
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 default_r_val=0.7_dp)
738 CALL keyword_create(keyword, __location__, name=
"BROYDEN_SIGMA_MIN", &
739 description=
"Minimum adaptive curvature.", &
740 usage=
"BROYDEN_SIGMA_MIN 0.05", &
741 default_r_val=0.05_dp)
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 lone_keyword_l_val=.true.)
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 lone_keyword_l_val=.true.)
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 lone_keyword_l_val=.true.)
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", &
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)"), &
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 default_r_val=-1.0_dp)
798 description=
"Target relative uncertainty in the location of the minimum for LINESEARCH GOLD", &
799 usage=
"GOLD_TARGET 0.1", &
800 default_r_val=0.01_dp)
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", &
811 enum_c_vals=
s2a(
"FULL_ALL",
"FULL_SINGLE_INVERSE",
"FULL_SINGLE",
"FULL_KINETIC",
"FULL_S_INVERSE", &
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"), &
832 description=
"If FULL_ALL the cholesky decomposition of the S matrix is used. "// &
833 "Options on the algorithm to be used.", &
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"), &
845 keyword, __location__, name=
"PRECOND_SOLVER", &
846 description=
"How the preconditioner is applied to the residual.", &
847 usage=
"PRECOND_SOLVER DIRECT", &
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)"), &
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 default_r_val=-1.0_dp)
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 default_r_val=1.0e-16_dp)
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", &
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 default_l_val=.false.)
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 default_l_val=.false.)
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 default_l_val=.false.)
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 default_l_val=.false.)
926 CALL keyword_create(keyword, __location__, name=
"NONDIAG_ENERGY_STRENGTH", &
927 description=
"The prefactor for the non-diagonal energy penalty (FD smearing)", &
928 usage=
"NONDIAG_ENERGY_STRENGTH", default_r_val=1.0_dp)
932 END SUBROUTINE create_ot_section
940 SUBROUTINE create_diagonalization_section(section)
946 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 n_keywords=0, n_subsections=1, repeats=.false.)
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 lone_keyword_l_val=.true.)
962 description=
"Algorithm to be used for diagonalization", &
963 usage=
"ALGORITHM 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"), &
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, &
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, &
999 description=
"Required accuracy in iterative diagonalization as compared to current SCF convergence", &
1000 usage=
"EPS_ADAPT 0.01", &
1001 default_r_val=0._dp)
1006 description=
"Maximum number of iterations in iterative diagonalization", &
1007 usage=
"MAX_ITER 20", &
1013 description=
"Required accuracy in iterative diagonalization", &
1014 usage=
"EPS_ITER 1.e-8", &
1015 default_r_val=1.e-8_dp)
1019 NULLIFY (subsection)
1020 CALL create_ot_section(subsection)
1024 NULLIFY (subsection)
1025 CALL create_krylov_section(subsection)
1029 NULLIFY (subsection)
1030 CALL create_diag_subspace_section(subsection)
1034 NULLIFY (subsection)
1035 CALL create_davidson_section(subsection)
1039 NULLIFY (subsection)
1044 END SUBROUTINE create_diagonalization_section
1050 SUBROUTINE create_davidson_section(section)
1055 cpassert(.NOT.
ASSOCIATED(section))
1058 n_keywords=2, n_subsections=0, repeats=.false.)
1063 keyword, __location__, name=
"PRECONDITIONER", &
1064 description=
"Type of preconditioner to be used with all minimization schemes. ", &
1065 usage=
"PRECONDITIONER 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"), &
1077 CALL keyword_create(keyword, __location__, name=
"PRECOND_SOLVER", &
1078 description=
"How the preconditioner is applied to the residual.", &
1079 usage=
"PRECOND_SOLVER DIRECT", &
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)"), &
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 default_r_val=0.2_dp)
1103 CALL keyword_create(keyword, __location__, name=
"NEW_PREC_EACH", &
1104 description=
"Number of SCF iterations after which a new Preconditioner is computed", &
1105 usage=
"NEW_PREC_EACH 10", default_i_val=20)
1110 description=
"First SCF iteration at which a Preconditioner is employed", &
1111 usage=
"FIRST_PREC 1", default_i_val=1)
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 usage=
"CONV_MOS_PERCENT 0.8", default_r_val=0.5_dp)
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 lone_keyword_l_val=.true.)
1129 END SUBROUTINE create_davidson_section
1135 SUBROUTINE create_krylov_section(section)
1140 cpassert(.NOT.
ASSOCIATED(section))
1143 n_keywords=2, n_subsections=0, repeats=.false.)
1148 description=
"Dimension of the Krylov space used for the Lanczos refinement", &
1149 usage=
"NKRYLOV 20", &
1155 description=
"Size of the block of vectors refined simultaneously by the Lanczos procedure", &
1162 description=
"Convergence criterion for the MOs", &
1163 usage=
"EPS_KRYLOV 0.00001", &
1164 default_r_val=0.0000001_dp)
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 default_r_val=-1.0_dp)
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 lone_keyword_l_val=.true.)
1186 END SUBROUTINE create_krylov_section
1192 SUBROUTINE create_diag_subspace_section(section)
1198 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 n_keywords=2, n_subsections=1, repeats=.false.)
1204 NULLIFY (keyword, subsection)
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 lone_keyword_l_val=.true.)
1215 description=
"Maximum number of iterations for the SCF inner loop", &
1216 usage=
"MAX_ITER 20", &
1222 description=
"Required energy accuracy for convergence of subspace diagonalization", &
1223 usage=
"EPS_ENE 1.e-8", &
1224 default_r_val=1.e-4_dp)
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 default_r_val=1._dp)
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 default_r_val=-1.0_dp)
1248 END SUBROUTINE create_diag_subspace_section
1257 SUBROUTINE create_smear_section(section)
1263 cpassert(.NOT.
ASSOCIATED(section))
1267 description=
"Controls smearing of MO occupation numbers for systems with small or zero gaps.", &
1275 name=
"_SECTION_PARAMETERS_", &
1276 description=
"Controls the activation of smearing", &
1277 usage=
"&SMEAR ON", &
1278 default_l_val=.false., &
1279 lone_keyword_l_val=.true.)
1285 description=
"Selects the smearing method to apply.", &
1286 usage=
"METHOD Fermi_Dirac", &
1288 enum_c_vals=
s2a(
"FERMI_DIRAC",
"ENERGY_WINDOW",
"LIST",
"GAUSSIAN", &
1289 "METHFESSEL_PAXTON",
"MARZARI_VANDERBILT"), &
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 "Marzari-Vanderbilt cold smearing with width SIGMA."))
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", &
1320 usage=
"LIST 2.0 0.6666 0.6666 0.66666 0.0 0.0")
1325 name=
"ELECTRONIC_TEMPERATURE", &
1326 variants=
s2a(
"ELEC_TEMP",
"TELEC"), &
1327 description=
"Electronic temperature used for Fermi-Dirac smearing.", &
1333 usage=
"ELECTRONIC_TEMPERATURE [K] 300")
1338 name=
"EPS_FERMI_DIRAC", &
1339 description=
"Accuracy checks on occupation numbers use this as a tolerance", &
1343 default_r_val=1.0e-10_dp, &
1344 usage=
"EPS_FERMI_DIRAC 1.0E-6")
1350 description=
"Smearing width sigma (in energy units) in the case of "// &
1351 "Gaussian, Methfessel-Paxton or Marzari-Vanderbilt smearing.", &
1355 default_r_val=0.002_dp, &
1357 usage=
"SIGMA [eV] 0.2")
1362 name=
"WINDOW_SIZE", &
1363 description=
"Size of the energy window centred at the Fermi level", &
1367 default_r_val=0.0_dp, &
1369 usage=
"WINDOW_SIZE [eV] 0.3")
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.", &
1381 default_r_val=-100.0_dp, &
1382 usage=
"FIXED_MAGNETIC_MOMENT 1.5")
1386 END SUBROUTINE create_smear_section
1396 TYPE(
section_type),
POINTER :: group_section, print_key, subsection
1398 NULLIFY (keyword, subsection, group_section, print_key)
1400 cpassert(.NOT.
ASSOCIATED(section))
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, &
1409 NULLIFY (subsection, keyword)
1410 CALL create_outer_scf_section(subsection)
1414 CALL create_becke_constraint_section(subsection)
1418 CALL create_hirshfeld_constraint_section(subsection)
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"), &
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."), &
1438 description=
"Constraint force constants (Lagrange multipliers). "// &
1439 "Give one value per constraint group.", &
1440 type_of_var=
real_t, n_var=-1, &
1441 default_r_val=0.0_dp)
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 default_r_val=0.0_dp)
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 default_l_val=.false., lone_keyword_l_val=.true.)
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 default_lc_val=
"fragment_a.cube")
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 default_lc_val=
"fragment_b.cube")
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 default_lc_val=
"fragment_a_spin.cube")
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 default_lc_val=
"fragment_b_spin.cube")
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 default_l_val=.false., lone_keyword_l_val=.true.)
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 default_l_val=.false., lone_keyword_l_val=.true.)
1530 description=
"Controls the printing of basic info about the method.", &
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 n_keywords=1, n_subsections=0, repeats=.false.)
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 usage=
"STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=
integer_t)
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 n_keywords=4, n_subsections=0, repeats=.true.)
1559 description=
"Specifies the list of atoms that are included in the constraint group.", &
1560 usage=
"ATOMS {integer} {integer} .. {integer}", &
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 type_of_var=
real_t, n_var=-1)
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"), &
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."), &
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 default_l_val=.false., lone_keyword_l_val=.true.)
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 n_keywords=1, n_subsections=0, repeats=.true.)
1610 description=
"Specifies the list of atoms that are included in the DUMMY_ATOMS group.", &
1611 usage=
"ATOMS {integer} {integer} .. {integer}", &
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 default_l_val=.false., lone_keyword_l_val=.true.)
1628 CALL keyword_create(keyword, __location__, name=
"PRECOND_FREQ", &
1629 description=
"See REUSE_PRECOND.", &
1630 usage=
"PRECOND_FREQ {int}", default_i_val=0)
1635 description=
"Determines how many times a previously built preconditioner can be reused.", &
1636 usage=
"MAX_REUSE {int}", default_i_val=0)
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 default_l_val=.false., lone_keyword_l_val=.true.)
1652 description=
"See PURGE_HISTORY.", &
1653 usage=
"PURGE_FREQ {int} ", default_i_val=1)
1657 CALL keyword_create(keyword, __location__, name=
"PURGE_OFFSET", &
1658 description=
"See PURGE_HISTORY.", &
1659 usage=
"PURGE_OFFSET {int} ", default_i_val=1)
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 usage=
"COUNTER {int} ", default_i_val=0)
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 default_l_val=.false., lone_keyword_l_val=.true.)
1685 SUBROUTINE create_hirshfeld_constraint_section(section)
1692 cpassert(.NOT.
ASSOCIATED(section))
1693 CALL section_create(section, __location__, name=
"HIRSHFELD_CONSTRAINT", &
1694 description=
"Parameters for CDFT with a Gaussian Hirshfeld constraint.", &
1695 n_keywords=11, n_subsections=0, repeats=.false.)
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, &
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."), &
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"), &
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."), &
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", &
1728 type_of_var=
real_t, n_var=1)
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 type_of_var=
real_t, n_var=-1)
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 default_l_val=.false., lone_keyword_l_val=.true.)
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 default_l_val=.false., lone_keyword_l_val=.true.)
1757 CALL keyword_create(keyword, __location__, name=
"ATOMS_MEMORY", &
1758 description=
"Number of atomic gradients to store in memory.", &
1759 usage=
"ATOMS_MEMORY", &
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 default_l_val=.true., lone_keyword_l_val=.true.)
1773 description=
"Numerical cutoff for calculation of weight function.", &
1774 usage=
"EPS_CUTOFF {real} ", default_r_val=1.0e-12_dp)
1778 CALL keyword_create(keyword, __location__, name=
"ATOMIC_CUTOFF", &
1779 description=
"Numerical cutoff for calculation of Hirshfeld densities.", &
1780 usage=
"ATOMIC_CUTOFF {real} ", default_r_val=1.0e-12_dp)
1784 END SUBROUTINE create_hirshfeld_constraint_section
1790 SUBROUTINE create_becke_constraint_section(section)
1796 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 n_keywords=13, repeats=.false., citations=[
becke1988b])
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 default_l_val=.false., lone_keyword_l_val=.true.)
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 type_of_var=
real_t, n_var=-1)
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 default_l_val=.false., lone_keyword_l_val=.true.)
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 default_l_val=.false., lone_keyword_l_val=.true.)
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"), &
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."), &
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 default_l_val=.false., lone_keyword_l_val=.true.)
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 default_l_val=.false., lone_keyword_l_val=.true.)
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", &
1872 type_of_var=
real_t, n_var=1)
1877 description=
"Density threshold for cavity creation. Grid points where the Gaussian"// &
1878 " density falls below the threshold are ignored.", &
1879 usage=
"EPS_CAVITY {real} ", default_r_val=1.0e-6_dp)
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"), &
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."), &
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", &
1900 type_of_var=
real_t, n_var=1)
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 type_of_var=
real_t, n_var=-1)
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 default_l_val=.false., lone_keyword_l_val=.true.)
1924 END SUBROUTINE create_becke_constraint_section
1933 SUBROUTINE create_cdft_opt_section(section)
1938 cpassert(.NOT.
ASSOCIATED(section))
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 "// &
1944 n_keywords=10, n_subsections=0, repeats=.false.)
1948 CALL keyword_create(keyword, __location__, name=
"BROYDEN_TYPE", &
1949 description=
"Specifies the Broyden optimizer variant to use.", &
1950 usage=
"BROYDEN_TYPE BT1", &
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."), &
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", &
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)."), &
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 usage=
"JACOBIAN_STEP 5.0E-3 ", n_var=-1, default_r_val=5.0e-3_dp)
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 default_i_vals=[1, 1], type_of_var=
integer_t)
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 default_l_val=.false., lone_keyword_l_val=.true.)
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 usage=
"JACOBIAN_VECTOR 1.0 0.0", n_var=-1, type_of_var=
real_t)
2022 description=
"The maximum number of backtracking line search steps to perform.", &
2023 usage=
"MAX_LS 5", default_i_val=5)
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 usage=
"FACTOR_LS 0.5", default_r_val=0.5_dp)
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 default_l_val=.false., lone_keyword_l_val=.true.)
2043 END SUBROUTINE create_cdft_opt_section
2052 SUBROUTINE create_gce_section(section)
2058 cpassert(.NOT.
ASSOCIATED(section))
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).", &
2089 name=
"_SECTION_PARAMETERS_", &
2090 description=
"Controls the activation of grand canonical SCF", &
2092 default_l_val=.false., &
2093 lone_keyword_l_val=.true.)
2098 name=
"TARGET_WORKFUNCTION", &
2099 description=
"The user input target work function of the symmetric slab model", &
2103 default_r_val=0.16_dp, &
2105 usage=
"TARGET_WORKFUNCTION [eV] 0.16")
2110 name=
"MIXING_COEF", &
2111 description=
"The proportion of the target work function mixed with the "// &
2112 "work function of the previous SCF iteration", &
2116 default_r_val=0.3_dp, &
2117 usage=
"MIXING_COEF 0.3")
2121 END SUBROUTINE create_gce_section
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public vandevondele2003
integer, save, public holmberg2017
integer, save, public vandevondele2005a
integer, save, public schiffmann2015
integer, save, public weber2008
integer, save, public holmberg2018
integer, save, public becke1988b
integer, save, public stewart1982
integer, save, public chai2024a
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public low_print_level
integer, parameter, public high_print_level
integer, parameter, public add_last_numeric
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
module that contains the definitions of the scf types
subroutine, public create_mixing_section(section, ls_scf)
Create CP2K input section for the mixing of the density matrix to be used only with diagonalization m...
manage control variables for the maximum overlap method
subroutine, public create_mom_section(section)
Create CP2K input section for variable occupancy using the Maximum Overlap Method....
Utilities for string manipulations.
character(len=1), parameter, public newline