(git:b279b6b)
qs_cdft_scf_utils.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 Auxiliary routines for performing a constrained DFT SCF run with Quickstep.
10 !> \par History
11 !> - Separated some routines from qs_scf (03.2018) [Nico Holmberg]
12 !> \author Nico Holmberg (03.2018)
13 ! **************************************************************************************************
15  USE cp_control_types, ONLY: dft_control_type
16  USE cp_files, ONLY: close_file,&
18  open_file
20  cp_logger_type,&
21  cp_to_string
22  USE input_constants, ONLY: &
28  USE kinds, ONLY: default_path_length,&
29  dp
30  USE mathlib, ONLY: invert_matrix
31  USE message_passing, ONLY: mp_para_env_type
32  USE qs_environment_types, ONLY: get_qs_env,&
33  qs_environment_type
34  USE qs_scf_types, ONLY: qs_scf_env_type
35  USE scf_control_types, ONLY: scf_control_type
36 #include "./base/base_uses.f90"
37 
38  IMPLICIT NONE
39 
40  PRIVATE
41 
42  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_cdft_scf_utils'
43 
47 
48 CONTAINS
49 
50 ! **************************************************************************************************
51 !> \brief Prepares the finite difference stencil for computing the Jacobian. The constraints
52 !> are re-evaluated by perturbing each constraint.
53 !> \param qs_env the qs_env where to build the Jacobian
54 !> \param output_unit the output unit number
55 !> \param nwork the number of perturbations to take in the negative direction
56 !> \param pwork the number of perturbations to take in the positive direction
57 !> \param coeff list of coefficients that determine how to sum up the various perturbations
58 !> \param step_multiplier list of values that determine how large steps to take for each perturbatio
59 !> \param dh total length of the interval to use for computing the finite difference derivatives
60 !> \par History
61 !> 03.2018 created [Nico Holmberg]
62 ! **************************************************************************************************
63  SUBROUTINE prepare_jacobian_stencil(qs_env, output_unit, nwork, pwork, &
64  coeff, step_multiplier, dh)
65  TYPE(qs_environment_type), POINTER :: qs_env
66  INTEGER :: output_unit, nwork, pwork
67  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: coeff, step_multiplier, dh
68 
69  CHARACTER(len=15) :: fmt_code
70  INTEGER :: ivar
71  TYPE(dft_control_type), POINTER :: dft_control
72  TYPE(qs_scf_env_type), POINTER :: scf_env
73  TYPE(scf_control_type), POINTER :: scf_control
74 
75  NULLIFY (scf_env, scf_control, dft_control)
76 
77  cpassert(ASSOCIATED(qs_env))
78  CALL get_qs_env(qs_env, scf_env=scf_env, &
79  scf_control=scf_control, &
80  dft_control=dft_control)
81 
82  IF (SIZE(scf_control%outer_scf%cdft_opt_control%jacobian_step) /= 1 .AND. &
83  SIZE(scf_control%outer_scf%cdft_opt_control%jacobian_step) /= SIZE(scf_env%outer_scf%variables, 1)) &
84  CALL cp_abort(__location__, &
85  cp_to_string(SIZE(scf_control%outer_scf%cdft_opt_control%jacobian_step))// &
86  " values passed to keyword JACOBIAN_STEP, expected 1 or "// &
87  cp_to_string(SIZE(scf_env%outer_scf%variables, 1)))
88 
89  ALLOCATE (dh(SIZE(scf_env%outer_scf%variables, 1)))
90  IF (SIZE(dh) /= SIZE(scf_control%outer_scf%cdft_opt_control%jacobian_step)) THEN
91  DO ivar = 1, SIZE(dh)
92  dh(ivar) = scf_control%outer_scf%cdft_opt_control%jacobian_step(1)
93  END DO
94  ELSE
95  dh(:) = scf_control%outer_scf%cdft_opt_control%jacobian_step
96  END IF
97 
98  SELECT CASE (scf_control%outer_scf%cdft_opt_control%jacobian_type)
99  CASE DEFAULT
100  CALL cp_abort(__location__, &
101  "Unknown Jacobian type: "// &
102  cp_to_string(scf_control%outer_scf%cdft_opt_control%jacobian_type))
103  CASE (jacobian_fd1)
104  ! f'(x0) = [ f(x0+h) - f(x0) ] / h
105  nwork = 0
106  pwork = 1
107  ALLOCATE (coeff(nwork:pwork), step_multiplier(nwork:pwork))
108  coeff(nwork) = -1.0_dp
109  coeff(pwork) = 1.0_dp
110  step_multiplier = 1.0_dp
111  CASE (jacobian_fd1_backward)
112  ! f'(x0) = [ f(x0) - f(x0-h) ] / h
113  nwork = -1
114  pwork = 0
115  ALLOCATE (coeff(nwork:pwork), step_multiplier(nwork:pwork))
116  coeff(nwork) = -1.0_dp
117  coeff(pwork) = 1.0_dp
118  step_multiplier = -1.0_dp
119  CASE (jacobian_fd2)
120  ! f'(x0) = [ -f(x0+2h) + 4f(x0+h) - 3f(x0) ] / 2h
121  nwork = 0
122  pwork = 2
123  ALLOCATE (coeff(nwork:pwork), step_multiplier(nwork:pwork))
124  coeff(0) = -3.0_dp
125  coeff(1) = 4.0_dp
126  coeff(2) = -1.0_dp
127  step_multiplier(0) = 0.0_dp
128  step_multiplier(1) = 1.0_dp
129  step_multiplier(2) = 2.0_dp
130  dh(:) = 2.0_dp*dh(:)
131  CASE (jacobian_fd2_backward)
132  ! f'(x0) = [ 3f(x0) - 4f(x0-h) + f(x0-2h) ] / 2h
133  nwork = -2
134  pwork = 0
135  ALLOCATE (coeff(nwork:pwork), step_multiplier(nwork:pwork))
136  coeff(0) = 3.0_dp
137  coeff(-1) = -4.0_dp
138  coeff(-2) = 1.0_dp
139  step_multiplier(0) = 0.0_dp
140  step_multiplier(-1) = -1.0_dp
141  step_multiplier(-2) = -2.0_dp
142  dh(:) = 2.0_dp*dh(:)
143  CASE (jacobian_fd1_central)
144  ! f'(x0) = [ f(x0+h) - f(x0-h) ] / 2h
145  nwork = -1
146  pwork = 1
147  ALLOCATE (coeff(nwork:pwork), step_multiplier(nwork:pwork))
148  coeff(0) = 0.0_dp
149  coeff(nwork) = -1.0_dp
150  coeff(pwork) = 1.0_dp
151  step_multiplier(0) = 0.0_dp
152  step_multiplier(nwork) = -1.0_dp
153  step_multiplier(pwork) = 1.0_dp
154  dh(:) = 2.0_dp*dh(:)
155  END SELECT
156  ! Print some info
157  IF (output_unit > 0) THEN
158  WRITE (output_unit, fmt="(/,A)") &
159  " ================================== JACOBIAN CALCULATION ================================="
160  WRITE (output_unit, fmt="(A)") &
161  " Evaluating inverse Jacobian using finite differences"
162  WRITE (output_unit, '(A,I10,A,I10)') &
163  " Energy evaluation: ", dft_control%qs_control%cdft_control%ienergy, &
164  ", CDFT SCF iteration: ", scf_env%outer_scf%iter_count
165  SELECT CASE (scf_control%outer_scf%cdft_opt_control%jacobian_type)
166  CASE (jacobian_fd1)
167  WRITE (output_unit, '(A)') " Type : First order forward difference"
168  CASE (jacobian_fd1_backward)
169  WRITE (output_unit, '(A)') " Type : First order backward difference"
170  CASE (jacobian_fd2)
171  WRITE (output_unit, '(A)') " Type : Second order forward difference"
172  CASE (jacobian_fd2_backward)
173  WRITE (output_unit, '(A)') " Type : Second order backward difference"
174  CASE (jacobian_fd1_central)
175  WRITE (output_unit, '(A)') " Type : First order central difference"
176  CASE DEFAULT
177  CALL cp_abort(__location__, "Unknown Jacobian type: "// &
178  cp_to_string(scf_control%outer_scf%cdft_opt_control%jacobian_type))
179  END SELECT
180  IF (SIZE(scf_control%outer_scf%cdft_opt_control%jacobian_step) == 1) THEN
181  WRITE (output_unit, '(A,ES12.4)') " Step size : ", scf_control%outer_scf%cdft_opt_control%jacobian_step
182  ELSE
183  WRITE (output_unit, '(A,ES12.4,A)') &
184  " Step sizes : ", scf_control%outer_scf%cdft_opt_control%jacobian_step(1), ' (constraint 1)'
185  IF (SIZE(scf_control%outer_scf%cdft_opt_control%jacobian_step) < 10) THEN
186  fmt_code = '(ES34.4,A,I2,A)'
187  ELSE
188  fmt_code = '(ES34.4,A,I3,A)'
189  END IF
190  DO ivar = 2, SIZE(scf_control%outer_scf%cdft_opt_control%jacobian_step)
191  WRITE (output_unit, fmt_code) scf_control%outer_scf%cdft_opt_control%jacobian_step(ivar), " (constraint", ivar, ")"
192  END DO
193  END IF
194  END IF
195 
196  END SUBROUTINE prepare_jacobian_stencil
197 ! **************************************************************************************************
198 !> \brief Builds a strictly diagonal inverse Jacobian from MD/SCF history.
199 !> \param qs_env the qs_environment_type where to compute the Jacobian
200 !> \param used_history flag that determines if history was actually used to prepare the Jacobian
201 !> \par History
202 !> 03.2018 created [Nico Holmberg]
203 ! **************************************************************************************************
204  SUBROUTINE build_diagonal_jacobian(qs_env, used_history)
205  TYPE(qs_environment_type), POINTER :: qs_env
206  LOGICAL :: used_history
207 
208  INTEGER :: i, ihistory, nvar, outer_scf_ihistory
209  LOGICAL :: use_md_history
210  REAL(kind=dp) :: inv_error
211  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: jacobian
212  REAL(kind=dp), DIMENSION(:, :), POINTER :: gradient_history, inv_jacobian, &
213  variable_history
214  TYPE(qs_scf_env_type), POINTER :: scf_env
215  TYPE(scf_control_type), POINTER :: scf_control
216 
217  NULLIFY (scf_control, scf_env)
218 
219  CALL get_qs_env(qs_env, scf_env=scf_env, &
220  scf_control=scf_control, &
221  outer_scf_ihistory=outer_scf_ihistory)
222  ihistory = scf_env%outer_scf%iter_count
223 
224  IF (outer_scf_ihistory .GE. 3 .AND. .NOT. used_history) THEN
225  ! First, lets try using the history from previous energy evaluations
226  CALL get_qs_env(qs_env, gradient_history=gradient_history, &
227  variable_history=variable_history)
228  nvar = SIZE(scf_env%outer_scf%variables, 1)
229  use_md_history = .true.
230  ! Check that none of the history values are identical in which case we should try something different
231  DO i = 1, nvar
232  IF (abs(variable_history(i, 2) - variable_history(i, 1)) .LT. 1.0e-12_dp) &
233  use_md_history = .false.
234  END DO
235  IF (use_md_history) THEN
236  ALLOCATE (jacobian(nvar, nvar))
237  DO i = 1, nvar
238  jacobian(i, i) = (gradient_history(i, 2) - gradient_history(i, 1))/ &
239  (variable_history(i, 2) - variable_history(i, 1))
240  END DO
241  IF (.NOT. ASSOCIATED(scf_env%outer_scf%inv_jacobian)) &
242  ALLOCATE (scf_env%outer_scf%inv_jacobian(nvar, nvar))
243  inv_jacobian => scf_env%outer_scf%inv_jacobian
244  CALL invert_matrix(jacobian, inv_jacobian, inv_error)
245  DEALLOCATE (jacobian)
246  ! Mark that an inverse Jacobian was just built and the next outer_loop_optimize should not perform
247  ! a Broyden update of it
248  scf_control%outer_scf%cdft_opt_control%broyden_update = .false.
249  ! Mark that the MD history has been used and should not be reused anymore on this energy evaluation
250  used_history = .true.
251  END IF
252  END IF
253  IF (ihistory .GE. 2 .AND. .NOT. ASSOCIATED(scf_env%outer_scf%inv_jacobian)) THEN
254  ! Next, try history from current SCF procedure
255  nvar = SIZE(scf_env%outer_scf%variables, 1)
256  IF (SIZE(scf_env%outer_scf%gradient, 2) .LT. 3) &
257  CALL cp_abort(__location__, &
258  "Keyword EXTRAPOLATION_ORDER in section OUTER_SCF must be greater than or equal "// &
259  "to 3 for optimizers that build the Jacobian from SCF history.")
260  ALLOCATE (jacobian(nvar, nvar))
261  DO i = 1, nvar
262  jacobian(i, i) = (scf_env%outer_scf%gradient(i, ihistory) - scf_env%outer_scf%gradient(i, ihistory - 1))/ &
263  (scf_env%outer_scf%variables(i, ihistory) - scf_env%outer_scf%variables(i, ihistory - 1))
264  END DO
265  IF (.NOT. ASSOCIATED(scf_env%outer_scf%inv_jacobian)) &
266  ALLOCATE (scf_env%outer_scf%inv_jacobian(nvar, nvar))
267  inv_jacobian => scf_env%outer_scf%inv_jacobian
268  CALL invert_matrix(jacobian, inv_jacobian, inv_error)
269  DEALLOCATE (jacobian)
270  scf_control%outer_scf%cdft_opt_control%broyden_update = .false.
271  ELSE
272  ! No history => will fall back to SD optimizer in outer_loop_optimize
273  END IF
274 
275  END SUBROUTINE build_diagonal_jacobian
276 
277 ! **************************************************************************************************
278 !> \brief Restarts the finite difference inverse Jacobian.
279 !> \param qs_env the qs_environment_type where to compute the Jacobian
280 !> \par History
281 !> 03.2018 created [Nico Holmberg]
282 ! **************************************************************************************************
283  SUBROUTINE restart_inverse_jacobian(qs_env)
284  TYPE(qs_environment_type), POINTER :: qs_env
285 
286  INTEGER :: i, iwork, j, nvar
287  REAL(kind=dp), DIMENSION(:, :), POINTER :: inv_jacobian
288  TYPE(qs_scf_env_type), POINTER :: scf_env
289  TYPE(scf_control_type), POINTER :: scf_control
290 
291  NULLIFY (scf_env, scf_control)
292  cpassert(ASSOCIATED(qs_env))
293  CALL get_qs_env(qs_env, scf_env=scf_env, scf_control=scf_control)
294 
295  cpassert(ASSOCIATED(scf_control%outer_scf%cdft_opt_control%jacobian_vector))
296  nvar = SIZE(scf_env%outer_scf%variables, 1)
297  IF (SIZE(scf_control%outer_scf%cdft_opt_control%jacobian_vector) /= nvar**2) &
298  CALL cp_abort(__location__, &
299  "Too many or too few values defined for restarting inverse Jacobian.")
300  IF (.NOT. ASSOCIATED(scf_env%outer_scf%inv_jacobian)) &
301  ALLOCATE (scf_env%outer_scf%inv_jacobian(nvar, nvar))
302  inv_jacobian => scf_env%outer_scf%inv_jacobian
303  iwork = 1
304  DO i = 1, nvar
305  DO j = 1, nvar
306  inv_jacobian(i, j) = scf_control%outer_scf%cdft_opt_control%jacobian_vector(iwork)
307  iwork = iwork + 1
308  END DO
309  END DO
310  DEALLOCATE (scf_control%outer_scf%cdft_opt_control%jacobian_vector)
311  scf_control%outer_scf%cdft_opt_control%jacobian_restart = .false.
312  scf_control%outer_scf%cdft_opt_control%broyden_update = .false.
313  scf_env%outer_scf%deallocate_jacobian = .false.
314 
315  END SUBROUTINE restart_inverse_jacobian
316 
317 ! **************************************************************************************************
318 !> \brief Prints the finite difference inverse Jacobian to file
319 !> \param logger the default IO logger
320 !> \param inv_jacobian the inverse Jacobian matrix
321 !> \param iter_count the iteration number
322 !> \par History
323 !> 03.2018 created [Nico Holmberg]
324 ! **************************************************************************************************
325  SUBROUTINE print_inverse_jacobian(logger, inv_jacobian, iter_count)
326  TYPE(cp_logger_type), POINTER :: logger
327  REAL(kind=dp), DIMENSION(:, :), INTENT(IN), &
328  POINTER :: inv_jacobian
329  INTEGER :: iter_count
330 
331  CHARACTER(len=default_path_length) :: project_name
332  INTEGER :: i, j, lp, nvar, output_unit
333 
334  nvar = SIZE(inv_jacobian, 1)
335  output_unit = get_unit_number()
336  project_name = logger%iter_info%project_name
337  lp = len_trim(project_name)
338  project_name(lp + 1:len(project_name)) = ".inverseJacobian"
339  CALL open_file(file_name=project_name, file_status="UNKNOWN", &
340  file_action="WRITE", file_position="APPEND", &
341  unit_number=output_unit)
342  WRITE (output_unit, fmt="(/,A)") "Inverse Jacobian matrix in row major order"
343  WRITE (output_unit, fmt="(A,I10)") "Iteration: ", iter_count
344  DO i = 1, nvar
345  DO j = 1, nvar
346  WRITE (output_unit, *) inv_jacobian(i, j)
347  END DO
348  END DO
349  CALL close_file(unit_number=output_unit)
350 
351  END SUBROUTINE print_inverse_jacobian
352 
353 ! **************************************************************************************************
354 !> \brief Creates a temporary logger for redirecting output to a new file
355 !> \param para_env the para_env
356 !> \param project_name the project basename
357 !> \param suffix the suffix
358 !> \param output_unit the default unit number for the newly created temporary logger
359 !> \param tmp_logger pointer to the newly created temporary logger
360 !> \par History
361 !> 03.2018 created [Nico Holmberg]
362 ! **************************************************************************************************
363  SUBROUTINE create_tmp_logger(para_env, project_name, suffix, output_unit, tmp_logger)
364  TYPE(mp_para_env_type), POINTER :: para_env
365  CHARACTER(len=*) :: project_name, suffix
366  INTEGER, INTENT(OUT) :: output_unit
367  TYPE(cp_logger_type), INTENT(OUT), POINTER :: tmp_logger
368 
369  INTEGER :: lp
370 
371  IF (para_env%is_source()) THEN
372  lp = len_trim(project_name)
373  project_name(lp + 1:len(project_name)) = suffix
374  CALL open_file(file_name=project_name, file_status="UNKNOWN", &
375  file_action="WRITE", file_position="APPEND", &
376  unit_number=output_unit)
377  ELSE
378  output_unit = -1
379  END IF
380  CALL cp_logger_create(tmp_logger, &
381  para_env=para_env, &
382  default_global_unit_nr=output_unit, &
383  close_global_unit_on_dealloc=.false.)
384 
385  END SUBROUTINE create_tmp_logger
386 
387 ! **************************************************************************************************
388 !> \brief Checks if the inverse Jacobian should be calculated and initializes the calculation
389 !> \param scf_control the scf_control that holds the Jacobian settings
390 !> \param scf_env the scf_env that holds the CDFT iteration information
391 !> \param explicit_jacobian flag that determines if the finite difference Jacobian is needed
392 !> \param should_build flag that determines if the Jacobian should be built
393 !> \param used_history flag that determines if SCF history has been used to build a Jacobian
394 !> \par History
395 !> 03.2018 created [Nico Holmberg]
396 ! **************************************************************************************************
397  SUBROUTINE initialize_inverse_jacobian(scf_control, scf_env, explicit_jacobian, &
398  should_build, used_history)
399  TYPE(scf_control_type), POINTER :: scf_control
400  TYPE(qs_scf_env_type), POINTER :: scf_env
401  LOGICAL :: explicit_jacobian, should_build, &
402  used_history
403 
404  cpassert(ASSOCIATED(scf_control))
405  cpassert(ASSOCIATED(scf_env))
406 
407  SELECT CASE (scf_control%outer_scf%optimizer)
408  CASE DEFAULT
409  cpabort("Noncompatible optimizer requested.")
411  cpassert(ASSOCIATED(scf_control%outer_scf%cdft_opt_control))
412  scf_control%outer_scf%cdft_opt_control%build_jacobian = .true.
413  explicit_jacobian = .true.
415  cpassert(ASSOCIATED(scf_control%outer_scf%cdft_opt_control))
416  SELECT CASE (scf_control%outer_scf%cdft_opt_control%broyden_type)
418  scf_control%outer_scf%cdft_opt_control%build_jacobian = .true.
419  explicit_jacobian = .false.
421  scf_control%outer_scf%cdft_opt_control%build_jacobian = .true.
422  explicit_jacobian = .true.
423  END SELECT
424  END SELECT
425  IF (scf_control%outer_scf%cdft_opt_control%build_jacobian) THEN
426  ! Reset counter
427  IF (scf_env%outer_scf%iter_count == 1) scf_control%outer_scf%cdft_opt_control%ijacobian(1) = 0
428  ! Check if an old Jacobian can be reused avoiding a rebuild
429  IF (ASSOCIATED(scf_env%outer_scf%inv_jacobian)) THEN
430  ! Rebuild if number of previous energy evaluations exceeds limit
431  IF (scf_control%outer_scf%cdft_opt_control%ijacobian(2) .GE. &
432  scf_control%outer_scf%cdft_opt_control%jacobian_freq(2) .AND. .NOT. used_history .AND. &
433  scf_control%outer_scf%cdft_opt_control%jacobian_freq(2) > 0) THEN
434  should_build = .true.
435  ! Zero the corresponding counters
436  scf_control%outer_scf%cdft_opt_control%ijacobian(:) = 0
437  ! Rebuild if number of previous SCF iterations exceeds limit (on this energy eval)
438  ELSE IF (scf_control%outer_scf%cdft_opt_control%ijacobian(1) .GE. &
439  scf_control%outer_scf%cdft_opt_control%jacobian_freq(1) .AND. &
440  scf_control%outer_scf%cdft_opt_control%jacobian_freq(1) > 0) THEN
441  should_build = .true.
442  ! Zero the corresponding counter
443  scf_control%outer_scf%cdft_opt_control%ijacobian(1) = 0
444  END IF
445  IF (should_build) DEALLOCATE (scf_env%outer_scf%inv_jacobian)
446  ELSE
447  should_build = .true.
448  ! Zero the counter
449  scf_control%outer_scf%cdft_opt_control%ijacobian(:) = 0
450  END IF
451  END IF
452 
453  END SUBROUTINE initialize_inverse_jacobian
454 
455 END MODULE qs_cdft_scf_utils
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Utility routines to open and close files. Tracking of preconnections.
Definition: cp_files.F:16
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
Definition: cp_files.F:308
integer function, public get_unit_number(file_name)
Returns the first logical unit that is not preconnected.
Definition: cp_files.F:237
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
Definition: cp_files.F:119
various routines to log and control the output. The idea is that decisions about where to log should ...
subroutine, public cp_logger_create(logger, para_env, print_level, default_global_unit_nr, default_local_unit_nr, global_filename, local_filename, close_global_unit_on_dealloc, iter_info, close_local_unit_on_dealloc, suffix, template_logger)
initializes a logger
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public jacobian_fd1_central
integer, parameter, public broyden_type_2_explicit_ls
integer, parameter, public broyden_type_1_explicit
integer, parameter, public broyden_type_2_ls
integer, parameter, public jacobian_fd2
integer, parameter, public broyden_type_1
integer, parameter, public outer_scf_optimizer_broyden
integer, parameter, public broyden_type_1_explicit_ls
integer, parameter, public broyden_type_2_explicit
integer, parameter, public jacobian_fd1
integer, parameter, public broyden_type_2
integer, parameter, public jacobian_fd1_backward
integer, parameter, public jacobian_fd2_backward
integer, parameter, public outer_scf_optimizer_newton_ls
integer, parameter, public outer_scf_optimizer_newton
integer, parameter, public broyden_type_1_ls
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
integer, parameter, public default_path_length
Definition: kinds.F:58
Collection of simple mathematical functions and subroutines.
Definition: mathlib.F:15
Interface to the message passing library MPI.
Auxiliary routines for performing a constrained DFT SCF run with Quickstep.
subroutine, public prepare_jacobian_stencil(qs_env, output_unit, nwork, pwork, coeff, step_multiplier, dh)
Prepares the finite difference stencil for computing the Jacobian. The constraints are re-evaluated b...
subroutine, public build_diagonal_jacobian(qs_env, used_history)
Builds a strictly diagonal inverse Jacobian from MD/SCF history.
subroutine, public print_inverse_jacobian(logger, inv_jacobian, iter_count)
Prints the finite difference inverse Jacobian to file.
subroutine, public create_tmp_logger(para_env, project_name, suffix, output_unit, tmp_logger)
Creates a temporary logger for redirecting output to a new file.
subroutine, public restart_inverse_jacobian(qs_env)
Restarts the finite difference inverse Jacobian.
subroutine, public initialize_inverse_jacobian(scf_control, scf_env, explicit_jacobian, should_build, used_history)
Checks if the inverse Jacobian should be calculated and initializes the calculation.
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, 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_nonbond, sab_almo, sab_kp, sab_kp_nosym, 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, 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, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
Get the QUICKSTEP environment.
module that contains the definitions of the scf types
Definition: qs_scf_types.F:14
parameters that control an scf iteration