(git:3d5d2e5)
Loading...
Searching...
No Matches
bse_full_diag.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 Routines for the full diagonalization of GW + Bethe-Salpeter for computing
10!> electronic excitations
11!> \par History
12!> 10.2023 created [Maximilian Graml]
13! **************************************************************************************************
15
25 USE bse_types, ONLY: bse_env_type
30 occ_of_ia,&
48 USE cp_fm_types, ONLY: &
52 USE input_constants, ONLY: bse_iterdiag,&
58 USE kinds, ONLY: dp
61 USE physcon, ONLY: evolt
63#include "./base/base_uses.f90"
64
65 IMPLICIT NONE
66
67 PRIVATE
68
69 CHARACTER(LEN=*), PARAMETER, PRIVATE :: moduleN = 'bse_full_diag'
70
73
74CONTAINS
75
76! **************************************************************************************************
77!> \brief Matrix A constructed from GW energies and 3c-B-matrices (cf. subroutine screen_slabs)
78!> A_ia,jb = (ε_a-ε_i) δ_ij δ_ab + α * v_ia,jb - W_ij,ab
79!> ε_a, ε_i are GW singleparticle energies from Eigenval_reduced
80!> α is a spin-dependent factor
81!> v_ia,jb = \sum_P B^P_ia B^P_jb (unscreened Coulomb interaction)
82!> W_ij,ab = \sum_P \bar{B}^P_ij B^P_ab (screened Coulomb interaction)
83!> \param fm_S_ia ...
84!> \param fm_S_bar_ij ...
85!> \param fm_S_ab ...
86!> \param fm_A ...
87!> \param Eigenval ...
88!> \param unit_nr ...
89!> \param homo ...
90!> \param virtual ...
91!> \param dimen_RI ...
92!> \param bse_env the BSE environment (settings; para_env, dft_control, exstate_env)
93! **************************************************************************************************
94 SUBROUTINE create_a(fm_S_ia, fm_S_bar_ij, fm_S_ab, &
95 fm_A, Eigenval, unit_nr, &
96 homo, virtual, dimen_RI, bse_env)
97
98 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: fm_s_ia, fm_s_bar_ij, fm_s_ab
99 TYPE(cp_fm_type), INTENT(INOUT) :: fm_a
100 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: eigenval
101 INTEGER, INTENT(IN) :: unit_nr
102 INTEGER, DIMENSION(:), INTENT(IN) :: homo, virtual
103 INTEGER, INTENT(IN) :: dimen_ri
104 TYPE(bse_env_type), INTENT(IN) :: bse_env
105
106 CHARACTER(LEN=*), PARAMETER :: routinen = 'create_A'
107
108 INTEGER :: a_virt_row, handle, i_occ_row, i_row_global, ii, isp, j_col_global, jj, k_isp, &
109 k_ov, n_ov_joint, ncol_local_a, nrow_local_a, nspins, sizeeigen
110 INTEGER, ALLOCATABLE, DIMENSION(:) :: eig_offsets, n_ov, offsets
111 INTEGER, DIMENSION(4) :: reordering
112 INTEGER, DIMENSION(:), POINTER :: col_indices_a, row_indices_a
113 REAL(kind=dp) :: alpha, alpha_screening, eigen_diff
114 TYPE(cp_blacs_env_type), POINTER :: blacs_env
115 TYPE(cp_fm_struct_type), POINTER :: fm_struct_a, fm_struct_s_joint, &
116 fm_struct_w
117 TYPE(cp_fm_type) :: fm_a_copy, fm_s_joint, fm_w
118 TYPE(dft_control_type), POINTER :: dft_control
119 TYPE(excited_energy_type), POINTER :: ex_env
120 TYPE(tddfpt2_control_type), POINTER :: tddfpt_control
121
122 CALL timeset(routinen, handle)
123
124 nspins = SIZE(homo)
125 ALLOCATE (n_ov(nspins), offsets(nspins), eig_offsets(nspins))
126 CALL get_bse_spin_block_layout(homo, virtual, n_ov, offsets, n_ov_joint)
127 ! Flat Eigenval layout: sigma-block isp at eig_offsets(isp)+1 .. eig_offsets(isp)+homo(isp)+virtual(isp)
128 eig_offsets(1) = 0
129 DO isp = 2, nspins
130 eig_offsets(isp) = eig_offsets(isp - 1) + homo(isp - 1) + virtual(isp - 1)
131 END DO
132
133 NULLIFY (dft_control, tddfpt_control)
134 dft_control => bse_env%dft_control
135 tddfpt_control => dft_control%tddfpt2_control
136
137 IF (unit_nr > 0 .AND. bse_env%bse_debug_print) THEN
138 WRITE (unit_nr, '(T2,A10,T13,A10)') 'BSE|DEBUG|', 'Creating A'
139 END IF
140
141 !Determines factor of exchange term, depending on requested spin configuration (cf. input_constants.F)
142 SELECT CASE (bse_env%bse_spin_config)
143 CASE (bse_singlet)
144 alpha = 2.0_dp
145 CASE (bse_triplet)
146 alpha = 0.0_dp
147 END SELECT
148 ! For open-shell (nspins>1): each spin block contributes once; SPIN_CONFIG is ignored.
149 IF (nspins > 1) THEN
150 CALL cp_warn(__location__, &
151 "BSE: SPIN_CONFIG ignored for open-shell reference; using alpha=1.")
152 alpha = 1.0_dp
153 END IF
154
155 IF (bse_env%screening_method == bse_screening_alpha) THEN
156 alpha_screening = bse_env%screening_factor
157 ELSE
158 alpha_screening = 1.0_dp
159 END IF
160
161 ! create the blacs env for ij matrices (NOT fm_S_ia%matrix_struct related parallel_gemms!)
162 NULLIFY (blacs_env)
163 CALL cp_blacs_env_create(blacs_env=blacs_env, para_env=bse_env%para_env)
164
165 ! We have to use the same blacs_env for A as for the matrices fm_S_ia from RPA
166 ! Logic: A_ia,jb = (ε_a-ε_i) δ_ij δ_ab + α * v_ia,jb - W_ij,ab
167 ! We create v_ia,jb and W_ij,ab, then we communicate entries from local W_ij,ab
168 ! to the full matrix v_ia,jb. By adding these and the energy diffenences: v_ia,jb -> A_ia,jb
169 ! We use the A matrix already from the start instead of v
170 CALL cp_fm_struct_create(fm_struct_a, context=fm_s_ia(1)%matrix_struct%context, &
171 nrow_global=n_ov_joint, ncol_global=n_ov_joint, &
172 para_env=fm_s_ia(1)%matrix_struct%para_env)
173 CALL cp_fm_create(fm_a, fm_struct_a, name="fm_A_iajb")
174 CALL cp_fm_set_all(fm_a, 0.0_dp)
175 ! fm_A_copy only used in the TDDFPT do_bse_w_only path (closed-shell only)
176 IF (tddfpt_control%do_bse_w_only .AND. nspins == 1) THEN
177 CALL cp_fm_create(fm_a_copy, fm_struct_a, name="fm_A_iajb")
178 CALL cp_fm_set_all(fm_a_copy, 0.0_dp)
179 END IF
180
181 ! Create A matrix from GW Energies, v_ia,jb and W_ij,ab
182 ! v_ia,jb = \sum_P B^P_ia B^P_jb (Coulomb)
183 IF ((.NOT. tddfpt_control%do_bse) .AND. (.NOT. tddfpt_control%do_bse_w_only)) THEN
184 IF (nspins > 1) THEN
185 ! Assemble joint ia-slab for a single Coulomb gemm across all spin blocks
186 CALL cp_fm_struct_create(fm_struct_s_joint, &
187 context=fm_s_ia(1)%matrix_struct%context, &
188 nrow_global=dimen_ri, ncol_global=n_ov_joint, &
189 para_env=fm_s_ia(1)%matrix_struct%para_env)
190 CALL cp_fm_create(fm_s_joint, fm_struct_s_joint, name="fm_S_ia_joint")
191 CALL cp_fm_set_all(fm_s_joint, 0.0_dp)
192 CALL assemble_joint_ov_slab(fm_s_ia, offsets, n_ov, dimen_ri, fm_s_joint)
193 CALL parallel_gemm(transa="T", transb="N", m=n_ov_joint, n=n_ov_joint, k=dimen_ri, &
194 alpha=alpha, matrix_a=fm_s_joint, matrix_b=fm_s_joint, beta=0.0_dp, &
195 matrix_c=fm_a)
196 CALL cp_fm_release(fm_s_joint)
197 CALL cp_fm_struct_release(fm_struct_s_joint)
198 ELSE
199 CALL parallel_gemm(transa="T", transb="N", m=homo(1)*virtual(1), n=homo(1)*virtual(1), &
200 k=dimen_ri, alpha=alpha, &
201 matrix_a=fm_s_ia(1), matrix_b=fm_s_ia(1), &
202 beta=0.0_dp, matrix_c=fm_a)
203 END IF
204 END IF
205
206 IF (unit_nr > 0 .AND. bse_env%bse_debug_print) THEN
207 WRITE (unit_nr, '(T2,A10,T13,A16)') 'BSE|DEBUG|', 'Allocated A_iajb'
208 END IF
209
210 ! W term on sigma-diagonal blocks only: W^sigma_ij,ab = sum_P barB^P_ij B^P_ab
211 ! offsets(isp) places each block at the correct position in joint A.
212 ! For nspins=1: offsets(1)=0, equivalent to the original code.
213 DO isp = 1, nspins
214 IF (bse_env%screening_method /= bse_screening_rpa) THEN
215 CALL cp_fm_struct_create(fm_struct_w, context=fm_s_ab(isp)%matrix_struct%context, &
216 nrow_global=homo(isp)**2, ncol_global=virtual(isp)**2, &
217 para_env=fm_s_ab(isp)%matrix_struct%para_env)
218 CALL cp_fm_create(fm_w, fm_struct_w, name="fm_W_ijab")
219 CALL cp_fm_set_all(fm_w, 0.0_dp)
220 !W_ij,ab = \sum_P \bar{B}^P_ij B^P_ab
221 CALL parallel_gemm(transa="T", transb="N", m=homo(isp)**2, n=virtual(isp)**2, &
222 k=dimen_ri, alpha=alpha_screening, &
223 matrix_a=fm_s_bar_ij(isp), matrix_b=fm_s_ab(isp), &
224 beta=0.0_dp, matrix_c=fm_w)
225 reordering = [1, 3, 2, 4]
226 CALL cp_fm_permute(fm_a, fm_w, -1.0_dp, homo(isp), virtual(isp), virtual(isp), virtual(isp), reordering, &
227 row_offset=offsets(isp), col_offset=offsets(isp))
228 IF (nspins == 1 .AND. tddfpt_control%do_bse_w_only) THEN
229 CALL cp_fm_permute(fm_a_copy, fm_w, -1.0_dp, homo(1), virtual(1), virtual(1), virtual(1), reordering)
230 END IF
231 ! W and A stash for TDDFPT path (closed-shell only; open-shell deferred)
232 IF (nspins == 1) THEN
233 IF (tddfpt_control%do_bse .OR. tddfpt_control%do_bse_w_only .OR. &
234 tddfpt_control%do_bse_gw_only) THEN
235 NULLIFY (ex_env)
236 ex_env => bse_env%exstate_env
237 IF (.NOT. tddfpt_control%do_bse_gw_only) THEN
238 ALLOCATE (ex_env%bse_w_matrix_MO(1, 1))
239 ALLOCATE (ex_env%bse_a_matrix_MO(1, 1))
240 CALL cp_fm_create(ex_env%bse_w_matrix_MO(1, 1), fm_struct_w)
241 CALL cp_fm_create(ex_env%bse_a_matrix_MO(1, 1), fm_struct_a)
242 CALL cp_fm_to_fm(fm_w, ex_env%bse_w_matrix_MO(1, 1))
243 IF (tddfpt_control%do_bse_w_only) THEN
244 CALL cp_fm_to_fm(fm_a_copy, ex_env%bse_a_matrix_MO(1, 1))
245 ELSE
246 CALL cp_fm_to_fm(fm_a, ex_env%bse_a_matrix_MO(1, 1))
247 END IF
248 END IF
249 END IF
250 END IF
251 CALL cp_fm_release(fm_w)
252 CALL cp_fm_struct_release(fm_struct_w)
253 END IF
254 END DO
255
256 IF (unit_nr > 0 .AND. bse_env%bse_debug_print) THEN
257 WRITE (unit_nr, '(T2,A10,T13,A16)') 'BSE|DEBUG|', 'Allocated W_ijab'
258 END IF
259 IF (nspins == 1 .AND. tddfpt_control%do_bse_w_only) CALL cp_fm_release(fm_a_copy)
260
261 ! Get local row/col indices for direct diagonal access
262 CALL cp_fm_get_info(matrix=fm_a, nrow_local=nrow_local_a, ncol_local=ncol_local_a, &
263 row_indices=row_indices_a, col_indices=col_indices_a)
264
265 !Add (ε_a-ε_i) on the diagonal of each sigma-block; cross-spin blocks have no ε contribution.
266 IF (.NOT. tddfpt_control%do_bse) THEN
267 DO ii = 1, nrow_local_a
268 i_row_global = row_indices_a(ii)
269 DO jj = 1, ncol_local_a
270 j_col_global = col_indices_a(jj)
271 IF (i_row_global == j_col_global) THEN
272 ! Decode spin: isp such that i_row_global in [offsets(isp)+1, offsets(isp)+n_ov(isp)]
273 isp = nspins
274 DO k_isp = 1, nspins - 1
275 IF (i_row_global <= offsets(k_isp) + n_ov(k_isp)) THEN
276 isp = k_isp
277 EXIT
278 END IF
279 END DO
280 k_ov = i_row_global - offsets(isp)
281 i_occ_row = occ_of_ia(k_ov, virtual(isp))
282 a_virt_row = virt_of_ia(k_ov, virtual(isp))
283 eigen_diff = eigenval(eig_offsets(isp) + a_virt_row + homo(isp)) - &
284 eigenval(eig_offsets(isp) + i_occ_row)
285 fm_a%local_data(ii, jj) = fm_a%local_data(ii, jj) + eigen_diff
286 END IF
287 END DO
288 END DO
289 END IF
290
291 ! GW eigenvalue stash for TDDFPT path (closed-shell only)
292 IF (nspins == 1) THEN
293 IF (tddfpt_control%do_bse .OR. tddfpt_control%do_bse_w_only .OR. &
294 tddfpt_control%do_bse_gw_only) THEN
295 sizeeigen = SIZE(eigenval)
296 ALLOCATE (ex_env%gw_eigen(sizeeigen))
297 ex_env%gw_eigen(:) = eigenval(:)
298 END IF
299 END IF
300
301 CALL cp_fm_struct_release(fm_struct_a)
302 DEALLOCATE (n_ov, offsets, eig_offsets)
303
304 CALL cp_blacs_env_release(blacs_env)
305
306 CALL timestop(handle)
307
308 END SUBROUTINE create_a
309
310! **************************************************************************************************
311!> \brief Matrix B constructed from 3c-B-matrices (cf. subroutine screen_slabs)
312!> B_ia,jb = α * v_ia,jb - W_ib,aj
313!> α is a spin-dependent factor
314!> v_ia,jb = \sum_P B^P_ia B^P_jb (unscreened Coulomb interaction)
315!> W_ib,aj = \sum_P \bar{B}^P_ib B^P_aj (screened Coulomb interaction)
316!> \param fm_S_ia ...
317!> \param fm_S_bar_ia ...
318!> \param fm_B ...
319!> \param homo ...
320!> \param virtual ...
321!> \param dimen_RI ...
322!> \param unit_nr ...
323!> \param bse_env the BSE environment (settings)
324! **************************************************************************************************
325 SUBROUTINE create_b(fm_S_ia, fm_S_bar_ia, fm_B, &
326 homo, virtual, dimen_RI, unit_nr, bse_env)
327
328 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: fm_s_ia, fm_s_bar_ia
329 TYPE(cp_fm_type), INTENT(INOUT) :: fm_b
330 INTEGER, DIMENSION(:), INTENT(IN) :: homo, virtual
331 INTEGER, INTENT(IN) :: dimen_ri, unit_nr
332 TYPE(bse_env_type), INTENT(IN) :: bse_env
333
334 CHARACTER(LEN=*), PARAMETER :: routinen = 'create_B'
335
336 INTEGER :: handle, isp, n_ov_joint, nspins
337 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_ov, offsets
338 INTEGER, DIMENSION(4) :: reordering
339 REAL(kind=dp) :: alpha, alpha_screening
340 TYPE(cp_fm_struct_type), POINTER :: fm_struct_b, fm_struct_s_joint, &
341 fm_struct_w
342 TYPE(cp_fm_type) :: fm_s_joint, fm_w
343
344 CALL timeset(routinen, handle)
345
346 nspins = SIZE(homo)
347 ALLOCATE (n_ov(nspins), offsets(nspins))
348 CALL get_bse_spin_block_layout(homo, virtual, n_ov, offsets, n_ov_joint)
349
350 IF (unit_nr > 0 .AND. bse_env%bse_debug_print) THEN
351 WRITE (unit_nr, '(T2,A10,T13,A10)') 'BSE|DEBUG|', 'Creating B'
352 END IF
353
354 ! Coulomb prefactor: SPIN_CONFIG sector for closed shell; for open shell each spin block
355 ! contributes once (alpha=1). create_A already emits the SPIN_CONFIG-ignored warning.
356 SELECT CASE (bse_env%bse_spin_config)
357 CASE (bse_singlet)
358 alpha = 2.0_dp
359 CASE (bse_triplet)
360 alpha = 0.0_dp
361 END SELECT
362 IF (nspins > 1) alpha = 1.0_dp
363
364 IF (bse_env%screening_method == bse_screening_alpha) THEN
365 alpha_screening = bse_env%screening_factor
366 ELSE
367 alpha_screening = 1.0_dp
368 END IF
369
370 ! Joint B over all spin blocks: B_ia,jb = alpha*(ia|bj) - W^sigma_ib,aj (W spin-diagonal)
371 NULLIFY (fm_struct_b)
372 CALL cp_fm_struct_create(fm_struct_b, context=fm_s_ia(1)%matrix_struct%context, &
373 nrow_global=n_ov_joint, ncol_global=n_ov_joint, &
374 para_env=fm_s_ia(1)%matrix_struct%para_env)
375 CALL cp_fm_create(fm_b, fm_struct_b, name="fm_B_iajb")
376 CALL cp_fm_set_all(fm_b, 0.0_dp)
377
378 ! Coulomb v_ia,jb = sum_P B^P_ia B^P_jb (= (ia|bj)); cross-spin blocks filled automatically.
379 IF (nspins > 1) THEN
380 NULLIFY (fm_struct_s_joint)
381 CALL cp_fm_struct_create(fm_struct_s_joint, &
382 context=fm_s_ia(1)%matrix_struct%context, &
383 nrow_global=dimen_ri, ncol_global=n_ov_joint, &
384 para_env=fm_s_ia(1)%matrix_struct%para_env)
385 CALL cp_fm_create(fm_s_joint, fm_struct_s_joint, name="fm_S_ia_joint")
386 CALL cp_fm_set_all(fm_s_joint, 0.0_dp)
387 CALL assemble_joint_ov_slab(fm_s_ia, offsets, n_ov, dimen_ri, fm_s_joint)
388 CALL parallel_gemm(transa="T", transb="N", m=n_ov_joint, n=n_ov_joint, k=dimen_ri, &
389 alpha=alpha, matrix_a=fm_s_joint, matrix_b=fm_s_joint, beta=0.0_dp, &
390 matrix_c=fm_b)
391 CALL cp_fm_release(fm_s_joint)
392 CALL cp_fm_struct_release(fm_struct_s_joint)
393 ELSE
394 CALL parallel_gemm(transa="T", transb="N", m=homo(1)*virtual(1), n=homo(1)*virtual(1), &
395 k=dimen_ri, alpha=alpha, &
396 matrix_a=fm_s_ia(1), matrix_b=fm_s_ia(1), &
397 beta=0.0_dp, matrix_c=fm_b)
398 END IF
399
400 IF (unit_nr > 0 .AND. bse_env%bse_debug_print) THEN
401 WRITE (unit_nr, '(T2,A10,T13,A16)') 'BSE|DEBUG|', 'Allocated B_iajb'
402 END IF
403
404 ! W^sigma_ib,aj = sum_P barB^P_ib B^P_aj on sigma-diagonal blocks only (offsets place them).
405 ! reordering [1,4,3,2] maps W_ib,ja -> B_ia,jb. For nspins=1: offsets(1)=0 (original code).
406 IF (bse_env%screening_method /= bse_screening_rpa) THEN
407 DO isp = 1, nspins
408 NULLIFY (fm_struct_w)
409 CALL cp_fm_struct_create(fm_struct_w, &
410 context=fm_s_ia(isp)%matrix_struct%context, &
411 nrow_global=homo(isp)*virtual(isp), &
412 ncol_global=homo(isp)*virtual(isp), &
413 para_env=fm_s_ia(isp)%matrix_struct%para_env)
414 CALL cp_fm_create(fm_w, fm_struct_w, name="fm_W_ibaj")
415 CALL cp_fm_set_all(fm_w, 0.0_dp)
416 CALL parallel_gemm(transa="T", transb="N", m=homo(isp)*virtual(isp), &
417 n=homo(isp)*virtual(isp), k=dimen_ri, alpha=alpha_screening, &
418 matrix_a=fm_s_bar_ia(isp), matrix_b=fm_s_ia(isp), &
419 beta=0.0_dp, matrix_c=fm_w)
420 reordering = [1, 4, 3, 2]
421 CALL cp_fm_permute(fm_b, fm_w, -1.0_dp, virtual(isp), virtual(isp), virtual(isp), virtual(isp), &
422 reordering, row_offset=offsets(isp), col_offset=offsets(isp))
423 CALL cp_fm_release(fm_w)
424 CALL cp_fm_struct_release(fm_struct_w)
425 END DO
426 END IF
427
428 CALL cp_fm_struct_release(fm_struct_b)
429 DEALLOCATE (n_ov, offsets)
430
431 CALL timestop(handle)
432
433 END SUBROUTINE create_b
434
435! **************************************************************************************************
436!> \brief Explicit A, and B for ABBA, from the slabs the screening method contracts: the bare ones for
437!> TDHF and ALPHA screening, the W-multiplied ones otherwise
438!> \param fm_S_ia ...
439!> \param fm_S_ij ...
440!> \param fm_S_ab ...
441!> \param fm_S_bar_ia ...
442!> \param fm_S_bar_ij ...
443!> \param fm_A ...
444!> \param fm_B created only for ABBA
445!> \param do_abba ...
446!> \param Eigenval ...
447!> \param unit_nr ...
448!> \param homo ...
449!> \param virtual ...
450!> \param dimen_RI ...
451!> \param bse_env the BSE environment (settings)
452! **************************************************************************************************
453 SUBROUTINE create_a_and_b(fm_S_ia, fm_S_ij, fm_S_ab, fm_S_bar_ia, &
454 fm_S_bar_ij, fm_A, fm_B, do_abba, Eigenval, unit_nr, &
455 homo, virtual, dimen_RI, bse_env)
456
457 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: fm_s_ia, fm_s_ij, fm_s_ab, fm_s_bar_ia, &
458 fm_s_bar_ij
459 TYPE(cp_fm_type), INTENT(INOUT) :: fm_a, fm_b
460 LOGICAL, INTENT(IN) :: do_abba
461 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: eigenval
462 INTEGER, INTENT(IN) :: unit_nr
463 INTEGER, DIMENSION(:), INTENT(IN) :: homo, virtual
464 INTEGER, INTENT(IN) :: dimen_ri
465 TYPE(bse_env_type), INTENT(IN) :: bse_env
466
467 ! RPA skips the W term; TDHF and ALPHA use the bare slabs.
468 IF (bse_env%screening_method /= bse_screening_w0) THEN
469 CALL create_a(fm_s_ia, fm_s_ij, fm_s_ab, fm_a, eigenval, unit_nr, &
470 homo, virtual, dimen_ri, bse_env)
471 IF (do_abba) THEN
472 CALL create_b(fm_s_ia, fm_s_ia, fm_b, homo, virtual, dimen_ri, unit_nr, &
473 bse_env)
474 END IF
475 ELSE
476 CALL create_a(fm_s_ia, fm_s_bar_ij, fm_s_ab, fm_a, eigenval, unit_nr, &
477 homo, virtual, dimen_ri, bse_env)
478 IF (do_abba) THEN
479 CALL create_b(fm_s_ia, fm_s_bar_ia, fm_b, homo, virtual, dimen_ri, unit_nr, &
480 bse_env)
481 END IF
482 END IF
483
484 END SUBROUTINE create_a_and_b
485
486! **************************************************************************************************
487!> \brief Form C = sqrt(Δ) (Δ + 2 B) sqrt(Δ) in place for RPA, where A-B = diag(Δ).
488!> \param fm_C RPA coupling matrix B on entry; squared excitation matrix C on exit.
489!> \param gap Positive occupied-virtual energy differences Δ.
490! **************************************************************************************************
491 SUBROUTINE create_hermitian_form_rpa(fm_C, gap)
492 TYPE(cp_fm_type), INTENT(INOUT) :: fm_c
493 REAL(kind=dp), DIMENSION(:), INTENT(IN) :: gap
494
495 CHARACTER(LEN=*), PARAMETER :: routinen = 'create_hermitian_form_rpa'
496
497 INTEGER :: handle, icol, irow, ncol_local, &
498 nrow_local
499 INTEGER, DIMENSION(:), POINTER :: col_indices, row_indices
500
501 CALL timeset(routinen, handle)
502
503 IF (minval(gap) <= 0.0_dp) cpabort("RPA requires positive occupied-virtual energy differences")
504 CALL cp_fm_scale(2.0_dp, fm_c)
505 CALL cp_fm_get_info(fm_c, nrow_local=nrow_local, ncol_local=ncol_local, &
506 row_indices=row_indices, col_indices=col_indices)
507 DO icol = 1, ncol_local
508 DO irow = 1, nrow_local
509 IF (row_indices(irow) == col_indices(icol)) THEN
510 fm_c%local_data(irow, icol) = fm_c%local_data(irow, icol) + gap(row_indices(irow))
511 END IF
512 END DO
513 END DO
514 CALL cp_fm_column_scale(fm_c, sqrt(gap))
515 CALL cp_fm_row_scale(fm_c, sqrt(gap))
516
517 CALL timestop(handle)
518
519 END SUBROUTINE create_hermitian_form_rpa
520
521 ! **************************************************************************************************
522!> \brief Construct C = U (A+B) U^T with A-B = U^T U (U upper Cholesky factor) to solve the full
523!> BSE as a hermitian problem; C is similar to (A-B)(A+B) and has eigenvalues Ω_n^2.
524!> Any factor M with A-B = M M^T works in Eq. (A7) of F. Furche, J. Chem. Phys. 114, 5982 (2001);
525!> here M = U^T; U and A+B are kept for the back-transform of Eq. (A10).
526!> \param fm_A matrix A
527!> \param fm_B matrix B
528!> \param fm_C on exit C = U (A+B) U^T
529!> \param fm_chol_A_minus_B on exit the upper Cholesky factor U of A-B, zero below the diagonal
530!> \param fm_A_plus_B on exit A+B
531!> \param unit_nr output unit
532!> \param bse_env the BSE environment (settings)
533! **************************************************************************************************
534 SUBROUTINE create_hermitian_form_of_abba(fm_A, fm_B, fm_C, fm_chol_A_minus_B, fm_A_plus_B, unit_nr, bse_env)
535
536 TYPE(cp_fm_type), INTENT(IN) :: fm_a, fm_b
537 TYPE(cp_fm_type), INTENT(INOUT) :: fm_c, fm_chol_a_minus_b, fm_a_plus_b
538 INTEGER, INTENT(IN) :: unit_nr
539 TYPE(bse_env_type), INTENT(IN) :: bse_env
540
541 CHARACTER(LEN=*), PARAMETER :: routinen = 'create_hermitian_form_of_ABBA'
542
543 INTEGER :: chol_info, dim_mat, handle
544 REAL(kind=dp), ALLOCATABLE :: chol_pivot(:), diag_b(:), gap(:)
545 TYPE(cp_fm_type) :: fm_work
546
547 CALL timeset(routinen, handle)
548
549 CALL cp_fm_create(fm_a_plus_b, fm_a%matrix_struct)
550 CALL cp_fm_to_fm(fm_a, fm_a_plus_b)
551 CALL cp_fm_scale_and_add(1.0_dp, fm_a_plus_b, 1.0_dp, fm_b)
552
553 IF (bse_env%screening_method == bse_screening_rpa) THEN
554 ! In RPA, A-B is diagonal, so its Cholesky factor is the diagonal sqrt(Δ)
555 CALL cp_fm_get_info(fm_a, nrow_global=dim_mat)
556 ALLOCATE (gap(dim_mat), diag_b(dim_mat))
557 CALL cp_fm_get_diag(fm_a, gap)
558 CALL cp_fm_get_diag(fm_b, diag_b)
559 gap(:) = gap(:) - diag_b(:)
560 CALL cp_fm_create(fm_c, fm_b%matrix_struct)
561 CALL cp_fm_to_fm(fm_b, fm_c)
562 CALL create_hermitian_form_rpa(fm_c, gap)
563 ! diagonal A-B: U = diag(sqrt(Δ)), so C = sqrt(Δ) (A+B) sqrt(Δ)
564 CALL cp_fm_create(fm_chol_a_minus_b, fm_a%matrix_struct)
565 CALL cp_fm_set_all(fm_chol_a_minus_b, 0.0_dp, 1.0_dp)
566 CALL cp_fm_column_scale(fm_chol_a_minus_b, sqrt(gap))
567 IF (unit_nr > 0) THEN
568 WRITE (unit_nr, '(T2,A4,T7,A,T65,F16.6)') 'BSE|', &
569 'Smallest eigenvalue of A-B (eV)', minval(gap)*evolt
570 END IF
571 DEALLOCATE (gap, diag_b)
572 CALL timestop(handle)
573 RETURN
574 END IF
575
576 ! Final result: C = U (A+B) U^T EQ.I
577 ! \_/ \___/ \_/
578 ! fm_chol_A_minus_B fm_A_plus_B fm_chol_A_minus_B
579 ! (EQ.Ia) (EQ.Ib) (EQ.Ia)
580 ! with the upper Cholesky factor U of A-B = U^T U (EQ.Ia) and A+B built above (EQ.Ib).
581 ! Intermediate work matrix:
582 ! fm_work: A-B, overwritten by its factorization, then the product U (A+B) EQ.II
583 ! A-B = U^T U; the Cholesky factorization fails when A-B is not positive definite
584 CALL cp_fm_create(fm_work, fm_a%matrix_struct)
585 CALL cp_fm_to_fm(fm_a, fm_work)
586 CALL cp_fm_scale_and_add(1.0_dp, fm_work, -1.0_dp, fm_b)
587 CALL cp_fm_cholesky_decompose(fm_work, info_out=chol_info)
588 IF (chol_info /= 0) THEN
589 CALL cp_abort(__location__, &
590 "Matrix (A-B) is not positive definite. "// &
591 "Hermitian diagonalization of full ABBA matrix is ill-defined.")
592 END IF
593 ! the factorization leaves A-B in the strict lower part; a zero there lets U enter plain GEMMs
594 CALL cp_fm_create(fm_chol_a_minus_b, fm_a%matrix_struct)
595 CALL cp_fm_set_all(fm_chol_a_minus_b, 0.0_dp)
596 CALL cp_fm_to_fm_triangular(fm_work, fm_chol_a_minus_b, "U")
597
598 ! each U_ii^2 is a Schur complement of A-B, so min_i U_ii^2 >= smallest eigenvalue of A-B
599 CALL cp_fm_get_info(fm_a, nrow_global=dim_mat)
600 ALLOCATE (chol_pivot(dim_mat))
601 CALL cp_fm_get_diag(fm_chol_a_minus_b, chol_pivot)
602 IF (unit_nr > 0) THEN
603 WRITE (unit_nr, '(T2,A4,T7,A,T65,F16.6)') 'BSE|', &
604 'Upper bound to smallest eigenvalue of A-B (eV)', minval(chol_pivot**2)*evolt
605 END IF
606 DEALLOCATE (chol_pivot)
607
608 ! C = U (A+B) U^T by two GEMMs
609 CALL cp_fm_create(fm_c, fm_a%matrix_struct)
610 CALL parallel_gemm("N", "N", dim_mat, dim_mat, dim_mat, 1.0_dp, fm_chol_a_minus_b, fm_a_plus_b, 0.0_dp, fm_work)
611 CALL parallel_gemm("N", "T", dim_mat, dim_mat, dim_mat, 1.0_dp, fm_work, fm_chol_a_minus_b, 0.0_dp, fm_c)
612 CALL cp_fm_release(fm_work)
613
614 IF (unit_nr > 0 .AND. bse_env%bse_debug_print) THEN
615 WRITE (unit_nr, '(T2,A10,T13,A)') 'BSE|DEBUG|', 'Filled C=U (A+B) U^T with A-B=U^T U'
616 END IF
617
618 CALL timestop(handle)
619 END SUBROUTINE create_hermitian_form_of_abba
620
621! **************************************************************************************************
622!> \brief Solving eigenvalue equation C Z^n = (Ω^n)^2 Z^n .
623!> Here, the eigenvectors Z^n relate to X^n via
624!> Eq. (A10) in F. Furche J. Chem. Phys., Vol. 114, No. 14, (2001).
625!> \param fm_C ...
626!> \param homo ...
627!> \param virtual ...
628!> \param homo_irred ...
629!> \param fm_chol_A_minus_B upper Cholesky factor U of A-B = U^T U; deallocated on exit
630!> \param fm_A_plus_B A+B; deallocated on exit
631!> \param unit_nr ...
632!> \param diag_est ...
633!> \param bse_env the BSE environment (settings, and the state the post-processing reads)
634!> \param mo_coeff ...
635! **************************************************************************************************
636 SUBROUTINE diagonalize_c(fm_C, homo, virtual, homo_irred, fm_chol_A_minus_B, fm_A_plus_B, &
637 unit_nr, diag_est, bse_env, mo_coeff)
638
639 TYPE(cp_fm_type), INTENT(INOUT) :: fm_c
640 INTEGER, DIMENSION(:), INTENT(IN) :: homo, virtual, homo_irred
641 TYPE(cp_fm_type), INTENT(INOUT) :: fm_chol_a_minus_b, fm_a_plus_b
642 INTEGER, INTENT(IN) :: unit_nr
643 REAL(kind=dp), INTENT(IN) :: diag_est
644 TYPE(bse_env_type), INTENT(IN) :: bse_env
645 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: mo_coeff
646
647 CHARACTER(LEN=*), PARAMETER :: routinen = 'diagonalize_C'
648
649 INTEGER :: diag_info, handle, n_ov_joint, nspins
650 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: exc_ens
651 TYPE(cp_fm_type) :: fm_eigvec_x, fm_eigvec_y, fm_eigvec_z, &
652 fm_mat_eigvec_transform_diff, &
653 fm_mat_eigvec_transform_sum
654
655 CALL timeset(routinen, handle)
656
657 nspins = SIZE(homo)
658 n_ov_joint = sum(homo*virtual)
659
660 IF (unit_nr > 0) THEN
661 WRITE (unit_nr, '(T2,A4,T7,A17,A22,ES6.0,A3)') 'BSE|', 'Diagonalizing C. ', &
662 'This will take around ', diag_est, ' s.'
663 END IF
664
665 !We have now the full matrix C=U (A+B) U^T
666 !Now: Diagonalize it
667 CALL cp_fm_create(fm_eigvec_z, fm_c%matrix_struct)
668
669 ALLOCATE (exc_ens(n_ov_joint))
670
671 CALL choose_eigv_solver(fm_c, fm_eigvec_z, exc_ens, diag_info)
672
673 IF (diag_info /= 0) THEN
674 CALL cp_abort(__location__, &
675 "Diagonalization of C=U (A+B) U^T failed in BSE")
676 END IF
677
678 ! C could have negative eigenvalues, since we do not explicitly check A+B
679 ! for positive definiteness (would make another O(N^6) Diagon. necessary)
680 ! Instead, we include a check here
681 IF (exc_ens(1) < 0) THEN
682 IF (unit_nr > 0) THEN
683 CALL cp_abort(__location__, &
684 "Matrix C=U (A+B) U^T has negative eigenvalues, i.e. "// &
685 "(A+B) is not positive definite.")
686 END IF
687 END IF
688 exc_ens = sqrt(exc_ens)
689
690 ! Prepare eigenvector for interpretation of singleparticle transitions
691 ! Compare: F. Furche J. Chem. Phys., Vol. 114, No. 14, (2001)
692 ! We aim for the upper part of the vector (X,Y) for a direct comparison with the TDA result
693
694 ! Following Furche, we basically use Eqs. (A10): First, we multiply
695 ! the factor of A-B with eigenvectors and then the eigenvalues
696 ! One has to be careful about the index structure, since the eigenvector matrix is not symmetric anymore!
697
698 ! First, Eq. I from (A10) from Furche with (A-B)^0.5 -> U^T: (X+Y)_n = (Ω_n)^-0.5 U^T T_n
699 CALL cp_fm_create(fm_mat_eigvec_transform_sum, fm_c%matrix_struct)
700 CALL cp_fm_set_all(fm_mat_eigvec_transform_sum, 0.0_dp)
701 CALL parallel_gemm(transa="T", transb="N", m=n_ov_joint, n=n_ov_joint, k=n_ov_joint, alpha=1.0_dp, &
702 matrix_a=fm_chol_a_minus_b, matrix_b=fm_eigvec_z, beta=0.0_dp, &
703 matrix_c=fm_mat_eigvec_transform_sum)
704 CALL cp_fm_release(fm_chol_a_minus_b)
705 CALL cp_fm_release(fm_eigvec_z)
706 ! This normalizes the eigenvectors
707 CALL comp_eigvec_coeff_bse(fm_mat_eigvec_transform_sum, exc_ens, -0.5_dp, gamma=2.0_dp, do_transpose=.true.)
708
709 ! Second, Eq. II from (A10) from Furche, (X-Y)_n = (Ω_n)^0.5 U^-1 T_n, taken from
710 ! (A+B)(X+Y)_n = Ω_n (X-Y)_n, so no inverse of U is needed
711 CALL cp_fm_create(fm_mat_eigvec_transform_diff, fm_c%matrix_struct)
712 CALL cp_fm_set_all(fm_mat_eigvec_transform_diff, 0.0_dp)
713 CALL parallel_gemm(transa="N", transb="N", m=n_ov_joint, n=n_ov_joint, k=n_ov_joint, alpha=1.0_dp, &
714 matrix_a=fm_a_plus_b, matrix_b=fm_mat_eigvec_transform_sum, beta=0.0_dp, &
715 matrix_c=fm_mat_eigvec_transform_diff)
716 CALL cp_fm_release(fm_a_plus_b)
717
718 ! This normalizes the eigenvectors; the factor Ω_n^-1 carries the normalization of (X+Y)_n
719 CALL comp_eigvec_coeff_bse(fm_mat_eigvec_transform_diff, exc_ens, -1.0_dp, gamma=1.0_dp, do_transpose=.true.)
720
721 ! Now, we add the two equations to obtain X_n
722 ! Add overwrites the first argument, therefore we copy it beforehand
723 CALL cp_fm_create(fm_eigvec_x, fm_c%matrix_struct)
724 CALL cp_fm_to_fm(fm_mat_eigvec_transform_sum, fm_eigvec_x)
725 CALL cp_fm_scale_and_add(1.0_dp, fm_eigvec_x, 1.0_dp, fm_mat_eigvec_transform_diff)
726
727 ! Now, we subtract the two equations to obtain Y_n
728 ! Add overwrites the first argument, therefore we copy it beforehand
729 CALL cp_fm_create(fm_eigvec_y, fm_c%matrix_struct)
730 CALL cp_fm_to_fm(fm_mat_eigvec_transform_sum, fm_eigvec_y)
731 CALL cp_fm_scale_and_add(1.0_dp, fm_eigvec_y, -1.0_dp, fm_mat_eigvec_transform_diff)
732
733 !Cleanup
734 CALL cp_fm_release(fm_mat_eigvec_transform_diff)
735 CALL cp_fm_release(fm_mat_eigvec_transform_sum)
736
737 IF (nspins == 1) THEN
738 CALL postprocess_bse(exc_ens, fm_eigvec_x, bse_env, mo_coeff, &
739 homo(1), virtual(1), homo_irred(1), unit_nr, &
740 .false., fm_eigvec_y)
741 ELSE
742 ! Open-shell ABBA: helper forms X+Y internally and prints amplitudes (X and Y).
743 CALL bse_open_shell_optical(exc_ens, fm_eigvec_x, homo, virtual, homo_irred, &
744 .false., mo_coeff, bse_env, unit_nr, fm_eigvec_y)
745 END IF
746
747 DEALLOCATE (exc_ens)
748 CALL cp_fm_release(fm_eigvec_x)
749 CALL cp_fm_release(fm_eigvec_y)
750
751 CALL timestop(handle)
752
753 END SUBROUTINE diagonalize_c
754
755! **************************************************************************************************
756!> \brief Solving hermitian eigenvalue equation A X^n = Ω^n X^n
757!> \param fm_A ...
758!> \param homo ...
759!> \param virtual ...
760!> \param homo_irred ...
761!> \param unit_nr ...
762!> \param diag_est ...
763!> \param bse_env the BSE environment (settings, and the state the post-processing reads)
764!> \param mo_coeff ...
765! **************************************************************************************************
766 SUBROUTINE diagonalize_a(fm_A, homo, virtual, homo_irred, &
767 unit_nr, diag_est, bse_env, mo_coeff)
768
769 TYPE(cp_fm_type), INTENT(INOUT) :: fm_a
770 INTEGER, DIMENSION(:), INTENT(IN) :: homo, virtual, homo_irred
771 INTEGER, INTENT(IN) :: unit_nr
772 REAL(kind=dp), INTENT(IN) :: diag_est
773 TYPE(bse_env_type), INTENT(IN) :: bse_env
774 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: mo_coeff
775
776 CHARACTER(LEN=*), PARAMETER :: routinen = 'diagonalize_A'
777
778 INTEGER :: diag_info, handle, n_ov_joint, nspins
779 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: exc_ens
780 TYPE(cp_fm_type) :: fm_eigvec
781
782 CALL timeset(routinen, handle)
783
784 nspins = SIZE(homo)
785 n_ov_joint = sum(homo*virtual)
786
787 IF (unit_nr > 0) THEN
788 WRITE (unit_nr, '(T2,A4,T7,A17,A22,ES6.0,A3)') 'BSE|', 'Diagonalizing A. ', &
789 'This will take around ', diag_est, ' s.'
790 END IF
791
792 CALL cp_fm_create(fm_eigvec, fm_a%matrix_struct)
793
794 ALLOCATE (exc_ens(n_ov_joint))
795
796 CALL choose_eigv_solver(fm_a, fm_eigvec, exc_ens, diag_info)
797
798 IF (diag_info /= 0) THEN
799 CALL cp_abort(__location__, &
800 "Diagonalization of A failed in TDA-BSE")
801 END IF
802
803 IF (nspins == 1) THEN
804 CALL postprocess_bse(exc_ens, fm_eigvec, bse_env, mo_coeff, &
805 homo(1), virtual(1), homo_irred(1), unit_nr, .true.)
806 ELSE
807 CALL bse_open_shell_optical(exc_ens, fm_eigvec, homo, virtual, homo_irred, &
808 .true., mo_coeff, bse_env, unit_nr)
809 END IF
810
811 CALL cp_fm_release(fm_eigvec)
812 DEALLOCATE (exc_ens)
813
814 CALL timestop(handle)
815
816 END SUBROUTINE diagonalize_a
817
818! **************************************************************************************************
819!> \brief Open-shell (UKS) spin-summed post-processing for the joint spin-block space: joint
820!> excitation energies, per-spin transition amplitudes, and oscillator strengths. Mirrors
821!> postprocess_bse but spin-summed; exciton descriptors and NTOs are not yet implemented (CPWARN).
822!> \param Exc_ens joint excitation energies
823!> \param fm_eigvec_X joint X eigenvectors (excitations)
824!> \param homo per-spin reduced/active occupied counts
825!> \param virtual per-spin reduced/active virtual counts
826!> \param homo_irred per-spin full occupied counts (absolute-MO labels; N_e = sum)
827!> \param flag_tda .TRUE. -> TDA (coeff=X), .FALSE. -> ABBA (coeff=X+Y)
828!> \param mo_coeff per-spin MO coefficients
829!> \param bse_env the BSE environment (settings; the AO dipoles, mos)
830!> \param unit_nr ...
831!> \param fm_eigvec_Y joint Y eigenvectors (deexcitations; ABBA only)
832! **************************************************************************************************
833 SUBROUTINE bse_open_shell_optical(Exc_ens, fm_eigvec_X, homo, virtual, homo_irred, &
834 flag_tda, mo_coeff, bse_env, unit_nr, fm_eigvec_Y)
835
836 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: exc_ens
837 TYPE(cp_fm_type), INTENT(IN) :: fm_eigvec_x
838 INTEGER, DIMENSION(:), INTENT(IN) :: homo, virtual, homo_irred
839 LOGICAL, INTENT(IN) :: flag_tda
840 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: mo_coeff
841 TYPE(bse_env_type), INTENT(IN) :: bse_env
842 INTEGER, INTENT(IN) :: unit_nr
843 TYPE(cp_fm_type), INTENT(IN), OPTIONAL :: fm_eigvec_y
844
845 CHARACTER(LEN=*), PARAMETER :: routinen = 'bse_open_shell_optical'
846
847 CHARACTER(LEN=10) :: info_approximation, multiplet
848 INTEGER :: handle, idir, isp, jdir, n, n_ov_joint, &
849 nspins
850 INTEGER, ALLOCATABLE, DIMENSION(:) :: n_ov_sp, offsets_sp
851 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: oscill_str_joint
852 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: pol_res_joint, trans_mom_joint
853 TYPE(cp_fm_struct_type), POINTER :: fm_struct_dip_reord, fm_struct_sp, &
854 fm_struct_tmom
855 TYPE(cp_fm_type) :: fm_dip_reord_sp, fm_eigvec_sp, &
856 fm_trans_coeff
857 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_dip_ab_sp, fm_dip_ai_sp, fm_dip_ij_sp
858 TYPE(cp_fm_type), DIMENSION(3) :: fm_trans_mom_joint
859
860 CALL timeset(routinen, handle)
861
862 nspins = SIZE(homo)
863 ALLOCATE (n_ov_sp(nspins), offsets_sp(nspins))
864 CALL get_bse_spin_block_layout(homo, virtual, n_ov_sp, offsets_sp, n_ov_joint)
865
866 ! LEN=10 locals auto-pad short literals with spaces (avoids the L-15 short-literal trap);
867 ! print_excitation_energies prints A6 of these, print_optical_properties prints them as-is.
868 multiplet = "UKS"
869 IF (flag_tda) THEN
870 info_approximation = " -TDA- "
871 ELSE
872 info_approximation = "-ABBA-"
873 END IF
874
875 IF (unit_nr > 0) THEN
876 WRITE (unit_nr, '(T2,A4,T7,A43)') 'BSE|', 'Joint open-shell BSE excitation energies:'
877 END IF
878 CALL print_excitation_energies(exc_ens, n_ov_joint, 1, flag_tda, multiplet, &
879 info_approximation, bse_env, unit_nr)
880
881 ! Per-spin single-particle transition amplitudes (X via =>, Y via <=).
882 CALL print_transition_amplitudes(fm_eigvec_x, homo, virtual, homo_irred, &
883 info_approximation, bse_env, unit_nr, fm_eigvec_y)
884
885 ! Transition coefficient for the spin-summed moment: X (TDA) or X+Y (ABBA).
886 CALL cp_fm_create(fm_trans_coeff, fm_eigvec_x%matrix_struct)
887 CALL cp_fm_to_fm(fm_eigvec_x, fm_trans_coeff)
888 IF (PRESENT(fm_eigvec_y)) CALL cp_fm_scale_and_add(1.0_dp, fm_trans_coeff, 1.0_dp, fm_eigvec_y)
889
890 ! Spin-summed transition moments: D^n_dir = sum_σ sum_{ia,σ} D^{dir,σ}_{ai} C_{ia,σ,n}
891 ! with C = X (TDA) or X+Y (ABBA); explicit spin sum, factor 1.0.
892 ALLOCATE (fm_dip_ai_sp(3), fm_dip_ij_sp(3), fm_dip_ab_sp(3))
893 ALLOCATE (oscill_str_joint(n_ov_joint), trans_mom_joint(3, 1, n_ov_joint))
894 ALLOCATE (pol_res_joint(3, 3, n_ov_joint))
895 trans_mom_joint(:, :, :) = 0.0_dp
896 NULLIFY (fm_struct_dip_reord, fm_struct_sp, fm_struct_tmom)
897 CALL cp_fm_struct_create(fm_struct_tmom, fm_trans_coeff%matrix_struct%para_env, &
898 fm_trans_coeff%matrix_struct%context, 1, n_ov_joint)
899 DO idir = 1, 3
900 CALL cp_fm_create(fm_trans_mom_joint(idir), fm_struct_tmom)
901 CALL cp_fm_set_all(fm_trans_mom_joint(idir), 0.0_dp)
902 END DO
903 DO isp = 1, nspins
904 CALL get_multipoles_mo(fm_dip_ai_sp, fm_dip_ij_sp, fm_dip_ab_sp, &
905 bse_env%matrix_dipole_ao, bse_env%mos, mo_coeff(isp:isp), &
906 homo(isp), virtual(isp), fm_trans_coeff%matrix_struct%context, &
907 ispin=isp)
908 NULLIFY (fm_struct_sp, fm_struct_dip_reord)
909 CALL cp_fm_struct_create(fm_struct_sp, fm_trans_coeff%matrix_struct%para_env, &
910 fm_trans_coeff%matrix_struct%context, n_ov_sp(isp), n_ov_joint)
911 CALL cp_fm_create(fm_eigvec_sp, fm_struct_sp)
912 CALL cp_fm_set_all(fm_eigvec_sp, 0.0_dp)
913 CALL cp_fm_to_fm_submat(fm_trans_coeff, fm_eigvec_sp, n_ov_sp(isp), n_ov_joint, &
914 offsets_sp(isp) + 1, 1, 1, 1)
915 CALL cp_fm_struct_create(fm_struct_dip_reord, fm_trans_coeff%matrix_struct%para_env, &
916 fm_trans_coeff%matrix_struct%context, 1, n_ov_sp(isp))
917 DO idir = 1, 3
918 CALL cp_fm_create(fm_dip_reord_sp, fm_struct_dip_reord, name="bse_dip_reord")
919 CALL cp_fm_set_all(fm_dip_reord_sp, 0.0_dp)
920 CALL cp_fm_permute(fm_dip_reord_sp, fm_dip_ai_sp(idir), 1.0_dp, 1, 1, 1, virtual(isp), [2, 4, 3, 1])
921 CALL parallel_gemm('N', 'N', 1, n_ov_joint, n_ov_sp(isp), 1.0_dp, &
922 fm_dip_reord_sp, fm_eigvec_sp, 1.0_dp, fm_trans_mom_joint(idir))
923 CALL cp_fm_release(fm_dip_reord_sp)
924 CALL cp_fm_release(fm_dip_ai_sp(idir))
925 CALL cp_fm_release(fm_dip_ij_sp(idir))
926 CALL cp_fm_release(fm_dip_ab_sp(idir))
927 END DO
928 CALL cp_fm_release(fm_eigvec_sp)
929 CALL cp_fm_struct_release(fm_struct_sp)
930 NULLIFY (fm_struct_sp)
931 CALL cp_fm_struct_release(fm_struct_dip_reord)
932 NULLIFY (fm_struct_dip_reord)
933 END DO
934 DO idir = 1, 3
935 CALL cp_fm_get_submatrix(fm_trans_mom_joint(idir), trans_mom_joint(idir, :, :))
936 CALL cp_fm_release(fm_trans_mom_joint(idir))
937 END DO
938 CALL cp_fm_struct_release(fm_struct_tmom)
939 DO n = 1, n_ov_joint
940 DO idir = 1, 3
941 DO jdir = 1, 3
942 pol_res_joint(idir, jdir, n) = 2.0_dp*exc_ens(n)*trans_mom_joint(idir, 1, n) &
943 *trans_mom_joint(jdir, 1, n)
944 END DO
945 END DO
946 oscill_str_joint(n) = 2.0_dp/3.0_dp*exc_ens(n)*sum(abs(trans_mom_joint(:, 1, n))**2)
947 END DO
948 CALL print_optical_properties(exc_ens, oscill_str_joint, trans_mom_joint, pol_res_joint, &
949 n_ov_joint, 1, sum(homo_irred), flag_tda, info_approximation, &
950 bse_env, unit_nr, open_shell=.true.)
951 ! Open-shell post-processing is partial: energies, amplitudes, spin-summed oscillator strengths.
952 CALL cp_warn(__location__, &
953 "Open-shell (UKS) BSE: exciton descriptors and NTO analysis are not yet "// &
954 "implemented and have been skipped.")
955 CALL cp_fm_release(fm_trans_coeff)
956 DEALLOCATE (fm_dip_ai_sp, fm_dip_ij_sp, fm_dip_ab_sp)
957 DEALLOCATE (n_ov_sp, offsets_sp, oscill_str_joint, trans_mom_joint, pol_res_joint)
958
959 CALL timestop(handle)
960
961 END SUBROUTINE bse_open_shell_optical
962
963! **************************************************************************************************
964!> \brief Prints the success message (incl. energies) for full diag of BSE (TDA/full ABBA via flag)
965!> \param Exc_ens ...
966!> \param fm_eigvec_X ...
967!> \param bse_env the BSE environment (settings; the AO multipoles and their reference point, mos, subsys)
968!> \param mo_coeff ...
969!> \param homo ...
970!> \param virtual ...
971!> \param homo_irred ...
972!> \param unit_nr ...
973!> \param flag_TDA ...
974!> \param fm_eigvec_Y ...
975! **************************************************************************************************
976 SUBROUTINE postprocess_bse(Exc_ens, fm_eigvec_X, bse_env, mo_coeff, &
977 homo, virtual, homo_irred, unit_nr, &
978 flag_TDA, fm_eigvec_Y)
979
980 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: exc_ens
981 TYPE(cp_fm_type), INTENT(IN) :: fm_eigvec_x
982 TYPE(bse_env_type), INTENT(IN) :: bse_env
983 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: mo_coeff
984 INTEGER :: homo, virtual, homo_irred, unit_nr
985 LOGICAL, OPTIONAL :: flag_tda
986 TYPE(cp_fm_type), INTENT(IN), OPTIONAL :: fm_eigvec_y
987
988 CHARACTER(LEN=*), PARAMETER :: routinen = 'postprocess_bse'
989
990 CHARACTER(LEN=10) :: info_approximation, multiplet
991 INTEGER :: handle, i_exc, idir, n_moments_di, &
992 n_moments_quad
993 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: oscill_str, ref_point_multipole
994 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: polarizability_residues, trans_mom_bse
995 TYPE(cp_fm_type) :: fm_x_ia, fm_y_ia
996 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_dipole_ab_trunc, fm_dipole_ai_trunc, &
997 fm_dipole_ij_trunc, fm_quadpole_ab_trunc, fm_quadpole_ai_trunc, fm_quadpole_ij_trunc
998 TYPE(exciton_descr_type), ALLOCATABLE, &
999 DIMENSION(:) :: exc_descr
1000 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
1001
1002 CALL timeset(routinen, handle)
1003
1004 !Prepare variables for printing
1005 IF (bse_env%bse_spin_config == 0) THEN
1006 multiplet = "Singlet"
1007 ELSE
1008 multiplet = "Triplet"
1009 END IF
1010 IF (.NOT. PRESENT(flag_tda)) THEN
1011 flag_tda = .false.
1012 END IF
1013 IF (flag_tda) THEN
1014 info_approximation = " -TDA- "
1015 ELSE
1016 info_approximation = "-ABBA-"
1017 END IF
1018
1019 n_moments_di = 3
1020 n_moments_quad = 9
1021 ! Compute BSE dipoles and oscillator strengths - Keep in memory for later usage
1022 ! Need dipoles also for spatial expectation values, which are well-defined also for triplets
1023 ALLOCATE (fm_dipole_ij_trunc(n_moments_di))
1024 ALLOCATE (fm_dipole_ab_trunc(n_moments_di))
1025 ALLOCATE (fm_dipole_ai_trunc(n_moments_di))
1026 ALLOCATE (ref_point_multipole(3))
1027 ref_point_multipole(:) = bse_env%multipole_ref_point
1028 ! Obtain dipoles in MO basis
1029 CALL get_multipoles_mo(fm_dipole_ai_trunc, fm_dipole_ij_trunc, fm_dipole_ab_trunc, &
1030 bse_env%matrix_dipole_ao, bse_env%mos, mo_coeff, &
1031 homo, virtual, fm_eigvec_x%matrix_struct%context)
1032 ! Compute exciton descriptors from these multipoles
1033 IF (bse_env%num_print_exc_descr > 0) THEN
1034 ! Obtain quadrupoles in MO basis
1035 ALLOCATE (fm_quadpole_ij_trunc(n_moments_quad))
1036 ALLOCATE (fm_quadpole_ab_trunc(n_moments_quad))
1037 ALLOCATE (fm_quadpole_ai_trunc(n_moments_quad))
1038 ! the preparer builds the AO quadrupoles whenever NUM_PRINT_EXC_DESCR is nonzero
1039 cpassert(ASSOCIATED(bse_env%matrix_quadpole_ao))
1040 CALL get_multipoles_mo(fm_quadpole_ai_trunc, fm_quadpole_ij_trunc, fm_quadpole_ab_trunc, &
1041 bse_env%matrix_quadpole_ao, bse_env%mos, mo_coeff, &
1042 homo, virtual, fm_eigvec_x%matrix_struct%context)
1043 ! Iterate over excitation index outside of routine to make it compatible with tddft module
1044 ALLOCATE (exc_descr(bse_env%num_print_exc_descr))
1045 DO i_exc = 1, bse_env%num_print_exc_descr
1046 CALL reshuffle_eigvec(fm_eigvec_x, fm_x_ia, homo, virtual, i_exc, .false.)
1047 IF (.NOT. flag_tda) THEN
1048 CALL reshuffle_eigvec(fm_eigvec_y, fm_y_ia, homo, virtual, i_exc, .false.)
1049
1050 CALL get_exciton_descriptors(exc_descr, fm_x_ia, &
1051 fm_quadpole_ij_trunc, fm_quadpole_ab_trunc, &
1052 fm_quadpole_ai_trunc, &
1053 i_exc, homo, virtual, &
1054 fm_y_ia)
1055 ELSE
1056 CALL get_exciton_descriptors(exc_descr, fm_x_ia, &
1057 fm_quadpole_ij_trunc, fm_quadpole_ab_trunc, &
1058 fm_quadpole_ai_trunc, &
1059 i_exc, homo, virtual)
1060 END IF
1061 CALL cp_fm_release(fm_x_ia)
1062 IF (.NOT. flag_tda) THEN
1063 CALL cp_fm_release(fm_y_ia)
1064 END IF
1065 END DO
1066 END IF
1067
1068 IF (bse_env%bse_spin_config == 0) THEN
1069 CALL get_oscillator_strengths(fm_eigvec_x, exc_ens, fm_dipole_ai_trunc, &
1070 trans_mom_bse, oscill_str, polarizability_residues, &
1071 homo, virtual, fm_eigvec_y)
1072 END IF
1073
1074 ! the iterative driver prints the header before its solver runs
1075 IF (bse_env%bse_diag_method /= bse_iterdiag) THEN
1076 CALL print_output_header(homo, virtual, homo_irred, flag_tda, bse_env, unit_nr)
1077 END IF
1078
1079 ! Prints excitation energies up to user-specified number
1080 CALL print_excitation_energies(exc_ens, homo, virtual, flag_tda, multiplet, &
1081 info_approximation, bse_env, unit_nr)
1082
1083 ! Print single particle transition amplitudes, i.e. components of eigenvectors X and Y
1084 CALL print_transition_amplitudes(fm_eigvec_x, [homo], [virtual], [homo_irred], &
1085 info_approximation, bse_env, unit_nr, fm_eigvec_y)
1086
1087 ! Prints optical properties, if state is a singlet
1088 CALL print_optical_properties(exc_ens, oscill_str, trans_mom_bse, polarizability_residues, &
1089 homo, virtual, homo_irred, flag_tda, &
1090 info_approximation, bse_env, unit_nr)
1091 ! Print exciton descriptors if keyword is invoked
1092 IF (bse_env%num_print_exc_descr > 0) THEN
1093 CALL qs_subsys_get(bse_env%subsys, particle_set=particle_set)
1094 CALL print_exciton_descriptors(exc_descr, ref_point_multipole, unit_nr, &
1095 bse_env%num_print_exc_descr, bse_env%bse_debug_print, &
1096 bse_env%print_directional_exc_descr, &
1097 bse_env%print_directional_crosscorrelation, &
1098 'BSE|', particle_set)
1099 END IF
1100
1101 ! Compute and print excitation wavefunctions
1102 IF (bse_env%do_nto_analysis) THEN
1103 IF (unit_nr > 0) THEN
1104 WRITE (unit_nr, '(T2,A4)') 'BSE|'
1105 WRITE (unit_nr, '(T2,A4,T7,A47)') &
1106 'BSE|', "Calculating Natural Transition Orbitals (NTOs)."
1107 WRITE (unit_nr, '(T2,A4)') 'BSE|'
1108 END IF
1109 CALL calculate_ntos(fm_eigvec_x, fm_eigvec_y, &
1110 mo_coeff, homo, virtual, &
1111 info_approximation, &
1112 oscill_str, &
1113 bse_env, unit_nr)
1114 END IF
1115
1116 DO idir = 1, n_moments_di
1117 CALL cp_fm_release(fm_dipole_ai_trunc(idir))
1118 CALL cp_fm_release(fm_dipole_ij_trunc(idir))
1119 CALL cp_fm_release(fm_dipole_ab_trunc(idir))
1120 END DO
1121 IF (bse_env%num_print_exc_descr > 0) THEN
1122 DO idir = 1, n_moments_quad
1123 CALL cp_fm_release(fm_quadpole_ai_trunc(idir))
1124 CALL cp_fm_release(fm_quadpole_ij_trunc(idir))
1125 CALL cp_fm_release(fm_quadpole_ab_trunc(idir))
1126 END DO
1127 DEALLOCATE (fm_quadpole_ai_trunc, fm_quadpole_ij_trunc, fm_quadpole_ab_trunc)
1128 DEALLOCATE (exc_descr)
1129 END IF
1130 DEALLOCATE (fm_dipole_ai_trunc, fm_dipole_ij_trunc, fm_dipole_ab_trunc)
1131 DEALLOCATE (ref_point_multipole)
1132 IF (bse_env%bse_spin_config == 0) THEN
1133 DEALLOCATE (oscill_str, trans_mom_bse, polarizability_residues)
1134 END IF
1135 IF (unit_nr > 0) THEN
1136 WRITE (unit_nr, '(T2,A4)') 'BSE|'
1137 WRITE (unit_nr, '(T2,A4)') 'BSE|'
1138 END IF
1139
1140 CALL timestop(handle)
1141
1142 END SUBROUTINE postprocess_bse
1143
1144END MODULE bse_full_diag
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_b(fm_s_ia, fm_s_bar_ia, fm_b, homo, virtual, dimen_ri, unit_nr, bse_env)
Matrix B constructed from 3c-B-matrices (cf. subroutine screen_slabs) B_ia,jb = α * v_ia,...
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 diagonalize_c(fm_c, homo, virtual, homo_irred, fm_chol_a_minus_b, fm_a_plus_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....
subroutine, public create_hermitian_form_of_abba(fm_a, fm_b, fm_c, fm_chol_a_minus_b, fm_a_plus_b, unit_nr, bse_env)
Construct C = U (A+B) U^T with A-B = U^T U (U upper Cholesky factor) to solve the full BSE as a hermi...
subroutine, public create_hermitian_form_rpa(fm_c, gap)
Form C = sqrt(Δ) (Δ + 2 B) sqrt(Δ) in place for RPA, where A-B = diag(Δ).
subroutine, public create_a(fm_s_ia, fm_s_bar_ij, fm_s_ab, fm_a, eigenval, unit_nr, homo, virtual, dimen_ri, bse_env)
Matrix A constructed from GW energies and 3c-B-matrices (cf. subroutine screen_slabs) A_ia,...
Routines for printing information in context of the BSE calculation.
Definition bse_print.F:13
subroutine, public print_transition_amplitudes(fm_eigvec_x, homo, virtual, homo_irred, info_approximation, bse_env, unit_nr, fm_eigvec_y)
...
Definition bse_print.F:363
subroutine, public print_excitation_energies(exc_ens, homo, virtual, flag_tda, multiplet, info_approximation, bse_env, unit_nr)
...
Definition bse_print.F:314
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.
Definition bse_print.F:100
subroutine, public print_optical_properties(exc_ens, oscill_str, trans_mom_bse, polarizability_residues, homo, virtual, homo_irred, flag_tda, info_approximation, bse_env, unit_nr, open_shell)
...
Definition bse_print.F:459
subroutine, public print_exciton_descriptors(exc_descr, ref_point_multipole, unit_nr, num_print_exc_descr, print_checkvalue, print_directional_exc_descr, print_directional_crosscorrelation, prefix_output, particle_set)
Prints exciton descriptors, cf. Mewes et al., JCTC 14, 710-725 (2018).
Definition bse_print.F:671
Routines for computing excitonic properties, e.g. exciton diameter, from the BSE.
subroutine, public get_oscillator_strengths(fm_eigvec_x, exc_ens, fm_dipole_ai_trunc, trans_mom_bse, oscill_str, polarizability_residues, homo_red, virtual_red, fm_eigvec_y)
Compute and return BSE dipoles d_r^n = sqrt(2) sum_ia < ψ_i | r | ψ_a > ( X_ia^n + Y_ia^n ) and oscil...
subroutine, public get_exciton_descriptors(exc_descr, fm_x_ia, fm_multipole_ij_trunc, fm_multipole_ab_trunc, fm_multipole_ai_trunc, i_exc, homo, virtual, fm_y_ia)
...
subroutine, public calculate_ntos(fm_x, fm_y, mo_coeff, homo, virtual, info_approximation, oscill_str, bse_env, unit_nr)
...
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 assemble_joint_ov_slab(fm_s_ia, offsets, n_ov, dimen_ri, fm_s_joint)
Column-concatenate per-spin ia-slabs into the joint dimen_RI x n_ov_joint slab. Sigma-block of spin i...
Definition bse_util.F:1377
subroutine, public get_multipoles_mo(fm_multipole_ai_trunc, fm_multipole_ij_trunc, fm_multipole_ab_trunc, matrix_multipole, mos, mo_coeff, homo_red, virtual_red, context_bse, ispin)
The multipoles in the MO window, D^k_pq = sum_µν C_µp M^k_µν C_νq, cut to the ai, ij and ab blocks of...
Definition bse_util.F:1180
pure integer function, public occ_of_ia(ia, virt)
Occupied level of the compound transition index ia = (i-1)*virt + a.
Definition bse_util.F:109
subroutine, public reshuffle_eigvec(fm_eigvec, fm_eigvec_reshuffled, homo, virtual, n_exc, do_transpose)
...
Definition bse_util.F:794
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:548
pure integer function, public virt_of_ia(ia, virt)
Virtual level of the compound transition index ia = (i-1)*virt + a.
Definition bse_util.F:124
subroutine, public comp_eigvec_coeff_bse(fm_work, eig_vals, beta, gamma, do_transpose)
Routine for computing the coefficients of the eigenvectors of the BSE matrix from a multiplication wi...
Definition bse_util.F:189
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_release(blacs_env)
releases the given blacs_env
subroutine, public cp_blacs_env_create(blacs_env, para_env, blacs_grid_layout, blacs_repeatable, row_major, grid_2d)
allocates and initializes a type that represent a blacs context
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_row_scale(matrixa, scaling)
scales row i of matrix a with scaling(i)
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
subroutine, public cp_fm_scale(alpha, matrix_a)
scales a matrix matrix_a = alpha * matrix_b
subroutine, public cp_fm_column_scale(matrixa, scaling, first_col, source)
Scales columns of the full matrix by corresponding factors.
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,...
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
Definition cp_fm_diag.F:17
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...
Definition cp_fm_diag.F:262
Redistribution of full matrices and distributed arrays.
subroutine, public cp_fm_permute(fm_out, fm_in, beta, nrow_secidx_in, ncol_secidx_in, nrow_secidx_out, ncol_secidx_out, reordering, row_offset, col_offset, first_index, last_index)
Add a permuted or restricted four-index tensor stored as a full matrix.
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
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_get_diag(matrix, diag, n_active)
returns the diagonal elements of a fm
subroutine, public cp_fm_to_fm_submat(msource, mtarget, nrow, ncol, s_firstrow, s_firstcol, t_firstrow, t_firstcol)
copy just a part ot the 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
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
subroutine, public cp_fm_to_fm_triangular(msource, mtarget, uplo)
copy just a triangular matrix
Types for excited states potential energies.
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
Definition gamma.F:15
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public bse_iterdiag
integer, parameter, public bse_singlet
integer, parameter, public bse_triplet
integer, parameter, public bse_screening_w0
integer, parameter, public bse_screening_alpha
integer, parameter, public bse_screening_rpa
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public evolt
Definition physcon.F:189
types that represent a quickstep subsys
subroutine, public qs_subsys_get(subsys, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
Settings of the &BSE section (read_bse_section, re-read before every BSE run, normalised in place by ...
Definition bse_types.F:44
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
represent a full matrix
Contains information on the excited states energy.