60#include "../base/base_uses.f90"
66 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rt_propagator_init'
83 INTEGER :: i, imat, unit_nr
84 REAL(kind=
dp) :: dt, prefac
85 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: mos_new, mos_next, mos_old
87 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: exp_h_new, exp_h_old, matrix_ks, &
88 matrix_ks_im, propagator_matrix, &
96 dft_control=dft_control, &
98 matrix_ks=matrix_ks, &
99 matrix_ks_im=matrix_ks_im)
101 rtp_control => dft_control%rtp_control
102 CALL get_rtp(rtp=rtp, exp_h_old=exp_h_old, exp_h_new=exp_h_new, &
103 propagator_matrix=propagator_matrix, dt=dt)
105 CALL calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
106 DO i = 1,
SIZE(exp_h_old)
107 CALL dbcsr_copy(exp_h_old(i)%matrix, exp_h_new(i)%matrix)
110 IF (rtp_control%propagator ==
do_cn)
THEN
111 rtp%orders(1, :) = 0; rtp%orders(2, :) = 1; rtp_control%mat_exp =
do_pade; rtp_control%propagator =
do_em
112 ELSE IF (rtp_control%mat_exp ==
do_pade .OR. rtp_control%mat_exp ==
do_taylor)
THEN
113 IF (rtp%linear_scaling)
THEN
114 CALL get_maxabs_eigval_sparse(rtp, s_mat, matrix_ks, rtp_control)
116 CALL get_maxabs_eigval(rtp, s_mat, matrix_ks, rtp_control)
120 IF ((rtp_control%mat_exp ==
do_pade .OR. rtp_control%mat_exp ==
do_arnoldi) .AND. rtp%linear_scaling)
THEN
123 IF (logger%para_env%is_source())
THEN
125 WRITE (unit_nr, *)
"linear_scaling currently does not support pade nor arnoldi exponentials, switching to taylor"
129 ELSE IF (rtp_control%mat_exp ==
do_bch .AND. .NOT. rtp%linear_scaling)
THEN
132 IF (logger%para_env%is_source())
THEN
134 WRITE (unit_nr, *)
"BCH exponential currently only support linear_scaling, switching to arnoldi"
141 SELECT CASE (rtp_control%propagator)
147 DO imat = 1,
SIZE(exp_h_new)
148 CALL dbcsr_copy(propagator_matrix(imat)%matrix, exp_h_new(imat)%matrix)
149 CALL dbcsr_scale(propagator_matrix(imat)%matrix, prefac)
156 IF (rtp_control%propagator ==
do_etrs)
THEN
160 CALL get_rtp(rtp=rtp, mos_new=mos_new, mos_next=mos_next)
161 DO imat = 1,
SIZE(mos_new)
164 ELSEIF (rtp_control%mat_exp ==
do_bch .OR. rtp_control%mat_exp ==
do_exact)
THEN
166 IF (rtp%linear_scaling)
THEN
171 DO imat = 1,
SIZE(exp_h_new)
172 CALL dbcsr_copy(exp_h_old(imat)%matrix, exp_h_new(imat)%matrix)
177 IF (rtp%linear_scaling)
THEN
178 CALL get_rtp(rtp=rtp, rho_old=rho_old)
180 CALL get_rtp(rtp=rtp, mos_old=mos_old)
197 SUBROUTINE get_maxabs_eigval(rtp, s_mat, matrix_ks, rtp_control)
199 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: s_mat, matrix_ks
202 CHARACTER(len=*),
PARAMETER :: routinen =
'get_maxabs_eigval'
203 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
205 INTEGER :: handle, ispin, method, ndim
207 REAL(
dp) :: max_eval, min_eval, norm2, scale, t
208 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: eigval_h
209 TYPE(
cp_fm_type) :: eigvec_h, h_fm, s_half, s_inv_fm, &
210 s_minus_half, tmp, tmp_mat_h
213 CALL timeset(routinen, handle)
215 CALL get_rtp(rtp=rtp, s_inv=s_inv, dt=t)
218 matrix_struct=rtp%ao_ao_fmstruct, &
223 matrix_struct=rtp%ao_ao_fmstruct, &
227 matrix_struct=rtp%ao_ao_fmstruct, &
231 matrix_struct=rtp%ao_ao_fmstruct, &
235 matrix_struct=rtp%ao_ao_fmstruct, &
238 ndim = s_inv_fm%matrix_struct%nrow_global
240 IF (rtp_control%propagator ==
do_etrs) scale = 2.0_dp
246 matrix_struct=rtp%ao_ao_fmstruct, &
250 matrix_struct=rtp%ao_ao_fmstruct, &
253 ALLOCATE (eigval_h(ndim))
259 eigval_h(:) = one/eigval_h(:)
260 CALL backtransform_matrix(eigval_h, eigvec_h, s_inv_fm)
261 eigval_h(:) = sqrt(eigval_h(:))
262 CALL backtransform_matrix(eigval_h, eigvec_h, s_minus_half)
263 eigval_h(:) = one/eigval_h(:)
264 CALL backtransform_matrix(eigval_h, eigvec_h, s_half)
268 IF (rtp_control%mat_exp ==
do_taylor) method = 1
269 IF (rtp_control%mat_exp ==
do_pade) method = 2
270 emd = (.NOT. rtp_control%fixed_ions)
272 DO ispin = 1,
SIZE(matrix_ks)
278 CALL parallel_gemm(
"N",
"N", ndim, ndim, ndim, one, h_fm, s_minus_half, zero, &
280 CALL parallel_gemm(
"N",
"N", ndim, ndim, ndim, one, s_minus_half, tmp_mat_h, zero, &
284 min_eval = minval(eigval_h)
285 max_eval = maxval(eigval_h)
286 norm2 = 2.0_dp*max(abs(min_eval), abs(max_eval))
288 rtp_control%eps_exp, method, emd)
291 DEALLOCATE (eigval_h)
300 CALL timestop(handle)
302 END SUBROUTINE get_maxabs_eigval
315 SUBROUTINE get_maxabs_eigval_sparse(rtp, s_mat, matrix_ks, rtp_control)
317 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: s_mat, matrix_ks
320 CHARACTER(len=*),
PARAMETER :: routinen =
'get_maxabs_eigval_sparse'
321 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
323 INTEGER :: handle, ispin, method
324 LOGICAL :: converged, emd
325 REAL(
dp) :: max_ev, min_ev, norm2, scale, t
326 TYPE(
dbcsr_type),
POINTER :: s_half, s_minus_half, tmp, tmp2
328 CALL timeset(routinen, handle)
335 NULLIFY (s_minus_half)
336 ALLOCATE (s_minus_half)
337 CALL dbcsr_create(s_minus_half, template=s_mat(1)%matrix)
340 CALL dbcsr_create(tmp, template=s_mat(1)%matrix, matrix_type=
"N")
343 CALL dbcsr_create(tmp2, template=s_mat(1)%matrix, matrix_type=
"N")
345 IF (rtp_control%propagator ==
do_etrs) scale = 2.0_dp
347 emd = (.NOT. rtp_control%fixed_ions)
349 IF (rtp_control%mat_exp ==
do_taylor) method = 1
350 IF (rtp_control%mat_exp ==
do_pade) method = 2
352 rtp%newton_schulz_order, rtp%lanzcos_threshold, rtp%lanzcos_max_iter)
353 DO ispin = 1,
SIZE(matrix_ks)
354 CALL dbcsr_multiply(
"N",
"N", t, matrix_ks(ispin)%matrix, s_minus_half, zero, tmp, &
355 filter_eps=rtp%filter_eps)
356 CALL dbcsr_multiply(
"N",
"N", one, s_minus_half, tmp, zero, tmp2, &
357 filter_eps=rtp%filter_eps)
358 CALL arnoldi_extremal(tmp2, max_ev, min_ev, threshold=rtp%lanzcos_threshold, &
359 max_iter=rtp%lanzcos_max_iter, converged=converged)
360 norm2 = 2.0_dp*max(abs(min_ev), abs(max_ev))
362 rtp_control%eps_exp, method, emd)
370 CALL timestop(handle)
372 END SUBROUTINE get_maxabs_eigval_sparse
383 SUBROUTINE backtransform_matrix(Eval, eigenvec, matrix)
385 REAL(
dp),
DIMENSION(:),
INTENT(in) :: eval
386 TYPE(
cp_fm_type),
INTENT(IN) :: eigenvec, matrix
388 CHARACTER(len=*),
PARAMETER :: routinen =
'backtransform_matrix'
389 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
391 INTEGER :: handle, i, j, l, ncol_local, ndim, &
393 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
396 CALL timeset(routinen, handle)
398 matrix_struct=matrix%matrix_struct, &
400 CALL cp_fm_get_info(matrix, nrow_local=nrow_local, ncol_local=ncol_local, &
401 row_indices=row_indices, col_indices=col_indices)
403 ndim = matrix%matrix_struct%nrow_global
409 tmp%local_data(j, i) = eigenvec%local_data(j, i)*eval(l)
412 CALL parallel_gemm(
"N",
"T", ndim, ndim, ndim, one, tmp, eigenvec, zero, &
416 CALL timestop(handle)
418 END SUBROUTINE backtransform_matrix
435 TYPE(
cp_fm_type),
DIMENSION(:),
OPTIONAL,
POINTER :: mos_old
437 INTEGER :: im, ispin, ncol, re
438 REAL(kind=
dp) :: alpha
440 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_new, rho_old
442 CALL get_rtp(rtp=rtp, rho_old=rho_old, rho_new=rho_new)
444 IF (
PRESENT(mos_old))
THEN
446 DO ispin = 1,
SIZE(mos_old)/2
447 re = 2*ispin - 1; im = 2*ispin
448 CALL dbcsr_set(rho_old(re)%matrix, 0.0_dp)
451 matrix_struct=mos(ispin)%mo_coeff%matrix_struct, &
455 IF (mos(ispin)%uniform_occupation)
THEN
456 alpha = 3.0_dp - real(
SIZE(mos_old)/2,
dp)
461 alpha=alpha, keep_sparsity=.false.)
466 matrix_v=mos_old(re), &
469 alpha=alpha, keep_sparsity=.false.)
474 IF (mos(ispin)%uniform_occupation)
THEN
475 alpha = 3.0_dp - real(
SIZE(mos_old)/2,
dp)
480 alpha=alpha, keep_sparsity=.false.)
485 matrix_v=mos_old(im), &
488 alpha=alpha, keep_sparsity=.false.)
491 CALL dbcsr_copy(rho_new(re)%matrix, rho_old(re)%matrix)
495 matrix_struct=mos(ispin)%mo_coeff%matrix_struct, &
497 alpha = 3.0_dp - real(
SIZE(mos_old)/2,
dp)
503 matrix_v=mos_occ_im, &
506 alpha=2.0_dp*alpha, &
507 symmetry_mode=-1, keep_sparsity=.false.)
510 CALL dbcsr_copy(rho_new(im)%matrix, rho_old(im)%matrix)
517 DO ispin = 1,
SIZE(mos)
519 CALL dbcsr_set(rho_old(re)%matrix, 0.0_dp)
523 matrix_struct=mos(ispin)%mo_coeff%matrix_struct, &
526 IF (mos(ispin)%uniform_occupation)
THEN
527 alpha = 3.0_dp - real(
SIZE(mos),
dp)
532 alpha=alpha, keep_sparsity=.false.)
537 matrix_v=mos(ispin)%mo_coeff, &
540 alpha=alpha, keep_sparsity=.false.)
543 CALL dbcsr_copy(rho_new(re)%matrix, rho_old(re)%matrix)
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...
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, first_row, last_row, first_column, last_column, first_k, last_k, retain_sparsity, filter_eps, flop)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_set(matrix, alpha)
...
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_uplo_to_full(matrix, work, uplo)
given a triangular matrix according to uplo, 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_create(matrix, matrix_struct, name, use_sp, set_zero)
creates a new full matrix with the given structure
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
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, iounit)
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_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, 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, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_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, harris_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, eeq, rhs, do_rixs, tb_tblite)
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...
type of a logger, at the moment it contains just a print level starting at which level it should be l...