(git:27c966b)
Loading...
Searching...
No Matches
qs_ot_scf.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 basic functionality for using ot in the scf routines.
10!> \par History
11!> 01.2003 : Joost VandeVondele : adapted for LSD
12!> \author Joost VandeVondele (25.08.2002)
13! **************************************************************************************************
16 USE cp_dbcsr_api, ONLY: &
18 dbcsr_set, dbcsr_type, dbcsr_type_no_symmetry
20 dbcsr_dot,&
26 USE cp_fm_types, ONLY: cp_fm_type
34 USE kinds, ONLY: dp
36 USE qs_mo_types, ONLY: get_mo_set,&
39 USE qs_ot, ONLY: qs_ot_get_orbitals,&
42 USE qs_ot_minimizer, ONLY: ot_mini,&
52#include "./base/base_uses.f90"
53
54 IMPLICIT NONE
55
56 PRIVATE
57
58 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_ot_scf'
59 ! *** Public subroutines ***
60
61 PUBLIC :: ot_scf_init
62 PUBLIC :: ot_scf_mini
63 PUBLIC :: ot_scf_destroy
64 PUBLIC :: ot_scf_read_input
65
66CONTAINS
67
68! **************************************************************************************************
69!> \brief ...
70!> \param qs_ot_env ...
71!> \param scf_section ...
72!> \param do_kpoints ...
73! **************************************************************************************************
74 SUBROUTINE ot_scf_read_input(qs_ot_env, scf_section, do_kpoints)
75 TYPE(qs_ot_type), DIMENSION(:), POINTER :: qs_ot_env
76 TYPE(section_vals_type), POINTER :: scf_section
77 LOGICAL, INTENT(IN) :: do_kpoints
78
79 CHARACTER(len=*), PARAMETER :: routinen = 'ot_scf_read_input'
80
81 INTEGER :: handle, ispin, nspin, output_unit
82 LOGICAL :: explicit
83 TYPE(cp_logger_type), POINTER :: logger
84 TYPE(section_vals_type), POINTER :: ot_section
85
86 CALL timeset(routinen, handle)
87
88 logger => cp_get_default_logger()
89 output_unit = cp_print_key_unit_nr(logger, scf_section, "PRINT%PROGRAM_RUN_INFO", &
90 extension=".log")
91
92 ! decide default settings
93 CALL qs_ot_settings_init(qs_ot_env(1)%settings)
94
95 ! use ot input new style
96 ot_section => section_vals_get_subs_vals(scf_section, "OT")
97 CALL section_vals_get(ot_section, explicit=explicit)
98
99 CALL ot_readwrite_input(qs_ot_env(1)%settings, ot_section, output_unit, &
100 complex_kpoints=do_kpoints)
101
102 CALL cp_print_key_finished_output(output_unit, logger, scf_section, &
103 "PRINT%PROGRAM_RUN_INFO")
104
105 ! copy the ot settings type so it is identical
106 nspin = SIZE(qs_ot_env)
107 DO ispin = 2, nspin
108 qs_ot_env(ispin)%settings = qs_ot_env(1)%settings
109 END DO
110
111 CALL timestop(handle)
112
113 END SUBROUTINE ot_scf_read_input
114
115! **************************************************************************************************
116!> \brief performs the actual minimisation, needs only limited info
117!> updated for restricted calculations
118!> matrix_dedc is the derivative of the energy with respect to the orbitals (except for a factor 2*fi)
119!> a null pointer for matrix_s implies that matrix_s is the unit matrix
120!> \param mo_array ...
121!> \param matrix_dedc ...
122!> \param smear ...
123!> \param matrix_s ...
124!> \param energy ...
125!> \param energy_only ...
126!> \param delta ...
127!> \param qs_ot_env ...
128! **************************************************************************************************
129 SUBROUTINE ot_scf_mini(mo_array, matrix_dedc, smear, matrix_s, energy, &
130 energy_only, delta, qs_ot_env)
131
132 TYPE(mo_set_type), DIMENSION(:), INTENT(INOUT) :: mo_array
133 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_dedc
134 TYPE(smear_type), POINTER :: smear
135 TYPE(dbcsr_type), POINTER :: matrix_s
136 REAL(kind=dp) :: energy
137 LOGICAL, INTENT(INOUT) :: energy_only
138 REAL(kind=dp) :: delta
139 TYPE(qs_ot_type), DIMENSION(:), POINTER :: qs_ot_env
140
141 CHARACTER(len=*), PARAMETER :: routinen = 'ot_scf_mini'
142
143 INTEGER :: handle, ispin, k, n, nspin
144 LOGICAL :: need_gradient, restart_history
145 REAL(kind=dp) :: ener_nondiag, trace
146 TYPE(cp_1d_r_p_type), ALLOCATABLE, DIMENSION(:) :: expectation_values, occupation_numbers, &
147 scaling_factor
148 TYPE(cp_logger_type), POINTER :: logger
149 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_dedc_physical, matrix_dedc_scaled
150 TYPE(dbcsr_type), POINTER :: mo_coeff
151
152 CALL timeset(routinen, handle)
153
154 NULLIFY (logger)
155 logger => cp_get_default_logger()
156
157 CALL ot_mini_prepare(qs_ot_env, restart_history)
158 need_gradient = .NOT. qs_ot_env(1)%energy_only .OR. restart_history
159
160 nspin = SIZE(mo_array)
161
162 ALLOCATE (occupation_numbers(nspin))
163 ALLOCATE (scaling_factor(nspin))
164
165 IF (qs_ot_env(1)%settings%do_ener) THEN
166 ALLOCATE (expectation_values(nspin))
167 END IF
168
169 DO ispin = 1, nspin
170 CALL get_mo_set(mo_set=mo_array(ispin), occupation_numbers=occupation_numbers(ispin)%array)
171 ALLOCATE (scaling_factor(ispin)%array(SIZE(occupation_numbers(ispin)%array)))
172 scaling_factor(ispin)%array = 2.0_dp*occupation_numbers(ispin)%array
173 IF (qs_ot_env(1)%settings%do_ener) THEN
174 ALLOCATE (expectation_values(ispin)%array(SIZE(occupation_numbers(ispin)%array)))
175 END IF
176 END DO
177
178 ! optimizing orbital energies somehow implies non-equivalent orbitals
179 IF (qs_ot_env(1)%settings%do_ener) THEN
180 cpassert(qs_ot_env(1)%settings%do_rotation)
181 END IF
182 ! add_nondiag_energy requires do_ener
183 IF (qs_ot_env(1)%settings%add_nondiag_energy) THEN
184 cpassert(qs_ot_env(1)%settings%do_ener)
185 END IF
186
187 ! get a rotational force
188 IF (.NOT. energy_only) THEN
189 IF (qs_ot_env(1)%settings%do_rotation) THEN
190 DO ispin = 1, SIZE(qs_ot_env)
191 CALL get_mo_set(mo_set=mo_array(ispin), mo_coeff_b=mo_coeff)
192 CALL dbcsr_get_info(mo_coeff, nfullrows_total=n, nfullcols_total=k)
193 CALL dbcsr_multiply('T', 'N', 1.0_dp, mo_coeff, matrix_dedc(ispin)%matrix, &
194 0.0_dp, qs_ot_env(ispin)%rot_mat_chc)
195 CALL dbcsr_copy(qs_ot_env(ispin)%matrix_buf1, qs_ot_env(ispin)%rot_mat_chc)
196
197 CALL dbcsr_scale_by_vector(qs_ot_env(ispin)%matrix_buf1, alpha=scaling_factor(ispin)%array, side='right')
198 ! create the derivative of the energy wrt to rot_mat_u
199 CALL dbcsr_multiply('N', 'N', 1.0_dp, qs_ot_env(ispin)%rot_mat_u, qs_ot_env(ispin)%matrix_buf1, &
200 0.0_dp, qs_ot_env(ispin)%rot_mat_dedu)
201 END DO
202
203 ! here we construct the derivative of the free energy with respect to the evals
204 ! (note that this requires the diagonal elements of chc)
205 ! the mo occupations should in principle remain unaltered
206 IF (qs_ot_env(1)%settings%do_ener) THEN
207 DO ispin = 1, SIZE(mo_array)
208 CALL dbcsr_get_diag(qs_ot_env(ispin)%rot_mat_chc, expectation_values(ispin)%array)
209 qs_ot_env(ispin)%ener_gx = expectation_values(ispin)%array
210 CALL set_mo_occupation(mo_set=mo_array(ispin), &
211 smear=smear, eval_deriv=qs_ot_env(ispin)%ener_gx)
212 END DO
213 END IF
214
215 ! chc only needs to be stored in u independent form if we require add_nondiag_energy,
216 ! which will use it in non-selfconsistent form for e.g. the linesearch
217 ! transform C^T H C -> U C^T H C U ^ T
218 IF (qs_ot_env(1)%settings%add_nondiag_energy) THEN
219 DO ispin = 1, SIZE(qs_ot_env)
220 CALL dbcsr_get_info(qs_ot_env(ispin)%rot_mat_u, nfullcols_total=k)
221 CALL dbcsr_multiply('N', 'N', 1.0_dp, qs_ot_env(ispin)%rot_mat_u, qs_ot_env(ispin)%rot_mat_chc, &
222 0.0_dp, qs_ot_env(ispin)%matrix_buf1)
223 CALL dbcsr_multiply('N', 'T', 1.0_dp, qs_ot_env(ispin)%matrix_buf1, qs_ot_env(ispin)%rot_mat_u, &
224 0.0_dp, qs_ot_env(ispin)%rot_mat_chc)
225 END DO
226 END IF
227 END IF
228 END IF
229
230 ! evaluate non-diagonal energy contribution
231 ener_nondiag = 0.0_dp
232 IF (qs_ot_env(1)%settings%add_nondiag_energy) THEN
233 DO ispin = 1, SIZE(qs_ot_env)
234 ! transform \tilde H to the current basis of C (assuming non-selfconsistent H)
235 CALL dbcsr_get_info(qs_ot_env(ispin)%rot_mat_u, nfullcols_total=k)
236 CALL dbcsr_multiply('T', 'N', 1.0_dp, qs_ot_env(ispin)%rot_mat_u, qs_ot_env(ispin)%rot_mat_chc, &
237 0.0_dp, qs_ot_env(ispin)%matrix_buf1)
238 CALL dbcsr_multiply('N', 'N', 1.0_dp, qs_ot_env(ispin)%matrix_buf1, qs_ot_env(ispin)%rot_mat_u, &
239 0.0_dp, qs_ot_env(ispin)%matrix_buf2)
240
241 ! subtract the current ener_x from the diagonal
242 CALL dbcsr_get_diag(qs_ot_env(ispin)%matrix_buf2, expectation_values(ispin)%array)
243 expectation_values(ispin)%array = expectation_values(ispin)%array - qs_ot_env(ispin)%ener_x
244 CALL dbcsr_set_diag(qs_ot_env(ispin)%matrix_buf2, expectation_values(ispin)%array)
245
246 ! get nondiag energy trace (D^T D)
247 CALL dbcsr_dot(qs_ot_env(ispin)%matrix_buf2, qs_ot_env(ispin)%matrix_buf2, trace)
248 ener_nondiag = ener_nondiag + 0.5_dp*qs_ot_env(1)%settings%nondiag_energy_strength*trace
249
250 ! get gradient (again ignoring dependencies of H)
251 IF (.NOT. energy_only) THEN
252 ! first for the ener_x (-2*(diag(C^T H C)-ener_x))
253 qs_ot_env(ispin)%ener_gx = qs_ot_env(ispin)%ener_gx - &
254 qs_ot_env(1)%settings%nondiag_energy_strength*expectation_values(ispin)%array
255
256 ! next for the rot_mat_u derivative (2 * k * \tilde H U D)
257 CALL dbcsr_multiply('N', 'N', 1.0_dp, qs_ot_env(ispin)%rot_mat_chc, qs_ot_env(ispin)%rot_mat_u, &
258 0.0_dp, qs_ot_env(ispin)%matrix_buf1)
259 CALL dbcsr_multiply('N', 'N', 2.0_dp*qs_ot_env(1)%settings%nondiag_energy_strength, &
260 qs_ot_env(ispin)%matrix_buf1, qs_ot_env(ispin)%matrix_buf2, &
261 1.0_dp, qs_ot_env(ispin)%rot_mat_dedu)
262 END IF
263 END DO
264 END IF
265
266 ! The minimizer does not read derivative matrices on an energy-only trial.
267 matrix_dedc_scaled => matrix_dedc
268 NULLIFY (matrix_dedc_physical)
269 IF (need_gradient) THEN
270 ALLOCATE (matrix_dedc_scaled(SIZE(matrix_dedc)))
271 IF (qs_ot_env(1)%settings%occupation_preconditioner) THEN
272 ALLOCATE (matrix_dedc_physical(SIZE(matrix_dedc)))
273 END IF
274 DO ispin = 1, SIZE(matrix_dedc)
275 ALLOCATE (matrix_dedc_scaled(ispin)%matrix)
276 CALL dbcsr_copy(matrix_dedc_scaled(ispin)%matrix, matrix_dedc(ispin)%matrix)
277
278 IF (qs_ot_env(1)%settings%occupation_preconditioner) THEN
279 ALLOCATE (matrix_dedc_physical(ispin)%matrix)
280 CALL dbcsr_copy(matrix_dedc_physical(ispin)%matrix, matrix_dedc(ispin)%matrix)
281 CALL dbcsr_scale_by_vector(matrix_dedc_physical(ispin)%matrix, &
282 alpha=2.0_dp*occupation_numbers(ispin)%array, side='right')
283 scaling_factor(ispin)%array = 2.0_dp
284 END IF
285 CALL dbcsr_scale_by_vector(matrix_dedc_scaled(ispin)%matrix, alpha=scaling_factor(ispin)%array, side='right')
286 END DO
287 END IF
288
289 ! notice we use qs_ot_env(1) for driving all output and the minimization in case of LSD
290 qs_ot_env(1)%etotal = energy + ener_nondiag
291
292 IF (ASSOCIATED(matrix_dedc_physical) .AND. &
293 (qs_ot_env(1)%settings%ot_method == "CG" .OR. &
294 qs_ot_env(1)%settings%ot_method == "SD")) THEN
295 CALL ot_mini(qs_ot_env, matrix_dedc_scaled, matrix_hc_physical=matrix_dedc_physical, &
296 restart_history=restart_history)
297 ELSE
298 CALL ot_mini(qs_ot_env, matrix_dedc_scaled, restart_history=restart_history)
299 END IF
300
301 delta = qs_ot_env(1)%delta
302 energy_only = qs_ot_env(1)%energy_only
303
304 ! generate the orbitals using the new matrix_x
305 DO ispin = 1, SIZE(qs_ot_env)
306 CALL get_mo_set(mo_set=mo_array(ispin), mo_coeff_b=mo_coeff)
307 CALL dbcsr_get_info(mo_coeff, nfullrows_total=n, nfullcols_total=k)
308 SELECT CASE (qs_ot_env(1)%settings%ot_algorithm)
309 CASE ("TOD")
310 IF (ASSOCIATED(matrix_s)) THEN
311 CALL dbcsr_multiply('N', 'N', 1.0_dp, matrix_s, qs_ot_env(ispin)%matrix_x, &
312 0.0_dp, qs_ot_env(ispin)%matrix_sx)
313 ELSE
314 CALL dbcsr_copy(qs_ot_env(ispin)%matrix_sx, qs_ot_env(ispin)%matrix_x)
315 END IF
316 CALL qs_ot_get_p(qs_ot_env(ispin)%matrix_x, qs_ot_env(ispin)%matrix_sx, qs_ot_env(ispin))
317 CALL qs_ot_get_orbitals(mo_coeff, qs_ot_env(ispin)%matrix_x, qs_ot_env(ispin))
318 CASE ("REF")
319 CALL qs_ot_get_orbitals_ref(mo_coeff, matrix_s, qs_ot_env(ispin)%matrix_x, &
320 qs_ot_env(ispin)%matrix_sx, qs_ot_env(ispin)%matrix_gx_old, &
321 qs_ot_env(ispin)%matrix_dx, qs_ot_env(ispin), qs_ot_env(1))
322 CASE DEFAULT
323 cpabort("Algorithm not yet implemented")
324 END SELECT
325 END DO
326
327 IF (qs_ot_env(1)%restricted) THEN
328 CALL mo_set_restrict(mo_array, convert_dbcsr=.true.)
329 END IF
330 !
331 ! obtain the new set of OT eigenvalues and set the occupations accordingly
332 !
333 IF (qs_ot_env(1)%settings%do_ener) THEN
334 DO ispin = 1, SIZE(mo_array)
335 mo_array(ispin)%eigenvalues = qs_ot_env(ispin)%ener_x
336 CALL set_mo_occupation(mo_set=mo_array(ispin), &
337 smear=smear)
338 END DO
339 END IF
340
341 ! cleanup
342 DO ispin = 1, SIZE(scaling_factor)
343 DEALLOCATE (scaling_factor(ispin)%array)
344 END DO
345 DEALLOCATE (scaling_factor)
346 IF (qs_ot_env(1)%settings%do_ener) THEN
347 DO ispin = 1, SIZE(expectation_values)
348 DEALLOCATE (expectation_values(ispin)%array)
349 END DO
350 DEALLOCATE (expectation_values)
351 END IF
352 DEALLOCATE (occupation_numbers)
353 IF (need_gradient) THEN
354 DO ispin = 1, SIZE(matrix_dedc_scaled)
355 CALL dbcsr_release(matrix_dedc_scaled(ispin)%matrix)
356 DEALLOCATE (matrix_dedc_scaled(ispin)%matrix)
357 END DO
358 DEALLOCATE (matrix_dedc_scaled)
359 END IF
360 IF (ASSOCIATED(matrix_dedc_physical)) THEN
361 DO ispin = 1, SIZE(matrix_dedc_physical)
362 CALL dbcsr_release(matrix_dedc_physical(ispin)%matrix)
363 DEALLOCATE (matrix_dedc_physical(ispin)%matrix)
364 END DO
365 DEALLOCATE (matrix_dedc_physical)
366 END IF
367
368 CALL timestop(handle)
369
370 END SUBROUTINE ot_scf_mini
371
372! **************************************************************************************************
373!> \brief initialises qs_ot_env so that mo_coeff is the current point
374!> and that the minization can be started.
375!> \param mo_array ...
376!> \param matrix_s ...
377!> \param qs_ot_env ...
378!> \param matrix_ks ...
379!> \param broyden_adaptive_sigma ...
380! **************************************************************************************************
381 SUBROUTINE ot_scf_init(mo_array, matrix_s, qs_ot_env, matrix_ks, broyden_adaptive_sigma)
382
383 TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mo_array
384 TYPE(dbcsr_type), POINTER :: matrix_s
385 TYPE(qs_ot_type), DIMENSION(:), POINTER :: qs_ot_env
386 TYPE(dbcsr_type), POINTER :: matrix_ks
387 REAL(kind=dp) :: broyden_adaptive_sigma
388
389 CHARACTER(len=*), PARAMETER :: routinen = 'ot_scf_init'
390
391 INTEGER :: handle, ispin, k, n, nspin
392 LOGICAL :: is_equal
393 TYPE(cp_fm_type), POINTER :: mo_coeff_fm
394 TYPE(dbcsr_type), POINTER :: mo_coeff
395
396 CALL timeset(routinen, handle)
397
398 DO ispin = 1, SIZE(mo_array)
399 IF (.NOT. ASSOCIATED(mo_array(ispin)%mo_coeff_b)) THEN
400 cpabort("Shouldn't get there")
401 ! we do ot then copy fm to dbcsr
402 ! allocate that somewhere else ! fm -> dbcsr
403 CALL dbcsr_init_p(mo_array(ispin)%mo_coeff_b)
404 CALL cp_dbcsr_m_by_n_from_row_template(mo_array(ispin)%mo_coeff_b, template=matrix_ks, &
405 n=mo_array(ispin)%nmo, &
406 sym=dbcsr_type_no_symmetry)
407 END IF
408 END DO
409
410 ! *** set a history for broyden
411 DO ispin = 1, SIZE(qs_ot_env)
412 qs_ot_env(ispin)%broyden_adaptive_sigma = broyden_adaptive_sigma
413 END DO
414
415 ! **** SCP
416 ! **** SCP
417 ! adapted for work with the restricted keyword
418 nspin = SIZE(qs_ot_env)
419
420 DO ispin = 1, nspin
421
422 CALL qs_ot_set_context(qs_ot_env(ispin), spin_index=ispin)
423
424 NULLIFY (mo_coeff)
425 CALL get_mo_set(mo_set=mo_array(ispin), mo_coeff_b=mo_coeff, mo_coeff=mo_coeff_fm)
426 CALL copy_fm_to_dbcsr(mo_coeff_fm, mo_coeff) !fm -> dbcsr
427
428 CALL dbcsr_get_info(mo_coeff, nfullrows_total=n, nfullcols_total=k)
429
430 ! allocate
431 CALL qs_ot_allocate(qs_ot_env(ispin), matrix_ks, mo_coeff_fm%matrix_struct)
432
433 ! set c0,sc0
434 CALL dbcsr_copy(qs_ot_env(ispin)%matrix_c0, mo_coeff)
435 IF (ASSOCIATED(matrix_s)) THEN
436 CALL dbcsr_multiply('N', 'N', 1.0_dp, matrix_s, qs_ot_env(ispin)%matrix_c0, &
437 0.0_dp, qs_ot_env(ispin)%matrix_sc0)
438 ELSE
439 CALL dbcsr_copy(qs_ot_env(ispin)%matrix_sc0, qs_ot_env(ispin)%matrix_c0)
440 END IF
441
442 ! init
443 CALL qs_ot_init(qs_ot_env(ispin))
444
445 ! set x
446 CALL dbcsr_set(qs_ot_env(ispin)%matrix_x, 0.0_dp)
447 CALL dbcsr_set(qs_ot_env(ispin)%matrix_sx, 0.0_dp)
448
449 IF (qs_ot_env(ispin)%settings%do_rotation) THEN
450 CALL dbcsr_set(qs_ot_env(ispin)%rot_mat_x, 0.0_dp)
451 CALL dbcsr_set(qs_ot_env(ispin)%rot_mat_u, 0.0_dp)
452 CALL dbcsr_add_on_diag(qs_ot_env(ispin)%rot_mat_u, 1.0_dp)
453 END IF
454
455 IF (qs_ot_env(ispin)%settings%do_ener) THEN
456 is_equal = SIZE(qs_ot_env(ispin)%ener_x) == SIZE(mo_array(ispin)%eigenvalues)
457 cpassert(is_equal)
458 qs_ot_env(ispin)%ener_x = mo_array(ispin)%eigenvalues
459 END IF
460
461 SELECT CASE (qs_ot_env(1)%settings%ot_algorithm)
462 CASE ("TOD")
463 ! get c
464 CALL qs_ot_get_p(qs_ot_env(ispin)%matrix_x, qs_ot_env(ispin)%matrix_sx, qs_ot_env(ispin))
465 CASE ("REF")
466 CALL dbcsr_copy(qs_ot_env(ispin)%matrix_x, qs_ot_env(ispin)%matrix_c0)
467 CALL dbcsr_copy(qs_ot_env(ispin)%matrix_sx, qs_ot_env(ispin)%matrix_sc0)
468 CASE DEFAULT
469 cpabort("Algorithm not yet implemented")
470 END SELECT
471
472 END DO
473 CALL timestop(handle)
474 END SUBROUTINE ot_scf_init
475
476! **************************************************************************************************
477!> \brief ...
478!> \param qs_ot_env ...
479! **************************************************************************************************
480 SUBROUTINE ot_scf_destroy(qs_ot_env)
481
482 TYPE(qs_ot_type) :: qs_ot_env
483
484 CALL qs_ot_destroy(qs_ot_env)
485
486 END SUBROUTINE ot_scf_destroy
487
488END MODULE qs_ot_scf
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, first_row, last_row, first_column, last_column, first_k, last_k, retain_sparsity, filter_eps, flop)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_init_p(matrix)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_set_diag(matrix, diag)
Copies the diagonal elements from the given array into the given matrix.
subroutine, public dbcsr_get_diag(matrix, diag)
Copies the diagonal elements from the given matrix into the given array.
subroutine, public dbcsr_add_on_diag(matrix, alpha)
Adds the given scalar to the diagonal of the matrix. Reserves any missing diagonal blocks.
subroutine, public dbcsr_dot(matrix_a, matrix_b, trace)
Computes the dot product of two matrices, also known as the trace of their matrix product.
subroutine, public dbcsr_scale_by_vector(matrix, alpha, side)
Scales the rows/columns of given matrix.
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_m_by_n_from_row_template(matrix, template, n, sym)
Utility function to create dbcsr matrix, m x n matrix (n arbitrary) with the same processor grid and ...
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout, file_access)
...
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
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Set occupation of molecular orbitals.
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public mo_set_restrict(mo_array, convert_dbcsr)
make the beta orbitals explicitly equal to the alpha orbitals effectively copying the orbital data
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count, cmo_coeff)
Get the components of a MO set data structure.
orbital transformations
subroutine, public ot_mini(qs_ot_env, matrix_hc, matrix_hc_im, matrix_hc_physical, matrix_hc_physical_im, para_env_inter_kp, gradient_only, gradient_prepared, restart_history)
...
subroutine, public ot_mini_prepare(qs_ot_env, restart_history, para_env_inter_kp)
Prepare projection metrics and synchronize pending history restarts before building gradients.
basic functionality for using ot in the scf routines.
Definition qs_ot_scf.F:14
subroutine, public ot_scf_init(mo_array, matrix_s, qs_ot_env, matrix_ks, broyden_adaptive_sigma)
initialises qs_ot_env so that mo_coeff is the current point and that the minization can be started.
Definition qs_ot_scf.F:382
subroutine, public ot_scf_read_input(qs_ot_env, scf_section, do_kpoints)
...
Definition qs_ot_scf.F:75
subroutine, public ot_scf_mini(mo_array, matrix_dedc, smear, matrix_s, energy, energy_only, delta, qs_ot_env)
performs the actual minimisation, needs only limited info updated for restricted calculations matrix_...
Definition qs_ot_scf.F:131
subroutine, public ot_scf_destroy(qs_ot_env)
...
Definition qs_ot_scf.F:481
orbital transformations
Definition qs_ot_types.F:15
subroutine, public qs_ot_init(qs_ot_env)
init matrices, needs c0 and sc0 so that c0*sc0=1
subroutine, public qs_ot_settings_init(settings)
sets default values for the settings type
subroutine, public qs_ot_allocate(qs_ot_env, matrix_s, fm_struct_ref, ortho_k, energy_dimension)
allocates the data in qs_ot_env, for a calculation with fm_struct_ref ortho_k allows for specifying a...
subroutine, public ot_readwrite_input(settings, ot_section, output_unit, complex_kpoints, eigensolver)
...
subroutine, public qs_ot_set_context(qs_ot_env, spin_index, kpoint_index, local_kpoint_index, kpoint_weight)
label an OT environment by spin and optional irreducible k-point context
subroutine, public qs_ot_destroy(qs_ot_env)
deallocates data
orbital transformations
Definition qs_ot.F:15
subroutine, public qs_ot_get_p(matrix_x, matrix_sx, qs_ot_env)
computes p=x*S*x and the matrix functionals related matrices
Definition qs_ot.F:844
subroutine, public qs_ot_get_orbitals(matrix_c, matrix_x, qs_ot_env)
c=(c0*cos(p^0.5)+x*sin(p^0.5)*p^(-0.5)) x rot_mat_u this assumes that x is already ortho to S*C0,...
Definition qs_ot.F:1180
subroutine, public qs_ot_get_orbitals_ref(matrix_c, matrix_s, matrix_x, matrix_sx, matrix_gx_old, matrix_dx, qs_ot_env, qs_ot_env1)
...
Definition qs_ot.F:575
parameters that control an scf iteration
represent a pointer to a 1d array
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
contains the parameters needed by a scf run