(git:f56c6e3)
Loading...
Searching...
No Matches
rt_propagation_types.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Types and set_get for real time propagation
10!> depending on runtype and diagonalization method different
11!> matrices are allocated
12!> exp_H_old, exp_H_new, mos_new, mos_old contain always
13!> real and imaginary parts of the matrices
14!> odd index = real part (alpha, beta spin)
15!> even index= imaginary part (alpha, beta spin)
16!> \par History
17!> 02.2014 switched to dbcsr matrices [Samuel Andermatt]
18!> \author Florian Schiffmann 02.09
19! **************************************************************************************************
20
22
23 USE bibliography, ONLY: kunert2003,&
24 cite_reference
27 USE cp_dbcsr_api, ONLY: dbcsr_create,&
40 USE cp_fm_types, ONLY: cp_fm_create,&
44 USE kinds, ONLY: dp
45 USE qs_matrix_pools, ONLY: mpools_get,&
47 USE qs_mo_types, ONLY: get_mo_set,&
49#include "./base/base_uses.f90"
50
51 IMPLICIT NONE
52
53 PRIVATE
54
55 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'rt_propagation_types'
56
57 TYPE rtp_rho_type
58 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: new => null()
59 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: old => null()
60 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: next => null()
61 END TYPE rtp_rho_type
62
63 TYPE rtp_history_type
64 TYPE(dbcsr_p_type), POINTER, DIMENSION(:, :) :: rho_history => null()
65 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: s_history => null()
66 TYPE(cp_fm_type), POINTER, DIMENSION(:, :) :: mo_history => null()
67 END TYPE rtp_history_type
68
69 TYPE rtp_mos_type
70 TYPE(cp_fm_type), POINTER, DIMENSION(:) :: new => null()
71 TYPE(cp_fm_type), POINTER, DIMENSION(:) :: old => null()
72 TYPE(cp_fm_type), POINTER, DIMENSION(:) :: next => null()
73 TYPE(cp_fm_type), POINTER, DIMENSION(:) :: admm => null()
74 END TYPE rtp_mos_type
75
77 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: exp_h_old => null()
78 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: exp_h_new => null()
79 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: h_last_iter => null()
80 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: propagator_matrix => null()
81 TYPE(dbcsr_type), POINTER :: s_inv => null()
82 TYPE(dbcsr_type), POINTER :: s_half => null()
83 TYPE(dbcsr_type), POINTER :: s_minus_half => null()
84 TYPE(dbcsr_type), POINTER :: b_mat => null()
85 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: c_mat => null()
86 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: s_der => null()
87 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: sinvh => null()
88 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: sinvh_imag => null()
89 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: sinvb => null()
90 ! Matrix of local moments - may not be updated if ions are fixed
91 TYPE(dbcsr_p_type), POINTER, DIMENSION(:) :: local_moments => null()
92 TYPE(dbcsr_type), POINTER :: local_moments_work => null()
93 TYPE(rtp_rho_type), POINTER :: rho => null()
94 TYPE(rtp_mos_type), POINTER :: mos => null()
95 ! Moment trace, Indices : Spin, direction, time index
96 COMPLEX(KIND=dp), DIMENSION(:, :, :), POINTER :: moments
97 ! Fields do not have a spin index
98 COMPLEX(KIND=dp), DIMENSION(:, :), POINTER :: fields
99 REAL(kind=dp), DIMENSION(:), POINTER :: times
100 REAL(kind=dp) :: energy_old = 0.0_dp
101 REAL(kind=dp) :: energy_new = 0.0_dp
102 REAL(kind=dp) :: dt = 0.0_dp
103 REAL(kind=dp) :: delta_iter = 0.0_dp
104 REAL(kind=dp) :: delta_iter_old = 0.0_dp
105 REAL(kind=dp) :: filter_eps = 0.0_dp
106 REAL(kind=dp) :: filter_eps_small = 0.0_dp
107 REAL(kind=dp) :: mixing_factor = 0.0_dp
108 LOGICAL :: mixing = .false.
109 LOGICAL :: do_hfx = .false.
110 LOGICAL :: propagate_complex_ks = .false.
111 LOGICAL :: track_imag_density = .false.
112 INTEGER, DIMENSION(:, :), ALLOCATABLE :: orders
113 INTEGER :: nsteps = -1
114 INTEGER :: istep = -1
115 INTEGER :: i_start = -1
116 INTEGER :: max_steps = -1
117 INTEGER :: iter = -1
118 INTEGER :: narn_old = -1
119 LOGICAL :: converged = .false.
120 LOGICAL :: matrix_update = .false.
121 LOGICAL :: write_restart = .false.
122 TYPE(rtp_history_type), POINTER :: history => null()
123 TYPE(cp_fm_struct_type), POINTER :: ao_ao_fmstruct => null()
124 INTEGER :: lanzcos_max_iter = -1
125 REAL(kind=dp) :: lanzcos_threshold = 0.0_dp
126 INTEGER :: newton_schulz_order = -1
127 LOGICAL :: linear_scaling = .false.
128 END TYPE rt_prop_type
129
130! *** Public data types ***
131
132 PUBLIC :: rt_prop_type
133
134! *** Public subroutines ***
135
136 PUBLIC :: rt_prop_create, &
139 get_rtp, &
143CONTAINS
144
145! **************************************************************************************************
146!> \brief ...
147!> \param rtp ...
148!> \param mos ...
149!> \param mpools ...
150!> \param dft_control ...
151!> \param template ...
152!> \param linear_scaling ...
153!> \param mos_aux ...
154! **************************************************************************************************
155 SUBROUTINE rt_prop_create(rtp, mos, mpools, dft_control, template, linear_scaling, mos_aux)
156
157 TYPE(rt_prop_type), POINTER :: rtp
158 TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mos
159 TYPE(qs_matrix_pools_type), POINTER :: mpools
160 TYPE(dft_control_type), POINTER :: dft_control
161 TYPE(dbcsr_type), POINTER :: template
162 LOGICAL, INTENT(IN) :: linear_scaling
163 TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_aux
164
165 INTEGER :: i, nspin
166 TYPE(rtp_control_type), POINTER :: rtp_control
167
168 CALL cite_reference(kunert2003)
169
170 NULLIFY (rtp_control)
171
172 rtp_control => dft_control%rtp_control
173
174 nspin = dft_control%nspins
175
176 NULLIFY (rtp%mos, rtp%rho)
177 rtp%linear_scaling = linear_scaling
178
179 IF (rtp%linear_scaling) THEN
180 ALLOCATE (rtp%rho)
181 NULLIFY (rtp%rho%old)
182 CALL dbcsr_allocate_matrix_set(rtp%rho%old, 2*nspin)
183 NULLIFY (rtp%rho%next)
184 CALL dbcsr_allocate_matrix_set(rtp%rho%next, 2*nspin)
185 NULLIFY (rtp%rho%new)
186 CALL dbcsr_allocate_matrix_set(rtp%rho%new, 2*nspin)
187 DO i = 1, 2*nspin
188 CALL dbcsr_init_p(rtp%rho%old(i)%matrix)
189 CALL dbcsr_create(rtp%rho%old(i)%matrix, template=template, matrix_type="N")
190 CALL dbcsr_init_p(rtp%rho%next(i)%matrix)
191 CALL dbcsr_create(rtp%rho%next(i)%matrix, template=template, matrix_type="N")
192 CALL dbcsr_init_p(rtp%rho%new(i)%matrix)
193 CALL dbcsr_create(rtp%rho%new(i)%matrix, template=template, matrix_type="N")
194 END DO
195 ELSE
196 IF (PRESENT(mos_aux)) THEN
197 CALL rt_prop_create_mos(rtp, mos, mpools, dft_control, mos_aux)
198 ELSE
199 CALL rt_prop_create_mos(rtp, mos, mpools, dft_control)
200 END IF
201 END IF
202
203 NULLIFY (rtp%exp_H_old)
204 NULLIFY (rtp%exp_H_new)
205 NULLIFY (rtp%H_last_iter)
206 NULLIFY (rtp%propagator_matrix)
207 CALL dbcsr_allocate_matrix_set(rtp%exp_H_old, 2*nspin)
208 CALL dbcsr_allocate_matrix_set(rtp%exp_H_new, 2*nspin)
209 CALL dbcsr_allocate_matrix_set(rtp%H_last_iter, 2*nspin)
210 CALL dbcsr_allocate_matrix_set(rtp%propagator_matrix, 2*nspin)
211 DO i = 1, 2*nspin
212 CALL dbcsr_init_p(rtp%exp_H_old(i)%matrix)
213 CALL dbcsr_create(rtp%exp_H_old(i)%matrix, template=template, matrix_type="N")
214 CALL dbcsr_init_p(rtp%exp_H_new(i)%matrix)
215 CALL dbcsr_create(rtp%exp_H_new(i)%matrix, template=template, matrix_type="N")
216 CALL dbcsr_init_p(rtp%H_last_iter(i)%matrix)
217 CALL dbcsr_create(rtp%H_last_iter(i)%matrix, template=template, matrix_type="N")
218 CALL dbcsr_init_p(rtp%propagator_matrix(i)%matrix)
219 CALL dbcsr_create(rtp%propagator_matrix(i)%matrix, template=template, matrix_type="N")
220 END DO
221 NULLIFY (rtp%S_inv)
222 ALLOCATE (rtp%S_inv)
223 CALL dbcsr_create(rtp%S_inv, template=template, matrix_type="S")
224 NULLIFY (rtp%S_half)
225 ALLOCATE (rtp%S_half)
226 CALL dbcsr_create(rtp%S_half, template=template, matrix_type="S")
227 NULLIFY (rtp%S_minus_half)
228 ALLOCATE (rtp%S_minus_half)
229 CALL dbcsr_create(rtp%S_minus_half, template=template, matrix_type="S")
230 NULLIFY (rtp%B_mat)
231 NULLIFY (rtp%C_mat)
232 NULLIFY (rtp%S_der)
233 NULLIFY (rtp%SinvH)
234 NULLIFY (rtp%SinvB)
235 IF (.NOT. rtp_control%fixed_ions) THEN
236 ALLOCATE (rtp%B_mat)
237 CALL dbcsr_create(rtp%B_mat, template=template, matrix_type="N")
238 CALL dbcsr_allocate_matrix_set(rtp%C_mat, 3)
239 CALL dbcsr_allocate_matrix_set(rtp%S_der, 9)
240 CALL dbcsr_allocate_matrix_set(rtp%SinvH, nspin)
241 CALL dbcsr_allocate_matrix_set(rtp%SinvB, nspin)
242 DO i = 1, nspin
243 CALL dbcsr_init_p(rtp%SinvH(i)%matrix)
244 CALL dbcsr_create(rtp%SinvH(i)%matrix, template=template, matrix_type="N")
245 CALL dbcsr_init_p(rtp%SinvB(i)%matrix)
246 CALL dbcsr_create(rtp%SinvB(i)%matrix, template=template, matrix_type="N")
247 END DO
248 DO i = 1, 3
249 CALL dbcsr_init_p(rtp%C_mat(i)%matrix)
250 CALL dbcsr_create(rtp%C_mat(i)%matrix, template=template, matrix_type="N")
251 END DO
252 DO i = 1, 9
253 CALL dbcsr_init_p(rtp%S_der(i)%matrix)
254 CALL dbcsr_create(rtp%S_der(i)%matrix, template=template, matrix_type="N")
255 END DO
256 END IF
257 ALLOCATE (rtp%orders(2, nspin))
258 rtp_control%converged = .false.
259 rtp%matrix_update = .true.
260 rtp%narn_old = 0
261 rtp%istep = 0
262 rtp%iter = 0
263 rtp%do_hfx = .false.
264 rtp%track_imag_density = .false.
265
266 END SUBROUTINE rt_prop_create
267
268! **************************************************************************************************
269!> \brief Initialize SinvH_imag for rtp
270!> \param rtp ...
271!> \param nspins ...
272! **************************************************************************************************
273 SUBROUTINE rtp_create_sinvh_imag(rtp, nspins)
274 TYPE(rt_prop_type), INTENT(INOUT) :: rtp
275 INTEGER :: nspins
276
277 INTEGER :: i
278
279 NULLIFY (rtp%SinvH_imag)
280 CALL dbcsr_allocate_matrix_set(rtp%SinvH_imag, nspins)
281 DO i = 1, nspins
282 CALL dbcsr_init_p(rtp%SinvH_imag(i)%matrix)
283 CALL dbcsr_create(rtp%SinvH_imag(i)%matrix, template=rtp%SinvH(1)%matrix, matrix_type="N")
284 END DO
285
286 END SUBROUTINE rtp_create_sinvh_imag
287
288! **************************************************************************************************
289!> \brief Initialize the mos for rtp
290!> \param rtp ...
291!> \param mos ...
292!> \param mpools ...
293!> \param dft_control ...
294!> \param mos_aux ...
295!> \param init_mos_old ...
296!> \param init_mos_new ...
297!> \param init_mos_next ...
298!> \param init_mos_admn ...
299! **************************************************************************************************
300 SUBROUTINE rt_prop_create_mos(rtp, mos, mpools, dft_control, mos_aux, init_mos_old, &
301 init_mos_new, init_mos_next, init_mos_admn)
302 TYPE(rt_prop_type), POINTER :: rtp
303 TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mos
304 TYPE(qs_matrix_pools_type), POINTER :: mpools
305 TYPE(dft_control_type), POINTER :: dft_control
306 TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_aux
307 LOGICAL, OPTIONAL :: init_mos_old, init_mos_new, &
308 init_mos_next, init_mos_admn
309
310 INTEGER :: i, j, nao, nrow_block, nspin
311 LOGICAL :: my_mos_admn, my_mos_new, my_mos_next, &
312 my_mos_old
313 TYPE(cp_fm_pool_p_type), DIMENSION(:), POINTER :: ao_mo_fm_pools
314 TYPE(cp_fm_struct_type), POINTER :: ao_mo_fmstruct
315
316 IF (PRESENT(init_mos_old)) THEN
317 my_mos_old = init_mos_old
318 ELSE
319 my_mos_old = .true.
320 END IF
321
322 IF (PRESENT(init_mos_new)) THEN
323 my_mos_new = init_mos_new
324 ELSE
325 my_mos_new = .true.
326 END IF
327
328 IF (PRESENT(init_mos_next)) THEN
329 my_mos_next = init_mos_next
330 ELSE
331 my_mos_next = .true.
332 END IF
333
334 IF (PRESENT(init_mos_admn)) THEN
335 my_mos_admn = init_mos_admn
336 ELSE
337 my_mos_admn = .true.
338 END IF
339
340 nspin = dft_control%nspins
341 CALL mpools_get(mpools, ao_mo_fm_pools=ao_mo_fm_pools)
342 ao_mo_fmstruct => fm_pool_get_el_struct(ao_mo_fm_pools(1)%pool)
343 CALL cp_fm_struct_get(ao_mo_fmstruct, nrow_block=nrow_block)
344 CALL get_mo_set(mos(1), nao=nao)
345
346 CALL cp_fm_struct_create(fmstruct=rtp%ao_ao_fmstruct, &
347 nrow_block=nrow_block, ncol_block=nrow_block, &
348 nrow_global=nao, ncol_global=nao, &
349 template_fmstruct=ao_mo_fmstruct)
350 IF (.NOT. (ASSOCIATED(rtp%mos))) ALLOCATE (rtp%mos)
351 IF (my_mos_old) ALLOCATE (rtp%mos%old(2*nspin))
352 IF (my_mos_new) ALLOCATE (rtp%mos%new(2*nspin))
353 IF (my_mos_next) ALLOCATE (rtp%mos%next(2*nspin))
354 NULLIFY (rtp%mos%admm)
355 IF ((dft_control%do_admm) .AND. my_mos_admn) THEN
356 IF (PRESENT(mos_aux)) THEN
357 cpassert(ASSOCIATED(mos_aux))
358 ELSE
359 cpabort("The optional argument mos_aux is missing which is required with ADMM")
360 END IF
361 ALLOCATE (rtp%mos%admm(2*nspin))
362 END IF
363 DO i = 1, nspin
364 DO j = 1, 2
365 IF (my_mos_old) CALL cp_fm_create(rtp%mos%old(2*(i - 1) + j), &
366 matrix_struct=mos(i)%mo_coeff%matrix_struct, &
367 name="mos_old"//trim(adjustl(cp_to_string(2*(i - 1) + j))))
368 IF (my_mos_new) CALL cp_fm_create(rtp%mos%new(2*(i - 1) + j), &
369 matrix_struct=mos(i)%mo_coeff%matrix_struct, &
370 name="mos_new"//trim(adjustl(cp_to_string(2*(i - 1) + j))))
371 IF (my_mos_next) CALL cp_fm_create(rtp%mos%next(2*(i - 1) + j), &
372 matrix_struct=mos(i)%mo_coeff%matrix_struct, &
373 name="mos_next"//trim(adjustl(cp_to_string(2*(i - 1) + j))))
374 IF ((dft_control%do_admm) .AND. my_mos_admn) THEN
375 CALL cp_fm_create(rtp%mos%admm(2*(i - 1) + j), &
376 matrix_struct=mos_aux(i)%mo_coeff%matrix_struct, &
377 name="mos_admm"//trim(adjustl(cp_to_string(2*(i - 1) + j))))
378 END IF
379 END DO
380 END DO
381
382 END SUBROUTINE rt_prop_create_mos
383
384! **************************************************************************************************
385!> \brief ...
386!> \param rtp ...
387!> \param exp_H_old ...
388!> \param exp_H_new ...
389!> \param H_last_iter ...
390!> \param rho_old ...
391!> \param rho_next ...
392!> \param rho_new ...
393!> \param mos ...
394!> \param mos_new ...
395!> \param mos_old ...
396!> \param mos_next ...
397!> \param S_inv ...
398!> \param S_half ...
399!> \param S_minus_half ...
400!> \param B_mat ...
401!> \param C_mat ...
402!> \param propagator_matrix ...
403!> \param mixing ...
404!> \param mixing_factor ...
405!> \param S_der ...
406!> \param dt ...
407!> \param nsteps ...
408!> \param SinvH ...
409!> \param SinvH_imag ...
410!> \param SinvB ...
411!> \param admm_mos ...
412! **************************************************************************************************
413 SUBROUTINE get_rtp(rtp, exp_H_old, exp_H_new, H_last_iter, rho_old, rho_next, rho_new, mos, mos_new, mos_old, mos_next, &
414 S_inv, S_half, S_minus_half, B_mat, C_mat, propagator_matrix, mixing, mixing_factor, &
415 S_der, dt, nsteps, SinvH, SinvH_imag, SinvB, admm_mos)
416
417 TYPE(rt_prop_type), INTENT(IN) :: rtp
418 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
419 POINTER :: exp_h_old, exp_h_new, h_last_iter, &
420 rho_old, rho_next, rho_new
421 TYPE(rtp_mos_type), OPTIONAL, POINTER :: mos
422 TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: mos_new, mos_old, mos_next
423 TYPE(dbcsr_type), OPTIONAL, POINTER :: s_inv, s_half, s_minus_half, b_mat
424 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
425 POINTER :: c_mat, propagator_matrix
426 LOGICAL, OPTIONAL :: mixing
427 REAL(dp), INTENT(out), OPTIONAL :: mixing_factor
428 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
429 POINTER :: s_der
430 REAL(dp), INTENT(out), OPTIONAL :: dt
431 INTEGER, INTENT(out), OPTIONAL :: nsteps
432 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
433 POINTER :: sinvh, sinvh_imag, sinvb
434 TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: admm_mos
435
436 IF (PRESENT(exp_h_old)) exp_h_old => rtp%exp_H_old
437 IF (PRESENT(exp_h_new)) exp_h_new => rtp%exp_H_new
438 IF (PRESENT(h_last_iter)) h_last_iter => rtp%H_last_iter
439 IF (PRESENT(propagator_matrix)) propagator_matrix => rtp%propagator_matrix
440
441 IF (PRESENT(rho_old)) rho_old => rtp%rho%old
442 IF (PRESENT(rho_next)) rho_next => rtp%rho%next
443 IF (PRESENT(rho_new)) rho_new => rtp%rho%new
444 IF (PRESENT(mos)) mos => rtp%mos
445 IF (PRESENT(mos_old)) mos_old => rtp%mos%old
446 IF (PRESENT(mos_new)) mos_new => rtp%mos%new
447 IF (PRESENT(mos_next)) mos_next => rtp%mos%next
448 IF (PRESENT(admm_mos)) admm_mos => rtp%mos%admm
449
450 IF (PRESENT(s_inv)) s_inv => rtp%S_inv
451 IF (PRESENT(s_half)) s_half => rtp%S_half
452 IF (PRESENT(s_minus_half)) s_minus_half => rtp%S_minus_half
453 IF (PRESENT(b_mat)) b_mat => rtp%B_mat
454 IF (PRESENT(c_mat)) c_mat => rtp%C_mat
455 IF (PRESENT(sinvh)) sinvh => rtp%SinvH
456 IF (PRESENT(sinvh_imag)) sinvh_imag => rtp%SinvH_imag
457 IF (PRESENT(sinvb)) sinvb => rtp%SinvB
458 IF (PRESENT(s_der)) s_der => rtp%S_der
459
460 IF (PRESENT(dt)) dt = rtp%dt
461 IF (PRESENT(mixing)) mixing = rtp%mixing
462 IF (PRESENT(mixing_factor)) mixing_factor = rtp%mixing_factor
463 IF (PRESENT(nsteps)) nsteps = rtp%nsteps
464
465 END SUBROUTINE get_rtp
466
467! **************************************************************************************************
468!> \brief ...
469!> \param rtp ...
470! **************************************************************************************************
471 SUBROUTINE rt_prop_release(rtp)
472 TYPE(rt_prop_type), INTENT(inout) :: rtp
473
474 CALL dbcsr_deallocate_matrix_set(rtp%exp_H_old)
475 CALL dbcsr_deallocate_matrix_set(rtp%exp_H_new)
476 CALL dbcsr_deallocate_matrix_set(rtp%H_last_iter)
477 CALL dbcsr_deallocate_matrix_set(rtp%propagator_matrix)
478 IF (ASSOCIATED(rtp%rho)) THEN
479 IF (ASSOCIATED(rtp%rho%old)) &
480 CALL dbcsr_deallocate_matrix_set(rtp%rho%old)
481 IF (ASSOCIATED(rtp%rho%next)) &
482 CALL dbcsr_deallocate_matrix_set(rtp%rho%next)
483 IF (ASSOCIATED(rtp%rho%new)) &
484 CALL dbcsr_deallocate_matrix_set(rtp%rho%new)
485 DEALLOCATE (rtp%rho)
486 END IF
487
488 CALL rt_prop_release_mos(rtp)
489
490 CALL dbcsr_deallocate_matrix(rtp%S_inv)
491 CALL dbcsr_deallocate_matrix(rtp%S_half)
492 CALL dbcsr_deallocate_matrix(rtp%S_minus_half)
493 IF (ASSOCIATED(rtp%B_mat)) &
494 CALL dbcsr_deallocate_matrix(rtp%B_mat)
495 IF (ASSOCIATED(rtp%C_mat)) &
496 CALL dbcsr_deallocate_matrix_set(rtp%C_mat)
497 IF (ASSOCIATED(rtp%S_der)) &
498 CALL dbcsr_deallocate_matrix_set(rtp%S_der)
499 IF (ASSOCIATED(rtp%SinvH)) &
500 CALL dbcsr_deallocate_matrix_set(rtp%SinvH)
501 IF (ASSOCIATED(rtp%SinvH_imag)) &
502 CALL dbcsr_deallocate_matrix_set(rtp%SinvH_imag)
503 IF (ASSOCIATED(rtp%SinvB)) &
504 CALL dbcsr_deallocate_matrix_set(rtp%SinvB)
505 IF (ASSOCIATED(rtp%history)) &
506 CALL rtp_history_release(rtp)
507 DEALLOCATE (rtp%orders)
508 END SUBROUTINE rt_prop_release
509
510! **************************************************************************************************
511!> \brief Deallocated the mos for rtp...
512!> \param rtp ...
513! **************************************************************************************************
514 SUBROUTINE rt_prop_release_mos(rtp)
515 TYPE(rt_prop_type), INTENT(inout) :: rtp
516
517 IF (ASSOCIATED(rtp%mos)) THEN
518 IF (ASSOCIATED(rtp%mos%old)) &
519 CALL cp_fm_release(rtp%mos%old)
520 IF (ASSOCIATED(rtp%mos%new)) &
521 CALL cp_fm_release(rtp%mos%new)
522 IF (ASSOCIATED(rtp%mos%next)) &
523 CALL cp_fm_release(rtp%mos%next)
524 IF (ASSOCIATED(rtp%mos%admm)) &
525 CALL cp_fm_release(rtp%mos%admm)
526 CALL cp_fm_struct_release(rtp%ao_ao_fmstruct)
527 DEALLOCATE (rtp%mos)
528 END IF
529
530 END SUBROUTINE rt_prop_release_mos
531! **************************************************************************************************
532!> \brief ...
533!> \param rtp ...
534!> \param aspc_order ...
535! **************************************************************************************************
536 SUBROUTINE rtp_history_create(rtp, aspc_order)
537 TYPE(rt_prop_type), INTENT(inout) :: rtp
538 INTEGER, INTENT(in) :: aspc_order
539
540 INTEGER :: i, j, nmat
541 TYPE(rtp_history_type), POINTER :: history
542
543 NULLIFY (history)
544 ALLOCATE (rtp%history)
545 history => rtp%history
546
547 NULLIFY (history%rho_history, history%mo_history, history%s_history)
548 IF (aspc_order > 0) THEN
549 IF (rtp%linear_scaling) THEN
550 nmat = SIZE(rtp%rho%new)
551 CALL dbcsr_allocate_matrix_set(history%rho_history, nmat, aspc_order)
552 DO i = 1, nmat
553 DO j = 1, aspc_order
554 CALL dbcsr_init_p(history%rho_history(i, j)%matrix)
555 CALL dbcsr_create(history%rho_history(i, j)%matrix, &
556 name="rho_hist"//trim(adjustl(cp_to_string(i))), &
557 template=rtp%rho%new(1)%matrix)
558 END DO
559 END DO
560 ELSE
561 nmat = SIZE(rtp%mos%old)
562 ALLOCATE (history%mo_history(nmat, aspc_order))
563 DO i = 1, nmat
564 DO j = 1, aspc_order
565 CALL cp_fm_create(history%mo_history(i, j), &
566 matrix_struct=rtp%mos%new(i)%matrix_struct, &
567 name="mo_hist"//trim(adjustl(cp_to_string(i))))
568 END DO
569 END DO
570 ALLOCATE (history%s_history(aspc_order))
571 DO i = 1, aspc_order
572 NULLIFY (history%s_history(i)%matrix)
573 END DO
574 END IF
575 END IF
576
577 END SUBROUTINE rtp_history_create
578
579! **************************************************************************************************
580!> \brief ...
581!> \param rtp ...
582! **************************************************************************************************
583 SUBROUTINE rtp_history_release(rtp)
584 TYPE(rt_prop_type), INTENT(inout) :: rtp
585
586 INTEGER :: i
587
588 IF (ASSOCIATED(rtp%history%rho_history)) THEN
589 CALL dbcsr_deallocate_matrix_set(rtp%history%rho_history)
590 END IF
591
592 CALL cp_fm_release(rtp%history%mo_history)
593
594 IF (ASSOCIATED(rtp%history%s_history)) THEN
595 DO i = 1, SIZE(rtp%history%s_history)
596 IF (ASSOCIATED(rtp%history%s_history(i)%matrix)) &
597 CALL dbcsr_deallocate_matrix(rtp%history%s_history(i)%matrix)
598 END DO
599 DEALLOCATE (rtp%history%s_history)
600 END IF
601 DEALLOCATE (rtp%history)
602
603 END SUBROUTINE rtp_history_release
604
605END MODULE rt_propagation_types
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public kunert2003
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
subroutine, public dbcsr_init_p(matrix)
...
DBCSR operations in CP2K.
pool for for elements that are retained and released
type(cp_fm_struct_type) function, pointer, public fm_pool_get_el_struct(pool)
returns the structure of the elements in this pool
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_get(fmstruct, para_env, context, descriptor, ncol_block, nrow_block, nrow_global, ncol_global, first_p_pos, row_indices, col_indices, nrow_local, ncol_local, nrow_locals, ncol_locals, local_leading_dimension)
returns the values of various attributes of the matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
wrapper for the pools of matrixes
subroutine, public mpools_get(mpools, ao_mo_fm_pools, ao_ao_fm_pools, mo_mo_fm_pools, ao_mosub_fm_pools, mosub_mosub_fm_pools, maxao_maxmo_fm_pool, maxao_maxao_fm_pool, maxmo_maxmo_fm_pool)
returns various attributes of the mpools (notably the pools contained in it)
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
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)
Get the components of a MO set data structure.
Types and set_get for real time propagation depending on runtype and diagonalization method different...
subroutine, public rt_prop_release_mos(rtp)
Deallocated the mos for rtp...
subroutine, public rt_prop_create_mos(rtp, mos, mpools, dft_control, mos_aux, init_mos_old, init_mos_new, init_mos_next, init_mos_admn)
Initialize the mos for rtp.
subroutine, public rt_prop_create(rtp, mos, mpools, dft_control, template, linear_scaling, mos_aux)
...
subroutine, public rtp_create_sinvh_imag(rtp, nspins)
Initialize SinvH_imag for rtp.
subroutine, public rtp_history_create(rtp, aspc_order)
...
subroutine, public get_rtp(rtp, exp_h_old, exp_h_new, h_last_iter, rho_old, rho_next, rho_new, mos, mos_new, mos_old, mos_next, s_inv, s_half, s_minus_half, b_mat, c_mat, propagator_matrix, mixing, mixing_factor, s_der, dt, nsteps, sinvh, sinvh_imag, sinvb, admm_mos)
...
subroutine, public rt_prop_release(rtp)
...
keeps the information about the structure of a full matrix
represent a full matrix
container for the pools of matrixes used by qs