Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief almo_scf_env methods
10 : !> \par History
11 : !> 2016.12 created [Rustam Z Khaliullin]
12 : !> \author Rustam Z Khaliullin
13 : ! **************************************************************************************************
14 : MODULE almo_scf_env_methods
15 :
16 : USE almo_scf_types, ONLY: almo_max_cutoff_multiplier,&
17 : almo_scf_env_type
18 : USE cp_control_types, ONLY: dft_control_type
19 : USE input_constants, ONLY: &
20 : almo_constraint_distance, almo_deloc_none, almo_deloc_xalmo_1diag, &
21 : almo_domain_layout_atomic, almo_domain_layout_molecular, almo_frz_crystal, &
22 : almo_mat_distr_molecular, almo_scf_diag, almo_scf_skip, almo_scf_trustr, cg_hager_zhang, &
23 : do_bondparm_vdw, molecular_guess, tensor_orthogonal, virt_full, virt_minimal, virt_number, &
24 : xalmo_trial_r0_out
25 : USE input_section_types, ONLY: section_vals_get,&
26 : section_vals_get_subs_vals,&
27 : section_vals_type,&
28 : section_vals_val_get
29 : USE kinds, ONLY: dp
30 : USE qs_environment_types, ONLY: get_qs_env,&
31 : qs_environment_type,&
32 : set_qs_env
33 : #include "./base/base_uses.f90"
34 :
35 : IMPLICIT NONE
36 :
37 : PRIVATE
38 :
39 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'almo_scf_env_methods'
40 :
41 : PUBLIC :: almo_scf_env_create
42 :
43 : CONTAINS
44 :
45 : ! **************************************************************************************************
46 : !> \brief Creation and basic initialization of the almo environment
47 : !> \param qs_env ...
48 : !> \par History
49 : !> 2016.11 created [Rustam Z Khaliullin]
50 : !> \author Rustam Z Khaliullin
51 : ! **************************************************************************************************
52 72 : SUBROUTINE almo_scf_env_create(qs_env)
53 : TYPE(qs_environment_type), POINTER :: qs_env
54 :
55 : CHARACTER(len=*), PARAMETER :: routineN = 'almo_scf_env_create'
56 :
57 : INTEGER :: handle, nallocate
58 : TYPE(almo_scf_env_type), POINTER :: almo_scf_env
59 : TYPE(dft_control_type), POINTER :: dft_control
60 : TYPE(section_vals_type), POINTER :: input
61 :
62 72 : CALL timeset(routineN, handle)
63 :
64 864 : ALLOCATE (almo_scf_env)
65 :
66 : ! get basic quantities from the qs_env
67 72 : CALL get_qs_env(qs_env, input=input, dft_control=dft_control)
68 :
69 : ! parse the almo_scf section and set appropriate quantities
70 72 : CALL almo_scf_init_read_write_input(input, almo_scf_env)
71 :
72 : ! set up the buffer for the history of matrices
73 72 : almo_scf_env%nspins = dft_control%nspins
74 72 : almo_scf_env%almo_history%nstore = almo_scf_env%almo_extrapolation_order
75 72 : almo_scf_env%almo_history%istore = 0
76 : ! do not allocate zero
77 72 : nallocate = MAX(1, almo_scf_env%almo_extrapolation_order)
78 722 : ALLOCATE (almo_scf_env%almo_history%matrix_p_up_down(almo_scf_env%nspins, nallocate))
79 294 : ALLOCATE (almo_scf_env%almo_history%matrix_t(almo_scf_env%nspins))
80 72 : almo_scf_env%xalmo_history%nstore = almo_scf_env%xalmo_extrapolation_order
81 72 : almo_scf_env%xalmo_history%istore = 0
82 72 : nallocate = MAX(1, almo_scf_env%xalmo_extrapolation_order)
83 466 : ALLOCATE (almo_scf_env%xalmo_history%matrix_p_up_down(almo_scf_env%nspins, nallocate))
84 : !ALLOCATE (almo_scf_env%xalmo_history%matrix_x(almo_scf_env%nspins, nallocate))
85 294 : ALLOCATE (almo_scf_env%xalmo_history%matrix_t(almo_scf_env%nspins))
86 :
87 : ! put almo_scf_env in qs_env
88 72 : CALL set_qs_env(qs_env, almo_scf_env=almo_scf_env)
89 :
90 72 : CALL timestop(handle)
91 :
92 72 : END SUBROUTINE almo_scf_env_create
93 :
94 : ! **************************************************************************************************
95 : !> \brief Parses the ALMO input section
96 : !> \param input ...
97 : !> \param almo_scf_env ...
98 : !> \par History
99 : !> 2011.05 created [Rustam Z Khaliullin]
100 : !> 2024.02 modified [Raphael Rullan]
101 : !> \author Rustam Z Khaliullin
102 : ! **************************************************************************************************
103 144 : SUBROUTINE almo_scf_init_read_write_input(input, almo_scf_env)
104 : TYPE(section_vals_type), POINTER :: input
105 : TYPE(almo_scf_env_type), INTENT(INOUT) :: almo_scf_env
106 :
107 : CHARACTER(len=*), PARAMETER :: routineN = 'almo_scf_init_read_write_input'
108 :
109 : INTEGER :: handle, i, ndomain
110 : LOGICAL :: explicit
111 : TYPE(section_vals_type), POINTER :: almo_analysis_section, almo_opt_diis_section, &
112 : almo_opt_pcg_section, almo_opt_trustr_section, almo_scf_section, fragment_section, &
113 : matrix_iterate_section, nlmo_opt_pcg_section, penalty_section, &
114 : xalmo_opt_newton_pcg_section, xalmo_opt_pcg_section, xalmo_opt_trustr_section
115 :
116 72 : CALL timeset(routineN, handle)
117 :
118 72 : almo_scf_section => section_vals_get_subs_vals(input, "DFT%ALMO_SCF")
119 : almo_opt_diis_section => section_vals_get_subs_vals(almo_scf_section, &
120 72 : "ALMO_OPTIMIZER_DIIS")
121 : almo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, &
122 72 : "ALMO_OPTIMIZER_PCG")
123 : almo_opt_trustr_section => section_vals_get_subs_vals(almo_scf_section, &
124 72 : "ALMO_OPTIMIZER_TRUSTR")
125 : xalmo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, &
126 72 : "XALMO_OPTIMIZER_PCG")
127 : xalmo_opt_trustr_section => section_vals_get_subs_vals(almo_scf_section, &
128 72 : "XALMO_OPTIMIZER_TRUSTR")
129 : nlmo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, &
130 72 : "NLMO_OPTIMIZER_PCG")
131 72 : almo_analysis_section => section_vals_get_subs_vals(almo_scf_section, "ANALYSIS")
132 : xalmo_opt_newton_pcg_section => section_vals_get_subs_vals(xalmo_opt_pcg_section, &
133 72 : "XALMO_NEWTON_PCG_SOLVER")
134 : matrix_iterate_section => section_vals_get_subs_vals(almo_scf_section, &
135 72 : "MATRIX_ITERATE")
136 :
137 : ! read user input
138 : ! common ALMO options
139 : CALL section_vals_val_get(almo_scf_section, "EPS_FILTER", &
140 72 : r_val=almo_scf_env%eps_filter)
141 : CALL section_vals_val_get(almo_scf_section, "ALMO_SCF_GUESS", &
142 72 : i_val=almo_scf_env%almo_scf_guess)
143 : CALL section_vals_val_get(almo_scf_section, "ALMO_ALGORITHM", &
144 72 : i_val=almo_scf_env%almo_update_algorithm)
145 : CALL section_vals_val_get(almo_scf_section, "XALMO_ALGORITHM", &
146 72 : i_val=almo_scf_env%xalmo_update_algorithm)
147 : CALL section_vals_val_get(almo_scf_section, "XALMO_TRIAL_WF", &
148 72 : i_val=almo_scf_env%xalmo_trial_wf)
149 : CALL section_vals_val_get(almo_scf_section, "MO_OVERLAP_INV_ALG", &
150 72 : i_val=almo_scf_env%sigma_inv_algorithm)
151 : CALL section_vals_val_get(almo_scf_section, "DELOCALIZE_METHOD", &
152 72 : i_val=almo_scf_env%deloc_method)
153 : CALL section_vals_val_get(almo_scf_section, "XALMO_R_CUTOFF_FACTOR", &
154 72 : r_val=almo_scf_env%quencher_r0_factor)
155 : CALL section_vals_val_get(almo_scf_section, "ALMO_EXTRAPOLATION_ORDER", &
156 72 : i_val=almo_scf_env%almo_extrapolation_order)
157 72 : almo_scf_env%almo_extrapolation_order = MAX(0, almo_scf_env%almo_extrapolation_order)
158 : CALL section_vals_val_get(almo_scf_section, "XALMO_EXTRAPOLATION_ORDER", &
159 72 : i_val=almo_scf_env%xalmo_extrapolation_order)
160 72 : almo_scf_env%xalmo_extrapolation_order = MAX(0, almo_scf_env%xalmo_extrapolation_order)
161 : CALL section_vals_val_get(almo_scf_section, "RETURN_ORTHOGONALIZED_MOS", &
162 72 : l_val=almo_scf_env%return_orthogonalized_mos)
163 : CALL section_vals_val_get(almo_scf_section, "CONSTRUCT_NLMOS", &
164 72 : l_val=almo_scf_env%construct_nlmos)
165 :
166 : CALL section_vals_val_get(matrix_iterate_section, "EPS_LANCZOS", &
167 72 : r_val=almo_scf_env%eps_lanczos)
168 : CALL section_vals_val_get(matrix_iterate_section, "ORDER_LANCZOS", &
169 72 : i_val=almo_scf_env%order_lanczos)
170 : CALL section_vals_val_get(matrix_iterate_section, "MAX_ITER_LANCZOS", &
171 72 : i_val=almo_scf_env%max_iter_lanczos)
172 : CALL section_vals_val_get(matrix_iterate_section, "EPS_TARGET_FACTOR", &
173 72 : r_val=almo_scf_env%matrix_iter_eps_error_factor)
174 :
175 : ! optimizers
176 : CALL section_vals_val_get(almo_opt_diis_section, "EPS_ERROR", &
177 72 : r_val=almo_scf_env%opt_block_diag_diis%eps_error)
178 : CALL section_vals_val_get(almo_opt_diis_section, "MAX_ITER", &
179 72 : i_val=almo_scf_env%opt_block_diag_diis%max_iter)
180 : CALL section_vals_val_get(almo_opt_diis_section, "EPS_ERROR_EARLY", &
181 72 : r_val=almo_scf_env%opt_block_diag_diis%eps_error_early)
182 : CALL section_vals_val_get(almo_opt_diis_section, "MAX_ITER_EARLY", &
183 72 : i_val=almo_scf_env%opt_block_diag_diis%max_iter_early)
184 : CALL section_vals_val_get(almo_opt_diis_section, "N_DIIS", &
185 72 : i_val=almo_scf_env%opt_block_diag_diis%ndiis)
186 :
187 : CALL section_vals_val_get(almo_opt_pcg_section, "EPS_ERROR", &
188 72 : r_val=almo_scf_env%opt_block_diag_pcg%eps_error)
189 : CALL section_vals_val_get(almo_opt_pcg_section, "MAX_ITER", &
190 72 : i_val=almo_scf_env%opt_block_diag_pcg%max_iter)
191 : CALL section_vals_val_get(almo_opt_pcg_section, "EPS_ERROR_EARLY", &
192 72 : r_val=almo_scf_env%opt_block_diag_pcg%eps_error_early)
193 : CALL section_vals_val_get(almo_opt_pcg_section, "MAX_ITER_EARLY", &
194 72 : i_val=almo_scf_env%opt_block_diag_pcg%max_iter_early)
195 : CALL section_vals_val_get(almo_opt_pcg_section, "MAX_ITER_OUTER_LOOP", &
196 72 : i_val=almo_scf_env%opt_block_diag_pcg%max_iter_outer_loop)
197 : CALL section_vals_val_get(almo_opt_pcg_section, "LIN_SEARCH_EPS_ERROR", &
198 72 : r_val=almo_scf_env%opt_block_diag_pcg%lin_search_eps_error)
199 : CALL section_vals_val_get(almo_opt_pcg_section, "LIN_SEARCH_STEP_SIZE_GUESS", &
200 72 : r_val=almo_scf_env%opt_block_diag_pcg%lin_search_step_size_guess)
201 : CALL section_vals_val_get(almo_opt_pcg_section, "PRECOND_FILTER_THRESHOLD", &
202 72 : r_val=almo_scf_env%opt_block_diag_pcg%neglect_threshold)
203 : CALL section_vals_val_get(almo_opt_pcg_section, "CONJUGATOR", &
204 72 : i_val=almo_scf_env%opt_block_diag_pcg%conjugator)
205 : CALL section_vals_val_get(almo_opt_pcg_section, "PRECONDITIONER", &
206 72 : i_val=almo_scf_env%opt_block_diag_pcg%preconditioner)
207 :
208 : CALL section_vals_val_get(almo_opt_trustr_section, "EPS_ERROR", &
209 72 : r_val=almo_scf_env%opt_block_diag_trustr%eps_error)
210 : CALL section_vals_val_get(almo_opt_trustr_section, "MAX_ITER", &
211 72 : i_val=almo_scf_env%opt_block_diag_trustr%max_iter)
212 : CALL section_vals_val_get(almo_opt_trustr_section, "ALGORITHM", &
213 72 : i_val=almo_scf_env%opt_block_diag_trustr%trustr_algorithm)
214 : CALL section_vals_val_get(almo_opt_trustr_section, "EPS_ERROR_EARLY", &
215 72 : r_val=almo_scf_env%opt_block_diag_trustr%eps_error_early)
216 : CALL section_vals_val_get(almo_opt_trustr_section, "MAX_ITER_EARLY", &
217 72 : i_val=almo_scf_env%opt_block_diag_trustr%max_iter_early)
218 : CALL section_vals_val_get(almo_opt_trustr_section, "MAX_ITER_OUTER_LOOP", &
219 72 : i_val=almo_scf_env%opt_block_diag_trustr%max_iter_outer_loop)
220 : CALL section_vals_val_get(almo_opt_trustr_section, "ETA", &
221 72 : r_val=almo_scf_env%opt_block_diag_trustr%rho_do_not_update)
222 : almo_scf_env%opt_block_diag_trustr%rho_do_not_update = &
223 72 : MIN(MAX(almo_scf_env%opt_block_diag_trustr%rho_do_not_update, 0.0_dp), 0.25_dp)
224 : CALL section_vals_val_get(almo_opt_trustr_section, "MODEL_GRAD_NORM_RATIO", &
225 72 : r_val=almo_scf_env%opt_block_diag_trustr%model_grad_norm_ratio)
226 : CALL section_vals_val_get(almo_opt_trustr_section, "INITIAL_TRUST_RADIUS", &
227 72 : r_val=almo_scf_env%opt_block_diag_trustr%initial_trust_radius)
228 : CALL section_vals_val_get(almo_opt_trustr_section, "MAX_TRUST_RADIUS", &
229 72 : r_val=almo_scf_env%opt_block_diag_trustr%max_trust_radius)
230 : CALL section_vals_val_get(almo_opt_trustr_section, "CONJUGATOR", &
231 72 : i_val=almo_scf_env%opt_block_diag_trustr%conjugator)
232 : CALL section_vals_val_get(almo_opt_trustr_section, "PRECONDITIONER", &
233 72 : i_val=almo_scf_env%opt_block_diag_trustr%preconditioner)
234 :
235 : CALL section_vals_val_get(xalmo_opt_trustr_section, "EPS_ERROR", &
236 72 : r_val=almo_scf_env%opt_xalmo_trustr%eps_error)
237 : CALL section_vals_val_get(xalmo_opt_trustr_section, "MAX_ITER", &
238 72 : i_val=almo_scf_env%opt_xalmo_trustr%max_iter)
239 : CALL section_vals_val_get(xalmo_opt_trustr_section, "ALGORITHM", &
240 72 : i_val=almo_scf_env%opt_xalmo_trustr%trustr_algorithm)
241 : CALL section_vals_val_get(xalmo_opt_trustr_section, "EPS_ERROR_EARLY", &
242 72 : r_val=almo_scf_env%opt_xalmo_trustr%eps_error_early)
243 : CALL section_vals_val_get(xalmo_opt_trustr_section, "MAX_ITER_EARLY", &
244 72 : i_val=almo_scf_env%opt_xalmo_trustr%max_iter_early)
245 : CALL section_vals_val_get(xalmo_opt_trustr_section, "MAX_ITER_OUTER_LOOP", &
246 72 : i_val=almo_scf_env%opt_xalmo_trustr%max_iter_outer_loop)
247 : CALL section_vals_val_get(xalmo_opt_trustr_section, "ETA", &
248 72 : r_val=almo_scf_env%opt_xalmo_trustr%rho_do_not_update)
249 : almo_scf_env%opt_xalmo_trustr%rho_do_not_update = &
250 72 : MIN(MAX(almo_scf_env%opt_xalmo_trustr%rho_do_not_update, 0.0_dp), 0.25_dp)
251 : CALL section_vals_val_get(xalmo_opt_trustr_section, "MODEL_GRAD_NORM_RATIO", &
252 72 : r_val=almo_scf_env%opt_xalmo_trustr%model_grad_norm_ratio)
253 : CALL section_vals_val_get(xalmo_opt_trustr_section, "INITIAL_TRUST_RADIUS", &
254 72 : r_val=almo_scf_env%opt_xalmo_trustr%initial_trust_radius)
255 : CALL section_vals_val_get(xalmo_opt_trustr_section, "MAX_TRUST_RADIUS", &
256 72 : r_val=almo_scf_env%opt_xalmo_trustr%max_trust_radius)
257 : CALL section_vals_val_get(xalmo_opt_trustr_section, "CONJUGATOR", &
258 72 : i_val=almo_scf_env%opt_xalmo_trustr%conjugator)
259 : CALL section_vals_val_get(xalmo_opt_trustr_section, "PRECONDITIONER", &
260 72 : i_val=almo_scf_env%opt_xalmo_trustr%preconditioner)
261 :
262 : CALL section_vals_val_get(xalmo_opt_pcg_section, "EPS_ERROR", &
263 72 : r_val=almo_scf_env%opt_xalmo_pcg%eps_error)
264 : CALL section_vals_val_get(xalmo_opt_pcg_section, "MAX_ITER", &
265 72 : i_val=almo_scf_env%opt_xalmo_pcg%max_iter)
266 : CALL section_vals_val_get(xalmo_opt_pcg_section, "EPS_ERROR_EARLY", &
267 72 : r_val=almo_scf_env%opt_xalmo_pcg%eps_error_early)
268 : CALL section_vals_val_get(xalmo_opt_pcg_section, "MAX_ITER_EARLY", &
269 72 : i_val=almo_scf_env%opt_xalmo_pcg%max_iter_early)
270 : CALL section_vals_val_get(xalmo_opt_pcg_section, "MAX_ITER_OUTER_LOOP", &
271 72 : i_val=almo_scf_env%opt_xalmo_pcg%max_iter_outer_loop)
272 : CALL section_vals_val_get(xalmo_opt_pcg_section, "LIN_SEARCH_EPS_ERROR", &
273 72 : r_val=almo_scf_env%opt_xalmo_pcg%lin_search_eps_error)
274 : CALL section_vals_val_get(xalmo_opt_pcg_section, "LIN_SEARCH_STEP_SIZE_GUESS", &
275 72 : r_val=almo_scf_env%opt_xalmo_pcg%lin_search_step_size_guess)
276 : CALL section_vals_val_get(xalmo_opt_pcg_section, "PRECOND_FILTER_THRESHOLD", &
277 72 : r_val=almo_scf_env%opt_xalmo_pcg%neglect_threshold)
278 : CALL section_vals_val_get(xalmo_opt_pcg_section, "CONJUGATOR", &
279 72 : i_val=almo_scf_env%opt_xalmo_pcg%conjugator)
280 : CALL section_vals_val_get(xalmo_opt_pcg_section, "PRECONDITIONER", &
281 72 : i_val=almo_scf_env%opt_xalmo_pcg%preconditioner)
282 :
283 72 : penalty_section => section_vals_get_subs_vals(nlmo_opt_pcg_section, "PENALTY")
284 : CALL section_vals_val_get(nlmo_opt_pcg_section, "EPS_ERROR", &
285 72 : r_val=almo_scf_env%opt_nlmo_pcg%eps_error)
286 : CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER", &
287 72 : i_val=almo_scf_env%opt_nlmo_pcg%max_iter)
288 : CALL section_vals_val_get(nlmo_opt_pcg_section, "EPS_ERROR_EARLY", &
289 72 : r_val=almo_scf_env%opt_nlmo_pcg%eps_error_early)
290 : CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER_EARLY", &
291 72 : i_val=almo_scf_env%opt_nlmo_pcg%max_iter_early)
292 : CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER_OUTER_LOOP", &
293 72 : i_val=almo_scf_env%opt_nlmo_pcg%max_iter_outer_loop)
294 : CALL section_vals_val_get(nlmo_opt_pcg_section, "LIN_SEARCH_EPS_ERROR", &
295 72 : r_val=almo_scf_env%opt_nlmo_pcg%lin_search_eps_error)
296 : CALL section_vals_val_get(nlmo_opt_pcg_section, "LIN_SEARCH_STEP_SIZE_GUESS", &
297 72 : r_val=almo_scf_env%opt_nlmo_pcg%lin_search_step_size_guess)
298 : CALL section_vals_val_get(nlmo_opt_pcg_section, "PRECOND_FILTER_THRESHOLD", &
299 72 : r_val=almo_scf_env%opt_nlmo_pcg%neglect_threshold)
300 : CALL section_vals_val_get(nlmo_opt_pcg_section, "CONJUGATOR", &
301 72 : i_val=almo_scf_env%opt_nlmo_pcg%conjugator)
302 : CALL section_vals_val_get(nlmo_opt_pcg_section, "PRECONDITIONER", &
303 72 : i_val=almo_scf_env%opt_nlmo_pcg%preconditioner)
304 : CALL section_vals_val_get(penalty_section, &
305 : "OPERATOR", &
306 72 : i_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%operator_type)
307 : CALL section_vals_val_get(penalty_section, &
308 : "PENALTY_STRENGTH", &
309 72 : r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength)
310 : CALL section_vals_val_get(penalty_section, &
311 : "PENALTY_STRENGTH_DECREASE_FACTOR", &
312 72 : r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%penalty_strength_dec_factor)
313 : CALL section_vals_val_get(penalty_section, &
314 : "DETERMINANT_TOLERANCE", &
315 72 : r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%determinant_tolerance)
316 : CALL section_vals_val_get(penalty_section, &
317 : "FINAL_DETERMINANT", &
318 72 : r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%final_determinant)
319 : CALL section_vals_val_get(penalty_section, &
320 : "COMPACTIFICATION_FILTER_START", &
321 72 : r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%compactification_filter_start)
322 : CALL section_vals_val_get(penalty_section, &
323 : "VIRTUAL_NLMOS", &
324 72 : l_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%virtual_nlmos)
325 :
326 : CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "EPS_ERROR", &
327 72 : r_val=almo_scf_env%opt_xalmo_newton_pcg_solver%eps_error)
328 : CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "MAX_ITER", &
329 72 : i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%max_iter)
330 : CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "MAX_ITER_OUTER_LOOP", &
331 72 : i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%max_iter_outer_loop)
332 : CALL section_vals_val_get(xalmo_opt_newton_pcg_section, "PRECONDITIONER", &
333 72 : i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%preconditioner)
334 :
335 : CALL section_vals_val_get(almo_analysis_section, "_SECTION_PARAMETERS_", &
336 72 : l_val=almo_scf_env%almo_analysis%do_analysis)
337 : CALL section_vals_val_get(almo_analysis_section, "FROZEN_MO_ENERGY_TERM", &
338 72 : i_val=almo_scf_env%almo_analysis%frozen_mo_energy_term)
339 :
340 : fragment_section => section_vals_get_subs_vals(almo_scf_section, &
341 72 : "FRAGMENT")
342 : CALL section_vals_get(fragment_section, &
343 72 : explicit=explicit, n_repetition=ndomain)
344 :
345 72 : IF (explicit) THEN
346 18 : ALLOCATE (almo_scf_env%charge_of_domain(ndomain))
347 12 : ALLOCATE (almo_scf_env%multiplicity_of_domain(ndomain))
348 6 : ALLOCATE (almo_scf_env%activate(1))
349 18 : almo_scf_env%multiplicity_of_domain = 0
350 18 : almo_scf_env%charge_of_domain = 0
351 12 : almo_scf_env%activate = 1
352 18 : DO i = 1, ndomain
353 :
354 : CALL section_vals_val_get(fragment_section, "CHARGE", &
355 12 : i_rep_section=i, i_val=almo_scf_env%fragment%charge)
356 12 : almo_scf_env%charge_of_domain(i) = almo_scf_env%fragment%charge
357 :
358 : CALL section_vals_val_get(fragment_section, "MULTIPLICITY", &
359 12 : i_rep_section=i, i_val=almo_scf_env%fragment%multiplicity)
360 18 : almo_scf_env%multiplicity_of_domain(i) = almo_scf_env%fragment%multiplicity
361 : END DO
362 : ELSE
363 66 : ALLOCATE (almo_scf_env%activate(1))
364 132 : almo_scf_env%activate = 0
365 : END IF
366 :
367 72 : almo_scf_env%domain_layout_aos = almo_domain_layout_molecular
368 72 : almo_scf_env%domain_layout_mos = almo_domain_layout_molecular
369 72 : almo_scf_env%mat_distr_aos = almo_mat_distr_molecular
370 72 : almo_scf_env%mat_distr_mos = almo_mat_distr_molecular
371 :
372 72 : almo_scf_env%constraint_type = almo_constraint_distance
373 72 : almo_scf_env%mu = -0.1_dp
374 72 : almo_scf_env%fixed_mu = .FALSE.
375 72 : almo_scf_env%mixing_fraction = 0.45_dp
376 72 : almo_scf_env%eps_prev_guess = almo_scf_env%eps_filter/1000.0_dp
377 :
378 72 : almo_scf_env%deloc_cayley_tensor_type = tensor_orthogonal
379 72 : almo_scf_env%deloc_cayley_conjugator = cg_hager_zhang
380 72 : almo_scf_env%deloc_cayley_max_iter = 100
381 72 : almo_scf_env%deloc_use_occ_orbs = .TRUE.
382 72 : almo_scf_env%deloc_cayley_use_virt_orbs = .FALSE.
383 72 : almo_scf_env%deloc_cayley_linear = .FALSE.
384 72 : almo_scf_env%deloc_cayley_eps_convergence = 1.0E-6_dp
385 72 : almo_scf_env%deloc_cayley_occ_precond = .TRUE.
386 72 : almo_scf_env%deloc_cayley_vir_precond = .TRUE.
387 72 : almo_scf_env%deloc_truncate_virt = virt_full
388 72 : almo_scf_env%deloc_virt_per_domain = -1
389 :
390 72 : almo_scf_env%opt_k_eps_convergence = 1.0E-5_dp
391 72 : almo_scf_env%opt_k_max_iter = 100
392 72 : almo_scf_env%opt_k_outer_max_iter = 1
393 72 : almo_scf_env%opt_k_trial_step_size = 0.05_dp
394 72 : almo_scf_env%opt_k_conjugator = cg_hager_zhang
395 72 : almo_scf_env%opt_k_trial_step_size_multiplier = 1.05_dp
396 72 : almo_scf_env%opt_k_conj_iter_start = 0
397 72 : almo_scf_env%opt_k_prec_iter_start = 0
398 72 : almo_scf_env%opt_k_conj_iter_freq = 10000000
399 72 : almo_scf_env%opt_k_prec_iter_freq = 10000000
400 :
401 72 : almo_scf_env%quencher_radius_type = do_bondparm_vdw
402 72 : almo_scf_env%quencher_r1_factor = almo_scf_env%quencher_r0_factor
403 : !almo_scf_env%quencher_r0_shift=0.0_dp
404 : !almo_scf_env%quencher_r1_shift=0.0_dp
405 : !almo_scf_env%quencher_r0_shift = cp_unit_to_cp2k(&
406 : ! almo_scf_env%quencher_r0_shift,"angstrom")
407 : !almo_scf_env%quencher_r1_shift = cp_unit_to_cp2k(&
408 : ! almo_scf_env%quencher_r1_shift,"angstrom")
409 :
410 72 : almo_scf_env%quencher_s0 = 1.0E-4_dp
411 72 : almo_scf_env%quencher_s1 = 1.0E-6_dp
412 :
413 72 : almo_scf_env%envelope_amplitude = 1.0_dp
414 :
415 72 : almo_scf_env%logical01 = .FALSE. ! md in eDOF space
416 72 : almo_scf_env%logical02 = .TRUE. ! not used
417 72 : almo_scf_env%logical03 = .TRUE. ! not used
418 72 : almo_scf_env%logical04 = .TRUE. ! use preconditioner
419 72 : almo_scf_env%logical05 = .FALSE. ! optimize theta
420 :
421 72 : almo_scf_env%real01 = almo_scf_env%eps_filter/10.0_dp ! skip gradients
422 72 : almo_scf_env%real02 = 0.0_dp ! not used
423 72 : almo_scf_env%real03 = 0.0_dp ! not used
424 72 : almo_scf_env%real04 = 0.5_dp ! mixing s-f precond
425 :
426 72 : almo_scf_env%integer01 = 10 ! start eDOF-md
427 72 : almo_scf_env%integer02 = 4 ! preconditioner type
428 72 : almo_scf_env%integer03 = 0 ! not used
429 72 : almo_scf_env%integer04 = 0 ! fixed number of line searches (no grad)
430 72 : almo_scf_env%integer05 = 0 ! not used
431 :
432 : ! check for conflicts between options
433 72 : IF (almo_scf_env%xalmo_trial_wf == xalmo_trial_r0_out .AND. &
434 : almo_scf_env%xalmo_update_algorithm == almo_scf_trustr) THEN
435 0 : CPABORT("Trust region algorithm cannot optimize projected XALMOs")
436 : END IF
437 :
438 : CALL section_vals_val_get(almo_scf_section, "XALMO_ALGORITHM", &
439 72 : i_val=almo_scf_env%xalmo_update_algorithm)
440 : CALL section_vals_val_get(almo_scf_section, "XALMO_TRIAL_WF", &
441 72 : i_val=almo_scf_env%xalmo_trial_wf)
442 72 : IF (almo_scf_env%deloc_method == almo_deloc_xalmo_1diag .AND. &
443 : almo_scf_env%xalmo_update_algorithm /= almo_scf_diag) THEN
444 0 : CPABORT("1-step delocalization correction requires a different algorithm")
445 : END IF
446 :
447 : IF (almo_scf_env%xalmo_trial_wf == xalmo_trial_r0_out .AND. &
448 72 : almo_scf_env%almo_update_algorithm == almo_scf_skip .AND. &
449 : almo_scf_env%almo_scf_guess /= molecular_guess) THEN
450 0 : CPABORT("R0 projector requires optimized ALMOs")
451 : END IF
452 :
453 72 : IF (almo_scf_env%deloc_method == almo_deloc_none .AND. &
454 : almo_scf_env%almo_update_algorithm == almo_scf_skip) THEN
455 0 : CPABORT("No optimization requested")
456 : END IF
457 :
458 72 : IF (almo_scf_env%deloc_truncate_virt == virt_number .AND. &
459 : almo_scf_env%deloc_virt_per_domain <= 0) THEN
460 0 : CPABORT("specify a positive number of virtual orbitals")
461 : END IF
462 :
463 72 : IF (almo_scf_env%deloc_truncate_virt == virt_minimal) THEN
464 0 : CPABORT("VIRT TRUNCATION TO MINIMAL BASIS IS NIY")
465 : END IF
466 :
467 72 : IF (almo_scf_env%domain_layout_mos /= almo_domain_layout_molecular) THEN
468 0 : CPABORT("use MOLECULAR domains")
469 : END IF
470 :
471 72 : IF (almo_scf_env%domain_layout_aos /= almo_domain_layout_molecular) THEN
472 0 : CPABORT("use MOLECULAR domains")
473 : END IF
474 :
475 72 : IF (almo_scf_env%mat_distr_mos /= almo_mat_distr_molecular) THEN
476 0 : CPABORT("use MOLECULAR distr for MOs")
477 : END IF
478 :
479 72 : IF (almo_scf_env%mat_distr_aos == almo_mat_distr_molecular .AND. &
480 : almo_scf_env%domain_layout_aos == almo_domain_layout_atomic) THEN
481 0 : CPABORT("AO blocks cannot be larger than domains")
482 : END IF
483 :
484 72 : IF (almo_scf_env%mat_distr_mos == almo_mat_distr_molecular .AND. &
485 : almo_scf_env%domain_layout_mos == almo_domain_layout_atomic) THEN
486 0 : CPABORT("MO blocks cannot be larger than domains")
487 : END IF
488 :
489 72 : IF (almo_scf_env%quencher_r1_factor > almo_max_cutoff_multiplier) THEN
490 : CALL cp_abort(__LOCATION__, &
491 : "XALMO_R_CUTOFF_FACTOR is larger than almo_max_cutoff_multiplier. "// &
492 0 : "Increase the hard-coded almo_max_cutoff_multiplier")
493 : END IF
494 :
495 : ! check analysis settings
496 72 : IF (almo_scf_env%almo_analysis%do_analysis) THEN
497 :
498 : IF (almo_scf_env%almo_analysis%frozen_mo_energy_term == almo_frz_crystal &
499 8 : .AND. almo_scf_env%almo_scf_guess /= molecular_guess) THEN
500 0 : CPABORT("To compute frozen-MO energy term set ALMO_SCF_GUESS MOLECULAR")
501 : END IF
502 :
503 : END IF ! end analysis settings
504 :
505 72 : CALL timestop(handle)
506 :
507 72 : END SUBROUTINE almo_scf_init_read_write_input
508 :
509 : END MODULE almo_scf_env_methods
510 :
|