46#include "../base/base_uses.f90"
52 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'arnoldi_api'
76 IF (control%generalized_ev)
THEN
77 CALL arnoldi_generalized_ev(matrix, arnoldi_env)
79 CALL arnoldi_normal_ev(matrix, arnoldi_env)
99 SUBROUTINE arnoldi_normal_ev(matrix, arnoldi_env)
103 CHARACTER(LEN=*),
PARAMETER :: routinen =
'arnoldi_normal_ev'
105 INTEGER :: handle, i_loop, ncol_local, nrow_local
110 NULLIFY (restart_vec)
111 CALL timeset(routinen, handle)
115 CALL dbcsr_copy(vectors%result_vec, vectors%input_vec)
121 CALL dbcsr_get_info(matrix=vectors%input_vec, nfullrows_local=nrow_local, nfullcols_local=ncol_local)
122 control%local_comp = ncol_local > 0 .AND. nrow_local > 0
126 IF (.NOT. control%iram .OR. i_loop == 0)
THEN
145 IF (.NOT.
ASSOCIATED(restart_vec))
ALLOCATE (restart_vec)
149 IF (control%converged)
EXIT
158 DEALLOCATE (restart_vec)
159 CALL timestop(handle)
161 END SUBROUTINE arnoldi_normal_ev
179 SUBROUTINE arnoldi_generalized_ev(matrix, arnoldi_env)
183 CHARACTER(LEN=*),
PARAMETER :: routinen =
'arnoldi_generalized_ev'
185 INTEGER :: handle, i_loop, ncol_local, nrow_local
187 TYPE(
dbcsr_p_type),
ALLOCATABLE,
DIMENSION(:) :: matrix_arnoldi
191 CALL timeset(routinen, handle)
192 ALLOCATE (matrix_arnoldi(2))
194 matrix_arnoldi(1)%matrix => a_rho_b
195 matrix_arnoldi(2)%matrix => matrix(2)%matrix
199 CALL dbcsr_copy(vectors%result_vec, vectors%input_vec)
205 CALL dbcsr_get_info(matrix=vectors%input_vec, nfullrows_local=nrow_local, nfullcols_local=ncol_local)
206 control%local_comp = ncol_local > 0 .AND. nrow_local > 0
209 IF (i_loop == 0)
THEN
227 IF (control%converged)
EXIT
236 DEALLOCATE (matrix_arnoldi)
238 CALL timestop(handle)
240 END SUBROUTINE arnoldi_generalized_ev
254 TYPE(
dbcsr_type),
INTENT(INOUT),
TARGET :: matrix_a
255 REAL(kind=
dp),
INTENT(OUT) :: max_ev, min_ev
256 LOGICAL,
INTENT(OUT) :: converged
257 REAL(kind=
dp),
INTENT(IN) :: threshold
258 INTEGER,
INTENT(IN) :: max_iter
260 CHARACTER(LEN=*),
PARAMETER :: routinen =
'arnoldi_extremal'
262 INTEGER :: handle, max_iter_internal, nrestarts
264 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: arnoldi_matrices
266 CALL timeset(routinen, handle)
270 IF (.true.) max_iter_internal = 16
271 IF (threshold <= 1.0e-3_dp) max_iter_internal = 32
272 IF (threshold <= 1.0e-4_dp) max_iter_internal = 64
275 nrestarts = max_iter/max_iter_internal
277 ALLOCATE (arnoldi_matrices(1))
278 arnoldi_matrices(1)%matrix => matrix_a
279 CALL setup_arnoldi_env(arnoldi_env, arnoldi_matrices, max_iter=max_iter_internal, &
280 threshold=threshold, selection_crit=1, nval_request=2, nrestarts=nrestarts, &
281 generalized_ev=.false., iram=.true.)
282 CALL arnoldi_ev(arnoldi_matrices, arnoldi_env)
287 DEALLOCATE (arnoldi_matrices)
289 CALL timestop(handle)
303 TYPE(
dbcsr_type),
INTENT(IN),
TARGET :: matrix_a
304 REAL(kind=
dp),
DIMENSION(:),
INTENT(INOUT) :: vec_x
305 TYPE(
dbcsr_type),
INTENT(IN),
OPTIONAL,
TARGET :: matrix_p
306 LOGICAL,
INTENT(OUT) :: converged
307 REAL(kind=
dp),
INTENT(IN) :: threshold
308 INTEGER,
INTENT(IN) :: max_iter
310 CHARACTER(LEN=*),
PARAMETER :: routinen =
'arnoldi_conjugate_gradient'
312 INTEGER :: handle, i, j, nb, nloc, no
313 INTEGER,
DIMENSION(:),
POINTER :: rb_offset, rb_size
314 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xvec
318 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: arnoldi_matrices
322 CALL timeset(routinen, handle)
327 CALL dbcsr_copy(vectors%result_vec, vectors%input_vec)
333 CALL dbcsr_get_info(x, nfullrows_local=nloc, row_blk_size=rb_size, row_blk_offset=rb_offset)
340 xvec(1:nb, 1) = vec_x(no:no + nb - 1)
345 ALLOCATE (arnoldi_matrices(3))
346 arnoldi_matrices(1)%matrix => matrix_a
347 IF (
PRESENT(matrix_p))
THEN
348 arnoldi_matrices(2)%matrix => matrix_p
350 NULLIFY (arnoldi_matrices(2)%matrix)
352 arnoldi_matrices(3)%matrix => x
354 threshold=threshold, selection_crit=1, nval_request=1, nrestarts=0, &
355 generalized_ev=.false., iram=.false.)
357 CALL conjugate_gradient(arnoldi_env, arnoldi_matrices, vectors)
367 vec_x(no:no + nb - 1) = xvec(1:nb, 1)
371 CALL control%mp_group%sum(vec_x)
380 DEALLOCATE (arnoldi_matrices)
382 CALL timestop(handle)
392 SUBROUTINE conjugate_gradient(arnoldi_env, arnoldi_matrices, vectors)
398 REAL(kind=
dp) :: alpha, beta, pap, rsnew, rsold
405 control%converged = .false.
406 pcgrp = control%pcol_group
407 mpgrp = control%mp_group
409 NULLIFY (amat, pmat, xvec)
410 amat => arnoldi_matrices(1)%matrix
411 pmat => arnoldi_matrices(2)%matrix
412 xvec => arnoldi_matrices(3)%matrix
414 IF (
ASSOCIATED(pmat))
THEN
418 0.0_dp, vectors%rep_row_vec, vectors%rep_col_vec)
422 0.0_dp, vectors%rep_row_vec, vectors%rep_col_vec)
425 CALL dbcsr_add(rvec, apvec, 1.0_dp, -1.0_dp)
429 0.0_dp, vectors%rep_row_vec, vectors%rep_col_vec)
432 rsold = vec_dot_vec(rvec, zvec, mpgrp)
433 DO iter = 1, control%max_iter
436 0.0_dp, vectors%rep_row_vec, vectors%rep_col_vec)
439 pap = vec_dot_vec(pvec, apvec, mpgrp)
440 IF (abs(pap) < 1.e-24_dp)
THEN
446 CALL dbcsr_add(xvec, pvec, 1.0_dp, alpha)
447 CALL dbcsr_add(rvec, apvec, 1.0_dp, -alpha)
448 rsnew = vec_dot_vec(rvec, rvec, mpgrp)
449 IF (sqrt(rsnew) < control%threshold)
EXIT
450 cpassert(alpha /= 0.0_dp)
454 0.0_dp, vectors%rep_row_vec, vectors%rep_col_vec)
456 rsnew = vec_dot_vec(rvec, zvec, mpgrp)
461 IF (sqrt(rsnew) < control%threshold) control%converged = .true.
472 rsold = vec_dot_vec(rvec, rvec, mpgrp)
473 DO iter = 1, control%max_iter
476 0.0_dp, vectors%rep_row_vec, vectors%rep_col_vec)
478 pap = vec_dot_vec(pvec, apvec, mpgrp)
479 IF (abs(pap) < 1.e-24_dp)
THEN
484 CALL dbcsr_add(xvec, pvec, 1.0_dp, alpha)
485 CALL dbcsr_add(rvec, apvec, 1.0_dp, -alpha)
486 rsnew = vec_dot_vec(rvec, rvec, mpgrp)
487 IF (sqrt(rsnew) < control%threshold)
EXIT
488 cpassert(alpha /= 0.0_dp)
493 IF (sqrt(rsnew) < control%threshold) control%converged = .true.
499 END SUBROUTINE conjugate_gradient
508 FUNCTION vec_dot_vec(avec, bvec, mpgrp)
RESULT(adotb)
511 REAL(kind=
dp) :: adotb
515 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: av, bv
523 IF (found .AND.
SIZE(bv) > 0)
THEN
524 adotb = adotb + dot_product(av(:, 1), bv(:, 1))
528 CALL mpgrp%sum(adotb)
530 END FUNCTION vec_dot_vec
arnoldi iteration using dbcsr
subroutine, public arnoldi_ev(matrix, arnoldi_env)
Driver routine for different arnoldi eigenvalue methods the selection which one is to be taken is mad...
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...
subroutine, public arnoldi_conjugate_gradient(matrix_a, vec_x, matrix_p, converged, threshold, max_iter)
Wrapper for conjugated gradient algorithm for Ax=b.
The methods which allow to analyze and manipulate the arnoldi procedure The main routine and this sho...
subroutine, public deallocate_arnoldi_env(arnoldi_env)
Deallocate the data in arnoldi_env.
integer function, public get_nrestart(arnoldi_env)
returns the number of restarts allowed for arnoldi
logical function, public arnoldi_is_converged(arnoldi_env)
Find out whether the method with the current search criterion is converged.
subroutine, public get_selected_ritz_vector(arnoldi_env, ind, matrix, vector)
...
subroutine, public select_evals(arnoldi_env)
perform the selection of eigenvalues, fills the selected_ind array
subroutine, public setup_arnoldi_env(arnoldi_env, matrix, max_iter, threshold, selection_crit, nval_request, nrestarts, generalized_ev, iram)
This routine sets the environment for the arnoldi iteration and the krylov subspace creation....
subroutine, public set_arnoldi_initial_vector(arnoldi_env, vector)
...
complex(dp) function, public get_selected_ritz_val(arnoldi_env, ind)
get a single specific Ritz value from the set of selected
methods for arnoldi iteration
subroutine, public compute_evals(arnoldi_env)
Call the correct eigensolver, in the arnoldi method only the right eigenvectors are used....
subroutine, public arnoldi_init(matrix, vectors, arnoldi_env)
Interface for the initialization of the arnoldi subspace creation currently it can only setup a rando...
subroutine, public arnoldi_iram(arnoldi_env)
Alogorithm for the implicit restarts in the arnoldi method this is an early implementation which scal...
subroutine, public gev_build_subspace(matrix, vectors, arnoldi_env)
builds the basis rothogonal wrt. the metric. The structure looks similar to normal arnoldi but norms,...
subroutine, public gev_update_data(matrix, matrix_arnoldi, vectors, arnoldi_env)
Updates all data after an inner loop of the generalized ev arnoldi. Updates rho and C=A-rho*B accordi...
subroutine, public gev_arnoldi_init(matrix, matrix_arnoldi, vectors, arnoldi_env)
Computes the initial guess for the solution of the generalized eigenvalue using the arnoldi method.
subroutine, public build_subspace(matrix, vectors, arnoldi_env)
Here we create the Krylov subspace and fill the Hessenberg matrix convergence check is only performed...
collection of types used in arnoldi
type(arnoldi_control_type) function, pointer, public get_control(arnoldi_env)
...
operations for skinny matrices/vectors expressed in dbcsr form
subroutine, public create_replicated_col_vec_from_matrix(dbcsr_vec, matrix, ncol)
creates a col vector like object whose blocks can be replicated along the processor row and has the s...
subroutine, public create_col_vec_from_matrix(dbcsr_vec, matrix, ncol)
creates a dbcsr col vector like object which lives on proc_col 0 and has the same row dist as the tem...
subroutine, public create_replicated_row_vec_from_matrix(dbcsr_vec, matrix, nrow)
creates a row vector like object whose blocks can be replicated along the processor col and has the s...
subroutine, public dbcsr_matrix_colvec_multiply(matrix, vec_in, vec_out, alpha, beta, work_row, work_col)
the real driver routine for the multiply, not all symmetries implemented yet
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.