39#include "./base/base_uses.f90"
44 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'input_cp2k_almo'
46 INTEGER,
PARAMETER,
PRIVATE :: optimizer_block_diagonal_diis = 1
47 INTEGER,
PARAMETER,
PRIVATE :: optimizer_block_diagonal_pcg = 2
48 INTEGER,
PARAMETER,
PRIVATE :: optimizer_xalmo_pcg = 3
49 INTEGER,
PARAMETER,
PRIVATE :: optimizer_xalmo_trustr = 4
50 INTEGER,
PARAMETER,
PRIVATE :: optimizer_newton_pcg_solver = 5
51 INTEGER,
PARAMETER,
PRIVATE :: optimizer_nlmo_pcg = 6
52 INTEGER,
PARAMETER,
PRIVATE :: optimizer_block_diagonal_trustr = 7
71 cpassert(.NOT.
ASSOCIATED(section))
73 description=
"Settings for a class of efficient linear scaling methods based "// &
74 "on absolutely localized orbitals"// &
75 " (ALMOs). ALMO methods are currently restricted to closed-shell molecular systems.", &
76 n_keywords=10, n_subsections=6, repeats=.false., &
82 description=
"Threshold for the matrix sparsity filter", &
83 usage=
"EPS_FILTER 1.e-6", default_r_val=1.e-7_dp)
87 CALL keyword_create(keyword, __location__, name=
"ALMO_SCF_GUESS", &
88 description=
"The method to generate initial ALMOs.", &
89 usage=
"ALMO_SCF_GUESS MOLECULAR", &
91 enum_c_vals=
s2a(
"MOLECULAR",
"ATOMIC"), &
92 enum_desc=
s2a(
"SCF calculations on single molecules controlled by the regular SCF "// &
93 "keywords outside ALMO options. This kind of calculation is expensive "// &
94 "and only recommended if ALMO SCF does not converge from the ATOMIC guess.", &
95 "Superposition of atomic densities."), &
100 CALL keyword_create(keyword, __location__, name=
"MO_OVERLAP_INV_ALG", &
101 description=
"Algorithm to invert MO overlap matrix.", &
102 usage=
"MO_OVERLAP_INV_ALG LS_HOTELLING", &
104 enum_c_vals=
s2a(
"LS_HOTELLING",
"LS_TAYLOR",
"DENSE_CHOLESKY"), &
105 enum_desc=
s2a(
"Linear scaling iterative Hotelling algorithm. Fast for large sparse matrices.", &
106 "Linear scaling algorithm based on Taylor expansion of (A+B)^(-1).", &
107 "Stable but dense Cholesky algorithm. Cubically scaling."), &
119 CALL keyword_create(keyword, __location__, name=
"ALMO_EXTRAPOLATION_ORDER", &
120 description=
"Number of previous states used for the ASPC extrapolation of the ALMO "// &
121 "initial guess. 0 implies that the guess is given by ALMO_SCF_GUESS at each step.", &
122 usage=
"ALMO_EXTRAPOLATION_ORDER 3", default_i_val=3)
126 CALL keyword_create(keyword, __location__, name=
"XALMO_EXTRAPOLATION_ORDER", &
127 description=
"Number of previous states used for the ASPC extrapolation of the initial guess "// &
128 "for the delocalization correction.", &
129 usage=
"XALMO_EXTRAPOLATION_ORDER 1", default_i_val=0)
133 CALL keyword_create(keyword, __location__, name=
"ALMO_ALGORITHM", &
134 description=
"Specifies the algorithm to update block-diagonal ALMOs during the SCF procedure.", &
135 usage=
"ALMO_ALGORITHM DIAG", &
138 enum_c_vals=
s2a(
"DIAG",
"PCG",
"TRUST_REGION",
"SKIP"), &
139 enum_desc=
s2a(
"DIIS-accelerated diagonalization controlled by ALMO_OPTIMIZER_DIIS. "// &
140 "Recommended for large systems containing small fragments.", &
143 "Energy minimization with a PCG algorithm controlled by ALMO_OPTIMIZER_PCG.", &
144 "Trust-region optimizer is recommended if PCG has difficulty converging. "// &
145 "It is controlled by ALMO_OPTIMIZER_TRUSTR", &
146 "Skip optimization of block-diagonal ALMOs."), &
152 CALL keyword_create(keyword, __location__, name=
"XALMO_ALGORITHM", &
153 description=
"Specifies the algorithm to update ALMOs on eXtended domains (XALMOs).", &
154 usage=
"XALMO_ALGORITHM TRUST_REGION", &
156 enum_c_vals=
s2a(
"DIAG",
"PCG",
"TRUST_REGION"), &
157 enum_desc=
s2a(
"DIIS-accelerated diagonalization.", &
158 "PCG algorithm controlled by XALMO_OPTIMIZER_PCG.", &
159 "Trust-region optimizer controlled by XALMO_OPTIMIZER_TRUSTR"), &
164 CALL keyword_create(keyword, __location__, name=
"XALMO_TRIAL_WF", &
165 description=
"Determines the form of the trial XALMOs.", &
166 usage=
"XALMO_TRIAL_WF SIMPLE", &
168 enum_c_vals=
s2a(
"SIMPLE",
"PROJECT_R0_OUT"), &
169 enum_desc=
s2a(
"Straightforward AO-basis expansion.", &
170 "Block-diagonal ALMOs plus the XALMO term projected onto the unoccupied "// &
177 keyword, __location__, name=
"DELOCALIZE_METHOD", &
178 description=
"Methods to reintroduce electron delocalization, which is excluded "// &
179 "with the block-diagonal ALMO reference. Electron delocalization can "// &
180 "be computed using either fully delocalized MOs or spatially restricted "// &
181 "ALMOs (called eXtended ALMOs or XALMOs). All methods below use either a PCG or trust-region "// &
182 "optimizers controlled by XALMO_OPTIMIZER_* subsections. The only exception is "// &
183 "the non-iterative XALMO_1DIAG.", &
184 usage=
"DELOCALIZE_METHOD XALMO_X", &
186 enum_c_vals=
s2a(
"NONE",
"XALMO_1DIAG",
"XALMO_X",
"XALMO_SCF",
"FULL_X",
"FULL_SCF",
"FULL_X_THEN_SCF"), &
187 enum_desc=
s2a(
"Neglect electron delocalization", &
188 "Correction based on one diagonalization of the spatially projected Hamiltonian (XALMO)", &
189 "Single excitation correction (no Hamiltonian re-build) with spatial restrictions (XALMO)", &
190 "Self-consistent treatment of delocalization with spatial restrictions (XALMO)", &
191 "Single excitation correction (no Hamiltonian re-build) without spatial restrictions", &
192 "Self-consistent treatment of delocalization without spatial restrictions", &
193 "Single excitation correction followed by full SCF procedure, both without spatial restrictions"), &
199 CALL keyword_create(keyword, __location__, name=
"XALMO_R_CUTOFF_FACTOR", &
200 description=
"Controls the localization radius of XALMOs: "// &
202 "R_cutoff = XALMO_R_CUTOFF_FACTOR*(radius(at1)+radius(at2))", &
203 usage=
"XALMO_R_CUTOFF_FACTOR 1.6", default_r_val=1.50_dp)
207 CALL keyword_create(keyword, __location__, name=
"RETURN_ORTHOGONALIZED_MOS", &
208 description=
"Orthogonalize final ALMOs before they are returned "// &
209 "to Quickstep (i.e. for calculation of properties)", &
210 usage=
"RETURN_ORTHOGONALIZED_MOS .TRUE.", default_l_val=.true., &
211 lone_keyword_l_val=.true.)
215 CALL keyword_create(keyword, __location__, name=
"CONSTRUCT_NLMOS", &
216 description=
"Turns on post-SCF construction of NLMOs", &
217 usage=
"CONSTRUCT_NLMOS .TRUE.", default_l_val=.false.)
524 CALL create_optimizer_section(subsection, optimizer_block_diagonal_diis)
529 CALL create_optimizer_section(subsection, optimizer_block_diagonal_pcg)
534 CALL create_optimizer_section(subsection, optimizer_block_diagonal_trustr)
539 CALL create_optimizer_section(subsection, optimizer_xalmo_pcg)
544 CALL create_optimizer_section(subsection, optimizer_xalmo_trustr)
549 CALL create_optimizer_section(subsection, optimizer_nlmo_pcg)
554 CALL create_matrix_iterate_section(subsection)
559 CALL create_almo_analysis_section(subsection)
575 RECURSIVE SUBROUTINE create_optimizer_section(section, optimizer_id)
578 INTEGER,
INTENT(IN) :: optimizer_id
580 INTEGER :: optimizer_type
584 cpassert(.NOT.
ASSOCIATED(section))
588 SELECT CASE (optimizer_id)
589 CASE (optimizer_block_diagonal_diis)
590 CALL section_create(section, __location__, name=
"ALMO_OPTIMIZER_DIIS", &
591 description=
"Controls the iterative DIIS-accelerated optimization of block-diagonal ALMOs.", &
592 n_keywords=5, n_subsections=0, repeats=.false.)
594 CASE (optimizer_block_diagonal_pcg)
595 CALL section_create(section, __location__, name=
"ALMO_OPTIMIZER_PCG", &
596 description=
"Controls the PCG optimization of block-diagonal ALMOs.", &
597 n_keywords=9, n_subsections=1, repeats=.false.)
599 CASE (optimizer_nlmo_pcg)
600 CALL section_create(section, __location__, name=
"NLMO_OPTIMIZER_PCG", &
601 description=
"Controls the PCG optimization of nonorthogonal localized MOs.", &
602 n_keywords=9, n_subsections=1, repeats=.false.)
605 CALL create_penalty_section(subsection)
608 CASE (optimizer_xalmo_pcg)
609 CALL section_create(section, __location__, name=
"XALMO_OPTIMIZER_PCG", &
610 description=
"Controls the PCG optimization of extended ALMOs.", &
611 n_keywords=10, n_subsections=2, repeats=.false.)
613 CALL create_optimizer_section(subsection, optimizer_newton_pcg_solver)
617 CASE (optimizer_xalmo_trustr)
618 CALL section_create(section, __location__, name=
"XALMO_OPTIMIZER_TRUSTR", &
619 description=
"Controls the trust-region optimization of extended ALMOs. "// &
620 "Trust radius is varied in the outer loop. Once the trust radius is "// &
621 "chosen (and fixed) the model function can be minized using various "// &
622 "approaches. Currently, an iterative conjugate-gradient approach is "// &
623 "used and controlled by the inner loop", &
624 n_keywords=10, n_subsections=0, repeats=.false.)
626 CASE (optimizer_block_diagonal_trustr)
627 CALL section_create(section, __location__, name=
"ALMO_OPTIMIZER_TRUSTR", &
628 description=
"Controls the trust-region optimization of block-diagonal ALMOs. "// &
629 "See XALMO_OPTIMIZER_TRUSTR section for brief explanations.", &
630 n_keywords=10, n_subsections=0, repeats=.false.)
632 CASE (optimizer_newton_pcg_solver)
633 CALL section_create(section, __location__, name=
"XALMO_NEWTON_PCG_SOLVER", &
634 description=
"Controls an iterative solver of the Newton-Raphson linear equation.", &
635 n_keywords=4, n_subsections=0, repeats=.false.)
638 cpabort(
"No default values allowed")
645 description=
"Maximum number of iterations", &
646 usage=
"MAX_ITER 100", default_i_val=20)
651 description=
"Target value of the MAX norm of the error", &
652 usage=
"EPS_ERROR 1.E-6", default_r_val=1.0e-5_dp)
657 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_EARLY", &
658 description=
"Maximum number of iterations for truncated SCF "// &
659 "(e.g. Langevin-corrected MD). Negative values mean that this keyword is not used.", &
660 usage=
"MAX_ITER_EARLY 5", default_i_val=-1)
664 CALL keyword_create(keyword, __location__, name=
"EPS_ERROR_EARLY", &
665 description=
"Target value of the MAX norm of the error for truncated SCF "// &
666 "(e.g. Langevin-corrected MD). Negative values mean that this keyword is not used.", &
667 usage=
"EPS_ERROR_EARLY 1.E-2", default_r_val=-1.0_dp)
675 description=
"Number of error vectors to be used in the DIIS "// &
676 "optimization procedure", &
677 usage=
"N_DIIS 5", default_i_val=6)
687 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_OUTER_LOOP", &
688 description=
"Maximum number of iterations in the outer loop. "// &
689 "Use the outer loop to update the preconditioner and reset the conjugator. "// &
690 "This can speed up convergence significantly.", &
691 usage=
"MAX_ITER_OUTER_LOOP 10", default_i_val=0)
695 CALL keyword_create(keyword, __location__, name=
"PRECONDITIONER", &
696 description=
"Select a preconditioner for the conjugate gradient optimization", &
697 usage=
"PRECONDITIONER DOMAIN", &
699 enum_c_vals=
s2a(
"NONE",
"DEFAULT",
"DOMAIN",
"FULL"), &
700 enum_desc=
s2a(
"Do not use preconditioner", &
701 "Same as DOMAIN preconditioner", &
702 "Invert preconditioner domain-by-domain."// &
703 " The main component of the linear scaling algorithm", &
704 "Solve linear equations step=-H.grad on the entire space"), &
714 CALL keyword_create(keyword, __location__, name=
"LIN_SEARCH_EPS_ERROR", &
715 description=
"Target value of the gradient norm during the linear search", &
716 usage=
"LIN_SEARCH_EPS_ERROR 1.E-2", default_r_val=1.0e-3_dp)
720 CALL keyword_create(keyword, __location__, name=
"LIN_SEARCH_STEP_SIZE_GUESS", &
721 description=
"The size of the first step in the linear search", &
722 usage=
"LIN_SEARCH_STEP_SIZE_GUESS 0.1", default_r_val=1.0_dp)
726 CALL keyword_create(keyword, __location__, name=
"PRECOND_FILTER_THRESHOLD", &
727 description=
"Select eigenvalues of the preconditioner "// &
728 "that are smaller than the threshold and project out the "// &
729 "corresponding eigenvectors from the gradient. No matter "// &
730 "how large the threshold is the maximum number of projected "// &
731 "eienvectors for a fragment equals to the number of occupied "// &
732 "orbitals of fragment's neighbors.", &
733 usage=
"PRECOND_FILTER_THRESHOLD 0.1", default_r_val=-1.0_dp)
743 description=
"Various methods to compute step directions in the PCG optimization", &
744 usage=
"CONJUGATOR POLAK_RIBIERE", &
746 enum_c_vals=
s2a(
"ZERO",
"POLAK_RIBIERE",
"FLETCHER_REEVES", &
747 "HESTENES_STIEFEL",
"FLETCHER",
"LIU_STOREY",
"DAI_YUAN",
"HAGER_ZHANG"), &
748 enum_desc=
s2a(
"Steepest descent",
"Polak and Ribiere", &
749 "Fletcher and Reeves",
"Hestenes and Stiefel", &
750 "Fletcher (Conjugate descent)",
"Liu and Storey", &
751 "Dai and Yuan",
"Hager and Zhang"), &
763 description=
"Selects an algorithm to solve the fixed-radius subproblem", &
764 usage=
"ALGORITHM CG", &
766 enum_c_vals=
s2a(
"CG",
"CAUCHY",
"DOGLEG"), &
767 enum_desc=
s2a(
"Steihaug's iterative CG algorithm that does not invert model Hessian", &
768 "Compute simple Cauchy point", &
769 "Dogleg optimizer"), &
775 description=
"Must be between 0.0 and 0.25. Rho value below which the "// &
776 "optimization of the model function is not accepted and the "// &
777 "optimization is restarted from the same point but decreased "// &
778 "trust radius. Rho is the ratio of the actual over predicted "// &
779 "change in the objective function", &
780 usage=
"ETA 0.1", default_r_val=0.25_dp)
784 CALL keyword_create(keyword, __location__, name=
"MODEL_GRAD_NORM_RATIO", &
785 description=
"Stop the fixed-trust-radius (inner) loop optimization "// &
786 "once the ratio of the current norm of the model gradient over the "// &
787 "initial norm drops below this threshold", &
788 usage=
"MODEL_GRAD_NORM_RATIO 1.E-2", default_r_val=0.01_dp)
792 CALL keyword_create(keyword, __location__, name=
"INITIAL_TRUST_RADIUS", &
793 description=
"Initial trust radius", &
794 usage=
"INITIAL_TRUST_RADIUS 0.1", default_r_val=0.1_dp)
798 CALL keyword_create(keyword, __location__, name=
"MAX_TRUST_RADIUS", &
799 description=
"Maximum allowed trust radius", &
800 usage=
"MAX_TRUST_RADIUS 1.0", default_r_val=2.0_dp)
806 END SUBROUTINE create_optimizer_section
815 SUBROUTINE create_matrix_iterate_section(section)
821 cpassert(.NOT.
ASSOCIATED(section))
824 CALL section_create(section, __location__, name=
"MATRIX_ITERATE", &
825 description=
"Controls linear scaling iterative procedure on matrices: inversion, sqrti, etc. "// &
826 "High-order Lanczos accelerates convergence provided it can estimate the eigenspectrum correctly.", &
827 n_keywords=4, n_subsections=0, repeats=.false.)
831 CALL keyword_create(keyword, __location__, name=
"EPS_TARGET_FACTOR", &
832 description=
"Multiplication factor that determines acceptable error in the iterative procedure. "// &
833 "Acceptable error = EPS_TARGET_FACTOR * EPS_FILTER", &
834 usage=
"EPS_TARGET_FACTOR 100.0", default_r_val=10.0_dp)
839 description=
"Threshold for Lanczos eigenvalue estimation.", &
840 usage=
"EPS_LANCZOS 1.0E-4", default_r_val=1.0e-3_dp)
844 CALL keyword_create(keyword, __location__, name=
"ORDER_LANCZOS", &
845 description=
"Order of the Lanczos estimator. Use 0 to turn off. Do not use 1.", &
846 usage=
"ORDER_LANCZOS 5", default_i_val=3)
850 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LANCZOS", &
851 description=
"Maximum number of Lanczos iterations.", &
852 usage=
"MAX_ITER_LANCZOS 64", default_i_val=128)
856 END SUBROUTINE create_matrix_iterate_section
865 SUBROUTINE create_penalty_section(section)
871 cpassert(.NOT.
ASSOCIATED(section))
875 description=
"Add penalty terms to the energy functional.", &
876 n_keywords=3, n_subsections=0, repeats=.false.)
881 keyword, __location__, name=
"OPERATOR", &
882 description=
"Type of opertator which defines the spread functional", &
883 usage=
"OPERATOR PIPEK", &
884 enum_c_vals=
s2a(
"BERRY",
"PIPEK"), &
890 CALL keyword_create(keyword, __location__, name=
"PENALTY_STRENGTH", &
891 description=
"Strength of the orthogonalization penalty", &
892 usage=
"PENALTY_STRENGTH 1.1", default_r_val=1.1_dp)
896 CALL keyword_create(keyword, __location__, name=
"PENALTY_STRENGTH_DECREASE_FACTOR", &
897 description=
"Factor that decreases the strength of the orthogonalization penalty.", &
898 usage=
"PENALTY_STRENGTH_DECREASE_FACTOR 1.1", default_r_val=1.1_dp)
902 CALL keyword_create(keyword, __location__, name=
"DETERMINANT_TOLERANCE", &
903 description=
"Stop the optimization of the penalty strength if the determinant of the overlap "// &
904 "changes less than this tolerance threshold.", &
905 usage=
"DETERMINANT_TOLERANCE 1.0E-4", default_r_val=1.0e-3_dp)
909 CALL keyword_create(keyword, __location__, name=
"FINAL_DETERMINANT", &
910 description=
"The final determinant that obtained after optimization.", &
911 usage=
"FINAL_DETERMINANT 0.1", default_r_val=0.1_dp)
915 CALL keyword_create(keyword, __location__, name=
"COMPACTIFICATION_FILTER_START", &
916 description=
"Set orbital coefficients with absolute value smaller than this value to zero.", &
917 usage=
"COMPACTIFICATION_FILTER_START 1.e-6", default_r_val=-1.0_dp)
921 CALL keyword_create(keyword, __location__, name=
"VIRTUAL_NLMOS", &
922 description=
"Localize virtual oribtals", &
923 usage=
"VIRTUAL_NLMOS .TRUE.", default_l_val=.false.)
927 END SUBROUTINE create_penalty_section
936 SUBROUTINE create_almo_analysis_section(section)
943 cpassert(.NOT.
ASSOCIATED(section))
947 description=
"Controls electronic structure analysis based on ALMOs and XALMOs.", &
948 n_keywords=2, n_subsections=1, repeats=.false., &
953 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
954 description=
"Activation of ALMO-based electronic structure analysis.", &
955 usage=
"&ANALYSIS T", &
956 default_l_val=.false., &
957 lone_keyword_l_val=.true.)
961 CALL keyword_create(keyword, __location__, name=
"FROZEN_MO_ENERGY_TERM", &
962 description=
"Perform calculations on single molecules to compute the frozen density term", &
963 usage=
"FROZEN_MO_ENERGY_TERM SUBLATTICE", default_i_val=
almo_frz_none, &
965 enum_c_vals=
s2a(
"SKIP",
"SUBLATTICE"), &
966 enum_desc=
s2a(
"Do not compute the frozen MO energy term.", &
968 "Use energies of single molecules in their positions in the crystal "// &
969 "cell as the reference. "// &
970 "This term does not have an interpretation if fragmetns are charged."), &
978 CALL create_almo_print_section(subsection)
982 END SUBROUTINE create_almo_analysis_section
991 SUBROUTINE create_almo_print_section(section)
997 cpassert(.NOT.
ASSOCIATED(section))
998 NULLIFY (section, print_key)
1001 description=
"Controls printing of detailed ALMO decomosition analysis results", &
1002 n_keywords=0, n_subsections=2, repeats=.true.)
1006 description=
"Controls printing of the electron transfer terms in "// &
1007 "ALMO energy decomposition analysis. "// &
1008 "File format: first column is the index of the electron acceptor "// &
1009 "fragment, second -- is the index of the electron donor fragment, "// &
1010 "third - the energy change (a.u.) associated with the electron transfer.", &
1017 description=
"Controls printing of the electron transfer terms in "// &
1018 "ALMO charge transfer analysis. "// &
1019 "File format: first column is the index of the electron acceptor "// &
1020 "fragment, second -- is the index of the electron donor fragment, "// &
1021 "third - the change (a.u.) transferred between the two fragments.", &
1027 END SUBROUTINE create_almo_print_section
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public scheiber2018
integer, save, public khaliullin2008
integer, save, public khaliullin2007
integer, save, public khaliullin2013
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
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
Defines the basic variable types.
integer, parameter, public dp
Utilities for string manipulations.