43#include "./base/base_uses.f90"
48 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'input_cp2k_ls'
64 cpassert(.NOT.
ASSOCIATED(section))
66 description=
"Specifies the parameters of the linear scaling SCF routines", &
67 n_keywords=24, n_subsections=3, repeats=.false., &
70 NULLIFY (keyword, subsection)
73 description=
"Perform DIIS within linear scaling SCF", &
74 usage=
"LS_DIIS", lone_keyword_l_val=.true., &
75 default_l_val=.false.)
80 description=
"Iteration cycle to start DIIS Kohn-Sham matrix update", &
81 usage=
"INI_DIIS 2", default_i_val=2)
86 description=
"Size of LS_DIIS buffer", &
87 usage=
"MAX_DIIS 4", default_i_val=4)
92 description=
"Minimal number of density mixing before start DIIS", &
93 usage=
"NMIXING 2", default_i_val=2)
98 description=
"Threshold on the convergence to start using DIIS", &
99 usage=
"EPS_DIIS 1.e-1", default_r_val=1.e-1_dp)
104 description=
"Maximum number of SCF iteration to be performed for one optimization", &
105 usage=
"MAX_SCF 200", default_i_val=20)
110 keyword, __location__, name=
"EPS_SCF", &
111 description=
"Target accuracy for the SCF convergence in terms of change of the total energy per electron.", &
112 usage=
"EPS_SCF 1.e-6", default_r_val=1.e-7_dp)
116 CALL keyword_create(keyword, __location__, name=
"MIXING_FRACTION", &
117 description=
"Mixing density matrices uses the specified fraction in the SCF procedure.", &
118 usage=
"MIXING_FRACTION 0.4", default_r_val=0.45_dp)
123 description=
"Threshold used for filtering matrix operations.", &
124 usage=
"EPS_FILTER 1.0E-7", default_r_val=1.0e-6_dp)
129 description=
"Threshold used for lanczos estimates.", &
130 usage=
"EPS_LANCZOS 1.0E-4", default_r_val=1.0e-3_dp)
134 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LANCZOS", &
135 description=
"Maximum number of lanczos iterations.", &
136 usage=
"MAX_ITER_LANCZOS ", default_i_val=128)
141 description=
"Value (or initial guess) for the chemical potential,"// &
142 " i.e. some suitable energy between HOMO and LUMO energy.", &
143 usage=
"MU 0.0", default_r_val=-0.1_dp)
148 description=
"Should the calculation be performed at fixed chemical potential,"// &
149 " or should it be found fixing the number of electrons", &
150 usage=
"FIXED_MU .TRUE.", default_l_val=.false., lone_keyword_l_val=.true.)
154 CALL keyword_create(keyword, __location__, name=
"EXTRAPOLATION_ORDER", &
155 description=
"Number of previous matrices used for the ASPC extrapolation of the initial guess. "// &
156 "0 implies that an atomic guess is used at each step. "// &
157 "low (1-2) will result in a drift of the constant of motion during MD. "// &
158 "high (>5) might be somewhat unstable, leading to more SCF iterations.", &
159 usage=
"EXTRAPOLATION_ORDER 3", default_i_val=4)
163 CALL keyword_create(keyword, __location__, name=
"S_PRECONDITIONER", &
164 description=
"Preconditions S with some appropriate form.", &
165 usage=
"S_PRECONDITIONER MOLECULAR", &
167 enum_c_vals=
s2a(
"NONE",
"ATOMIC",
"MOLECULAR"), &
168 enum_desc=
s2a(
"No preconditioner", &
169 "Using atomic blocks", &
170 "Using molecular sub-blocks. Recommended if molecules are defined and not too large."), &
175 CALL keyword_create(keyword, __location__, name=
"S_SQRT_METHOD", &
176 description=
"Method for the caclulation of the sqrt of S.", &
177 usage=
"S_SQRT_METHOD NEWTONSCHULZ", &
179 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT"), &
180 enum_desc=
s2a(
"Using a Newton-Schulz-like iteration", &
181 "Using the p-th root method."), &
187 variants=
s2a(
"SIGN_SQRT_ORDER"), &
188 description=
"Order of the iteration method for the calculation of the sqrt of S.", &
189 usage=
"S_SQRT_ORDER 3", default_i_val=3)
193 CALL keyword_create(keyword, __location__, name=
"PURIFICATION_METHOD", &
194 description=
"Scheme used to purify the Kohn-Sham matrix into the density matrix.", &
195 usage=
"PURIFICATION_METHOD TRS4", &
198 enum_c_vals=
s2a(
"SIGN",
"TRS4",
"TC2",
"PEXSI"), &
199 enum_desc=
s2a(
"Sign matrix iteration.", &
200 "Trace resetting 4th order scheme", &
201 "Trace conserving 2nd order scheme", &
208 description=
"Method used for the computation of the sign matrix.", &
209 usage=
"SIGN_METHOD NEWTONSCHULZ", &
212 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"PROOT",
"SUBMATRIX"), &
213 enum_desc=
s2a(
"Newton-Schulz iteration.", &
214 "p-th order root iteration", &
215 "Submatrix method"), &
220 CALL keyword_create(keyword, __location__, name=
"SUBMATRIX_SIGN_METHOD", &
221 description=
"Method used for the computation of the sign matrix of all submatrices.", &
222 usage=
"SUBMATRIX_SIGN_METHOD NEWTONSCHULZ", &
224 enum_c_vals=
s2a(
"NEWTONSCHULZ",
"DIRECT",
"DIRECT_MUADJ",
"DIRECT_MUADJ_LOWMEM"), &
225 enum_desc=
s2a(
"Newton-Schulz iteration.", &
226 "Direct method calculating all eigenvalues.", &
227 "Direct method with internal adjustment of mu", &
228 "Direct method with internal adjustment of mu, using two passes to save memory"), &
235 description=
"Order of the method used for the computation of the sign matrix.", &
236 usage=
"SIGN_ORDER 2", &
241 CALL keyword_create(keyword, __location__, name=
"SIGN_SYMMETRIC", &
242 description=
"Use symmetric orthogonalization when generating the input for the sign function.", &
243 usage=
"SIGN_SYMMETRIC .TRUE.", default_l_val=.false., lone_keyword_l_val=.true.)
247 CALL keyword_create(keyword, __location__, name=
"DYNAMIC_THRESHOLD", &
248 description=
"Should the threshold for the purification be chosen dynamically", &
249 usage=
"DYNAMIC_THRESHOLD .TRUE.", default_l_val=.false., lone_keyword_l_val=.true.)
253 CALL keyword_create(keyword, __location__, name=
"NON_MONOTONIC", &
254 description=
"Should the purification be performed non-monotonically. Relevant for TC2 only.", &
255 usage=
"NON_MONOTONIC .TRUE.", default_l_val=.true., lone_keyword_l_val=.true.)
260 keyword, __location__, name=
"MATRIX_CLUSTER_TYPE", &
261 description=
"Specify how atomic blocks should be clustered in the used matrices, in order to improve flop rate, "// &
262 "and possibly speedup the matrix multiply. Note that the atomic s_preconditioner can not be used. "// &
263 "Furthermore, since screening is on matrix blocks, "// &
264 "slightly more accurate results can be expected with molecular.", &
265 usage=
"MATRIX_CLUSTER_TYPE MOLECULAR", &
267 enum_c_vals=
s2a(
"ATOMIC",
"MOLECULAR"), &
268 enum_desc=
s2a(
"Using atomic blocks", &
269 "Using molecular blocks."), &
275 keyword, __location__, name=
"RESTART_WRITE", &
276 description=
"Write the density matrix at the end of the SCF (currently requires EXTRAPOLATION_ORDER>0). "// &
277 "Files might be rather large.", &
278 usage=
"RESTART_WRITE", default_l_val=.false., lone_keyword_l_val=.true.)
283 description=
"Read the density matrix before the (first) SCF.", &
284 usage=
"RESTART_READ", default_l_val=.false., lone_keyword_l_val=.true.)
289 description=
"Method used to compute the inverse of S.", &
290 usage=
"S_INVERSION MOLECULAR", &
292 enum_c_vals=
s2a(
"SIGN_SQRT",
"HOTELLING"), &
293 enum_desc=
s2a(
"Using the inverse sqrt as obtained from sign function iterations.", &
294 "Using the Hotellign iteration."), &
299 CALL keyword_create(keyword, __location__, name=
"REPORT_ALL_SPARSITIES", &
300 description=
"Run the sparsity report at the end of the SCF", &
301 usage=
"REPORT_ALL_SPARSITIES", default_l_val=.true., lone_keyword_l_val=.true.)
305 CALL keyword_create(keyword, __location__, name=
"PERFORM_MU_SCAN", &
306 description=
"Do a scan of the chemical potential after the SCF", &
307 usage=
"PERFORM_MU_SCAN", default_l_val=.false., lone_keyword_l_val=.true.)
312 description=
"Perform an accuracy check on the inverse/sqrt of the s matrix.", &
313 usage=
"CHECK_S_INV", default_l_val=.false., lone_keyword_l_val=.true.)
317 CALL create_ls_curvy_section(subsection)
321 CALL create_chebyshev_section(subsection)
329 CALL create_pexsi_section(subsection)
344 SUBROUTINE create_chebyshev_section(section)
350 cpassert(.NOT.
ASSOCIATED(section))
353 description=
"Specifies the parameters needed for the chebyshev expansion based properties.", &
354 n_keywords=24, n_subsections=3, repeats=.false.)
360 description=
"Order of the polynomial expansion.", &
361 usage=
"N_CHEBYSHEV 2000", default_i_val=500)
367 description=
"Controls the printing of the Density of States (DOS).", &
370 description=
"Number of points in the computed DOS", &
371 usage=
"N_GRIDPOINTS 10000", default_i_val=2000)
379 print_key, __location__, &
380 name=
"PRINT_SPECIFIC_E_DENSITY_CUBE", &
381 description=
"Controls the printing of cube files with "// &
382 "the electronic density (states) "// &
383 "contributing to the density of states within "// &
384 "the specific energy range "// &
385 "(MIN_ENERGY ≤ E ≤ MAX_ENERGY). MIN_ENERGY and MAX_ENERGY need to be specified explicitly.", &
389 description=
"The stride (X,Y,Z) used to write the cube file "// &
390 "(larger values result in smaller cube files). You can provide 3 numbers (for X,Y,Z) or"// &
391 " 1 number valid for all components.", &
392 usage=
"STRIDE 2 2 2", n_var=-1, default_i_vals=(/2, 2, 2/), type_of_var=
integer_t)
397 description=
"Lower bounds of the energy ranges of interest.", &
398 usage=
"MIN_ENERGY -1.01 -0.62 0.10 .. ", &
399 type_of_var=
real_t, n_var=-1)
404 description=
"Upper bounds of the energy ranges of interest.", &
405 usage=
"MAX_ENERGY -0.81 -0.43 0.22 .. ", &
406 type_of_var=
real_t, n_var=-1)
413 END SUBROUTINE create_chebyshev_section
420 SUBROUTINE create_ls_curvy_section(section)
425 cpassert(.NOT.
ASSOCIATED(section))
427 description=
"Specifies the parameters of the linear scaling SCF routines", &
428 n_keywords=24, n_subsections=3, repeats=.false., &
434 description=
"Line serch type used in the curvy_setp optimization.", &
436 enum_c_vals=
s2a(
"3POINT",
"3POINT_2D"), &
437 enum_desc=
s2a(
"Performs a three point line search", &
438 "Only for spin unrestricted calcualtions. Separate step sizes for alpha and beta spin"// &
439 " using a fit to a 2D parabolic function"), &
444 CALL keyword_create(keyword, __location__, name=
"N_BCH_HISTORY", &
445 description=
"Number of stored matrices in the Baker-Campbell-Hausdorff series. "// &
446 "Reduces the BCH evaluation during line search but can be memory intense. ", &
447 usage=
"N_BCH_HISTORY 5", &
452 CALL keyword_create(keyword, __location__, name=
"MIN_HESSIAN_SHIFT", &
453 description=
"Minimal eigenvalue shift for the Hessian in the Newton iteration."// &
454 " Useful for small band gap systems (0.5-1.0 recommended). ", &
455 usage=
"MIN_HESSIAN_SHIFT 0.0", default_r_val=0.0_dp)
459 CALL keyword_create(keyword, __location__, name=
"FILTER_FACTOR", &
460 description=
"Allows to set a separate EPS_FILTER in the newton iterations."// &
461 " The new EPS is EPS_FILTER*FILTER_FACTOR.", &
462 usage=
"FILTER_FACTOR 10.0", default_r_val=1.0_dp)
466 CALL keyword_create(keyword, __location__, name=
"FILTER_FACTOR_SCALE", &
467 description=
"Allows for dynamic EPS_FILTER. Updates the filter factor every SCF-Newton "// &
468 "step by FILTER_FACTOR=FILTER_FACTOR*FILTER_FACTOR_SCALE", &
469 usage=
"FILTER_FACTOR_SCALE 0.5", default_r_val=1.0_dp)
474 description=
"Lowest EPS_FILTER in dynamic filtering. Given as multiple of EPS_FILTER:"// &
475 " EPS_FILTER_MIN=EPS_FILTER*MIN_FILTER", &
476 usage=
"MIN_FILTER 1.0", default_r_val=1.0_dp)
480 END SUBROUTINE create_ls_curvy_section
489 SUBROUTINE create_pexsi_section(section)
494 cpassert(.NOT.
ASSOCIATED(section))
497 description=
"Specifies the parameters of the PEXSI library. The density matrix is calculated "// &
498 "with PEXSI if PURIFICATION_METHOD (in LS_SCF section) is set to PEXSI. "// &
499 "The computational cost of PEXSI is at most quadratically scaling w.r.t. the system size "// &
500 "and PEXSI is applicable to insulating and metallic systems. The value of EPS_PGF_ORB "// &
501 "(in QS input section) defines the sparsity of the matrices sent to PEXSI and EPS_FILTER "// &
502 "is overwritten with 0.", &
507 description=
"Electronic temperature", &
514 description=
"Spectral gap. Note: This can be set to be 0 in most cases.", &
515 default_r_val=0.0_dp, unit_str=
"hartree")
520 description=
"Number of terms in the pole expansion (should be even).", &
525 CALL keyword_create(keyword, __location__, name=
"IS_INERTIA_COUNT", &
526 description=
"Whether inertia counting is used each time the DFT driver "// &
527 "of PEXSI is invoked. If FALSE, inertia counting is still used in the "// &
528 "first SCF iteration.", &
529 default_l_val=.false., lone_keyword_l_val=.true.)
533 CALL keyword_create(keyword, __location__, name=
"MAX_PEXSI_ITER", &
534 description=
"Maximum number of PEXSI iterations after each inertia counting procedure.", &
540 description=
"Initial guess of lower bound for mu.", &
541 default_r_val=-5.0_dp, unit_str=
"hartree")
546 description=
"Initial guess of upper bound for mu.", &
547 default_r_val=5.0_dp, unit_str=
"hartree")
551 CALL keyword_create(keyword, __location__, name=
"MU_INERTIA_TOLERANCE", &
552 description=
"Stopping criterion in terms of the chemical potential for the "// &
553 "inertia counting procedure.", &
554 default_r_val=0.01_dp, unit_str=
"hartree")
558 CALL keyword_create(keyword, __location__, name=
"MU_INERTIA_EXPANSION", &
559 description=
"If the chemical potential is not in the initial interval, "// &
560 "the interval is expanded by MU_INERTIA_EXPANSION.", &
561 default_r_val=0.15_dp, unit_str=
"hartree")
565 CALL keyword_create(keyword, __location__, name=
"MU_PEXSI_SAFE_GUARD", &
566 description=
"Safe guard criterion in terms of the chemical potential to "// &
567 "reinvoke the inertia counting procedure.", &
568 default_r_val=0.01_dp, unit_str=
"hartree")
572 CALL keyword_create(keyword, __location__, name=
"NUM_ELECTRON_PEXSI_TOLERANCE", &
573 description=
"Stopping criterion of the PEXSI iteration in terms of "// &
574 "The number of electrons compared to the exact number of electrons. "// &
575 "This threshold is the target tolerance applied at convergence of SCF.", &
576 default_r_val=0.1_dp)
580 CALL keyword_create(keyword, __location__, name=
"NUM_ELECTRON_INITIAL_TOLERANCE", &
581 description=
"The same as NUM_ELECTRON_PEXSI_TOLERANCE but applied in the first SCF steps. "// &
582 "If set to a value smaller than NUM_ELECTRON_PEXSI_TOLERANCE, it is overwritten with "// &
583 "NUM_ELECTRON_PEXSI_TOLERANCE (default). If set to a value larger than "// &
584 "NUM_ELECTRON_PEXSI_TOLERANCE, the PEXSI tolerance in number of electrons is set adaptively "// &
585 "according to the SCF convergence error of the previous SCF step. This reduces the number "// &
586 "of PEXSI iterations in the first SCF steps but leads to at least one more SCF step.", &
587 default_r_val=0.0_dp)
592 description=
"Ordering strategy for factorization and selected inversion.", &
593 enum_c_vals=
s2a(
"PARALLEL",
"SEQUENTIAL",
"MULTIPLE_MINIMUM_DEGREE"), &
594 enum_desc=
s2a(
"Parallel ordering using ParMETIS/PT-SCOTCH (PARMETIS option in SuperLU_DIST)", &
595 "Sequential ordering using METIS (METIS_AT_PLUS_A option in SuperLU_DIST)", &
596 "Multiple minimum degree ordering (MMD_AT_PLUS_A option in SuperLU_DIST)"), &
597 enum_i_vals=(/0, 1, 2/), default_i_val=0)
602 description=
"row permutation strategy for factorization and selected inversion.", &
603 enum_c_vals=
s2a(
"NOROWPERM",
"LARGEDIAG"), &
604 enum_desc=
s2a(
"No row permutation (NOROWPERM option in SuperLU_DIST)", &
605 "Make diagonal entry larger than off diagonal (LargeDiag option in SuperLU_DIST)"), &
606 enum_i_vals=(/0, 1/), default_i_val=0)
611 description=
"Number of processors for PARMETIS/PT-SCOTCH. Only used if ORDERING is set to PARALLEL. "// &
612 "If 0, the number of processors for PARMETIS/PT-SCOTCH will be set equal to the number of "// &
613 "MPI ranks per pole. Note: if more than one processor is used, a segmentation fault may occur in the "// &
614 "symbolic factorization phase.", &
620 description=
"The level of output information.", &
621 enum_c_vals=
s2a(
"SILENT",
"BASIC",
"DETAILED"), &
622 enum_i_vals=(/0, 1, 2/), default_i_val=1)
626 CALL keyword_create(keyword, __location__, name=
"MIN_RANKS_PER_POLE", &
627 description=
"The minimum number of processors used for each pole. The real "// &
628 "number of processors per pole is the smallest number greater or equal to "// &
629 "MIN_RANKS_PER_POLE that divides MPI size without remainder. For efficiency, MIN_RANKS_PER_POLE "// &
630 "should be a small numbers (limited by the available memory).", &
635 CALL keyword_create(keyword, __location__, name=
"CSR_SCREENING", &
636 description=
"Whether distance screening should be applied to improve sparsity of CSR matrices.", &
637 default_l_val=.true., lone_keyword_l_val=.true.)
641 END SUBROUTINE create_pexsi_section
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public lin2009
integer, save, public vandevondele2012
integer, save, public lin2013
integer, save, public shao2003
integer, save, public niklasson2003
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public high_print_level
subroutine, public cp_print_key_section_create(print_key_section, location, name, description, print_level, each_iter_names, each_iter_values, add_last, filename, common_iter_levels, citations, unit_str)
creates a print_key section
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Defines the basic variable types.
integer, parameter, public dp
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...
Utilities for string manipulations.