18 deallocate_arnoldi_env,&
19 get_selected_ritz_val,&
50#include "./base/base_uses.f90"
56 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'preconditioner_solvers'
71 INTEGER :: my_solver_type
73 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: matrix_s
76 REAL(
dp) :: occ_matrix
80 SELECT CASE (my_solver_type)
85 CALL make_full_inverse_cholesky(preconditioner_env, matrix_s)
90 CALL make_full_fact_cholesky(preconditioner_env, matrix_s)
96 IF (
ASSOCIATED(preconditioner_env%sparse_matrix))
THEN
97 IF (preconditioner_env%condition_num < 0.0_dp)
THEN
98 CALL estimate_cond_num(preconditioner_env%sparse_matrix, preconditioner_env%condition_num)
101 1.0_dp/preconditioner_env%condition_num*0.01_dp)
107 CALL make_full_inverse_cholesky(preconditioner_env, matrix_s)
110 CALL make_inverse_update(preconditioner_env, matrix_h)
114 cpabort(
"PRECOND_SOLVER CHEBYSHEV currently requires PRECONDITIONER FULL_KINETIC")
117 cpassert(
ASSOCIATED(preconditioner_env%sparse_matrix))
118 CALL estimate_cond_num(preconditioner_env%sparse_matrix, preconditioner_env%condition_num, &
119 max_eigenvalue=preconditioner_env%polynomial_max, &
120 min_eigenvalue=preconditioner_env%polynomial_min)
124 preconditioner_env%polynomial_min = 0.5_dp*preconditioner_env%polynomial_min
125 preconditioner_env%polynomial_max = &
127 IF (preconditioner_env%polynomial_min <= sqrt(epsilon(1.0_dp)) .OR. &
128 preconditioner_env%polynomial_max <= preconditioner_env%polynomial_min)
THEN
129 cpwarn(
"Invalid Chebyshev bounds; using Cholesky inverse")
131 CALL make_full_inverse_cholesky(preconditioner_env, matrix_s)
135 preconditioner_env%para_env, preconditioner_env%ctxt)
141 cpabort(
"Doesn't know this type of solver")
151 SUBROUTINE make_full_inverse_cholesky(preconditioner_env, matrix_s)
154 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: matrix_s
156 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_inverse_cholesky'
158 INTEGER :: handle, info
162 CALL timeset(routinen, handle)
167 preconditioner_env%para_env, preconditioner_env%ctxt)
168 fm => preconditioner_env%fm
170 CALL cp_fm_create(fm_work, fm%matrix_struct, name=
"fm_work")
180 IF (
PRESENT(matrix_s))
THEN
192 CALL timestop(handle)
194 END SUBROUTINE make_full_inverse_cholesky
202 SUBROUTINE make_full_fact_cholesky(preconditioner_env, matrix_s)
205 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: matrix_s
207 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_fact_cholesky'
209 INTEGER :: handle, info_out
212 CALL timeset(routinen, handle)
217 preconditioner_env%para_env, preconditioner_env%ctxt)
219 fm => preconditioner_env%fm
225 IF (info_out /= 0)
THEN
228 IF (
PRESENT(matrix_s))
THEN
236 CALL timestop(handle)
238 END SUBROUTINE make_full_fact_cholesky
245 SUBROUTINE make_inverse_update(preconditioner_env, matrix_h)
249 CHARACTER(len=*),
PARAMETER :: routinen =
'make_inverse_update'
253 REAL(kind=
dp) :: filter_eps
255 CALL timeset(routinen, handle)
265 IF (.NOT.
ASSOCIATED(preconditioner_env%dbcsr_matrix))
THEN
268 CALL dbcsr_create(preconditioner_env%dbcsr_matrix,
"prec_dbcsr", &
269 template=matrix_h, matrix_type=dbcsr_type_no_symmetry)
273 filter_eps = 1.0_dp/preconditioner_env%condition_num*0.1_dp
276 CALL dbcsr_filter(preconditioner_env%dbcsr_matrix, filter_eps*100.0_dp)
278 CALL invert_hotelling(preconditioner_env%dbcsr_matrix, preconditioner_env%sparse_matrix, filter_eps*10.0_dp, &
279 use_inv_as_guess=use_guess, norm_convergence=0.4_dp, filter_eps=filter_eps)
281 CALL timestop(handle)
283 END SUBROUTINE make_inverse_update
293 SUBROUTINE estimate_cond_num(matrix, cond_num, max_eigenvalue, min_eigenvalue)
295 REAL(kind=
dp) :: cond_num
296 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: max_eigenvalue, min_eigenvalue
298 CHARACTER(len=*),
PARAMETER :: routinen =
'estimate_cond_num'
301 REAL(kind=
dp) :: max_ev, min_ev
302 TYPE(arnoldi_env_type) :: arnoldi_env
305 CALL timeset(routinen, handle)
308 ALLOCATE (matrices(1))
309 matrices(1)%matrix => matrix
311 CALL setup_arnoldi_env(arnoldi_env, matrices, max_iter=20, threshold=5.0e-4_dp, selection_crit=2, &
312 nval_request=1, nrestarts=15, generalized_ev=.false., iram=.false.)
314 max_ev = real(get_selected_ritz_val(arnoldi_env, 1),
dp)
315 CALL deallocate_arnoldi_env(arnoldi_env)
317 CALL setup_arnoldi_env(arnoldi_env, matrices, max_iter=20, threshold=5.0e-4_dp, selection_crit=3, &
318 nval_request=1, nrestarts=15, generalized_ev=.false., iram=.false.)
320 min_ev = real(get_selected_ritz_val(arnoldi_env, 1),
dp)
321 CALL deallocate_arnoldi_env(arnoldi_env)
323 cond_num = max_ev/min_ev
324 IF (
PRESENT(max_eigenvalue)) max_eigenvalue = max_ev
325 IF (
PRESENT(min_eigenvalue)) min_eigenvalue = min_ev
326 DEALLOCATE (matrices)
328 CALL timestop(handle)
329 END SUBROUTINE estimate_cond_num
340 TYPE(
dbcsr_type),
POINTER :: dbcsr_matrix, template_mat
342 CHARACTER(len=*),
PARAMETER :: routinen =
'transfer_fm_to_dbcsr'
346 CALL timeset(routinen, handle)
347 IF (
ASSOCIATED(fm_matrix))
THEN
348 IF (.NOT.
ASSOCIATED(dbcsr_matrix))
THEN
350 CALL dbcsr_create(dbcsr_matrix, template=template_mat, &
351 name=
"preconditioner_env%dbcsr_matrix", &
352 matrix_type=dbcsr_type_no_symmetry)
356 DEALLOCATE (fm_matrix)
360 CALL timestop(handle)
378 CHARACTER(len=*),
PARAMETER :: routinen =
'transfer_dbcsr_to_fm'
383 CALL timeset(routinen, handle)
384 IF (
ASSOCIATED(dbcsr_matrix))
THEN
385 NULLIFY (fm_struct_tmp)
387 IF (
ASSOCIATED(fm_matrix))
THEN
389 DEALLOCATE (fm_matrix)
394 context=context, para_env=para_env)
401 DEALLOCATE (dbcsr_matrix)
404 CALL timestop(handle)
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...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public schiffmann2015
methods related to the blacs parallel environment
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_init_p(matrix)
...
subroutine, public dbcsr_filter(matrix, eps)
...
real(kind=dp) function, public dbcsr_get_occupation(matrix)
...
subroutine, public dbcsr_release(matrix)
...
real(dp) function, public dbcsr_gershgorin_norm(matrix)
Compute the gershgorin norm of a dbcsr matrix.
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan)
Copy a DBCSR matrix to a BLACS matrix.
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_uplo_to_full(matrix, work, uplo)
given a triangular matrix according to uplo, computes the corresponding full matrix
various cholesky decomposition related routines
subroutine, public cp_fm_cholesky_invert(matrix, n, info_out)
used to replace the cholesky decomposition by the inverse
subroutine, public cp_fm_cholesky_decompose(matrix, n, info_out)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
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_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
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, nrow, ncol, set_zero)
creates a new full matrix with the given structure
Routines useful for iterative matrix calculations.
subroutine, public invert_hotelling(matrix_inverse, matrix, threshold, use_inv_as_guess, norm_convergence, filter_eps, accelerator_order, max_iter_lanczos, eps_lanczos, silent)
invert a symmetric positive definite matrix by Hotelling's method explicit symmetrization makes this ...
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
solves the preconditioner, contains to utility function for fm<->dbcsr transfers, should be moved soo...
subroutine, public transfer_dbcsr_to_fm(dbcsr_matrix, fm_matrix, para_env, context)
transfers a dbcsr to a full matrix
subroutine, public solve_preconditioner(my_solver_type, preconditioner_env, matrix_s, matrix_h)
...
subroutine, public transfer_fm_to_dbcsr(fm_matrix, dbcsr_matrix, template_mat)
transfers a full matrix to a dbcsr
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
stores all the informations relevant to an mpi environment