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()
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()
96 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
POINTER :: moments
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
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()
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.
155 SUBROUTINE rt_prop_create(rtp, mos, mpools, dft_control, template, linear_scaling, mos_aux)
162 LOGICAL,
INTENT(IN) :: linear_scaling
163 TYPE(
mo_set_type),
DIMENSION(:),
OPTIONAL,
POINTER :: mos_aux
170 NULLIFY (rtp_control)
172 rtp_control => dft_control%rtp_control
174 nspin = dft_control%nspins
176 NULLIFY (rtp%mos, rtp%rho)
177 rtp%linear_scaling = linear_scaling
179 IF (rtp%linear_scaling)
THEN
181 NULLIFY (rtp%rho%old)
183 NULLIFY (rtp%rho%next)
185 NULLIFY (rtp%rho%new)
189 CALL dbcsr_create(rtp%rho%old(i)%matrix, template=template, matrix_type=
"N")
191 CALL dbcsr_create(rtp%rho%next(i)%matrix, template=template, matrix_type=
"N")
193 CALL dbcsr_create(rtp%rho%new(i)%matrix, template=template, matrix_type=
"N")
196 IF (
PRESENT(mos_aux))
THEN
203 NULLIFY (rtp%exp_H_old)
204 NULLIFY (rtp%exp_H_new)
205 NULLIFY (rtp%H_last_iter)
206 NULLIFY (rtp%propagator_matrix)
213 CALL dbcsr_create(rtp%exp_H_old(i)%matrix, template=template, matrix_type=
"N")
215 CALL dbcsr_create(rtp%exp_H_new(i)%matrix, template=template, matrix_type=
"N")
217 CALL dbcsr_create(rtp%H_last_iter(i)%matrix, template=template, matrix_type=
"N")
219 CALL dbcsr_create(rtp%propagator_matrix(i)%matrix, template=template, matrix_type=
"N")
223 CALL dbcsr_create(rtp%S_inv, template=template, matrix_type=
"S")
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")
235 IF (.NOT. rtp_control%fixed_ions)
THEN
237 CALL dbcsr_create(rtp%B_mat, template=template, matrix_type=
"N")
244 CALL dbcsr_create(rtp%SinvH(i)%matrix, template=template, matrix_type=
"N")
246 CALL dbcsr_create(rtp%SinvB(i)%matrix, template=template, matrix_type=
"N")
250 CALL dbcsr_create(rtp%C_mat(i)%matrix, template=template, matrix_type=
"N")
254 CALL dbcsr_create(rtp%S_der(i)%matrix, template=template, matrix_type=
"N")
257 ALLOCATE (rtp%orders(2, nspin))
258 rtp_control%converged = .false.
259 rtp%matrix_update = .true.
264 rtp%track_imag_density = .false.
279 NULLIFY (rtp%SinvH_imag)
283 CALL dbcsr_create(rtp%SinvH_imag(i)%matrix, template=rtp%SinvH(1)%matrix, matrix_type=
"N")
301 init_mos_new, init_mos_next, init_mos_admn)
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
310 INTEGER :: i, j, nao, nrow_block, nspin
311 LOGICAL :: my_mos_admn, my_mos_new, my_mos_next, &
316 IF (
PRESENT(init_mos_old))
THEN
317 my_mos_old = init_mos_old
322 IF (
PRESENT(init_mos_new))
THEN
323 my_mos_new = init_mos_new
328 IF (
PRESENT(init_mos_next))
THEN
329 my_mos_next = init_mos_next
334 IF (
PRESENT(init_mos_admn))
THEN
335 my_mos_admn = init_mos_admn
340 nspin = dft_control%nspins
341 CALL mpools_get(mpools, ao_mo_fm_pools=ao_mo_fm_pools)
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))
359 cpabort(
"The optional argument mos_aux is missing which is required with ADMM")
361 ALLOCATE (rtp%mos%admm(2*nspin))
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
376 matrix_struct=mos_aux(i)%mo_coeff%matrix_struct, &
377 name=
"mos_admm"//trim(adjustl(
cp_to_string(2*(i - 1) + j))))
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)
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
425 POINTER :: c_mat, propagator_matrix
426 LOGICAL,
OPTIONAL :: mixing
427 REAL(
dp),
INTENT(out),
OPTIONAL :: mixing_factor
430 REAL(
dp),
INTENT(out),
OPTIONAL :: dt
431 INTEGER,
INTENT(out),
OPTIONAL :: nsteps
433 POINTER :: sinvh, sinvh_imag, sinvb
434 TYPE(
cp_fm_type),
DIMENSION(:),
OPTIONAL,
POINTER :: admm_mos
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
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
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
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
478 IF (
ASSOCIATED(rtp%rho))
THEN
479 IF (
ASSOCIATED(rtp%rho%old)) &
481 IF (
ASSOCIATED(rtp%rho%next)) &
483 IF (
ASSOCIATED(rtp%rho%new)) &
493 IF (
ASSOCIATED(rtp%B_mat)) &
495 IF (
ASSOCIATED(rtp%C_mat)) &
497 IF (
ASSOCIATED(rtp%S_der)) &
499 IF (
ASSOCIATED(rtp%SinvH)) &
501 IF (
ASSOCIATED(rtp%SinvH_imag)) &
503 IF (
ASSOCIATED(rtp%SinvB)) &
505 IF (
ASSOCIATED(rtp%history)) &
506 CALL rtp_history_release(rtp)
507 DEALLOCATE (rtp%orders)
517 IF (
ASSOCIATED(rtp%mos))
THEN
518 IF (
ASSOCIATED(rtp%mos%old)) &
520 IF (
ASSOCIATED(rtp%mos%new)) &
522 IF (
ASSOCIATED(rtp%mos%next)) &
524 IF (
ASSOCIATED(rtp%mos%admm)) &
538 INTEGER,
INTENT(in) :: aspc_order
540 INTEGER :: i, j, nmat
541 TYPE(rtp_history_type),
POINTER :: history
544 ALLOCATE (rtp%history)
545 history => rtp%history
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)
557 template=rtp%rho%new(1)%matrix)
561 nmat =
SIZE(rtp%mos%old)
562 ALLOCATE (history%mo_history(nmat, aspc_order))
566 matrix_struct=rtp%mos%new(i)%matrix_struct, &
570 ALLOCATE (history%s_history(aspc_order))
572 NULLIFY (history%s_history(i)%matrix)
583 SUBROUTINE rtp_history_release(rtp)
588 IF (
ASSOCIATED(rtp%history%rho_history))
THEN
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)) &
599 DEALLOCATE (rtp%history%s_history)
601 DEALLOCATE (rtp%history)
603 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