18 deallocate_arnoldi_data,&
19 get_selected_ritz_val,&
36 USE dbcsr_api,
ONLY: &
37 dbcsr_create, dbcsr_filter, dbcsr_get_info, dbcsr_get_occupation, dbcsr_init_p, &
38 dbcsr_p_type, dbcsr_release, dbcsr_type, dbcsr_type_no_symmetry, dbcsr_type_real_8
47 #include "./base/base_uses.f90"
53 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'preconditioner_solvers'
68 INTEGER :: my_solver_type
69 TYPE(preconditioner_type) :: preconditioner_env
70 TYPE(dbcsr_type),
OPTIONAL,
POINTER :: matrix_s
71 TYPE(dbcsr_type),
POINTER :: matrix_h
73 REAL(
dp) :: occ_matrix
77 SELECT CASE (my_solver_type)
82 CALL make_full_inverse_cholesky(preconditioner_env, matrix_s)
87 CALL make_full_fact_cholesky(preconditioner_env, matrix_s)
93 IF (
ASSOCIATED(preconditioner_env%sparse_matrix))
THEN
94 IF (preconditioner_env%condition_num < 0.0_dp) &
95 CALL estimate_cond_num(preconditioner_env%sparse_matrix, preconditioner_env%condition_num)
96 CALL dbcsr_filter(preconditioner_env%sparse_matrix, &
97 1.0_dp/preconditioner_env%condition_num*0.01_dp)
98 occ_matrix = dbcsr_get_occupation(preconditioner_env%sparse_matrix)
103 CALL make_full_inverse_cholesky(preconditioner_env, matrix_s)
106 CALL make_inverse_update(preconditioner_env, matrix_h)
112 cpabort(
"Doesn't know this type of solver")
122 SUBROUTINE make_full_inverse_cholesky(preconditioner_env, matrix_s)
124 TYPE(preconditioner_type) :: preconditioner_env
125 TYPE(dbcsr_type),
OPTIONAL,
POINTER :: matrix_s
127 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_inverse_cholesky'
129 INTEGER :: handle, info
130 TYPE(cp_fm_type) :: fm_work
131 TYPE(cp_fm_type),
POINTER :: fm
133 CALL timeset(routinen, handle)
138 preconditioner_env%para_env, preconditioner_env%ctxt)
139 fm => preconditioner_env%fm
141 CALL cp_fm_create(fm_work, fm%matrix_struct, name=
"fm_work")
151 IF (
PRESENT(matrix_s))
THEN
161 CALL cp_fm_release(fm_work)
163 CALL timestop(handle)
165 END SUBROUTINE make_full_inverse_cholesky
173 SUBROUTINE make_full_fact_cholesky(preconditioner_env, matrix_s)
175 TYPE(preconditioner_type) :: preconditioner_env
176 TYPE(dbcsr_type),
OPTIONAL,
POINTER :: matrix_s
178 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_fact_cholesky'
180 INTEGER :: handle, info_out
181 TYPE(cp_fm_type),
POINTER :: fm
183 CALL timeset(routinen, handle)
188 preconditioner_env%para_env, preconditioner_env%ctxt)
190 fm => preconditioner_env%fm
196 IF (info_out .NE. 0)
THEN
199 IF (
PRESENT(matrix_s))
THEN
207 CALL timestop(handle)
209 END SUBROUTINE make_full_fact_cholesky
216 SUBROUTINE make_inverse_update(preconditioner_env, matrix_h)
217 TYPE(preconditioner_type) :: preconditioner_env
218 TYPE(dbcsr_type),
POINTER :: matrix_h
220 CHARACTER(len=*),
PARAMETER :: routinen =
'make_inverse_update'
224 REAL(kind=
dp) :: filter_eps
226 CALL timeset(routinen, handle)
236 IF (.NOT.
ASSOCIATED(preconditioner_env%dbcsr_matrix))
THEN
238 CALL dbcsr_init_p(preconditioner_env%dbcsr_matrix)
239 CALL dbcsr_create(preconditioner_env%dbcsr_matrix,
"prec_dbcsr", &
240 template=matrix_h, matrix_type=dbcsr_type_no_symmetry)
244 filter_eps = 1.0_dp/preconditioner_env%condition_num*0.1_dp
247 CALL dbcsr_filter(preconditioner_env%dbcsr_matrix, filter_eps*100.0_dp)
249 CALL invert_hotelling(preconditioner_env%dbcsr_matrix, preconditioner_env%sparse_matrix, filter_eps*10.0_dp, &
250 use_inv_as_guess=use_guess, norm_convergence=0.4_dp, filter_eps=filter_eps)
252 CALL timestop(handle)
254 END SUBROUTINE make_inverse_update
262 SUBROUTINE estimate_cond_num(matrix, cond_num)
263 TYPE(dbcsr_type),
POINTER :: matrix
264 REAL(kind=
dp) :: cond_num
266 CHARACTER(len=*),
PARAMETER :: routinen =
'estimate_cond_num'
269 REAL(kind=
dp) :: max_ev, min_ev
270 TYPE(arnoldi_data_type) :: my_arnoldi
271 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrices
273 CALL timeset(routinen, handle)
276 ALLOCATE (matrices(1))
277 matrices(1)%matrix => matrix
279 CALL setup_arnoldi_data(my_arnoldi, matrices, max_iter=20, threshold=5.0e-4_dp, selection_crit=2, &
280 nval_request=1, nrestarts=15, generalized_ev=.false., iram=.false.)
282 max_ev = real(get_selected_ritz_val(my_arnoldi, 1),
dp)
283 CALL deallocate_arnoldi_data(my_arnoldi)
285 CALL setup_arnoldi_data(my_arnoldi, matrices, max_iter=20, threshold=5.0e-4_dp, selection_crit=3, &
286 nval_request=1, nrestarts=15, generalized_ev=.false., iram=.false.)
288 min_ev = real(get_selected_ritz_val(my_arnoldi, 1),
dp)
289 CALL deallocate_arnoldi_data(my_arnoldi)
291 cond_num = max_ev/min_ev
292 DEALLOCATE (matrices)
294 CALL timestop(handle)
295 END SUBROUTINE estimate_cond_num
305 TYPE(cp_fm_type),
POINTER :: fm_matrix
306 TYPE(dbcsr_type),
POINTER :: dbcsr_matrix, template_mat
308 CHARACTER(len=*),
PARAMETER :: routinen =
'transfer_fm_to_dbcsr'
312 CALL timeset(routinen, handle)
313 IF (
ASSOCIATED(fm_matrix))
THEN
314 IF (.NOT.
ASSOCIATED(dbcsr_matrix))
THEN
315 CALL dbcsr_init_p(dbcsr_matrix)
316 CALL dbcsr_create(dbcsr_matrix, template=template_mat, &
317 name=
"preconditioner_env%dbcsr_matrix", &
318 matrix_type=dbcsr_type_no_symmetry, &
319 nze=0, data_type=dbcsr_type_real_8)
322 CALL cp_fm_release(fm_matrix)
323 DEALLOCATE (fm_matrix)
327 CALL timestop(handle)
340 TYPE(dbcsr_type),
POINTER :: dbcsr_matrix
341 TYPE(cp_fm_type),
POINTER :: fm_matrix
342 TYPE(mp_para_env_type),
POINTER :: para_env
343 TYPE(cp_blacs_env_type),
POINTER :: context
345 CHARACTER(len=*),
PARAMETER :: routinen =
'transfer_dbcsr_to_fm'
348 TYPE(cp_fm_struct_type),
POINTER :: fm_struct_tmp
350 CALL timeset(routinen, handle)
351 IF (
ASSOCIATED(dbcsr_matrix))
THEN
352 NULLIFY (fm_struct_tmp)
354 IF (
ASSOCIATED(fm_matrix))
THEN
355 CALL cp_fm_release(fm_matrix)
356 DEALLOCATE (fm_matrix)
359 CALL dbcsr_get_info(dbcsr_matrix, nfullrows_total=n)
361 context=context, para_env=para_env)
367 CALL dbcsr_release(dbcsr_matrix)
368 DEALLOCATE (dbcsr_matrix)
371 CALL timestop(handle)
arnoldi iteration using dbcsr
subroutine, public arnoldi_ev(matrix, arnoldi_data)
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
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
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_upper_to_full(matrix, work)
given an upper triangular matrix 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, use_sp)
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