33 USE dbcsr_api,
ONLY: &
34 dbcsr_copy, dbcsr_create, dbcsr_deallocate_matrix, dbcsr_filter, dbcsr_multiply, &
35 dbcsr_p_type, dbcsr_scale, dbcsr_set, dbcsr_type
59 #include "../base/base_uses.f90"
65 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rt_propagator_init'
80 TYPE(qs_environment_type),
POINTER :: qs_env
82 INTEGER :: i, imat, unit_nr
83 REAL(kind=
dp) :: dt, prefac
84 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: mos_new, mos_next, mos_old
85 TYPE(cp_logger_type),
POINTER :: logger
86 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: exp_h_new, exp_h_old, matrix_ks, &
87 matrix_ks_im, propagator_matrix, &
89 TYPE(dft_control_type),
POINTER :: dft_control
90 TYPE(rt_prop_type),
POINTER :: rtp
91 TYPE(rtp_control_type),
POINTER :: rtp_control
95 dft_control=dft_control, &
97 matrix_ks=matrix_ks, &
98 matrix_ks_im=matrix_ks_im)
100 rtp_control => dft_control%rtp_control
101 CALL get_rtp(rtp=rtp, exp_h_old=exp_h_old, exp_h_new=exp_h_new, &
102 propagator_matrix=propagator_matrix, dt=dt)
104 CALL calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
105 DO i = 1,
SIZE(exp_h_old)
106 CALL dbcsr_copy(exp_h_old(i)%matrix, exp_h_new(i)%matrix)
109 IF (rtp_control%propagator ==
do_cn)
THEN
110 rtp%orders(1, :) = 0; rtp%orders(2, :) = 1; rtp_control%mat_exp =
do_pade; rtp_control%propagator =
do_em
111 ELSE IF (rtp_control%mat_exp ==
do_pade .OR. rtp_control%mat_exp ==
do_taylor)
THEN
112 IF (rtp%linear_scaling)
THEN
113 CALL get_maxabs_eigval_sparse(rtp, s_mat, matrix_ks, rtp_control)
115 CALL get_maxabs_eigval(rtp, s_mat, matrix_ks, rtp_control)
119 IF ((rtp_control%mat_exp ==
do_pade .OR. rtp_control%mat_exp ==
do_arnoldi) .AND. rtp%linear_scaling)
THEN
122 IF (logger%para_env%is_source())
THEN
124 WRITE (unit_nr, *)
"linear_scaling currently does not support pade nor arnoldi exponentials, switching to taylor"
128 ELSE IF (rtp_control%mat_exp ==
do_bch .AND. .NOT. rtp%linear_scaling)
THEN
131 IF (logger%para_env%is_source())
THEN
133 WRITE (unit_nr, *)
"BCH exponential currently only support linear_scaling, switching to arnoldi"
140 SELECT CASE (rtp_control%propagator)
146 DO imat = 1,
SIZE(exp_h_new)
147 CALL dbcsr_copy(propagator_matrix(imat)%matrix, exp_h_new(imat)%matrix)
148 CALL dbcsr_scale(propagator_matrix(imat)%matrix, prefac)
155 IF (rtp_control%propagator ==
do_etrs)
THEN
159 CALL get_rtp(rtp=rtp, mos_new=mos_new, mos_next=mos_next)
160 DO imat = 1,
SIZE(mos_new)
161 CALL cp_fm_to_fm(mos_new(imat), mos_next(imat))
163 ELSEIF (rtp_control%mat_exp ==
do_bch)
THEN
165 IF (rtp%linear_scaling)
THEN
170 DO imat = 1,
SIZE(exp_h_new)
171 CALL dbcsr_copy(exp_h_old(imat)%matrix, exp_h_new(imat)%matrix)
176 IF (rtp%linear_scaling)
THEN
177 CALL get_rtp(rtp=rtp, rho_old=rho_old)
179 CALL get_rtp(rtp=rtp, mos_old=mos_old)
196 SUBROUTINE get_maxabs_eigval(rtp, s_mat, matrix_ks, rtp_control)
197 TYPE(rt_prop_type),
POINTER :: rtp
198 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: s_mat, matrix_ks
199 TYPE(rtp_control_type),
POINTER :: rtp_control
201 CHARACTER(len=*),
PARAMETER :: routinen =
'get_maxabs_eigval'
202 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
204 INTEGER :: handle, ispin, method, ndim
206 REAL(
dp) :: max_eval, min_eval, norm2, scale, t
207 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: eigval_h
208 TYPE(cp_fm_type) :: eigvec_h, h_fm, s_half, s_inv_fm, &
209 s_minus_half, tmp, tmp_mat_h
210 TYPE(dbcsr_type),
POINTER :: s_inv
212 CALL timeset(routinen, handle)
214 CALL get_rtp(rtp=rtp, s_inv=s_inv, dt=t)
217 matrix_struct=rtp%ao_ao_fmstruct, &
222 matrix_struct=rtp%ao_ao_fmstruct, &
226 matrix_struct=rtp%ao_ao_fmstruct, &
230 matrix_struct=rtp%ao_ao_fmstruct, &
234 matrix_struct=rtp%ao_ao_fmstruct, &
237 ndim = s_inv_fm%matrix_struct%nrow_global
239 IF (rtp_control%propagator ==
do_etrs) scale = 2.0_dp
245 matrix_struct=rtp%ao_ao_fmstruct, &
249 matrix_struct=rtp%ao_ao_fmstruct, &
252 ALLOCATE (eigval_h(ndim))
258 eigval_h(:) = one/eigval_h(:)
259 CALL backtransform_matrix(eigval_h, eigvec_h, s_inv_fm)
260 eigval_h(:) = sqrt(eigval_h(:))
261 CALL backtransform_matrix(eigval_h, eigvec_h, s_minus_half)
262 eigval_h(:) = one/eigval_h(:)
263 CALL backtransform_matrix(eigval_h, eigvec_h, s_half)
264 CALL cp_fm_release(eigvec_h)
265 CALL cp_fm_release(tmp)
267 IF (rtp_control%mat_exp ==
do_taylor) method = 1
268 IF (rtp_control%mat_exp ==
do_pade) method = 2
269 emd = (.NOT. rtp_control%fixed_ions)
271 DO ispin = 1,
SIZE(matrix_ks)
277 CALL parallel_gemm(
"N",
"N", ndim, ndim, ndim, one, h_fm, s_minus_half, zero, &
279 CALL parallel_gemm(
"N",
"N", ndim, ndim, ndim, one, s_minus_half, tmp_mat_h, zero, &
283 min_eval = minval(eigval_h)
284 max_eval = maxval(eigval_h)
285 norm2 = 2.0_dp*max(abs(min_eval), abs(max_eval))
287 rtp_control%eps_exp, method, emd)
290 DEALLOCATE (eigval_h)
293 CALL cp_fm_release(s_inv_fm)
294 CALL cp_fm_release(s_half)
295 CALL cp_fm_release(s_minus_half)
296 CALL cp_fm_release(h_fm)
297 CALL cp_fm_release(tmp_mat_h)
299 CALL timestop(handle)
301 END SUBROUTINE get_maxabs_eigval
314 SUBROUTINE get_maxabs_eigval_sparse(rtp, s_mat, matrix_ks, rtp_control)
315 TYPE(rt_prop_type),
POINTER :: rtp
316 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: s_mat, matrix_ks
317 TYPE(rtp_control_type),
POINTER :: rtp_control
319 CHARACTER(len=*),
PARAMETER :: routinen =
'get_maxabs_eigval_sparse'
320 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
322 INTEGER :: handle, ispin, method
323 LOGICAL :: converged, emd
324 REAL(
dp) :: max_ev, min_ev, norm2, scale, t
325 TYPE(dbcsr_type),
POINTER :: s_half, s_minus_half, tmp, tmp2
327 CALL timeset(routinen, handle)
333 CALL dbcsr_create(s_half, template=s_mat(1)%matrix)
334 NULLIFY (s_minus_half)
335 ALLOCATE (s_minus_half)
336 CALL dbcsr_create(s_minus_half, template=s_mat(1)%matrix)
339 CALL dbcsr_create(tmp, template=s_mat(1)%matrix, matrix_type=
"N")
342 CALL dbcsr_create(tmp2, template=s_mat(1)%matrix, matrix_type=
"N")
344 IF (rtp_control%propagator ==
do_etrs) scale = 2.0_dp
346 emd = (.NOT. rtp_control%fixed_ions)
348 IF (rtp_control%mat_exp ==
do_taylor) method = 1
349 IF (rtp_control%mat_exp ==
do_pade) method = 2
351 rtp%newton_schulz_order, rtp%lanzcos_threshold, rtp%lanzcos_max_iter)
352 DO ispin = 1,
SIZE(matrix_ks)
353 CALL dbcsr_multiply(
"N",
"N", t, matrix_ks(ispin)%matrix, s_minus_half, zero, tmp, &
354 filter_eps=rtp%filter_eps)
355 CALL dbcsr_multiply(
"N",
"N", one, s_minus_half, tmp, zero, tmp2, &
356 filter_eps=rtp%filter_eps)
357 CALL arnoldi_extremal(tmp2, max_ev, min_ev, threshold=rtp%lanzcos_threshold, &
358 max_iter=rtp%lanzcos_max_iter, converged=converged)
359 norm2 = 2.0_dp*max(abs(min_ev), abs(max_ev))
361 rtp_control%eps_exp, method, emd)
364 CALL dbcsr_deallocate_matrix(s_half)
365 CALL dbcsr_deallocate_matrix(s_minus_half)
366 CALL dbcsr_deallocate_matrix(tmp)
367 CALL dbcsr_deallocate_matrix(tmp2)
369 CALL timestop(handle)
382 SUBROUTINE backtransform_matrix(Eval, eigenvec, matrix)
384 REAL(
dp),
DIMENSION(:),
INTENT(in) :: eval
385 TYPE(cp_fm_type),
INTENT(IN) :: eigenvec, matrix
387 CHARACTER(len=*),
PARAMETER :: routinen =
'backtransform_matrix'
388 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
390 INTEGER :: handle, i, j, l, ncol_local, ndim, &
392 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
393 TYPE(cp_fm_type) :: tmp
395 CALL timeset(routinen, handle)
397 matrix_struct=matrix%matrix_struct, &
399 CALL cp_fm_get_info(matrix, nrow_local=nrow_local, ncol_local=ncol_local, &
400 row_indices=row_indices, col_indices=col_indices)
402 ndim = matrix%matrix_struct%nrow_global
408 tmp%local_data(j, i) = eigenvec%local_data(j, i)*eval(l)
411 CALL parallel_gemm(
"N",
"T", ndim, ndim, ndim, one, tmp, eigenvec, zero, &
414 CALL cp_fm_release(tmp)
415 CALL timestop(handle)
417 END SUBROUTINE backtransform_matrix
432 TYPE(rt_prop_type),
POINTER :: rtp
433 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
434 TYPE(cp_fm_type),
DIMENSION(:),
OPTIONAL,
POINTER :: mos_old
436 INTEGER :: im, ispin, ncol, re
437 REAL(kind=
dp) :: alpha
438 TYPE(cp_fm_type) :: mos_occ, mos_occ_im
439 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_new, rho_old
441 CALL get_rtp(rtp=rtp, rho_old=rho_old, rho_new=rho_new)
443 IF (
PRESENT(mos_old))
THEN
445 DO ispin = 1,
SIZE(mos_old)/2
446 re = 2*ispin - 1; im = 2*ispin
447 CALL dbcsr_set(rho_old(re)%matrix, 0.0_dp)
450 matrix_struct=mos(ispin)%mo_coeff%matrix_struct, &
453 CALL cp_fm_to_fm(mos_old(re), mos_occ)
454 IF (mos(ispin)%uniform_occupation)
THEN
455 alpha = 3.0_dp - real(
SIZE(mos_old)/2,
dp)
460 alpha=alpha, keep_sparsity=.false.)
465 matrix_v=mos_old(re), &
468 alpha=alpha, keep_sparsity=.false.)
472 CALL cp_fm_to_fm(mos_old(im), mos_occ)
473 IF (mos(ispin)%uniform_occupation)
THEN
474 alpha = 3.0_dp - real(
SIZE(mos_old)/2,
dp)
479 alpha=alpha, keep_sparsity=.false.)
484 matrix_v=mos_old(im), &
487 alpha=alpha, keep_sparsity=.false.)
489 CALL dbcsr_filter(rho_old(re)%matrix, rtp%filter_eps)
490 CALL dbcsr_copy(rho_new(re)%matrix, rho_old(re)%matrix)
494 matrix_struct=mos(ispin)%mo_coeff%matrix_struct, &
496 alpha = 3.0_dp - real(
SIZE(mos_old)/2,
dp)
497 CALL cp_fm_to_fm(mos_old(re), mos_occ)
499 CALL cp_fm_to_fm(mos_old(im), mos_occ_im)
502 matrix_v=mos_occ_im, &
505 alpha=2.0_dp*alpha, &
506 symmetry_mode=-1, keep_sparsity=.false.)
508 CALL dbcsr_filter(rho_old(im)%matrix, rtp%filter_eps)
509 CALL dbcsr_copy(rho_new(im)%matrix, rho_old(im)%matrix)
510 CALL cp_fm_release(mos_occ_im)
511 CALL cp_fm_release(mos_occ)
516 DO ispin = 1,
SIZE(mos)
518 CALL dbcsr_set(rho_old(re)%matrix, 0.0_dp)
522 matrix_struct=mos(ispin)%mo_coeff%matrix_struct, &
524 CALL cp_fm_to_fm(mos(ispin)%mo_coeff, mos_occ)
525 IF (mos(ispin)%uniform_occupation)
THEN
526 alpha = 3.0_dp - real(
SIZE(mos),
dp)
531 alpha=alpha, keep_sparsity=.false.)
536 matrix_v=mos(ispin)%mo_coeff, &
539 alpha=alpha, keep_sparsity=.false.)
541 CALL dbcsr_filter(rho_old(re)%matrix, rtp%filter_eps)
542 CALL dbcsr_copy(rho_new(re)%matrix, rho_old(re)%matrix)
543 CALL cp_fm_release(mos_occ)
arnoldi iteration using dbcsr
subroutine, public arnoldi_extremal(matrix_a, max_ev, min_ev, converged, threshold, max_iter)
simple wrapper to estimate extremal eigenvalues with arnoldi, using the old lanczos interface this hi...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
basic linear algebra operations for full matrices
subroutine, public cp_fm_column_scale(matrixa, scaling)
scales column i of matrix a with scaling(i)
subroutine, public cp_fm_upper_to_full(matrix, work)
given an upper triangular matrix computes the corresponding full matrix
subroutine, public cp_fm_scale(alpha, matrix_a)
scales a matrix matrix_a = alpha * matrix_b
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public cp_fm_syevd(matrix, eigenvectors, eigenvalues, info)
Computes all eigenvalues and vectors of a real symmetric matrix significantly faster than syevx,...
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
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 ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Routines useful for iterative matrix calculations.
subroutine, public matrix_sqrt_newton_schulz(matrix_sqrt, matrix_sqrt_inv, matrix, threshold, order, eps_lanczos, max_iter_lanczos, symmetrize, converged)
compute the sqrt of a matrix via the sign function and the corresponding Newton-Schulz iterations the...
Defines the basic variable types.
integer, parameter, public dp
Routines for calculating a complex matrix exponential.
subroutine, public get_nsquare_norder(norm, nsquare, norder, eps_exp, method, do_emd)
optimization function for pade/taylor order and number of squaring steps
basic linear algebra operations for full matrixes
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, WannierCentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Get the QUICKSTEP environment.
Definition and initialisation of the mo data type.
Routines for calculating a complex matrix exponential.
subroutine, public compute_exponential_sparse(propagator, propagator_matrix, rtp_control, rtp)
Sparse versions of the matrix exponentials.
subroutine, public compute_exponential(propagator, propagator_matrix, rtp_control, rtp)
decides which type of exponential has to be computed
subroutine, public propagate_arnoldi(rtp, rtp_control)
computes U_prop*MOs using arnoldi subspace algorithm
Routines for propagating the orbitals.
subroutine, public calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
computes S_inv*H, if needed Sinv*B and S_inv*H_imag and store these quantities to the
subroutine, public put_data_to_history(rtp, mos, rho, s_mat, ihist)
...
subroutine, public s_matrices_create(s_mat, rtp)
calculates the needed overlap-like matrices depending on the way the exponential is calculated,...
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 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)
...
Routines for that prepare rtp and EMD.
subroutine, public init_propagators(qs_env)
prepares the initial matrices for the propagators
subroutine, public rt_initialize_rho_from_mos(rtp, mos, mos_old)
Computes the density matrix from the mos Update: Initialized the density matrix from complex mos (for...