57#include "./base/base_uses.f90"
63 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'gw_small_cell_full_kp'
80 CHARACTER(LEN=*),
PARAMETER :: routinen =
'gw_calc_small_cell_full_kp'
84 CALL timeset(routinen, handle)
91 CALL compute_chi(bs_env)
95 CALL compute_w_real_space(bs_env, qs_env)
102 CALL compute_sigma_x(bs_env, qs_env)
106 CALL compute_sigma_c(bs_env)
109 CALL compute_qp_energies(bs_env)
113 CALL timestop(handle)
121 SUBROUTINE compute_chi(bs_env)
124 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_chi'
126 INTEGER :: cell_dr(3), cell_r1(3), cell_r2(3), &
127 handle, i_cell_delta_r, i_cell_r1, &
128 i_cell_r2, i_t, i_task_delta_r_local, &
130 LOGICAL :: cell_found
131 REAL(kind=
dp) :: t1, tau
132 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: gocc_s, gvir_s, t_chi_r
133 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_gocc, t_gvir
135 CALL timeset(routinen, handle)
137 DO i_t = 1, bs_env%num_time_freq_points
139 CALL dbt_create_2c_r(gocc_s, bs_env%t_G, bs_env%nimages_scf_desymm)
140 CALL dbt_create_2c_r(gvir_s, bs_env%t_G, bs_env%nimages_scf_desymm)
141 CALL dbt_create_2c_r(t_chi_r, bs_env%t_chi, bs_env%nimages_scf_desymm)
142 CALL dbt_create_3c_r1_r2(t_gocc, bs_env%t_RI_AO__AO, bs_env%nimages_3c, bs_env%nimages_3c)
143 CALL dbt_create_3c_r1_r2(t_gvir, bs_env%t_RI_AO__AO, bs_env%nimages_3c, bs_env%nimages_3c)
146 tau = bs_env%imag_time_points(i_t)
148 DO ispin = 1, bs_env%n_spin
155 CALL g_occ_vir(bs_env, tau, gocc_s, ispin, occ=.true., vir=.false.)
156 CALL g_occ_vir(bs_env, tau, gvir_s, ispin, occ=.false., vir=.true.)
159 DO i_task_delta_r_local = 1, bs_env%n_tasks_Delta_R_local
161 IF (bs_env%skip_DR_chi(i_task_delta_r_local)) cycle
163 i_cell_delta_r = bs_env%task_Delta_R(i_task_delta_r_local)
165 DO i_cell_r2 = 1, bs_env%nimages_3c
167 cell_r2(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r2)
168 cell_dr(1:3) = bs_env%index_to_cell_Delta_R(1:3, i_cell_delta_r)
171 CALL add_r(cell_r2, cell_dr, bs_env%index_to_cell_3c, cell_r1, &
172 cell_found, bs_env%cell_to_index_3c, i_cell_r1)
175 IF (.NOT. cell_found) cycle
177 CALL g_times_3c(gocc_s, t_gocc, bs_env, i_cell_r1, i_cell_r2, &
178 i_task_delta_r_local, bs_env%skip_DR_R12_S_Goccx3c_chi)
179 CALL g_times_3c(gvir_s, t_gvir, bs_env, i_cell_r2, i_cell_r1, &
180 i_task_delta_r_local, bs_env%skip_DR_R12_S_Gvirx3c_chi)
185 CALL contract_m_occ_vir_to_chi(t_gocc, t_gvir, t_chi_r, bs_env, &
186 i_task_delta_r_local)
192 CALL bs_env%para_env%sync()
195 bs_env%mat_RI_RI_tensor, bs_env)
197 CALL destroy_t_1d(gocc_s)
198 CALL destroy_t_1d(gvir_s)
199 CALL destroy_t_1d(t_chi_r)
200 CALL destroy_t_2d(t_gocc)
201 CALL destroy_t_2d(t_gvir)
203 IF (bs_env%unit_nr > 0)
THEN
204 WRITE (bs_env%unit_nr,
'(T2,A,I13,A,I3,A,F7.1,A)') &
205 χτ
'Computed ^R(i) for time point', i_t,
' /', bs_env%num_time_freq_points, &
211 CALL timestop(handle)
213 END SUBROUTINE compute_chi
221 SUBROUTINE dbt_create_2c_r(R, template, nimages)
223 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: r
224 TYPE(dbt_type) :: template
227 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dbt_create_2c_R'
229 INTEGER :: handle, i_cell_s
231 CALL timeset(routinen, handle)
233 ALLOCATE (r(nimages))
234 DO i_cell_s = 1, nimages
235 CALL dbt_create(template, r(i_cell_s))
238 CALL timestop(handle)
240 END SUBROUTINE dbt_create_2c_r
249 SUBROUTINE dbt_create_3c_r1_r2(t_3c_R1_R2, t_3c_template, nimages_1, nimages_2)
251 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_3c_r1_r2
252 TYPE(dbt_type) :: t_3c_template
253 INTEGER :: nimages_1, nimages_2
255 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dbt_create_3c_R1_R2'
257 INTEGER :: handle, i_cell, j_cell
259 CALL timeset(routinen, handle)
261 ALLOCATE (t_3c_r1_r2(nimages_1, nimages_2))
262 DO i_cell = 1, nimages_1
263 DO j_cell = 1, nimages_2
264 CALL dbt_create(t_3c_template, t_3c_r1_r2(i_cell, j_cell))
268 CALL timestop(handle)
270 END SUBROUTINE dbt_create_3c_r1_r2
282 SUBROUTINE g_times_3c(t_G_S, t_M, bs_env, i_cell_R1, i_cell_R2, i_task_Delta_R_local, &
284 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: t_g_s
285 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_m
287 INTEGER :: i_cell_r1, i_cell_r2, &
289 LOGICAL,
ALLOCATABLE,
DIMENSION(:, :, :) :: skip_dr_r1_s_gx3c
291 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_times_3c'
293 INTEGER :: handle, i_cell_r1_p_s, i_cell_s
294 INTEGER(KIND=int_8) :: flop
295 INTEGER,
DIMENSION(3) :: cell_r1, cell_r1_plus_cell_s, cell_r2, &
297 LOGICAL :: cell_found
298 TYPE(dbt_type) :: t_3c_int
300 CALL timeset(routinen, handle)
302 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_int)
304 cell_r1(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r1)
305 cell_r2(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r2)
307 DO i_cell_s = 1, bs_env%nimages_scf_desymm
309 IF (skip_dr_r1_s_gx3c(i_task_delta_r_local, i_cell_r1, i_cell_s)) cycle
311 cell_s(1:3) = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_s)
312 cell_r1_plus_cell_s(1:3) = cell_r1(1:3) + cell_s(1:3)
316 IF (.NOT. cell_found) cycle
318 i_cell_r1_p_s = bs_env%cell_to_index_3c(cell_r1_plus_cell_s(1), cell_r1_plus_cell_s(2), &
319 cell_r1_plus_cell_s(3))
321 IF (bs_env%nblocks_3c(i_cell_r2, i_cell_r1_p_s) == 0) cycle
323 CALL get_t_3c_int(t_3c_int, bs_env, i_cell_r2, i_cell_r1_p_s)
325 CALL dbt_contract(alpha=1.0_dp, &
327 tensor_2=t_g_s(i_cell_s), &
329 tensor_3=t_m(i_cell_r1, i_cell_r2), &
330 contract_1=[3], notcontract_1=[1, 2], map_1=[1, 2], &
331 contract_2=[2], notcontract_2=[1], map_2=[3], &
332 filter_eps=bs_env%eps_filter, flop=flop)
334 IF (flop == 0_int_8) skip_dr_r1_s_gx3c(i_task_delta_r_local, i_cell_r1, i_cell_s) = .true.
338 CALL dbt_destroy(t_3c_int)
340 CALL timestop(handle)
342 END SUBROUTINE g_times_3c
351 SUBROUTINE get_t_3c_int(t_3c_int, bs_env, j_cell, k_cell)
353 TYPE(dbt_type) :: t_3c_int
355 INTEGER :: j_cell, k_cell
357 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_t_3c_int'
361 CALL timeset(routinen, handle)
363 CALL dbt_clear(t_3c_int)
364 IF (j_cell < k_cell)
THEN
365 CALL dbt_copy(bs_env%t_3c_int(k_cell, j_cell), t_3c_int, order=[1, 3, 2])
367 CALL dbt_copy(bs_env%t_3c_int(j_cell, k_cell), t_3c_int)
370 CALL timestop(handle)
372 END SUBROUTINE get_t_3c_int
383 SUBROUTINE g_occ_vir(bs_env, tau, G_S, ispin, occ, vir)
386 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: g_s
390 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_occ_vir'
392 INTEGER :: handle, homo, i_cell_s, ikp, j, &
393 j_col_local, n_mo, ncol_local, &
395 INTEGER,
DIMENSION(:),
POINTER :: col_indices
396 REAL(kind=
dp) :: tau_e
398 CALL timeset(routinen, handle)
400 cpassert(occ .NEQV. vir)
403 ncol_local=ncol_local, &
404 col_indices=col_indices)
406 nkp = bs_env%nkp_scf_desymm
407 nimages = bs_env%nimages_scf_desymm
409 homo = bs_env%n_occ(ispin)
411 DO i_cell_s = 1, bs_env%nimages_scf_desymm
418 CALL cp_cfm_to_cfm(bs_env%cfm_mo_coeff_kp(ikp, ispin), bs_env%cfm_work_mo)
421 DO j_col_local = 1, ncol_local
423 j = col_indices(j_col_local)
426 tau_e = abs(tau*0.5_dp*(bs_env%eigenval_scf(j, ikp, ispin) - bs_env%e_fermi(ispin)))
428 IF (tau_e < bs_env%stabilize_exp)
THEN
429 bs_env%cfm_work_mo%local_data(:, j_col_local) = &
430 bs_env%cfm_work_mo%local_data(:, j_col_local)*exp(-tau_e)
432 bs_env%cfm_work_mo%local_data(:, j_col_local) =
z_zero
435 IF ((occ .AND. j > homo) .OR. (vir .AND. j <= homo))
THEN
436 bs_env%cfm_work_mo%local_data(:, j_col_local) =
z_zero
442 matrix_a=bs_env%cfm_work_mo, matrix_b=bs_env%cfm_work_mo, &
443 beta=
z_zero, matrix_c=bs_env%cfm_work_mo_2)
447 bs_env%kpoints_scf_desymm, ikp)
452 DO i_cell_s = 1, bs_env%nimages_scf_desymm
454 bs_env%mat_ao_ao_tensor%matrix, g_s(i_cell_s), bs_env)
457 CALL timestop(handle)
459 END SUBROUTINE g_occ_vir
469 SUBROUTINE contract_m_occ_vir_to_chi(t_Gocc, t_Gvir, t_chi_R, bs_env, i_task_Delta_R_local)
470 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_gocc, t_gvir
471 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: t_chi_r
473 INTEGER :: i_task_delta_r_local
475 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_M_occ_vir_to_chi'
477 INTEGER :: handle, i_cell_delta_r, i_cell_r, &
478 i_cell_r1, i_cell_r1_minus_r, &
479 i_cell_r2, i_cell_r2_minus_r
480 INTEGER(KIND=int_8) :: flop, flop_tmp
481 INTEGER,
DIMENSION(3) :: cell_dr, cell_r, cell_r1, &
482 cell_r1_minus_r, cell_r2, &
484 LOGICAL :: cell_found
485 TYPE(dbt_type) :: t_gocc_2, t_gvir_2
487 CALL timeset(routinen, handle)
489 CALL dbt_create(bs_env%t_RI__AO_AO, t_gocc_2)
490 CALL dbt_create(bs_env%t_RI__AO_AO, t_gvir_2)
495 DO i_cell_r = 1, bs_env%nimages_scf_desymm
497 DO i_cell_r2 = 1, bs_env%nimages_3c
499 IF (bs_env%skip_DR_R_R2_MxM_chi(i_task_delta_r_local, i_cell_r2, i_cell_r)) cycle
501 i_cell_delta_r = bs_env%task_Delta_R(i_task_delta_r_local)
503 cell_r(1:3) = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_r)
504 cell_r2(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r2)
505 cell_dr(1:3) = bs_env%index_to_cell_Delta_R(1:3, i_cell_delta_r)
508 CALL add_r(cell_r2, cell_dr, bs_env%index_to_cell_3c, cell_r1, &
509 cell_found, bs_env%cell_to_index_3c, i_cell_r1)
510 IF (.NOT. cell_found) cycle
513 CALL add_r(cell_r1, -cell_r, bs_env%index_to_cell_3c, cell_r1_minus_r, &
514 cell_found, bs_env%cell_to_index_3c, i_cell_r1_minus_r)
515 IF (.NOT. cell_found) cycle
518 CALL add_r(cell_r2, -cell_r, bs_env%index_to_cell_3c, cell_r2_minus_r, &
519 cell_found, bs_env%cell_to_index_3c, i_cell_r2_minus_r)
520 IF (.NOT. cell_found) cycle
523 CALL dbt_copy(t_gocc(i_cell_r1, i_cell_r2), t_gocc_2, order=[1, 3, 2])
524 CALL dbt_copy(t_gvir(i_cell_r2_minus_r, i_cell_r1_minus_r), t_gvir_2)
527 CALL dbt_contract(alpha=bs_env%spin_degeneracy, &
528 tensor_1=t_gocc_2, tensor_2=t_gvir_2, &
529 beta=1.0_dp, tensor_3=t_chi_r(i_cell_r), &
530 contract_1=[2, 3], notcontract_1=[1], map_1=[1], &
531 contract_2=[2, 3], notcontract_2=[1], map_2=[2], &
532 filter_eps=bs_env%eps_filter, move_data=.true., flop=flop_tmp)
534 IF (flop_tmp == 0_int_8) bs_env%skip_DR_R_R2_MxM_chi(i_task_delta_r_local, &
535 i_cell_r2, i_cell_r) = .true.
537 flop = flop + flop_tmp
543 IF (flop == 0_int_8) bs_env%skip_DR_chi(i_task_delta_r_local) = .true.
546 DO i_cell_r1 = 1, bs_env%nimages_3c
547 DO i_cell_r2 = 1, bs_env%nimages_3c
548 CALL dbt_clear(t_gocc(i_cell_r1, i_cell_r2))
549 CALL dbt_clear(t_gvir(i_cell_r1, i_cell_r2))
553 CALL dbt_destroy(t_gocc_2)
554 CALL dbt_destroy(t_gvir_2)
556 CALL timestop(handle)
558 END SUBROUTINE contract_m_occ_vir_to_chi
565 SUBROUTINE compute_w_real_space(bs_env, qs_env)
569 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_W_real_space'
571 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: chi_k_w, eps_k_w, w_k_w
572 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_inv, m_inv_v_sqrt, v_sqrt
573 INTEGER :: handle, i_t, ikp, ikp_local, j_w, n_ri, &
575 REAL(kind=
dp) :: freq_j, t1, time_i, weight_ij
576 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: chi_r, mwm_r, w_r
578 CALL timeset(routinen, handle)
581 nimages_scf_desymm = bs_env%nimages_scf_desymm
583 ALLOCATE (chi_k_w(n_ri, n_ri), eps_k_w(n_ri, n_ri), w_k_w(n_ri, n_ri))
584 ALLOCATE (chi_r(n_ri, n_ri, nimages_scf_desymm), w_r(n_ri, n_ri, nimages_scf_desymm), &
585 mwm_r(n_ri, n_ri, nimages_scf_desymm))
589 CALL compute_minv_and_vsqrt(bs_env, qs_env, m_inv_v_sqrt, m_inv, v_sqrt)
591 IF (bs_env%unit_nr > 0)
THEN
592 WRITE (bs_env%unit_nr,
'(T2,A,T58,A,F7.1,A)') &
593 'Computed V_PQ(k),',
'Execution time',
m_walltime() - t1,
' s'
594 WRITE (bs_env%unit_nr,
'(A)')
' '
599 DO j_w = 1, bs_env%num_time_freq_points
602 chi_r(:, :, :) = 0.0_dp
603 DO i_t = 1, bs_env%num_time_freq_points
604 freq_j = bs_env%imag_freq_points(j_w)
605 time_i = bs_env%imag_time_points(i_t)
606 weight_ij = bs_env%weights_cos_t_to_w(j_w, i_t)*cos(time_i*freq_j)
612 w_r(:, :, :) = 0.0_dp
613 DO ikp = 1, bs_env%nkp_chi_eps_W_orig_plus_extra
616 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
618 ikp_local = ikp_local + 1
621 CALL rs_to_kp(chi_r, chi_k_w, bs_env%kpoints_scf_desymm%index_to_cell, &
622 bs_env%kpoints_chi_eps_W%xkp(1:3, ikp))
625 CALL power(chi_k_w, 1.0_dp, bs_env%eps_eigval_mat_RI)
630 CALL gemm_square(m_inv_v_sqrt(:, :, ikp_local),
'C', chi_k_w,
'N', m_inv_v_sqrt(:, :, ikp_local),
'N', eps_k_w)
633 CALL add_on_diag(eps_k_w,
z_one)
638 CALL power(eps_k_w, -1.0_dp, 0.0_dp)
641 CALL add_on_diag(eps_k_w, -
z_one)
644 CALL gemm_square(v_sqrt(:, :, ikp_local),
'N', eps_k_w,
'N', v_sqrt(:, :, ikp_local),
'C', w_k_w)
648 index_to_cell_ext=bs_env%kpoints_scf_desymm%index_to_cell)
652 CALL bs_env%para_env%sync()
653 CALL bs_env%para_env%sum(w_r)
657 CALL mult_w_with_minv(w_r, mwm_r, bs_env, qs_env)
660 DO i_t = 1, bs_env%num_time_freq_points
661 freq_j = bs_env%imag_freq_points(j_w)
662 time_i = bs_env%imag_time_points(i_t)
663 weight_ij = bs_env%weights_cos_w_to_t(i_t, j_w)*cos(time_i*freq_j)
669 IF (bs_env%unit_nr > 0)
THEN
670 WRITE (bs_env%unit_nr,
'(T2,A,T60,A,F7.1,A)') &
671 ωτ
'Computed W_PQ(k,i) for all k and ,',
'Execution time',
m_walltime() - t1,
' s'
672 WRITE (bs_env%unit_nr,
'(A)')
' '
675 CALL timestop(handle)
677 END SUBROUTINE compute_w_real_space
687 SUBROUTINE compute_minv_and_vsqrt(bs_env, qs_env, M_inv_V_sqrt, M_inv, V_sqrt)
690 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_inv_v_sqrt, m_inv, v_sqrt
692 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Minv_and_Vsqrt'
694 INTEGER :: handle, ikp, ikp_local, n_ri, nkp, &
696 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_r
698 CALL timeset(routinen, handle)
700 nkp = bs_env%nkp_chi_eps_W_orig_plus_extra
701 nkp_orig = bs_env%nkp_chi_eps_W_orig
707 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
708 nkp_local = nkp_local + 1
711 ALLOCATE (m_inv_v_sqrt(n_ri, n_ri, nkp_local), m_inv(n_ri, n_ri, nkp_local), &
712 v_sqrt(n_ri, n_ri, nkp_local))
714 m_inv_v_sqrt(:, :, :) =
z_zero
719 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
721 bs_env%size_lattice_sum_V, basis_type=
"RI_AUX", &
722 ikp_start=1, ikp_end=nkp_orig)
725 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_extra
727 bs_env%size_lattice_sum_V, basis_type=
"RI_AUX", &
728 ikp_start=nkp_orig + 1, ikp_end=nkp)
733 CALL get_v_tr_r(m_r, bs_env%ri_metric, bs_env%regularization_RI, bs_env, qs_env)
739 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
741 ikp_local = ikp_local + 1
744 CALL rs_to_kp(m_r, m_inv(:, :, ikp_local), &
745 bs_env%kpoints_scf_desymm%index_to_cell, &
746 bs_env%kpoints_chi_eps_W%xkp(1:3, ikp))
749 CALL power(m_inv(:, :, ikp_local), -1.0_dp, 0.0_dp)
752 CALL power(v_sqrt(:, :, ikp_local), 0.5_dp, 0.0_dp)
755 CALL gemm_square(m_inv(:, :, ikp_local),
'N', v_sqrt(:, :, ikp_local),
'C', m_inv_v_sqrt(:, :, ikp_local))
759 CALL timestop(handle)
761 END SUBROUTINE compute_minv_and_vsqrt
768 SUBROUTINE add_on_diag(matrix, alpha)
769 COMPLEX(KIND=dp),
DIMENSION(:, :) :: matrix
770 COMPLEX(KIND=dp) :: alpha
772 CHARACTER(len=*),
PARAMETER :: routinen =
'add_on_diag'
774 INTEGER :: handle, i, n
776 CALL timeset(routinen, handle)
779 cpassert(n ==
SIZE(matrix, 2))
782 matrix(i, i) = matrix(i, i) + alpha
785 CALL timestop(handle)
787 END SUBROUTINE add_on_diag
796 SUBROUTINE mult_w_with_minv(W_R, MWM_R, bs_env, qs_env)
797 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: w_r, mwm_r
801 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mult_W_with_Minv'
803 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: m_inv, w_k, work
804 INTEGER :: handle, ikp, n_ri
805 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_r
807 CALL timeset(routinen, handle)
810 CALL get_v_tr_r(m_r, bs_env%ri_metric, bs_env%regularization_RI, bs_env, qs_env)
813 ALLOCATE (m_inv(n_ri, n_ri), w_k(n_ri, n_ri), work(n_ri, n_ri))
814 mwm_r(:, :, :) = 0.0_dp
816 DO ikp = 1, bs_env%nkp_scf_desymm
819 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
823 bs_env%kpoints_scf_desymm%index_to_cell, &
824 bs_env%kpoints_scf_desymm%xkp(1:3, ikp))
827 CALL power(m_inv, -1.0_dp, 0.0_dp)
831 bs_env%kpoints_scf_desymm%index_to_cell, &
832 bs_env%kpoints_scf_desymm%xkp(1:3, ikp))
835 CALL gemm_square(m_inv,
'N', w_k,
'N', m_inv,
'N', work)
836 w_k(:, :) = work(:, :)
843 CALL bs_env%para_env%sync()
844 CALL bs_env%para_env%sum(mwm_r)
846 CALL timestop(handle)
848 END SUBROUTINE mult_w_with_minv
855 SUBROUTINE compute_sigma_x(bs_env, qs_env)
859 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Sigma_x'
861 INTEGER :: handle, i_task_delta_r_local, ispin
863 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: d_s, mi_vtr_mi_r, sigma_x_r
864 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_v
866 CALL timeset(routinen, handle)
868 CALL dbt_create_2c_r(mi_vtr_mi_r, bs_env%t_W, bs_env%nimages_scf_desymm)
869 CALL dbt_create_2c_r(d_s, bs_env%t_G, bs_env%nimages_scf_desymm)
870 CALL dbt_create_2c_r(sigma_x_r, bs_env%t_G, bs_env%nimages_scf_desymm)
871 CALL dbt_create_3c_r1_r2(t_v, bs_env%t_RI_AO__AO, bs_env%nimages_3c, bs_env%nimages_3c)
878 CALL get_minv_vtr_minv_r(mi_vtr_mi_r, bs_env, qs_env)
882 DO ispin = 1, bs_env%n_spin
886 CALL g_occ_vir(bs_env, 0.0_dp, d_s, ispin, occ=.true., vir=.false.)
889 DO i_task_delta_r_local = 1, bs_env%n_tasks_Delta_R_local
892 CALL contract_w(t_v, mi_vtr_mi_r, bs_env, i_task_delta_r_local)
897 CALL contract_to_sigma(sigma_x_r, t_v, d_s, i_task_delta_r_local, bs_env, &
898 occ=.true., vir=.false., clear_t_w=.true., fill_skip=.false.)
902 CALL bs_env%para_env%sync()
905 bs_env%mat_ao_ao_tensor, bs_env)
909 IF (bs_env%unit_nr > 0)
THEN
910 WRITE (bs_env%unit_nr,
'(T2,A,T58,A,F7.1,A)') &
911 Σ
'Computed ^x,',
' Execution time',
m_walltime() - t1,
' s'
912 WRITE (bs_env%unit_nr,
'(A)')
' '
915 CALL destroy_t_1d(mi_vtr_mi_r)
916 CALL destroy_t_1d(d_s)
917 CALL destroy_t_1d(sigma_x_r)
918 CALL destroy_t_2d(t_v)
920 CALL timestop(handle)
922 END SUBROUTINE compute_sigma_x
928 SUBROUTINE compute_sigma_c(bs_env)
931 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Sigma_c'
933 INTEGER :: handle, i_t, i_task_delta_r_local, ispin
934 REAL(kind=
dp) :: t1, tau
935 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: gocc_s, gvir_s, sigma_c_r_neg_tau, &
936 sigma_c_r_pos_tau, w_r
937 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_w
939 CALL timeset(routinen, handle)
941 CALL dbt_create_2c_r(gocc_s, bs_env%t_G, bs_env%nimages_scf_desymm)
942 CALL dbt_create_2c_r(gvir_s, bs_env%t_G, bs_env%nimages_scf_desymm)
943 CALL dbt_create_2c_r(w_r, bs_env%t_W, bs_env%nimages_scf_desymm)
944 CALL dbt_create_3c_r1_r2(t_w, bs_env%t_RI_AO__AO, bs_env%nimages_3c, bs_env%nimages_3c)
945 CALL dbt_create_2c_r(sigma_c_r_neg_tau, bs_env%t_G, bs_env%nimages_scf_desymm)
946 CALL dbt_create_2c_r(sigma_c_r_pos_tau, bs_env%t_G, bs_env%nimages_scf_desymm)
950 DO i_t = 1, bs_env%num_time_freq_points
952 DO ispin = 1, bs_env%n_spin
956 tau = bs_env%imag_time_points(i_t)
961 CALL g_occ_vir(bs_env, tau, gocc_s, ispin, occ=.true., vir=.false.)
962 CALL g_occ_vir(bs_env, tau, gvir_s, ispin, occ=.false., vir=.true.)
965 CALL fm_mwm_r_t_to_local_tensor_w_r(bs_env%fm_MWM_R_t(:, i_t), w_r, bs_env)
968 DO i_task_delta_r_local = 1, bs_env%n_tasks_Delta_R_local
970 IF (bs_env%skip_DR_Sigma(i_task_delta_r_local)) cycle
974 CALL contract_w(t_w, w_r, bs_env, i_task_delta_r_local)
980 CALL contract_to_sigma(sigma_c_r_neg_tau, t_w, gocc_s, i_task_delta_r_local, bs_env, &
981 occ=.true., vir=.false., clear_t_w=.false., fill_skip=.false.)
984 CALL contract_to_sigma(sigma_c_r_pos_tau, t_w, gvir_s, i_task_delta_r_local, bs_env, &
985 occ=.false., vir=.true., clear_t_w=.true., fill_skip=.true.)
989 CALL bs_env%para_env%sync()
992 bs_env%fm_Sigma_c_R_pos_tau(:, i_t, ispin), &
993 bs_env%mat_ao_ao, bs_env%mat_ao_ao_tensor, bs_env)
996 bs_env%fm_Sigma_c_R_neg_tau(:, i_t, ispin), &
997 bs_env%mat_ao_ao, bs_env%mat_ao_ao_tensor, bs_env)
999 IF (bs_env%unit_nr > 0)
THEN
1000 WRITE (bs_env%unit_nr,
'(T2,A,I10,A,I3,A,F7.1,A)') &
1001 Στ
'Computed ^c(i) for time point ', i_t,
' /', bs_env%num_time_freq_points, &
1009 CALL destroy_t_1d(gocc_s)
1010 CALL destroy_t_1d(gvir_s)
1011 CALL destroy_t_1d(w_r)
1012 CALL destroy_t_1d(sigma_c_r_neg_tau)
1013 CALL destroy_t_1d(sigma_c_r_pos_tau)
1014 CALL destroy_t_2d(t_w)
1016 CALL timestop(handle)
1018 END SUBROUTINE compute_sigma_c
1026 SUBROUTINE get_minv_vtr_minv_r(Mi_Vtr_Mi_R, bs_env, qs_env)
1027 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: mi_vtr_mi_r
1031 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Minv_Vtr_Minv_R'
1033 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: m_kp, mi_vtr_mi_kp, v_tr_kp
1034 INTEGER :: handle, i_cell_r, ikp, n_ri, &
1035 nimages_scf, nkp_scf
1036 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_r, mi_vtr_mi_r_arr, v_tr_r
1038 CALL timeset(routinen, handle)
1040 nimages_scf = bs_env%nimages_scf_desymm
1041 nkp_scf = bs_env%kpoints_scf_desymm%nkp
1044 CALL get_v_tr_r(v_tr_r, bs_env%trunc_coulomb, 0.0_dp, bs_env, qs_env)
1045 CALL get_v_tr_r(m_r, bs_env%ri_metric, bs_env%regularization_RI, bs_env, qs_env)
1047 ALLOCATE (v_tr_kp(n_ri, n_ri), m_kp(n_ri, n_ri), &
1048 mi_vtr_mi_kp(n_ri, n_ri), mi_vtr_mi_r_arr(n_ri, n_ri, nimages_scf))
1049 mi_vtr_mi_r_arr(:, :, :) = 0.0_dp
1053 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
1055 CALL rs_to_kp(v_tr_r, v_tr_kp, bs_env%kpoints_scf_desymm%index_to_cell, &
1056 bs_env%kpoints_scf_desymm%xkp(1:3, ikp))
1058 CALL rs_to_kp(m_r, m_kp, bs_env%kpoints_scf_desymm%index_to_cell, &
1059 bs_env%kpoints_scf_desymm%xkp(1:3, ikp))
1061 CALL power(m_kp, -1.0_dp, 0.0_dp)
1063 CALL gemm_square(m_kp,
'N', v_tr_kp,
'N', m_kp,
'N', mi_vtr_mi_kp)
1065 CALL add_kp_to_all_rs(mi_vtr_mi_kp, mi_vtr_mi_r_arr, bs_env%kpoints_scf_desymm, ikp)
1067 CALL bs_env%para_env%sync()
1068 CALL bs_env%para_env%sum(mi_vtr_mi_r_arr)
1074 DO i_cell_r = 1, nimages_scf
1076 bs_env%mat_RI_RI_tensor%matrix, mi_vtr_mi_r(i_cell_r), bs_env)
1079 CALL timestop(handle)
1081 END SUBROUTINE get_minv_vtr_minv_r
1087 SUBROUTINE destroy_t_1d(t_1d)
1088 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: t_1d
1090 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_t_1d'
1092 INTEGER :: handle, i
1094 CALL timeset(routinen, handle)
1096 DO i = 1,
SIZE(t_1d)
1097 CALL dbt_destroy(t_1d(i))
1101 CALL timestop(handle)
1103 END SUBROUTINE destroy_t_1d
1109 SUBROUTINE destroy_t_2d(t_2d)
1110 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_2d
1112 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_t_2d'
1114 INTEGER :: handle, i, j
1116 CALL timeset(routinen, handle)
1118 DO i = 1,
SIZE(t_2d, 1)
1119 DO j = 1,
SIZE(t_2d, 2)
1120 CALL dbt_destroy(t_2d(i, j))
1125 CALL timestop(handle)
1127 END SUBROUTINE destroy_t_2d
1136 SUBROUTINE contract_w(t_W, W_R, bs_env, i_task_Delta_R_local)
1137 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_w
1138 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: w_r
1140 INTEGER :: i_task_delta_r_local
1142 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_W'
1144 INTEGER :: handle, i_cell_delta_r, i_cell_r1, &
1145 i_cell_r2, i_cell_r2_m_r1, i_cell_s1, &
1147 INTEGER,
DIMENSION(3) :: cell_dr, cell_r1, cell_r2, cell_r2_m_r1, &
1148 cell_s1, cell_s1_m_r2_p_r1
1149 LOGICAL :: cell_found
1150 TYPE(dbt_type) :: t_3c_int, t_w_tmp
1152 CALL timeset(routinen, handle)
1154 CALL dbt_create(bs_env%t_RI__AO_AO, t_w_tmp)
1155 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_int)
1157 i_cell_delta_r = bs_env%task_Delta_R(i_task_delta_r_local)
1159 DO i_cell_r1 = 1, bs_env%nimages_3c
1161 cell_r1(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r1)
1162 cell_dr(1:3) = bs_env%index_to_cell_Delta_R(1:3, i_cell_delta_r)
1165 CALL add_r(cell_r1, cell_dr, bs_env%index_to_cell_3c, cell_s1, &
1166 cell_found, bs_env%cell_to_index_3c, i_cell_s1)
1167 IF (.NOT. cell_found) cycle
1169 DO i_cell_r2 = 1, bs_env%nimages_scf_desymm
1171 cell_r2(1:3) = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_r2)
1174 CALL add_r(cell_r2, -cell_r1, bs_env%index_to_cell_3c, cell_r2_m_r1, &
1175 cell_found, bs_env%cell_to_index_3c, i_cell_r2_m_r1)
1176 IF (.NOT. cell_found) cycle
1179 CALL add_r(cell_s1, cell_r2_m_r1, bs_env%index_to_cell_3c, cell_s1_m_r2_p_r1, &
1180 cell_found, bs_env%cell_to_index_3c, i_cell_s1_m_r1_p_r2)
1181 IF (.NOT. cell_found) cycle
1183 CALL get_t_3c_int(t_3c_int, bs_env, i_cell_s1_m_r1_p_r2, i_cell_r2_m_r1)
1188 CALL dbt_contract(alpha=1.0_dp, &
1189 tensor_1=w_r(i_cell_r2), &
1190 tensor_2=t_3c_int, &
1193 contract_1=[1], notcontract_1=[2], map_1=[1], &
1194 contract_2=[1], notcontract_2=[2, 3], map_2=[2, 3], &
1195 filter_eps=bs_env%eps_filter)
1198 CALL dbt_copy(t_w_tmp, t_w(i_cell_s1, i_cell_r1), order=[1, 2, 3], &
1199 move_data=.true., summation=.true.)
1205 CALL dbt_destroy(t_w_tmp)
1206 CALL dbt_destroy(t_3c_int)
1208 CALL timestop(handle)
1210 END SUBROUTINE contract_w
1224 SUBROUTINE contract_to_sigma(Sigma_R, t_W, G_S, i_task_Delta_R_local, bs_env, occ, vir, &
1225 clear_t_W, fill_skip)
1226 TYPE(dbt_type),
DIMENSION(:) :: sigma_r
1227 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_w
1228 TYPE(dbt_type),
DIMENSION(:) :: g_s
1229 INTEGER :: i_task_delta_r_local
1231 LOGICAL :: occ, vir, clear_t_w, fill_skip
1233 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_to_Sigma'
1235 INTEGER :: handle, handle2, i_cell_delta_r, i_cell_m_r1, i_cell_r, i_cell_r1, &
1236 i_cell_r1_minus_r, i_cell_s1, i_cell_s1_minus_r, i_cell_s1_p_s2_m_r1, i_cell_s2
1237 INTEGER(KIND=int_8) :: flop, flop_tmp
1238 INTEGER,
DIMENSION(3) :: cell_dr, cell_m_r1, cell_r, cell_r1, &
1239 cell_r1_minus_r, cell_s1, &
1240 cell_s1_minus_r, cell_s1_p_s2_m_r1, &
1242 LOGICAL :: cell_found
1243 REAL(kind=
dp) :: sign_sigma
1244 TYPE(dbt_type) :: t_3c_int, t_g, t_g_2
1246 CALL timeset(routinen, handle)
1248 cpassert(occ .EQV. (.NOT. vir))
1249 IF (occ) sign_sigma = -1.0_dp
1250 IF (vir) sign_sigma = 1.0_dp
1252 CALL dbt_create(bs_env%t_RI_AO__AO, t_g)
1253 CALL dbt_create(bs_env%t_RI_AO__AO, t_g_2)
1254 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_int)
1256 i_cell_delta_r = bs_env%task_Delta_R(i_task_delta_r_local)
1260 DO i_cell_r1 = 1, bs_env%nimages_3c
1262 cell_r1(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r1)
1263 cell_dr(1:3) = bs_env%index_to_cell_Delta_R(1:3, i_cell_delta_r)
1266 CALL add_r(cell_r1, cell_dr, bs_env%index_to_cell_3c, cell_s1, cell_found, &
1267 bs_env%cell_to_index_3c, i_cell_s1)
1268 IF (.NOT. cell_found) cycle
1270 DO i_cell_s2 = 1, bs_env%nimages_scf_desymm
1272 IF (bs_env%skip_DR_R1_S2_Gx3c_Sigma(i_task_delta_r_local, i_cell_r1, i_cell_s2)) cycle
1274 cell_s2(1:3) = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_s2)
1275 cell_m_r1(1:3) = -cell_r1(1:3)
1276 cell_s1_p_s2_m_r1(1:3) = cell_s1(1:3) + cell_s2(1:3) - cell_r1(1:3)
1279 IF (.NOT. cell_found) cycle
1282 IF (.NOT. cell_found) cycle
1284 i_cell_m_r1 = bs_env%cell_to_index_3c(cell_m_r1(1), cell_m_r1(2), cell_m_r1(3))
1285 i_cell_s1_p_s2_m_r1 = bs_env%cell_to_index_3c(cell_s1_p_s2_m_r1(1), &
1286 cell_s1_p_s2_m_r1(2), &
1287 cell_s1_p_s2_m_r1(3))
1289 CALL timeset(routinen//
"_3c_x_G", handle2)
1291 CALL get_t_3c_int(t_3c_int, bs_env, i_cell_m_r1, i_cell_s1_p_s2_m_r1)
1296 CALL dbt_contract(alpha=1.0_dp, &
1297 tensor_1=g_s(i_cell_s2), &
1298 tensor_2=t_3c_int, &
1301 contract_1=[2], notcontract_1=[1], map_1=[3], &
1302 contract_2=[3], notcontract_2=[1, 2], map_2=[1, 2], &
1303 filter_eps=bs_env%eps_filter, flop=flop_tmp)
1305 IF (flop_tmp == 0_int_8 .AND. fill_skip)
THEN
1306 bs_env%skip_DR_R1_S2_Gx3c_Sigma(i_task_delta_r_local, i_cell_r1, i_cell_s2) = .true.
1309 CALL timestop(handle2)
1313 CALL dbt_copy(t_g, t_g_2, order=[1, 3, 2], move_data=.true.)
1315 CALL timeset(routinen//
"_contract", handle2)
1317 DO i_cell_r = 1, bs_env%nimages_scf_desymm
1319 IF (bs_env%skip_DR_R1_R_MxM_Sigma(i_task_delta_r_local, i_cell_r1, i_cell_r)) cycle
1321 cell_r = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_r)
1324 CALL add_r(cell_r1, -cell_r, bs_env%index_to_cell_3c, cell_r1_minus_r, &
1325 cell_found, bs_env%cell_to_index_3c, i_cell_r1_minus_r)
1326 IF (.NOT. cell_found) cycle
1329 CALL add_r(cell_s1, -cell_r, bs_env%index_to_cell_3c, cell_s1_minus_r, &
1330 cell_found, bs_env%cell_to_index_3c, i_cell_s1_minus_r)
1331 IF (.NOT. cell_found) cycle
1336 CALL dbt_contract(alpha=sign_sigma, &
1338 tensor_2=t_w(i_cell_s1_minus_r, i_cell_r1_minus_r), &
1340 tensor_3=sigma_r(i_cell_r), &
1341 contract_1=[1, 2], notcontract_1=[3], map_1=[1], &
1342 contract_2=[1, 2], notcontract_2=[3], map_2=[2], &
1343 filter_eps=bs_env%eps_filter, flop=flop_tmp)
1345 flop = flop + flop_tmp
1347 IF (flop_tmp == 0_int_8 .AND. fill_skip)
THEN
1348 bs_env%skip_DR_R1_R_MxM_Sigma(i_task_delta_r_local, i_cell_r1, i_cell_r) = .true.
1353 CALL dbt_clear(t_g_2)
1355 CALL timestop(handle2)
1359 IF (vir .AND. flop == 0_int_8) bs_env%skip_DR_Sigma(i_task_delta_r_local) = .true.
1363 DO i_cell_s1 = 1, bs_env%nimages_3c
1364 DO i_cell_r1 = 1, bs_env%nimages_3c
1365 CALL dbt_clear(t_w(i_cell_s1, i_cell_r1))
1370 CALL dbt_destroy(t_g)
1371 CALL dbt_destroy(t_g_2)
1372 CALL dbt_destroy(t_3c_int)
1374 CALL timestop(handle)
1376 END SUBROUTINE contract_to_sigma
1384 SUBROUTINE fm_mwm_r_t_to_local_tensor_w_r(fm_W_R, W_R, bs_env)
1386 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: w_r
1389 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_MWM_R_t_to_local_tensor_W_R'
1391 INTEGER :: handle, i_cell_r
1393 CALL timeset(routinen, handle)
1396 DO i_cell_r = 1, bs_env%nimages_scf_desymm
1398 bs_env%mat_RI_RI_tensor%matrix, w_r(i_cell_r), bs_env)
1401 CALL timestop(handle)
1403 END SUBROUTINE fm_mwm_r_t_to_local_tensor_w_r
1409 SUBROUTINE compute_qp_energies(bs_env)
1412 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_QP_energies'
1414 INTEGER :: handle, ikp, ispin, j_t
1415 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sigma_x_ikp_n
1416 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: sigma_c_ikp_n_freq, sigma_c_ikp_n_time
1419 CALL timeset(routinen, handle)
1421 CALL cp_cfm_create(cfm_mo_coeff, bs_env%fm_s_Gamma%matrix_struct)
1422 ALLOCATE (sigma_x_ikp_n(bs_env%n_ao))
1423 ALLOCATE (sigma_c_ikp_n_time(bs_env%n_ao, bs_env%num_time_freq_points, 2))
1424 ALLOCATE (sigma_c_ikp_n_freq(bs_env%n_ao, bs_env%num_time_freq_points, 2))
1426 DO ispin = 1, bs_env%n_spin
1428 DO ikp = 1, bs_env%nkp_bs_and_DOS
1431 CALL cp_cfm_to_cfm(bs_env%cfm_mo_coeff_kp(ikp, ispin), cfm_mo_coeff)
1435 CALL trafo_to_k_and_nn(bs_env%fm_Sigma_x_R, sigma_x_ikp_n, cfm_mo_coeff, bs_env, ikp)
1439 DO j_t = 1, bs_env%num_time_freq_points
1440 CALL trafo_to_k_and_nn(bs_env%fm_Sigma_c_R_pos_tau(:, j_t, ispin), &
1441 sigma_c_ikp_n_time(:, j_t, 1), cfm_mo_coeff, bs_env, ikp)
1442 CALL trafo_to_k_and_nn(bs_env%fm_Sigma_c_R_neg_tau(:, j_t, ispin), &
1443 sigma_c_ikp_n_time(:, j_t, 2), cfm_mo_coeff, bs_env, ikp)
1447 CALL time_to_freq(bs_env, sigma_c_ikp_n_time, sigma_c_ikp_n_freq, ispin)
1452 bs_env%v_xc_n(:, ikp, ispin), &
1453 bs_env%eigenval_scf(:, ikp, ispin), ikp, ispin)
1463 CALL timestop(handle)
1465 END SUBROUTINE compute_qp_energies
1475 SUBROUTINE trafo_to_k_and_nn(fm_rs, array_ikp_n, cfm_mo_coeff, bs_env, ikp)
1477 REAL(kind=
dp),
DIMENSION(:) :: array_ikp_n
1482 CHARACTER(LEN=*),
PARAMETER :: routinen =
'trafo_to_k_and_nn'
1484 INTEGER :: handle, n_ao
1488 CALL timeset(routinen, handle)
1492 CALL cp_fm_create(fm_ikp_re, cfm_mo_coeff%matrix_struct)
1495 CALL fm_rs_to_kp(cfm_ikp, fm_rs, bs_env%kpoints_DOS, ikp)
1511 CALL timestop(handle)
1513 END SUBROUTINE trafo_to_k_and_nn
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, matrix_struct, para_env)
Returns information about a full matrix.
subroutine, public cp_cfm_to_fm(msource, mtargetr, mtargeti)
Copy real and imaginary parts of a complex full matrix into separate real-value full matrices.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, set_zero)
Creates a new full matrix with the given structure.
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_diag(matrix, diag)
returns the diagonal elements of a fm
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp, set_zero)
creates a new full matrix with the given structure
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
This is the start of a dbt_api, all publically needed functions are exported here....
subroutine, public fm_to_local_tensor(fm_global, mat_global, mat_local, tensor, bs_env, atom_ranges)
...
subroutine, public local_dbt_to_global_fm(t_r, fm_r, mat_global, mat_local, bs_env)
...
subroutine, public local_array_to_fm(array_s, fm_s, weight, add)
...
subroutine, public fm_to_local_array(fm_s, array_s, weight, add)
...
subroutine, public gw_calc_small_cell_full_kp(qs_env, bs_env)
Perform GW band structure calculation.
subroutine, public get_v_tr_r(v_tr_r, pot_type, regularization_ri, bs_env, qs_env)
...
subroutine, public time_to_freq(bs_env, sigma_c_n_time, sigma_c_n_freq, ispin)
...
subroutine, public de_init_bs_env(bs_env)
...
subroutine, public analyt_conti_and_print(bs_env, sigma_c_ikp_n_freq, sigma_x_ikp_n, v_xc_ikp_n, eigenval_scf, ikp, ispin)
...
subroutine, public add_r(cell_1, cell_2, index_to_cell, cell_1_plus_2, cell_found, cell_to_index, i_cell_1_plus_2)
...
subroutine, public power(matrix, exponent, eps, cond_nr, min_ev, max_ev)
...
subroutine, public is_cell_in_index_to_cell(cell, index_to_cell, cell_found)
...
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
Routines to compute the Coulomb integral V_(alpha beta)(k) for a k-point k using lattice summation in...
subroutine, public build_2c_coulomb_matrix_kp_small_cell(v_k, qs_env, kpoints, size_lattice_sum, basis_type, ikp_start, ikp_end)
...
Implements transformations from k-space to R-space for Fortran array matrices.
subroutine, public rs_to_kp(rs_real, ks_complex, index_to_cell, xkp, deriv_direction, hmat)
Integrate RS matrices (stored as Fortran array) into a kpoint matrix at given kp.
subroutine, public fm_add_kp_to_all_rs(cfm_kp, fm_rs, kpoints, ikp)
Adds given kpoint matrix to a single rs matrix.
subroutine, public add_kp_to_all_rs(array_kp, array_rs, kpoints, ikp, index_to_cell_ext)
Adds given kpoint matrix to all rs matrices.
subroutine, public fm_rs_to_kp(cfm_kp, fm_rs, kpoints, ikp)
Transforms array of fm RS matrices into cfm k-space matrix, at given kpoint index.
Machine interface based on Fortran 2003 and POSIX.
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public z_zero
Collection of simple mathematical functions and subroutines.
basic linear algebra operations for full matrixes
subroutine, public get_all_vbm_cbm_bandgaps(bs_env)
...
Represent a complex full matrix.