63#include "./base/base_uses.f90"
69 CHARACTER(LEN=*),
PARAMETER,
PRIVATE :: moduleN =
'bse_full_diag'
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)
98 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: fm_s_ia, fm_s_bar_ij, fm_s_ab
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
106 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_A'
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
117 TYPE(
cp_fm_type) :: fm_a_copy, fm_s_joint, fm_w
122 CALL timeset(routinen, handle)
125 ALLOCATE (n_ov(nspins), offsets(nspins), eig_offsets(nspins))
130 eig_offsets(isp) = eig_offsets(isp - 1) + homo(isp - 1) + virtual(isp - 1)
133 NULLIFY (dft_control, tddfpt_control)
134 dft_control => bse_env%dft_control
135 tddfpt_control => dft_control%tddfpt2_control
137 IF (unit_nr > 0 .AND. bse_env%bse_debug_print)
THEN
138 WRITE (unit_nr,
'(T2,A10,T13,A10)')
'BSE|DEBUG|',
'Creating A'
142 SELECT CASE (bse_env%bse_spin_config)
150 CALL cp_warn(__location__, &
151 "BSE: SPIN_CONFIG ignored for open-shell reference; using alpha=1.")
156 alpha_screening = bse_env%screening_factor
158 alpha_screening = 1.0_dp
171 nrow_global=n_ov_joint, ncol_global=n_ov_joint, &
172 para_env=fm_s_ia(1)%matrix_struct%para_env)
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")
183 IF ((.NOT. tddfpt_control%do_bse) .AND. (.NOT. tddfpt_control%do_bse_w_only))
THEN
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")
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, &
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)
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'
216 nrow_global=homo(isp)**2, ncol_global=virtual(isp)**2, &
217 para_env=fm_s_ab(isp)%matrix_struct%para_env)
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)
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
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))
246 CALL cp_fm_to_fm(fm_a, ex_env%bse_a_matrix_MO(1, 1))
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'
259 IF (nspins == 1 .AND. tddfpt_control%do_bse_w_only)
CALL cp_fm_release(fm_a_copy)
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)
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
274 DO k_isp = 1, nspins - 1
275 IF (i_row_global <= offsets(k_isp) + n_ov(k_isp))
THEN
280 k_ov = i_row_global - offsets(isp)
281 i_occ_row =
occ_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
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(:)
302 DEALLOCATE (n_ov, offsets, eig_offsets)
306 CALL timestop(handle)
326 homo, virtual, dimen_RI, unit_nr, bse_env)
328 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: fm_s_ia, fm_s_bar_ia
330 INTEGER,
DIMENSION(:),
INTENT(IN) :: homo, virtual
331 INTEGER,
INTENT(IN) :: dimen_ri, unit_nr
334 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_B'
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
344 CALL timeset(routinen, handle)
347 ALLOCATE (n_ov(nspins), offsets(nspins))
350 IF (unit_nr > 0 .AND. bse_env%bse_debug_print)
THEN
351 WRITE (unit_nr,
'(T2,A10,T13,A10)')
'BSE|DEBUG|',
'Creating B'
356 SELECT CASE (bse_env%bse_spin_config)
362 IF (nspins > 1) alpha = 1.0_dp
365 alpha_screening = bse_env%screening_factor
367 alpha_screening = 1.0_dp
371 NULLIFY (fm_struct_b)
373 nrow_global=n_ov_joint, ncol_global=n_ov_joint, &
374 para_env=fm_s_ia(1)%matrix_struct%para_env)
380 NULLIFY (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")
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, &
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)
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'
408 NULLIFY (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)
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))
429 DEALLOCATE (n_ov, offsets)
431 CALL timestop(handle)
454 fm_S_bar_ij, fm_A, fm_B, do_abba, Eigenval, unit_nr, &
455 homo, virtual, dimen_RI, bse_env)
457 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: fm_s_ia, fm_s_ij, fm_s_ab, fm_s_bar_ia, &
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
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)
472 CALL create_b(fm_s_ia, fm_s_ia, fm_b, homo, virtual, dimen_ri, unit_nr, &
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)
479 CALL create_b(fm_s_ia, fm_s_bar_ia, fm_b, homo, virtual, dimen_ri, unit_nr, &
493 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: gap
495 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_hermitian_form_rpa'
497 INTEGER :: handle, icol, irow, ncol_local, &
499 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
501 CALL timeset(routinen, handle)
503 IF (minval(gap) <= 0.0_dp) cpabort(
"RPA requires positive occupied-virtual energy differences")
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))
517 CALL timestop(handle)
537 TYPE(
cp_fm_type),
INTENT(INOUT) :: fm_c, fm_chol_a_minus_b, fm_a_plus_b
538 INTEGER,
INTENT(IN) :: unit_nr
541 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_hermitian_form_of_ABBA'
543 INTEGER :: chol_info, dim_mat, handle
544 REAL(kind=
dp),
ALLOCATABLE :: chol_pivot(:), diag_b(:), gap(:)
547 CALL timeset(routinen, handle)
556 ALLOCATE (gap(dim_mat), diag_b(dim_mat))
559 gap(:) = gap(:) - diag_b(:)
564 CALL cp_fm_create(fm_chol_a_minus_b, fm_a%matrix_struct)
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
571 DEALLOCATE (gap, diag_b)
572 CALL timestop(handle)
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.")
594 CALL cp_fm_create(fm_chol_a_minus_b, fm_a%matrix_struct)
600 ALLOCATE (chol_pivot(dim_mat))
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
606 DEALLOCATE (chol_pivot)
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)
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'
618 CALL timestop(handle)
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)
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
645 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: mo_coeff
647 CHARACTER(LEN=*),
PARAMETER :: routinen =
'diagonalize_C'
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
655 CALL timeset(routinen, handle)
658 n_ov_joint = sum(homo*virtual)
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.'
669 ALLOCATE (exc_ens(n_ov_joint))
673 IF (diag_info /= 0)
THEN
674 CALL cp_abort(__location__, &
675 "Diagonalization of C=U (A+B) U^T failed in BSE")
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.")
688 exc_ens = sqrt(exc_ens)
699 CALL cp_fm_create(fm_mat_eigvec_transform_sum, fm_c%matrix_struct)
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)
711 CALL cp_fm_create(fm_mat_eigvec_transform_diff, fm_c%matrix_struct)
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)
724 CALL cp_fm_to_fm(fm_mat_eigvec_transform_sum, fm_eigvec_x)
730 CALL cp_fm_to_fm(fm_mat_eigvec_transform_sum, fm_eigvec_y)
737 IF (nspins == 1)
THEN
739 homo(1), virtual(1), homo_irred(1), unit_nr, &
740 .false., fm_eigvec_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)
751 CALL timestop(handle)
767 unit_nr, diag_est, bse_env, mo_coeff)
770 INTEGER,
DIMENSION(:),
INTENT(IN) :: homo, virtual, homo_irred
771 INTEGER,
INTENT(IN) :: unit_nr
772 REAL(kind=
dp),
INTENT(IN) :: diag_est
774 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: mo_coeff
776 CHARACTER(LEN=*),
PARAMETER :: routinen =
'diagonalize_A'
778 INTEGER :: diag_info, handle, n_ov_joint, nspins
779 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: exc_ens
782 CALL timeset(routinen, handle)
785 n_ov_joint = sum(homo*virtual)
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.'
794 ALLOCATE (exc_ens(n_ov_joint))
798 IF (diag_info /= 0)
THEN
799 CALL cp_abort(__location__, &
800 "Diagonalization of A failed in TDA-BSE")
803 IF (nspins == 1)
THEN
805 homo(1), virtual(1), homo_irred(1), unit_nr, .true.)
807 CALL bse_open_shell_optical(exc_ens, fm_eigvec, homo, virtual, homo_irred, &
808 .true., mo_coeff, bse_env, unit_nr)
814 CALL timestop(handle)
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)
836 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: exc_ens
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
842 INTEGER,
INTENT(IN) :: unit_nr
843 TYPE(
cp_fm_type),
INTENT(IN),
OPTIONAL :: fm_eigvec_y
845 CHARACTER(LEN=*),
PARAMETER :: routinen =
'bse_open_shell_optical'
847 CHARACTER(LEN=10) :: info_approximation, multiplet
848 INTEGER :: handle, idir, isp, jdir, n, n_ov_joint, &
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
855 TYPE(
cp_fm_type) :: fm_dip_reord_sp, fm_eigvec_sp, &
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
860 CALL timeset(routinen, handle)
863 ALLOCATE (n_ov_sp(nspins), offsets_sp(nspins))
870 info_approximation =
" -TDA- "
872 info_approximation =
"-ABBA-"
875 IF (unit_nr > 0)
THEN
876 WRITE (unit_nr,
'(T2,A4,T7,A43)')
'BSE|',
'Joint open-shell BSE excitation energies:'
879 info_approximation, bse_env, unit_nr)
883 info_approximation, bse_env, unit_nr, fm_eigvec_y)
886 CALL cp_fm_create(fm_trans_coeff, fm_eigvec_x%matrix_struct)
888 IF (
PRESENT(fm_eigvec_y))
CALL cp_fm_scale_and_add(1.0_dp, fm_trans_coeff, 1.0_dp, fm_eigvec_y)
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)
898 fm_trans_coeff%matrix_struct%context, 1, n_ov_joint)
900 CALL cp_fm_create(fm_trans_mom_joint(idir), fm_struct_tmom)
905 bse_env%matrix_dipole_ao, bse_env%mos, mo_coeff(isp:isp), &
906 homo(isp), virtual(isp), fm_trans_coeff%matrix_struct%context, &
908 NULLIFY (fm_struct_sp, fm_struct_dip_reord)
910 fm_trans_coeff%matrix_struct%context, n_ov_sp(isp), n_ov_joint)
914 offsets_sp(isp) + 1, 1, 1, 1)
916 fm_trans_coeff%matrix_struct%context, 1, n_ov_sp(isp))
918 CALL cp_fm_create(fm_dip_reord_sp, fm_struct_dip_reord, name=
"bse_dip_reord")
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))
930 NULLIFY (fm_struct_sp)
932 NULLIFY (fm_struct_dip_reord)
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)
946 oscill_str_joint(n) = 2.0_dp/3.0_dp*exc_ens(n)*sum(abs(trans_mom_joint(:, 1, n))**2)
949 n_ov_joint, 1, sum(homo_irred), flag_tda, info_approximation, &
950 bse_env, unit_nr, open_shell=.true.)
952 CALL cp_warn(__location__, &
953 "Open-shell (UKS) BSE: exciton descriptors and NTO analysis are not yet "// &
954 "implemented and have been skipped.")
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)
959 CALL timestop(handle)
961 END SUBROUTINE bse_open_shell_optical
977 homo, virtual, homo_irred, unit_nr, &
978 flag_TDA, fm_eigvec_Y)
980 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: exc_ens
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
988 CHARACTER(LEN=*),
PARAMETER :: routinen =
'postprocess_bse'
990 CHARACTER(LEN=10) :: info_approximation, multiplet
991 INTEGER :: handle, i_exc, idir, n_moments_di, &
993 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: oscill_str, ref_point_multipole
994 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: polarizability_residues, trans_mom_bse
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
999 DIMENSION(:) :: exc_descr
1002 CALL timeset(routinen, handle)
1005 IF (bse_env%bse_spin_config == 0)
THEN
1006 multiplet =
"Singlet"
1008 multiplet =
"Triplet"
1010 IF (.NOT.
PRESENT(flag_tda))
THEN
1014 info_approximation =
" -TDA- "
1016 info_approximation =
"-ABBA-"
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
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)
1033 IF (bse_env%num_print_exc_descr > 0)
THEN
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))
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)
1044 ALLOCATE (exc_descr(bse_env%num_print_exc_descr))
1045 DO i_exc = 1, bse_env%num_print_exc_descr
1047 IF (.NOT. flag_tda)
THEN
1051 fm_quadpole_ij_trunc, fm_quadpole_ab_trunc, &
1052 fm_quadpole_ai_trunc, &
1053 i_exc, homo, virtual, &
1057 fm_quadpole_ij_trunc, fm_quadpole_ab_trunc, &
1058 fm_quadpole_ai_trunc, &
1059 i_exc, homo, virtual)
1062 IF (.NOT. flag_tda)
THEN
1068 IF (bse_env%bse_spin_config == 0)
THEN
1070 trans_mom_bse, oscill_str, polarizability_residues, &
1071 homo, virtual, fm_eigvec_y)
1081 info_approximation, bse_env, unit_nr)
1085 info_approximation, bse_env, unit_nr, fm_eigvec_y)
1089 homo, virtual, homo_irred, flag_tda, &
1090 info_approximation, bse_env, unit_nr)
1092 IF (bse_env%num_print_exc_descr > 0)
THEN
1093 CALL qs_subsys_get(bse_env%subsys, particle_set=particle_set)
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)
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|'
1110 mo_coeff, homo, virtual, &
1111 info_approximation, &
1116 DO idir = 1, n_moments_di
1121 IF (bse_env%num_print_exc_descr > 0)
THEN
1122 DO idir = 1, n_moments_quad
1127 DEALLOCATE (fm_quadpole_ai_trunc, fm_quadpole_ij_trunc, fm_quadpole_ab_trunc)
1128 DEALLOCATE (exc_descr)
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)
1135 IF (unit_nr > 0)
THEN
1136 WRITE (unit_nr,
'(T2,A4)')
'BSE|'
1137 WRITE (unit_nr,
'(T2,A4)')
'BSE|'
1140 CALL timestop(handle)
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.
subroutine, public print_transition_amplitudes(fm_eigvec_x, homo, virtual, homo_irred, info_approximation, bse_env, unit_nr, fm_eigvec_y)
...
subroutine, public print_excitation_energies(exc_ens, homo, virtual, flag_tda, multiplet, info_approximation, bse_env, unit_nr)
...
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.
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)
...
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).
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...
Auxiliary routines for GW + Bethe-Salpeter for computing electronic excitations.
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...
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...
pure integer function, public occ_of_ia(ia, virt)
Occupied level of the compound transition index ia = (i-1)*virt + a.
subroutine, public reshuffle_eigvec(fm_eigvec, fm_eigvec_reshuffled, homo, virtual, n_exc, do_transpose)
...
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...
pure integer function, public virt_of_ia(ia, virt)
Virtual level of the compound transition index ia = (i-1)*virt + a.
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...
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...
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...
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
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...
Defines the basic variable types.
integer, parameter, public dp
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public evolt
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 ...
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
Contains information on the excited states energy.