(git:34ef472)
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-2024 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
25  USE cp_control_types, ONLY: dft_control_type,&
26  rtp_control_type
29  USE cp_fm_pool_types, ONLY: cp_fm_pool_p_type,&
34  cp_fm_struct_type
35  USE cp_fm_types, ONLY: cp_fm_create,&
36  cp_fm_release,&
37  cp_fm_type
38  USE cp_log_handling, ONLY: cp_to_string
39  USE dbcsr_api, ONLY: dbcsr_create,&
40  dbcsr_deallocate_matrix,&
41  dbcsr_init_p,&
42  dbcsr_p_type,&
43  dbcsr_type
44  USE kinds, ONLY: dp
45  USE qs_matrix_pools, ONLY: mpools_get,&
46  qs_matrix_pools_type
47  USE qs_mo_types, ONLY: get_mo_set,&
48  mo_set_type
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 
76  TYPE rt_prop_type
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  TYPE(rtp_rho_type), POINTER :: rho => null()
91  TYPE(rtp_mos_type), POINTER :: mos => null()
92  REAL(KIND=dp) :: energy_old = 0.0_dp
93  REAL(KIND=dp) :: energy_new = 0.0_dp
94  REAL(KIND=dp) :: dt = 0.0_dp
95  REAL(KIND=dp) :: delta_iter = 0.0_dp
96  REAL(KIND=dp) :: delta_iter_old = 0.0_dp
97  REAL(KIND=dp) :: filter_eps = 0.0_dp
98  REAL(KIND=dp) :: filter_eps_small = 0.0_dp
99  REAL(KIND=dp) :: mixing_factor = 0.0_dp
100  LOGICAL :: mixing = .false.
101  LOGICAL :: do_hfx = .false.
102  LOGICAL :: propagate_complex_ks = .false.
103  LOGICAL :: track_imag_density = .false.
104  INTEGER, DIMENSION(:, :), ALLOCATABLE :: orders
105  INTEGER :: nsteps = -1
106  INTEGER :: istep = -1
107  INTEGER :: i_start = -1
108  INTEGER :: max_steps = -1
109  INTEGER :: iter = -1
110  INTEGER :: narn_old = -1
111  LOGICAL :: converged = .false.
112  LOGICAL :: matrix_update = .false.
113  LOGICAL :: write_restart = .false.
114  TYPE(rtp_history_type), POINTER :: history => null()
115  TYPE(cp_fm_struct_type), POINTER :: ao_ao_fmstruct => null()
116  INTEGER :: lanzcos_max_iter = -1
117  REAL(KIND=dp) :: lanzcos_threshold = 0.0_dp
118  INTEGER :: newton_schulz_order = -1
119  LOGICAL :: linear_scaling = .false.
120  END TYPE rt_prop_type
121 
122 ! *** Public data types ***
123 
124  PUBLIC :: rt_prop_type
125 
126 ! *** Public subroutines ***
127 
128  PUBLIC :: rt_prop_create, &
131  get_rtp, &
132  rt_prop_release, &
135 CONTAINS
136 
137 ! **************************************************************************************************
138 !> \brief ...
139 !> \param rtp ...
140 !> \param mos ...
141 !> \param mpools ...
142 !> \param dft_control ...
143 !> \param template ...
144 !> \param linear_scaling ...
145 !> \param mos_aux ...
146 ! **************************************************************************************************
147  SUBROUTINE rt_prop_create(rtp, mos, mpools, dft_control, template, linear_scaling, mos_aux)
148 
149  TYPE(rt_prop_type), POINTER :: rtp
150  TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mos
151  TYPE(qs_matrix_pools_type), POINTER :: mpools
152  TYPE(dft_control_type), POINTER :: dft_control
153  TYPE(dbcsr_type), POINTER :: template
154  LOGICAL, INTENT(IN) :: linear_scaling
155  TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_aux
156 
157  INTEGER :: i, nspin
158  TYPE(rtp_control_type), POINTER :: rtp_control
159 
160  CALL cite_reference(kunert2003)
161 
162  NULLIFY (rtp_control)
163 
164  rtp_control => dft_control%rtp_control
165 
166  nspin = dft_control%nspins
167 
168  NULLIFY (rtp%mos, rtp%rho)
169  rtp%linear_scaling = linear_scaling
170 
171  IF (rtp%linear_scaling) THEN
172  ALLOCATE (rtp%rho)
173  NULLIFY (rtp%rho%old)
174  CALL dbcsr_allocate_matrix_set(rtp%rho%old, 2*nspin)
175  NULLIFY (rtp%rho%next)
176  CALL dbcsr_allocate_matrix_set(rtp%rho%next, 2*nspin)
177  NULLIFY (rtp%rho%new)
178  CALL dbcsr_allocate_matrix_set(rtp%rho%new, 2*nspin)
179  DO i = 1, 2*nspin
180  CALL dbcsr_init_p(rtp%rho%old(i)%matrix)
181  CALL dbcsr_create(rtp%rho%old(i)%matrix, template=template, matrix_type="N")
182  CALL dbcsr_init_p(rtp%rho%next(i)%matrix)
183  CALL dbcsr_create(rtp%rho%next(i)%matrix, template=template, matrix_type="N")
184  CALL dbcsr_init_p(rtp%rho%new(i)%matrix)
185  CALL dbcsr_create(rtp%rho%new(i)%matrix, template=template, matrix_type="N")
186  END DO
187  ELSE
188  IF (PRESENT(mos_aux)) THEN
189  CALL rt_prop_create_mos(rtp, mos, mpools, dft_control, mos_aux)
190  ELSE
191  CALL rt_prop_create_mos(rtp, mos, mpools, dft_control)
192  END IF
193  END IF
194 
195  NULLIFY (rtp%exp_H_old)
196  NULLIFY (rtp%exp_H_new)
197  NULLIFY (rtp%H_last_iter)
198  NULLIFY (rtp%propagator_matrix)
199  CALL dbcsr_allocate_matrix_set(rtp%exp_H_old, 2*nspin)
200  CALL dbcsr_allocate_matrix_set(rtp%exp_H_new, 2*nspin)
201  CALL dbcsr_allocate_matrix_set(rtp%H_last_iter, 2*nspin)
202  CALL dbcsr_allocate_matrix_set(rtp%propagator_matrix, 2*nspin)
203  DO i = 1, 2*nspin
204  CALL dbcsr_init_p(rtp%exp_H_old(i)%matrix)
205  CALL dbcsr_create(rtp%exp_H_old(i)%matrix, template=template, matrix_type="N")
206  CALL dbcsr_init_p(rtp%exp_H_new(i)%matrix)
207  CALL dbcsr_create(rtp%exp_H_new(i)%matrix, template=template, matrix_type="N")
208  CALL dbcsr_init_p(rtp%H_last_iter(i)%matrix)
209  CALL dbcsr_create(rtp%H_last_iter(i)%matrix, template=template, matrix_type="N")
210  CALL dbcsr_init_p(rtp%propagator_matrix(i)%matrix)
211  CALL dbcsr_create(rtp%propagator_matrix(i)%matrix, template=template, matrix_type="N")
212  END DO
213  NULLIFY (rtp%S_inv)
214  ALLOCATE (rtp%S_inv)
215  CALL dbcsr_create(rtp%S_inv, template=template, matrix_type="S")
216  NULLIFY (rtp%S_half)
217  ALLOCATE (rtp%S_half)
218  CALL dbcsr_create(rtp%S_half, template=template, matrix_type="S")
219  NULLIFY (rtp%S_minus_half)
220  ALLOCATE (rtp%S_minus_half)
221  CALL dbcsr_create(rtp%S_minus_half, template=template, matrix_type="S")
222  NULLIFY (rtp%B_mat)
223  NULLIFY (rtp%C_mat)
224  NULLIFY (rtp%S_der)
225  NULLIFY (rtp%SinvH)
226  NULLIFY (rtp%SinvB)
227  IF (.NOT. rtp_control%fixed_ions) THEN
228  ALLOCATE (rtp%B_mat)
229  CALL dbcsr_create(rtp%B_mat, template=template, matrix_type="N")
230  CALL dbcsr_allocate_matrix_set(rtp%C_mat, 3)
231  CALL dbcsr_allocate_matrix_set(rtp%S_der, 9)
232  CALL dbcsr_allocate_matrix_set(rtp%SinvH, nspin)
233  CALL dbcsr_allocate_matrix_set(rtp%SinvB, nspin)
234  DO i = 1, nspin
235  CALL dbcsr_init_p(rtp%SinvH(i)%matrix)
236  CALL dbcsr_create(rtp%SinvH(i)%matrix, template=template, matrix_type="N")
237  CALL dbcsr_init_p(rtp%SinvB(i)%matrix)
238  CALL dbcsr_create(rtp%SinvB(i)%matrix, template=template, matrix_type="N")
239  END DO
240  DO i = 1, 3
241  CALL dbcsr_init_p(rtp%C_mat(i)%matrix)
242  CALL dbcsr_create(rtp%C_mat(i)%matrix, template=template, matrix_type="N")
243  END DO
244  DO i = 1, 9
245  CALL dbcsr_init_p(rtp%S_der(i)%matrix)
246  CALL dbcsr_create(rtp%S_der(i)%matrix, template=template, matrix_type="N")
247  END DO
248  END IF
249  ALLOCATE (rtp%orders(2, nspin))
250  rtp_control%converged = .false.
251  rtp%matrix_update = .true.
252  rtp%narn_old = 0
253  rtp%istep = 0
254  rtp%iter = 0
255  rtp%do_hfx = .false.
256  rtp%track_imag_density = .false.
257 
258  END SUBROUTINE rt_prop_create
259 
260 ! **************************************************************************************************
261 !> \brief Initialize SinvH_imag for rtp
262 !> \param rtp ...
263 !> \param nspins ...
264 ! **************************************************************************************************
265  SUBROUTINE rtp_create_sinvh_imag(rtp, nspins)
266  TYPE(rt_prop_type), INTENT(INOUT) :: rtp
267  INTEGER :: nspins
268 
269  INTEGER :: i
270 
271  NULLIFY (rtp%SinvH_imag)
272  CALL dbcsr_allocate_matrix_set(rtp%SinvH_imag, nspins)
273  DO i = 1, nspins
274  CALL dbcsr_init_p(rtp%SinvH_imag(i)%matrix)
275  CALL dbcsr_create(rtp%SinvH_imag(i)%matrix, template=rtp%SinvH(1)%matrix, matrix_type="N")
276  END DO
277 
278  END SUBROUTINE rtp_create_sinvh_imag
279 
280 ! **************************************************************************************************
281 !> \brief Initialize the mos for rtp
282 !> \param rtp ...
283 !> \param mos ...
284 !> \param mpools ...
285 !> \param dft_control ...
286 !> \param mos_aux ...
287 !> \param init_mos_old ...
288 !> \param init_mos_new ...
289 !> \param init_mos_next ...
290 !> \param init_mos_admn ...
291 ! **************************************************************************************************
292  SUBROUTINE rt_prop_create_mos(rtp, mos, mpools, dft_control, mos_aux, init_mos_old, &
293  init_mos_new, init_mos_next, init_mos_admn)
294  TYPE(rt_prop_type), POINTER :: rtp
295  TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mos
296  TYPE(qs_matrix_pools_type), POINTER :: mpools
297  TYPE(dft_control_type), POINTER :: dft_control
298  TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_aux
299  LOGICAL, OPTIONAL :: init_mos_old, init_mos_new, &
300  init_mos_next, init_mos_admn
301 
302  INTEGER :: i, j, nao, nrow_block, nspin
303  LOGICAL :: my_mos_admn, my_mos_new, my_mos_next, &
304  my_mos_old
305  TYPE(cp_fm_pool_p_type), DIMENSION(:), POINTER :: ao_mo_fm_pools
306  TYPE(cp_fm_struct_type), POINTER :: ao_mo_fmstruct
307 
308  IF (PRESENT(init_mos_old)) THEN
309  my_mos_old = init_mos_old
310  ELSE
311  my_mos_old = .true.
312  END IF
313 
314  IF (PRESENT(init_mos_new)) THEN
315  my_mos_new = init_mos_new
316  ELSE
317  my_mos_new = .true.
318  END IF
319 
320  IF (PRESENT(init_mos_next)) THEN
321  my_mos_next = init_mos_next
322  ELSE
323  my_mos_next = .true.
324  END IF
325 
326  IF (PRESENT(init_mos_admn)) THEN
327  my_mos_admn = init_mos_admn
328  ELSE
329  my_mos_admn = .true.
330  END IF
331 
332  nspin = dft_control%nspins
333  CALL mpools_get(mpools, ao_mo_fm_pools=ao_mo_fm_pools)
334  ao_mo_fmstruct => fm_pool_get_el_struct(ao_mo_fm_pools(1)%pool)
335  CALL cp_fm_struct_get(ao_mo_fmstruct, nrow_block=nrow_block)
336  CALL get_mo_set(mos(1), nao=nao)
337 
338  CALL cp_fm_struct_create(fmstruct=rtp%ao_ao_fmstruct, &
339  nrow_block=nrow_block, ncol_block=nrow_block, &
340  nrow_global=nao, ncol_global=nao, &
341  template_fmstruct=ao_mo_fmstruct)
342  IF (.NOT. (ASSOCIATED(rtp%mos))) ALLOCATE (rtp%mos)
343  IF (my_mos_old) ALLOCATE (rtp%mos%old(2*nspin))
344  IF (my_mos_new) ALLOCATE (rtp%mos%new(2*nspin))
345  IF (my_mos_next) ALLOCATE (rtp%mos%next(2*nspin))
346  NULLIFY (rtp%mos%admm)
347  IF ((dft_control%do_admm) .AND. my_mos_admn) THEN
348  IF (PRESENT(mos_aux)) THEN
349  cpassert(ASSOCIATED(mos_aux))
350  ELSE
351  cpabort("The optional argument mos_aux is missing which is required with ADMM")
352  END IF
353  ALLOCATE (rtp%mos%admm(2*nspin))
354  END IF
355  DO i = 1, nspin
356  DO j = 1, 2
357  IF (my_mos_old) CALL cp_fm_create(rtp%mos%old(2*(i - 1) + j), &
358  matrix_struct=mos(i)%mo_coeff%matrix_struct, &
359  name="mos_old"//trim(adjustl(cp_to_string(2*(i - 1) + j))))
360  IF (my_mos_new) CALL cp_fm_create(rtp%mos%new(2*(i - 1) + j), &
361  matrix_struct=mos(i)%mo_coeff%matrix_struct, &
362  name="mos_new"//trim(adjustl(cp_to_string(2*(i - 1) + j))))
363  IF (my_mos_next) CALL cp_fm_create(rtp%mos%next(2*(i - 1) + j), &
364  matrix_struct=mos(i)%mo_coeff%matrix_struct, &
365  name="mos_next"//trim(adjustl(cp_to_string(2*(i - 1) + j))))
366  IF ((dft_control%do_admm) .AND. my_mos_admn) THEN
367  CALL cp_fm_create(rtp%mos%admm(2*(i - 1) + j), &
368  matrix_struct=mos_aux(i)%mo_coeff%matrix_struct, &
369  name="mos_admm"//trim(adjustl(cp_to_string(2*(i - 1) + j))))
370  END IF
371  END DO
372  END DO
373 
374  END SUBROUTINE rt_prop_create_mos
375 
376 ! **************************************************************************************************
377 !> \brief ...
378 !> \param rtp ...
379 !> \param exp_H_old ...
380 !> \param exp_H_new ...
381 !> \param H_last_iter ...
382 !> \param rho_old ...
383 !> \param rho_next ...
384 !> \param rho_new ...
385 !> \param mos ...
386 !> \param mos_new ...
387 !> \param mos_old ...
388 !> \param mos_next ...
389 !> \param S_inv ...
390 !> \param S_half ...
391 !> \param S_minus_half ...
392 !> \param B_mat ...
393 !> \param C_mat ...
394 !> \param propagator_matrix ...
395 !> \param mixing ...
396 !> \param mixing_factor ...
397 !> \param S_der ...
398 !> \param dt ...
399 !> \param nsteps ...
400 !> \param SinvH ...
401 !> \param SinvH_imag ...
402 !> \param SinvB ...
403 !> \param admm_mos ...
404 ! **************************************************************************************************
405  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, &
406  S_inv, S_half, S_minus_half, B_mat, C_mat, propagator_matrix, mixing, mixing_factor, &
407  S_der, dt, nsteps, SinvH, SinvH_imag, SinvB, admm_mos)
408 
409  TYPE(rt_prop_type), INTENT(IN) :: rtp
410  TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
411  POINTER :: exp_h_old, exp_h_new, h_last_iter, &
412  rho_old, rho_next, rho_new
413  TYPE(rtp_mos_type), OPTIONAL, POINTER :: mos
414  TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: mos_new, mos_old, mos_next
415  TYPE(dbcsr_type), OPTIONAL, POINTER :: s_inv, s_half, s_minus_half, b_mat
416  TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
417  POINTER :: c_mat, propagator_matrix
418  LOGICAL, OPTIONAL :: mixing
419  REAL(dp), INTENT(out), OPTIONAL :: mixing_factor
420  TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
421  POINTER :: s_der
422  REAL(dp), INTENT(out), OPTIONAL :: dt
423  INTEGER, INTENT(out), OPTIONAL :: nsteps
424  TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
425  POINTER :: sinvh, sinvh_imag, sinvb
426  TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: admm_mos
427 
428  IF (PRESENT(exp_h_old)) exp_h_old => rtp%exp_H_old
429  IF (PRESENT(exp_h_new)) exp_h_new => rtp%exp_H_new
430  IF (PRESENT(h_last_iter)) h_last_iter => rtp%H_last_iter
431  IF (PRESENT(propagator_matrix)) propagator_matrix => rtp%propagator_matrix
432 
433  IF (PRESENT(rho_old)) rho_old => rtp%rho%old
434  IF (PRESENT(rho_next)) rho_next => rtp%rho%next
435  IF (PRESENT(rho_new)) rho_new => rtp%rho%new
436  IF (PRESENT(mos)) mos => rtp%mos
437  IF (PRESENT(mos_old)) mos_old => rtp%mos%old
438  IF (PRESENT(mos_new)) mos_new => rtp%mos%new
439  IF (PRESENT(mos_next)) mos_next => rtp%mos%next
440  IF (PRESENT(admm_mos)) admm_mos => rtp%mos%admm
441 
442  IF (PRESENT(s_inv)) s_inv => rtp%S_inv
443  IF (PRESENT(s_half)) s_half => rtp%S_half
444  IF (PRESENT(s_minus_half)) s_minus_half => rtp%S_minus_half
445  IF (PRESENT(b_mat)) b_mat => rtp%B_mat
446  IF (PRESENT(c_mat)) c_mat => rtp%C_mat
447  IF (PRESENT(sinvh)) sinvh => rtp%SinvH
448  IF (PRESENT(sinvh_imag)) sinvh_imag => rtp%SinvH_imag
449  IF (PRESENT(sinvb)) sinvb => rtp%SinvB
450  IF (PRESENT(s_der)) s_der => rtp%S_der
451 
452  IF (PRESENT(dt)) dt = rtp%dt
453  IF (PRESENT(mixing)) mixing = rtp%mixing
454  IF (PRESENT(mixing_factor)) mixing_factor = rtp%mixing_factor
455  IF (PRESENT(nsteps)) nsteps = rtp%nsteps
456 
457  END SUBROUTINE get_rtp
458 
459 ! **************************************************************************************************
460 !> \brief ...
461 !> \param rtp ...
462 ! **************************************************************************************************
463  SUBROUTINE rt_prop_release(rtp)
464  TYPE(rt_prop_type), INTENT(inout) :: rtp
465 
466  CALL dbcsr_deallocate_matrix_set(rtp%exp_H_old)
467  CALL dbcsr_deallocate_matrix_set(rtp%exp_H_new)
468  CALL dbcsr_deallocate_matrix_set(rtp%H_last_iter)
469  CALL dbcsr_deallocate_matrix_set(rtp%propagator_matrix)
470  IF (ASSOCIATED(rtp%rho)) THEN
471  IF (ASSOCIATED(rtp%rho%old)) &
472  CALL dbcsr_deallocate_matrix_set(rtp%rho%old)
473  IF (ASSOCIATED(rtp%rho%next)) &
474  CALL dbcsr_deallocate_matrix_set(rtp%rho%next)
475  IF (ASSOCIATED(rtp%rho%new)) &
476  CALL dbcsr_deallocate_matrix_set(rtp%rho%new)
477  DEALLOCATE (rtp%rho)
478  END IF
479 
480  CALL rt_prop_release_mos(rtp)
481 
482  CALL dbcsr_deallocate_matrix(rtp%S_inv)
483  CALL dbcsr_deallocate_matrix(rtp%S_half)
484  CALL dbcsr_deallocate_matrix(rtp%S_minus_half)
485  IF (ASSOCIATED(rtp%B_mat)) &
486  CALL dbcsr_deallocate_matrix(rtp%B_mat)
487  IF (ASSOCIATED(rtp%C_mat)) &
488  CALL dbcsr_deallocate_matrix_set(rtp%C_mat)
489  IF (ASSOCIATED(rtp%S_der)) &
490  CALL dbcsr_deallocate_matrix_set(rtp%S_der)
491  IF (ASSOCIATED(rtp%SinvH)) &
492  CALL dbcsr_deallocate_matrix_set(rtp%SinvH)
493  IF (ASSOCIATED(rtp%SinvH_imag)) &
494  CALL dbcsr_deallocate_matrix_set(rtp%SinvH_imag)
495  IF (ASSOCIATED(rtp%SinvB)) &
496  CALL dbcsr_deallocate_matrix_set(rtp%SinvB)
497  IF (ASSOCIATED(rtp%history)) &
498  CALL rtp_history_release(rtp)
499  DEALLOCATE (rtp%orders)
500  END SUBROUTINE rt_prop_release
501 
502 ! **************************************************************************************************
503 !> \brief Deallocated the mos for rtp...
504 !> \param rtp ...
505 ! **************************************************************************************************
506  SUBROUTINE rt_prop_release_mos(rtp)
507  TYPE(rt_prop_type), INTENT(inout) :: rtp
508 
509  IF (ASSOCIATED(rtp%mos)) THEN
510  IF (ASSOCIATED(rtp%mos%old)) &
511  CALL cp_fm_release(rtp%mos%old)
512  IF (ASSOCIATED(rtp%mos%new)) &
513  CALL cp_fm_release(rtp%mos%new)
514  IF (ASSOCIATED(rtp%mos%next)) &
515  CALL cp_fm_release(rtp%mos%next)
516  IF (ASSOCIATED(rtp%mos%admm)) &
517  CALL cp_fm_release(rtp%mos%admm)
518  CALL cp_fm_struct_release(rtp%ao_ao_fmstruct)
519  DEALLOCATE (rtp%mos)
520  END IF
521 
522  END SUBROUTINE rt_prop_release_mos
523 ! **************************************************************************************************
524 !> \brief ...
525 !> \param rtp ...
526 !> \param aspc_order ...
527 ! **************************************************************************************************
528  SUBROUTINE rtp_history_create(rtp, aspc_order)
529  TYPE(rt_prop_type), INTENT(inout) :: rtp
530  INTEGER, INTENT(in) :: aspc_order
531 
532  INTEGER :: i, j, nmat
533  TYPE(rtp_history_type), POINTER :: history
534 
535  NULLIFY (history)
536  ALLOCATE (rtp%history)
537  history => rtp%history
538 
539  NULLIFY (history%rho_history, history%mo_history, history%s_history)
540  IF (aspc_order .GT. 0) THEN
541  IF (rtp%linear_scaling) THEN
542  nmat = SIZE(rtp%rho%new)
543  CALL dbcsr_allocate_matrix_set(history%rho_history, nmat, aspc_order)
544  DO i = 1, nmat
545  DO j = 1, aspc_order
546  CALL dbcsr_init_p(history%rho_history(i, j)%matrix)
547  CALL dbcsr_create(history%rho_history(i, j)%matrix, &
548  name="rho_hist"//trim(adjustl(cp_to_string(i))), &
549  template=rtp%rho%new(1)%matrix)
550  END DO
551  END DO
552  ELSE
553  nmat = SIZE(rtp%mos%old)
554  ALLOCATE (history%mo_history(nmat, aspc_order))
555  DO i = 1, nmat
556  DO j = 1, aspc_order
557  CALL cp_fm_create(history%mo_history(i, j), &
558  matrix_struct=rtp%mos%new(i)%matrix_struct, &
559  name="mo_hist"//trim(adjustl(cp_to_string(i))))
560  END DO
561  END DO
562  ALLOCATE (history%s_history(aspc_order))
563  DO i = 1, aspc_order
564  NULLIFY (history%s_history(i)%matrix)
565  END DO
566  END IF
567  END IF
568 
569  END SUBROUTINE rtp_history_create
570 
571 ! **************************************************************************************************
572 !> \brief ...
573 !> \param rtp ...
574 ! **************************************************************************************************
575  SUBROUTINE rtp_history_release(rtp)
576  TYPE(rt_prop_type), INTENT(inout) :: rtp
577 
578  INTEGER :: i
579 
580  IF (ASSOCIATED(rtp%history%rho_history)) THEN
581  CALL dbcsr_deallocate_matrix_set(rtp%history%rho_history)
582  END IF
583 
584  CALL cp_fm_release(rtp%history%mo_history)
585 
586  IF (ASSOCIATED(rtp%history%s_history)) THEN
587  DO i = 1, SIZE(rtp%history%s_history)
588  IF (ASSOCIATED(rtp%history%s_history(i)%matrix)) &
589  CALL dbcsr_deallocate_matrix(rtp%history%s_history(i)%matrix)
590  END DO
591  DEALLOCATE (rtp%history%s_history)
592  END IF
593  DEALLOCATE (rtp%history)
594 
595  END SUBROUTINE rtp_history_release
596 
597 END MODULE rt_propagation_types
collects all references to literature in CP2K as new algorithms / method are included from literature...
Definition: bibliography.F:28
integer, save, public kunert2003
Definition: bibliography.F:43
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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
Definition: cp_fm_struct.F:14
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
Definition: cp_fm_struct.F:125
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
Definition: cp_fm_struct.F:409
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
Definition: cp_fm_struct.F:320
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
Definition: cp_fm_types.F:167
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.
Definition: qs_mo_types.F:397
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 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_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 rt_prop_release(rtp)
...