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