23#include "./base/base_uses.f90"
29 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'ls_matrix_exp'
64 B_re, B_im, beta, C_re, C_im, filter_eps)
65 CHARACTER(LEN=1),
INTENT(IN) :: transa, transb
66 REAL(kind=
dp),
INTENT(IN) :: alpha
67 TYPE(
dbcsr_type),
INTENT(IN) :: a_re, a_im, b_re, b_im
68 REAL(kind=
dp),
INTENT(IN) :: beta
70 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: filter_eps
72 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_complex_dbcsr_gemm_3'
73 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
75 CHARACTER(LEN=1) :: transa2, transb2
77 REAL(kind=
dp) :: alpha2, alpha3, alpha4
78 TYPE(
dbcsr_type),
POINTER :: a_plus_b, ac, bd, c_plus_d
80 CALL timeset(routinen, handle)
89 IF (transa ==
"C")
THEN
96 IF (transb ==
"C")
THEN
113 CALL dbcsr_create(a_plus_b, template=a_re, matrix_type=
"N")
116 CALL dbcsr_create(c_plus_d, template=a_re, matrix_type=
"N")
119 CALL dbcsr_multiply(transa2, transb2, alpha, a_re, b_re, zero, ac, filter_eps=filter_eps)
120 CALL dbcsr_multiply(transa2, transb2, alpha2, a_im, b_im, zero, bd, filter_eps=filter_eps)
122 CALL dbcsr_add(a_plus_b, a_re, zero, alpha)
123 CALL dbcsr_add(a_plus_b, a_im, one, alpha3)
124 CALL dbcsr_add(c_plus_d, b_re, zero, alpha)
125 CALL dbcsr_add(c_plus_d, b_im, one, alpha4)
129 CALL dbcsr_multiply(transa2, transb2, one/alpha, a_plus_b, c_plus_d, beta, c_im, filter_eps=filter_eps)
148 CALL timestop(handle)
165 INTEGER,
INTENT(in) :: nsquare, ntaylor
166 REAL(kind=
dp),
INTENT(in) :: filter_eps
168 CHARACTER(len=*),
PARAMETER :: routinen =
'taylor_only_imaginary_dbcsr'
169 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
171 INTEGER :: handle, i, nloop
172 REAL(kind=
dp) :: square_fac, tfac, tmp
173 TYPE(
dbcsr_type),
POINTER :: t1, t2, tres_im, tres_re
175 CALL timeset(routinen, handle)
178 square_fac = 1.0_dp/(2.0_dp**real(nsquare,
dp))
183 CALL dbcsr_create(t1, template=im_matrix, matrix_type=
"N")
186 CALL dbcsr_create(t2, template=im_matrix, matrix_type=
"N")
189 CALL dbcsr_create(tres_re, template=im_matrix, matrix_type=
"N")
192 CALL dbcsr_create(tres_im, template=im_matrix, matrix_type=
"N")
201 nloop = ceiling(real(ntaylor,
dp)/2.0_dp)
208 t2, filter_eps=filter_eps)
210 IF (mod(i, 2) == 0) tfac = -tfac
215 t1, filter_eps=filter_eps)
217 IF (mod(i, 2) == 1) tfac = -tfac
222 IF (nsquare .GT. 0)
THEN
225 tres_re, tres_im, zero, exp_h(1)%matrix, exp_h(2)%matrix, &
226 filter_eps=filter_eps)
239 CALL timestop(handle)
259 INTEGER,
INTENT(in) :: nsquare, ntaylor
260 REAL(kind=
dp),
INTENT(in) :: filter_eps
262 CHARACTER(len=*),
PARAMETER :: routinen =
'taylor_full_complex_dbcsr'
265 REAL(kind=
dp) :: square_fac
266 TYPE(
dbcsr_type) :: t1_im, t1_re, t2_im, t2_re
269 CALL timeset(routinen, handle)
272 tres_re => exp_h(1)%matrix
273 tres_im => exp_h(2)%matrix
276 square_fac = 1.0_dp/real(2**nsquare,
dp)
279 CALL dbcsr_create(t1_re, template=re_part, matrix_type=
"N")
280 CALL dbcsr_create(t1_im, template=re_part, matrix_type=
"N")
281 CALL dbcsr_create(t2_re, template=re_part, matrix_type=
"N")
282 CALL dbcsr_create(t2_im, template=re_part, matrix_type=
"N")
303 a_re=t1_re, a_im=t1_im, &
304 b_re=re_part, b_im=im_part, &
305 c_re=t2_re, c_im=t2_im, filter_eps=filter_eps)
308 CALL dbcsr_add(tres_re, t2_re, 1.0_dp, 1.0_dp)
309 CALL dbcsr_add(tres_im, t2_im, 1.0_dp, 1.0_dp)
316 IF (nsquare .GT. 0)
THEN
320 a_re=tres_re, a_im=tres_im, &
321 b_re=tres_re, b_im=tres_im, &
322 c_re=t2_re, c_im=t2_im, filter_eps=filter_eps)
335 CALL timestop(handle)
351 TYPE(
dbcsr_type),
POINTER :: propagator, density_re, density_im
352 REAL(kind=
dp),
INTENT(in) :: filter_eps, filter_eps_small, eps_exp
354 CHARACTER(len=*),
PARAMETER :: routinen =
'bch_expansion_imaginary_propagator'
355 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
357 INTEGER :: handle, i, unit_nr
358 LOGICAL :: convergence
359 REAL(kind=
dp) :: alpha, max_alpha, prefac
360 TYPE(
dbcsr_type),
POINTER :: comm, comm2, tmp, tmp2
362 CALL timeset(routinen, handle)
382 convergence = .false.
385 CALL dbcsr_multiply(
"N",
"N", -prefac, propagator, tmp2, zero, comm, &
386 filter_eps=filter_eps_small)
387 CALL dbcsr_multiply(
"N",
"N", prefac, propagator, tmp, zero, comm2, &
388 filter_eps=filter_eps_small)
393 CALL dbcsr_add(density_re, comm, one, one)
394 CALL dbcsr_add(density_im, comm2, one, one)
400 IF (alpha > max_alpha) max_alpha = alpha
402 IF (alpha > max_alpha) max_alpha = alpha
403 IF (max_alpha < eps_exp) convergence = .true.
404 IF (convergence)
THEN
405 IF (unit_nr > 0)
WRITE (unit=unit_nr, fmt=
"((T3,A,I2,A))") &
406 "BCH converged after ", i,
" steps"
414 cpwarn_if(.NOT. convergence,
"BCH method did not converge")
421 CALL timestop(handle)
438 filter_eps, filter_eps_small, eps_exp)
439 TYPE(
dbcsr_type),
POINTER :: propagator_re, propagator_im, &
440 density_re, density_im
441 REAL(kind=
dp),
INTENT(in) :: filter_eps, filter_eps_small, eps_exp
443 CHARACTER(len=*),
PARAMETER :: routinen =
'bch_expansion_complex_propagator'
444 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
446 INTEGER :: handle, i, unit_nr
447 LOGICAL :: convergence
448 REAL(kind=
dp) :: alpha, max_alpha, prefac
449 TYPE(
dbcsr_type),
POINTER :: comm, comm2, tmp, tmp2
451 CALL timeset(routinen, handle)
471 convergence = .false.
476 tmp, tmp2, zero, comm, comm2, filter_eps=filter_eps_small)
481 CALL dbcsr_add(density_re, comm, one, one)
482 CALL dbcsr_add(density_im, comm2, one, one)
488 IF (alpha > max_alpha) max_alpha = alpha
490 IF (alpha > max_alpha) max_alpha = alpha
491 IF (max_alpha < eps_exp) convergence = .true.
492 IF (convergence)
THEN
493 IF (unit_nr > 0)
WRITE (unit=unit_nr, fmt=
"((T3,A,I2,A))") &
494 "BCH converged after ", i,
" steps"
502 cpwarn_if(.NOT. convergence,
"BCH method did not converge")
509 CALL timestop(handle)
subroutine, public dbcsr_transposed(transposed, normal, shallow_data_copy, transpose_distribution, use_distribution)
...
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)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_add_on_diag(matrix, alpha)
Adds the given scalar to the diagonal of the matrix. Reserves any missing diagonal blocks.
real(dp) function, public dbcsr_frobenius_norm(matrix)
Compute the frobenius norm of a dbcsr matrix.
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
Defines the basic variable types.
integer, parameter, public dp
Routines for calculating a complex matrix exponential with dbcsr matrices. Based on the code in matri...
subroutine, public taylor_only_imaginary_dbcsr(exp_h, im_matrix, nsquare, ntaylor, filter_eps)
specialized subroutine for purely imaginary matrix exponentials
subroutine, public bch_expansion_imaginary_propagator(propagator, density_re, density_im, filter_eps, filter_eps_small, eps_exp)
The Baker-Campbell-Hausdorff expansion for a purely imaginary exponent (e.g. rtp) Works for a non uni...
subroutine, public taylor_full_complex_dbcsr(exp_h, re_part, im_part, nsquare, ntaylor, filter_eps)
subroutine for general complex matrix exponentials on input a separate dbcsr_type for real and comple...
subroutine, public cp_complex_dbcsr_gemm_3(transa, transb, alpha, a_re, a_im, b_re, b_im, beta, c_re, c_im, filter_eps)
Convenience function. Computes the matrix multiplications needed for the multiplication of complex sp...
subroutine, public bch_expansion_complex_propagator(propagator_re, propagator_im, density_re, density_im, filter_eps, filter_eps_small, eps_exp)
The Baker-Campbell-Hausdorff expansion for a complex exponent (e.g. rtp) Works for a non unitary prop...