51#include "./base/base_uses.f90"
57 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'bse_iterative'
89 homo_red_arr, virt_red_arr, homo, dimen_RI, &
90 do_tda, do_abba, bse_env, mo_coeff, unit_nr)
92 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: eigenval_reduced
93 INTEGER,
DIMENSION(:),
INTENT(IN) :: homo_red_arr, virt_red_arr, homo
94 INTEGER,
INTENT(IN) :: dimen_ri
95 LOGICAL,
INTENT(IN) :: do_tda, do_abba
97 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: mo_coeff
98 INTEGER,
INTENT(IN) :: unit_nr
100 CHARACTER(LEN=*),
PARAMETER :: routinen =
'solve_bse_iteratively'
101 INTEGER,
PARAMETER :: n_ov_max_debug = 20000
103 CHARACTER(LEN=16) :: margin_str, n_ov_str, solver_str
104 INTEGER :: abba_status, handle, n_ov
106 REAL(kind=
dp) :: ab_margin
107 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: exc_ens, exc_ens_abba
110 TYPE(
cp_fm_type) :: fm_a_bse, fm_b_bse, fm_x_abba, fm_x_ia, &
116 CALL timeset(routinen, handle)
118 dft_control => bse_env%dft_control
119 IF (dft_control%tddfpt2_control%do_bse .OR. dft_control%tddfpt2_control%do_bse_w_only .OR. &
120 dft_control%tddfpt2_control%do_bse_gw_only)
THEN
123 CALL cp_abort(__location__, &
124 "BSE_DIAG_METHOD ITERDIAG cannot provide the BSE kernel of TDDFPT "// &
125 "(DO_BSE, DO_BSE_W_ONLY, DO_BSE_GW_ONLY). Use BSE_DIAG_METHOD FULLDIAG.")
128 n_ov = homo_red_arr(1)*virt_red_arr(1)
130 do_debug = bse_env%bse_debug_print .AND. n_ov <= n_ov_max_debug
131 IF (bse_env%bse_debug_print .AND. .NOT. do_debug .AND. unit_nr > 0)
THEN
132 WRITE (n_ov_str,
'(I0)') n_ov_max_debug
133 CALL cp_warn(__location__, &
134 "BSE_DEBUG_PRINT: the checks of the iterative solver against the explicit A "// &
135 "and B are skipped above N_ov = "//trim(n_ov_str)//
".")
138 CALL create_matvec_env(mv_env, bse_env%fm_S_ia(1), bse_env%fm_S_ij(1), &
139 bse_env%fm_S_ab(1), bse_env%fm_S_bar_ia(1), &
140 bse_env%fm_S_bar_ij(1), eigenval_reduced, &
141 homo_red_arr(1), virt_red_arr(1), do_abba, bse_env, unit_nr)
144 CALL create_a_and_b(bse_env%fm_S_ia, bse_env%fm_S_ij, bse_env%fm_S_ab, &
145 bse_env%fm_S_bar_ia, bse_env%fm_S_bar_ij, fm_a_bse, fm_b_bse, &
146 do_abba, eigenval_reduced, unit_nr, homo_red_arr, virt_red_arr, dimen_ri, &
156 blacs_env_ia => bse_env%fm_S_ia(1)%matrix_struct%context
157 CALL blacs_env_ia%retain()
165 CALL print_output_header(homo_red_arr(1), virt_red_arr(1), homo(1), .true., bse_env, unit_nr)
169 CALL copy_to_ia_context(fm_x, blacs_env_ia, fm_x_ia)
171 homo_red_arr(1), virt_red_arr(1), homo(1), unit_nr, .true.)
179 NULLIFY (fm_tda_guess)
180 IF (do_tda) fm_tda_guess => fm_x
181 CALL print_output_header(homo_red_arr(1), virt_red_arr(1), homo(1), .false., bse_env, unit_nr)
182 SELECT CASE (bse_env%abba_solver)
184 solver_str =
'MK_DAVIDSON'
186 abba_status, ab_margin, fm_tda_guess)
188 solver_str =
'OLSEN_STRATMANN'
190 abba_status, ab_margin, fm_tda_guess)
192 cpabort(
"Unknown BSE_ITERAT%ABBA_SOLVER")
195 WRITE (margin_str,
'(F16.6)') ab_margin*
evolt
196 IF (.NOT. do_tda)
THEN
197 CALL cp_abort(__location__, &
198 "Matrix (A-B) is not positive definite on the trial space of the "// &
199 trim(solver_str)//
" solver (eigenvalue "//trim(adjustl(margin_str))//
" eV). "// &
200 "The full ABBA problem is ill-defined for this reference.")
203 IF (unit_nr > 0)
THEN
204 CALL cp_warn(__location__, &
205 "BSE: A-B is not positive definite on the trial space (margin "// &
206 trim(adjustl(margin_str))//
" eV); the ABBA calculation is skipped, "// &
207 "TDA results above are complete.")
208 WRITE (unit_nr,
'(T2,A4)')
'BSE|'
209 WRITE (unit_nr,
'(T2,A4,T7,A,T67,F14.6)')
'BSE|', &
210 'A-B is not positive definite on the trial space (eV)', ab_margin*
evolt
211 WRITE (unit_nr,
'(T2,A4,T7,A)')
'BSE|', &
212 'The ABBA calculation is skipped, the TDA results above are complete'
220 CALL copy_to_ia_context(fm_x_abba, blacs_env_ia, fm_x_ia)
221 CALL copy_to_ia_context(fm_y_abba, blacs_env_ia, fm_y_ia)
225 homo_red_arr(1), virt_red_arr(1), homo(1), unit_nr, .false., fm_y_ia)
228 DEALLOCATE (exc_ens_abba)
240 CALL timestop(handle)
251 SUBROUTINE copy_to_ia_context(fm_vec, blacs_env_ia, fm_vec_ia)
257 INTEGER :: n_exc, n_ov
262 CALL cp_fm_struct_create(fm_struct, para_env=blacs_env_ia%para_env, context=blacs_env_ia, &
263 nrow_global=n_ov, ncol_global=n_exc)
264 CALL cp_fm_create(fm_vec_ia, fm_struct, name=
"fm_davidson_ia")
268 END SUBROUTINE copy_to_ia_context
288 SUBROUTINE create_matvec_env(mv_env, fm_S_ia, fm_S_ij, fm_S_ab, fm_S_bar_ia, fm_S_bar_ij, &
289 Eigenval_reduced, homo_red, virt_red, do_abba, bse_env, unit_nr)
292 TYPE(
cp_fm_type),
INTENT(IN),
TARGET :: fm_s_ia, fm_s_ij, fm_s_ab, fm_s_bar_ia, &
294 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: eigenval_reduced
295 INTEGER,
INTENT(IN) :: homo_red, virt_red
296 LOGICAL,
INTENT(IN) :: do_abba
298 INTEGER,
INTENT(IN) :: unit_nr
300 REAL(kind=
dp) :: alpha, w_fac
304 SELECT CASE (bse_env%bse_spin_config)
311 SELECT CASE (bse_env%screening_method)
313 w_fac = bse_env%screening_factor
325 fm_w_ij => fm_s_bar_ij
326 fm_w_ia => fm_s_bar_ia
328 CALL bse_matvec_create(mv_env, fm_s_ia, fm_w_ij, fm_s_ab, fm_w_ia, eigenval_reduced, &
329 homo_red, virt_red, alpha, w_fac, do_abba, unit_nr, &
330 block_cols=bse_env%matvec_block_columns, memory_per_proc_gb=bse_env%memory_per_proc_gb)
332 END SUBROUTINE create_matvec_env
Block Davidson solvers for the lowest excitations of the Bethe-Salpeter equation on top of the matrix...
subroutine, public bse_davidson_abba_os(mv_env, bse_env, unit_nr, exc_ens, fm_x, fm_y, abba_status, ab_margin, fm_x_tda)
Block Davidson with thick restart for the NUM_EXC_EN lowest solutions of the full problem in the pair...
integer, parameter, public abba_indefinite
subroutine, public bse_davidson_abba_mk(mv_env, bse_env, unit_nr, exc_ens, fm_x, fm_y, abba_status, ab_margin, fm_x_tda)
Block Davidson with thick restart for the NUM_EXC_EN lowest solutions of the full problem,...
subroutine, public bse_davidson_tda(mv_env, bse_env, unit_nr, exc_ens, fm_x)
Block Davidson with thick restart for the NUM_EXC_EN lowest solutions of sum_jb A_ia,...
subroutine, public bse_davidson_refcheck(fm_a_explicit, exc_ens, fm_x, bse_env, unit_nr, fm_b_explicit, fm_y)
Debug check of a Davidson result against the full diagonalization of the explicit matrices: energies,...
Routines for the full diagonalization of GW + Bethe-Salpeter for computing electronic excitations.
subroutine, public postprocess_bse(exc_ens, fm_eigvec_x, bse_env, mo_coeff, homo, virtual, homo_irred, unit_nr, flag_tda, fm_eigvec_y)
Prints the success message (incl. energies) for full diag of BSE (TDA/full ABBA via flag).
subroutine, public create_a_and_b(fm_s_ia, fm_s_ij, fm_s_ab, fm_s_bar_ia, fm_s_bar_ij, fm_a, fm_b, do_abba, eigenval, unit_nr, homo, virtual, dimen_ri, bse_env)
Explicit A, and B for ABBA, from the slabs the screening method contracts: the bare ones for TDHF and...
Iterative solution of the Bethe-Salpeter equation: the block Davidson solvers on top of the matrix-fr...
subroutine, public solve_bse_iteratively(eigenval_reduced, homo_red_arr, virt_red_arr, homo, dimen_ri, do_tda, do_abba, bse_env, mo_coeff, unit_nr)
Lowest excitations of a closed-shell reference from the block Davidson solvers on top of the matrix-f...
Matrix-free application of the BSE matrices A and B to trial vectors from RI slabs that are sliced al...
subroutine, public bse_matvec_create(mv_env, fm_s_ia, fm_s_bar_ij, fm_s_ab, fm_s_bar_ia, eps_reduced, homo, virt, alpha, w_fac, do_abba, unit_nr, block_cols, memory_per_proc_gb)
Moves the RI slabs onto an npe x 1 process grid, such that every rank owns whole RI slices,...
subroutine, public bse_matvec_release(mv_env)
Frees the sliced slabs, the transition energies and the process grid of mv_env.
subroutine, public bse_matvec_selfcheck(mv_env, fm_a_explicit, unit_nr, fm_b_explicit)
Debug check of the matrix-free application against the explicit matrices A (and B),...
Routines for printing information in context of the BSE calculation.
subroutine, public print_output_header(homo, virtual, homo_irred, flag_tda, bse_env, unit_nr)
Banner, defining equations and legend of one BSE problem, printed before it is solved.
The BSE environment: the settings of the &BSE section and the state a GW path prepares for the solver...
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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_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_to_fm_submat_general(source, destination, nrows, ncols, s_firstrow, s_firstcol, d_firstrow, d_firstcol, global_context)
General copy of a submatrix of fm matrix to a submatrix of another fm matrix. The two matrices can ha...
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
Defines the basic variable types.
integer, parameter, public dp
Definition of physical constants:
real(kind=dp), parameter, public evolt
RI slabs of one spin channel, every rank holding n_ri_loc whole RI slices.
Settings of the &BSE section (read_bse_section, re-read before every BSE run, normalised in place by ...
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix