18 deallocate_arnoldi_data,&
19 get_selected_ritz_val,&
20 get_selected_ritz_vector,&
21 set_arnoldi_initial_vector,&
44 USE dbcsr_api,
ONLY: &
45 dbcsr_add, dbcsr_add_on_diag, dbcsr_copy, dbcsr_create, dbcsr_get_info, dbcsr_multiply, &
46 dbcsr_p_type, dbcsr_release, dbcsr_type, dbcsr_type_symmetric
54 #include "./base/base_uses.f90"
60 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'preconditioner_makes'
79 energy_homo, eigenvalues_ot, energy_gap, &
81 TYPE(preconditioner_type) :: preconditioner_env
82 TYPE(dbcsr_type),
POINTER :: matrix_h
83 TYPE(dbcsr_type),
OPTIONAL,
POINTER :: matrix_s, matrix_t
84 TYPE(cp_fm_type),
INTENT(IN) :: mo_coeff
85 REAL(kind=
dp) :: energy_homo
86 REAL(kind=
dp),
DIMENSION(:) :: eigenvalues_ot
87 REAL(kind=
dp) :: energy_gap
88 INTEGER :: my_solver_type
90 INTEGER :: precon_type
92 precon_type = preconditioner_env%in_use
93 SELECT CASE (precon_type)
96 cpabort(
"Only PRECOND_SOLVER DEFAULT for the moment")
97 IF (
PRESENT(matrix_s))
THEN
98 CALL make_full_single(preconditioner_env, preconditioner_env%fm, &
99 matrix_h, matrix_s, energy_homo, energy_gap)
101 CALL make_full_single_ortho(preconditioner_env, preconditioner_env%fm, &
102 matrix_h, energy_homo, energy_gap)
107 IF (.NOT.
PRESENT(matrix_s)) &
108 cpabort(
"Type for S=1 not implemented")
109 CALL make_full_s_inverse(preconditioner_env, matrix_s)
113 IF (.NOT. (
PRESENT(matrix_s) .AND.
PRESENT(matrix_t))) &
114 cpabort(
"Type for S=1 not implemented")
115 CALL make_full_kinetic(preconditioner_env, matrix_t, matrix_s, energy_gap)
118 CALL make_full_single_inverse(preconditioner_env, mo_coeff, matrix_h, energy_gap, &
122 cpabort(
"Only PRECOND_SOLVER DEFAULT for the moment")
124 IF (
PRESENT(matrix_s))
THEN
125 CALL make_full_all(preconditioner_env, mo_coeff, matrix_h, matrix_s, &
126 eigenvalues_ot, energy_gap)
128 CALL make_full_all_ortho(preconditioner_env, mo_coeff, matrix_h, &
129 eigenvalues_ot, energy_gap)
133 cpabort(
"Type not implemented")
143 SUBROUTINE make_full_s_inverse(preconditioner_env, matrix_s)
144 TYPE(preconditioner_type) :: preconditioner_env
145 TYPE(dbcsr_type),
POINTER :: matrix_s
147 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_s_inverse'
151 CALL timeset(routinen, handle)
153 cpassert(
ASSOCIATED(matrix_s))
155 IF (.NOT.
ASSOCIATED(preconditioner_env%sparse_matrix))
THEN
156 ALLOCATE (preconditioner_env%sparse_matrix)
158 CALL dbcsr_copy(preconditioner_env%sparse_matrix, matrix_s, name=
"full_kinetic")
160 CALL timestop(handle)
162 END SUBROUTINE make_full_s_inverse
172 SUBROUTINE make_full_kinetic(preconditioner_env, matrix_t, matrix_s, &
174 TYPE(preconditioner_type) :: preconditioner_env
175 TYPE(dbcsr_type),
POINTER :: matrix_t, matrix_s
176 REAL(kind=
dp) :: energy_gap
178 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_kinetic'
181 REAL(kind=
dp) :: shift
183 CALL timeset(routinen, handle)
185 cpassert(
ASSOCIATED(matrix_t))
186 cpassert(
ASSOCIATED(matrix_s))
188 IF (.NOT.
ASSOCIATED(preconditioner_env%sparse_matrix))
THEN
189 ALLOCATE (preconditioner_env%sparse_matrix)
191 CALL dbcsr_copy(preconditioner_env%sparse_matrix, matrix_t, name=
"full_kinetic")
193 shift = max(0.0_dp, energy_gap)
195 CALL dbcsr_add(preconditioner_env%sparse_matrix, matrix_s, &
196 alpha_scalar=1.0_dp, beta_scalar=shift)
198 CALL timestop(handle)
200 END SUBROUTINE make_full_kinetic
211 SUBROUTINE make_full_single(preconditioner_env, fm, matrix_h, matrix_s, &
212 energy_homo, energy_gap)
213 TYPE(preconditioner_type) :: preconditioner_env
214 TYPE(cp_fm_type),
POINTER :: fm
215 TYPE(dbcsr_type),
POINTER :: matrix_h, matrix_s
216 REAL(kind=
dp) :: energy_homo, energy_gap
218 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_single'
220 INTEGER :: handle, i, n
221 REAL(kind=
dp),
DIMENSION(:),
POINTER :: evals
222 TYPE(cp_fm_struct_type),
POINTER :: fm_struct_tmp
223 TYPE(cp_fm_type) :: fm_h, fm_s
225 CALL timeset(routinen, handle)
227 NULLIFY (fm_struct_tmp, evals)
229 IF (
ASSOCIATED(fm))
THEN
230 CALL cp_fm_release(fm)
234 CALL dbcsr_get_info(matrix_h, nfullrows_total=n)
238 context=preconditioner_env%ctxt, &
239 para_env=preconditioner_env%para_env)
241 CALL cp_fm_create(fm, fm_struct_tmp, name=
"preconditioner")
250 SELECT CASE (preconditioner_env%cholesky_use)
257 invert_tr=.false., uplo_tr=
"U", n_rows=n, n_cols=n, alpha=1.0_dp)
259 invert_tr=.false., uplo_tr=
"U", n_rows=n, n_cols=n, alpha=1.0_dp)
263 cpabort(
"cholesky type not implemented")
268 SELECT CASE (preconditioner_env%cholesky_use)
271 invert_tr=.false., uplo_tr=
"U", n_rows=n, n_cols=n, alpha=1.0_dp)
273 evals(i) = 1.0_dp/max(evals(i) - energy_homo, energy_gap)
275 CALL cp_fm_to_fm(fm, fm_h)
279 evals(i) = 1.0_dp/max(evals(i) - energy_homo, energy_gap)
281 CALL cp_fm_to_fm(fm_h, fm)
285 CALL parallel_gemm(
'N',
'T', n, n, n, 1.0_dp, fm, fm_h, 0.0_dp, fm_s)
286 CALL cp_fm_to_fm(fm_s, fm)
289 CALL cp_fm_release(fm_h)
290 CALL cp_fm_release(fm_s)
292 CALL timestop(handle)
294 END SUBROUTINE make_full_single
304 SUBROUTINE make_full_single_ortho(preconditioner_env, fm, matrix_h, &
305 energy_homo, energy_gap)
306 TYPE(preconditioner_type) :: preconditioner_env
307 TYPE(cp_fm_type),
POINTER :: fm
308 TYPE(dbcsr_type),
POINTER :: matrix_h
309 REAL(kind=
dp) :: energy_homo, energy_gap
311 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_single_ortho'
313 INTEGER :: handle, i, n
314 REAL(kind=
dp),
DIMENSION(:),
POINTER :: evals
315 TYPE(cp_fm_struct_type),
POINTER :: fm_struct_tmp
316 TYPE(cp_fm_type) :: fm_h, fm_s
318 CALL timeset(routinen, handle)
319 NULLIFY (fm_struct_tmp, evals)
321 IF (
ASSOCIATED(fm))
THEN
322 CALL cp_fm_release(fm)
326 CALL dbcsr_get_info(matrix_h, nfullrows_total=n)
330 context=preconditioner_env%ctxt, &
331 para_env=preconditioner_env%para_env)
333 CALL cp_fm_create(fm, fm_struct_tmp, name=
"preconditioner")
342 evals(i) = 1.0_dp/max(evals(i) - energy_homo, energy_gap)
344 CALL cp_fm_to_fm(fm, fm_h)
346 CALL parallel_gemm(
'N',
'T', n, n, n, 1.0_dp, fm, fm_h, 0.0_dp, fm_s)
347 CALL cp_fm_to_fm(fm_s, fm)
350 CALL cp_fm_release(fm_h)
351 CALL cp_fm_release(fm_s)
353 CALL timestop(handle)
355 END SUBROUTINE make_full_single_ortho
376 SUBROUTINE make_full_all(preconditioner_env, matrix_c0, matrix_h, matrix_s, c0_evals, energy_gap)
377 TYPE(preconditioner_type) :: preconditioner_env
378 TYPE(cp_fm_type),
INTENT(IN) :: matrix_c0
379 TYPE(dbcsr_type),
POINTER :: matrix_h, matrix_s
380 REAL(kind=
dp),
DIMENSION(:) :: c0_evals
381 REAL(kind=
dp) :: energy_gap
383 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_all'
384 REAL(kind=
dp),
PARAMETER :: fudge_factor = 0.25_dp, &
385 lambda_base = 10.0_dp
387 INTEGER :: handle, k, n
388 REAL(kind=
dp) :: error_estimate, lambda
389 REAL(kind=
dp),
DIMENSION(:),
POINTER :: diag, norms, shifted_evals
390 TYPE(cp_fm_struct_type),
POINTER :: fm_struct_tmp
391 TYPE(cp_fm_type) :: matrix_hc0, matrix_left, matrix_s1, &
392 matrix_s2, matrix_sc0, matrix_shc0, &
394 TYPE(cp_fm_type),
POINTER :: matrix_pre
396 CALL timeset(routinen, handle)
398 IF (
ASSOCIATED(preconditioner_env%fm))
THEN
399 CALL cp_fm_release(preconditioner_env%fm)
400 DEALLOCATE (preconditioner_env%fm)
401 NULLIFY (preconditioner_env%fm)
405 context=preconditioner_env%ctxt, &
406 para_env=preconditioner_env%para_env)
407 ALLOCATE (preconditioner_env%fm)
408 CALL cp_fm_create(preconditioner_env%fm, fm_struct_tmp, name=
"preconditioner_env%fm")
410 CALL cp_fm_create(matrix_tmp, fm_struct_tmp, name=
"matrix_tmp")
412 ALLOCATE (preconditioner_env%full_evals(n))
413 ALLOCATE (preconditioner_env%occ_evals(k))
429 CALL cp_fm_create(matrix_sc0, matrix_c0%matrix_struct, name=
"sc0")
431 CALL cp_fm_create(matrix_hc0, matrix_c0%matrix_struct, name=
"hc0")
435 CALL cp_fm_create(matrix_shc0, matrix_c0%matrix_struct, name=
"shc0")
437 SELECT CASE (preconditioner_env%cholesky_use)
440 CALL cp_fm_to_fm(matrix_hc0, matrix_shc0)
442 invert_tr=.false., uplo_tr=
"U", n_rows=n, n_cols=k, alpha=1.0_dp)
446 cpabort(
"cholesky type not implemented")
449 context=preconditioner_env%ctxt, &
450 para_env=preconditioner_env%para_env)
451 CALL cp_fm_create(matrix_s1, fm_struct_tmp, name=
"matrix_s1")
454 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, matrix_shc0, matrix_shc0, 0.0_dp, matrix_s1)
457 error_estimate = maxval(sqrt(abs(diag - c0_evals**2)))
459 CALL cp_fm_release(matrix_s1)
460 CALL cp_fm_release(matrix_shc0)
465 preconditioner_env%energy_gap = max(energy_gap, error_estimate*fudge_factor)
467 matrix_pre => preconditioner_env%fm
470 CALL parallel_gemm(
'N',
'T', n, n, k, -1.0_dp, matrix_hc0, matrix_sc0, 1.0_dp, matrix_tmp)
473 context=preconditioner_env%ctxt, &
474 para_env=preconditioner_env%para_env)
475 CALL cp_fm_create(matrix_left, fm_struct_tmp, name=
"matrix_left")
477 CALL parallel_gemm(
'T',
'N', k, n, n, 1.0_dp, matrix_c0, matrix_tmp, 0.0_dp, matrix_left)
479 CALL parallel_gemm(
'N',
'N', n, n, k, -1.0_dp, matrix_sc0, matrix_left, 1.0_dp, matrix_tmp)
480 CALL cp_fm_release(matrix_left)
482 ALLOCATE (shifted_evals(k))
483 lambda = lambda_base + error_estimate
484 shifted_evals = c0_evals - lambda
485 CALL cp_fm_to_fm(matrix_sc0, matrix_hc0)
487 CALL parallel_gemm(
'N',
'T', n, n, k, 1.0_dp, matrix_hc0, matrix_sc0, 1.0_dp, matrix_tmp)
490 SELECT CASE (preconditioner_env%cholesky_use)
493 invert_tr=.false., uplo_tr=
"U", n_rows=n, n_cols=n, alpha=1.0_dp)
495 invert_tr=.false., uplo_tr=
"U", n_rows=n, n_cols=n, alpha=1.0_dp)
500 SELECT CASE (preconditioner_env%cholesky_use)
503 invert_tr=.false., uplo_tr=
"U", n_rows=n, n_cols=n, alpha=1.0_dp)
504 CALL cp_fm_to_fm(matrix_pre, matrix_tmp)
507 CALL cp_fm_to_fm(matrix_tmp, matrix_pre)
513 context=preconditioner_env%ctxt, &
514 para_env=preconditioner_env%para_env)
515 CALL cp_fm_create(matrix_s1, fm_struct_tmp, name=
"matrix_s1")
516 CALL cp_fm_create(matrix_s2, fm_struct_tmp, name=
"matrix_s2")
519 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, matrix_sc0, matrix_tmp, 0.0_dp, matrix_s1)
521 WRITE (*, *)
"matrix norm deviation (should be close to zero): ", maxval(abs(abs(norms) - 1.0_dp))
523 CALL cp_fm_release(matrix_s1)
524 CALL cp_fm_release(matrix_s2)
528 preconditioner_env%occ_evals = c0_evals
530 preconditioner_env%full_evals(1:k) = c0_evals
531 CALL cp_fm_to_fm(matrix_c0, matrix_pre, k, 1, 1)
533 CALL cp_fm_release(matrix_sc0)
534 CALL cp_fm_release(matrix_hc0)
535 CALL cp_fm_release(ortho)
536 CALL cp_fm_release(matrix_tmp)
537 DEALLOCATE (shifted_evals)
538 CALL timestop(handle)
540 END SUBROUTINE make_full_all
550 SUBROUTINE make_full_all_ortho(preconditioner_env, matrix_c0, matrix_h, c0_evals, energy_gap)
552 TYPE(preconditioner_type) :: preconditioner_env
553 TYPE(cp_fm_type),
INTENT(IN) :: matrix_c0
554 TYPE(dbcsr_type),
POINTER :: matrix_h
555 REAL(kind=
dp),
DIMENSION(:) :: c0_evals
556 REAL(kind=
dp) :: energy_gap
558 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_all_ortho'
559 REAL(kind=
dp),
PARAMETER :: fudge_factor = 0.25_dp, &
560 lambda_base = 10.0_dp
562 INTEGER :: handle, k, n
563 REAL(kind=
dp) :: error_estimate, lambda
564 REAL(kind=
dp),
DIMENSION(:),
POINTER :: diag, norms, shifted_evals
565 TYPE(cp_fm_struct_type),
POINTER :: fm_struct_tmp
566 TYPE(cp_fm_type) :: matrix_hc0, matrix_left, matrix_s1, &
567 matrix_s2, matrix_sc0, matrix_tmp
568 TYPE(cp_fm_type),
POINTER :: matrix_pre
570 CALL timeset(routinen, handle)
572 IF (
ASSOCIATED(preconditioner_env%fm))
THEN
573 CALL cp_fm_release(preconditioner_env%fm)
574 DEALLOCATE (preconditioner_env%fm)
575 NULLIFY (preconditioner_env%fm)
579 context=preconditioner_env%ctxt, &
580 para_env=preconditioner_env%para_env)
581 ALLOCATE (preconditioner_env%fm)
582 CALL cp_fm_create(preconditioner_env%fm, fm_struct_tmp, name=
"preconditioner_env%fm")
583 CALL cp_fm_create(matrix_tmp, fm_struct_tmp, name=
"matrix_tmp")
585 ALLOCATE (preconditioner_env%full_evals(n))
586 ALLOCATE (preconditioner_env%occ_evals(k))
594 CALL cp_fm_create(matrix_sc0, matrix_c0%matrix_struct, name=
"sc0")
595 CALL cp_fm_to_fm(matrix_c0, matrix_sc0)
596 CALL cp_fm_create(matrix_hc0, matrix_c0%matrix_struct, name=
"hc0")
601 context=preconditioner_env%ctxt, &
602 para_env=preconditioner_env%para_env)
603 CALL cp_fm_create(matrix_s1, fm_struct_tmp, name=
"matrix_s1")
606 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, matrix_hc0, matrix_hc0, 0.0_dp, matrix_s1)
609 error_estimate = maxval(sqrt(abs(diag - c0_evals**2)))
611 CALL cp_fm_release(matrix_s1)
616 preconditioner_env%energy_gap = max(energy_gap, error_estimate*fudge_factor)
618 matrix_pre => preconditioner_env%fm
622 CALL parallel_gemm(
'N',
'T', n, n, k, -1.0_dp, matrix_hc0, matrix_sc0, 1.0_dp, matrix_tmp)
625 context=preconditioner_env%ctxt, &
626 para_env=preconditioner_env%para_env)
627 CALL cp_fm_create(matrix_left, fm_struct_tmp, name=
"matrix_left")
629 CALL parallel_gemm(
'T',
'N', k, n, n, 1.0_dp, matrix_c0, matrix_tmp, 0.0_dp, matrix_left)
631 CALL parallel_gemm(
'N',
'N', n, n, k, -1.0_dp, matrix_sc0, matrix_left, 1.0_dp, matrix_tmp)
632 CALL cp_fm_release(matrix_left)
634 ALLOCATE (shifted_evals(k))
635 lambda = lambda_base + error_estimate
636 shifted_evals = c0_evals - lambda
637 CALL cp_fm_to_fm(matrix_sc0, matrix_hc0)
639 CALL parallel_gemm(
'N',
'T', n, n, k, 1.0_dp, matrix_hc0, matrix_sc0, 1.0_dp, matrix_tmp)
646 CALL cp_fm_to_fm(matrix_pre, matrix_tmp)
648 context=preconditioner_env%ctxt, &
649 para_env=preconditioner_env%para_env)
650 CALL cp_fm_create(matrix_s1, fm_struct_tmp, name=
"matrix_s1")
651 CALL cp_fm_create(matrix_s2, fm_struct_tmp, name=
"matrix_s2")
654 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, matrix_sc0, matrix_tmp, 0.0_dp, matrix_s1)
657 WRITE (*, *)
"matrix norm deviation (should be close to zero): ", maxval(abs(abs(norms) - 1.0_dp))
659 CALL cp_fm_release(matrix_s1)
660 CALL cp_fm_release(matrix_s2)
664 preconditioner_env%occ_evals = c0_evals
666 preconditioner_env%full_evals(1:k) = c0_evals
667 CALL cp_fm_to_fm(matrix_c0, matrix_pre, k, 1, 1)
669 CALL cp_fm_release(matrix_sc0)
670 CALL cp_fm_release(matrix_hc0)
671 CALL cp_fm_release(matrix_tmp)
672 DEALLOCATE (shifted_evals)
674 CALL timestop(handle)
676 END SUBROUTINE make_full_all_ortho
695 SUBROUTINE make_full_single_inverse(preconditioner_env, matrix_c0, matrix_h, energy_gap, matrix_s)
696 TYPE(preconditioner_type) :: preconditioner_env
697 TYPE(cp_fm_type),
INTENT(IN) :: matrix_c0
698 TYPE(dbcsr_type),
POINTER :: matrix_h
699 REAL(kind=
dp) :: energy_gap
700 TYPE(dbcsr_type),
OPTIONAL,
POINTER :: matrix_s
702 CHARACTER(len=*),
PARAMETER :: routinen =
'make_full_single_inverse'
704 INTEGER :: handle, k, n
705 REAL(kind=
dp) :: max_ev, min_ev, pre_shift
706 TYPE(arnoldi_data_type) :: my_arnoldi
707 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrices
708 TYPE(dbcsr_type),
TARGET :: dbcsr_cthc, dbcsr_hc, dbcsr_sc, mo_dbcsr
710 CALL timeset(routinen, handle)
717 CALL dbcsr_create(dbcsr_sc, template=mo_dbcsr)
718 CALL dbcsr_create(dbcsr_hc, template=mo_dbcsr)
722 IF (.NOT.
ASSOCIATED(preconditioner_env%sparse_matrix))
THEN
723 ALLOCATE (preconditioner_env%sparse_matrix)
727 CALL dbcsr_copy(preconditioner_env%sparse_matrix, matrix_h)
731 IF (
PRESENT(matrix_s))
THEN
732 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix_s, mo_dbcsr, 0.0_dp, dbcsr_sc)
734 CALL dbcsr_copy(dbcsr_sc, mo_dbcsr)
739 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix_h, mo_dbcsr, 0.0_dp, dbcsr_hc)
740 CALL dbcsr_multiply(
"T",
"N", 1.0_dp, mo_dbcsr, dbcsr_hc, 0.0_dp, dbcsr_cthc)
743 ALLOCATE (matrices(1))
744 matrices(1)%matrix => dbcsr_cthc
745 CALL setup_arnoldi_data(my_arnoldi, matrices, max_iter=20, threshold=1.0e-3_dp, selection_crit=2, &
746 nval_request=1, nrestarts=8, generalized_ev=.false., iram=.false.)
747 IF (
ASSOCIATED(preconditioner_env%max_ev_vector)) &
748 CALL set_arnoldi_initial_vector(my_arnoldi, preconditioner_env%max_ev_vector)
750 max_ev = real(get_selected_ritz_val(my_arnoldi, 1),
dp)
753 IF (.NOT.
ASSOCIATED(preconditioner_env%max_ev_vector))
ALLOCATE (preconditioner_env%max_ev_vector)
754 CALL get_selected_ritz_vector(my_arnoldi, 1, matrices(1)%matrix, preconditioner_env%max_ev_vector)
755 CALL deallocate_arnoldi_data(my_arnoldi)
756 DEALLOCATE (matrices)
759 CALL dbcsr_add_on_diag(dbcsr_cthc, -0.5_dp)
761 CALL dbcsr_multiply(
"N",
"N", 2.0_dp, dbcsr_sc, dbcsr_cthc, 0.0_dp, dbcsr_hc)
762 CALL dbcsr_multiply(
"N",
"T", -1.0_dp, dbcsr_hc, dbcsr_sc, 1.0_dp, preconditioner_env%sparse_matrix)
766 IF (
PRESENT(matrix_s))
THEN
767 ALLOCATE (matrices(2))
768 matrices(1)%matrix => preconditioner_env%sparse_matrix
769 matrices(2)%matrix => matrix_s
770 CALL setup_arnoldi_data(my_arnoldi, matrices, max_iter=20, threshold=2.0e-2_dp, selection_crit=3, &
771 nval_request=1, nrestarts=21, generalized_ev=.true., iram=.false.)
773 ALLOCATE (matrices(1))
774 matrices(1)%matrix => preconditioner_env%sparse_matrix
775 CALL setup_arnoldi_data(my_arnoldi, matrices, max_iter=20, threshold=2.0e-2_dp, selection_crit=3, &
776 nval_request=1, nrestarts=8, generalized_ev=.false., iram=.false.)
778 IF (
ASSOCIATED(preconditioner_env%min_ev_vector)) &
779 CALL set_arnoldi_initial_vector(my_arnoldi, preconditioner_env%min_ev_vector)
783 min_ev = real(get_selected_ritz_val(my_arnoldi, 1),
dp)
786 IF (.NOT.
ASSOCIATED(preconditioner_env%min_ev_vector))
ALLOCATE (preconditioner_env%min_ev_vector)
787 CALL get_selected_ritz_vector(my_arnoldi, 1, matrices(1)%matrix, preconditioner_env%min_ev_vector)
788 CALL deallocate_arnoldi_data(my_arnoldi)
789 DEALLOCATE (matrices)
794 pre_shift = max(1.5_dp*(min_ev - max_ev), energy_gap)
795 IF (min_ev .LT. pre_shift)
THEN
796 pre_shift = pre_shift - min_ev
800 IF (
PRESENT(matrix_s))
THEN
801 CALL dbcsr_add(preconditioner_env%sparse_matrix, matrix_s, 1.0_dp, pre_shift)
803 CALL dbcsr_add_on_diag(preconditioner_env%sparse_matrix, pre_shift)
806 CALL dbcsr_release(mo_dbcsr)
807 CALL dbcsr_release(dbcsr_hc)
808 CALL dbcsr_release(dbcsr_sc)
809 CALL dbcsr_release(dbcsr_cthc)
811 CALL timestop(handle)
813 END SUBROUTINE make_full_single_inverse
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...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
subroutine, public cp_dbcsr_m_by_n_from_template(matrix, template, m, n, sym, data_type)
Utility function to create an arbitrary shaped dbcsr matrix with the same processor grid as the templ...
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_fm_to_dbcsr_row_template(matrix, fm_in, template)
Utility function to copy a specially shaped fm to dbcsr_matrix The result matrix will be the matrix i...
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_upper_to_full(matrix, work)
given an upper triangular matrix computes the corresponding full matrix
subroutine, public cp_fm_triangular_invert(matrix_a, uplo_tr)
inverts a triangular matrix
subroutine, public cp_fm_triangular_multiply(triangular_matrix, matrix_b, side, transpose_tr, invert_tr, uplo_tr, unit_diag_tr, n_rows, n_cols, alpha)
multiplies in place by a triangular matrix: matrix_b = alpha op(triangular_matrix) matrix_b or (if si...
various cholesky decomposition related routines
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,...
subroutine, public cp_fm_cholesky_reduce(matrix, matrixb, itype)
reduce a matrix pencil A,B to normal form B has to be cholesky decomposed with cp_fm_cholesky_decompo...
subroutine, public cp_fm_cholesky_restore(matrix, neig, matrixb, matrixout, op, pos, transa)
...
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public choose_eigv_solver(matrix, eigenvectors, eigenvalues, info)
Choose the Eigensolver depending on which library is available ELPA seems to be unstable for small sy...
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_get_diag(matrix, diag)
returns the diagonal elements of a fm
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_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
Defines the basic variable types.
integer, parameter, public dp
basic linear algebra operations for full matrixes
computes preconditioners, and implements methods to apply them currently used in qs_ot
subroutine, public make_preconditioner_matrix(preconditioner_env, matrix_h, matrix_s, matrix_t, mo_coeff, energy_homo, eigenvalues_ot, energy_gap, my_solver_type)
...