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.)
518 CALL create_almo_fragment_section(subsection)
523 CALL create_optimizer_section(subsection, optimizer_block_diagonal_diis)
528 CALL create_optimizer_section(subsection, optimizer_block_diagonal_pcg)
533 CALL create_optimizer_section(subsection, optimizer_block_diagonal_trustr)
538 CALL create_optimizer_section(subsection, optimizer_xalmo_pcg)
543 CALL create_optimizer_section(subsection, optimizer_xalmo_trustr)
548 CALL create_optimizer_section(subsection, optimizer_nlmo_pcg)
553 CALL create_matrix_iterate_section(subsection)
558 CALL create_almo_analysis_section(subsection)
574 RECURSIVE SUBROUTINE create_optimizer_section(section, optimizer_id)
577 INTEGER,
INTENT(IN) :: optimizer_id
579 INTEGER :: optimizer_type
583 cpassert(.NOT.
ASSOCIATED(section))
587 SELECT CASE (optimizer_id)
588 CASE (optimizer_block_diagonal_diis)
589 CALL section_create(section, __location__, name=
"ALMO_OPTIMIZER_DIIS", &
590 description=
"Controls the iterative DIIS-accelerated optimization of block-diagonal ALMOs.", &
591 n_keywords=5, n_subsections=0, repeats=.false.)
593 CASE (optimizer_block_diagonal_pcg)
594 CALL section_create(section, __location__, name=
"ALMO_OPTIMIZER_PCG", &
595 description=
"Controls the PCG optimization of block-diagonal ALMOs.", &
596 n_keywords=9, n_subsections=1, repeats=.false.)
598 CASE (optimizer_nlmo_pcg)
599 CALL section_create(section, __location__, name=
"NLMO_OPTIMIZER_PCG", &
600 description=
"Controls the PCG optimization of nonorthogonal localized MOs.", &
601 n_keywords=9, n_subsections=1, repeats=.false.)
604 CALL create_penalty_section(subsection)
607 CASE (optimizer_xalmo_pcg)
608 CALL section_create(section, __location__, name=
"XALMO_OPTIMIZER_PCG", &
609 description=
"Controls the PCG optimization of extended ALMOs.", &
610 n_keywords=10, n_subsections=2, repeats=.false.)
612 CALL create_optimizer_section(subsection, optimizer_newton_pcg_solver)
616 CASE (optimizer_xalmo_trustr)
617 CALL section_create(section, __location__, name=
"XALMO_OPTIMIZER_TRUSTR", &
618 description=
"Controls the trust-region optimization of extended ALMOs. "// &
619 "Trust radius is varied in the outer loop. Once the trust radius is "// &
620 "chosen (and fixed) the model function can be minized using various "// &
621 "approaches. Currently, an iterative conjugate-gradient approach is "// &
622 "used and controlled by the inner loop", &
623 n_keywords=10, n_subsections=0, repeats=.false.)
625 CASE (optimizer_block_diagonal_trustr)
626 CALL section_create(section, __location__, name=
"ALMO_OPTIMIZER_TRUSTR", &
627 description=
"Controls the trust-region optimization of block-diagonal ALMOs. "// &
628 "See XALMO_OPTIMIZER_TRUSTR section for brief explanations.", &
629 n_keywords=10, n_subsections=0, repeats=.false.)
631 CASE (optimizer_newton_pcg_solver)
632 CALL section_create(section, __location__, name=
"XALMO_NEWTON_PCG_SOLVER", &
633 description=
"Controls an iterative solver of the Newton-Raphson linear equation.", &
634 n_keywords=4, n_subsections=0, repeats=.false.)
637 cpabort(
"No default values allowed")
644 description=
"Maximum number of iterations", &
645 usage=
"MAX_ITER 100", default_i_val=20)
650 description=
"Target value of the MAX norm of the error", &
651 usage=
"EPS_ERROR 1.E-6", default_r_val=1.0e-5_dp)
656 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_EARLY", &
657 description=
"Maximum number of iterations for truncated SCF "// &
658 "(e.g. Langevin-corrected MD). Negative values mean that this keyword is not used.", &
659 usage=
"MAX_ITER_EARLY 5", default_i_val=-1)
663 CALL keyword_create(keyword, __location__, name=
"EPS_ERROR_EARLY", &
664 description=
"Target value of the MAX norm of the error for truncated SCF "// &
665 "(e.g. Langevin-corrected MD). Negative values mean that this keyword is not used.", &
666 usage=
"EPS_ERROR_EARLY 1.E-2", default_r_val=-1.0_dp)
674 description=
"Number of error vectors to be used in the DIIS "// &
675 "optimization procedure", &
676 usage=
"N_DIIS 5", default_i_val=6)
686 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_OUTER_LOOP", &
687 description=
"Maximum number of iterations in the outer loop. "// &
688 "Use the outer loop to update the preconditioner and reset the conjugator. "// &
689 "This can speed up convergence significantly.", &
690 usage=
"MAX_ITER_OUTER_LOOP 10", default_i_val=0)
694 CALL keyword_create(keyword, __location__, name=
"PRECONDITIONER", &
695 description=
"Select a preconditioner for the conjugate gradient optimization", &
696 usage=
"PRECONDITIONER DOMAIN", &
698 enum_c_vals=
s2a(
"NONE",
"DEFAULT",
"DOMAIN",
"FULL"), &
699 enum_desc=
s2a(
"Do not use preconditioner", &
700 "Same as DOMAIN preconditioner", &
701 "Invert preconditioner domain-by-domain."// &
702 " The main component of the linear scaling algorithm", &
703 "Solve linear equations step=-H.grad on the entire space"), &
713 CALL keyword_create(keyword, __location__, name=
"LIN_SEARCH_EPS_ERROR", &
714 description=
"Target value of the gradient norm during the linear search", &
715 usage=
"LIN_SEARCH_EPS_ERROR 1.E-2", default_r_val=1.0e-3_dp)
719 CALL keyword_create(keyword, __location__, name=
"LIN_SEARCH_STEP_SIZE_GUESS", &
720 description=
"The size of the first step in the linear search", &
721 usage=
"LIN_SEARCH_STEP_SIZE_GUESS 0.1", default_r_val=1.0_dp)
725 CALL keyword_create(keyword, __location__, name=
"PRECOND_FILTER_THRESHOLD", &
726 description=
"Select eigenvalues of the preconditioner "// &
727 "that are smaller than the threshold and project out the "// &
728 "corresponding eigenvectors from the gradient. No matter "// &
729 "how large the threshold is the maximum number of projected "// &
730 "eienvectors for a fragment equals to the number of occupied "// &
731 "orbitals of fragment's neighbors.", &
732 usage=
"PRECOND_FILTER_THRESHOLD 0.1", default_r_val=-1.0_dp)
742 description=
"Various methods to compute step directions in the PCG optimization", &
743 usage=
"CONJUGATOR POLAK_RIBIERE", &
745 enum_c_vals=
s2a(
"ZERO",
"POLAK_RIBIERE",
"FLETCHER_REEVES", &
746 "HESTENES_STIEFEL",
"FLETCHER",
"LIU_STOREY",
"DAI_YUAN",
"HAGER_ZHANG"), &
747 enum_desc=
s2a(
"Steepest descent",
"Polak and Ribiere", &
748 "Fletcher and Reeves",
"Hestenes and Stiefel", &
749 "Fletcher (Conjugate descent)",
"Liu and Storey", &
750 "Dai and Yuan",
"Hager and Zhang"), &
762 description=
"Selects an algorithm to solve the fixed-radius subproblem", &
763 usage=
"ALGORITHM CG", &
765 enum_c_vals=
s2a(
"CG",
"CAUCHY",
"DOGLEG"), &
766 enum_desc=
s2a(
"Steihaug's iterative CG algorithm that does not invert model Hessian", &
767 "Compute simple Cauchy point", &
768 "Dogleg optimizer"), &
774 description=
"Must be between 0.0 and 0.25. Rho value below which the "// &
775 "optimization of the model function is not accepted and the "// &
776 "optimization is restarted from the same point but decreased "// &
777 "trust radius. Rho is the ratio of the actual over predicted "// &
778 "change in the objective function", &
779 usage=
"ETA 0.1", default_r_val=0.25_dp)
783 CALL keyword_create(keyword, __location__, name=
"MODEL_GRAD_NORM_RATIO", &
784 description=
"Stop the fixed-trust-radius (inner) loop optimization "// &
785 "once the ratio of the current norm of the model gradient over the "// &
786 "initial norm drops below this threshold", &
787 usage=
"MODEL_GRAD_NORM_RATIO 1.E-2", default_r_val=0.01_dp)
791 CALL keyword_create(keyword, __location__, name=
"INITIAL_TRUST_RADIUS", &
792 description=
"Initial trust radius", &
793 usage=
"INITIAL_TRUST_RADIUS 0.1", default_r_val=0.1_dp)
797 CALL keyword_create(keyword, __location__, name=
"MAX_TRUST_RADIUS", &
798 description=
"Maximum allowed trust radius", &
799 usage=
"MAX_TRUST_RADIUS 1.0", default_r_val=2.0_dp)
805 END SUBROUTINE create_optimizer_section
814 SUBROUTINE create_matrix_iterate_section(section)
820 cpassert(.NOT.
ASSOCIATED(section))
823 CALL section_create(section, __location__, name=
"MATRIX_ITERATE", &
824 description=
"Controls linear scaling iterative procedure on matrices: inversion, sqrti, etc. "// &
825 "High-order Lanczos accelerates convergence provided it can estimate the eigenspectrum correctly.", &
826 n_keywords=4, n_subsections=0, repeats=.false.)
830 CALL keyword_create(keyword, __location__, name=
"EPS_TARGET_FACTOR", &
831 description=
"Multiplication factor that determines acceptable error in the iterative procedure. "// &
832 "Acceptable error = EPS_TARGET_FACTOR * EPS_FILTER", &
833 usage=
"EPS_TARGET_FACTOR 100.0", default_r_val=10.0_dp)
838 description=
"Threshold for Lanczos eigenvalue estimation.", &
839 usage=
"EPS_LANCZOS 1.0E-4", default_r_val=1.0e-3_dp)
843 CALL keyword_create(keyword, __location__, name=
"ORDER_LANCZOS", &
844 description=
"Order of the Lanczos estimator. Use 0 to turn off. Do not use 1.", &
845 usage=
"ORDER_LANCZOS 5", default_i_val=3)
849 CALL keyword_create(keyword, __location__, name=
"MAX_ITER_LANCZOS", &
850 description=
"Maximum number of Lanczos iterations.", &
851 usage=
"MAX_ITER_LANCZOS 64", default_i_val=128)
855 END SUBROUTINE create_matrix_iterate_section
864 SUBROUTINE create_penalty_section(section)
870 cpassert(.NOT.
ASSOCIATED(section))
874 description=
"Add penalty terms to the energy functional.", &
875 n_keywords=3, n_subsections=0, repeats=.false.)
880 keyword, __location__, name=
"OPERATOR", &
881 description=
"Type of opertator which defines the spread functional", &
882 usage=
"OPERATOR PIPEK", &
883 enum_c_vals=
s2a(
"BERRY",
"PIPEK"), &
889 CALL keyword_create(keyword, __location__, name=
"PENALTY_STRENGTH", &
890 description=
"Strength of the orthogonalization penalty", &
891 usage=
"PENALTY_STRENGTH 1.1", default_r_val=1.1_dp)
895 CALL keyword_create(keyword, __location__, name=
"PENALTY_STRENGTH_DECREASE_FACTOR", &
896 description=
"Factor that decreases the strength of the orthogonalization penalty.", &
897 usage=
"PENALTY_STRENGTH_DECREASE_FACTOR 1.1", default_r_val=1.1_dp)
901 CALL keyword_create(keyword, __location__, name=
"DETERMINANT_TOLERANCE", &
902 description=
"Stop the optimization of the penalty strength if the determinant of the overlap "// &
903 "changes less than this tolerance threshold.", &
904 usage=
"DETERMINANT_TOLERANCE 1.0E-4", default_r_val=1.0e-3_dp)
908 CALL keyword_create(keyword, __location__, name=
"FINAL_DETERMINANT", &
909 description=
"The final determinant that obtained after optimization.", &
910 usage=
"FINAL_DETERMINANT 0.1", default_r_val=0.1_dp)
914 CALL keyword_create(keyword, __location__, name=
"COMPACTIFICATION_FILTER_START", &
915 description=
"Set orbital coefficients with absolute value smaller than this value to zero.", &
916 usage=
"COMPACTIFICATION_FILTER_START 1.e-6", default_r_val=-1.0_dp)
920 CALL keyword_create(keyword, __location__, name=
"VIRTUAL_NLMOS", &
921 description=
"Localize virtual oribtals", &
922 usage=
"VIRTUAL_NLMOS .TRUE.", default_l_val=.false.)
926 END SUBROUTINE create_penalty_section
935 SUBROUTINE create_almo_analysis_section(section)
942 cpassert(.NOT.
ASSOCIATED(section))
946 description=
"Controls electronic structure analysis based on ALMOs and XALMOs.", &
947 n_keywords=2, n_subsections=1, repeats=.false., &
952 CALL keyword_create(keyword, __location__, name=
"_SECTION_PARAMETERS_", &
953 description=
"Activation of ALMO-based electronic structure analysis.", &
954 usage=
"&ANALYSIS T", &
955 default_l_val=.false., &
956 lone_keyword_l_val=.true.)
960 CALL keyword_create(keyword, __location__, name=
"FROZEN_MO_ENERGY_TERM", &
961 description=
"Perform calculations on single molecules to compute the frozen density term", &
962 usage=
"FROZEN_MO_ENERGY_TERM SUBLATTICE", default_i_val=
almo_frz_none, &
964 enum_c_vals=
s2a(
"SKIP",
"SUBLATTICE"), &
965 enum_desc=
s2a(
"Do not compute the frozen MO energy term.", &
967 "Use energies of single molecules in their positions in the crystal "// &
968 "cell as the reference. "// &
969 "This term does not have an interpretation if fragmetns are charged."), &
977 CALL create_almo_print_section(subsection)
981 END SUBROUTINE create_almo_analysis_section
990 SUBROUTINE create_almo_fragment_section(section)
996 cpassert(.NOT.
ASSOCIATED(section))
1000 description=
"Specifies the caracteristics of "// &
1001 "each fragments.", &
1002 n_keywords=3, n_subsections=0, repeats=.true.)
1005 CALL keyword_create(keyword, __location__, name=
"_FRAGMENT_PARAMETERS_", &
1006 description=
"Defines the index of the fragment.", &
1007 usage=
"_FRAGMENT_PARAMETERS_ <INTEGER>", n_var=1, default_i_val=0)
1012 description=
"Specifies the charge of a fragment.", &
1013 usage=
"CHARGE 1", default_i_val=0)
1018 name=
"MULTIPLICITY", &
1019 variants=[
"MULTIP"], &
1020 description=
"Specifies for each fragment the multiplicity. Two times the total spin plus one. "// &
1021 "Specify 3 for a triplet, 4 for a quartet,and so on. Default is 1 (singlet) for an "// &
1022 "even number and 2 (doublet) for an odd number of electrons.", &
1023 usage=
"MULTIPLICITY 3", &
1028 END SUBROUTINE create_almo_fragment_section
1037 SUBROUTINE create_almo_print_section(section)
1043 cpassert(.NOT.
ASSOCIATED(section))
1044 NULLIFY (section, print_key)
1047 description=
"Controls printing of detailed ALMO decomosition analysis results", &
1048 n_keywords=0, n_subsections=2, repeats=.true.)
1052 description=
"Controls printing of the electron transfer terms in "// &
1053 "ALMO energy decomposition analysis. "// &
1054 "File format: first column is the index of the electron acceptor "// &
1055 "fragment, second -- is the index of the electron donor fragment, "// &
1056 "third - the energy change (a.u.) associated with the electron transfer.", &
1063 description=
"Controls printing of the electron transfer terms in "// &
1064 "ALMO charge transfer analysis. "// &
1065 "File format: first column is the index of the electron acceptor "// &
1066 "fragment, second -- is the index of the electron donor fragment, "// &
1067 "third - the change (a.u.) transferred between the two fragments.", &
1073 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.