Skip to content

Commit

Permalink
BSE: new features and update manual (cp2k#3781)
Browse files Browse the repository at this point in the history
  • Loading branch information
MGraml authored Nov 20, 2024
1 parent 52af7ed commit 4dc10b3
Show file tree
Hide file tree
Showing 23 changed files with 3,590 additions and 866 deletions.
515 changes: 429 additions & 86 deletions docs/methods/properties/optical/bethe-salpeter.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ list(
bse_main.F
bse_full_diag.F
bse_iterative.F
bse_print.F
bse_properties.F
bse_util.F
bsse.F
cell_methods.F
Expand Down
313 changes: 117 additions & 196 deletions src/bse_full_diag.F

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/bse_iterative.F
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ SUBROUTINE do_subspace_iterations(B_bar_ijQ_bse_local, B_abQ_bse_local, B_bar_ia
num_res_unconverged = -1
num_exact_en_unconverged = -1

bse_davidson_abort_cond = mp2_env%ri_g0w0%davidson_abort_cond
num_exc_en = mp2_env%ri_g0w0%num_exc_en
num_add_start_z_space = mp2_env%ri_g0w0%num_add_start_z_space
fac_max_z_space = mp2_env%ri_g0w0%fac_max_z_space
num_new_t = mp2_env%ri_g0w0%num_new_t
num_davidson_iter = mp2_env%ri_g0w0%num_davidson_iter
eps_res = mp2_env%ri_g0w0%eps_res
eps_exc_en = mp2_env%ri_g0w0%eps_exc_en
z_space_energy_cutoff = mp2_env%ri_g0w0%z_space_energy_cutoff
bse_davidson_abort_cond = mp2_env%bse%davidson_abort_cond
num_exc_en = mp2_env%bse%num_exc_en
num_add_start_z_space = mp2_env%bse%num_add_start_z_space
fac_max_z_space = mp2_env%bse%fac_max_z_space
num_new_t = mp2_env%bse%num_new_t
num_davidson_iter = mp2_env%bse%num_davidson_iter
eps_res = mp2_env%bse%eps_res
eps_exc_en = mp2_env%bse%eps_exc_en
z_space_energy_cutoff = mp2_env%bse%z_space_energy_cutoff

num_Z_vectors_init = num_exc_en + num_add_start_z_space

Expand Down Expand Up @@ -244,7 +244,7 @@ SUBROUTINE do_subspace_iterations(B_bar_ijQ_bse_local, B_abQ_bse_local, B_bar_ia
END IF

IF (davidson_converged == 1) THEN
CALL success_message(Subspace_full_eigenval, num_new_t, eps_res, num_res_unconverged, &
CALL postprocess_bse(Subspace_full_eigenval, num_new_t, eps_res, num_res_unconverged, &
bse_spin_config, unit_nr, num_exc_en, num_Z_vectors_init, &
num_davidson_iter, i_iter, num_Z_vectors, num_max_z_space, max_res_norm, &
max_en_diff, num_en_unconverged, bse_davidson_abort_cond_string, &
Expand Down Expand Up @@ -469,7 +469,7 @@ SUBROUTINE create_bse_work_arrays(AZ, Z_vectors_reshaped, AZ_reshaped, BZ, M_ia_
!> \param success_abort_string ...
!> \param z_space_energy_cutoff ...
! **************************************************************************************************
SUBROUTINE success_message(Subspace_full_eigenval, num_new_t, eps_res, num_res_unconverged, &
SUBROUTINE postprocess_bse(Subspace_full_eigenval, num_new_t, eps_res, num_res_unconverged, &
bse_spin_config, unit_nr, num_exc_en, num_Z_vectors_init, &
num_davidson_iter, i_iter, num_Z_vectors, num_max_z_space, max_res_norm, &
max_en_diff, num_en_unconverged, bse_davidson_abort_cond_string, &
Expand All @@ -487,7 +487,7 @@ SUBROUTINE success_message(Subspace_full_eigenval, num_new_t, eps_res, num_res_u
CHARACTER(LEN=10) :: success_abort_string
REAL(KIND=dp) :: z_space_energy_cutoff

CHARACTER(LEN=*), PARAMETER :: routineN = 'success_message'
CHARACTER(LEN=*), PARAMETER :: routineN = 'postprocess_bse'

CHARACTER(LEN=10) :: multiplet
INTEGER :: handle, i
Expand Down
17 changes: 10 additions & 7 deletions src/bse_main.F
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ MODULE bse_main
diagonalize_C
USE bse_iterative, ONLY: do_subspace_iterations,&
fill_local_3c_arrays
USE bse_util, ONLY: deallocate_matrices_bse,&
USE bse_print, ONLY: print_BSE_start_flag
USE bse_util, ONLY: adapt_BSE_input_params,&
deallocate_matrices_bse,&
estimate_BSE_resources,&
mult_B_with_W,&
print_BSE_start_flag,&
truncate_BSE_matrices
USE cp_fm_types, ONLY: cp_fm_release,&
cp_fm_type
Expand Down Expand Up @@ -116,7 +117,7 @@ SUBROUTINE start_bse_calculation(fm_mat_S_ia_bse, fm_mat_S_ij_bse, fm_mat_S_ab_b
my_do_tda = .FALSE.
my_do_abba = .FALSE.
!Method: Iterative or full diagonalization
SELECT CASE (mp2_env%ri_g0w0%bse_diag_method)
SELECT CASE (mp2_env%bse%bse_diag_method)
CASE (bse_iterdiag)
my_do_iterat_diag = .TRUE.
!MG: Basics of the Davidson solver are implemented, but not rigorously checked.
Expand All @@ -125,7 +126,7 @@ SUBROUTINE start_bse_calculation(fm_mat_S_ia_bse, fm_mat_S_ij_bse, fm_mat_S_ab_b
my_do_fulldiag = .TRUE.
END SELECT
!Approximation: TDA and/or full ABBA matrix
SELECT CASE (mp2_env%ri_g0w0%flag_tda)
SELECT CASE (mp2_env%bse%flag_tda)
CASE (bse_tda)
my_do_tda = .TRUE.
CASE (bse_abba)
Expand All @@ -140,7 +141,7 @@ SUBROUTINE start_bse_calculation(fm_mat_S_ia_bse, fm_mat_S_ij_bse, fm_mat_S_ab_b
! Link BSE debug flag against debug print level
logger => cp_get_default_logger()
IF (logger%iter_info%print_level == debug_print_level) THEN
mp2_env%ri_g0w0%bse_debug_print = .TRUE.
mp2_env%bse%bse_debug_print = .TRUE.
END IF

CALL fm_mat_S_ia_bse%matrix_struct%para_env%sync()
Expand Down Expand Up @@ -168,6 +169,8 @@ SUBROUTINE start_bse_calculation(fm_mat_S_ia_bse, fm_mat_S_ij_bse, fm_mat_S_ab_b
gd_array, color_sub, para_env)
END IF

CALL adapt_BSE_input_params(homo_red, virtual_red, unit_nr, mp2_env)

IF (my_do_fulldiag) THEN
! Quick estimate of memory consumption and runtime of diagonalizations
CALL estimate_BSE_resources(homo_red, virtual_red, unit_nr, my_do_abba, &
Expand Down Expand Up @@ -220,12 +223,12 @@ SUBROUTINE start_bse_calculation(fm_mat_S_ia_bse, fm_mat_S_ij_bse, fm_mat_S_ab_b

CALL deallocate_matrices_bse(fm_mat_S_bar_ia_bse, fm_mat_S_bar_ij_bse, &
fm_mat_S_ia_trunc, fm_mat_S_ij_trunc, fm_mat_S_ab_trunc, &
fm_mat_Q_static_bse_gemm)
fm_mat_Q_static_bse_gemm, mp2_env)
DEALLOCATE (Eigenval_reduced)
IF (my_do_iterat_diag) THEN
! Contains untested Block-Davidson algorithm
CALL do_subspace_iterations(B_bar_ijQ_bse_local, B_abQ_bse_local, B_bar_iaQ_bse_local, &
B_iaQ_bse_local, homo(1), virtual(1), mp2_env%ri_g0w0%bse_spin_config, unit_nr, &
B_iaQ_bse_local, homo(1), virtual(1), mp2_env%bse%bse_spin_config, unit_nr, &
Eigenval(:, 1, 1), para_env, mp2_env)
! Deallocate local 3c-B-matrices
DEALLOCATE (B_bar_ijQ_bse_local, B_abQ_bse_local, B_bar_iaQ_bse_local, B_iaQ_bse_local)
Expand Down
Loading

0 comments on commit 4dc10b3

Please sign in to comment.