(git:c28f603)
Loading...
Searching...
No Matches
almo_scf_env_methods.F
Go to the documentation of this file.
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! **************************************************************************************************
15
19 USE input_constants, ONLY: &
29 USE kinds, ONLY: dp
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
43CONTAINS
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 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 CALL timeset(routinen, handle)
63
64 ALLOCATE (almo_scf_env)
65
66 ! get basic quantities from the qs_env
67 CALL get_qs_env(qs_env, input=input, dft_control=dft_control)
68
69 ! parse the almo_scf section and set appropriate quantities
70 CALL almo_scf_init_read_write_input(input, almo_scf_env)
71
72 ! set up the buffer for the history of matrices
73 almo_scf_env%nspins = dft_control%nspins
74 almo_scf_env%almo_history%nstore = almo_scf_env%almo_extrapolation_order
75 almo_scf_env%almo_history%istore = 0
76 ! do not allocate zero
77 nallocate = max(1, almo_scf_env%almo_extrapolation_order)
78 ALLOCATE (almo_scf_env%almo_history%matrix_p_up_down(almo_scf_env%nspins, nallocate))
79 ALLOCATE (almo_scf_env%almo_history%matrix_t(almo_scf_env%nspins))
80 almo_scf_env%xalmo_history%nstore = almo_scf_env%xalmo_extrapolation_order
81 almo_scf_env%xalmo_history%istore = 0
82 nallocate = max(1, almo_scf_env%xalmo_extrapolation_order)
83 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 ALLOCATE (almo_scf_env%xalmo_history%matrix_t(almo_scf_env%nspins))
86
87 ! put almo_scf_env in qs_env
88 CALL set_qs_env(qs_env, almo_scf_env=almo_scf_env)
89
90 CALL timestop(handle)
91
92 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 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 CALL timeset(routinen, handle)
117
118 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 "ALMO_OPTIMIZER_DIIS")
121 almo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, &
122 "ALMO_OPTIMIZER_PCG")
123 almo_opt_trustr_section => section_vals_get_subs_vals(almo_scf_section, &
124 "ALMO_OPTIMIZER_TRUSTR")
125 xalmo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, &
126 "XALMO_OPTIMIZER_PCG")
127 xalmo_opt_trustr_section => section_vals_get_subs_vals(almo_scf_section, &
128 "XALMO_OPTIMIZER_TRUSTR")
129 nlmo_opt_pcg_section => section_vals_get_subs_vals(almo_scf_section, &
130 "NLMO_OPTIMIZER_PCG")
131 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 "XALMO_NEWTON_PCG_SOLVER")
134 matrix_iterate_section => section_vals_get_subs_vals(almo_scf_section, &
135 "MATRIX_ITERATE")
136
137 ! read user input
138 ! common ALMO options
139 CALL section_vals_val_get(almo_scf_section, "EPS_FILTER", &
140 r_val=almo_scf_env%eps_filter)
141 CALL section_vals_val_get(almo_scf_section, "ALMO_SCF_GUESS", &
142 i_val=almo_scf_env%almo_scf_guess)
143 CALL section_vals_val_get(almo_scf_section, "ALMO_ALGORITHM", &
144 i_val=almo_scf_env%almo_update_algorithm)
145 CALL section_vals_val_get(almo_scf_section, "XALMO_ALGORITHM", &
146 i_val=almo_scf_env%xalmo_update_algorithm)
147 CALL section_vals_val_get(almo_scf_section, "XALMO_TRIAL_WF", &
148 i_val=almo_scf_env%xalmo_trial_wf)
149 CALL section_vals_val_get(almo_scf_section, "MO_OVERLAP_INV_ALG", &
150 i_val=almo_scf_env%sigma_inv_algorithm)
151 CALL section_vals_val_get(almo_scf_section, "DELOCALIZE_METHOD", &
152 i_val=almo_scf_env%deloc_method)
153 CALL section_vals_val_get(almo_scf_section, "XALMO_R_CUTOFF_FACTOR", &
154 r_val=almo_scf_env%quencher_r0_factor)
155 CALL section_vals_val_get(almo_scf_section, "ALMO_EXTRAPOLATION_ORDER", &
156 i_val=almo_scf_env%almo_extrapolation_order)
157 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 i_val=almo_scf_env%xalmo_extrapolation_order)
160 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 l_val=almo_scf_env%return_orthogonalized_mos)
163 CALL section_vals_val_get(almo_scf_section, "CONSTRUCT_NLMOS", &
164 l_val=almo_scf_env%construct_nlmos)
165
166 CALL section_vals_val_get(matrix_iterate_section, "EPS_LANCZOS", &
167 r_val=almo_scf_env%eps_lanczos)
168 CALL section_vals_val_get(matrix_iterate_section, "ORDER_LANCZOS", &
169 i_val=almo_scf_env%order_lanczos)
170 CALL section_vals_val_get(matrix_iterate_section, "MAX_ITER_LANCZOS", &
171 i_val=almo_scf_env%max_iter_lanczos)
172 CALL section_vals_val_get(matrix_iterate_section, "EPS_TARGET_FACTOR", &
173 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 r_val=almo_scf_env%opt_block_diag_diis%eps_error)
178 CALL section_vals_val_get(almo_opt_diis_section, "MAX_ITER", &
179 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 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 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 i_val=almo_scf_env%opt_block_diag_diis%ndiis)
186
187 CALL section_vals_val_get(almo_opt_pcg_section, "EPS_ERROR", &
188 r_val=almo_scf_env%opt_block_diag_pcg%eps_error)
189 CALL section_vals_val_get(almo_opt_pcg_section, "MAX_ITER", &
190 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 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 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 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 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 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 r_val=almo_scf_env%opt_block_diag_pcg%neglect_threshold)
203 CALL section_vals_val_get(almo_opt_pcg_section, "CONJUGATOR", &
204 i_val=almo_scf_env%opt_block_diag_pcg%conjugator)
205 CALL section_vals_val_get(almo_opt_pcg_section, "PRECONDITIONER", &
206 i_val=almo_scf_env%opt_block_diag_pcg%preconditioner)
207
208 CALL section_vals_val_get(almo_opt_trustr_section, "EPS_ERROR", &
209 r_val=almo_scf_env%opt_block_diag_trustr%eps_error)
210 CALL section_vals_val_get(almo_opt_trustr_section, "MAX_ITER", &
211 i_val=almo_scf_env%opt_block_diag_trustr%max_iter)
212 CALL section_vals_val_get(almo_opt_trustr_section, "ALGORITHM", &
213 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 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 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 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 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 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 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 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 r_val=almo_scf_env%opt_block_diag_trustr%max_trust_radius)
230 CALL section_vals_val_get(almo_opt_trustr_section, "CONJUGATOR", &
231 i_val=almo_scf_env%opt_block_diag_trustr%conjugator)
232 CALL section_vals_val_get(almo_opt_trustr_section, "PRECONDITIONER", &
233 i_val=almo_scf_env%opt_block_diag_trustr%preconditioner)
234
235 CALL section_vals_val_get(xalmo_opt_trustr_section, "EPS_ERROR", &
236 r_val=almo_scf_env%opt_xalmo_trustr%eps_error)
237 CALL section_vals_val_get(xalmo_opt_trustr_section, "MAX_ITER", &
238 i_val=almo_scf_env%opt_xalmo_trustr%max_iter)
239 CALL section_vals_val_get(xalmo_opt_trustr_section, "ALGORITHM", &
240 i_val=almo_scf_env%opt_xalmo_trustr%trustr_algorithm)
241 CALL section_vals_val_get(xalmo_opt_trustr_section, "EPS_ERROR_EARLY", &
242 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 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 i_val=almo_scf_env%opt_xalmo_trustr%max_iter_outer_loop)
247 CALL section_vals_val_get(xalmo_opt_trustr_section, "ETA", &
248 r_val=almo_scf_env%opt_xalmo_trustr%rho_do_not_update)
249 almo_scf_env%opt_xalmo_trustr%rho_do_not_update = &
250 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 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 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 r_val=almo_scf_env%opt_xalmo_trustr%max_trust_radius)
257 CALL section_vals_val_get(xalmo_opt_trustr_section, "CONJUGATOR", &
258 i_val=almo_scf_env%opt_xalmo_trustr%conjugator)
259 CALL section_vals_val_get(xalmo_opt_trustr_section, "PRECONDITIONER", &
260 i_val=almo_scf_env%opt_xalmo_trustr%preconditioner)
261
262 CALL section_vals_val_get(xalmo_opt_pcg_section, "EPS_ERROR", &
263 r_val=almo_scf_env%opt_xalmo_pcg%eps_error)
264 CALL section_vals_val_get(xalmo_opt_pcg_section, "MAX_ITER", &
265 i_val=almo_scf_env%opt_xalmo_pcg%max_iter)
266 CALL section_vals_val_get(xalmo_opt_pcg_section, "EPS_ERROR_EARLY", &
267 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 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 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 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 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 r_val=almo_scf_env%opt_xalmo_pcg%neglect_threshold)
278 CALL section_vals_val_get(xalmo_opt_pcg_section, "CONJUGATOR", &
279 i_val=almo_scf_env%opt_xalmo_pcg%conjugator)
280 CALL section_vals_val_get(xalmo_opt_pcg_section, "PRECONDITIONER", &
281 i_val=almo_scf_env%opt_xalmo_pcg%preconditioner)
282
283 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 r_val=almo_scf_env%opt_nlmo_pcg%eps_error)
286 CALL section_vals_val_get(nlmo_opt_pcg_section, "MAX_ITER", &
287 i_val=almo_scf_env%opt_nlmo_pcg%max_iter)
288 CALL section_vals_val_get(nlmo_opt_pcg_section, "EPS_ERROR_EARLY", &
289 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 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 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 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 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 r_val=almo_scf_env%opt_nlmo_pcg%neglect_threshold)
300 CALL section_vals_val_get(nlmo_opt_pcg_section, "CONJUGATOR", &
301 i_val=almo_scf_env%opt_nlmo_pcg%conjugator)
302 CALL section_vals_val_get(nlmo_opt_pcg_section, "PRECONDITIONER", &
303 i_val=almo_scf_env%opt_nlmo_pcg%preconditioner)
304 CALL section_vals_val_get(penalty_section, &
305 "OPERATOR", &
306 i_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%operator_type)
307 CALL section_vals_val_get(penalty_section, &
308 "PENALTY_STRENGTH", &
309 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 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 r_val=almo_scf_env%opt_nlmo_pcg%opt_penalty%determinant_tolerance)
316 CALL section_vals_val_get(penalty_section, &
317 "FINAL_DETERMINANT", &
318 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 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 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 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 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 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 i_val=almo_scf_env%opt_xalmo_newton_pcg_solver%preconditioner)
334
335 CALL section_vals_val_get(almo_analysis_section, "_SECTION_PARAMETERS_", &
336 l_val=almo_scf_env%almo_analysis%do_analysis)
337 CALL section_vals_val_get(almo_analysis_section, "FROZEN_MO_ENERGY_TERM", &
338 i_val=almo_scf_env%almo_analysis%frozen_mo_energy_term)
339
340 fragment_section => section_vals_get_subs_vals(almo_scf_section, &
341 "FRAGMENT")
342 CALL section_vals_get(fragment_section, &
343 explicit=explicit, n_repetition=ndomain)
344
345 IF (explicit) THEN
346 ALLOCATE (almo_scf_env%charge_of_domain(ndomain))
347 ALLOCATE (almo_scf_env%multiplicity_of_domain(ndomain))
348 ALLOCATE (almo_scf_env%activate(1))
349 almo_scf_env%multiplicity_of_domain = 0
350 almo_scf_env%charge_of_domain = 0
351 almo_scf_env%activate = 1
352 DO i = 1, ndomain
353
354 CALL section_vals_val_get(fragment_section, "CHARGE", &
355 i_rep_section=i, i_val=almo_scf_env%fragment%charge)
356 almo_scf_env%charge_of_domain(i) = almo_scf_env%fragment%charge
357
358 CALL section_vals_val_get(fragment_section, "MULTIPLICITY", &
359 i_rep_section=i, i_val=almo_scf_env%fragment%multiplicity)
360 almo_scf_env%multiplicity_of_domain(i) = almo_scf_env%fragment%multiplicity
361 END DO
362 ELSE
363 ALLOCATE (almo_scf_env%activate(1))
364 almo_scf_env%activate = 0
365 END IF
366
367 !CALL section_vals_val_get(almo_scf_section,"DOMAIN_LAYOUT_AOS",&
368 ! i_val=almo_scf_env%domain_layout_aos)
369 !CALL section_vals_val_get(almo_scf_section,"DOMAIN_LAYOUT_MOS",&
370 ! i_val=almo_scf_env%domain_layout_mos)
371 !CALL section_vals_val_get(almo_scf_section,"MATRIX_CLUSTERING_AOS",&
372 ! i_val=almo_scf_env%mat_distr_aos)
373 !CALL section_vals_val_get(almo_scf_section,"MATRIX_CLUSTERING_MOS",&
374 ! i_val=almo_scf_env%mat_distr_mos)
375 !CALL section_vals_val_get(almo_scf_section,"CONSTRAINT_TYPE",&
376 ! i_val=almo_scf_env%constraint_type)
377 !CALL section_vals_val_get(almo_scf_section,"MU",&
378 ! r_val=almo_scf_env%mu)
379 !CALL section_vals_val_get(almo_scf_section,"FIXED_MU",&
380 ! l_val=almo_scf_env%fixed_mu)
381 !CALL section_vals_val_get(almo_scf_section,"EPS_USE_PREV_AS_GUESS",&
382 ! r_val=almo_scf_env%eps_prev_guess)
383 !CALL section_vals_val_get(almo_scf_section,"MIXING_FRACTION",&
384 ! r_val=almo_scf_env%mixing_fraction)
385 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_TENSOR_TYPE",&
386 ! i_val=almo_scf_env%deloc_cayley_tensor_type)
387 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_CONJUGATOR",&
388 ! i_val=almo_scf_env%deloc_cayley_conjugator)
389 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_MAX_ITER",&
390 ! i_val=almo_scf_env%deloc_cayley_max_iter)
391 !CALL section_vals_val_get(almo_scf_section,"DELOC_USE_OCC_ORBS",&
392 ! l_val=almo_scf_env%deloc_use_occ_orbs)
393 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_USE_VIRT_ORBS",&
394 ! l_val=almo_scf_env%deloc_cayley_use_virt_orbs)
395 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_LINEAR",&
396 ! l_val=almo_scf_env%deloc_cayley_linear)
397 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_EPS_CONVERGENCE",&
398 ! r_val=almo_scf_env%deloc_cayley_eps_convergence)
399 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_OCC_PRECOND",&
400 ! l_val=almo_scf_env%deloc_cayley_occ_precond)
401 !CALL section_vals_val_get(almo_scf_section,"DELOC_CAYLEY_VIR_PRECOND",&
402 ! l_val=almo_scf_env%deloc_cayley_vir_precond)
403 !CALL section_vals_val_get(almo_scf_section,"ALMO_UPDATE_ALGORITHM_BD",&
404 ! i_val=almo_scf_env%almo_update_algorithm)
405 !CALL section_vals_val_get(almo_scf_section,"DELOC_TRUNCATE_VIRTUALS",&
406 ! i_val=almo_scf_env%deloc_truncate_virt)
407 !CALL section_vals_val_get(almo_scf_section,"DELOC_VIRT_PER_DOMAIN",&
408 ! i_val=almo_scf_env%deloc_virt_per_domain)
409 !
410 !CALL section_vals_val_get(almo_scf_section,"OPT_K_EPS_CONVERGENCE",&
411 ! r_val=almo_scf_env%opt_k_eps_convergence)
412 !CALL section_vals_val_get(almo_scf_section,"OPT_K_MAX_ITER",&
413 ! i_val=almo_scf_env%opt_k_max_iter)
414 !CALL section_vals_val_get(almo_scf_section,"OPT_K_OUTER_MAX_ITER",&
415 ! i_val=almo_scf_env%opt_k_outer_max_iter)
416 !CALL section_vals_val_get(almo_scf_section,"OPT_K_TRIAL_STEP_SIZE",&
417 ! r_val=almo_scf_env%opt_k_trial_step_size)
418 !CALL section_vals_val_get(almo_scf_section,"OPT_K_CONJUGATOR",&
419 ! i_val=almo_scf_env%opt_k_conjugator)
420 !CALL section_vals_val_get(almo_scf_section,"OPT_K_TRIAL_STEP_SIZE_MULTIPLIER",&
421 ! r_val=almo_scf_env%opt_k_trial_step_size_multiplier)
422 !CALL section_vals_val_get(almo_scf_section,"OPT_K_CONJ_ITER_START",&
423 ! i_val=almo_scf_env%opt_k_conj_iter_start)
424 !CALL section_vals_val_get(almo_scf_section,"OPT_K_PREC_ITER_START",&
425 ! i_val=almo_scf_env%opt_k_prec_iter_start)
426 !CALL section_vals_val_get(almo_scf_section,"OPT_K_CONJ_ITER_FREQ_RESET",&
427 ! i_val=almo_scf_env%opt_k_conj_iter_freq)
428 !CALL section_vals_val_get(almo_scf_section,"OPT_K_PREC_ITER_FREQ_UPDATE",&
429 ! i_val=almo_scf_env%opt_k_prec_iter_freq)
430 !
431 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_RADIUS_TYPE",&
432 ! i_val=almo_scf_env%quencher_radius_type)
433 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_R0_FACTOR",&
434 ! r_val=almo_scf_env%quencher_r0_factor)
435 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_R1_FACTOR",&
436 ! r_val=almo_scf_env%quencher_r1_factor)
437 !!CALL section_vals_val_get(almo_scf_section,"QUENCHER_R0_SHIFT",&
438 !! r_val=almo_scf_env%quencher_r0_shift)
439 !!
440 !!CALL section_vals_val_get(almo_scf_section,"QUENCHER_R1_SHIFT",&
441 !! r_val=almo_scf_env%quencher_r1_shift)
442 !!
443 !!almo_scf_env%quencher_r0_shift = cp_unit_to_cp2k(&
444 !! almo_scf_env%quencher_r0_shift,"angstrom")
445 !!almo_scf_env%quencher_r1_shift = cp_unit_to_cp2k(&
446 !! almo_scf_env%quencher_r1_shift,"angstrom")
447 !
448 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_AO_OVERLAP_0",&
449 ! r_val=almo_scf_env%quencher_s0)
450 !CALL section_vals_val_get(almo_scf_section,"QUENCHER_AO_OVERLAP_1",&
451 ! r_val=almo_scf_env%quencher_s1)
452
453 !CALL section_vals_val_get(almo_scf_section,"ENVELOPE_AMPLITUDE",&
454 ! r_val=almo_scf_env%envelope_amplitude)
455
456 !! how to read lists
457 !CALL section_vals_val_get(almo_scf_section,"INT_LIST01", &
458 ! n_rep_val=n_rep)
459 !counter_i = 0
460 !DO k = 1,n_rep
461 ! CALL section_vals_val_get(almo_scf_section,"INT_LIST01",&
462 ! i_rep_val=k,i_vals=tmplist)
463 ! DO jj = 1,SIZE(tmplist)
464 ! counter_i=counter_i+1
465 ! almo_scf_env%charge_of_domain(counter_i)=tmplist(jj)
466 ! ENDDO
467 !ENDDO
468
469 almo_scf_env%domain_layout_aos = almo_domain_layout_molecular
470 almo_scf_env%domain_layout_mos = almo_domain_layout_molecular
471 almo_scf_env%mat_distr_aos = almo_mat_distr_molecular
472 almo_scf_env%mat_distr_mos = almo_mat_distr_molecular
473
474 almo_scf_env%constraint_type = almo_constraint_distance
475 almo_scf_env%mu = -0.1_dp
476 almo_scf_env%fixed_mu = .false.
477 almo_scf_env%mixing_fraction = 0.45_dp
478 almo_scf_env%eps_prev_guess = almo_scf_env%eps_filter/1000.0_dp
479
480 almo_scf_env%deloc_cayley_tensor_type = tensor_orthogonal
481 almo_scf_env%deloc_cayley_conjugator = cg_hager_zhang
482 almo_scf_env%deloc_cayley_max_iter = 100
483 almo_scf_env%deloc_use_occ_orbs = .true.
484 almo_scf_env%deloc_cayley_use_virt_orbs = .false.
485 almo_scf_env%deloc_cayley_linear = .false.
486 almo_scf_env%deloc_cayley_eps_convergence = 1.0e-6_dp
487 almo_scf_env%deloc_cayley_occ_precond = .true.
488 almo_scf_env%deloc_cayley_vir_precond = .true.
489 almo_scf_env%deloc_truncate_virt = virt_full
490 almo_scf_env%deloc_virt_per_domain = -1
491
492 almo_scf_env%opt_k_eps_convergence = 1.0e-5_dp
493 almo_scf_env%opt_k_max_iter = 100
494 almo_scf_env%opt_k_outer_max_iter = 1
495 almo_scf_env%opt_k_trial_step_size = 0.05_dp
496 almo_scf_env%opt_k_conjugator = cg_hager_zhang
497 almo_scf_env%opt_k_trial_step_size_multiplier = 1.05_dp
498 almo_scf_env%opt_k_conj_iter_start = 0
499 almo_scf_env%opt_k_prec_iter_start = 0
500 almo_scf_env%opt_k_conj_iter_freq = 10000000
501 almo_scf_env%opt_k_prec_iter_freq = 10000000
502
503 almo_scf_env%quencher_radius_type = do_bondparm_vdw
504 almo_scf_env%quencher_r1_factor = almo_scf_env%quencher_r0_factor
505 !almo_scf_env%quencher_r0_shift=0.0_dp
506 !almo_scf_env%quencher_r1_shift=0.0_dp
507 !almo_scf_env%quencher_r0_shift = cp_unit_to_cp2k(&
508 ! almo_scf_env%quencher_r0_shift,"angstrom")
509 !almo_scf_env%quencher_r1_shift = cp_unit_to_cp2k(&
510 ! almo_scf_env%quencher_r1_shift,"angstrom")
511
512 almo_scf_env%quencher_s0 = 1.0e-4_dp
513 almo_scf_env%quencher_s1 = 1.0e-6_dp
514
515 almo_scf_env%envelope_amplitude = 1.0_dp
516
517 almo_scf_env%logical01 = .false. ! md in eDOF space
518 almo_scf_env%logical02 = .true. ! not used
519 almo_scf_env%logical03 = .true. ! not used
520 almo_scf_env%logical04 = .true. ! use preconditioner
521 almo_scf_env%logical05 = .false. ! optimize theta
522
523 almo_scf_env%real01 = almo_scf_env%eps_filter/10.0_dp ! skip gradients
524 almo_scf_env%real02 = 0.0_dp ! not used
525 almo_scf_env%real03 = 0.0_dp ! not used
526 almo_scf_env%real04 = 0.5_dp ! mixing s-f precond
527
528 almo_scf_env%integer01 = 10 ! start eDOF-md
529 almo_scf_env%integer02 = 4 ! preconditioner type
530 almo_scf_env%integer03 = 0 ! not used
531 almo_scf_env%integer04 = 0 ! fixed number of line searches (no grad)
532 almo_scf_env%integer05 = 0 ! not used
533
534 ! check for conflicts between options
535 IF (almo_scf_env%xalmo_trial_wf == xalmo_trial_r0_out .AND. &
536 almo_scf_env%xalmo_update_algorithm == almo_scf_trustr) THEN
537 cpabort("Trust region algorithm cannot optimize projected XALMOs")
538 END IF
539
540 CALL section_vals_val_get(almo_scf_section, "XALMO_ALGORITHM", &
541 i_val=almo_scf_env%xalmo_update_algorithm)
542 CALL section_vals_val_get(almo_scf_section, "XALMO_TRIAL_WF", &
543 i_val=almo_scf_env%xalmo_trial_wf)
544 IF (almo_scf_env%deloc_method == almo_deloc_xalmo_1diag .AND. &
545 almo_scf_env%xalmo_update_algorithm /= almo_scf_diag) THEN
546 cpabort("1-step delocalization correction requires a different algorithm")
547 END IF
548
549 IF (almo_scf_env%xalmo_trial_wf == xalmo_trial_r0_out .AND. &
550 almo_scf_env%almo_update_algorithm == almo_scf_skip .AND. &
551 almo_scf_env%almo_scf_guess /= molecular_guess) THEN
552 cpabort("R0 projector requires optimized ALMOs")
553 END IF
554
555 IF (almo_scf_env%deloc_method == almo_deloc_none .AND. &
556 almo_scf_env%almo_update_algorithm == almo_scf_skip) THEN
557 cpabort("No optimization requested")
558 END IF
559
560 IF (almo_scf_env%deloc_truncate_virt == virt_number .AND. &
561 almo_scf_env%deloc_virt_per_domain <= 0) THEN
562 cpabort("specify a positive number of virtual orbitals")
563 END IF
564
565 IF (almo_scf_env%deloc_truncate_virt == virt_minimal) THEN
566 cpabort("VIRT TRUNCATION TO MINIMAL BASIS IS NIY")
567 END IF
568
569 IF (almo_scf_env%domain_layout_mos /= almo_domain_layout_molecular) THEN
570 cpabort("use MOLECULAR domains")
571 END IF
572
573 IF (almo_scf_env%domain_layout_aos /= almo_domain_layout_molecular) THEN
574 cpabort("use MOLECULAR domains")
575 END IF
576
577 IF (almo_scf_env%mat_distr_mos /= almo_mat_distr_molecular) THEN
578 cpabort("use MOLECULAR distr for MOs")
579 END IF
580
581 IF (almo_scf_env%mat_distr_aos == almo_mat_distr_molecular .AND. &
582 almo_scf_env%domain_layout_aos == almo_domain_layout_atomic) THEN
583 cpabort("AO blocks cannot be larger than domains")
584 END IF
585
586 IF (almo_scf_env%mat_distr_mos == almo_mat_distr_molecular .AND. &
587 almo_scf_env%domain_layout_mos == almo_domain_layout_atomic) THEN
588 cpabort("MO blocks cannot be larger than domains")
589 END IF
590
591 IF (almo_scf_env%quencher_r1_factor > almo_max_cutoff_multiplier) THEN
592 CALL cp_abort(__location__, &
593 "XALMO_R_CUTOFF_FACTOR is larger than almo_max_cutoff_multiplier. "// &
594 "Increase the hard-coded almo_max_cutoff_multiplier")
595 END IF
596
597 ! check analysis settings
598 IF (almo_scf_env%almo_analysis%do_analysis) THEN
599
600 IF (almo_scf_env%almo_analysis%frozen_mo_energy_term == almo_frz_crystal &
601 .AND. almo_scf_env%almo_scf_guess /= molecular_guess) THEN
602 cpabort("To compute frozen-MO energy term set ALMO_SCF_GUESS MOLECULAR")
603 END IF
604
605 END IF ! end analysis settings
606
607 CALL timestop(handle)
608
609 END SUBROUTINE almo_scf_init_read_write_input
610
611END MODULE almo_scf_env_methods
612
almo_scf_env methods
subroutine, public almo_scf_env_create(qs_env)
Creation and basic initialization of the almo environment.
Types for all ALMO-based methods.
real(kind=dp), parameter, public almo_max_cutoff_multiplier
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public xalmo_trial_r0_out
integer, parameter, public molecular_guess
integer, parameter, public almo_constraint_distance
integer, parameter, public virt_number
integer, parameter, public almo_domain_layout_atomic
integer, parameter, public almo_mat_distr_molecular
integer, parameter, public almo_domain_layout_molecular
integer, parameter, public do_bondparm_vdw
integer, parameter, public almo_scf_diag
integer, parameter, public almo_frz_crystal
integer, parameter, public almo_scf_skip
integer, parameter, public almo_scf_trustr
integer, parameter, public virt_minimal
integer, parameter, public virt_full
integer, parameter, public tensor_orthogonal
integer, parameter, public almo_deloc_xalmo_1diag
integer, parameter, public almo_deloc_none
integer, parameter, public cg_hager_zhang
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.