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=21, n_subsections=8, 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)
120 CALL create_adiis_section(subsection)
128 CALL create_gce_section(subsection)
134 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LUMO", &
135 variants=[
"MAX_ITER_LUMOS"], &
136 description=
"Maximum number of iterations for the calculation of the LUMO energies "// &
137 "with the OT eigensolver.", &
138 usage=
"MAX_ITER_LUMO 100", default_i_val=299)
143 variants=[
"EPS_LUMOS"], &
144 description=
"Target accuracy for the calculation of the LUMO energies with the OT eigensolver.", &
145 usage=
"EPS_LUMO 1.0E-6", default_r_val=1.0e-5_dp)
150 description=
"Maximum number of inner SCF iterations for one electronic optimization.", &
151 usage=
"MAX_SCF 200", default_i_val=50)
155 CALL keyword_create(keyword, __location__, name=
"MAX_SCF_HISTORY", variants=[
"MAX_SCF_HIST"], &
156 description=
"Maximum number of SCF iterations after the history pipeline is filled", &
157 usage=
"MAX_SCF_HISTORY 1", default_i_val=0, lone_keyword_i_val=1)
162 variants=[
"MAX_DIIS_BUFFER_SIZE"], &
163 description=
"Maximum number of conventional DIIS subspace vectors to be used", &
164 usage=
"MAX_DIIS 3", default_i_val=4)
169 variants=[
"LSHIFT"], &
170 description=
"Use level shifting to improve convergence", &
172 usage=
"LEVEL_SHIFT 0.1", &
173 default_r_val=0.0_dp)
178 description=
"Target convergence threshold for the inner SCF cycle.", &
179 usage=
"EPS_SCF 1.e-6", default_r_val=1.e-5_dp)
183 CALL keyword_create(keyword, __location__, name=
"EPS_SCF_HISTORY", variants=[
"EPS_SCF_HIST"], &
184 description=
"Target accuracy for the SCF convergence after the history pipeline is filled.", &
185 usage=
"EPS_SCF_HISTORY 1.e-5", default_r_val=0.0_dp, lone_keyword_r_val=1.0e-5_dp)
190 description=
"If the cholesky method should be used for computing "// &
191 "the inverse of S, and in this case calling which Lapack routines", &
193 enum_c_vals=
s2a(
"OFF",
"REDUCE",
"RESTORE",
"INVERSE",
"INVERSE_DBCSR"), &
194 enum_desc=
s2a(
"The cholesky algorithm is not used",
"Reduce is called", &
195 "Reduce is replaced by two restore", &
196 "Restore uses operator multiply by inverse of the triangular matrix", &
197 "Like inverse, but matrix stored as dbcsr, sparce matrix algebra used when possible"), &
203 description=
"Throw away linear combinations of basis functions with a small eigenvalue in S", &
204 usage=
"EPS_EIGVAL 1.0", default_r_val=1.0e-5_dp)
209 description=
"Threshold on the convergence to start using DIAG/DIIS or OT/DIIS."// &
210 " Default for OT/DIIS is never to switch.", &
211 usage=
"EPS_DIIS 5.0e-2", default_r_val=0.1_dp)
216 keyword, __location__, name=
"SCF_GUESS", &
217 description=
"Selects how the initial wavefunction or density matrix is generated.", &
218 usage=
"SCF_GUESS RESTART", default_i_val=
atomic_guess, &
219 enum_c_vals=
s2a(
"ATOMIC",
"RESTART",
"RANDOM",
"CORE", &
220 "HISTORY_RESTART",
"MOPAC",
"EHT",
"SPARSE",
"EXTERNAL_DENSITY",
"NONE"), &
221 enum_desc=
s2a(
"Generate an atomic density using the atomic code and internal default values", &
222 "Use the RESTART file as an initial guess (and ATOMIC if not present).", &
223 "Use random wavefunction coefficients.", &
224 "Diagonalize the core hamiltonian for an initial guess.", &
225 "Extrapolated from previous RESTART files.", &
226 "Use same guess as MOPAC for semi-empirical methods or a simple diagonal density matrix for other methods", &
227 "Use the EHT (gfn0-xTB) code to generate an initial wavefunction.", &
228 "Generate a sparse wavefunction using the atomic code (for OT based methods)", &
229 "Read a scalar electron density from a cube file for the first SCF Hamiltonian", &
230 "Skip initial guess (only for non-self consistent methods)."), &
236 CALL keyword_create(keyword, __location__, name=
"EXTERNAL_DENSITY_FILE_NAME", &
237 description=
"Cube file containing the electron density used when SCF_GUESS is "// &
238 "EXTERNAL_DENSITY. The density is consumed once to build the first KS Hamiltonian; "// &
239 "all subsequent densities are generated by the regular SCF solver. The cube grid "// &
240 "has to coincide with the finest CP2K real-space grid.", &
241 usage=
"EXTERNAL_DENSITY_FILE_NAME <FILENAME>", &
242 type_of_var=
char_t, default_c_val=
"", n_var=1)
247 description=
"sets the number of rows in a scalapack block", &
248 usage=
"NROW_BLOCK 31", default_i_val=32)
253 description=
"Sets the number of columns in a scalapack block", &
254 usage=
"NCOL_BLOCK 31", default_i_val=32)
259 description=
"Number of additional molecular orbitals added for each spin channel. "// &
260 "This is commonly needed for smearing, excited-state, or post-Hartree-Fock calculations. "// &
261 "Use -1 to add all available orbitals. For k-point smearing, use AUTO "// &
262 "to select and adapt the virtual-space buffer.", &
263 usage=
"ADDED_MOS {integer|AUTO}", default_c_val=
"0", n_var=-1)
268 name=
"ROKS_SCHEME", &
269 description=
"Selects the ROKS scheme when ROKS is applied.", &
270 usage=
"ROKS_SCHEME HIGH-SPIN", &
273 enum_c_vals=
s2a(
"GENERAL",
"HIGH-SPIN"), &
281 variants=[
"F_ROKS"], &
282 description=
"Allows to define the parameter f for the "// &
283 "general ROKS scheme.", &
284 usage=
"ROKS_F 1/2", &
288 default_r_val=0.5_dp)
293 name=
"ROKS_PARAMETERS", &
294 variants=[
"ROKS_PARAMETER"], &
295 description=
"Allows to define all parameters for the high-spin "// &
296 "ROKS scheme explicitly. "// &
297 "The full set of 6 parameters has to be specified "// &
298 "in the order acc, bcc, aoo, boo, avv, bvv", &
299 usage=
"ROKS_PARAMETERS 1/2 1/2 1/2 1/2 1/2 1/2", &
303 default_r_vals=[-0.5_dp, 1.5_dp, 0.5_dp, 0.5_dp, 1.5_dp, -0.5_dp])
307 CALL keyword_create(keyword, __location__, name=
"IGNORE_CONVERGENCE_FAILURE", &
308 description=
"If true, only a warning is issued if an SCF "// &
309 "iteration has not converged. By default, a run is aborted "// &
310 "if the required convergence criteria have not been achieved.", &
311 usage=
"IGNORE_CONVERGENCE_FAILURE logical_value", &
312 default_l_val=.false., &
313 lone_keyword_l_val=.true.)
317 CALL keyword_create(keyword, __location__, name=
"FORCE_SCF_CALCULATION", &
318 description=
"Request a SCF type solution even for nonSCF methods. ", &
319 usage=
"FORCE_SCF_CALCULATION logical_value", &
320 default_l_val=.false., &
321 lone_keyword_l_val=.true.)
326 description=
"Printing of information during the SCF.", repeats=.false.)
329 description=
"Controls the dumping of the MO restart file during SCF. "// &
330 "By default keeps a short history of three restarts. "// &
331 "See also RESTART_HISTORY", &
333 each_iter_names=
s2a(
"QS_SCF"), each_iter_values=[20], &
335 CALL keyword_create(keyword, __location__, name=
"BACKUP_COPIES", &
336 description=
"Specifies the maximum number of backup copies.", &
337 usage=
"BACKUP_COPIES {int}", &
345 print_key, __location__,
"RESTART_HISTORY", &
346 description=
"Dumps unique MO restart files during the run keeping all of them.", &
348 each_iter_names=
s2a(
"__ROOT__",
"MD",
"GEO_OPT",
"ROT_OPT",
"NEB",
"METADYNAMICS",
"QS_SCF"), &
349 each_iter_values=[500, 500, 500, 500, 500, 500, 500], &
351 CALL keyword_create(keyword, __location__, name=
"BACKUP_COPIES", &
352 description=
"Specifies the maximum number of backup copies.", &
353 usage=
"BACKUP_COPIES {int}", &
361 description=
"Controls the printing of basic iteration information during the SCF.", &
364 description=
"If the printkey is activated switches the printing of timings"// &
365 " to cumulative (over the SCF).", &
366 default_l_val=.false., lone_keyword_l_val=.true.)
373 description=
"Controls the printing of basic information during the SCF.", &
379 description=
"Controls the printing relative to the orthonormality of MOs (CT S C).", &
385 description=
"Prints the min/max eigenvalues of the overlap of the MOs without S (CT C).", &
391 description=
"Controls the printing of detailed energy information.", &
397 description=
"Controls the printing of DIIS information.", &
403 description=
"Controls the printing of total densities.", &
409 description=
"Controls the printing of information on Lanczos refinement iterations.", &
415 print_key, __location__,
"DIAG_SUB_SCF", &
416 description=
"Controls the printing of information on subspace diagonalization internal loop. ", &
422 description=
"Controls the printing of information on Davidson iterations.", &
428 description=
"Controls the printing of information on Filter Matrix method.", &
433 CALL keyword_create(keyword, __location__, name=
"DM_RESTART_WRITE", &
434 description=
"Write the density matrix into a binary file at the end of the SCF.", &
435 usage=
"DM_RESTART_WRITE", default_l_val=.false., lone_keyword_l_val=.true.)
450 SUBROUTINE create_outer_scf_section(section)
456 cpassert(.NOT.
ASSOCIATED(section))
458 description=
"Controls an outer SCF loop, often used to stabilize difficult OT convergence, "// &
459 "constraints, or other variables wrapped around the inner SCF cycle.", &
460 n_keywords=13, n_subsections=1, repeats=.false.)
464 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
465 description=
"Activates the outer SCF loop.", &
466 usage=
"&OUTER_SCF ON", default_l_val=.false., lone_keyword_l_val=.true.)
472 CALL create_cdft_opt_section(subsection)
477 description=
"Specifies which kind of outer SCF should be employed", &
478 usage=
"TYPE DDAPC_CONSTRAINT ", &
480 enum_c_vals=
s2a(
"DDAPC_CONSTRAINT",
"S2_CONSTRAINT", &
481 "BASIS_CENTER_OPT",
"CDFT_CONSTRAINT",
"NONE"), &
482 enum_desc=
s2a(
"Enforce a constraint on the DDAPC, requires the corresponding section", &
483 "Enforce a constraint on the S2, requires the corresponding section", &
484 "Optimize positions of basis functions, if atom types FLOATING_BASIS_CENTER "// &
486 "Enforce a constraint on a generic CDFT weight population. "// &
487 "Requires the corresponding section QS&CDFT"// &
488 " which determines the type of weight used.", &
489 "Do nothing in the outer loop, useful for resetting the inner loop,"), &
496 description=
"Method used to bring the outer loop to a stationary point", &
497 usage=
"OPTIMIZER SD", &
499 enum_c_vals=
s2a(
"SD",
"DIIS",
"NONE",
"BISECT",
"BROYDEN",
"NEWTON",
"SECANT",
"NEWTON_LS"), &
500 enum_desc=
s2a(
"Takes steps in the direction of the gradient, multiplied by step_size", &
501 "Uses a Direct Inversion in the Iterative Subspace method", &
502 "Do nothing, useful only with the none type", &
503 "Bisection of the gradient, useful for difficult one dimensional cases", &
504 "Broyden's method. Variant defined in BROYDEN_TYPE.", &
505 "Newton's method. Only compatible with CDFT constraints.", &
506 "Secant method. Only for one dimensional cases. See Broyden for "// &
507 "multidimensional cases.", &
508 "Newton's method with backtracking line search to find the optimal step size. "// &
509 "Only compatible with CDFT constraints. Starts from the regular Newton solution "// &
510 "and successively reduces the step size until the L2 norm of the CDFT gradient "// &
511 "decreases or MAX_LS steps is reached. Potentially very expensive because "// &
512 "each iteration performs a full SCF calculation."), &
520 CALL keyword_create(keyword, __location__, name=
"BISECT_TRUST_COUNT", &
521 description=
"Maximum number of times the same point will be used in bisection,"// &
522 " a small number guards against the effect of wrongly converged states.", &
523 usage=
"BISECT_TRUST_COUNT 5", default_i_val=10)
528 description=
"The target gradient of the outer SCF variables. "// &
529 "Notice that the EPS_SCF of the inner loop also determines "// &
530 "the value that can be reached in the outer loop, "// &
531 "typically EPS_SCF of the outer loop must be smaller "// &
532 "than or equal to EPS_SCF of the inner loop.", &
533 usage=
"EPS_SCF 1.0E-6 ", default_r_val=1.0e-5_dp)
537 CALL keyword_create(keyword, __location__, name=
"DIIS_BUFFER_LENGTH", &
538 description=
"Maximum number of DIIS vectors used ", &
539 usage=
"DIIS_BUFFER_LENGTH 5", default_i_val=3)
543 CALL keyword_create(keyword, __location__, name=
"EXTRAPOLATION_ORDER", &
544 description=
"Number of past states used in the extrapolation of the variables during e.g. MD", &
545 usage=
"EXTRAPOLATION_ORDER 5", default_i_val=3)
550 description=
"Maximum number of outer SCF loops.", &
551 usage=
"MAX_SCF 20", default_i_val=50)
556 description=
"The initial step_size used in the optimizer (currently steepest descent). "// &
557 "Note that in cases where a sadle point is sought for (constrained DFT),"// &
558 " this can be negative. For Newton and Broyden optimizers, use a value less/higher than "// &
559 "the default 1.0 (in absolute value, the sign is not significant) to active an under/overrelaxed "// &
561 usage=
"STEP_SIZE -1.0", default_r_val=0.5_dp)
565 END SUBROUTINE create_outer_scf_section
574 SUBROUTINE create_ot_section(section, diagonalization)
576 LOGICAL,
INTENT(IN),
OPTIONAL :: diagonalization
578 LOGICAL :: is_diagonalization
581 cpassert(.NOT.
ASSOCIATED(section))
582 is_diagonalization = .false.
583 IF (
PRESENT(diagonalization)) is_diagonalization = diagonalization
584 IF (is_diagonalization)
THEN
586 description=
"Configures OT as the iterative eigensolver selected by "// &
587 "SCF%DIAGONALIZATION%ALGORITHM OT. The solver minimizes the trace of the "// &
588 "requested orbital subspace for a fixed Kohn-Sham matrix. Orbital energies, "// &
589 "occupations, smearing, density construction, and density mixing are handled "// &
590 "afterwards by the parent DIAGONALIZATION SCF path.", &
591 n_keywords=28, n_subsections=0, repeats=.false., &
595 description=
"Sets the various options for the orbital transformation (OT) method. "// &
596 "Default settings already provide an efficient, yet robust method. "// &
597 "Most systems benefit from using the FULL_ALL preconditioner "// &
598 "combined with a small value (0.001) of ENERGY_GAP. "// &
599 "Well-behaved systems might benefit from using a DIIS minimizer. "//
newline//
newline// &
600 "**Advantages:** "// &
601 "It's fast, because no expensive diagonalisation is performed. "// &
602 "If preconditioned correctly, method guaranteed to find minimum. "//
newline//
newline// &
603 "**Disadvantages:** "// &
604 "Sensitive to preconditioning. A good preconditioner can be expensive. "// &
605 "Metallic systems require a sufficiently large virtual orbital space and "// &
606 "the coupled ROTATION and ENERGIES variables.", &
607 n_keywords=28, n_subsections=0, repeats=.false., &
613 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
614 description=
"controls the activation of the ot method", &
616 default_l_val=.false., &
617 lone_keyword_l_val=.true.)
622 description=
"Algorithm to be used for OT", &
623 usage=
"ALGORITHM STRICT", &
625 enum_c_vals=
s2a(
"STRICT",
"IRAC"), &
626 enum_desc=
s2a(
"Strict orthogonality: Taylor or diagonalization based algorithm.", &
627 "Orbital Transformation based Iterative Refinement "// &
628 "of the Approximative Congruence transformation (OT/IR)."), &
635 description=
"The refinement polynomial degree (2, 3 or 4).", &
636 usage=
"IRAC_DEGREE 4", &
642 description=
"Maximum allowed refinement iteration.", &
643 usage=
"MAX_IRAC 5", &
649 description=
"The orthogonality method.", &
650 usage=
"ORTHO_IRAC POLY", &
652 enum_c_vals=
s2a(
"CHOL",
"POLY",
"LWDN"), &
653 enum_desc=
s2a(
"Cholesky.",
"Polynomial.",
"Loewdin."), &
658 CALL keyword_create(keyword, __location__, name=
"EPS_IRAC_FILTER_MATRIX", &
659 description=
"Sets the threshold for filtering the matrices.", &
660 usage=
"EPS_IRAC_FILTER_MATRIX 1.0E-5", &
661 default_r_val=0.0_dp)
666 description=
"Targeted accuracy during the refinement iteration.", &
667 usage=
"EPS_IRAC 1.0E-5", &
668 default_r_val=1.0e-10_dp)
672 CALL keyword_create(keyword, __location__, name=
"EPS_IRAC_QUICK_EXIT", &
673 description=
"Only one extra refinement iteration is "// &
674 "done when the norm is below this value.", &
675 usage=
"EPS_IRAC_QUICK_EXIT 1.0E-2", &
676 default_r_val=1.0e-5_dp)
680 CALL keyword_create(keyword, __location__, name=
"EPS_IRAC_SWITCH", &
681 description=
"The algorithm switches to the polynomial "// &
682 "refinement when the norm is below this value.", &
683 usage=
"EPS_IRAC_SWITCH 1.0E-3", &
684 default_r_val=1.0e-2_dp)
688 CALL keyword_create(keyword, __location__, name=
"ON_THE_FLY_LOC", &
689 description=
"On the fly localization of the molecular orbitals. "// &
690 "Can only be used with OT/IRAC.", &
691 usage=
"ON_THE_FLY_LOC T", &
692 default_l_val=.false.)
697 keyword, __location__, name=
"MINIMIZER", &
698 description=
"Minimizer to be used with the OT method", &
699 usage=
"MINIMIZER DIIS", &
701 enum_c_vals=
s2a(
"SD",
"CG",
"DIIS",
"BROYDEN",
"LBFGS"), &
702 enum_desc=
s2a(
"Steepest descent: not recommended",
"Conjugate Gradients: most reliable, use for difficult systems."// &
703 " The total energy should decrease at every OT CG step if the line search is appropriate.", &
704 "Direct inversion in the iterative subspace: less reliable than CG, but sometimes about 50% faster", &
705 "Broyden mixing approximating the inverse Hessian", &
706 "Limited-memory BFGS in the fixed OT product chart. The selected OT preconditioner is used"// &
707 " as the initial inverse Hessian. The secant history is reset after a tenfold increase in"// &
708 " the raw fixed-chart gradient norm. With OUTER_SCF, an explicit EPS_DIIS can switch later"// &
709 " outer iterations to OT/DIIS. Available with ALGORITHM STRICT or IRAC."), &
715 variants=[
"SAFER_DIIS"], &
716 description=
"Reject DIIS steps if they point away from the"// &
717 " minimum, do SD in that case.", &
718 usage=
"SAFE_DIIS ON", default_l_val=.true.)
723 description=
"Maximum DIIS SCF inner loop cycles. This can be used to extend"// &
724 " SCF cycles after a switch to DIIS (see eps_diis).", &
725 usage=
"MAX_SCF_DIIS 20", &
730 CALL keyword_create(keyword, __location__, name=
"N_HISTORY_VEC", &
731 variants=
s2a(
"NDIIS",
"N_DIIS",
"N_BROYDEN",
"N_LBFGS"), &
732 description=
"Number of history vectors to be used with DIIS, BROYDEN, or LBFGS", &
733 usage=
"N_HISTORY_VEC 7", &
739 keyword, __location__, name=
"LBFGS_CURVATURE_TOL", &
740 description=
"Minimum dimensionless relative curvature accepted for an LBFGS secant pair."// &
741 " Values are restricted to the interval [0,1).", &
742 usage=
"LBFGS_CURVATURE_TOL 1.0E-4", &
743 default_r_val=1.0e-4_dp)
748 keyword, __location__, name=
"LBFGS_DAMPING", &
749 description=
"Regularize weak or negative LBFGS curvature by the smallest shift of the"// &
750 " gradient difference along the step that satisfies LBFGS_CURVATURE_TOL."// &
751 " If disabled, such secant pairs are skipped.", &
752 usage=
"LBFGS_DAMPING ON", &
753 default_l_val=.true., &
754 lone_keyword_l_val=.true.)
759 description=
"Underrelaxation for the broyden mixer", &
760 usage=
"BROYDEN_BETA 0.9", &
761 default_r_val=0.9_dp)
765 CALL keyword_create(keyword, __location__, name=
"BROYDEN_GAMMA", &
766 description=
"Backtracking parameter", &
767 usage=
"BROYDEN_GAMMA 0.5", &
768 default_r_val=0.5_dp)
772 CALL keyword_create(keyword, __location__, name=
"BROYDEN_SIGMA", &
773 description=
"Curvature of energy functional.", &
774 usage=
"BROYDEN_SIGMA 0.25", &
775 default_r_val=0.25_dp)
780 description=
"Dampening of estimated energy curvature.", &
781 usage=
"BROYDEN_ETA 0.7", &
782 default_r_val=0.7_dp)
786 CALL keyword_create(keyword, __location__, name=
"BROYDEN_OMEGA", &
787 description=
"Growth limit of curvature.", &
788 usage=
"BROYDEN_OMEGA 1.1", &
789 default_r_val=1.1_dp)
793 CALL keyword_create(keyword, __location__, name=
"BROYDEN_SIGMA_DECREASE", &
794 description=
"Reduction of curvature on bad approximation.", &
795 usage=
"BROYDEN_SIGMA_DECREASE 0.7", &
796 default_r_val=0.7_dp)
800 CALL keyword_create(keyword, __location__, name=
"BROYDEN_SIGMA_MIN", &
801 description=
"Minimum adaptive curvature.", &
802 usage=
"BROYDEN_SIGMA_MIN 0.05", &
803 default_r_val=0.05_dp)
807 CALL keyword_create(keyword, __location__, name=
"BROYDEN_FORGET_HISTORY", &
808 description=
"Forget history on bad approximation", &
809 usage=
"BROYDEN_FORGET_HISTORY OFF", default_l_val=.false., &
810 lone_keyword_l_val=.true.)
814 CALL keyword_create(keyword, __location__, name=
"BROYDEN_ADAPTIVE_SIGMA", &
815 description=
"Enable adaptive curvature estimation", &
816 usage=
"BROYDEN_ADAPTIVE_SIGMA ON", default_l_val=.true., &
817 lone_keyword_l_val=.true.)
821 CALL keyword_create(keyword, __location__, name=
"BROYDEN_ENABLE_FLIP", &
822 description=
"Ensure positive definite update", &
823 usage=
"BROYDEN_ENABLE_FLIP ON", default_l_val=.true., &
824 lone_keyword_l_val=.true.)
829 variants=[
"LINE_SEARCH"], &
830 description=
"1D line search algorithm to be used with the OT minimizer,"// &
831 " in increasing order of robustness and cost. MINIMIZER CG combined with"// &
832 " LINESEARCH GOLD should always find an electronic minimum."// &
833 " Whereas the 2PNT minimizer is almost always OK, 3PNT might be needed for systems"// &
834 " in which successive OT CG steps do not decrease the total energy.", &
835 usage=
"LINESEARCH GOLD", &
837 enum_c_vals=
s2a(
"ADAPT",
"NONE",
"2PNT",
"3PNT",
"GOLD"), &
838 enum_desc=
s2a(
"extrapolates usually based on 3 points, "// &
839 "uses additional points on demand, very robust.", &
840 "always take steps of fixed length", &
841 "extrapolate based on 2 points", &
842 "extrapolate based on 3 points", &
843 "perform 1D golden section search of the minimum (very expensive)"), &
849 keyword, __location__, name=
"STEPSIZE", &
850 description=
"Initial stepsize used for the line search, sometimes this parameter can be reduced to stabilize DIIS"// &
851 " or to improve the CG behavior in the first few steps."// &
852 " The optimal value depends on the quality of the preconditioner."// &
853 " A negative values leaves the choice to CP2K depending on the preconditioner.", &
854 usage=
"STEPSIZE 0.4", &
855 default_r_val=-1.0_dp)
860 description=
"Target relative uncertainty in the location of the minimum for LINESEARCH GOLD", &
861 usage=
"GOLD_TARGET 0.1", &
862 default_r_val=0.01_dp)
867 keyword, __location__, name=
"PRECONDITIONER", &
868 description=
"Type of preconditioner to be used with all minimization schemes. "// &
869 "They differ in effectiveness, cost of construction, cost of application. "// &
870 "Properly preconditioned minimization can be orders of magnitude faster than doing nothing.", &
871 usage=
"PRECONDITIONER FULL_ALL", &
873 enum_c_vals=
s2a(
"FULL_ALL",
"FERMI_LOW_RANK",
"FULL_ALL_COVARIANT", &
874 "FULL_SINGLE_INVERSE",
"FULL_SINGLE", &
875 "FULL_KINETIC",
"FULL_S_INVERSE",
"NONE"), &
876 enum_desc=
s2a(
"Most effective state selective preconditioner based on diagonalization, "// &
877 "requires the ENERGY_GAP parameter to be an underestimate of the HOMO-LUMO gap. "// &
878 "This preconditioner is recommended for almost all systems, except very large systems where "// &
879 "make_preconditioner would dominate the total computational cost.", &
880 "Experimental rotationally covariant bounded spectral preconditioner. It applies an "// &
881 "overlap-inverse base plus a configurable number of complementary-state corrections relative to a "// &
882 "common occupied reference level. Construction currently retains a full diagonalization. "// &
883 "Application can be cheaper when the complementary space is larger than the retained rank.", &
884 "Experimental rotation-covariant form of FULL_ALL. It diagonalizes a private copy of the "// &
885 "occupied projected Hamiltonian, applies the complete state-selective Sylvester spectrum "// &
886 "in that canonical copy, and rotates every input and output consistently without changing "// &
887 "the physical orbitals. Complex K-point ROKS canonicalization is restricted to orbital "// &
888 "subspaces with equal alpha/beta occupation signatures. Real Gamma-point use still "// &
889 "requires uniform occupations and excludes ROKS.", &
890 "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
891 "but cheaper to construct, "// &
892 "might be somewhat less robust. Recommended for large systems.", &
893 "Based on H-eS diagonalisation, not as good as FULL_ALL, but somewhat cheaper to apply. ", &
894 "Cholesky inversion of S and T, fast construction, robust, and relatively good, "// &
895 "use for very large systems.", &
896 "Cholesky inversion of S, not as good as FULL_KINETIC, yet equally expensive.", &
897 "skip preconditioning"), &
906 keyword, __location__, name=
"FERMI_LOW_RANK_BASE", &
907 description=
"Base operator used only with PRECONDITIONER FERMI_LOW_RANK. OVERLAP_INVERSE "// &
908 "applies the exact dense inverse overlap. LATTICE_FFT projects the overlap onto translations "// &
909 "of an explicitly replicated SUBSYS multiple unit cell, inverts its small reciprocal-space "// &
910 "blocks, and applies the approximate inverse with lattice FFTs. This choice implies "// &
911 "LATTICE_FFT ON; use the general LATTICE_FFT keyword for AUTO selection. The experimental "// &
912 "FFT path is restricted to real Gamma-point OT calculations.", &
913 usage=
"FERMI_LOW_RANK_BASE LATTICE_FFT", &
915 enum_c_vals=
s2a(
"OVERLAP_INVERSE",
"LATTICE_FFT"), &
916 enum_desc=
s2a(
"Exact dense inverse-overlap base", &
917 "Approximate block-circulant inverse applied by lattice FFT"), &
923 keyword, __location__, name=
"FERMI_LOW_RANK_MAX_RANK", &
924 description=
"Maximum number of complementary eigenstates retained by PRECONDITIONER FERMI_LOW_RANK. "// &
925 "Larger values approach the complete common-reference spectral operator at higher application cost. "// &
926 "A value of -1 retains the entire complementary space. A finite cap never splits a numerically "// &
927 "degenerate boundary manifold.", &
928 usage=
"FERMI_LOW_RANK_MAX_RANK 64", &
934 keyword, __location__, name=
"LATTICE_FFT", &
935 description=
"Apply the inverse of a block-circulant projection of the selected OT "// &
936 "preconditioner with FFTs over explicitly replicated cells. Supported by FULL_S_INVERSE, "// &
937 "FULL_KINETIC, FULL_SINGLE_INVERSE, FULL_ALL_COVARIANT, and FERMI_LOW_RANK in real "// &
938 "Gamma-point calculations. FULL_ALL_COVARIANT projects and inverts one gap-floored "// &
939 "state-dependent Hessian operator per canonical occupied state. "// &
940 "ON requires the projected reciprocal-space blocks to be positive definite. AUTO uses the "// &
941 "FFT operator only for at least eight replicated cells and a relative projection error no "// &
942 "larger than 1.0E-3. It also requires an estimated application-work ratio no larger than "// &
943 "0.8 and limits reciprocal-block storage to four times one dense real operator; otherwise "// &
944 "it retains the conventional solver. The estimates include reference-cell block size, "// &
945 "occupied-column batch size, state-operator count, and message-passing ranks. Construction "// &
946 "of state-independent operators accumulates only the projected reference-cell blocks across "// &
947 "ranks. FULL_ALL_COVARIANT and explicit local corrections still require dense construction "// &
948 "data. Application routes complete orbital columns across ranks and distributes the FFT "// &
949 "batches over those columns.", &
950 usage=
"LATTICE_FFT AUTO", &
952 enum_c_vals=
s2a(
"OFF",
"ON",
"AUTO"), &
953 enum_desc=
s2a(
"Use the conventional OT preconditioner solver", &
954 "Always use the approximate lattice-FFT inverse", &
955 "Use the lattice-FFT inverse only when conservative selection criteria pass"), &
961 keyword, __location__, name=
"LATTICE_FFT_LOCAL_CELLS", &
962 description=
"Number of replicated cell blocks retained in an optional balanced local"// &
963 " correction to LATTICE_FFT ON. Cells are selected from the largest block-row"// &
964 " contributions to the non-circulant residual. The two-level correction is symmetric"// &
965 " positive definite and exactly inverts the selected coordinate subspace. A value of"// &
966 " zero disables the correction. The correction is deliberately unavailable with AUTO,"// &
967 " which continues to reject defective or otherwise non-circulant operators.", &
968 usage=
"LATTICE_FFT_LOCAL_CELLS 1", &
974 description=
"If FULL_ALL the cholesky decomposition of the S matrix is used. "// &
975 "Options on the algorithm to be used.", &
977 enum_c_vals=
s2a(
"OFF",
"REDUCE",
"RESTORE",
"INVERSE",
"INVERSE_DBCSR"), &
978 enum_desc=
s2a(
"The cholesky algorithm is not used",
"Reduce is called", &
979 "Reduce is replaced by two restore", &
980 "Restore uses operator multiply by inverse of the triangular matrix", &
981 "Like inverse, but matrix stored as dbcsr, sparce matrix algebra used when possible"), &
987 keyword, __location__, name=
"PRECOND_SOLVER", &
988 description=
"How the preconditioner is applied to the residual.", &
989 usage=
"PRECOND_SOLVER DIRECT", &
991 enum_c_vals=
s2a(
"DEFAULT",
"DIRECT",
"INVERSE_CHOLESKY",
"INVERSE_UPDATE",
"CHEBYSHEV"), &
992 enum_desc=
s2a(
"the default",
"Cholesky decomposition followed by triangular solve "// &
993 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
994 "Cholesky decomposition followed by explicit inversion "// &
995 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
996 "Performs a Hotelling update of the inverse if a previous preconditioner is present. "// &
997 "Mainly useful for GPU accelerated systems (works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
998 "Applies a bounded Chebyshev approximation to the inverse using matrix products only "// &
999 "(currently requires FULL_KINETIC)."), &
1009 keyword, __location__, name=
"CHEBYSHEV_DEGREE", &
1010 description=
"Polynomial degree of the positive Chebyshev semi-iterative inverse used by "// &
1011 "PRECOND_SOLVER CHEBYSHEV.", &
1012 usage=
"CHEBYSHEV_DEGREE 8", &
1018 keyword, __location__, name=
"ENERGY_GAP", &
1019 description=
"Should be an estimate for the energy gap [a.u.] (HOMO-LUMO) and is used in preconditioning, "// &
1020 "especially effective with the FULL_ALL preconditioner, in which case it should be an underestimate "// &
1021 "of the gap (can be a small number, e.g. 0.002)."// &
1022 " FULL_SINGLE_INVERSE takes it as lower bound (values below 0.05 can cause stability issues)."// &
1023 " In general, higher values will tame the preconditioner in case of poor initial guesses."// &
1024 " A negative value will leave the choice to CP2K depending on type of preconditioner.", &
1025 usage=
"ENERGY_GAP 0.001", &
1026 default_r_val=-1.0_dp)
1031 keyword, __location__, name=
"EPS_TAYLOR", &
1032 variants=[
"EPSTAYLOR"], &
1033 description=
"Target accuracy of the taylor expansion for the matrix functions, should normally be kept as is.", &
1034 usage=
"EPS_TAYLOR 1.0E-15", &
1035 default_r_val=1.0e-16_dp)
1040 keyword, __location__, name=
"MAX_TAYLOR", &
1041 description=
"Maximum order of the Taylor expansion before diagonalisation is preferred, for large parallel runs"// &
1042 " a slightly higher order could sometimes result in a small speedup.", &
1043 usage=
"MAX_TAYLOR 5", &
1049 description=
"Introduce additional variables so that rotations of the occupied"// &
1050 " subspace are allowed as well, only needed for cases where the energy is not invariant under"// &
1051 " a rotation of the occupied subspace such as non-singlet restricted calculations"// &
1052 " or fractional occupations. This variable is not used by DIAGONALIZATION%OT, "// &
1053 "which canonicalizes the converged eigenspace explicitly.", &
1054 usage=
"ROTATION", lone_keyword_l_val=.true., &
1055 default_l_val=.false.)
1060 description=
"Optimize auxiliary orbital energies for Mermin smearing in direct SCF%OT "// &
1061 "(requires ROTATION and smearing to be active). DIAGONALIZATION%OT obtains "// &
1062 "orbital energies by canonicalizing its converged eigenspace instead.", &
1063 usage=
"ENERGIES", lone_keyword_l_val=.true., &
1064 default_l_val=.false.)
1068 CALL keyword_create(keyword, __location__, name=
"OCCUPATION_PRECONDITIONER", &
1069 description=
"Augment the direct SCF%OT orbital metric with coupled fixed-N "// &
1070 "occupation response. This augments the independently selected orbital "// &
1071 "preconditioner. It is not used by DIAGONALIZATION%OT, where occupations are "// &
1072 "assigned after the eigensolver has converged.", &
1073 usage=
"OCCUPATION_PRECONDITIONER", lone_keyword_l_val=.true., &
1074 default_l_val=.false.)
1078 CALL keyword_create(keyword, __location__, name=
"NONDIAG_ENERGY", &
1079 description=
"Add a non-diagonal auxiliary-energy penalty in direct SCF%OT. "// &
1080 "It is not used by DIAGONALIZATION%OT.", &
1081 usage=
"NONDIAG_ENERGY", lone_keyword_l_val=.true., &
1082 default_l_val=.false.)
1086 CALL keyword_create(keyword, __location__, name=
"NONDIAG_ENERGY_STRENGTH", &
1087 description=
"The prefactor for the non-diagonal energy penalty (FD smearing)", &
1088 usage=
"NONDIAG_ENERGY_STRENGTH", default_r_val=1.0_dp)
1092 END SUBROUTINE create_ot_section
1098 SUBROUTINE create_adiis_section(section)
1103 cpassert(.NOT.
ASSOCIATED(section))
1105 description=
"Parameters for the ADIIS SCF update method.", &
1106 n_keywords=3, n_subsections=0, repeats=.false.)
1110 description=
"Maximum number of paired density/Fock states retained by ADIIS. "// &
1111 "Histories up to 12 use exact active-face enumeration; larger histories use "// &
1112 "deterministic pairwise simplex minimization.", &
1113 usage=
"MAX_HISTORY 7", default_i_val=16)
1118 description=
"Enable safeguarded optimal damping of raw Roothaan steps used to initialize "// &
1119 "or globalize ADIIS. "// &
1120 "ODA supports STANDARD diagonalization, including k-point calculations. "// &
1121 "It is disabled with a warning when HF%ACE is active. "// &
1122 "Smearing remains unsupported for ADIIS and ODA.", &
1123 usage=
"ODA T", default_l_val=.false., lone_keyword_l_val=.true.)
1128 description=
"Print per-iteration ADIIS and ODA diagnostic metrics.", &
1129 usage=
"VERBOSE", lone_keyword_l_val=.true., default_l_val=.false.)
1133 END SUBROUTINE create_adiis_section
1141 SUBROUTINE create_diagonalization_section(section)
1147 cpassert(.NOT.
ASSOCIATED(section))
1148 CALL section_create(section, __location__, name=
"DIAGONALIZATION", &
1149 description=
"Set up type and parameters for Kohn-Sham matrix diagonalization.", &
1150 n_keywords=0, n_subsections=1, repeats=.false.)
1154 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
1155 description=
"controls the activation of the diagonalization method", &
1156 usage=
"&DIAGONALIZATION T", &
1157 default_l_val=.false., &
1158 lone_keyword_l_val=.true.)
1162 CALL keyword_create(keyword, __location__, name=
"UPDATE_METHOD", &
1163 description=
"Selects the SCF update method used with diagonalization. MIXING uses "// &
1164 "the existing density-mixing and DIIS workflow; ADIIS uses augmented-DIIS "// &
1165 "Fock-space interpolation and accepts the diagonalized density directly.", &
1167 enum_c_vals=
s2a(
"MIXING",
"ADIIS"), &
1168 enum_desc=
s2a(
"Use the existing density-mixing SCF workflow", &
1169 "Use augmented-DIIS Fock-space interpolation"), &
1176 description=
"Algorithm to be used for diagonalization", &
1177 usage=
"ALGORITHM STANDARD", &
1179 enum_c_vals=
s2a(
"STANDARD",
"OT",
"LANCZOS",
"DAVIDSON",
"FILTER_MATRIX"), &
1180 enum_desc=
s2a(
"AO-basis Kohn-Sham diagonalization using LAPACK-compatible methods"// &
1181 " or a late-SCF Jacobi sweep.", &
1182 "Iterative diagonalization using OT method", &
1183 "Block Krylov-space approach to self-consistent diagonalisation", &
1184 "Preconditioned blocked Davidson", &
1185 "Filter matrix diagonalization"), &
1191 CALL keyword_create(keyword, __location__, name=
"JACOBI_THRESHOLD", &
1192 description=
"Controls the accuracy of the pseudo-diagonalization method using Jacobi rotations", &
1193 usage=
"JACOBI_THRESHOLD 1.0E-6", &
1194 default_r_val=1.0e-7_dp, &
1200 description=
"Below this threshold value for the SCF convergence the pseudo-diagonalization "// &
1201 "method using Jacobi rotations is activated. This method is much faster than a "// &
1202 "real diagonalization and it is even speeding up while achieving full convergence. "// &
1203 "However, it needs a pre-converged wavefunction obtained by at least one real "// &
1204 "diagonalization which is further optimized while keeping the original eigenvalue "// &
1205 "spectrum. The MO eigenvalues are NOT updated. The method might be useful to speed "// &
1206 "up calculations for large systems e.g. using a semi-empirical method.", &
1207 usage=
"EPS_JACOBI 1.0E-5", &
1208 default_r_val=0.0_dp, &
1214 description=
"Tolerance of the iterative diagonalization relative to the current SCF convergence. "// &
1215 "A positive value makes the inner tolerance the looser of EPS_ITER and this factor "// &
1216 "times the SCF error: loose while the density is far from self-consistency, "// &
1217 "tightening as the SCF converges. The value 0 disables the tracking.", &
1218 usage=
"EPS_ADAPT 0.01", &
1219 default_r_val=0._dp)
1224 description=
"Maximum number of iterations in iterative diagonalization", &
1225 usage=
"MAX_ITER 20", &
1231 description=
"Required accuracy in iterative diagonalization", &
1232 usage=
"EPS_ITER 1.e-8", &
1233 default_r_val=1.e-8_dp)
1237 NULLIFY (subsection)
1238 CALL create_ot_section(subsection, diagonalization=.true.)
1242 NULLIFY (subsection)
1243 CALL create_krylov_section(subsection)
1247 NULLIFY (subsection)
1248 CALL create_diag_subspace_section(subsection)
1252 NULLIFY (subsection)
1253 CALL create_davidson_section(subsection)
1257 NULLIFY (subsection)
1262 END SUBROUTINE create_diagonalization_section
1268 SUBROUTINE create_davidson_section(section)
1273 cpassert(.NOT.
ASSOCIATED(section))
1275 description=
"Settings of the blocked Davidson iterative diagonalization. "// &
1276 "Also available at symmetry-reduced complex k points.", &
1277 n_keywords=2, n_subsections=0, repeats=.false., &
1283 keyword, __location__, name=
"PRECONDITIONER", &
1284 description=
"Type of preconditioner to be used with all minimization schemes. "// &
1285 "With k points, all preconditioners except NONE use the complex "// &
1286 "k-point preconditioners.", &
1287 usage=
"PRECONDITIONER FULL_ALL", &
1289 enum_c_vals=
s2a(
"FULL_ALL",
"FULL_SINGLE_INVERSE",
"FULL_KINETIC",
"FULL_S_INVERSE",
"NONE"), &
1290 enum_desc=
s2a(
"Most effective state selective preconditioner based on diagonalization ", &
1291 "Based on H-eS cholesky inversion, similar to FULL_SINGLE in preconditioning efficiency "// &
1292 "but cheaper to construct, might be somewhat less robust. Recommended for large systems.", &
1293 "Preconditioner based on the kinetic energy matrix", &
1294 "Preconditioner based on the overlap matrix", &
1295 "skip preconditioning"), &
1302 CALL keyword_create(keyword, __location__, name=
"PRECOND_SOLVER", &
1303 description=
"How the preconditioner is applied to the residual.", &
1304 usage=
"PRECOND_SOLVER DIRECT", &
1306 enum_c_vals=
s2a(
"DEFAULT",
"DIRECT",
"INVERSE_CHOLESKY"), &
1307 enum_desc=
s2a(
"the default",
"Cholesky decomposition followed by triangular solve "// &
1308 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)", &
1309 "Cholesky decomposition followed by explicit inversion "// &
1310 "(works for FULL_KINETIC/SINGLE_INVERSE/S_INVERSE)"), &
1318 keyword, __location__, name=
"ENERGY_GAP", &
1319 description=
"Should be an estimate for the energy gap [a.u.] (HOMO-LUMO) and is used in preconditioning, "// &
1320 "especially effective with the FULL_ALL preconditioner, in which case it should be an underestimate "// &
1321 "of the gap (0.001 doing normally fine). For the other preconditioners, making this value larger (0.2)"// &
1322 " will tame the preconditioner in case of poor initial guesses.", &
1323 usage=
"ENERGY_GAP 0.001", &
1324 default_r_val=0.2_dp)
1328 CALL keyword_create(keyword, __location__, name=
"NEW_PREC_EACH", &
1329 description=
"Number of SCF iterations after which a new Preconditioner is computed", &
1330 usage=
"NEW_PREC_EACH 10", default_i_val=20)
1335 description=
"First SCF iteration at which a Preconditioner is employed. "// &
1336 "With k points the first build waits until after the cold start, whatever lower value is set. "// &
1337 "The preconditioner makers read the MO coefficients, and only the cold start fills them.", &
1338 usage=
"FIRST_PREC 1", default_i_val=1)
1342 CALL keyword_create(keyword, __location__, name=
"CONV_MOS_PERCENT", &
1343 description=
"Minimal percent of MOS that have to converge within the Davidson loop"// &
1344 " before the SCF iteration is completed and a new Hamiltonian is computed", &
1345 usage=
"CONV_MOS_PERCENT 0.8", default_r_val=0.5_dp)
1350 description=
"Divisor that maps the SCF mixing error onto the adaptive Davidson tolerance. "// &
1351 "The inner tolerance tracks EPS_ADAPT times the mixing error divided by this value. "// &
1352 "The value approximates how much the per-column residuals amplify the density mixing error. "// &
1353 "A measured amplification on a smeared slab is 20. Increase the value for looser tracking. "// &
1354 "Only used with EPS_ADAPT.", &
1355 usage=
"NOISE_SCALE 100", default_r_val=100.0_dp)
1360 description=
"Use MOS as sparse matrix and avoid as much as possible multiplications with full matrices. "// &
1361 "Not used with k points.", &
1362 usage=
"SPARSE_MOS", default_l_val=.true., &
1363 lone_keyword_l_val=.true.)
1367 END SUBROUTINE create_davidson_section
1373 SUBROUTINE create_krylov_section(section)
1378 cpassert(.NOT.
ASSOCIATED(section))
1381 n_keywords=2, n_subsections=0, repeats=.false.)
1386 description=
"Dimension of the Krylov space used for the Lanczos refinement", &
1387 usage=
"NKRYLOV 20", &
1393 description=
"Size of the block of vectors refined simultaneously by the Lanczos procedure", &
1400 description=
"Convergence criterion for the MOs", &
1401 usage=
"EPS_KRYLOV 0.00001", &
1402 default_r_val=0.0000001_dp)
1406 CALL keyword_create(keyword, __location__, name=
"EPS_STD_DIAG", &
1407 description=
"Level of convergence to be reached before starting the Lanczos procedure."// &
1408 " Above this threshold a standard diagonalization method is used."// &
1409 " If negative Lanczos is started at the first iteration", &
1410 usage=
"EPS_STD_DIAG 0.001", &
1411 default_r_val=-1.0_dp)
1415 CALL keyword_create(keyword, __location__, name=
"CHECK_MOS_CONV", &
1416 description=
"This requires to check the convergence of MOS also when standard "// &
1417 "diagonalization steps are performed, if the block krylov approach is active.", &
1418 usage=
"CHECK_MOS_CONV T", &
1419 default_l_val=.false., &
1420 lone_keyword_l_val=.true.)
1424 END SUBROUTINE create_krylov_section
1430 SUBROUTINE create_diag_subspace_section(section)
1436 cpassert(.NOT.
ASSOCIATED(section))
1437 CALL section_create(section, __location__, name=
"DIAG_SUB_SCF", &
1438 description=
"Activation of self-consistenf subspace refinement by diagonalization "// &
1439 "of H by adjusting the occupation but keeping the MOS unchanged.", &
1440 n_keywords=2, n_subsections=1, repeats=.false.)
1442 NULLIFY (keyword, subsection)
1444 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
1445 description=
"controls the activation of inner SCF loop to refine occupations in MOS subspace", &
1446 usage=
"&DIAG_SUB_SCF T", &
1447 default_l_val=.false., &
1448 lone_keyword_l_val=.true.)
1453 description=
"Maximum number of iterations for the SCF inner loop", &
1454 usage=
"MAX_ITER 20", &
1460 description=
"Required energy accuracy for convergence of subspace diagonalization", &
1461 usage=
"EPS_ENE 1.e-8", &
1462 default_r_val=1.e-4_dp)
1466 CALL keyword_create(keyword, __location__, name=
"EPS_ADAPT_SCF", &
1467 description=
"Required density matrix accuracy as compared to current SCF convergence", &
1468 usage=
"EPS_ADAPT_SCF 1.e-1", &
1469 default_r_val=1._dp)
1474 keyword, __location__, name=
"EPS_SKIP_SUB_DIAG", &
1475 description=
"Level of convergence to be reached before starting the internal loop of subspace rotations."// &
1476 " Above this threshold only the outer diagonalization method is used."// &
1477 " If negative the subspace rotation is started at the first iteration", &
1478 usage=
"EPS_SKIP_SUB_DIAG 0.001", &
1479 default_r_val=-1.0_dp)
1486 END SUBROUTINE create_diag_subspace_section
1495 SUBROUTINE create_smear_section(section)
1501 cpassert(.NOT.
ASSOCIATED(section))
1505 description=
"Controls smearing of MO occupation numbers for systems with small or zero gaps.", &
1513 name=
"_SECTION_PARAMETERS_", &
1514 description=
"Controls the activation of smearing", &
1515 usage=
"&SMEAR ON", &
1516 default_l_val=.false., &
1517 lone_keyword_l_val=.true.)
1523 description=
"Selects the smearing method to apply.", &
1524 usage=
"METHOD Fermi_Dirac", &
1526 enum_c_vals=
s2a(
"FERMI_DIRAC",
"ENERGY_WINDOW",
"LIST",
"GAUSSIAN", &
1527 "METHFESSEL_PAXTON",
"MARZARI_VANDERBILT"), &
1530 enum_desc=
s2a(
"Fermi-Dirac distribution defined by the keyword ELECTRONIC_TEMPERATURE. "// &
1531 "Use this method if the temperature equivalence is important for you, "// &
1532 "e.g. if you want to compute some properties based on the occupations. "// &
1533 "If you use this method without interest in electronic temperature, "// &
1534 "it's suggested to use extrapolated result from finite ELECTRONIC_TEMPERATURE "// &
1535 "to ELECTRONIC_TEMPERATURE = 0. Note the forces and stress are consistent "// &
1536 "with the free energy and not with the extrapolated energy.", &
1537 "Energy window defined by the keyword WINDOW_SIZE.", &
1538 "Use a fixed list of occupations.", &
1539 "Gaussian broadening with width SIGMA; should work well in most cases. "// &
1540 "With this method you have to use extrapolated results from finite "// &
1541 "SIGMA results to SIGMA = 0, but usually this value would not be quite "// &
1542 "accurate without systematically reducing SIGMA. Note the forces and stress "// &
1543 "are consistent with the free energy and not with the extrapolated energy.", &
1544 "First-order Methfessel-Paxton distribution with width SIGMA. Don't "// &
1545 "use it for semiconductors and insulators because the partial "// &
1546 "occupancies can be unphysical and thus lead to wrong results.", &
1547 "Marzari-Vanderbilt cold smearing with width SIGMA."))
1553 description=
"A list of fractional occupations to use. Must match the number of states "// &
1554 "and sum up to the correct number of electrons", &
1558 usage=
"LIST 2.0 0.6666 0.6666 0.66666 0.0 0.0")
1563 name=
"ELECTRONIC_TEMPERATURE", &
1564 variants=
s2a(
"ELEC_TEMP",
"TELEC"), &
1565 description=
"Electronic temperature used for Fermi-Dirac smearing.", &
1571 usage=
"ELECTRONIC_TEMPERATURE [K] 300")
1576 name=
"EPS_FERMI_DIRAC", &
1577 description=
"Accuracy checks on occupation numbers use this as a tolerance", &
1581 default_r_val=1.0e-10_dp, &
1582 usage=
"EPS_FERMI_DIRAC 1.0E-6")
1588 description=
"Smearing width sigma (in energy units) in the case of "// &
1589 "Gaussian, Methfessel-Paxton or Marzari-Vanderbilt smearing.", &
1593 default_r_val=0.002_dp, &
1595 usage=
"SIGMA [eV] 0.2")
1600 name=
"WINDOW_SIZE", &
1601 description=
"Size of the energy window centred at the Fermi level", &
1605 default_r_val=0.0_dp, &
1607 usage=
"WINDOW_SIZE [eV] 0.3")
1611 CALL keyword_create(keyword, __location__, name=
"FIXED_MAGNETIC_MOMENT", &
1612 description=
"Imposed difference between the numbers of electrons of spin up "// &
1613 "and spin down: m = n(up) - n(down). A negative value (default) allows "// &
1614 "for a change of the magnetic moment. -1 specifically keeps an integer "// &
1615 "number of spin up and spin down electrons.", &
1619 default_r_val=-100.0_dp, &
1620 usage=
"FIXED_MAGNETIC_MOMENT 1.5")
1624 END SUBROUTINE create_smear_section
1634 TYPE(
section_type),
POINTER :: group_section, print_key, subsection
1636 NULLIFY (keyword, subsection, group_section, print_key)
1638 cpassert(.NOT.
ASSOCIATED(section))
1640 description=
"Parameters needed to set up a constrained DFT calculation."// &
1641 " Each repetition of the ATOM_GROUP section defines a new constraint."// &
1642 " The constraint(s) is (are) converged in a separate external SCF loop with settings"// &
1643 " read from the OUTER_SCF section. Supported constraints: Becke and Gaussian"// &
1644 " Hirshfeld (partial).", n_keywords=8, n_subsections=2, &
1647 NULLIFY (subsection, keyword)
1648 CALL create_outer_scf_section(subsection)
1652 CALL create_becke_constraint_section(subsection)
1656 CALL create_hirshfeld_constraint_section(subsection)
1660 CALL keyword_create(keyword, __location__, name=
"TYPE_OF_CONSTRAINT", &
1661 description=
"Specifies the type of constraint used.", &
1662 usage=
"TYPE_OF_CONSTRAINT (NONE|HIRSHFELD|BECKE)", &
1663 enum_c_vals=
s2a(
"NONE",
"HIRSHFELD",
"BECKE"), &
1666 enum_desc=
s2a(
"No constraint (disables section).", &
1667 "Gaussian Hirshfeld constraint. Partial implementation: no forces. "// &
1668 "Requires corresponding section. Not as extensively tested.", &
1669 "Becke constraint. Requires corresponding section."), &
1676 description=
"Constraint force constants (Lagrange multipliers). "// &
1677 "Give one value per constraint group.", &
1678 type_of_var=
real_t, n_var=-1, &
1679 default_r_val=0.0_dp)
1684 description=
"Constraint target values. Give one value per constraint group. "// &
1685 "The target value is the desired number of valence electrons, spin moment, or the number of "// &
1686 "alpha or beta electrons on the atoms that define the constraint, suitably multiplied by "// &
1687 "atomic coefficients in case a relative constraint between two sets of atoms is employed. "// &
1688 "Note that core charges are not subtracted from the target value.", &
1689 usage=
"TARGET {real}", repeats=.false., &
1690 type_of_var=
real_t, n_var=-1, &
1691 default_r_val=0.0_dp)
1695 CALL keyword_create(keyword, __location__, name=
"ATOMIC_CHARGES", &
1696 description=
"Calculate atomic CDFT charges with selected weight function"// &
1697 " (Z = Z_core - Z_CDFT). With fragment based constraints, charges are"// &
1698 " relative to the fragment reference state i.e. Z = Z_CDFT -"// &
1699 " Z_frag_reference. Note: if the number of atoms is greater than the"// &
1700 " default pw_pool max cache, calculation of atomic CDFT charges"// &
1701 " will prompt harmless warnings during deallocation of atomic grids.", &
1702 usage=
"ATOMIC_CHARGES", &
1703 default_l_val=.false., lone_keyword_l_val=.true.)
1707 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_A_FILE_NAME", variants=[
"FRAGMENT_A_FILE"], &
1708 description=
"Name of the reference total electron density cube file for fragment A."// &
1709 " May include a path. The reference electron density needs to be outputted"// &
1710 " on the same grid as the full system (same cutoff and cell, output stride 1)."// &
1711 " For GAPW, generate the cube with E_DENSITY_CUBE% DENSITY_INCLUDE TOTAL_DENSITY;"// &
1712 " a regular GAPW electron-density cube contains only the soft density and is rejected.", &
1713 usage=
"FRAGMENT_A_FILE_NAME <FILENAME>", &
1714 default_lc_val=
"fragment_a.cube")
1718 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_B_FILE_NAME", variants=[
"FRAGMENT_B_FILE"], &
1719 description=
"Name of the reference total electron density cube file for fragment B."// &
1720 " May include a path. The reference electron density needs to be outputted"// &
1721 " on the same grid as the full system (same cutoff and cell, output stride 1)."// &
1722 " For GAPW, generate the cube with E_DENSITY_CUBE% DENSITY_INCLUDE TOTAL_DENSITY;"// &
1723 " a regular GAPW electron-density cube contains only the soft density and is rejected.", &
1724 usage=
"FRAGMENT_B_FILE_NAME <FILENAME>", &
1725 default_lc_val=
"fragment_b.cube")
1729 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_A_SPIN_FILE", &
1730 variants=[
"FRAGMENT_A_SPIN_FILE_NAME"], &
1731 description=
"Name of the reference spin density cube file for fragment A."// &
1732 " May include a path. The reference spin density needs to be outputted"// &
1733 " on the same grid as the full system (same cutoff and cell, output stride 1)."// &
1734 " For GAPW, use the TOTAL_SPIN_DENSITY cube generated together with"// &
1735 " E_DENSITY_CUBE% DENSITY_INCLUDE TOTAL_DENSITY.", &
1736 usage=
"FRAGMENT_A_SPIN_FILE <FILENAME>", &
1737 default_lc_val=
"fragment_a_spin.cube")
1741 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_B_SPIN_FILE", &
1742 variants=[
"FRAGMENT_B_SPIN_FILE_NAME"], &
1743 description=
"Name of the reference spin density cube file for fragment B."// &
1744 " May include a path. The reference spin density needs to be outputted"// &
1745 " on the same grid as the full system (same cutoff and cell, output stride 1)."// &
1746 " For GAPW, use the TOTAL_SPIN_DENSITY cube generated together with"// &
1747 " E_DENSITY_CUBE% DENSITY_INCLUDE TOTAL_DENSITY.", &
1748 usage=
"FRAGMENT_B_SPIN_FILE <FILENAME>", &
1749 default_lc_val=
"fragment_b_spin.cube")
1753 CALL keyword_create(keyword, __location__, name=
"FLIP_FRAGMENT_A", &
1754 description=
"Logical which determines if the reference spin difference density "// &
1755 "(rho_alpha-rho_beta) for fragment A should be flipped. With default (off) "// &
1756 "value, the fragment is constrained to have more alpha than beta electrons "// &
1757 "if the isolated fragment has unpaired electrons. Useful in conjunction with "// &
1758 "FLIP_FRAGMENT_B.", &
1759 usage=
"FLIP_FRAGMENT_A", &
1760 default_l_val=.false., lone_keyword_l_val=.true.)
1764 CALL keyword_create(keyword, __location__, name=
"FLIP_FRAGMENT_B", &
1765 description=
"Logical which determines if the reference spin difference density "// &
1766 "(rho_alpha-rho_beta) for fragment B should be flipped. With default (off) "// &
1767 "value, the fragment is constrained to have more alpha than beta electrons "// &
1768 "if the isolated fragment has unpaired electrons. Useful in conjunction with "// &
1769 "FLIP_FRAGMENT_A.", &
1770 usage=
"FLIP_FRAGMENT_B", &
1771 default_l_val=.false., lone_keyword_l_val=.true.)
1776 description=
"Controls the printing of basic info about the method.", &
1779 CALL section_create(subsection, __location__, name=
"WEIGHT_FUNCTION", &
1780 description=
"Controls the printing of cube files with "// &
1781 "the CDFT weight function(s). Intended for single-point testing. "// &
1782 "In multistep simulations, generated cube files are overwritten each step.", &
1783 n_keywords=1, n_subsections=0, repeats=.false.)
1786 description=
"The stride (X,Y,Z) used to write the cube file "// &
1787 "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
1788 " 1 number valid for all components.", &
1789 usage=
"STRIDE 2 2 2", n_var=-1, default_i_vals=[2, 2, 2], type_of_var=
integer_t)
1799 CALL section_create(group_section, __location__, name=
"ATOM_GROUP", &
1800 description=
"Define a group of atoms for use in a CDFT constraint. Each repetition of "// &
1801 "this section creates a new constraint.", &
1802 n_keywords=4, n_subsections=0, repeats=.true.)
1805 description=
"Specifies the list of atoms that are included in the constraint group.", &
1806 usage=
"ATOMS {integer} {integer} .. {integer}", &
1812 description=
"Defines coefficients for the atoms in the list of atoms. Accepts values +/-1.0.", &
1813 usage=
"COEFF 1.0 -1.0", repeats=.true., &
1814 type_of_var=
real_t, n_var=-1)
1818 CALL keyword_create(keyword, __location__, name=
"CONSTRAINT_TYPE ", &
1819 description=
"Determines what type of constraint to apply. ", &
1820 usage=
"CONSTRAINT_TYPE (CHARGE|MAGNETIZATION|ALPHA|BETA)", &
1821 enum_c_vals=
s2a(
"CHARGE",
"MAGNETIZATION",
"ALPHA",
"BETA"), &
1824 enum_desc=
s2a(
"Total charge density constraint (rho_alpha + rho_beta).", &
1825 "Magnetization density constraint (rho_alpha - rho_beta).", &
1826 "Alpha spin density constraint.", &
1827 "Beta spin density constraint."), &
1832 CALL keyword_create(keyword, __location__, name=
"FRAGMENT_CONSTRAINT", &
1833 description=
"Use a fragment based constraint. "// &
1834 "Takes as input the electron densities of two isolated fragments in the "// &
1835 "same geometry that they have in the full system. "// &
1836 "The isolated fragment densities are read from cube files defined in FRAGMENT_{A,B}_FILE. "// &
1837 "For magnetization density constraints, additional files containing the spin difference "// &
1838 "densities must be defined with the keywords FRAGMENT_{A,B}_SPIN_FILE. "// &
1839 "With this keyword active, the target value of the constraint is calculated from the "// &
1840 "the superposition of the isolated fragment densities. Supports only static calculations.", &
1841 usage=
"FRAGMENT_CONSTRAINT", &
1842 default_l_val=.false., lone_keyword_l_val=.true.)
1849 CALL section_create(group_section, __location__, name=
"DUMMY_ATOMS", &
1850 description=
"Define an extra group of atoms for which only atomic CDFT charges "// &
1851 "should be computed. The section cannot contain any constraint "// &
1852 "atoms that were included in section ATOM_GROUP.", &
1853 n_keywords=1, n_subsections=0, repeats=.true.)
1856 description=
"Specifies the list of atoms that are included in the DUMMY_ATOMS group.", &
1857 usage=
"ATOMS {integer} {integer} .. {integer}", &
1865 CALL keyword_create(keyword, __location__, name=
"REUSE_PRECOND", &
1866 description=
"Reuse a previously built OT preconditioner between subsequent CDFT SCF iterations "// &
1867 "if the inner OT SCF loop converged in PRECOND_FREQ steps or less. Intended mainly for MD "// &
1868 "simulations with the FULL_ALL preconditioner to speed up the final iterations of the CDFT SCF loop.", &
1869 usage=
"REUSE_PRECOND yes", repeats=.false., n_var=1, &
1870 default_l_val=.false., lone_keyword_l_val=.true.)
1874 CALL keyword_create(keyword, __location__, name=
"PRECOND_FREQ", &
1875 description=
"See REUSE_PRECOND.", &
1876 usage=
"PRECOND_FREQ {int}", default_i_val=0)
1881 description=
"Determines how many times a previously built preconditioner can be reused.", &
1882 usage=
"MAX_REUSE {int}", default_i_val=0)
1886 CALL keyword_create(keyword, __location__, name=
"PURGE_HISTORY", &
1887 description=
"Purge wavefunction and constraint history to improve SCF convergence during MD."// &
1888 " Counts how often the convergence of the first CDFT SCF iteration takes 2 or more outer SCF"// &
1889 " iterations and purges the history if the counter exceeds PURGE_FREQ, and PURGE_OFFSET"// &
1890 " MD steps have passed since the last purge."// &
1891 " The counter is zeroed after each purge.", &
1892 usage=
"PURGE_HISTORY yes", repeats=.false., n_var=1, &
1893 default_l_val=.false., lone_keyword_l_val=.true.)
1898 description=
"See PURGE_HISTORY.", &
1899 usage=
"PURGE_FREQ {int} ", default_i_val=1)
1903 CALL keyword_create(keyword, __location__, name=
"PURGE_OFFSET", &
1904 description=
"See PURGE_HISTORY.", &
1905 usage=
"PURGE_OFFSET {int} ", default_i_val=1)
1910 description=
"A counter to track the total number of energy evaluations. Needed by"// &
1911 " some optimizers to print information. Useful mainly for restarts.", &
1912 usage=
"COUNTER {int} ", default_i_val=0)
1917 description=
"Precompute gradients due to constraint during"// &
1918 " initial formation of constraint and store them in memory. Does"// &
1919 " nothing if forces are not calculated.", &
1920 usage=
"IN_MEMORY", &
1921 default_l_val=.false., lone_keyword_l_val=.true.)
1931 SUBROUTINE create_hirshfeld_constraint_section(section)
1938 cpassert(.NOT.
ASSOCIATED(section))
1939 CALL section_create(section, __location__, name=
"HIRSHFELD_CONSTRAINT", &
1940 description=
"Parameters for CDFT with a Gaussian Hirshfeld constraint.", &
1941 n_keywords=11, n_subsections=0, repeats=.false.)
1943 CALL keyword_create(keyword, __location__, name=
"SHAPE_FUNCTION", &
1944 description=
"Type of shape function used for Hirshfeld partitioning.", &
1945 usage=
"SHAPE_FUNCTION {Gaussian,Density}", repeats=.false., n_var=1, &
1947 enum_c_vals=
s2a(
"GAUSSIAN",
"DENSITY"), &
1948 enum_desc=
s2a(
"One Gaussian per atom with radius determined by the keyword GAUSSIAN_SHAPE.", &
1949 "Atomic density expanded in terms of multiple Gaussians."), &
1954 CALL keyword_create(keyword, __location__, name=
"GAUSSIAN_SHAPE", &
1955 description=
"Specifies the type of Gaussian used for SHAPE_FUNCTION GAUSSIAN.", &
1956 usage=
"GAUSSIAN_SHAPE (SINGLE|VDW|COVALENT|USER)", &
1957 enum_c_vals=
s2a(
"DEFAULT",
"SINGLE",
"VDW",
"COVALENT",
"USER"), &
1959 enum_desc=
s2a(
"Use covalent radii (in angstrom) to construct Gaussians, but fixed"// &
1960 " 1.0_dp radius for elements with a radius larger than this value.", &
1961 "Single Gaussian for all atom types with radius given by GAUSSIAN_RADIUS.", &
1962 "Use van der Waals radii to construct Gaussians.", &
1963 "Use covalent radii to construct Gaussians.", &
1964 "Use user defined radii (keyword ATOMIC_RADII) to construct Gaussians."), &
1969 CALL keyword_create(keyword, __location__, name=
"GAUSSIAN_RADIUS", &
1970 description=
"Radius parameter controlling the creation of Gaussians.", &
1971 usage=
"GAUSSIAN_RADIUS <REAL>", &
1972 unit_str=
"angstrom", &
1974 type_of_var=
real_t, n_var=1)
1978 CALL keyword_create(keyword, __location__, name=
"ATOMIC_RADII", &
1979 description=
"Defines custom radii to setup the spherical Gaussians. "// &
1980 "Give one value per element in the same order as they "// &
1981 "appear in the input coordinates.", &
1982 usage=
"ATOMIC_RADII {real} {real} {real}", repeats=.false., &
1983 unit_str=
"angstrom", &
1984 type_of_var=
real_t, n_var=-1)
1989 description=
"Convert the Gaussian radius from angstrom to bohr. This results in a larger "// &
1990 "Gaussian than without unit conversion.", &
1991 usage=
"USE_BOHR .TRUE.", &
1992 default_l_val=.false., lone_keyword_l_val=.true.)
1996 CALL keyword_create(keyword, __location__, name=
"PRINT_DENSITY", &
1997 description=
"Logical to control printing of Hirshfeld densities to .cube file.", &
1998 usage=
"PRINT_DENSITY TRUE", &
1999 default_l_val=.false., lone_keyword_l_val=.true.)
2003 CALL keyword_create(keyword, __location__, name=
"ATOMS_MEMORY", &
2004 description=
"Number of atomic gradients to store in memory.", &
2005 usage=
"ATOMS_MEMORY", &
2011 CALL keyword_create(keyword, __location__, name=
"USE_ATOMIC_CUTOFF", &
2012 description=
"Logical to control use of ATOMIC_CUTOFF.", &
2013 usage=
"USE_ATOMIC_CUTOFF TRUE", &
2014 default_l_val=.true., lone_keyword_l_val=.true.)
2019 description=
"Numerical cutoff for calculation of weight function.", &
2020 usage=
"EPS_CUTOFF {real} ", default_r_val=1.0e-12_dp)
2024 CALL keyword_create(keyword, __location__, name=
"ATOMIC_CUTOFF", &
2025 description=
"Numerical cutoff for calculation of Hirshfeld densities.", &
2026 usage=
"ATOMIC_CUTOFF {real} ", default_r_val=1.0e-12_dp)
2030 END SUBROUTINE create_hirshfeld_constraint_section
2036 SUBROUTINE create_becke_constraint_section(section)
2042 cpassert(.NOT.
ASSOCIATED(section))
2043 CALL section_create(section, __location__, name=
"BECKE_CONSTRAINT", &
2044 description=
"Define settings influencing the construction of the Becke weight function.", &
2045 n_keywords=13, repeats=.false., citations=[
becke1988b])
2048 description=
"Adjust Becke cell boundaries with atomic"// &
2049 " radii to generate a heteronuclear cutoff profile. These"// &
2050 " radii are defined with the keyword ATOMIC_RADII.", &
2051 usage=
"ADJUST_SIZE", &
2052 default_l_val=.false., lone_keyword_l_val=.true.)
2056 CALL keyword_create(keyword, __location__, name=
"ATOMIC_RADII", &
2057 description=
"Defines atomic radii to generate a heteronuclear cutoff profile."// &
2058 " Give one value per element in the same order as they"// &
2059 " appear in the input coordinates.", &
2060 usage=
"ATOMIC_RADII {real} {real} {real}", repeats=.false., &
2061 unit_str=
"angstrom", &
2062 type_of_var=
real_t, n_var=-1)
2067 description=
"If grid point is farther than GLOBAL_CUTOFF from all constraint atoms, "// &
2068 "move directly to next grid point, thus saving computational resources.", &
2069 usage=
"SHOULD_SKIP", &
2070 default_l_val=.false., lone_keyword_l_val=.true.)
2074 CALL keyword_create(keyword, __location__, name=
"CAVITY_CONFINE", &
2075 description=
"Activates Gaussian cavity confinement. The constraint is evaluated only inside "// &
2076 "the cavity. The cavity is formed by summing spherical Gaussians centered on the constraint atoms.", &
2077 usage=
"CAVITY_CONFINE", &
2078 default_l_val=.false., lone_keyword_l_val=.true.)
2082 CALL keyword_create(keyword, __location__, name=
"CAVITY_SHAPE", &
2083 description=
"Specifies the type of Gaussian cavity used.", &
2084 usage=
"CAVITY_SHAPE (SINGLE|VDW|COVALENT|USER)", &
2085 enum_c_vals=
s2a(
"DEFAULT",
"SINGLE",
"VDW",
"COVALENT",
"USER"), &
2087 enum_desc=
s2a(
"Use covalent radii (in angstrom) to construct Gaussians, but fixed"// &
2088 " 1.0_dp radius for elements with a radius larger than this value.", &
2089 "Single Gaussian for all atom types with radius given by CAVITY_RADIUS.", &
2090 "Use van der Waals radii to construct Gaussians.", &
2091 "Use covalent radii to construct Gaussians.", &
2092 "Use user defined radii (keyword ATOMIC_RADII) to construct Gaussians."), &
2097 CALL keyword_create(keyword, __location__, name=
"CAVITY_USE_BOHR", &
2098 description=
"Convert the cavity radius from angstrom to bohr. This results in a larger"// &
2099 " confinement cavity than without unit conversion.", &
2100 usage=
"CAVITY_USE_BOHR TRUE", &
2101 default_l_val=.false., lone_keyword_l_val=.true.)
2105 CALL keyword_create(keyword, __location__, name=
"CAVITY_PRINT", &
2106 description=
"Print cavity in Gaussian cube file format. Currently, printing options"// &
2107 " are hardcoded.", &
2108 usage=
"CAVITY_PRINT", &
2109 default_l_val=.false., lone_keyword_l_val=.true.)
2113 CALL keyword_create(keyword, __location__, name=
"CAVITY_RADIUS", &
2114 description=
"Radius parameter controlling the creation of Gaussian cavity confinement.", &
2115 usage=
"CAVITY_RADIUS <REAL>", &
2116 unit_str=
"angstrom", &
2118 type_of_var=
real_t, n_var=1)
2123 description=
"Density threshold for cavity creation. Grid points where the Gaussian"// &
2124 " density falls below the threshold are ignored.", &
2125 usage=
"EPS_CAVITY {real} ", default_r_val=1.0e-6_dp)
2130 description=
"Specifies the type of cutoff used when building the Becke weight function.", &
2131 usage=
"CUTOFF_TYPE (GLOBAL|ELEMENT)", &
2132 enum_c_vals=
s2a(
"GLOBAL",
"ELEMENT"), &
2134 enum_desc=
s2a(
"Use a single value for all elements. Read from GLOBAL_CUTOFF.", &
2135 "Use a different value for all elements. Values read from ELEMENT_CUTOFF."), &
2140 CALL keyword_create(keyword, __location__, name=
"GLOBAL_CUTOFF", &
2141 description=
"Parameter used to select which atoms contribute to the"// &
2142 " weight function at each real space grid point.", &
2143 usage=
"GLOBAL_CUTOFF <REAL>", &
2144 unit_str=
"angstrom", &
2146 type_of_var=
real_t, n_var=1)
2150 CALL keyword_create(keyword, __location__, name=
"ELEMENT_CUTOFF", &
2151 description=
"Defines element specific cutoffs to decide which atoms contribute to the"// &
2152 " weight function at each real space grid point. Give one value per element in the same"// &
2153 " order as they appear in the coordinates.", &
2154 usage=
"ELEMENT_CUTOFF {real} {real} {real}", repeats=.false., &
2155 unit_str=
"angstrom", &
2156 type_of_var=
real_t, n_var=-1)
2161 description=
"Precompute gradients due to Becke constraint during"// &
2162 " initial formation of constraint and store them in memory. Useful"// &
2163 " in combination with confinement, memory intensive otherwise. Does"// &
2164 " nothing if forces are not calculated.", &
2165 usage=
"IN_MEMORY", &
2166 default_l_val=.false., lone_keyword_l_val=.true.)
2170 END SUBROUTINE create_becke_constraint_section
2179 SUBROUTINE create_cdft_opt_section(section)
2184 cpassert(.NOT.
ASSOCIATED(section))
2186 description=
"Parameters controlling optimization methods that are compatible "// &
2187 "only with CDFT based constraints (i.e. CDFT SCF is active). Specifically, "// &
2188 "the control parameters for the Broyden and Newton optimizers are defined in this "// &
2190 n_keywords=10, n_subsections=0, repeats=.false.)
2194 CALL keyword_create(keyword, __location__, name=
"BROYDEN_TYPE", &
2195 description=
"Specifies the Broyden optimizer variant to use.", &
2196 usage=
"BROYDEN_TYPE BT1", &
2198 enum_c_vals=
s2a(
"BT1",
"BT1_EXPLICIT",
"BT2",
"BT2_EXPLICIT", &
2199 "BT1_LS",
"BT1_EXPLICIT_LS",
"BT2_LS",
"BT2_EXPLICIT_LS"), &
2200 enum_desc=
s2a(
"Broyden's first method, also known as the good method. The initial Jacobian"// &
2201 " is built from MD history if available. Otherwise switches to SD for one"// &
2202 " SCF iteration until a Jacobian can be built from the SCF history.", &
2203 "Same as BT1, but computes the explicit Jacobian with finite differences. "// &
2204 "Requires a CDFT SCF procedure to be active.", &
2205 "Same as BT1, but uses Broyden's second method, also known as the bad method.", &
2206 "Same as BT1_EXPLICIT, but using Broyden's second method.", &
2207 "Same as BT1, but uses backtracking line search for optimizing the step size "// &
2208 "(see optimizer NEWTON_LS).", &
2209 "Same as BT1_EXPLICIT, but uses backtracking line search for optimizing the step size.", &
2210 "Same as BT2, but uses backtracking line search for optimizing the step size.", &
2211 "Same as BT2_EXPLICIT, but uses backtracking line search for optimizing the step size."), &
2218 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_TYPE", &
2219 description=
"Finite difference method used to calculate the inverse Jacobian "// &
2220 "needed by some optimizers. Compatible only with CDFT constraints.", &
2221 usage=
"JACOBIAN_TYPE FD1", &
2223 enum_c_vals=
s2a(
"FD1",
"FD1_BACKWARD",
"FD2",
"FD2_BACKWARD",
"FD1_CENTRAL"), &
2224 enum_desc=
s2a(
"First order forward difference (one extra energy evaluation per constraint).", &
2225 "First order backward difference (one extra energy evaluation per constraint).", &
2226 "Second order forward difference (two extra energy evaluations per constraint).", &
2227 "Second order backward difference (two extra energy evaluations per constraint).", &
2228 "First order central difference (two extra energy evaluations per constraint)."), &
2234 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_STEP", &
2235 description=
"Step size to use in the calculation of the inverse Jacobian with finite differences. "// &
2236 "Expects one value for all constraints, or one value per constraint.", &
2237 usage=
"JACOBIAN_STEP 5.0E-3 ", n_var=-1, default_r_val=5.0e-3_dp)
2241 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_FREQ", &
2242 description=
"Defines parameters that control how often the explicit Jacobian is built,"// &
2243 " which is needed by some optimizers. Expects two values. The first value"// &
2244 " determines how many consecutive CDFT SCF iterations should skip a rebuild,"// &
2245 " whereas the latter how many MD steps. The values can be zero (meaning never"// &
2246 " rebuild) or positive. Both values cannot be zero.", &
2247 usage=
"JACOBIAN_FREQ 1 1", n_var=2, &
2248 default_i_vals=[1, 1], type_of_var=
integer_t)
2252 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_RESTART", &
2253 description=
"Restart the inverse Jacobian using the vector defined with keyword JACOBIAN_VECTOR.", &
2254 usage=
"JACOBIAN_RESTART TRUE", &
2255 default_l_val=.false., lone_keyword_l_val=.true.)
2259 CALL keyword_create(keyword, __location__, name=
"JACOBIAN_VECTOR", &
2260 description=
"Defines the inverse Jacobian matrix. Useful for restarting calculations. "// &
2261 "Expects n^2 values where n is the total number of constraints. "// &
2262 "The matrix should be given in row major order.", &
2263 usage=
"JACOBIAN_VECTOR 1.0 0.0", n_var=-1, type_of_var=
real_t)
2268 description=
"The maximum number of backtracking line search steps to perform.", &
2269 usage=
"MAX_LS 5", default_i_val=5)
2274 description=
"Control parameter for backtracking line search. The step size is reduced by "// &
2275 "this factor on every line search iteration. Value must be between 0 and 1 (exclusive).", &
2276 usage=
"FACTOR_LS 0.5", default_r_val=0.5_dp)
2281 description=
"Continue backtracking line search until MAX_LS steps are reached or the "// &
2282 "norm of the CDFT gradient no longer decreases. Default (false) behavior exits the "// &
2283 "line search procedure on the first step that the gradient decreases.", &
2284 usage=
"CONTINUE_LS TRUE", &
2285 default_l_val=.false., lone_keyword_l_val=.true.)
2289 END SUBROUTINE create_cdft_opt_section
2298 SUBROUTINE create_gce_section(section)
2304 cpassert(.NOT.
ASSOCIATED(section))
2308 description=
"Enables grand canonical SCF calculations for "// &
2309 "slab models with a target work function specified by the "// &
2310 "user. The current implementation is intended for three "// &
2311 "dimensional periodic calculations and should be used "// &
2312 "together with the planar counter charge model. The planar "// &
2313 "counter charge screens the net charge of the DFT slab, so "// &
2314 "that the work function can be obtained from the planar "// &
2315 "averaged Hartree potential in the implicit solvent region "// &
2316 "or vacuum region. During the SCF iterations, the work "// &
2317 "function is mixed toward the target value. "// &
2318 "The reported GCE charges during SCF iterations are the "// &
2319 "current net charge of the DFT system excluding the planar "// &
2320 "counter charge. A positive value means electron deficiency. "// &
2321 "The input CHARGE value in the DFT section defines the "// &
2322 "reference charge state. The quantity N_e^(abs,alpha) is "// &
2323 "evaluated as the input CHARGE value minus the reported GCE "// &
2324 "charge. The reported GCE free energy is the sum of the DFT "// &
2325 "total energy and the product of the target work function "// &
2326 "and N_e^(abs,alpha).", &
2335 name=
"_SECTION_PARAMETERS_", &
2336 description=
"Controls the activation of grand canonical SCF", &
2338 default_l_val=.false., &
2339 lone_keyword_l_val=.true.)
2344 name=
"TARGET_WORKFUNCTION", &
2345 description=
"The user input target work function of the symmetric slab model", &
2349 default_r_val=0.16_dp, &
2351 usage=
"TARGET_WORKFUNCTION [eV] 0.16")
2356 name=
"MIXING_COEF", &
2357 description=
"The proportion of the target work function mixed with the "// &
2358 "work function of the previous SCF iteration", &
2362 default_r_val=0.3_dp, &
2363 usage=
"MIXING_COEF 0.3")
2367 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 blaha2010
integer, save, public holmberg2017
integer, save, public vandevondele2005a
integer, save, public schiffmann2015
integer, save, public hu2010
integer, save, public weber2008
integer, save, public kressefurthmueller1996
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