69#include "./base/base_uses.f90"
74 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'input_cp2k_scf'
93 cpassert(.NOT.
ASSOCIATED(section))
95 description=
"Parameters needed to perform an SCF run.", &
96 n_keywords=18, n_subsections=7, repeats=.false.)
100 CALL create_ot_section(subsection)
104 CALL create_diagonalization_section(subsection)
108 CALL create_outer_scf_section(subsection)
112 CALL create_smear_section(subsection)
124 CALL create_gce_section(subsection)
130 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LUMO", &
131 variants=[
"MAX_ITER_LUMOS"], &
132 description=
"Maximum number of iterations for the calculation of the LUMO energies "// &
133 "with the OT eigensolver.", &
134 usage=
"MAX_ITER_LUMO 100", default_i_val=299)
139 variants=[
"EPS_LUMOS"], &
140 description=
"Target accuracy for the calculation of the LUMO energies with the OT eigensolver.", &
141 usage=
"EPS_LUMO 1.0E-6", default_r_val=1.0e-5_dp)
146 description=
"Maximum number of inner SCF iterations for one electronic optimization.", &
147 usage=
"MAX_SCF 200", default_i_val=50)
151 CALL keyword_create(keyword, __location__, name=
"MAX_SCF_HISTORY", variants=[
"MAX_SCF_HIST"], &
152 description=
"Maximum number of SCF iterations after the history pipeline is filled", &
153 usage=
"MAX_SCF_HISTORY 1", default_i_val=0, lone_keyword_i_val=1)
158 variants=[
"MAX_DIIS_BUFFER_SIZE"], &
159 description=
"Maximum number of DIIS vectors to be used", &
160 usage=
"MAX_DIIS 3", default_i_val=4)
165 variants=[
"LSHIFT"], &
166 description=
"Use level shifting to improve convergence", &
168 usage=
"LEVEL_SHIFT 0.1", &
169 default_r_val=0.0_dp)
174 description=
"Target convergence threshold for the inner SCF cycle.", &
175 usage=
"EPS_SCF 1.e-6", default_r_val=1.e-5_dp)
179 CALL keyword_create(keyword, __location__, name=
"EPS_SCF_HISTORY", variants=[
"EPS_SCF_HIST"], &
180 description=
"Target accuracy for the SCF convergence after the history pipeline is filled.", &
181 usage=
"EPS_SCF_HISTORY 1.e-5", default_r_val=0.0_dp, lone_keyword_r_val=1.0e-5_dp)
186 description=
"If the cholesky method should be used for computing "// &
187 "the inverse of S, and in this case calling which Lapack routines", &
189 enum_c_vals=
s2a(
"OFF",
"REDUCE",
"RESTORE",
"INVERSE",
"INVERSE_DBCSR"), &
190 enum_desc=
s2a(
"The cholesky algorithm is not used",
"Reduce is called", &
191 "Reduce is replaced by two restore", &
192 "Restore uses operator multiply by inverse of the triangular matrix", &
193 "Like inverse, but matrix stored as dbcsr, sparce matrix algebra used when possible"), &
199 description=
"Throw away linear combinations of basis functions with a small eigenvalue in S", &
200 usage=
"EPS_EIGVAL 1.0", default_r_val=1.0e-5_dp)
205 description=
"Threshold on the convergence to start using DIAG/DIIS or OT/DIIS."// &
206 " Default for OT/DIIS is never to switch.", &
207 usage=
"EPS_DIIS 5.0e-2", default_r_val=0.1_dp)
212 keyword, __location__, name=
"SCF_GUESS", &
213 description=
"Selects how the initial wavefunction or density matrix is generated.", &
214 usage=
"SCF_GUESS RESTART", default_i_val=
atomic_guess, &
215 enum_c_vals=
s2a(
"ATOMIC",
"RESTART",
"RANDOM",
"CORE", &
216 "HISTORY_RESTART",
"MOPAC",
"EHT",
"SPARSE",
"NONE"), &
217 enum_desc=
s2a(
"Generate an atomic density using the atomic code and internal default values", &
218 "Use the RESTART file as an initial guess (and ATOMIC if not present).", &
219 "Use random wavefunction coefficients.", &
220 "Diagonalize the core hamiltonian for an initial guess.", &
221 "Extrapolated from previous RESTART files.", &
222 "Use same guess as MOPAC for semi-empirical methods or a simple diagonal density matrix for other methods", &
223 "Use the EHT (gfn0-xTB) code to generate an initial wavefunction.", &
224 "Generate a sparse wavefunction using the atomic code (for OT based methods)", &
225 "Skip initial guess (only for non-self consistent methods)."), &
232 description=
"sets the number of rows in a scalapack block", &
233 usage=
"NROW_BLOCK 31", default_i_val=32)
238 description=
"Sets the number of columns in a scalapack block", &
239 usage=
"NCOL_BLOCK 31", default_i_val=32)
244 description=
"Number of additional molecular orbitals added for each spin channel. "// &
245 "This is commonly needed for smearing, excited-state, or post-Hartree-Fock calculations. "// &
246 "Use -1 to add all available orbitals.", &
247 usage=
"ADDED_MOS", default_i_val=0, n_var=-1)
252 name=
"ROKS_SCHEME", &
253 description=
"Selects the ROKS scheme when ROKS is applied.", &
254 usage=
"ROKS_SCHEME HIGH-SPIN", &
257 enum_c_vals=
s2a(
"GENERAL",
"HIGH-SPIN"), &
265 variants=[
"F_ROKS"], &
266 description=
"Allows to define the parameter f for the "// &
267 "general ROKS scheme.", &
268 usage=
"ROKS_F 1/2", &
272 default_r_val=0.5_dp)
277 name=
"ROKS_PARAMETERS", &
278 variants=[
"ROKS_PARAMETER"], &
279 description=
"Allows to define all parameters for the high-spin "// &
280 "ROKS scheme explicitly. "// &
281 "The full set of 6 parameters has to be specified "// &
282 "in the order acc, bcc, aoo, boo, avv, bvv", &
283 usage=
"ROKS_PARAMETERS 1/2 1/2 1/2 1/2 1/2 1/2", &
287 default_r_vals=[-0.5_dp, 1.5_dp, 0.5_dp, 0.5_dp, 1.5_dp, -0.5_dp])
291 CALL keyword_create(keyword, __location__, name=
"IGNORE_CONVERGENCE_FAILURE", &
292 description=
"If true, only a warning is issued if an SCF "// &
293 "iteration has not converged. By default, a run is aborted "// &
294 "if the required convergence criteria have not been achieved.", &
295 usage=
"IGNORE_CONVERGENCE_FAILURE logical_value", &
296 default_l_val=.false., &
297 lone_keyword_l_val=.true.)
301 CALL keyword_create(keyword, __location__, name=
"FORCE_SCF_CALCULATION", &
302 description=
"Request a SCF type solution even for nonSCF methods. ", &
303 usage=
"FORCE_SCF_CALCULATION logical_value", &
304 default_l_val=.false., &
305 lone_keyword_l_val=.true.)
310 description=
"Printing of information during the SCF.", repeats=.false.)
313 description=
"Controls the dumping of the MO restart file during SCF. "// &
314 "By default keeps a short history of three restarts. "// &
315 "See also RESTART_HISTORY", &
317 each_iter_names=
s2a(
"QS_SCF"), each_iter_values=[20], &
319 CALL keyword_create(keyword, __location__, name=
"BACKUP_COPIES", &
320 description=
"Specifies the maximum number of backup copies.", &
321 usage=
"BACKUP_COPIES {int}", &
329 print_key, __location__,
"RESTART_HISTORY", &
330 description=
"Dumps unique MO restart files during the run keeping all of them.", &
332 each_iter_names=
s2a(
"__ROOT__",
"MD",
"GEO_OPT",
"ROT_OPT",
"NEB",
"METADYNAMICS",
"QS_SCF"), &
333 each_iter_values=[500, 500, 500, 500, 500, 500, 500], &
335 CALL keyword_create(keyword, __location__, name=
"BACKUP_COPIES", &
336 description=
"Specifies the maximum number of backup copies.", &
337 usage=
"BACKUP_COPIES {int}", &
345 description=
"Controls the printing of basic iteration information during the SCF.", &
348 description=
"If the printkey is activated switches the printing of timings"// &
349 " to cumulative (over the SCF).", &
350 default_l_val=.false., lone_keyword_l_val=.true.)
357 description=
"Controls the printing of basic information during the SCF.", &
363 description=
"Controls the printing relative to the orthonormality of MOs (CT S C).", &
369 description=
"Prints the min/max eigenvalues of the overlap of the MOs without S (CT C).", &
375 description=
"Controls the printing of detailed energy information.", &
381 description=
"Controls the printing of DIIS information.", &
387 description=
"Controls the printing of total densities.", &
393 description=
"Controls the printing of information on Lanczos refinement iterations.", &
399 print_key, __location__,
"DIAG_SUB_SCF", &
400 description=
"Controls the printing of information on subspace diagonalization internal loop. ", &
406 description=
"Controls the printing of information on Davidson iterations.", &
412 description=
"Controls the printing of information on Filter Matrix method.", &
417 CALL keyword_create(keyword, __location__, name=
"DM_RESTART_WRITE", &
418 description=
"Write the density matrix into a binary file at the end of the SCF.", &
419 usage=
"DM_RESTART_WRITE", default_l_val=.false., lone_keyword_l_val=.true.)
434 SUBROUTINE create_outer_scf_section(section)
440 cpassert(.NOT.
ASSOCIATED(section))
442 description=
"Controls an outer SCF loop, often used to stabilize difficult OT convergence, "// &
443 "constraints, or other variables wrapped around the inner SCF cycle.", &
444 n_keywords=13, n_subsections=1, repeats=.false.)
448 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
449 description=
"Activates the outer SCF loop.", &
450 usage=
"&OUTER_SCF ON", default_l_val=.false., lone_keyword_l_val=.true.)
456 CALL create_cdft_opt_section(subsection)
461 description=
"Specifies which kind of outer SCF should be employed", &
462 usage=
"TYPE DDAPC_CONSTRAINT ", &
464 enum_c_vals=
s2a(
"DDAPC_CONSTRAINT",
"S2_CONSTRAINT", &
465 "BASIS_CENTER_OPT",
"CDFT_CONSTRAINT",
"NONE"), &
466 enum_desc=
s2a(
"Enforce a constraint on the DDAPC, requires the corresponding section", &
467 "Enforce a constraint on the S2, requires the corresponding section", &
468 "Optimize positions of basis functions, if atom types FLOATING_BASIS_CENTER "// &
470 "Enforce a constraint on a generic CDFT weight population. "// &
471 "Requires the corresponding section QS&CDFT"// &
472 " which determines the type of weight used.", &
473 "Do nothing in the outer loop, useful for resetting the inner loop,"), &
480 description=
"Method used to bring the outer loop to a stationary point", &
481 usage=
"OPTIMIZER SD", &
483 enum_c_vals=
s2a(
"SD",
"DIIS",
"NONE",
"BISECT",
"BROYDEN",
"NEWTON",
"SECANT",
"NEWTON_LS"), &
484 enum_desc=
s2a(
"Takes steps in the direction of the gradient, multiplied by step_size", &
485 "Uses a Direct Inversion in the Iterative Subspace method", &
486 "Do nothing, useful only with the none type", &
487 "Bisection of the gradient, useful for difficult one dimensional cases", &
488 "Broyden's method. Variant defined in BROYDEN_TYPE.", &
489 "Newton's method. Only compatible with CDFT constraints.", &
490 "Secant method. Only for one dimensional cases. See Broyden for "// &
491 "multidimensional cases.", &
492 "Newton's method with backtracking line search to find the optimal step size. "// &
493 "Only compatible with CDFT constraints. Starts from the regular Newton solution "// &
494 "and successively reduces the step size until the L2 norm of the CDFT gradient "// &
495 "decreases or MAX_LS steps is reached. Potentially very expensive because "// &
496 "each iteration performs a full SCF calculation."), &
504 CALL keyword_create(keyword, __location__, name=
"BISECT_TRUST_COUNT", &
505 description=
"Maximum number of times the same point will be used in bisection,"// &
506 " a small number guards against the effect of wrongly converged states.", &
507 usage=
"BISECT_TRUST_COUNT 5", default_i_val=10)
512 description=
"The target gradient of the outer SCF variables. "// &
513 "Notice that the EPS_SCF of the inner loop also determines "// &
514 "the value that can be reached in the outer loop, "// &
515 "typically EPS_SCF of the outer loop must be smaller "// &
516 "than or equal to EPS_SCF of the inner loop.", &
517 usage=
"EPS_SCF 1.0E-6 ", default_r_val=1.0e-5_dp)
521 CALL keyword_create(keyword, __location__, name=
"DIIS_BUFFER_LENGTH", &
522 description=
"Maximum number of DIIS vectors used ", &
523 usage=
"DIIS_BUFFER_LENGTH 5", default_i_val=3)
527 CALL keyword_create(keyword, __location__, name=
"EXTRAPOLATION_ORDER", &
528 description=
"Number of past states used in the extrapolation of the variables during e.g. MD", &
529 usage=
"EXTRAPOLATION_ORDER 5", default_i_val=3)
534 description=
"Maximum number of outer SCF loops.", &
535 usage=
"MAX_SCF 20", default_i_val=50)
540 description=
"The initial step_size used in the optimizer (currently steepest descent). "// &
541 "Note that in cases where a sadle point is sought for (constrained DFT),"// &
542 " this can be negative. For Newton and Broyden optimizers, use a value less/higher than "// &
543 "the default 1.0 (in absolute value, the sign is not significant) to active an under/overrelaxed "// &
545 usage=
"STEP_SIZE -1.0", default_r_val=0.5_dp)
549 END SUBROUTINE create_outer_scf_section
557 SUBROUTINE create_ot_section(section)
562 cpassert(.NOT.
ASSOCIATED(section))
564 description=
"Sets the various options for the orbital transformation (OT) method. "// &
565 "Default settings already provide an efficient, yet robust method. "// &
566 "Most systems benefit from using the FULL_ALL preconditioner "// &
567 "combined with a small value (0.001) of ENERGY_GAP. "// &
568 "Well-behaved systems might benefit from using a DIIS minimizer. "//
newline//
newline// &
569 "**Advantages:** "// &
570 "It's fast, because no expensive diagonalisation is performed. "// &
571 "If preconditioned correctly, method guaranteed to find minimum. "//
newline//
newline// &
572 "**Disadvantages:** "// &
573 "Sensitive to preconditioning. A good preconditioner can be expensive. "// &
574 "No smearing, or advanced SCF mixing possible: POOR convergence for metallic systems.", &
575 n_keywords=27, n_subsections=0, repeats=.false., &
580 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
581 description=
"controls the activation of the ot method", &
583 default_l_val=.false., &
584 lone_keyword_l_val=.true.)
589 description=
"Algorithm to be used for OT", &
590 usage=
"ALGORITHM STRICT", &
592 enum_c_vals=
s2a(
"STRICT",
"IRAC"), &
593 enum_desc=
s2a(
"Strict orthogonality: Taylor or diagonalization based algorithm.", &
594 "Orbital Transformation based Iterative Refinement "// &
595 "of the Approximative Congruence transformation (OT/IR)."), &
602 description=
"The refinement polynomial degree (2, 3 or 4).", &
603 usage=
"IRAC_DEGREE 4", &
609 description=
"Maximum allowed refinement iteration.", &
610 usage=
"MAX_IRAC 5", &
616 description=
"The orthogonality method.", &
617 usage=
"ORTHO_IRAC POLY", &
619 enum_c_vals=
s2a(
"CHOL",
"POLY",
"LWDN"), &
620 enum_desc=
s2a(
"Cholesky.",
"Polynomial.",
"Loewdin."), &
625 CALL keyword_create(keyword, __location__, name=
"EPS_IRAC_FILTER_MATRIX", &
626 description=
"Sets the threshold for filtering the matrices.", &
627 usage=
"EPS_IRAC_FILTER_MATRIX 1.0E-5", &
628 default_r_val=0.0_dp)
633 description=
"Targeted accuracy during the refinement iteration.", &
634 usage=
"EPS_IRAC 1.0E-5", &
635 default_r_val=1.0e-10_dp)
639 CALL keyword_create(keyword, __location__, name=
"EPS_IRAC_QUICK_EXIT", &
640 description=
"Only one extra refinement iteration is "// &
641 "done when the norm is below this value.", &
642 usage=
"EPS_IRAC_QUICK_EXIT 1.0E-2", &
643 default_r_val=1.0e-5_dp)
647 CALL keyword_create(keyword, __location__, name=
"EPS_IRAC_SWITCH", &
648 description=
"The algorithm switches to the polynomial "// &
649 "refinement when the norm is below this value.", &
650 usage=
"EPS_IRAC_SWITCH 1.0E-3", &
651 default_r_val=1.0e-2_dp)
655 CALL keyword_create(keyword, __location__, name=
"ON_THE_FLY_LOC", &
656 description=
"On the fly localization of the molecular orbitals. "// &
657 "Can only be used with OT/IRAC.", &
658 usage=
"ON_THE_FLY_LOC T", &
659 default_l_val=.false.)
664 keyword, __location__, name=
"MINIMIZER", &
665 description=
"Minimizer to be used with the OT method", &
666 usage=
"MINIMIZER DIIS", &
668 enum_c_vals=
s2a(
"SD",
"CG",
"DIIS",
"BROYDEN"), &
669 enum_desc=
s2a(
"Steepest descent: not recommended",
"Conjugate Gradients: most reliable, use for difficult systems."// &
670 " The total energy should decrease at every OT CG step if the line search is appropriate.", &
671 "Direct inversion in the iterative subspace: less reliable than CG, but sometimes about 50% faster", &
672 "Broyden mixing approximating the inverse Hessian"), &
678 variants=[
"SAFER_DIIS"], &
679 description=
"Reject DIIS steps if they point away from the"// &
680 " minimum, do SD in that case.", &
681 usage=
"SAFE_DIIS ON", default_l_val=.true.)
686 description=
"Maximum DIIS SCF inner loop cycles. This can be used to extend"// &
687 " SCF cycles after a switch to DIIS (see eps_diis).", &
688 usage=
"MAX_SCF_DIIS 20", &
693 CALL keyword_create(keyword, __location__, name=
"N_HISTORY_VEC", &
694 variants=
s2a(
"NDIIS",
"N_DIIS",
"N_BROYDEN"), &
695 description=
"Number of history vectors to be used with DIIS or BROYDEN", &
702 description=
"Underrelaxation for the broyden mixer", &
703 usage=
"BROYDEN_BETA 0.9", &
704 default_r_val=0.9_dp)
708 CALL keyword_create(keyword, __location__, name=
"BROYDEN_GAMMA", &
709 description=
"Backtracking parameter", &
710 usage=
"BROYDEN_GAMMA 0.5", &
711 default_r_val=0.5_dp)
715 CALL keyword_create(keyword, __location__, name=
"BROYDEN_SIGMA", &
716 description=
"Curvature of energy functional.", &
717 usage=
"BROYDEN_SIGMA 0.25", &
718 default_r_val=0.25_dp)
723 description=
"Dampening of estimated energy curvature.", &
724 usage=
"BROYDEN_ETA 0.7", &
725 default_r_val=0.7_dp)
729 CALL keyword_create(keyword, __location__, name=
"BROYDEN_OMEGA", &
730 description=
"Growth limit of curvature.", &
731 usage=
"BROYDEN_OMEGA 1.1", &
732 default_r_val=1.1_dp)
736 CALL keyword_create(keyword, __location__, name=
"BROYDEN_SIGMA_DECREASE", &
737 description=
"Reduction of curvature on bad approximation.", &
738 usage=
"BROYDEN_SIGMA_DECREASE 0.7", &
739 default_r_val=0.7_dp)
743 CALL keyword_create(keyword, __location__, name=
"BROYDEN_SIGMA_MIN", &
744 description=
"Minimum adaptive curvature.", &
745 usage=
"BROYDEN_SIGMA_MIN 0.05", &
746 default_r_val=0.05_dp)
750 CALL keyword_create(keyword, __location__, name=
"BROYDEN_FORGET_HISTORY", &
751 description=
"Forget history on bad approximation", &
752 usage=
"BROYDEN_FORGET_HISTORY OFF", default_l_val=.false., &
753 lone_keyword_l_val=.true.)
757 CALL keyword_create(keyword, __location__, name=
"BROYDEN_ADAPTIVE_SIGMA", &
758 description=
"Enable adaptive curvature estimation", &
759 usage=
"BROYDEN_ADAPTIVE_SIGMA ON", default_l_val=.true., &
760 lone_keyword_l_val=.true.)
764 CALL keyword_create(keyword, __location__, name=
"BROYDEN_ENABLE_FLIP", &
765 description=
"Ensure positive definite update", &
766 usage=
"BROYDEN_ENABLE_FLIP ON", default_l_val=.true., &
767 lone_keyword_l_val=.true.)
772 variants=[
"LINE_SEARCH"], &
773 description=
"1D line search algorithm to be used with the OT minimizer,"// &
774 " in increasing order of robustness and cost. MINIMIZER CG combined with"// &
775 " LINESEARCH GOLD should always find an electronic minimum."// &
776 " Whereas the 2PNT minimizer is almost always OK, 3PNT might be needed for systems"// &
777 " in which successive OT CG steps do not decrease the total energy.", &
778 usage=
"LINESEARCH GOLD", &
780 enum_c_vals=
s2a(
"ADAPT",
"NONE",
"2PNT",
"3PNT",
"GOLD"), &
781 enum_desc=
s2a(
"extrapolates usually based on 3 points, "// &
782 "uses additional points on demand, very robust.", &
783 "always take steps of fixed length", &
784 "extrapolate based on 2 points", &
785 "extrapolate based on 3 points", &
786 "perform 1D golden section search of the minimum (very expensive)"), &
792 keyword, __location__, name=
"STEPSIZE", &
793 description=
"Initial stepsize used for the line search, sometimes this parameter can be reduced to stabilize DIIS"// &
794 " or to improve the CG behavior in the first few steps."// &
795 " The optimal value depends on the quality of the preconditioner."// &
796 " A negative values leaves the choice to CP2K depending on the preconditioner.", &
797 usage=
"STEPSIZE 0.4", &
798 default_r_val=-1.0_dp)
803 description=
"Target relative uncertainty in the location of the minimum for LINESEARCH GOLD", &
804 usage=
"GOLD_TARGET 0.1", &
805 default_r_val=0.01_dp)
810 keyword, __location__, name=
"PRECONDITIONER", &
811 description=
"Type of preconditioner to be used with all minimization schemes. "// &
812 "They differ in effectiveness, cost of construction, cost of application. "// &
813 "Properly preconditioned minimization can be orders of magnitude faster than doing nothing.", &
814 usage=
"PRECONDITIONER FULL_ALL", &
816 enum_c_vals=
s2a(
"FULL_ALL",
"FULL_SINGLE_INVERSE",
"FULL_SINGLE",
"FULL_KINETIC",
"FULL_S_INVERSE", &
818 enum_desc=
s2a(
"Most effective state selective preconditioner based on diagonalization, "// &
819 "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
820 "This preconditioner is recommended for almost all systems, except very large systems where "// &
821 "make_preconditioner would dominate the total computational cost.", &
822 "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
823 "but cheaper to construct, "// &
824 "might be somewhat less robust. Recommended for large systems.", &
825 "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
826 "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
827 "use for very large systems.", &
828 "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
829 "skip preconditioning"), &
837 description=
"If FULL_ALL the cholesky decomposition of the S matrix is used. "// &
838 "Options on the algorithm to be used.", &
840 enum_c_vals=
s2a(
"OFF",
"REDUCE",
"RESTORE",
"INVERSE",
"INVERSE_DBCSR"), &
841 enum_desc=
s2a(
"The cholesky algorithm is not used",
"Reduce is called", &
842 "Reduce is replaced by two restore", &
843 "Restore uses operator multiply by inverse of the triangular matrix", &
844 "Like inverse, but matrix stored as dbcsr, sparce matrix algebra used when possible"), &
850 keyword, __location__, name=
"PRECOND_SOLVER", &
851 description=
"How the preconditioner is applied to the residual.", &
852 usage=
"PRECOND_SOLVER DIRECT", &
854 enum_c_vals=
s2a(
"DEFAULT",
"DIRECT",
"INVERSE_CHOLESKY",
"INVERSE_UPDATE"), &
855 enum_desc=
s2a(
"the default",
"Cholesky decomposition followed by triangular solve "// &
856 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
857 "Cholesky decomposition followed by explicit inversion "// &
858 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
859 "Performs a Hotelling update of the inverse if a previous preconditioner is present. "// &
860 "Mainly useful for GPU accelerated systems (works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)"), &
869 keyword, __location__, name=
"ENERGY_GAP", &
870 description=
"Should be an estimate for the energy gap [a.u.] (HOMO-LUMO) and is used in preconditioning, "// &
871 "especially effective with the FULL_ALL preconditioner, in which case it should be an underestimate "// &
872 "of the gap (can be a small number, e.g. 0.002)."// &
873 " FULL_SINGLE_INVERSE takes it as lower bound (values below 0.05 can cause stability issues)."// &
874 " In general, higher values will tame the preconditioner in case of poor initial guesses."// &
875 " A negative value will leave the choice to CP2K depending on type of preconditioner.", &
876 usage=
"ENERGY_GAP 0.001", &
877 default_r_val=-1.0_dp)
882 keyword, __location__, name=
"EPS_TAYLOR", &
883 variants=[
"EPSTAYLOR"], &
884 description=
"Target accuracy of the taylor expansion for the matrix functions, should normally be kept as is.", &
885 usage=
"EPS_TAYLOR 1.0E-15", &
886 default_r_val=1.0e-16_dp)
891 keyword, __location__, name=
"MAX_TAYLOR", &
892 description=
"Maximum order of the Taylor expansion before diagonalisation is preferred, for large parallel runs"// &
893 " a slightly higher order could sometimes result in a small speedup.", &
894 usage=
"MAX_TAYLOR 5", &
900 description=
"Introduce additional variables so that rotations of the occupied"// &
901 " subspace are allowed as well, only needed for cases where the energy is not invariant under"// &
902 " a rotation of the occupied subspace such as non-singlet restricted calculations"// &
903 " or fractional occupations.", &
904 usage=
"ROTATION", lone_keyword_l_val=.true., &
905 default_l_val=.false.)
910 description=
"Optimize orbital energies for use in Fermi-Dirac smearing "// &
911 "(requires ROTATION and FD smearing to be active).", &
912 usage=
"ENERGIES", lone_keyword_l_val=.true., &
913 default_l_val=.false.)
917 CALL keyword_create(keyword, __location__, name=
"OCCUPATION_PRECONDITIONER", &
918 description=
"Preconditioner with the occupation numbers (FD smearing)", &
919 usage=
"OCCUPATION_PRECONDITIONER", lone_keyword_l_val=.true., &
920 default_l_val=.false.)
924 CALL keyword_create(keyword, __location__, name=
"NONDIAG_ENERGY", &
925 description=
"Add a non-diagonal energy penalty (FD smearing)", &
926 usage=
"NONDIAG_ENERGY", lone_keyword_l_val=.true., &
927 default_l_val=.false.)
931 CALL keyword_create(keyword, __location__, name=
"NONDIAG_ENERGY_STRENGTH", &
932 description=
"The prefactor for the non-diagonal energy penalty (FD smearing)", &
933 usage=
"NONDIAG_ENERGY_STRENGTH", default_r_val=1.0_dp)
937 END SUBROUTINE create_ot_section
945 SUBROUTINE create_diagonalization_section(section)
951 cpassert(.NOT.
ASSOCIATED(section))
952 CALL section_create(section, __location__, name=
"DIAGONALIZATION", &
953 description=
"Set up type and parameters for Kohn-Sham matrix diagonalization.", &
954 n_keywords=0, n_subsections=1, repeats=.false.)
958 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
959 description=
"controls the activation of the diagonalization method", &
960 usage=
"&DIAGONALIZATION T", &
961 default_l_val=.false., &
962 lone_keyword_l_val=.true.)
967 description=
"Algorithm to be used for diagonalization", &
968 usage=
"ALGORITHM STANDARD", &
970 enum_c_vals=
s2a(
"STANDARD",
"OT",
"LANCZOS",
"DAVIDSON",
"FILTER_MATRIX"), &
971 enum_desc=
s2a(
"Standard diagonalization: LAPACK methods or Jacobi.", &
972 "Iterative diagonalization using OT method", &
973 "Block Krylov-space approach to self-consistent diagonalisation", &
974 "Preconditioned blocked Davidson", &
975 "Filter matrix diagonalization"), &
981 CALL keyword_create(keyword, __location__, name=
"JACOBI_THRESHOLD", &
982 description=
"Controls the accuracy of the pseudo-diagonalization method using Jacobi rotations", &
983 usage=
"JACOBI_THRESHOLD 1.0E-6", &
984 default_r_val=1.0e-7_dp, &
990 description=
"Below this threshold value for the SCF convergence the pseudo-diagonalization "// &
991 "method using Jacobi rotations is activated. This method is much faster than a "// &
992 "real diagonalization and it is even speeding up while achieving full convergence. "// &
993 "However, it needs a pre-converged wavefunction obtained by at least one real "// &
994 "diagonalization which is further optimized while keeping the original eigenvalue "// &
995 "spectrum. The MO eigenvalues are NOT updated. The method might be useful to speed "// &
996 "up calculations for large systems e.g. using a semi-empirical method.", &
997 usage=
"EPS_JACOBI 1.0E-5", &
998 default_r_val=0.0_dp, &
1004 description=
"Required accuracy in iterative diagonalization as compared to current SCF convergence", &
1005 usage=
"EPS_ADAPT 0.01", &
1006 default_r_val=0._dp)
1011 description=
"Maximum number of iterations in iterative diagonalization", &
1012 usage=
"MAX_ITER 20", &
1018 description=
"Required accuracy in iterative diagonalization", &
1019 usage=
"EPS_ITER 1.e-8", &
1020 default_r_val=1.e-8_dp)
1024 NULLIFY (subsection)
1025 CALL create_ot_section(subsection)
1029 NULLIFY (subsection)
1030 CALL create_krylov_section(subsection)
1034 NULLIFY (subsection)
1035 CALL create_diag_subspace_section(subsection)
1039 NULLIFY (subsection)
1040 CALL create_davidson_section(subsection)
1044 NULLIFY (subsection)
1049 END SUBROUTINE create_diagonalization_section
1055 SUBROUTINE create_davidson_section(section)
1060 cpassert(.NOT.
ASSOCIATED(section))
1063 n_keywords=2, n_subsections=0, repeats=.false.)
1068 keyword, __location__, name=
"PRECONDITIONER", &
1069 description=
"Type of preconditioner to be used with all minimization schemes. ", &
1070 usage=
"PRECONDITIONER FULL_ALL", &
1072 enum_c_vals=
s2a(
"FULL_ALL",
"FULL_SINGLE_INVERSE",
"NONE"), &
1073 enum_desc=
s2a(
"Most effective state selective preconditioner based on diagonalization ", &
1074 "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
1075 "but cheaper to construct, might be somewhat less robust. Recommended for large systems.", &
1076 "skip preconditioning"), &
1082 CALL keyword_create(keyword, __location__, name=
"PRECOND_SOLVER", &
1083 description=
"How the preconditioner is applied to the residual.", &
1084 usage=
"PRECOND_SOLVER DIRECT", &
1086 enum_c_vals=
s2a(
"DEFAULT",
"DIRECT",
"INVERSE_CHOLESKY"), &
1087 enum_desc=
s2a(
"the default",
"Cholesky decomposition followed by triangular solve "// &
1088 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
1089 "Cholesky decomposition followed by explicit inversion "// &
1090 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)"), &
1098 keyword, __location__, name=
"ENERGY_GAP", &
1099 description=
"Should be an estimate for the energy gap [a.u.] (HOMO-LUMO) and is used in preconditioning, "// &
1100 "especially effective with the FULL_ALL preconditioner, in which case it should be an underestimate "// &
1101 "of the gap (0.001 doing normally fine). For the other preconditioners, making this value larger (0.2)"// &
1102 " will tame the preconditioner in case of poor initial guesses.", &
1103 usage=
"ENERGY_GAP 0.001", &
1104 default_r_val=0.2_dp)
1108 CALL keyword_create(keyword, __location__, name=
"NEW_PREC_EACH", &
1109 description=
"Number of SCF iterations after which a new Preconditioner is computed", &
1110 usage=
"NEW_PREC_EACH 10", default_i_val=20)
1115 description=
"First SCF iteration at which a Preconditioner is employed", &
1116 usage=
"FIRST_PREC 1", default_i_val=1)
1120 CALL keyword_create(keyword, __location__, name=
"CONV_MOS_PERCENT", &
1121 description=
"Minimal percent of MOS that have to converge within the Davidson loop"// &
1122 " before the SCF iteration is completed and a new Hamiltonian is computed", &
1123 usage=
"CONV_MOS_PERCENT 0.8", default_r_val=0.5_dp)
1128 description=
"Use MOS as sparse matrix and avoid as much as possible multiplications with full matrices", &
1129 usage=
"SPARSE_MOS", default_l_val=.true., &
1130 lone_keyword_l_val=.true.)
1134 END SUBROUTINE create_davidson_section
1140 SUBROUTINE create_krylov_section(section)
1145 cpassert(.NOT.
ASSOCIATED(section))
1148 n_keywords=2, n_subsections=0, repeats=.false.)
1153 description=
"Dimension of the Krylov space used for the Lanczos refinement", &
1154 usage=
"NKRYLOV 20", &
1160 description=
"Size of the block of vectors refined simultaneously by the Lanczos procedure", &
1167 description=
"Convergence criterion for the MOs", &
1168 usage=
"EPS_KRYLOV 0.00001", &
1169 default_r_val=0.0000001_dp)
1173 CALL keyword_create(keyword, __location__, name=
"EPS_STD_DIAG", &
1174 description=
"Level of convergence to be reached before starting the Lanczos procedure."// &
1175 " Above this threshold a standard diagonalization method is used."// &
1176 " If negative Lanczos is started at the first iteration", &
1177 usage=
"EPS_STD_DIAG 0.001", &
1178 default_r_val=-1.0_dp)
1182 CALL keyword_create(keyword, __location__, name=
"CHECK_MOS_CONV", &
1183 description=
"This requires to check the convergence of MOS also when standard "// &
1184 "diagonalization steps are performed, if the block krylov approach is active.", &
1185 usage=
"CHECK_MOS_CONV T", &
1186 default_l_val=.false., &
1187 lone_keyword_l_val=.true.)
1191 END SUBROUTINE create_krylov_section
1197 SUBROUTINE create_diag_subspace_section(section)
1203 cpassert(.NOT.
ASSOCIATED(section))
1204 CALL section_create(section, __location__, name=
"DIAG_SUB_SCF", &
1205 description=
"Activation of self-consistenf subspace refinement by diagonalization "// &
1206 "of H by adjusting the occupation but keeping the MOS unchanged.", &
1207 n_keywords=2, n_subsections=1, repeats=.false.)
1209 NULLIFY (keyword, subsection)
1211 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
1212 description=
"controls the activation of inner SCF loop to refine occupations in MOS subspace", &
1213 usage=
"&DIAG_SUB_SCF T", &
1214 default_l_val=.false., &
1215 lone_keyword_l_val=.true.)
1220 description=
"Maximum number of iterations for the SCF inner loop", &
1221 usage=
"MAX_ITER 20", &
1227 description=
"Required energy accuracy for convergence of subspace diagonalization", &
1228 usage=
"EPS_ENE 1.e-8", &
1229 default_r_val=1.e-4_dp)
1233 CALL keyword_create(keyword, __location__, name=
"EPS_ADAPT_SCF", &
1234 description=
"Required density matrix accuracy as compared to current SCF convergence", &
1235 usage=
"EPS_ADAPT_SCF 1.e-1", &
1236 default_r_val=1._dp)
1241 keyword, __location__, name=
"EPS_SKIP_SUB_DIAG", &
1242 description=
"Level of convergence to be reached before starting the internal loop of subspace rotations."// &
1243 " Above this threshold only the outer diagonalization method is used."// &
1244 " If negative the subspace rotation is started at the first iteration", &
1245 usage=
"EPS_SKIP_SUB_DIAG 0.001", &
1246 default_r_val=-1.0_dp)
1253 END SUBROUTINE create_diag_subspace_section
1262 SUBROUTINE create_smear_section(section)
1268 cpassert(.NOT.
ASSOCIATED(section))
1272 description=
"Controls smearing of MO occupation numbers for systems with small or zero gaps.", &
1280 name=
"_SECTION_PARAMETERS_", &
1281 description=
"Controls the activation of smearing", &
1282 usage=
"&SMEAR ON", &
1283 default_l_val=.false., &
1284 lone_keyword_l_val=.true.)
1290 description=
"Selects the smearing method to apply.", &
1291 usage=
"METHOD Fermi_Dirac", &
1293 enum_c_vals=
s2a(
"FERMI_DIRAC",
"ENERGY_WINDOW",
"LIST",
"GAUSSIAN", &
1294 "METHFESSEL_PAXTON",
"MARZARI_VANDERBILT"), &
1297 enum_desc=
s2a(
"Fermi-Dirac distribution defined by the keyword ELECTRONIC_TEMPERATURE. "// &
1298 "Use this method if the temperature equivalence is important for you, "// &
1299 "e.g. if you want to compute some properties based on the occupations. "// &
1300 "If you use this method without interest in electronic temperature, "// &
1301 "it's suggested to use extrapolated result from finite ELECTRONIC_TEMPERATURE "// &
1302 "to ELECTRONIC_TEMPERATURE = 0. Note the forces and stress are consistent "// &
1303 "with the free energy and not with the extrapolated energy.", &
1304 "Energy window defined by the keyword WINDOW_SIZE.", &
1305 "Use a fixed list of occupations.", &
1306 "Gaussian broadening with width SIGMA; should work well in most cases. "// &
1307 "With this method you have to use extrapolated results from finite "// &
1308 "SIGMA results to SIGMA = 0, but usually this value would not be quite "// &
1309 "accurate without systematically reducing SIGMA. Note the forces and stress "// &
1310 "are consistent with the free energy and not with the extrapolated energy.", &
1311 "First-order Methfessel-Paxton distribution with width SIGMA. Don't "// &
1312 "use it for semiconductors and insulators because the partial "// &
1313 "occupancies can be unphysical and thus lead to wrong results.", &
1314 "Marzari-Vanderbilt cold smearing with width SIGMA."))
1320 description=
"A list of fractional occupations to use. Must match the number of states "// &
1321 "and sum up to the correct number of electrons", &
1325 usage=
"LIST 2.0 0.6666 0.6666 0.66666 0.0 0.0")
1330 name=
"ELECTRONIC_TEMPERATURE", &
1331 variants=
s2a(
"ELEC_TEMP",
"TELEC"), &
1332 description=
"Electronic temperature used for Fermi-Dirac smearing.", &
1338 usage=
"ELECTRONIC_TEMPERATURE [K] 300")
1343 name=
"EPS_FERMI_DIRAC", &
1344 description=
"Accuracy checks on occupation numbers use this as a tolerance", &
1348 default_r_val=1.0e-10_dp, &
1349 usage=
"EPS_FERMI_DIRAC 1.0E-6")
1355 description=
"Smearing width sigma (in energy units) in the case of "// &
1356 "Gaussian, Methfessel-Paxton or Marzari-Vanderbilt smearing.", &
1360 default_r_val=0.002_dp, &
1362 usage=
"SIGMA [eV] 0.2")
1367 name=
"WINDOW_SIZE", &
1368 description=
"Size of the energy window centred at the Fermi level", &
1372 default_r_val=0.0_dp, &
1374 usage=
"WINDOW_SIZE [eV] 0.3")
1378 CALL keyword_create(keyword, __location__, name=
"FIXED_MAGNETIC_MOMENT", &
1379 description=
"Imposed difference between the numbers of electrons of spin up "// &
1380 "and spin down: m = n(up) - n(down). A negative value (default) allows "// &
1381 "for a change of the magnetic moment. -1 specifically keeps an integer "// &
1382 "number of spin up and spin down electrons.", &
1386 default_r_val=-100.0_dp, &
1387 usage=
"FIXED_MAGNETIC_MOMENT 1.5")
1391 END SUBROUTINE create_smear_section
1401 TYPE(
section_type),
POINTER :: group_section, print_key, subsection
1403 NULLIFY (keyword, subsection, group_section, print_key)
1405 cpassert(.NOT.
ASSOCIATED(section))
1407 description=
"Parameters needed to set up a constrained DFT calculation."// &
1408 " Each repetition of the ATOM_GROUP section defines a new constraint."// &
1409 " The constraint(s) is (are) converged in a separate external SCF loop with settings"// &
1410 " read from the OUTER_SCF section. Supported constraints: Becke and Gaussian"// &
1411 " Hirshfeld (partial).", n_keywords=8, n_subsections=2, &
1414 NULLIFY (subsection, keyword)
1415 CALL create_outer_scf_section(subsection)
1419 CALL create_becke_constraint_section(subsection)
1423 CALL create_hirshfeld_constraint_section(subsection)
1427 CALL keyword_create(keyword, __location__, name=
"TYPE_OF_CONSTRAINT", &
1428 description=
"Specifies the type of constraint used.", &
1429 usage=
"TYPE_OF_CONSTRAINT (NONE|HIRSHFELD|BECKE)", &
1430 enum_c_vals=
s2a(
"NONE",
"HIRSHFELD",
"BECKE"), &
1433 enum_desc=
s2a(
"No constraint (disables section).", &
1434 "Gaussian Hirshfeld constraint. Partial implementation: no forces. "// &
1435 "Requires corresponding section. Not as extensively tested.", &
1436 "Becke constraint. Requires corresponding section."), &
1443 description=
"Constraint force constants (Lagrange multipliers). "// &
1444 "Give one value per constraint group.", &
1445 type_of_var=
real_t, n_var=-1, &
1446 default_r_val=0.0_dp)
1451 description=
"Constraint target values. Give one value per constraint group. "// &
1452 "The target value is the desired number of valence electrons, spin moment, or the number of "// &
1453 "alpha or beta electrons on the atoms that define the constraint, suitably multiplied by "// &
1454 "atomic coefficients in case a relative constraint between two sets of atoms is employed. "// &
1455 "Note that core charges are not subtracted from the target value.", &
1456 usage=
"TARGET {real}", repeats=.false., &
1457 type_of_var=
real_t, n_var=-1, &
1458 default_r_val=0.0_dp)
1462 CALL keyword_create(keyword, __location__, name=
"ATOMIC_CHARGES", &
1463 description=
"Calculate atomic CDFT charges with selected weight function"// &
1464 " (Z = Z_core - Z_CDFT). With fragment based constraints, charges are"// &
1465 " relative to the fragment reference state i.e. Z = Z_CDFT -"// &
1466 " Z_frag_reference. Note: if the number of atoms is greater than the"// &
1467 " default pw_pool max cache, calculation of atomic CDFT charges"// &
1468 " will prompt harmless warnings during deallocation of atomic grids.", &
1469 usage=
"ATOMIC_CHARGES", &
1470 default_l_val=.false., lone_keyword_l_val=.true.)
1474 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_A_FILE_NAME", variants=[
"FRAGMENT_A_FILE"], &
1475 description=
"Name of the reference total electron density cube file for fragment A."// &
1476 " May include a path. The reference electron density needs to be outputted"// &
1477 " on the same grid as the full system (same cutoff and cell, output stride 1).", &
1478 usage=
"FRAGMENT_A_FILE_NAME <FILENAME>", &
1479 default_lc_val=
"fragment_a.cube")
1483 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_B_FILE_NAME", variants=[
"FRAGMENT_B_FILE"], &
1484 description=
"Name of the reference total electron density cube file for fragment B."// &
1485 " May include a path. The reference electron density needs to be outputted"// &
1486 " on the same grid as the full system (same cutoff and cell, output stride 1).", &
1487 usage=
"FRAGMENT_B_FILE_NAME <FILENAME>", &
1488 default_lc_val=
"fragment_b.cube")
1492 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_A_SPIN_FILE", &
1493 variants=[
"FRAGMENT_A_SPIN_FILE_NAME"], &
1494 description=
"Name of the reference spin density cube file for fragment A."// &
1495 " May include a path. The reference spin density needs to be outputted"// &
1496 " on the same grid as the full system (same cutoff and cell, output stride 1).", &
1497 usage=
"FRAGMENT_A_SPIN_FILE <FILENAME>", &
1498 default_lc_val=
"fragment_a_spin.cube")
1502 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_B_SPIN_FILE", &
1503 variants=[
"FRAGMENT_B_SPIN_FILE_NAME"], &
1504 description=
"Name of the reference spin density cube file for fragment B."// &
1505 " May include a path. The reference spin density needs to be outputted"// &
1506 " on the same grid as the full system (same cutoff and cell, output stride 1).", &
1507 usage=
"FRAGMENT_B_SPIN_FILE <FILENAME>", &
1508 default_lc_val=
"fragment_b_spin.cube")
1512 CALL keyword_create(keyword, __location__, name=
"FLIP_FRAGMENT_A", &
1513 description=
"Logical which determines if the reference spin difference density "// &
1514 "(rho_alpha-rho_beta) for fragment A should be flipped. With default (off) "// &
1515 "value, the fragment is constrained to have more alpha than beta electrons "// &
1516 "if the isolated fragment has unpaired electrons. Useful in conjunction with "// &
1517 "FLIP_FRAGMENT_B.", &
1518 usage=
"FLIP_FRAGMENT_A", &
1519 default_l_val=.false., lone_keyword_l_val=.true.)
1523 CALL keyword_create(keyword, __location__, name=
"FLIP_FRAGMENT_B", &
1524 description=
"Logical which determines if the reference spin difference density "// &
1525 "(rho_alpha-rho_beta) for fragment B should be flipped. With default (off) "// &
1526 "value, the fragment is constrained to have more alpha than beta electrons "// &
1527 "if the isolated fragment has unpaired electrons. Useful in conjunction with "// &
1528 "FLIP_FRAGMENT_A.", &
1529 usage=
"FLIP_FRAGMENT_B", &
1530 default_l_val=.false., lone_keyword_l_val=.true.)
1535 description=
"Controls the printing of basic info about the method.", &
1538 CALL section_create(subsection, __location__, name=
"WEIGHT_FUNCTION", &
1539 description=
"Controls the printing of cube files with "// &
1540 "the CDFT weight function(s). Intended for single-point testing. "// &
1541 "In multistep simulations, generated cube files are overwritten each step.", &
1542 n_keywords=1, n_subsections=0, repeats=.false.)
1545 description=
"The stride (X,Y,Z) used to write the cube file "// &
1546 "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
1547 " 1 number valid for all components.", &
1548 usage=
"STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=
integer_t)
1558 CALL section_create(group_section, __location__, name=
"ATOM_GROUP", &
1559 description=
"Define a group of atoms for use in a CDFT constraint. Each repetition of "// &
1560 "this section creates a new constraint.", &
1561 n_keywords=4, n_subsections=0, repeats=.true.)
1564 description=
"Specifies the list of atoms that are included in the constraint group.", &
1565 usage=
"ATOMS {integer} {integer} .. {integer}", &
1571 description=
"Defines coefficients for the atoms in the list of atoms. Accepts values +/-1.0.", &
1572 usage=
"COEFF 1.0 -1.0", repeats=.true., &
1573 type_of_var=
real_t, n_var=-1)
1577 CALL keyword_create(keyword, __location__, name=
"CONSTRAINT_TYPE ", &
1578 description=
"Determines what type of constraint to apply. ", &
1579 usage=
"CONSTRAINT_TYPE (CHARGE|MAGNETIZATION|ALPHA|BETA)", &
1580 enum_c_vals=
s2a(
"CHARGE",
"MAGNETIZATION",
"ALPHA",
"BETA"), &
1583 enum_desc=
s2a(
"Total charge density constraint (rho_alpha + rho_beta).", &
1584 "Magnetization density constraint (rho_alpha - rho_beta).", &
1585 "Alpha spin density constraint.", &
1586 "Beta spin density constraint."), &
1591 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_CONSTRAINT", &
1592 description=
"Use a fragment based constraint. "// &
1593 "Takes as input the electron densities of two isolated fragments in the "// &
1594 "same geometry that they have in the full system. "// &
1595 "The isolated fragment densities are read from cube files defined in FRAGMENT_{A,B}_FILE. "// &
1596 "For magnetization density constraints, additional files containing the spin difference "// &
1597 "densities must be defined with the keywords FRAGMENT_{A,B}_SPIN_FILE. "// &
1598 "With this keyword active, the target value of the constraint is calculated from the "// &
1599 "the superposition of the isolated fragment densities. Supports only static calculations.", &
1600 usage=
"FRAGMENT_CONSTRAINT", &
1601 default_l_val=.false., lone_keyword_l_val=.true.)
1608 CALL section_create(group_section, __location__, name=
"DUMMY_ATOMS", &
1609 description=
"Define an extra group of atoms for which only atomic CDFT charges "// &
1610 "should be computed. The section cannot contain any constraint "// &
1611 "atoms that were included in section ATOM_GROUP.", &
1612 n_keywords=1, n_subsections=0, repeats=.true.)
1615 description=
"Specifies the list of atoms that are included in the DUMMY_ATOMS group.", &
1616 usage=
"ATOMS {integer} {integer} .. {integer}", &
1624 CALL keyword_create(keyword, __location__, name=
"REUSE_PRECOND", &
1625 description=
"Reuse a previously built OT preconditioner between subsequent CDFT SCF iterations "// &
1626 "if the inner OT SCF loop converged in PRECOND_FREQ steps or less. Intended mainly for MD "// &
1627 "simulations with the FULL_ALL preconditioner to speed up the final iterations of the CDFT SCF loop.", &
1628 usage=
"REUSE_PRECOND yes", repeats=.false., n_var=1, &
1629 default_l_val=.false., lone_keyword_l_val=.true.)
1633 CALL keyword_create(keyword, __location__, name=
"PRECOND_FREQ", &
1634 description=
"See REUSE_PRECOND.", &
1635 usage=
"PRECOND_FREQ {int}", default_i_val=0)
1640 description=
"Determines how many times a previously built preconditioner can be reused.", &
1641 usage=
"MAX_REUSE {int}", default_i_val=0)
1645 CALL keyword_create(keyword, __location__, name=
"PURGE_HISTORY", &
1646 description=
"Purge wavefunction and constraint history to improve SCF convergence during MD."// &
1647 " Counts how often the convergence of the first CDFT SCF iteration takes 2 or more outer SCF"// &
1648 " iterations and purges the history if the counter exceeds PURGE_FREQ, and PURGE_OFFSET"// &
1649 " MD steps have passed since the last purge."// &
1650 " The counter is zeroed after each purge.", &
1651 usage=
"PURGE_HISTORY yes", repeats=.false., n_var=1, &
1652 default_l_val=.false., lone_keyword_l_val=.true.)
1657 description=
"See PURGE_HISTORY.", &
1658 usage=
"PURGE_FREQ {int} ", default_i_val=1)
1662 CALL keyword_create(keyword, __location__, name=
"PURGE_OFFSET", &
1663 description=
"See PURGE_HISTORY.", &
1664 usage=
"PURGE_OFFSET {int} ", default_i_val=1)
1669 description=
"A counter to track the total number of energy evaluations. Needed by"// &
1670 " some optimizers to print information. Useful mainly for restarts.", &
1671 usage=
"COUNTER {int} ", default_i_val=0)
1676 description=
"Precompute gradients due to constraint during"// &
1677 " initial formation of constraint and store them in memory. Does"// &
1678 " nothing if forces are not calculated.", &
1679 usage=
"IN_MEMORY", &
1680 default_l_val=.false., lone_keyword_l_val=.true.)
1690 SUBROUTINE create_hirshfeld_constraint_section(section)
1697 cpassert(.NOT.
ASSOCIATED(section))
1698 CALL section_create(section, __location__, name=
"HIRSHFELD_CONSTRAINT", &
1699 description=
"Parameters for CDFT with a Gaussian Hirshfeld constraint.", &
1700 n_keywords=11, n_subsections=0, repeats=.false.)
1702 CALL keyword_create(keyword, __location__, name=
"SHAPE_FUNCTION", &
1703 description=
"Type of shape function used for Hirshfeld partitioning.", &
1704 usage=
"SHAPE_FUNCTION {Gaussian,Density}", repeats=.false., n_var=1, &
1706 enum_c_vals=
s2a(
"GAUSSIAN",
"DENSITY"), &
1707 enum_desc=
s2a(
"One Gaussian per atom with radius determined by the keyword GAUSSIAN_SHAPE.", &
1708 "Atomic density expanded in terms of multiple Gaussians."), &
1713 CALL keyword_create(keyword, __location__, name=
"GAUSSIAN_SHAPE", &
1714 description=
"Specifies the type of Gaussian used for SHAPE_FUNCTION GAUSSIAN.", &
1715 usage=
"GAUSSIAN_SHAPE (SINGLE|VDW|COVALENT|USER)", &
1716 enum_c_vals=
s2a(
"DEFAULT",
"SINGLE",
"VDW",
"COVALENT",
"USER"), &
1718 enum_desc=
s2a(
"Use covalent radii (in angstrom) to construct Gaussians, but fixed"// &
1719 " 1.0_dp radius for elements with a radius larger than this value.", &
1720 "Single Gaussian for all atom types with radius given by GAUSSIAN_RADIUS.", &
1721 "Use van der Waals radii to construct Gaussians.", &
1722 "Use covalent radii to construct Gaussians.", &
1723 "Use user defined radii (keyword ATOMIC_RADII) to construct Gaussians."), &
1728 CALL keyword_create(keyword, __location__, name=
"GAUSSIAN_RADIUS", &
1729 description=
"Radius parameter controlling the creation of Gaussians.", &
1730 usage=
"GAUSSIAN_RADIUS <REAL>", &
1731 unit_str=
"angstrom", &
1733 type_of_var=
real_t, n_var=1)
1737 CALL keyword_create(keyword, __location__, name=
"ATOMIC_RADII", &
1738 description=
"Defines custom radii to setup the spherical Gaussians. "// &
1739 "Give one value per element in the same order as they "// &
1740 "appear in the input coordinates.", &
1741 usage=
"ATOMIC_RADII {real} {real} {real}", repeats=.false., &
1742 unit_str=
"angstrom", &
1743 type_of_var=
real_t, n_var=-1)
1748 description=
"Convert the Gaussian radius from angstrom to bohr. This results in a larger "// &
1749 "Gaussian than without unit conversion.", &
1750 usage=
"USE_BOHR .TRUE.", &
1751 default_l_val=.false., lone_keyword_l_val=.true.)
1755 CALL keyword_create(keyword, __location__, name=
"PRINT_DENSITY", &
1756 description=
"Logical to control printing of Hirshfeld densities to .cube file.", &
1757 usage=
"PRINT_DENSITY TRUE", &
1758 default_l_val=.false., lone_keyword_l_val=.true.)
1762 CALL keyword_create(keyword, __location__, name=
"ATOMS_MEMORY", &
1763 description=
"Number of atomic gradients to store in memory.", &
1764 usage=
"ATOMS_MEMORY", &
1770 CALL keyword_create(keyword, __location__, name=
"USE_ATOMIC_CUTOFF", &
1771 description=
"Logical to control use of ATOMIC_CUTOFF.", &
1772 usage=
"USE_ATOMIC_CUTOFF TRUE", &
1773 default_l_val=.true., lone_keyword_l_val=.true.)
1778 description=
"Numerical cutoff for calculation of weight function.", &
1779 usage=
"EPS_CUTOFF {real} ", default_r_val=1.0e-12_dp)
1783 CALL keyword_create(keyword, __location__, name=
"ATOMIC_CUTOFF", &
1784 description=
"Numerical cutoff for calculation of Hirshfeld densities.", &
1785 usage=
"ATOMIC_CUTOFF {real} ", default_r_val=1.0e-12_dp)
1789 END SUBROUTINE create_hirshfeld_constraint_section
1795 SUBROUTINE create_becke_constraint_section(section)
1801 cpassert(.NOT.
ASSOCIATED(section))
1802 CALL section_create(section, __location__, name=
"BECKE_CONSTRAINT", &
1803 description=
"Define settings influencing the construction of the Becke weight function.", &
1804 n_keywords=13, repeats=.false., citations=[
becke1988b])
1807 description=
"Adjust Becke cell boundaries with atomic"// &
1808 " radii to generate a heteronuclear cutoff profile. These"// &
1809 " radii are defined with the keyword ATOMIC_RADII.", &
1810 usage=
"ADJUST_SIZE", &
1811 default_l_val=.false., lone_keyword_l_val=.true.)
1815 CALL keyword_create(keyword, __location__, name=
"ATOMIC_RADII", &
1816 description=
"Defines atomic radii to generate a heteronuclear cutoff profile."// &
1817 " Give one value per element in the same order as they"// &
1818 " appear in the input coordinates.", &
1819 usage=
"ATOMIC_RADII {real} {real} {real}", repeats=.false., &
1820 unit_str=
"angstrom", &
1821 type_of_var=
real_t, n_var=-1)
1826 description=
"If grid point is farther than GLOBAL_CUTOFF from all constraint atoms, "// &
1827 "move directly to next grid point, thus saving computational resources.", &
1828 usage=
"SHOULD_SKIP", &
1829 default_l_val=.false., lone_keyword_l_val=.true.)
1833 CALL keyword_create(keyword, __location__, name=
"CAVITY_CONFINE", &
1834 description=
"Activates Gaussian cavity confinement. The constraint is evaluated only inside "// &
1835 "the cavity. The cavity is formed by summing spherical Gaussians centered on the constraint atoms.", &
1836 usage=
"CAVITY_CONFINE", &
1837 default_l_val=.false., lone_keyword_l_val=.true.)
1841 CALL keyword_create(keyword, __location__, name=
"CAVITY_SHAPE", &
1842 description=
"Specifies the type of Gaussian cavity used.", &
1843 usage=
"CAVITY_SHAPE (SINGLE|VDW|COVALENT|USER)", &
1844 enum_c_vals=
s2a(
"DEFAULT",
"SINGLE",
"VDW",
"COVALENT",
"USER"), &
1846 enum_desc=
s2a(
"Use covalent radii (in angstrom) to construct Gaussians, but fixed"// &
1847 " 1.0_dp radius for elements with a radius larger than this value.", &
1848 "Single Gaussian for all atom types with radius given by CAVITY_RADIUS.", &
1849 "Use van der Waals radii to construct Gaussians.", &
1850 "Use covalent radii to construct Gaussians.", &
1851 "Use user defined radii (keyword ATOMIC_RADII) to construct Gaussians."), &
1856 CALL keyword_create(keyword, __location__, name=
"CAVITY_USE_BOHR", &
1857 description=
"Convert the cavity radius from angstrom to bohr. This results in a larger"// &
1858 " confinement cavity than without unit conversion.", &
1859 usage=
"CAVITY_USE_BOHR TRUE", &
1860 default_l_val=.false., lone_keyword_l_val=.true.)
1864 CALL keyword_create(keyword, __location__, name=
"CAVITY_PRINT", &
1865 description=
"Print cavity in Gaussian cube file format. Currently, printing options"// &
1866 " are hardcoded.", &
1867 usage=
"CAVITY_PRINT", &
1868 default_l_val=.false., lone_keyword_l_val=.true.)
1872 CALL keyword_create(keyword, __location__, name=
"CAVITY_RADIUS", &
1873 description=
"Radius parameter controlling the creation of Gaussian cavity confinement.", &
1874 usage=
"CAVITY_RADIUS <REAL>", &
1875 unit_str=
"angstrom", &
1877 type_of_var=
real_t, n_var=1)
1882 description=
"Density threshold for cavity creation. Grid points where the Gaussian"// &
1883 " density falls below the threshold are ignored.", &
1884 usage=
"EPS_CAVITY {real} ", default_r_val=1.0e-6_dp)
1889 description=
"Specifies the type of cutoff used when building the Becke weight function.", &
1890 usage=
"CUTOFF_TYPE (GLOBAL|ELEMENT)", &
1891 enum_c_vals=
s2a(
"GLOBAL",
"ELEMENT"), &
1893 enum_desc=
s2a(
"Use a single value for all elements. Read from GLOBAL_CUTOFF.", &
1894 "Use a different value for all elements. Values read from ELEMENT_CUTOFF."), &
1899 CALL keyword_create(keyword, __location__, name=
"GLOBAL_CUTOFF", &
1900 description=
"Parameter used to select which atoms contribute to the"// &
1901 " weight function at each real space grid point.", &
1902 usage=
"GLOBAL_CUTOFF <REAL>", &
1903 unit_str=
"angstrom", &
1905 type_of_var=
real_t, n_var=1)
1909 CALL keyword_create(keyword, __location__, name=
"ELEMENT_CUTOFF", &
1910 description=
"Defines element specific cutoffs to decide which atoms contribute to the"// &
1911 " weight function at each real space grid point. Give one value per element in the same"// &
1912 " order as they appear in the coordinates.", &
1913 usage=
"ELEMENT_CUTOFF {real} {real} {real}", repeats=.false., &
1914 unit_str=
"angstrom", &
1915 type_of_var=
real_t, n_var=-1)
1920 description=
"Precompute gradients due to Becke constraint during"// &
1921 " initial formation of constraint and store them in memory. Useful"// &
1922 " in combination with confinement, memory intensive otherwise. Does"// &
1923 " nothing if forces are not calculated.", &
1924 usage=
"IN_MEMORY", &
1925 default_l_val=.false., lone_keyword_l_val=.true.)
1929 END SUBROUTINE create_becke_constraint_section
1938 SUBROUTINE create_cdft_opt_section(section)
1943 cpassert(.NOT.
ASSOCIATED(section))
1945 description=
"Parameters controlling optimization methods that are compatible "// &
1946 "only with CDFT based constraints (i.e. CDFT SCF is active). Specifically, "// &
1947 "the control parameters for the Broyden and Newton optimizers are defined in this "// &
1949 n_keywords=10, n_subsections=0, repeats=.false.)
1953 CALL keyword_create(keyword, __location__, name=
"BROYDEN_TYPE", &
1954 description=
"Specifies the Broyden optimizer variant to use.", &
1955 usage=
"BROYDEN_TYPE BT1", &
1957 enum_c_vals=
s2a(
"BT1",
"BT1_EXPLICIT",
"BT2",
"BT2_EXPLICIT", &
1958 "BT1_LS",
"BT1_EXPLICIT_LS",
"BT2_LS",
"BT2_EXPLICIT_LS"), &
1959 enum_desc=
s2a(
"Broyden's first method, also known as the good method. The initial Jacobian"// &
1960 " is built from MD history if available. Otherwise switches to SD for one"// &
1961 " SCF iteration until a Jacobian can be built from the SCF history.", &
1962 "Same as BT1, but computes the explicit Jacobian with finite differences. "// &
1963 "Requires a CDFT SCF procedure to be active.", &
1964 "Same as BT1, but uses Broyden's second method, also known as the bad method.", &
1965 "Same as BT1_EXPLICIT, but using Broyden's second method.", &
1966 "Same as BT1, but uses backtracking line search for optimizing the step size "// &
1967 "(see optimizer NEWTON_LS).", &
1968 "Same as BT1_EXPLICIT, but uses backtracking line search for optimizing the step size.", &
1969 "Same as BT2, but uses backtracking line search for optimizing the step size.", &
1970 "Same as BT2_EXPLICIT, but uses backtracking line search for optimizing the step size."), &
1977 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_TYPE", &
1978 description=
"Finite difference method used to calculate the inverse Jacobian "// &
1979 "needed by some optimizers. Compatible only with CDFT constraints.", &
1980 usage=
"JACOBIAN_TYPE FD1", &
1982 enum_c_vals=
s2a(
"FD1",
"FD1_BACKWARD",
"FD2",
"FD2_BACKWARD",
"FD1_CENTRAL"), &
1983 enum_desc=
s2a(
"First order forward difference (one extra energy evaluation per constraint).", &
1984 "First order backward difference (one extra energy evaluation per constraint).", &
1985 "Second order forward difference (two extra energy evaluations per constraint).", &
1986 "Second order backward difference (two extra energy evaluations per constraint).", &
1987 "First order central difference (two extra energy evaluations per constraint)."), &
1993 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_STEP", &
1994 description=
"Step size to use in the calculation of the inverse Jacobian with finite differences. "// &
1995 "Expects one value for all constraints, or one value per constraint.", &
1996 usage=
"JACOBIAN_STEP 5.0E-3 ", n_var=-1, default_r_val=5.0e-3_dp)
2000 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_FREQ", &
2001 description=
"Defines parameters that control how often the explicit Jacobian is built,"// &
2002 " which is needed by some optimizers. Expects two values. The first value"// &
2003 " determines how many consecutive CDFT SCF iterations should skip a rebuild,"// &
2004 " whereas the latter how many MD steps. The values can be zero (meaning never"// &
2005 " rebuild) or positive. Both values cannot be zero.", &
2006 usage=
"JACOBIAN_FREQ 1 1", n_var=2, &
2007 default_i_vals=[1, 1], type_of_var=
integer_t)
2011 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_RESTART", &
2012 description=
"Restart the inverse Jacobian using the vector defined with keyword JACOBIAN_VECTOR.", &
2013 usage=
"JACOBIAN_RESTART TRUE", &
2014 default_l_val=.false., lone_keyword_l_val=.true.)
2018 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_VECTOR", &
2019 description=
"Defines the inverse Jacobian matrix. Useful for restarting calculations. "// &
2020 "Expects n^2 values where n is the total number of constraints. "// &
2021 "The matrix should be given in row major order.", &
2022 usage=
"JACOBIAN_VECTOR 1.0 0.0", n_var=-1, type_of_var=
real_t)
2027 description=
"The maximum number of backtracking line search steps to perform.", &
2028 usage=
"MAX_LS 5", default_i_val=5)
2033 description=
"Control parameter for backtracking line search. The step size is reduced by "// &
2034 "this factor on every line search iteration. Value must be between 0 and 1 (exclusive).", &
2035 usage=
"FACTOR_LS 0.5", default_r_val=0.5_dp)
2040 description=
"Continue backtracking line search until MAX_LS steps are reached or the "// &
2041 "norm of the CDFT gradient no longer decreases. Default (false) behavior exits the "// &
2042 "line search procedure on the first step that the gradient decreases.", &
2043 usage=
"CONTINUE_LS TRUE", &
2044 default_l_val=.false., lone_keyword_l_val=.true.)
2048 END SUBROUTINE create_cdft_opt_section
2057 SUBROUTINE create_gce_section(section)
2063 cpassert(.NOT.
ASSOCIATED(section))
2067 description=
"Define the settings of the grand canonical ensemble DFT", &
2075 name=
"_SECTION_PARAMETERS_", &
2076 description=
"Controls the activation of grand canonical ensemble DFT", &
2078 default_l_val=.false., &
2079 lone_keyword_l_val=.true.)
2084 name=
"TARGET_WORKFUNCTION", &
2085 description=
"The user input target work function of the symmetric slab model", &
2089 default_r_val=0.16_dp, &
2091 usage=
"TARGET_WORKFUNCTION [eV] 0.16")
2096 name=
"MIXING_COEF", &
2097 description=
"The proportion of the target work function mixed with the "// &
2098 "work function of the previous SCF iteration", &
2102 default_r_val=0.3_dp, &
2103 usage=
"MIXING_COEF 0.3")
2107 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
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