(git:cccd2f3)
Loading...
Searching...
No Matches
qs_density_mixing_types.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 module that contains the definitions of the scf types
10!> \par History
11!> 02.2003 created [fawzi]
12!> \author fawzi
13! **************************************************************************************************
15#if defined(__TBLITE)
16 USE tblite_scf, ONLY: mixer_type
17#endif
18 USE ao_util, ONLY: exp_radius
19 USE input_constants, ONLY: broy_mix, &
21 gaussian, &
22 kerker_mix, &
24 no_mix, &
34 USE input_val_types, ONLY: real_t
35 USE kinds, ONLY: default_string_length, &
36 dp
38 USE string_utilities, ONLY: s2a
39#include "./base/base_uses.f90"
40
41 IMPLICIT NONE
42 PRIVATE
43
44 LOGICAL, PRIVATE, PARAMETER :: debug_this_module = .true.
45
46 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_density_mixing_types'
47
48 INTEGER, PARAMETER, PUBLIC :: no_mixing_nr = 0, direct_mixing_nr = 1, &
53
55 COMPLEX(dp), DIMENSION(:), POINTER :: cc => null()
56 END TYPE cp_1d_z_p_type
57
59 INTEGER :: ig_max = -1, ncall = -1, ncall_p(2) = -1, nbuffer = -1, n_simple_mix = -1, &
60 nskip_mixing = -1, p_metric_method = -1
61 INTEGER, POINTER, DIMENSION(:) :: ig_global_index => null()
62 LOGICAL :: gmix_p = .false.
63 LOGICAL, POINTER, DIMENSION(:) :: paw => null()
64 CHARACTER(len=15) :: iter_method = ""
65 REAL(kind=dp) :: alpha = -1.0_dp, bconst = -1.0_dp, beta = -1.0_dp, broy_w0 = -1.0_dp, &
66 max_g2 = -1.0_dp, max_gvec_exp = -1.0_dp, pulay_alpha = -1.0_dp, &
67 pulay_beta = -1.0_dp, r_step = -1.0_dp, reg_par = -1.0_dp, &
68 sigma_max = -1.0_dp, wc = -1.0_dp, wmax = -1.0_dp
69 ! Spin-channel-specific mixing parameters (for nspin==2, ispin=2 is the magnetization channel)
70 REAL(kind=dp) :: alpha_mag = -1.0_dp, beta_mag = -1.0_dp
71 REAL(kind=dp), DIMENSION(:), POINTER :: p_metric => null()
72 REAL(kind=dp), DIMENSION(:), POINTER :: kerker_factor => null()
73 REAL(kind=dp), DIMENSION(:), POINTER :: kerker_factor_mag => null()
74 REAL(kind=dp), DIMENSION(:), POINTER :: special_metric => null()
75 REAL(kind=dp), DIMENSION(:, :), POINTER :: weight => null()
76 REAL(kind=dp), DIMENSION(:, :), POINTER :: norm_res_buffer => null()
77 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: fmat => null(), gmat => null(), pulay_matrix => null(), smat => null()
78 !
79 INTEGER :: nat_local = -1, max_shell = -1
80 INTEGER :: tb_scc_mixer_memory = 0, tb_scc_mixer_natom = 0, &
81 tb_scc_mixer_ns = 0, tb_scc_mixer_step = 0
82 REAL(kind=dp) :: tb_scc_mixer_error = 0.0_dp
83 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: acharge => null()
84 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: dacharge => null()
85 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: dfbroy => null()
86 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: ubroy => null()
87 REAL(kind=dp), DIMENSION(:, :), POINTER :: abroy => null()
88 REAL(kind=dp), DIMENSION(:), POINTER :: wbroy => null()
89 INTEGER, DIMENSION(:), POINTER :: atlist => null()
90 !
91 TYPE(cp_1d_z_p_type), DIMENSION(:), POINTER :: last_res => null(), rhoin => null(), rhoin_old => null()
92 TYPE(cp_1d_z_p_type), DIMENSION(:, :), POINTER :: delta_res => null(), u_vec => null(), z_vec => null()
93 TYPE(cp_1d_z_p_type), DIMENSION(:, :), POINTER :: drho_buffer => null(), rhoin_buffer => null(), res_buffer => null()
94 !
95 TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: cpc_h_lastres => null(), cpc_s_lastres => null()
96 TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: cpc_h_in => null(), cpc_s_in => null()
97 TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER :: cpc_h_old => null(), cpc_s_old => null()
98 TYPE(rho_atom_coeff), DIMENSION(:, :, :), POINTER :: cpc_h_in_buffer => null(), cpc_s_in_buffer => null()
99 TYPE(rho_atom_coeff), DIMENSION(:, :, :), POINTER :: cpc_h_res_buffer => null(), cpc_s_res_buffer => null()
100 TYPE(rho_atom_coeff), DIMENSION(:, :, :), POINTER :: dcpc_h_in => null(), dcpc_s_in => null()
101#if defined(__TBLITE)
102 CLASS(mixer_type), ALLOCATABLE :: tb_scc_mixer
103#endif
104 END TYPE mixing_storage_type
105
106CONTAINS
107
108! **************************************************************************************************
109!> \brief creates a mixing_storage
110!> \param mixing_store ...
111!> \param mixing_section ...
112!> \param mixing_method ...
113!> \param ecut ...
114!> \par History
115!> 05.2009 created [MI]
116!> \author [MI]
117! **************************************************************************************************
118 SUBROUTINE mixing_storage_create(mixing_store, mixing_section, mixing_method, ecut)
119 TYPE(mixing_storage_type), INTENT(OUT) :: mixing_store
120 TYPE(section_vals_type), POINTER :: mixing_section
121 INTEGER, INTENT(IN) :: mixing_method
122 REAL(dp), INTENT(IN) :: ecut
123
124 REAL(dp) :: alpha, eps, gcut
125
126 mixing_store%nbuffer = 0
127 mixing_store%n_simple_mix = 0
128 mixing_store%ncall = 0
129 mixing_store%ncall_p = 0
130 mixing_store%alpha = 1.0_dp
131 mixing_store%pulay_beta = 1.0_dp
132 mixing_store%beta = 1.0_dp
133 mixing_store%alpha_mag = -1.0_dp
134 mixing_store%beta_mag = -1.0_dp
135 mixing_store%iter_method = "NoMix"
136 mixing_store%max_g2 = 2._dp*ecut
137 mixing_store%gmix_p = .false.
138 mixing_store%tb_scc_mixer_error = 0.0_dp
139 mixing_store%tb_scc_mixer_memory = 0
140 mixing_store%tb_scc_mixer_natom = 0
141 mixing_store%tb_scc_mixer_ns = 0
142 mixing_store%tb_scc_mixer_step = 0
143
144 NULLIFY (mixing_store%p_metric)
145 NULLIFY (mixing_store%kerker_factor)
146 NULLIFY (mixing_store%kerker_factor_mag)
147 NULLIFY (mixing_store%special_metric)
148 NULLIFY (mixing_store%pulay_matrix)
149 NULLIFY (mixing_store%weight)
150 NULLIFY (mixing_store%fmat)
151 NULLIFY (mixing_store%gmat)
152 NULLIFY (mixing_store%smat)
153 NULLIFY (mixing_store%acharge)
154 NULLIFY (mixing_store%dacharge)
155 NULLIFY (mixing_store%dfbroy)
156 NULLIFY (mixing_store%ubroy)
157 NULLIFY (mixing_store%abroy)
158 NULLIFY (mixing_store%wbroy)
159 NULLIFY (mixing_store%atlist)
160 NULLIFY (mixing_store%last_res)
161 NULLIFY (mixing_store%rhoin)
162 NULLIFY (mixing_store%rhoin_old)
163 NULLIFY (mixing_store%delta_res)
164 NULLIFY (mixing_store%u_vec)
165 NULLIFY (mixing_store%z_vec)
166 NULLIFY (mixing_store%drho_buffer)
167 NULLIFY (mixing_store%rhoin_buffer)
168 NULLIFY (mixing_store%res_buffer)
169 NULLIFY (mixing_store%norm_res_buffer)
170 NULLIFY (mixing_store%ig_global_index)
171 NULLIFY (mixing_store%paw)
172 NULLIFY (mixing_store%cpc_h_in)
173 NULLIFY (mixing_store%cpc_s_in)
174 NULLIFY (mixing_store%cpc_h_old)
175 NULLIFY (mixing_store%cpc_s_old)
176 NULLIFY (mixing_store%dcpc_h_in)
177 NULLIFY (mixing_store%dcpc_s_in)
178 NULLIFY (mixing_store%cpc_h_lastres)
179 NULLIFY (mixing_store%cpc_s_lastres)
180 NULLIFY (mixing_store%cpc_h_in_buffer)
181 NULLIFY (mixing_store%cpc_s_in_buffer)
182 NULLIFY (mixing_store%cpc_h_res_buffer)
183 NULLIFY (mixing_store%cpc_s_res_buffer)
184
185 CALL section_vals_val_get(mixing_section, "ALPHA", r_val=mixing_store%alpha)
186 CALL section_vals_val_get(mixing_section, "BETA", r_val=mixing_store%beta)
187 CALL section_vals_val_get(mixing_section, "ALPHA_MAG", r_val=mixing_store%alpha_mag)
188 CALL section_vals_val_get(mixing_section, "BETA_MAG", r_val=mixing_store%beta_mag)
189 ! Fall back to charge-channel values if magnetization parameters are not set
190 IF (mixing_store%alpha_mag < 0.0_dp) mixing_store%alpha_mag = mixing_store%alpha
191 IF (mixing_store%beta_mag < 0.0_dp) mixing_store%beta_mag = mixing_store%beta
192 CALL section_vals_val_get(mixing_section, "N_SIMPLE_MIX", i_val=mixing_store%n_simple_mix)
193 CALL section_vals_val_get(mixing_section, "NBUFFER", i_val=mixing_store%nbuffer)
194 CALL section_vals_val_get(mixing_section, "NSKIP", i_val=mixing_store%nskip_mixing)
195 CALL section_vals_val_get(mixing_section, "MAX_GVEC_EXP", r_val=mixing_store%max_gvec_exp)
196 CALL section_vals_val_get(mixing_section, "GMIX_P", l_val=mixing_store%gmix_p)
197
198 IF (mixing_store%max_gvec_exp > 0._dp) THEN
199 alpha = 0.25_dp/mixing_store%max_gvec_exp
200 eps = 1.e-4_dp
201 gcut = exp_radius(3, alpha, eps, 1.0_dp)
202 mixing_store%max_g2 = gcut*gcut
203 END IF
204
205 SELECT CASE (mixing_method)
206 CASE (gspace_mixing_nr)
207 mixing_store%nbuffer = 1
208 CASE (pulay_mixing_nr)
209 CALL section_vals_val_get(mixing_section, "PULAY_ALPHA", r_val=mixing_store%pulay_alpha)
210 CALL section_vals_val_get(mixing_section, "PULAY_BETA", r_val=mixing_store%pulay_beta)
211 CASE (broyden_mixing_nr)
212 CALL section_vals_val_get(mixing_section, "BROY_W0", r_val=mixing_store%broy_w0)
213 mixing_store%bconst = 20.0_dp
215 CALL section_vals_val_get(mixing_section, "REGULARIZATION", r_val=mixing_store%reg_par)
216 CALL section_vals_val_get(mixing_section, "MAX_STEP", r_val=mixing_store%sigma_max)
217 CALL section_vals_val_get(mixing_section, "R_FACTOR", r_val=mixing_store%r_step)
218 END SELECT
219
220 END SUBROUTINE mixing_storage_create
221
222! **************************************************************************************************
223!> \brief releases a mixing_storage
224!> \param mixing_store ...
225!> \par History
226!> 05.2009 created [MI]
227!> \author [MI]
228! **************************************************************************************************
229 SUBROUTINE mixing_storage_release(mixing_store)
230 TYPE(mixing_storage_type), INTENT(INOUT) :: mixing_store
231
232 INTEGER :: i, j, k
233
234 IF (ASSOCIATED(mixing_store%kerker_factor)) THEN
235 DEALLOCATE (mixing_store%kerker_factor)
236 END IF
237
238 IF (ASSOCIATED(mixing_store%kerker_factor_mag)) THEN
239 DEALLOCATE (mixing_store%kerker_factor_mag)
240 END IF
241
242 IF (ASSOCIATED(mixing_store%special_metric)) THEN
243 DEALLOCATE (mixing_store%special_metric)
244 END IF
245
246 IF (ASSOCIATED(mixing_store%pulay_matrix)) THEN
247 DEALLOCATE (mixing_store%pulay_matrix)
248 END IF
249
250 IF (ASSOCIATED(mixing_store%rhoin_buffer)) THEN
251 DO i = 1, SIZE(mixing_store%rhoin_buffer, 2)
252 DO j = 1, SIZE(mixing_store%rhoin_buffer, 1)
253 DEALLOCATE (mixing_store%rhoin_buffer(j, i)%cc)
254 END DO
255 END DO
256 DEALLOCATE (mixing_store%rhoin_buffer)
257 END IF
258
259 IF (ASSOCIATED(mixing_store%paw)) THEN
260 DEALLOCATE (mixing_store%paw)
261 END IF
262 IF (ASSOCIATED(mixing_store%cpc_h_in)) THEN
263 DO j = 1, SIZE(mixing_store%cpc_h_in, 2)
264 DO k = 1, SIZE(mixing_store%cpc_h_in, 1)
265 IF (ASSOCIATED(mixing_store%cpc_h_in(k, j)%r_coef)) THEN
266 DEALLOCATE (mixing_store%cpc_h_in(k, j)%r_coef)
267 DEALLOCATE (mixing_store%cpc_s_in(k, j)%r_coef)
268 END IF
269 END DO
270 END DO
271 DEALLOCATE (mixing_store%cpc_h_in)
272 DEALLOCATE (mixing_store%cpc_s_in)
273 END IF
274 IF (ASSOCIATED(mixing_store%cpc_h_old)) THEN
275 DO j = 1, SIZE(mixing_store%cpc_h_old, 2)
276 DO k = 1, SIZE(mixing_store%cpc_h_old, 1)
277 IF (ASSOCIATED(mixing_store%cpc_h_old(k, j)%r_coef)) THEN
278 DEALLOCATE (mixing_store%cpc_h_old(k, j)%r_coef)
279 DEALLOCATE (mixing_store%cpc_s_old(k, j)%r_coef)
280 END IF
281 END DO
282 END DO
283 DEALLOCATE (mixing_store%cpc_h_old)
284 DEALLOCATE (mixing_store%cpc_s_old)
285 END IF
286 IF (ASSOCIATED(mixing_store%cpc_h_in_buffer)) THEN
287 DO i = 1, SIZE(mixing_store%cpc_h_in_buffer, 3)
288 DO j = 1, SIZE(mixing_store%cpc_h_in_buffer, 2)
289 DO k = 1, SIZE(mixing_store%cpc_h_in_buffer, 1)
290 IF (ASSOCIATED(mixing_store%cpc_h_in_buffer(k, j, i)%r_coef)) THEN
291 DEALLOCATE (mixing_store%cpc_h_in_buffer(k, j, i)%r_coef)
292 DEALLOCATE (mixing_store%cpc_s_in_buffer(k, j, i)%r_coef)
293 END IF
294 END DO
295 END DO
296 END DO
297 DEALLOCATE (mixing_store%cpc_h_in_buffer)
298 DEALLOCATE (mixing_store%cpc_s_in_buffer)
299 END IF
300 IF (ASSOCIATED(mixing_store%cpc_h_res_buffer)) THEN
301 DO i = 1, SIZE(mixing_store%cpc_h_res_buffer, 3)
302 DO j = 1, SIZE(mixing_store%cpc_h_res_buffer, 2)
303 DO k = 1, SIZE(mixing_store%cpc_h_res_buffer, 1)
304 IF (ASSOCIATED(mixing_store%cpc_h_res_buffer(k, j, i)%r_coef)) THEN
305 DEALLOCATE (mixing_store%cpc_h_res_buffer(k, j, i)%r_coef)
306 DEALLOCATE (mixing_store%cpc_s_res_buffer(k, j, i)%r_coef)
307 END IF
308 END DO
309 END DO
310 END DO
311 DEALLOCATE (mixing_store%cpc_h_res_buffer)
312 DEALLOCATE (mixing_store%cpc_s_res_buffer)
313 END IF
314
315 IF (ASSOCIATED(mixing_store%dcpc_h_in)) THEN
316 DO i = 1, SIZE(mixing_store%dcpc_h_in, 3)
317 DO j = 1, SIZE(mixing_store%dcpc_h_in, 2)
318 DO k = 1, SIZE(mixing_store%dcpc_h_in, 1)
319 IF (ASSOCIATED(mixing_store%dcpc_h_in(k, j, i)%r_coef)) THEN
320 DEALLOCATE (mixing_store%dcpc_h_in(k, j, i)%r_coef)
321 DEALLOCATE (mixing_store%dcpc_s_in(k, j, i)%r_coef)
322 END IF
323 END DO
324 END DO
325 END DO
326 DEALLOCATE (mixing_store%dcpc_h_in)
327 DEALLOCATE (mixing_store%dcpc_s_in)
328 END IF
329 IF (ASSOCIATED(mixing_store%cpc_h_lastres)) THEN
330 DO j = 1, SIZE(mixing_store%cpc_h_lastres, 2)
331 DO k = 1, SIZE(mixing_store%cpc_h_lastres, 1)
332 IF (ASSOCIATED(mixing_store%cpc_h_lastres(k, j)%r_coef)) THEN
333 DEALLOCATE (mixing_store%cpc_h_lastres(k, j)%r_coef)
334 DEALLOCATE (mixing_store%cpc_s_lastres(k, j)%r_coef)
335 END IF
336 END DO
337 END DO
338 DEALLOCATE (mixing_store%cpc_h_lastres)
339 DEALLOCATE (mixing_store%cpc_s_lastres)
340 END IF
341
342 IF (ASSOCIATED(mixing_store%res_buffer)) THEN
343 DO i = 1, SIZE(mixing_store%res_buffer, 2)
344 DO j = 1, SIZE(mixing_store%res_buffer, 1)
345 DEALLOCATE (mixing_store%res_buffer(j, i)%cc)
346 END DO
347 END DO
348 DEALLOCATE (mixing_store%res_buffer)
349 END IF
350
351 IF (ASSOCIATED(mixing_store%norm_res_buffer)) THEN
352 DEALLOCATE (mixing_store%norm_res_buffer)
353 END IF
354
355 IF (ASSOCIATED(mixing_store%ig_global_index)) THEN
356 DEALLOCATE (mixing_store%ig_global_index)
357 END IF
358
359 IF (ASSOCIATED(mixing_store%drho_buffer)) THEN
360 DO i = 1, SIZE(mixing_store%drho_buffer, 2)
361 DO j = 1, SIZE(mixing_store%drho_buffer, 1)
362 DEALLOCATE (mixing_store%drho_buffer(j, i)%cc)
363 END DO
364 END DO
365 DEALLOCATE (mixing_store%drho_buffer)
366 END IF
367
368 IF (ASSOCIATED(mixing_store%last_res)) THEN
369 DO i = 1, SIZE(mixing_store%last_res)
370 DEALLOCATE (mixing_store%last_res(i)%cc)
371 END DO
372 DEALLOCATE (mixing_store%last_res)
373 END IF
374
375 IF (ASSOCIATED(mixing_store%rhoin)) THEN
376 DO i = 1, SIZE(mixing_store%rhoin)
377 DEALLOCATE (mixing_store%rhoin(i)%cc)
378 END DO
379 DEALLOCATE (mixing_store%rhoin)
380 END IF
381
382 IF (ASSOCIATED(mixing_store%rhoin_old)) THEN
383 DO i = 1, SIZE(mixing_store%rhoin_old)
384 DEALLOCATE (mixing_store%rhoin_old(i)%cc)
385 END DO
386 DEALLOCATE (mixing_store%rhoin_old)
387 END IF
388
389 IF (ASSOCIATED(mixing_store%p_metric)) THEN
390 DEALLOCATE (mixing_store%p_metric)
391 END IF
392
393 IF (ASSOCIATED(mixing_store%weight)) THEN
394 DEALLOCATE (mixing_store%weight)
395 END IF
396
397 IF (ASSOCIATED(mixing_store%fmat)) THEN
398 DEALLOCATE (mixing_store%fmat)
399 END IF
400
401 IF (ASSOCIATED(mixing_store%acharge)) THEN
402 DEALLOCATE (mixing_store%acharge)
403 END IF
404 IF (ASSOCIATED(mixing_store%dacharge)) THEN
405 DEALLOCATE (mixing_store%dacharge)
406 END IF
407 IF (ASSOCIATED(mixing_store%dfbroy)) THEN
408 DEALLOCATE (mixing_store%dfbroy)
409 END IF
410 IF (ASSOCIATED(mixing_store%ubroy)) THEN
411 DEALLOCATE (mixing_store%ubroy)
412 END IF
413 IF (ASSOCIATED(mixing_store%abroy)) THEN
414 DEALLOCATE (mixing_store%abroy)
415 END IF
416 IF (ASSOCIATED(mixing_store%wbroy)) THEN
417 DEALLOCATE (mixing_store%wbroy)
418 END IF
419 IF (ASSOCIATED(mixing_store%atlist)) THEN
420 DEALLOCATE (mixing_store%atlist)
421 END IF
422#if defined(__TBLITE)
423 IF (ALLOCATED(mixing_store%tb_scc_mixer)) THEN
424 DEALLOCATE (mixing_store%tb_scc_mixer)
425 END IF
426#endif
427
428 IF (ASSOCIATED(mixing_store%delta_res)) THEN
429 DO i = 1, SIZE(mixing_store%delta_res, 2)
430 DO j = 1, SIZE(mixing_store%delta_res, 1)
431 DEALLOCATE (mixing_store%delta_res(j, i)%cc)
432 END DO
433 END DO
434 DEALLOCATE (mixing_store%delta_res)
435 END IF
436
437 IF (ASSOCIATED(mixing_store%u_vec)) THEN
438 DO i = 1, SIZE(mixing_store%u_vec, 2)
439 DO j = 1, SIZE(mixing_store%u_vec, 1)
440 DEALLOCATE (mixing_store%u_vec(j, i)%cc)
441 END DO
442 END DO
443 DEALLOCATE (mixing_store%u_vec)
444 END IF
445
446 IF (ASSOCIATED(mixing_store%z_vec)) THEN
447 DO i = 1, SIZE(mixing_store%z_vec, 2)
448 DO j = 1, SIZE(mixing_store%z_vec, 1)
449 DEALLOCATE (mixing_store%z_vec(j, i)%cc)
450 END DO
451 END DO
452 DEALLOCATE (mixing_store%z_vec)
453 END IF
454
455 END SUBROUTINE mixing_storage_release
456
457! **************************************************************************************************
458!> \brief Create CP2K input section for the mixing of the density matrix to
459!> be used only with diagonalization methods, i.e. not with OT
460!> \param section ...
461!> \param ls_scf ...
462!> \date 20.02.2009
463!> \par History
464!> 02.2015 moved here from input_cp2k_dft.F, modified for use in LS SCF
465!> [Patrick Seewald]
466!> \author MI
467!> \version 1.0
468! **************************************************************************************************
469 SUBROUTINE create_mixing_section(section, ls_scf)
470
471 TYPE(section_type), POINTER :: section
472 LOGICAL, INTENT(IN), OPTIONAL :: ls_scf
473
474 CHARACTER(LEN=default_string_length) :: section_name
475 INTEGER :: default_mix
476 LOGICAL :: ls
477 TYPE(keyword_type), POINTER :: keyword
478
479 cpassert(.NOT. ASSOCIATED(section))
480
481 IF (PRESENT(ls_scf)) THEN
482 IF (ls_scf) THEN
483 ls = .true.
484 ELSE
485 ls = .false.
486 END IF
487 ELSE
488 ls = .false.
489 END IF
490
491 IF (ls) THEN
492 section_name = "RHO_MIXING"
493 ELSE
494 section_name = "MIXING"
495 END IF
496
497 CALL section_create(section, __location__, &
498 name=section_name, &
499 description="Define type and parameters for mixing "// &
500 "procedures to be applied to the density matrix. Normally, "// &
501 "only one type of mixing method should be accepted. The mixing "// &
502 "procedures activated by this section are only active for diagonalization "// &
503 "methods and linear scaling SCF, i.e. not with minimization methods based "// &
504 "on OT.", &
505 n_keywords=16, &
506 n_subsections=0, &
507 repeats=.false.)
508
509 NULLIFY (keyword)
510
511 CALL keyword_create(keyword, __location__, &
512 name="_SECTION_PARAMETERS_", &
513 description="Controls the activation of the mixing procedure", &
514 usage="&MIXING ON", &
515 default_l_val=.true., &
516 lone_keyword_l_val=.true.)
517 CALL section_add_keyword(section, keyword)
518 CALL keyword_release(keyword)
519
520 IF (.NOT. ls) THEN
521 default_mix = direct_p_mix
522 ELSE
523 default_mix = broy_mix
524 END IF
525
526 CALL keyword_create(keyword, __location__, &
527 name="METHOD", &
528 description="Mixing method to be applied", &
529 repeats=.false., &
530 usage="METHOD KERKER_MIXING", &
531 default_i_val=default_mix, &
532 enum_c_vals=s2a("NONE", &
533 "DIRECT_P_MIXING", &
534 "KERKER_MIXING", &
535 "PULAY_MIXING", &
536 "BROYDEN_MIXING", &
537 "MULTISECANT_MIXING"), &
539 multisec_mix], &
540 enum_desc=s2a("No mixing is applied", &
541 "Direct mixing of new and old density matrices", &
542 "Mixing of the potential in reciprocal space using the Kerker damping", &
543 "Pulay mixing", "Broyden mixing", &
544 "Multisecant scheme for mixing"))
545
546 CALL section_add_keyword(section, keyword)
547 CALL keyword_release(keyword)
548
549 CALL keyword_create(keyword, __location__, &
550 name="ALPHA", &
551 description="Fraction of new density to be included", &
552 repeats=.false., &
553 n_var=1, &
554 type_of_var=real_t, &
555 default_r_val=0.4_dp, &
556 usage="ALPHA 0.2")
557 CALL section_add_keyword(section, keyword)
558 CALL keyword_release(keyword)
559
560 CALL keyword_create(keyword, __location__, &
561 name="ALPHA_MAG", &
562 description="Fraction of new magnetization density to be included "// &
563 "(for spin-polarized calculations, ispin=2 channel after rho_total/m transform). "// &
564 "A negative value (default) means: use the same value as ALPHA. "// &
565 "For magnetic transition-metal systems, a larger value (e.g. 0.8-1.6) "// &
566 "than ALPHA often improves convergence.", &
567 repeats=.false., &
568 n_var=1, &
569 type_of_var=real_t, &
570 default_r_val=-1.0_dp, &
571 usage="ALPHA_MAG 0.8")
572 CALL section_add_keyword(section, keyword)
573 CALL keyword_release(keyword)
574
575 CALL keyword_create(keyword, __location__, &
576 name="BETA", &
577 description="Denominator parameter in Kerker damping "// &
578 "introduced to suppress charge sloshing: "// &
579 "rho_mix(g) = rho_in(g) + alpha*g^2/(g^2 + beta^2)*(rho_out(g)-rho_in(g))", &
580 repeats=.false., &
581 n_var=1, &
582 type_of_var=real_t, &
583 default_r_val=0.5_dp, &
584 unit_str="bohr^-1", &
585 usage="BETA 1.5")
586 CALL section_add_keyword(section, keyword)
587 CALL keyword_release(keyword)
588
589 CALL keyword_create(keyword, __location__, &
590 name="BETA_MAG", &
591 description="Kerker damping parameter for the magnetization channel "// &
592 "(for spin-polarized calculations). A negative value (default) means: "// &
593 "use the same value as BETA. Set to 0.0 to disable Kerker screening "// &
594 "on the magnetization density, which avoids suppression of long-range "// &
595 "magnetic order formation in transition-metal systems.", &
596 repeats=.false., &
597 n_var=1, &
598 type_of_var=real_t, &
599 default_r_val=-1.0_dp, &
600 unit_str="bohr^-1", &
601 usage="BETA_MAG 0.0")
602 CALL section_add_keyword(section, keyword)
603 CALL keyword_release(keyword)
604
605 CALL keyword_create(keyword, __location__, &
606 name="PULAY_ALPHA", &
607 description="Fraction of new density to be added to the Pulay expansion", &
608 repeats=.false., &
609 n_var=1, &
610 type_of_var=real_t, &
611 default_r_val=0.0_dp, &
612 usage="PULAY_ALPHA 0.2")
613 CALL section_add_keyword(section, keyword)
614 CALL keyword_release(keyword)
615
616 CALL keyword_create(keyword, __location__, &
617 name="PULAY_BETA", &
618 description="Fraction of residual contribution to be added to Pulay expansion", &
619 repeats=.false., &
620 n_var=1, &
621 type_of_var=real_t, &
622 default_r_val=1.0_dp, &
623 usage="PULAY_BETA 0.2")
624 CALL section_add_keyword(section, keyword)
625 CALL keyword_release(keyword)
626
627 CALL keyword_create(keyword, __location__, name="NMIXING", &
628 description="Minimal number of density mixing (should be greater than 0), "// &
629 "before starting DIIS", &
630 usage="NMIXING 1", default_i_val=2)
631 CALL section_add_keyword(section, keyword)
632 CALL keyword_release(keyword)
633
634 CALL keyword_create(keyword, __location__, name="NBUFFER", &
635 variants=s2a("NPULAY", "NBROYDEN", "NMULTISECANT"), &
636 description="Number of previous steps stored for the actual mixing scheme", &
637 usage="NBUFFER 2", default_i_val=4)
638 CALL section_add_keyword(section, keyword)
639 CALL keyword_release(keyword)
640
641 CALL keyword_create(keyword, __location__, &
642 name="BROY_W0", &
643 description=" w0 parameter used in Broyden mixing", &
644 repeats=.false., &
645 n_var=1, &
646 type_of_var=real_t, &
647 default_r_val=0.01_dp, &
648 usage="BROY_W0 0.03")
649 CALL section_add_keyword(section, keyword)
650 CALL keyword_release(keyword)
651
652 CALL keyword_create(keyword, __location__, &
653 name="BROY_WREF", &
654 description="", &
655 repeats=.false., &
656 n_var=1, &
657 type_of_var=real_t, &
658 default_r_val=100.0_dp, &
659 usage="BROY_WREF 0.2")
660 CALL section_add_keyword(section, keyword)
661 CALL keyword_release(keyword)
662
663 CALL keyword_create(keyword, __location__, &
664 name="BROY_WMAX", &
665 description="", &
666 repeats=.false., &
667 n_var=1, &
668 type_of_var=real_t, &
669 default_r_val=30.0_dp, &
670 usage="BROY_WMAX 10.0")
671 CALL section_add_keyword(section, keyword)
672 CALL keyword_release(keyword)
673
674 CALL keyword_create(keyword, __location__, &
675 name="REGULARIZATION", &
676 description="Regularization parameter to stabilize "// &
677 "the inversion of the residual matrix {Yn^t Yn} in the "// &
678 "multisecant mixing scheme (noise)", &
679 repeats=.false., &
680 n_var=1, &
681 type_of_var=real_t, &
682 default_r_val=0.00001_dp, &
683 usage="REGULARIZATION 0.000001")
684 CALL section_add_keyword(section, keyword)
685 CALL keyword_release(keyword)
686
687 CALL keyword_create(keyword, __location__, &
688 name="MAX_STEP", &
689 description="Upper bound for the magnitude of the "// &
690 "unpredicted step size in the update by the "// &
691 "multisecant mixing scheme", &
692 repeats=.false., &
693 n_var=1, &
694 type_of_var=real_t, &
695 default_r_val=0.1_dp, &
696 usage="MAX_STEP .2")
697 CALL section_add_keyword(section, keyword)
698 CALL keyword_release(keyword)
699
700 CALL keyword_create(keyword, __location__, &
701 name="R_FACTOR", &
702 description="Control factor for the magnitude of the "// &
703 "unpredicted step size in the update by the "// &
704 "multisecant mixing scheme", &
705 repeats=.false., &
706 n_var=1, &
707 type_of_var=real_t, &
708 default_r_val=0.05_dp, &
709 usage="R_FACTOR .12")
710 CALL section_add_keyword(section, keyword)
711 CALL keyword_release(keyword)
712
713 CALL keyword_create(keyword, __location__, name="NSKIP", &
714 variants=["NSKIP_MIXING"], &
715 description="Number of initial iteration for which the mixing is skipped", &
716 usage="NSKIP 10", default_i_val=0)
717 CALL section_add_keyword(section, keyword)
718 CALL keyword_release(keyword)
719
720 CALL keyword_create(keyword, __location__, name="N_SIMPLE_MIX", &
721 variants=["NSIMPLEMIX"], &
722 description="Number of kerker damping iterations before starting other mixing procedures", &
723 usage="NSIMPLEMIX", default_i_val=0)
724 CALL section_add_keyword(section, keyword)
725 CALL keyword_release(keyword)
726
727 CALL keyword_create(keyword, __location__, name="MAX_GVEC_EXP", &
728 description="Restricts the G-space mixing to lower part of G-vector spectrum,"// &
729 " up to a G0, by assigning the exponent of the Gaussian that can be "// &
730 "represented by vectors smaller than G0 within a certain accuracy. ", &
731 repeats=.false., &
732 n_var=1, &
733 type_of_var=real_t, &
734 default_r_val=-1._dp, &
735 usage="MAX_GVEC_EXP 3.")
736 CALL section_add_keyword(section, keyword)
737 CALL keyword_release(keyword)
738
739 CALL keyword_create(keyword, __location__, name="GMIX_P", &
740 description="Activate the mixing of the density matrix, using the same"// &
741 " mixing coefficient applied for the g-space mixing.", &
742 repeats=.false., &
743 lone_keyword_l_val=.true., &
744 default_l_val=.false., &
745 usage="GMIX_P")
746 CALL section_add_keyword(section, keyword)
747 CALL keyword_release(keyword)
748
749 END SUBROUTINE create_mixing_section
750
All kind of helpful little routines.
Definition ao_util.F:14
real(kind=dp) function, public exp_radius(l, alpha, threshold, prefactor, epsabs, epsrel, rlow)
The radius of a primitive Gaussian function for a given threshold is calculated. g(r) = prefactor*r**...
Definition ao_util.F:96
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public broy_mix
integer, parameter, public pulay_mix
integer, parameter, public direct_p_mix
integer, parameter, public no_mix
integer, parameter, public kerker_mix
integer, parameter, public multisec_mix
integer, parameter, public gaussian
represents keywords in an input
subroutine, public keyword_release(keyword)
releases the given keyword (see doc/ReferenceCounting.html)
subroutine, public keyword_create(keyword, location, name, description, usage, type_of_var, n_var, repeats, variants, default_val, default_l_val, default_r_val, default_lc_val, default_c_val, default_i_val, default_l_vals, default_r_vals, default_c_vals, default_i_vals, lone_keyword_val, lone_keyword_l_val, lone_keyword_r_val, lone_keyword_c_val, lone_keyword_i_val, lone_keyword_l_vals, lone_keyword_r_vals, lone_keyword_c_vals, lone_keyword_i_vals, enum_c_vals, enum_i_vals, enum, enum_strict, enum_desc, unit_str, citations, deprecation_notice, removed)
creates a keyword object
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_create(section, location, name, description, n_keywords, n_subsections, repeats, citations, deprecation_notice)
creates a list of keywords
subroutine, public section_add_keyword(section, keyword)
adds a keyword to the given section
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
a wrapper for basic fortran types.
integer, parameter, public real_t
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
module that contains the definitions of the scf types
integer, parameter, public broyden_mixing_nr
subroutine, public mixing_storage_release(mixing_store)
releases a mixing_storage
integer, parameter, public no_mixing_nr
integer, parameter, public direct_mixing_nr
subroutine, public create_mixing_section(section, ls_scf)
Create CP2K input section for the mixing of the density matrix to be used only with diagonalization m...
integer, parameter, public multisecant_mixing_nr
integer, parameter, public pulay_mixing_nr
subroutine, public mixing_storage_create(mixing_store, mixing_section, mixing_method, ecut)
creates a mixing_storage
integer, parameter, public gspace_mixing_nr
Utilities for string manipulations.
represent a keyword in the input
represent a section of the input file