(git:cd590b0)
Loading...
Searching...
No Matches
bse_main.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Main routines for GW + Bethe-Salpeter for computing electronic excitations: a GW path
10!> prepares the BSE environment, bse_solve runs the solver on it
11!> \par History
12!> 04.2024 created [Maximilian Graml]
13!> 09.2026 split into prepare_bse_env and bse_solve [Maximilian Graml]
14! **************************************************************************************************
15
17
18 USE bse_full_diag, ONLY: create_a_and_b,&
24 USE bse_matvec, ONLY: mem_fraction
26 USE bse_types, ONLY: bse_env_type
39 USE cp_fm_types, ONLY: cp_fm_create,&
48 USE input_constants, ONLY: &
52 USE kinds, ONLY: dp
55 USE mo_window, ONLY: mo_window_type
58 USE qs_mo_types, ONLY: get_mo_set,&
61#include "./base/base_uses.f90"
62
63 IMPLICIT NONE
64
65 PRIVATE
66
67 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'bse_main'
68
70
71CONTAINS
72
73! **************************************************************************************************
74!> \brief Prepares the BSE environment from the old GW's slabs: run flags, the window on the DFT
75!> axis, the window-sized slabs with both energy sets, [1+Q(0)]^-1 once, the AO multipoles
76!> and the QS pointers. Starts no solver.
77!> \param bse_env settings re-read from its section; state filled here
78!> \param fm_S_ia_full B^P_ia of the GW levels per spin, the RPA copy without the energy factor
79!> \param fm_S_ij_full B^P_ij per spin
80!> \param fm_S_ab_full B^P_ab per spin
81!> \param fm_Q the static polarizability Q(0), untouched; the caller releases it afterwards
82!> \param Eigenval quasiparticle energies (level, 1, spin)
83!> \param Eigenval_scf DFT energies (level, 1, spin)
84!> \param homo occupied MOs per spin
85!> \param virtual virtual MOs per spin
86!> \param dimen_RI RI dimension of the slabs
87!> \param dimen_RI_red reduced RI dimension of Q(0)
88!> \param gw_corr_lev_occ GW-corrected occupied levels; the window may not exceed them
89!> \param bse_lev_virt GW-corrected virtual levels per spin
90!> \param qs_env source of the pointers the solver reads and of the AO multipoles
91!> \param unit_nr output unit, positive on the writing rank only
92! **************************************************************************************************
93 SUBROUTINE prepare_bse_env(bse_env, fm_S_ia_full, fm_S_ij_full, fm_S_ab_full, fm_Q, &
94 Eigenval, Eigenval_scf, homo, virtual, dimen_RI, dimen_RI_red, &
95 gw_corr_lev_occ, bse_lev_virt, qs_env, unit_nr)
96
97 TYPE(bse_env_type), INTENT(INOUT) :: bse_env
98 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: fm_s_ia_full, fm_s_ij_full, fm_s_ab_full
99 TYPE(cp_fm_type), INTENT(IN) :: fm_q
100 REAL(kind=dp), DIMENSION(:, :, :), INTENT(IN) :: eigenval, eigenval_scf
101 INTEGER, DIMENSION(:), INTENT(IN) :: homo, virtual
102 INTEGER, INTENT(IN) :: dimen_ri, dimen_ri_red, gw_corr_lev_occ
103 INTEGER, DIMENSION(:), INTENT(IN) :: bse_lev_virt
104 TYPE(qs_environment_type), POINTER :: qs_env
105 INTEGER, INTENT(IN) :: unit_nr
106
107 CHARACTER(LEN=*), PARAMETER :: routinen = 'prepare_bse_env'
108
109 INTEGER :: handle, ispin, n_window, nspins
110 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_mo, n_ov, offsets
111 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eigenval_dft_spin, eigenval_qp_spin
112 TYPE(cp_logger_type), POINTER :: logger
113 TYPE(mo_window_type) :: window
114 TYPE(section_vals_type), POINTER :: bse_section
115
116 CALL timeset(routinen, handle)
117
118 ! the settings afresh from the input, since adapt_BSE_input_params normalises them in place and a
119 ! later energy evaluation on the same environment runs the BSE again; the local pointer keeps the
120 ! section apart from bse_env, whose section pointer the reader sets
121 bse_section => bse_env%bse_section
122 CALL read_bse_section(bse_section, bse_env)
123
124 nspins = SIZE(homo)
125 bse_env%nspins = nspins
126 bse_env%dimen_RI = dimen_ri
127 bse_env%dimen_RI_red = dimen_ri_red
128 ! the GW-corrected level counts, the ceiling of the window
129 bse_env%gw_corr_lev_occ = gw_corr_lev_occ
130 ALLOCATE (bse_env%gw_corr_lev_virt(nspins))
131 bse_env%gw_corr_lev_virt(:) = bse_lev_virt(:)
132
133 ! run flags from the settings
134 bse_env%do_iterdiag = bse_env%bse_diag_method == bse_iterdiag
135 bse_env%do_fulldiag = bse_env%bse_diag_method == bse_fulldiag
136 bse_env%do_tda = bse_env%flag_tda == bse_tda .OR. bse_env%flag_tda == bse_both
137 bse_env%do_abba = bse_env%flag_tda == bse_abba .OR. bse_env%flag_tda == bse_both
138
139 CALL print_bse_start_flag(bse_env%do_tda, bse_env%do_abba, unit_nr)
140
141 ! the debug flag follows the debug print level
142 logger => cp_get_default_logger()
143 IF (logger%iter_info%print_level == debug_print_level) THEN
144 bse_env%bse_debug_print = .true.
145 END IF
146
147 ! what the solver reads from QS and the GW (pointers, none owned); the para_env is the RPA's,
148 ! the one the slabs live on
149 bse_env%para_env => fm_s_ia_full(1)%matrix_struct%para_env
150 CALL get_qs_env(qs_env, subsys=bse_env%subsys, pw_env=bse_env%pw_env, &
151 dft_control=bse_env%dft_control, mos=bse_env%mos, &
152 exstate_env=bse_env%exstate_env)
153 CALL bse_env%para_env%sync()
154
155 IF (nspins > 1) THEN
156 IF (bse_env%do_iterdiag) THEN
157 cpabort("Iterative BSE is not yet available for open-shell references")
158 END IF
159 CALL cp_warn(__location__, &
160 "Open-shell (UKS/LSD) BSE is a recent addition and has not been "// &
161 "extensively validated. Verify results carefully before using them "// &
162 "for production calculations.")
163 END IF
164
165 ! one absolute window on the DFT axis, then the window-sized slabs and both energy sets per spin
166 ALLOCATE (n_mo(nspins))
167 n_mo(:) = homo(:) + virtual(:)
168 CALL bse_window_from_dft(eigenval_scf(:, 1, :), n_mo, homo, bse_env%bse_cutoff_occ, &
169 bse_env%bse_cutoff_empty, window, warn=.true.)
170 DEALLOCATE (n_mo)
171
172 ALLOCATE (bse_env%homo_red(nspins), bse_env%virt_red(nspins), bse_env%homo_full(nspins))
173 ALLOCATE (bse_env%fm_S_ia(nspins), bse_env%fm_S_ij(nspins), bse_env%fm_S_ab(nspins))
174 bse_env%homo_full(:) = homo(:)
175 DO ispin = 1, nspins
176 ! the cutoff summary is printed for a closed-shell reference only
177 CALL truncate_bse_matrices(fm_s_ia_full(ispin), fm_s_ij_full(ispin), fm_s_ab_full(ispin), &
178 eigenval_scf(:, 1, ispin), eigenval(:, 1, ispin), &
179 eigenval_dft_spin, eigenval_qp_spin, homo(ispin), virtual(ispin), &
180 dimen_ri, unit_nr, ispin, bse_env, window, nspins == 1)
181 ! the window is one absolute range, so every spin has the same number of levels
182 IF (ispin == 1) THEN
183 n_window = SIZE(eigenval_qp_spin)
184 ALLOCATE (bse_env%eigenval_dft(n_window, nspins), bse_env%eigenval_qp(n_window, nspins))
185 END IF
186 bse_env%eigenval_dft(:, ispin) = eigenval_dft_spin(:)
187 bse_env%eigenval_qp(:, ispin) = eigenval_qp_spin(:)
188 DEALLOCATE (eigenval_dft_spin, eigenval_qp_spin)
189 END DO
190 ALLOCATE (n_ov(nspins), offsets(nspins))
191 CALL get_bse_spin_block_layout(bse_env%homo_red, bse_env%virt_red, n_ov, offsets, bse_env%n_ov_joint)
192 DEALLOCATE (n_ov, offsets)
193
194 CALL invert_static_screening(fm_q, dimen_ri_red, bse_env%fm_eps_inv)
195
196 ! the AO multipoles for the transition dipoles and, when asked for, the exciton descriptors;
197 ! the open-shell path computes no descriptors
198 CALL get_multipoles_ao(qs_env, 1, bse_env%matrix_dipole_ao, bse_env%multipole_ref_point)
199 IF (bse_env%num_print_exc_descr /= 0 .AND. nspins == 1) THEN
200 CALL get_multipoles_ao(qs_env, 2, bse_env%matrix_quadpole_ao, bse_env%multipole_ref_point)
201 END IF
202
203 CALL timestop(handle)
204
205 END SUBROUTINE prepare_bse_env
206
207! **************************************************************************************************
208!> \brief The inverse dielectric matrix in the RI basis, [1+Q(0)]^-1_PQ on the leading dimen_RI_red
209!> block, P, Q ≤ dimen_RI_red, by Cholesky decomposition and inversion of a copy of Q(0)
210!> \param fm_Q the static polarizability Q_PQ(0), untouched
211!> \param dimen_RI_red reduced RI dimension of Q(0)
212!> \param fm_eps_inv [1+Q(0)]^-1_PQ, created here on fm_Q's structure
213! **************************************************************************************************
214 SUBROUTINE invert_static_screening(fm_Q, dimen_RI_red, fm_eps_inv)
215
216 TYPE(cp_fm_type), INTENT(IN) :: fm_q
217 INTEGER, INTENT(IN) :: dimen_ri_red
218 TYPE(cp_fm_type), INTENT(OUT) :: fm_eps_inv
219
220 CHARACTER(LEN=*), PARAMETER :: routinen = 'invert_static_screening'
221
222 INTEGER :: handle, i_global, iib, info_chol, &
223 j_global, jjb, ncol_local, nrow_local
224 INTEGER, DIMENSION(:), POINTER :: col_indices, row_indices
225 TYPE(cp_fm_type) :: fm_work
226
227 CALL timeset(routinen, handle)
228
229 ! a copy: the caller keeps Q(0), and the open-shell path inverts once for both spins
230 CALL cp_fm_create(fm_eps_inv, fm_q%matrix_struct)
231 CALL cp_fm_to_fm(fm_q, fm_eps_inv)
232 CALL cp_fm_create(fm_work, fm_q%matrix_struct)
233 CALL cp_fm_set_all(fm_work, 0.0_dp)
234
235 ! δ_PQ + Q_PQ(0) on the leading dimen_RI_red block
236 CALL cp_fm_get_info(matrix=fm_eps_inv, nrow_local=nrow_local, ncol_local=ncol_local, &
237 row_indices=row_indices, col_indices=col_indices)
238 DO jjb = 1, ncol_local
239 j_global = col_indices(jjb)
240 DO iib = 1, nrow_local
241 i_global = row_indices(iib)
242 IF (j_global == i_global .AND. i_global <= dimen_ri_red) THEN
243 fm_eps_inv%local_data(iib, jjb) = fm_eps_inv%local_data(iib, jjb) + 1.0_dp
244 END IF
245 END DO
246 END DO
247
248 ! [1+Q(0)]^-1_PQ by Cholesky, symmetrised from the stored triangle
249 CALL cp_fm_cholesky_decompose(matrix=fm_eps_inv, n=dimen_ri_red, info_out=info_chol)
250 IF (info_chol /= 0) THEN
251 CALL cp_abort(__location__, 'Cholesky decomposition failed for static polarization in BSE')
252 END IF
253 CALL cp_fm_cholesky_invert(fm_eps_inv)
254 CALL cp_fm_uplo_to_full(fm_eps_inv, fm_work)
255
256 CALL cp_fm_release(fm_work)
257
258 CALL timestop(handle)
259
260 END SUBROUTINE invert_static_screening
261
262! **************************************************************************************************
263!> \brief Solves the BSE on a prepared environment: input normalisation, the screened slabs from
264!> [1+Q(0)]^-1, then the FULLDIAG or ITERDIAG solver on the energies USE_KS_ENERGIES selects
265!> \param bse_env prepared by a GW path; the screened slabs are formed here
266!> \param mo_coeff MO coefficients of the reference, per spin, for the properties
267!> \param unit_nr output unit, positive on the writing rank only
268! **************************************************************************************************
269 SUBROUTINE bse_solve(bse_env, mo_coeff, unit_nr)
270
271 TYPE(bse_env_type), INTENT(INOUT) :: bse_env
272 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: mo_coeff
273 INTEGER, INTENT(IN) :: unit_nr
274
275 CHARACTER(LEN=*), PARAMETER :: routinen = 'bse_solve'
276
277 INTEGER :: handle, ispin, n_window, nspins
278 REAL(kind=dp) :: diag_runtime_est
279 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eigenval_joint
280 TYPE(cp_fm_type) :: fm_a_bse, fm_b_bse, fm_c_bse, &
281 fm_inv_sqrt_a_minus_b, &
282 fm_sqrt_a_minus_b
283 TYPE(tddfpt2_control_type), POINTER :: tddfpt_control
284
285 CALL timeset(routinen, handle)
286
287 nspins = bse_env%nspins
288
289 ! normalisation touches no slab; n_ov_joint x 1 is the transition count on either spin path
290 CALL adapt_bse_input_params(bse_env%n_ov_joint, 1, unit_nr, bse_env)
291
292 ! the energies the solver sees, flat joint layout [spin 1 window | spin 2 window]
293 n_window = SIZE(bse_env%eigenval_qp, 1)
294 ALLOCATE (eigenval_joint(n_window*nspins))
295 DO ispin = 1, nspins
296 IF (bse_env%use_ks_energies) THEN
297 eigenval_joint((ispin - 1)*n_window + 1:ispin*n_window) = bse_env%eigenval_dft(:, ispin)
298 ELSE
299 eigenval_joint((ispin - 1)*n_window + 1:ispin*n_window) = bse_env%eigenval_qp(:, ispin)
300 END IF
301 END DO
302
303 ! \bar{B}^P_ij and \bar{B}^P_ia per spin from the one [1+Q(0)]^-1
304 ALLOCATE (bse_env%fm_S_bar_ia(nspins), bse_env%fm_S_bar_ij(nspins))
305 DO ispin = 1, nspins
306 CALL screen_slabs(bse_env%fm_eps_inv, bse_env%fm_S_ij(ispin), bse_env%fm_S_ia(ispin), &
307 bse_env%dimen_RI_red, bse_env%homo_red(ispin), bse_env%virt_red(ispin), &
308 bse_env%fm_S_bar_ij(ispin), bse_env%fm_S_bar_ia(ispin))
309 END DO
310 CALL cp_fm_release(bse_env%fm_eps_inv)
311
312 IF (bse_env%do_iterdiag) THEN
313 CALL solve_bse_iteratively(eigenval_joint, &
314 bse_env%homo_red, bse_env%virt_red, bse_env%homo_full, &
315 bse_env%dimen_RI, bse_env%do_tda, bse_env%do_abba, &
316 bse_env, mo_coeff, unit_nr)
317 END IF
318
319 IF (bse_env%do_fulldiag) THEN
320 CALL estimate_bse_resources(bse_env%n_ov_joint, unit_nr, bse_env%do_abba, &
321 bse_env%para_env, diag_runtime_est)
322 CALL create_a_and_b(bse_env%fm_S_ia, bse_env%fm_S_ij, bse_env%fm_S_ab, &
323 bse_env%fm_S_bar_ia, bse_env%fm_S_bar_ij, fm_a_bse, fm_b_bse, &
324 bse_env%do_abba, eigenval_joint, unit_nr, bse_env%homo_red, &
325 bse_env%virt_red, bse_env%dimen_RI, bse_env)
326 IF (bse_env%do_abba) THEN
327 CALL create_hermitian_form_of_abba(fm_a_bse, fm_b_bse, fm_c_bse, &
328 fm_sqrt_a_minus_b, fm_inv_sqrt_a_minus_b, &
329 unit_nr, bse_env, diag_runtime_est)
330 END IF
331 CALL cp_fm_release(fm_b_bse)
332 tddfpt_control => bse_env%dft_control%tddfpt2_control
333 ! homo_full: per-spin absolute MO labels for the amplitude table, N_e = SUM(homo_full) for TRK
334 IF (bse_env%do_tda .AND. (.NOT. tddfpt_control%do_bse)) THEN
335 CALL diagonalize_a(fm_a_bse, bse_env%homo_red, bse_env%virt_red, bse_env%homo_full, &
336 unit_nr, diag_runtime_est, bse_env, mo_coeff)
337 END IF
338 CALL cp_fm_release(fm_a_bse)
339 IF (bse_env%do_abba) THEN
340 CALL diagonalize_c(fm_c_bse, bse_env%homo_red, bse_env%virt_red, bse_env%homo_full, &
341 fm_sqrt_a_minus_b, fm_inv_sqrt_a_minus_b, &
342 unit_nr, diag_runtime_est, bse_env, mo_coeff)
343 END IF
344 CALL cp_fm_release(fm_c_bse)
345 END IF
346
347 DEALLOCATE (eigenval_joint)
348
349 IF (unit_nr > 0) THEN
350 WRITE (unit_nr, '(T2,A4,T7,A53)') 'BSE|', 'The BSE was successfully calculated. Have a nice day!'
351 END IF
352
353 CALL timestop(handle)
354
355 END SUBROUTINE bse_solve
356
357! **************************************************************************************************
358!> \brief Early memory check for the full diagonalization, before any GW work: the window on the
359!> DFT axis gives n_ov, the estimate is estimate_BSE_resources', the budget the one the
360!> iterative solver uses. WARN and CLAMP warn, ABORT aborts, OFF prints the estimate only.
361!> \param bse_env settings; the window cutoffs, MEMORY_CHECK and MEMORY_BUDGET_GB
362!> \param mos the MO sets the GW will correct, for their DFT eigenvalues and occupations
363!> \param para_env the ranks that will hold the matrices
364!> \param unit_nr output unit, positive on the writing rank only
365! **************************************************************************************************
366 SUBROUTINE bse_fulldiag_memory_check(bse_env, mos, para_env, unit_nr)
367
368 TYPE(bse_env_type), INTENT(IN) :: bse_env
369 TYPE(mo_set_type), DIMENSION(:), INTENT(IN) :: mos
370 TYPE(mp_para_env_type), POINTER :: para_env
371 INTEGER, INTENT(IN) :: unit_nr
372
373 CHARACTER(LEN=*), PARAMETER :: routinen = 'bse_fulldiag_memory_check'
374
375 CHARACTER(LEN=16) :: bud_str, mem_str
376 CHARACTER(LEN=64) :: remedy
377 INTEGER :: handle, homo, ispin, n_ov_joint, nspins
378 LOGICAL :: from_free, over, skipped
379 REAL(kind=dp) :: budget_gb, mem_avail_gb, mem_est_gb
380 TYPE(mo_window_type) :: window
381
382 CALL timeset(routinen, handle)
383
384 nspins = SIZE(mos)
385 ! the preparer warns about a combined window; the estimate stays silent
386 CALL bse_window_from_mos(mos, bse_env%bse_cutoff_occ, bse_env%bse_cutoff_empty, window, warn=.false.)
387 n_ov_joint = 0
388 DO ispin = 1, nspins
389 CALL get_mo_set(mos(ispin), homo=homo)
390 n_ov_joint = n_ov_joint + (homo - window%first_mo + 1)*(window%last_mo - homo)
391 END DO
392
393 mem_est_gb = fulldiag_memory_estimate_gb(n_ov_joint, bse_env%flag_tda /= bse_tda)/ &
394 REAL(para_env%num_pe, kind=dp)
395
396 ! the budget: as given, or the share mem_fraction of the free memory per rank
397 from_free = bse_env%memory_budget_gb < 0.0_dp
398 skipped = .false.
399 budget_gb = bse_env%memory_budget_gb
400 IF (from_free) THEN
401 CALL mp_mem_avail_per_rank_gb(para_env, mem_avail_gb)
402 budget_gb = mem_fraction*mem_avail_gb
403 skipped = mem_avail_gb <= 0.0_dp
404 END IF
405 over = .NOT. skipped .AND. bse_env%memory_check /= bse_memcheck_off .AND. mem_est_gb > budget_gb
406
407 IF (unit_nr > 0) THEN
408 WRITE (unit_nr, '(T2,A4)') 'BSE|'
409 WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Early memory check for the full diagonalization'
410 WRITE (unit_nr, '(T2,A4,T7,A,T71,I10)') 'BSE|', 'Transition pairs in the active window (DFT axis)', &
411 n_ov_joint
412 WRITE (unit_nr, '(T2,A4,T7,A,T67,F14.3)') 'BSE|', 'Peak memory estimate per MPI rank (GB)', mem_est_gb
413 IF (.NOT. skipped) THEN
414 WRITE (unit_nr, '(T2,A4,T7,A,T67,F14.3)') 'BSE|', 'Memory budget per MPI rank (GB)', budget_gb
415 END IF
416 IF (bse_env%memory_check == bse_memcheck_off) THEN
417 WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Memory check: OFF'
418 ELSE IF (skipped) THEN
419 WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Memory check: skipped, free memory not detectable'
420 ELSE IF (over) THEN
421 WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Memory check: the estimate exceeds the budget'
422 ELSE
423 WRITE (unit_nr, '(T2,A4,T7,A)') 'BSE|', 'Memory check: within the budget'
424 END IF
425 WRITE (unit_nr, '(T2,A4)') 'BSE|'
426 END IF
427
428 IF (over) THEN
429 WRITE (mem_str, '(F16.3)') mem_est_gb
430 WRITE (bud_str, '(F16.3)') budget_gb
431 ! ITERDIAG is closed-shell only, so an open-shell run is not pointed to it
432 IF (nspins == 1) THEN
433 remedy = "more MPI ranks, a tighter window, ITERDIAG"
434 ELSE
435 remedy = "more MPI ranks, a tighter window"
436 END IF
437 SELECT CASE (bse_env%memory_check)
439 IF (unit_nr > 0) CALL cp_warn(__location__, &
440 "BSE full diagonalization: the estimate of "//trim(adjustl(mem_str))// &
441 " GB per MPI rank exceeds the budget of "//trim(adjustl(bud_str))// &
442 " GB. Try one of: "//trim(remedy)//".")
443 CASE (bse_memcheck_abort)
444 CALL cp_abort(__location__, &
445 "BSE full diagonalization: the estimate of "//trim(adjustl(mem_str))// &
446 " GB per MPI rank exceeds the budget of "//trim(adjustl(bud_str))// &
447 " GB. Try one of: "//trim(remedy)//", MEMORY_CHECK WARN.")
448 END SELECT
449 END IF
450
451 CALL timestop(handle)
452
453 END SUBROUTINE bse_fulldiag_memory_check
454
455END MODULE bse_main
Routines for the full diagonalization of GW + Bethe-Salpeter for computing electronic excitations.
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...
subroutine, public diagonalize_a(fm_a, homo, virtual, homo_irred, unit_nr, diag_est, bse_env, mo_coeff)
Solving hermitian eigenvalue equation A X^n = Ω^n X^n.
subroutine, public create_hermitian_form_of_abba(fm_a, fm_b, fm_c, fm_sqrt_a_minus_b, fm_inv_sqrt_a_minus_b, unit_nr, bse_env, diag_est)
Construct Matrix C=(A-B)^0.5 (A+B) (A-B)^0.5 to solve full BSE matrix as a hermitian problem (cf....
subroutine, public diagonalize_c(fm_c, homo, virtual, homo_irred, fm_sqrt_a_minus_b, fm_inv_sqrt_a_minus_b, unit_nr, diag_est, bse_env, mo_coeff)
Solving eigenvalue equation C Z^n = (Ω^n)^2 Z^n . Here, the eigenvectors Z^n relate to X^n via Eq....
Reads the &BSE input section into the BSE environment; called by read_mp2_section with the section un...
Definition bse_input.F:15
subroutine, public read_bse_section(bse_section, bse_env)
Reads every keyword of the &BSE section into the settings of the BSE environment.
Definition bse_input.F:38
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...
Main routines for GW + Bethe-Salpeter for computing electronic excitations: a GW path prepares the BS...
Definition bse_main.F:16
subroutine, public bse_fulldiag_memory_check(bse_env, mos, para_env, unit_nr)
Early memory check for the full diagonalization, before any GW work: the window on the DFT axis gives...
Definition bse_main.F:367
subroutine, public bse_solve(bse_env, mo_coeff, unit_nr)
Solves the BSE on a prepared environment: input normalisation, the screened slabs from [1+Q(0)]^-1,...
Definition bse_main.F:270
subroutine, public prepare_bse_env(bse_env, fm_s_ia_full, fm_s_ij_full, fm_s_ab_full, fm_q, eigenval, eigenval_scf, homo, virtual, dimen_ri, dimen_ri_red, gw_corr_lev_occ, bse_lev_virt, qs_env, unit_nr)
Prepares the BSE environment from the old GW's slabs: run flags, the window on the DFT axis,...
Definition bse_main.F:96
Matrix-free application of the BSE matrices A and B to trial vectors from RI slabs that are sliced al...
Definition bse_matvec.F:14
real(kind=dp), parameter, public mem_fraction
Definition bse_matvec.F:47
Routines for printing information in context of the BSE calculation.
Definition bse_print.F:13
subroutine, public print_bse_start_flag(bse_tda, bse_abba, unit_nr)
...
Definition bse_print.F:57
The BSE environment: the settings of the &BSE section and the state a GW path prepares for the solver...
Definition bse_types.F:14
Auxiliary routines for GW + Bethe-Salpeter for computing electronic excitations.
Definition bse_util.F:13
subroutine, public truncate_bse_matrices(fm_s_ia_full, fm_s_ij_full, fm_s_ab_full, eigenval_scf, eigenval, eigenval_reduced_scf, eigenval_reduced_qp, homo, virtual, dimen_ri, unit_nr, ispin, bse_env, window, print_window)
Determines indices within the given energy cutoffs and truncates Eigenvalues and matrices.
Definition bse_util.F:1229
subroutine, public estimate_bse_resources(n_ov_joint, unit_nr, bse_abba, para_env, diag_runtime_est)
Roughly estimates the needed runtime and memory during the BSE run.
Definition bse_util.F:921
subroutine, public adapt_bse_input_params(homo, virtual, unit_nr, bse_env)
Checks BSE input section and adapts them if necessary.
Definition bse_util.F:1530
pure real(kind=dp) function, public fulldiag_memory_estimate_gb(n_ov_joint, do_abba)
Peak memory of the full diagonalization in GB, all ranks together: n_ov^2 doubles times the matrices ...
Definition bse_util.F:964
subroutine, public bse_window_from_dft(eigenval_scf, n_mo, homo, cutoff_occ, cutoff_empty, window, warn)
The active MO window on the DFT axis: one absolute MO range for every spin; when the spin windows dif...
Definition bse_util.F:1143
subroutine, public get_bse_spin_block_layout(homo_red, virt_red, n_ov, offsets, n_ov_joint)
Spin-block layout for the open-shell (joint) BSE matrix: per-spin OV-pair counts and the block offset...
Definition bse_util.F:1116
subroutine, public bse_window_from_mos(mos, cutoff_occ, cutoff_empty, window, warn)
The active MO window of bse_window_from_dft, from the DFT eigenvalues of the MO sets.
Definition bse_util.F:1181
subroutine, public screen_slabs(fm_eps_inv, fm_s_ij, fm_s_ia, dimen_ri_red, homo, virtual, fm_s_bar_ij, fm_s_bar_ia)
The screened slabs \bar{B}^P_ij = sum_Q [1+Q(0)]^-1_PQ B^Q_ij and \bar{B}^P_ia = sum_Q [1+Q(0)]^-1_PQ...
Definition bse_util.F:150
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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 a full matrix distributed on many processors
Definition cp_fm_types.F:15
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_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
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public debug_print_level
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public bse_iterdiag
integer, parameter, public bse_memcheck_warn
integer, parameter, public bse_memcheck_off
integer, parameter, public bse_fulldiag
integer, parameter, public bse_memcheck_clamp
integer, parameter, public bse_tda
integer, parameter, public bse_both
integer, parameter, public bse_abba
integer, parameter, public bse_memcheck_abort
objects that represent the structure of input sections and the data contained in an input section
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
subroutine, public mp_mem_avail_per_rank_gb(comm, mem_avail_gb)
Memory that is currently free on the node, per MPI rank of that node, in GB.
Common selection and union operations for contiguous molecular-orbital windows.
Definition mo_window.F:11
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>.
Definition qs_moments.F:14
subroutine, public get_multipoles_ao(qs_env, n_moments, matrix_multipole, rpoint)
The AO multipoles M^k_µν = <φ_µ|(r - r_0)^k|φ_ν> of every order up to n_moments, on the block pattern...
Definition qs_moments.F:422
Settings of the &BSE section (read_bse_section, re-read by prepare_bse_env, normalised in place by ad...
Definition bse_types.F:41
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores all the informations relevant to an mpi environment