49#include "./base/base_uses.f90"
55 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rt_propagation_types'
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()
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
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()
80 TYPE(
dbcsr_p_type),
POINTER,
DIMENSION(:) :: propagator_matrix => 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
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()
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.
147 SUBROUTINE rt_prop_create(rtp, mos, mpools, dft_control, template, linear_scaling, mos_aux)
154 LOGICAL,
INTENT(IN) :: linear_scaling
155 TYPE(
mo_set_type),
DIMENSION(:),
OPTIONAL,
POINTER :: mos_aux
162 NULLIFY (rtp_control)
164 rtp_control => dft_control%rtp_control
166 nspin = dft_control%nspins
168 NULLIFY (rtp%mos, rtp%rho)
169 rtp%linear_scaling = linear_scaling
171 IF (rtp%linear_scaling)
THEN
173 NULLIFY (rtp%rho%old)
175 NULLIFY (rtp%rho%next)
177 NULLIFY (rtp%rho%new)
181 CALL dbcsr_create(rtp%rho%old(i)%matrix, template=template, matrix_type=
"N")
183 CALL dbcsr_create(rtp%rho%next(i)%matrix, template=template, matrix_type=
"N")
185 CALL dbcsr_create(rtp%rho%new(i)%matrix, template=template, matrix_type=
"N")
188 IF (
PRESENT(mos_aux))
THEN
195 NULLIFY (rtp%exp_H_old)
196 NULLIFY (rtp%exp_H_new)
197 NULLIFY (rtp%H_last_iter)
198 NULLIFY (rtp%propagator_matrix)
205 CALL dbcsr_create(rtp%exp_H_old(i)%matrix, template=template, matrix_type=
"N")
207 CALL dbcsr_create(rtp%exp_H_new(i)%matrix, template=template, matrix_type=
"N")
209 CALL dbcsr_create(rtp%H_last_iter(i)%matrix, template=template, matrix_type=
"N")
211 CALL dbcsr_create(rtp%propagator_matrix(i)%matrix, template=template, matrix_type=
"N")
215 CALL dbcsr_create(rtp%S_inv, template=template, matrix_type=
"S")
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")
227 IF (.NOT. rtp_control%fixed_ions)
THEN
229 CALL dbcsr_create(rtp%B_mat, template=template, matrix_type=
"N")
236 CALL dbcsr_create(rtp%SinvH(i)%matrix, template=template, matrix_type=
"N")
238 CALL dbcsr_create(rtp%SinvB(i)%matrix, template=template, matrix_type=
"N")
242 CALL dbcsr_create(rtp%C_mat(i)%matrix, template=template, matrix_type=
"N")
246 CALL dbcsr_create(rtp%S_der(i)%matrix, template=template, matrix_type=
"N")
249 ALLOCATE (rtp%orders(2, nspin))
250 rtp_control%converged = .false.
251 rtp%matrix_update = .true.
256 rtp%track_imag_density = .false.
271 NULLIFY (rtp%SinvH_imag)
275 CALL dbcsr_create(rtp%SinvH_imag(i)%matrix, template=rtp%SinvH(1)%matrix, matrix_type=
"N")
293 init_mos_new, init_mos_next, init_mos_admn)
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
302 INTEGER :: i, j, nao, nrow_block, nspin
303 LOGICAL :: my_mos_admn, my_mos_new, my_mos_next, &
308 IF (
PRESENT(init_mos_old))
THEN
309 my_mos_old = init_mos_old
314 IF (
PRESENT(init_mos_new))
THEN
315 my_mos_new = init_mos_new
320 IF (
PRESENT(init_mos_next))
THEN
321 my_mos_next = init_mos_next
326 IF (
PRESENT(init_mos_admn))
THEN
327 my_mos_admn = init_mos_admn
332 nspin = dft_control%nspins
333 CALL mpools_get(mpools, ao_mo_fm_pools=ao_mo_fm_pools)
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))
351 cpabort(
"The optional argument mos_aux is missing which is required with ADMM")
353 ALLOCATE (rtp%mos%admm(2*nspin))
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
368 matrix_struct=mos_aux(i)%mo_coeff%matrix_struct, &
369 name=
"mos_admm"//trim(adjustl(
cp_to_string(2*(i - 1) + j))))
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)
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
417 POINTER :: c_mat, propagator_matrix
418 LOGICAL,
OPTIONAL :: mixing
419 REAL(
dp),
INTENT(out),
OPTIONAL :: mixing_factor
422 REAL(
dp),
INTENT(out),
OPTIONAL :: dt
423 INTEGER,
INTENT(out),
OPTIONAL :: nsteps
425 POINTER :: sinvh, sinvh_imag, sinvb
426 TYPE(
cp_fm_type),
DIMENSION(:),
OPTIONAL,
POINTER :: admm_mos
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
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
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
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
470 IF (
ASSOCIATED(rtp%rho))
THEN
471 IF (
ASSOCIATED(rtp%rho%old)) &
473 IF (
ASSOCIATED(rtp%rho%next)) &
475 IF (
ASSOCIATED(rtp%rho%new)) &
485 IF (
ASSOCIATED(rtp%B_mat)) &
487 IF (
ASSOCIATED(rtp%C_mat)) &
489 IF (
ASSOCIATED(rtp%S_der)) &
491 IF (
ASSOCIATED(rtp%SinvH)) &
493 IF (
ASSOCIATED(rtp%SinvH_imag)) &
495 IF (
ASSOCIATED(rtp%SinvB)) &
497 IF (
ASSOCIATED(rtp%history)) &
498 CALL rtp_history_release(rtp)
499 DEALLOCATE (rtp%orders)
509 IF (
ASSOCIATED(rtp%mos))
THEN
510 IF (
ASSOCIATED(rtp%mos%old)) &
512 IF (
ASSOCIATED(rtp%mos%new)) &
514 IF (
ASSOCIATED(rtp%mos%next)) &
516 IF (
ASSOCIATED(rtp%mos%admm)) &
530 INTEGER,
INTENT(in) :: aspc_order
532 INTEGER :: i, j, nmat
533 TYPE(rtp_history_type),
POINTER :: history
536 ALLOCATE (rtp%history)
537 history => rtp%history
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)
549 template=rtp%rho%new(1)%matrix)
553 nmat =
SIZE(rtp%mos%old)
554 ALLOCATE (history%mo_history(nmat, aspc_order))
558 matrix_struct=rtp%mos%new(i)%matrix_struct, &
562 ALLOCATE (history%s_history(aspc_order))
564 NULLIFY (history%s_history(i)%matrix)
575 SUBROUTINE rtp_history_release(rtp)
580 IF (
ASSOCIATED(rtp%history%rho_history))
THEN
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)) &
591 DEALLOCATE (rtp%history%s_history)
593 DEALLOCATE (rtp%history)
595 END SUBROUTINE rtp_history_release
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
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.
integer, parameter, public dp
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.
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)
...
to create arrays of pools
keeps the information about the structure of a full matrix
container for the pools of matrixes used by qs