59#include "./base/base_uses.f90"
65 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'gw_tensor_small_cell_full_kp'
82 CHARACTER(LEN=*),
PARAMETER :: routinen =
'gw_calc_tensor_small_cell_full_kp'
86 CALL timeset(routinen, handle)
95 CALL compute_chi(bs_env)
99 CALL compute_w_real_space(bs_env, qs_env)
106 CALL compute_sigma_x(bs_env, qs_env)
110 CALL compute_sigma_c(bs_env)
113 CALL compute_qp_energies(bs_env)
117 CALL timestop(handle)
125 SUBROUTINE compute_chi(bs_env)
128 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_chi'
130 INTEGER :: cell_dr(3), cell_r1(3), cell_r2(3), &
131 handle, i_cell_delta_r, i_cell_r1, &
132 i_cell_r2, i_t, i_task_delta_r_local, &
134 LOGICAL :: cell_found
135 REAL(kind=
dp) :: t1, tau
136 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: gocc_s, gvir_s, t_chi_r
137 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_gocc, t_gvir
139 CALL timeset(routinen, handle)
141 DO i_t = 1, bs_env%num_time_freq_points
143 CALL dbt_create_2c_r(gocc_s, bs_env%t_G, bs_env%nimages_scf_desymm)
144 CALL dbt_create_2c_r(gvir_s, bs_env%t_G, bs_env%nimages_scf_desymm)
145 CALL dbt_create_2c_r(t_chi_r, bs_env%t_chi, bs_env%nimages_scf_desymm)
146 CALL dbt_create_3c_r1_r2(t_gocc, bs_env%t_RI_AO__AO, bs_env%nimages_3c, bs_env%nimages_3c)
147 CALL dbt_create_3c_r1_r2(t_gvir, bs_env%t_RI_AO__AO, bs_env%nimages_3c, bs_env%nimages_3c)
150 tau = bs_env%time_frequency_grid%imaginary_time(i_t)
152 DO ispin = 1, bs_env%n_spin
159 CALL g_occ_vir(bs_env, tau, gocc_s, ispin, occ=.true., vir=.false.)
160 CALL g_occ_vir(bs_env, tau, gvir_s, ispin, occ=.false., vir=.true.)
163 DO i_task_delta_r_local = 1, bs_env%n_tasks_Delta_R_local
165 IF (bs_env%skip_DR_chi(i_task_delta_r_local)) cycle
167 i_cell_delta_r = bs_env%task_Delta_R(i_task_delta_r_local)
169 DO i_cell_r2 = 1, bs_env%nimages_3c
171 cell_r2(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r2)
172 cell_dr(1:3) = bs_env%index_to_cell_Delta_R(1:3, i_cell_delta_r)
175 CALL add_r(cell_r2, cell_dr, bs_env%index_to_cell_3c, cell_r1, &
176 cell_found, bs_env%cell_to_index_3c, i_cell_r1)
179 IF (.NOT. cell_found) cycle
181 CALL g_times_3c(gocc_s, t_gocc, bs_env, i_cell_r1, i_cell_r2, &
182 i_task_delta_r_local, bs_env%skip_DR_R12_S_Goccx3c_chi)
183 CALL g_times_3c(gvir_s, t_gvir, bs_env, i_cell_r2, i_cell_r1, &
184 i_task_delta_r_local, bs_env%skip_DR_R12_S_Gvirx3c_chi)
189 CALL contract_m_occ_vir_to_chi(t_gocc, t_gvir, t_chi_r, bs_env, &
190 i_task_delta_r_local)
196 CALL bs_env%para_env%sync()
198 CALL cp_dbt_to_fm(t_chi_r, bs_env%fm_chi_R_t(:, i_t), bs_env%mat_RI_RI, bs_env%mat_RI_RI_tensor, &
201 CALL destroy_t_1d(gocc_s)
202 CALL destroy_t_1d(gvir_s)
203 CALL destroy_t_1d(t_chi_r)
204 CALL destroy_t_2d(t_gocc)
205 CALL destroy_t_2d(t_gvir)
207 IF (bs_env%unit_nr > 0)
THEN
208 WRITE (bs_env%unit_nr,
'(T2,A,I13,A,I3,A,F7.1,A)') &
209 'Computed χ^R(iτ) for time point', i_t,
' /', bs_env%num_time_freq_points, &
215 CALL timestop(handle)
217 END SUBROUTINE compute_chi
225 SUBROUTINE dbt_create_2c_r(R, template, nimages)
227 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: r
228 TYPE(dbt_type) :: template
231 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dbt_create_2c_R'
233 INTEGER :: handle, i_cell_s
235 CALL timeset(routinen, handle)
237 ALLOCATE (r(nimages))
238 DO i_cell_s = 1, nimages
239 CALL dbt_create(template, r(i_cell_s))
242 CALL timestop(handle)
244 END SUBROUTINE dbt_create_2c_r
253 SUBROUTINE dbt_create_3c_r1_r2(t_3c_R1_R2, t_3c_template, nimages_1, nimages_2)
255 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_3c_r1_r2
256 TYPE(dbt_type) :: t_3c_template
257 INTEGER :: nimages_1, nimages_2
259 CHARACTER(LEN=*),
PARAMETER :: routinen =
'dbt_create_3c_R1_R2'
261 INTEGER :: handle, i_cell, j_cell
263 CALL timeset(routinen, handle)
265 ALLOCATE (t_3c_r1_r2(nimages_1, nimages_2))
266 DO i_cell = 1, nimages_1
267 DO j_cell = 1, nimages_2
268 CALL dbt_create(t_3c_template, t_3c_r1_r2(i_cell, j_cell))
272 CALL timestop(handle)
274 END SUBROUTINE dbt_create_3c_r1_r2
286 SUBROUTINE g_times_3c(t_G_S, t_M, bs_env, i_cell_R1, i_cell_R2, i_task_Delta_R_local, &
288 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: t_g_s
289 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_m
291 INTEGER :: i_cell_r1, i_cell_r2, &
293 LOGICAL,
ALLOCATABLE,
DIMENSION(:, :, :) :: skip_dr_r1_s_gx3c
295 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_times_3c'
297 INTEGER :: handle, i_cell_r1_p_s, i_cell_s
298 INTEGER(KIND=int_8) :: flop
299 INTEGER,
DIMENSION(3) :: cell_r1, cell_r1_plus_cell_s, cell_r2, &
301 LOGICAL :: cell_found
302 TYPE(dbt_type) :: t_3c_int
304 CALL timeset(routinen, handle)
306 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_int)
308 cell_r1(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r1)
309 cell_r2(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r2)
311 DO i_cell_s = 1, bs_env%nimages_scf_desymm
313 IF (skip_dr_r1_s_gx3c(i_task_delta_r_local, i_cell_r1, i_cell_s)) cycle
315 cell_s(1:3) = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_s)
316 cell_r1_plus_cell_s(1:3) = cell_r1(1:3) + cell_s(1:3)
320 IF (.NOT. cell_found) cycle
322 i_cell_r1_p_s = bs_env%cell_to_index_3c(cell_r1_plus_cell_s(1), cell_r1_plus_cell_s(2), &
323 cell_r1_plus_cell_s(3))
325 IF (bs_env%nblocks_3c(i_cell_r2, i_cell_r1_p_s) == 0) cycle
327 CALL get_t_3c_int(t_3c_int, bs_env, i_cell_r2, i_cell_r1_p_s)
329 CALL dbt_contract(alpha=1.0_dp, &
331 tensor_2=t_g_s(i_cell_s), &
333 tensor_3=t_m(i_cell_r1, i_cell_r2), &
334 contract_1=[3], notcontract_1=[1, 2], map_1=[1, 2], &
335 contract_2=[2], notcontract_2=[1], map_2=[3], &
336 filter_eps=bs_env%eps_filter, flop=flop)
338 IF (flop == 0_int_8) skip_dr_r1_s_gx3c(i_task_delta_r_local, i_cell_r1, i_cell_s) = .true.
342 CALL dbt_destroy(t_3c_int)
344 CALL timestop(handle)
346 END SUBROUTINE g_times_3c
355 SUBROUTINE get_t_3c_int(t_3c_int, bs_env, j_cell, k_cell)
357 TYPE(dbt_type) :: t_3c_int
359 INTEGER :: j_cell, k_cell
361 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_t_3c_int'
365 CALL timeset(routinen, handle)
367 CALL dbt_clear(t_3c_int)
368 IF (j_cell < k_cell)
THEN
369 CALL dbt_copy(bs_env%t_3c_int(k_cell, j_cell), t_3c_int, order=[1, 3, 2])
371 CALL dbt_copy(bs_env%t_3c_int(j_cell, k_cell), t_3c_int)
374 CALL timestop(handle)
376 END SUBROUTINE get_t_3c_int
387 SUBROUTINE g_occ_vir(bs_env, tau, G_S, ispin, occ, vir)
390 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: g_s
394 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_occ_vir'
396 INTEGER :: first_mo, handle, homo, i_cell_s, ikp, &
398 REAL(kind=
dp) :: tau_e
399 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: column_factors
401 CALL timeset(routinen, handle)
403 cpassert(occ .NEQV. vir)
405 nkp = bs_env%nkp_scf_desymm
406 homo = bs_env%n_occ(ispin)
411 last_mo = bs_env%n_ao
413 ALLOCATE (column_factors(first_mo:last_mo))
415 DO i_cell_s = 1, bs_env%nimages_scf_desymm
422 DO j = first_mo, last_mo
424 tau_e = abs(tau*0.5_dp*(bs_env%eigenval_scf(j, ikp, ispin) - bs_env%e_fermi(ispin)))
425 IF (tau_e < bs_env%stabilize_exp)
THEN
426 column_factors(j) = exp(-tau_e)
428 column_factors(j) = 0.0_dp
433 bs_env%cfm_work_mo, bs_env%cfm_work_mo_2)
437 bs_env%kpoints_scf_desymm, ikp)
440 DEALLOCATE (column_factors)
443 DO i_cell_s = 1, bs_env%nimages_scf_desymm
444 CALL cp_fm_to_dbt(bs_env%fm_G_S(i_cell_s), bs_env%mat_ao_ao%matrix, bs_env%mat_ao_ao_tensor%matrix, &
445 g_s(i_cell_s), bs_env%para_env, bs_env%para_env_tensor%num_pe, &
449 CALL timestop(handle)
451 END SUBROUTINE g_occ_vir
461 SUBROUTINE contract_m_occ_vir_to_chi(t_Gocc, t_Gvir, t_chi_R, bs_env, i_task_Delta_R_local)
462 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_gocc, t_gvir
463 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: t_chi_r
465 INTEGER :: i_task_delta_r_local
467 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_M_occ_vir_to_chi'
469 INTEGER :: handle, i_cell_delta_r, i_cell_r, &
470 i_cell_r1, i_cell_r1_minus_r, &
471 i_cell_r2, i_cell_r2_minus_r
472 INTEGER(KIND=int_8) :: flop, flop_tmp
473 INTEGER,
DIMENSION(3) :: cell_dr, cell_r, cell_r1, &
474 cell_r1_minus_r, cell_r2, &
476 LOGICAL :: cell_found
477 TYPE(dbt_type) :: t_gocc_2, t_gvir_2
479 CALL timeset(routinen, handle)
481 CALL dbt_create(bs_env%t_RI__AO_AO, t_gocc_2)
482 CALL dbt_create(bs_env%t_RI__AO_AO, t_gvir_2)
487 DO i_cell_r = 1, bs_env%nimages_scf_desymm
489 DO i_cell_r2 = 1, bs_env%nimages_3c
491 IF (bs_env%skip_DR_R_R2_MxM_chi(i_task_delta_r_local, i_cell_r2, i_cell_r)) cycle
493 i_cell_delta_r = bs_env%task_Delta_R(i_task_delta_r_local)
495 cell_r(1:3) = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_r)
496 cell_r2(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r2)
497 cell_dr(1:3) = bs_env%index_to_cell_Delta_R(1:3, i_cell_delta_r)
500 CALL add_r(cell_r2, cell_dr, bs_env%index_to_cell_3c, cell_r1, &
501 cell_found, bs_env%cell_to_index_3c, i_cell_r1)
502 IF (.NOT. cell_found) cycle
505 CALL add_r(cell_r1, -cell_r, bs_env%index_to_cell_3c, cell_r1_minus_r, &
506 cell_found, bs_env%cell_to_index_3c, i_cell_r1_minus_r)
507 IF (.NOT. cell_found) cycle
510 CALL add_r(cell_r2, -cell_r, bs_env%index_to_cell_3c, cell_r2_minus_r, &
511 cell_found, bs_env%cell_to_index_3c, i_cell_r2_minus_r)
512 IF (.NOT. cell_found) cycle
515 CALL dbt_copy(t_gocc(i_cell_r1, i_cell_r2), t_gocc_2, order=[1, 3, 2])
516 CALL dbt_copy(t_gvir(i_cell_r2_minus_r, i_cell_r1_minus_r), t_gvir_2)
519 CALL dbt_contract(alpha=bs_env%spin_degeneracy, &
520 tensor_1=t_gocc_2, tensor_2=t_gvir_2, &
521 beta=1.0_dp, tensor_3=t_chi_r(i_cell_r), &
522 contract_1=[2, 3], notcontract_1=[1], map_1=[1], &
523 contract_2=[2, 3], notcontract_2=[1], map_2=[2], &
524 filter_eps=bs_env%eps_filter, move_data=.true., flop=flop_tmp)
526 IF (flop_tmp == 0_int_8) bs_env%skip_DR_R_R2_MxM_chi(i_task_delta_r_local, &
527 i_cell_r2, i_cell_r) = .true.
529 flop = flop + flop_tmp
535 IF (flop == 0_int_8) bs_env%skip_DR_chi(i_task_delta_r_local) = .true.
538 DO i_cell_r1 = 1, bs_env%nimages_3c
539 DO i_cell_r2 = 1, bs_env%nimages_3c
540 CALL dbt_clear(t_gocc(i_cell_r1, i_cell_r2))
541 CALL dbt_clear(t_gvir(i_cell_r1, i_cell_r2))
545 CALL dbt_destroy(t_gocc_2)
546 CALL dbt_destroy(t_gvir_2)
548 CALL timestop(handle)
550 END SUBROUTINE contract_m_occ_vir_to_chi
557 SUBROUTINE compute_w_real_space(bs_env, qs_env)
561 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_W_real_space'
563 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: chi_k_w, eps_k_w, w_k_w
564 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_inv, m_inv_v_sqrt, v_sqrt
565 INTEGER :: handle, i_cell_r, i_t, ikp, ikp_local, &
566 j_w, n_ri, nimages_scf_desymm
567 REAL(kind=
dp) :: t1, weight_ij
568 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: chi_r, mwm_r, w_r
570 CALL timeset(routinen, handle)
573 nimages_scf_desymm = bs_env%nimages_scf_desymm
575 ALLOCATE (chi_k_w(n_ri, n_ri), eps_k_w(n_ri, n_ri), w_k_w(n_ri, n_ri))
576 ALLOCATE (chi_r(n_ri, n_ri, nimages_scf_desymm), w_r(n_ri, n_ri, nimages_scf_desymm), &
577 mwm_r(n_ri, n_ri, nimages_scf_desymm))
581 CALL compute_minv_and_vsqrt(bs_env, qs_env, m_inv_v_sqrt, m_inv, v_sqrt)
583 IF (bs_env%unit_nr > 0)
THEN
584 WRITE (bs_env%unit_nr,
'(T2,A,T58,A,F7.1,A)') &
585 'Computed V_PQ(k),',
'Execution time',
m_walltime() - t1,
' s'
586 WRITE (bs_env%unit_nr,
'(A)')
' '
591 DO j_w = 1, bs_env%num_time_freq_points
594 chi_r(:, :, :) = 0.0_dp
595 DO i_t = 1, bs_env%num_time_freq_points
596 weight_ij = bs_env%time_frequency_grid%cosine_time_to_frequency(j_w, i_t)
602 w_r(:, :, :) = 0.0_dp
603 DO ikp = 1, bs_env%nkp_chi_eps_W_orig_plus_extra
606 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
608 ikp_local = ikp_local + 1
611 CALL rs_to_kp(chi_r, chi_k_w, bs_env%kpoints_scf_desymm%index_to_cell, &
612 bs_env%kpoints_chi_eps_W%xkp(1:3, ikp))
619 CALL gemm_square(m_inv_v_sqrt(:, :, ikp_local),
'C', chi_k_w,
'N', &
620 m_inv_v_sqrt(:, :, ikp_local),
'N', eps_k_w)
633 CALL gemm_square(v_sqrt(:, :, ikp_local),
'N', eps_k_w,
'N', &
634 v_sqrt(:, :, ikp_local),
'C', w_k_w)
638 index_to_cell_ext=bs_env%kpoints_scf_desymm%index_to_cell)
642 CALL bs_env%para_env%sync()
643 CALL bs_env%para_env%sum(w_r)
647 CALL mult_w_with_minv(w_r, mwm_r, bs_env, qs_env)
650 DO i_t = 1, bs_env%num_time_freq_points
651 weight_ij = bs_env%time_frequency_grid%cosine_frequency_to_time(i_t, j_w)
652 DO i_cell_r = 1, nimages_scf_desymm
654 alpha=weight_ij, beta=1.0_dp)
660 IF (bs_env%unit_nr > 0)
THEN
661 WRITE (bs_env%unit_nr,
'(T2,A,T60,A,F7.1,A)') &
662 'Computed W_PQ(k,iω) for all k and τ,',
'Execution time',
m_walltime() - t1,
' s'
663 WRITE (bs_env%unit_nr,
'(A)')
' '
666 CALL timestop(handle)
668 END SUBROUTINE compute_w_real_space
678 SUBROUTINE compute_minv_and_vsqrt(bs_env, qs_env, M_inv_V_sqrt, M_inv, V_sqrt)
681 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_inv_v_sqrt, m_inv, v_sqrt
683 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Minv_and_Vsqrt'
685 INTEGER :: handle, ikp, ikp_local, n_ri, nkp, &
687 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_r
689 CALL timeset(routinen, handle)
691 nkp = bs_env%nkp_chi_eps_W_orig_plus_extra
692 nkp_orig = bs_env%nkp_chi_eps_W_orig
698 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
699 nkp_local = nkp_local + 1
702 ALLOCATE (m_inv_v_sqrt(n_ri, n_ri, nkp_local), m_inv(n_ri, n_ri, nkp_local), &
703 v_sqrt(n_ri, n_ri, nkp_local))
705 m_inv_v_sqrt(:, :, :) =
z_zero
710 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
712 bs_env%size_lattice_sum_V, basis_type=
"RI_AUX", &
713 ikp_start=1, ikp_end=nkp_orig)
716 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_extra
718 bs_env%size_lattice_sum_V, basis_type=
"RI_AUX", &
719 ikp_start=nkp_orig + 1, ikp_end=nkp)
724 CALL get_v_tr_r(m_r, bs_env%ri_metric, bs_env%regularization_RI, bs_env, qs_env)
730 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
732 ikp_local = ikp_local + 1
735 CALL rs_to_kp(m_r, m_inv(:, :, ikp_local), &
736 bs_env%kpoints_scf_desymm%index_to_cell, &
737 bs_env%kpoints_chi_eps_W%xkp(1:3, ikp))
746 CALL gemm_square(m_inv(:, :, ikp_local),
'N', v_sqrt(:, :, ikp_local),
'C', m_inv_v_sqrt(:, :, ikp_local))
750 CALL timestop(handle)
752 END SUBROUTINE compute_minv_and_vsqrt
761 SUBROUTINE mult_w_with_minv(W_R, MWM_R, bs_env, qs_env)
762 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: w_r, mwm_r
766 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mult_W_with_Minv'
768 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: m_inv, w_k, work
769 INTEGER :: handle, ikp, n_ri
770 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_r
772 CALL timeset(routinen, handle)
775 CALL get_v_tr_r(m_r, bs_env%ri_metric, bs_env%regularization_RI, bs_env, qs_env)
778 ALLOCATE (m_inv(n_ri, n_ri), w_k(n_ri, n_ri), work(n_ri, n_ri))
779 mwm_r(:, :, :) = 0.0_dp
781 DO ikp = 1, bs_env%nkp_scf_desymm
784 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
788 bs_env%kpoints_scf_desymm%index_to_cell, &
789 bs_env%kpoints_scf_desymm%xkp(1:3, ikp))
796 bs_env%kpoints_scf_desymm%index_to_cell, &
797 bs_env%kpoints_scf_desymm%xkp(1:3, ikp))
800 CALL gemm_square(m_inv,
'N', w_k,
'N', m_inv,
'N', work)
801 w_k(:, :) = work(:, :)
808 CALL bs_env%para_env%sync()
809 CALL bs_env%para_env%sum(mwm_r)
811 CALL timestop(handle)
813 END SUBROUTINE mult_w_with_minv
820 SUBROUTINE compute_sigma_x(bs_env, qs_env)
824 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Sigma_x'
826 INTEGER :: handle, i_task_delta_r_local, ispin
828 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: d_s, mi_vtr_mi_r, sigma_x_r
829 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_v
831 CALL timeset(routinen, handle)
833 CALL dbt_create_2c_r(mi_vtr_mi_r, bs_env%t_W, bs_env%nimages_scf_desymm)
834 CALL dbt_create_2c_r(d_s, bs_env%t_G, bs_env%nimages_scf_desymm)
835 CALL dbt_create_2c_r(sigma_x_r, bs_env%t_G, bs_env%nimages_scf_desymm)
836 CALL dbt_create_3c_r1_r2(t_v, bs_env%t_RI_AO__AO, bs_env%nimages_3c, bs_env%nimages_3c)
843 CALL get_minv_vtr_minv_r(mi_vtr_mi_r, bs_env, qs_env)
847 DO ispin = 1, bs_env%n_spin
851 CALL g_occ_vir(bs_env, 0.0_dp, d_s, ispin, occ=.true., vir=.false.)
854 DO i_task_delta_r_local = 1, bs_env%n_tasks_Delta_R_local
857 CALL contract_w(t_v, mi_vtr_mi_r, bs_env, i_task_delta_r_local)
862 CALL contract_to_sigma(sigma_x_r, t_v, d_s, i_task_delta_r_local, bs_env, &
863 occ=.true., vir=.false., clear_t_w=.true., fill_skip=.false.)
867 CALL bs_env%para_env%sync()
869 CALL cp_dbt_to_fm(sigma_x_r, bs_env%fm_Sigma_x_R, bs_env%mat_ao_ao, bs_env%mat_ao_ao_tensor, &
874 IF (bs_env%unit_nr > 0)
THEN
875 WRITE (bs_env%unit_nr,
'(T2,A,T58,A,F7.1,A)') &
876 'Computed Σ^x,',
' Execution time',
m_walltime() - t1,
' s'
877 WRITE (bs_env%unit_nr,
'(A)')
' '
880 CALL destroy_t_1d(mi_vtr_mi_r)
881 CALL destroy_t_1d(d_s)
882 CALL destroy_t_1d(sigma_x_r)
883 CALL destroy_t_2d(t_v)
885 CALL timestop(handle)
887 END SUBROUTINE compute_sigma_x
893 SUBROUTINE compute_sigma_c(bs_env)
896 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Sigma_c'
898 INTEGER :: handle, i_t, i_task_delta_r_local, ispin
899 REAL(kind=
dp) :: t1, tau
900 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: gocc_s, gvir_s, sigma_c_r_neg_tau, &
901 sigma_c_r_pos_tau, w_r
902 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_w
904 CALL timeset(routinen, handle)
906 CALL dbt_create_2c_r(gocc_s, bs_env%t_G, bs_env%nimages_scf_desymm)
907 CALL dbt_create_2c_r(gvir_s, bs_env%t_G, bs_env%nimages_scf_desymm)
908 CALL dbt_create_2c_r(w_r, bs_env%t_W, bs_env%nimages_scf_desymm)
909 CALL dbt_create_3c_r1_r2(t_w, bs_env%t_RI_AO__AO, bs_env%nimages_3c, bs_env%nimages_3c)
910 CALL dbt_create_2c_r(sigma_c_r_neg_tau, bs_env%t_G, bs_env%nimages_scf_desymm)
911 CALL dbt_create_2c_r(sigma_c_r_pos_tau, bs_env%t_G, bs_env%nimages_scf_desymm)
915 DO i_t = 1, bs_env%num_time_freq_points
917 DO ispin = 1, bs_env%n_spin
921 tau = bs_env%time_frequency_grid%imaginary_time(i_t)
926 CALL g_occ_vir(bs_env, tau, gocc_s, ispin, occ=.true., vir=.false.)
927 CALL g_occ_vir(bs_env, tau, gvir_s, ispin, occ=.false., vir=.true.)
930 CALL fm_mwm_r_t_to_local_tensor_w_r(bs_env%fm_MWM_R_t(:, i_t), w_r, bs_env)
933 DO i_task_delta_r_local = 1, bs_env%n_tasks_Delta_R_local
935 IF (bs_env%skip_DR_Sigma(i_task_delta_r_local)) cycle
939 CALL contract_w(t_w, w_r, bs_env, i_task_delta_r_local)
945 CALL contract_to_sigma(sigma_c_r_neg_tau, t_w, gocc_s, i_task_delta_r_local, bs_env, &
946 occ=.true., vir=.false., clear_t_w=.false., fill_skip=.false.)
949 CALL contract_to_sigma(sigma_c_r_pos_tau, t_w, gvir_s, i_task_delta_r_local, bs_env, &
950 occ=.false., vir=.true., clear_t_w=.true., fill_skip=.true.)
954 CALL bs_env%para_env%sync()
956 CALL cp_dbt_to_fm(sigma_c_r_pos_tau, bs_env%fm_Sigma_c_R_pos_tau(:, i_t, ispin), bs_env%mat_ao_ao, &
957 bs_env%mat_ao_ao_tensor, bs_env%para_env)
959 CALL cp_dbt_to_fm(sigma_c_r_neg_tau, bs_env%fm_Sigma_c_R_neg_tau(:, i_t, ispin), bs_env%mat_ao_ao, &
960 bs_env%mat_ao_ao_tensor, bs_env%para_env)
962 IF (bs_env%unit_nr > 0)
THEN
963 WRITE (bs_env%unit_nr,
'(T2,A,I10,A,I3,A,F7.1,A)') &
964 'Computed Σ^c(iτ) for time point ', i_t,
' /', bs_env%num_time_freq_points, &
972 CALL destroy_t_1d(gocc_s)
973 CALL destroy_t_1d(gvir_s)
974 CALL destroy_t_1d(w_r)
975 CALL destroy_t_1d(sigma_c_r_neg_tau)
976 CALL destroy_t_1d(sigma_c_r_pos_tau)
977 CALL destroy_t_2d(t_w)
979 CALL timestop(handle)
981 END SUBROUTINE compute_sigma_c
989 SUBROUTINE get_minv_vtr_minv_r(Mi_Vtr_Mi_R, bs_env, qs_env)
990 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: mi_vtr_mi_r
994 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Minv_Vtr_Minv_R'
996 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: m_kp, mi_vtr_mi_kp, v_tr_kp
997 INTEGER :: handle, i_cell_r, ikp, n_ri, &
999 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: m_r, mi_vtr_mi_r_arr, v_tr_r
1001 CALL timeset(routinen, handle)
1003 nimages_scf = bs_env%nimages_scf_desymm
1004 nkp_scf = bs_env%kpoints_scf_desymm%nkp
1007 CALL get_v_tr_r(v_tr_r, bs_env%trunc_coulomb, 0.0_dp, bs_env, qs_env)
1008 CALL get_v_tr_r(m_r, bs_env%ri_metric, bs_env%regularization_RI, bs_env, qs_env)
1010 ALLOCATE (v_tr_kp(n_ri, n_ri), m_kp(n_ri, n_ri), &
1011 mi_vtr_mi_kp(n_ri, n_ri), mi_vtr_mi_r_arr(n_ri, n_ri, nimages_scf))
1012 mi_vtr_mi_r_arr(:, :, :) = 0.0_dp
1016 IF (
modulo(ikp, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
1018 CALL rs_to_kp(v_tr_r, v_tr_kp, bs_env%kpoints_scf_desymm%index_to_cell, &
1019 bs_env%kpoints_scf_desymm%xkp(1:3, ikp))
1021 CALL rs_to_kp(m_r, m_kp, bs_env%kpoints_scf_desymm%index_to_cell, &
1022 bs_env%kpoints_scf_desymm%xkp(1:3, ikp))
1026 CALL gemm_square(m_kp,
'N', v_tr_kp,
'N', m_kp,
'N', mi_vtr_mi_kp)
1028 CALL add_kp_to_all_rs(mi_vtr_mi_kp, mi_vtr_mi_r_arr, bs_env%kpoints_scf_desymm, ikp)
1030 CALL bs_env%para_env%sync()
1031 CALL bs_env%para_env%sum(mi_vtr_mi_r_arr)
1034 DO i_cell_r = 1, nimages_scf
1039 DO i_cell_r = 1, nimages_scf
1040 CALL cp_fm_to_dbt(bs_env%fm_chi_R_t(i_cell_r, 1), bs_env%mat_RI_RI%matrix, &
1041 bs_env%mat_RI_RI_tensor%matrix, mi_vtr_mi_r(i_cell_r), bs_env%para_env, &
1042 bs_env%para_env_tensor%num_pe, bs_env%eps_filter)
1045 CALL timestop(handle)
1047 END SUBROUTINE get_minv_vtr_minv_r
1053 SUBROUTINE destroy_t_1d(t_1d)
1054 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: t_1d
1056 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_t_1d'
1058 INTEGER :: handle, i
1060 CALL timeset(routinen, handle)
1062 DO i = 1,
SIZE(t_1d)
1063 CALL dbt_destroy(t_1d(i))
1067 CALL timestop(handle)
1069 END SUBROUTINE destroy_t_1d
1075 SUBROUTINE destroy_t_2d(t_2d)
1076 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_2d
1078 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_t_2d'
1080 INTEGER :: handle, i, j
1082 CALL timeset(routinen, handle)
1084 DO i = 1,
SIZE(t_2d, 1)
1085 DO j = 1,
SIZE(t_2d, 2)
1086 CALL dbt_destroy(t_2d(i, j))
1091 CALL timestop(handle)
1093 END SUBROUTINE destroy_t_2d
1102 SUBROUTINE contract_w(t_W, W_R, bs_env, i_task_Delta_R_local)
1103 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_w
1104 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: w_r
1106 INTEGER :: i_task_delta_r_local
1108 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_W'
1110 INTEGER :: handle, i_cell_delta_r, i_cell_r1, &
1111 i_cell_r2, i_cell_r2_m_r1, i_cell_s1, &
1113 INTEGER,
DIMENSION(3) :: cell_dr, cell_r1, cell_r2, cell_r2_m_r1, &
1114 cell_s1, cell_s1_m_r2_p_r1
1115 LOGICAL :: cell_found
1116 TYPE(dbt_type) :: t_3c_int, t_w_tmp
1118 CALL timeset(routinen, handle)
1120 CALL dbt_create(bs_env%t_RI__AO_AO, t_w_tmp)
1121 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_int)
1123 i_cell_delta_r = bs_env%task_Delta_R(i_task_delta_r_local)
1125 DO i_cell_r1 = 1, bs_env%nimages_3c
1127 cell_r1(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r1)
1128 cell_dr(1:3) = bs_env%index_to_cell_Delta_R(1:3, i_cell_delta_r)
1131 CALL add_r(cell_r1, cell_dr, bs_env%index_to_cell_3c, cell_s1, &
1132 cell_found, bs_env%cell_to_index_3c, i_cell_s1)
1133 IF (.NOT. cell_found) cycle
1135 DO i_cell_r2 = 1, bs_env%nimages_scf_desymm
1137 cell_r2(1:3) = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_r2)
1140 CALL add_r(cell_r2, -cell_r1, bs_env%index_to_cell_3c, cell_r2_m_r1, &
1141 cell_found, bs_env%cell_to_index_3c, i_cell_r2_m_r1)
1142 IF (.NOT. cell_found) cycle
1145 CALL add_r(cell_s1, cell_r2_m_r1, bs_env%index_to_cell_3c, cell_s1_m_r2_p_r1, &
1146 cell_found, bs_env%cell_to_index_3c, i_cell_s1_m_r1_p_r2)
1147 IF (.NOT. cell_found) cycle
1149 CALL get_t_3c_int(t_3c_int, bs_env, i_cell_s1_m_r1_p_r2, i_cell_r2_m_r1)
1154 CALL dbt_contract(alpha=1.0_dp, &
1155 tensor_1=w_r(i_cell_r2), &
1156 tensor_2=t_3c_int, &
1159 contract_1=[1], notcontract_1=[2], map_1=[1], &
1160 contract_2=[1], notcontract_2=[2, 3], map_2=[2, 3], &
1161 filter_eps=bs_env%eps_filter)
1164 CALL dbt_copy(t_w_tmp, t_w(i_cell_s1, i_cell_r1), order=[1, 2, 3], &
1165 move_data=.true., summation=.true.)
1171 CALL dbt_destroy(t_w_tmp)
1172 CALL dbt_destroy(t_3c_int)
1174 CALL timestop(handle)
1176 END SUBROUTINE contract_w
1190 SUBROUTINE contract_to_sigma(Sigma_R, t_W, G_S, i_task_Delta_R_local, bs_env, occ, vir, &
1191 clear_t_W, fill_skip)
1192 TYPE(dbt_type),
DIMENSION(:) :: sigma_r
1193 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_w
1194 TYPE(dbt_type),
DIMENSION(:) :: g_s
1195 INTEGER :: i_task_delta_r_local
1197 LOGICAL :: occ, vir, clear_t_w, fill_skip
1199 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_to_Sigma'
1201 INTEGER :: handle, handle2, i_cell_delta_r, i_cell_m_r1, i_cell_r, i_cell_r1, &
1202 i_cell_r1_minus_r, i_cell_s1, i_cell_s1_minus_r, i_cell_s1_p_s2_m_r1, i_cell_s2
1203 INTEGER(KIND=int_8) :: flop, flop_tmp
1204 INTEGER,
DIMENSION(3) :: cell_dr, cell_m_r1, cell_r, cell_r1, &
1205 cell_r1_minus_r, cell_s1, &
1206 cell_s1_minus_r, cell_s1_p_s2_m_r1, &
1208 LOGICAL :: cell_found
1209 REAL(kind=
dp) :: sign_sigma
1210 TYPE(dbt_type) :: t_3c_int, t_g, t_g_2
1212 CALL timeset(routinen, handle)
1214 cpassert(occ .EQV. (.NOT. vir))
1215 IF (occ) sign_sigma = -1.0_dp
1216 IF (vir) sign_sigma = 1.0_dp
1218 CALL dbt_create(bs_env%t_RI_AO__AO, t_g)
1219 CALL dbt_create(bs_env%t_RI_AO__AO, t_g_2)
1220 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_int)
1222 i_cell_delta_r = bs_env%task_Delta_R(i_task_delta_r_local)
1226 DO i_cell_r1 = 1, bs_env%nimages_3c
1228 cell_r1(1:3) = bs_env%index_to_cell_3c(1:3, i_cell_r1)
1229 cell_dr(1:3) = bs_env%index_to_cell_Delta_R(1:3, i_cell_delta_r)
1232 CALL add_r(cell_r1, cell_dr, bs_env%index_to_cell_3c, cell_s1, cell_found, &
1233 bs_env%cell_to_index_3c, i_cell_s1)
1234 IF (.NOT. cell_found) cycle
1236 DO i_cell_s2 = 1, bs_env%nimages_scf_desymm
1238 IF (bs_env%skip_DR_R1_S2_Gx3c_Sigma(i_task_delta_r_local, i_cell_r1, i_cell_s2)) cycle
1240 cell_s2(1:3) = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_s2)
1241 cell_m_r1(1:3) = -cell_r1(1:3)
1242 cell_s1_p_s2_m_r1(1:3) = cell_s1(1:3) + cell_s2(1:3) - cell_r1(1:3)
1245 IF (.NOT. cell_found) cycle
1248 IF (.NOT. cell_found) cycle
1250 i_cell_m_r1 = bs_env%cell_to_index_3c(cell_m_r1(1), cell_m_r1(2), cell_m_r1(3))
1251 i_cell_s1_p_s2_m_r1 = bs_env%cell_to_index_3c(cell_s1_p_s2_m_r1(1), &
1252 cell_s1_p_s2_m_r1(2), &
1253 cell_s1_p_s2_m_r1(3))
1255 CALL timeset(routinen//
"_3c_x_G", handle2)
1257 CALL get_t_3c_int(t_3c_int, bs_env, i_cell_m_r1, i_cell_s1_p_s2_m_r1)
1262 CALL dbt_contract(alpha=1.0_dp, &
1263 tensor_1=g_s(i_cell_s2), &
1264 tensor_2=t_3c_int, &
1267 contract_1=[2], notcontract_1=[1], map_1=[3], &
1268 contract_2=[3], notcontract_2=[1, 2], map_2=[1, 2], &
1269 filter_eps=bs_env%eps_filter, flop=flop_tmp)
1271 IF (flop_tmp == 0_int_8 .AND. fill_skip)
THEN
1272 bs_env%skip_DR_R1_S2_Gx3c_Sigma(i_task_delta_r_local, i_cell_r1, i_cell_s2) = .true.
1275 CALL timestop(handle2)
1279 CALL dbt_copy(t_g, t_g_2, order=[1, 3, 2], move_data=.true.)
1281 CALL timeset(routinen//
"_contract", handle2)
1283 DO i_cell_r = 1, bs_env%nimages_scf_desymm
1285 IF (bs_env%skip_DR_R1_R_MxM_Sigma(i_task_delta_r_local, i_cell_r1, i_cell_r)) cycle
1287 cell_r = bs_env%kpoints_scf_desymm%index_to_cell(1:3, i_cell_r)
1290 CALL add_r(cell_r1, -cell_r, bs_env%index_to_cell_3c, cell_r1_minus_r, &
1291 cell_found, bs_env%cell_to_index_3c, i_cell_r1_minus_r)
1292 IF (.NOT. cell_found) cycle
1295 CALL add_r(cell_s1, -cell_r, bs_env%index_to_cell_3c, cell_s1_minus_r, &
1296 cell_found, bs_env%cell_to_index_3c, i_cell_s1_minus_r)
1297 IF (.NOT. cell_found) cycle
1302 CALL dbt_contract(alpha=sign_sigma, &
1304 tensor_2=t_w(i_cell_s1_minus_r, i_cell_r1_minus_r), &
1306 tensor_3=sigma_r(i_cell_r), &
1307 contract_1=[1, 2], notcontract_1=[3], map_1=[1], &
1308 contract_2=[1, 2], notcontract_2=[3], map_2=[2], &
1309 filter_eps=bs_env%eps_filter, flop=flop_tmp)
1311 flop = flop + flop_tmp
1313 IF (flop_tmp == 0_int_8 .AND. fill_skip)
THEN
1314 bs_env%skip_DR_R1_R_MxM_Sigma(i_task_delta_r_local, i_cell_r1, i_cell_r) = .true.
1319 CALL dbt_clear(t_g_2)
1321 CALL timestop(handle2)
1325 IF (vir .AND. flop == 0_int_8) bs_env%skip_DR_Sigma(i_task_delta_r_local) = .true.
1329 DO i_cell_s1 = 1, bs_env%nimages_3c
1330 DO i_cell_r1 = 1, bs_env%nimages_3c
1331 CALL dbt_clear(t_w(i_cell_s1, i_cell_r1))
1336 CALL dbt_destroy(t_g)
1337 CALL dbt_destroy(t_g_2)
1338 CALL dbt_destroy(t_3c_int)
1340 CALL timestop(handle)
1342 END SUBROUTINE contract_to_sigma
1350 SUBROUTINE fm_mwm_r_t_to_local_tensor_w_r(fm_W_R, W_R, bs_env)
1352 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: w_r
1355 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_MWM_R_t_to_local_tensor_W_R'
1357 INTEGER :: handle, i_cell_r
1359 CALL timeset(routinen, handle)
1362 DO i_cell_r = 1, bs_env%nimages_scf_desymm
1363 CALL cp_fm_to_dbt(fm_w_r(i_cell_r), bs_env%mat_RI_RI%matrix, bs_env%mat_RI_RI_tensor%matrix, &
1364 w_r(i_cell_r), bs_env%para_env, bs_env%para_env_tensor%num_pe, &
1368 CALL timestop(handle)
1370 END SUBROUTINE fm_mwm_r_t_to_local_tensor_w_r
1376 SUBROUTINE compute_qp_energies(bs_env)
1379 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_QP_energies'
1381 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: sigma_c_ikp_n_freq
1382 INTEGER :: handle, ikp, ispin, j_t
1383 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sigma_x_ikp_n
1384 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: sigma_c_ikp_n_time
1387 CALL timeset(routinen, handle)
1389 CALL cp_cfm_create(cfm_mo_coeff, bs_env%fm_s_Gamma%matrix_struct)
1390 ALLOCATE (sigma_x_ikp_n(bs_env%n_ao))
1391 ALLOCATE (sigma_c_ikp_n_time(bs_env%n_ao, bs_env%num_time_freq_points, 2))
1392 ALLOCATE (sigma_c_ikp_n_freq(bs_env%n_ao, bs_env%num_freq_points_fit))
1394 DO ispin = 1, bs_env%n_spin
1396 DO ikp = 1, bs_env%nkp_bs_and_DOS
1399 CALL cp_cfm_to_cfm(bs_env%cfm_mo_coeff_kp(ikp, ispin), cfm_mo_coeff)
1403 CALL trafo_to_k_and_nn(bs_env%fm_Sigma_x_R, sigma_x_ikp_n, cfm_mo_coeff, bs_env, ikp)
1407 DO j_t = 1, bs_env%num_time_freq_points
1408 CALL trafo_to_k_and_nn(bs_env%fm_Sigma_c_R_pos_tau(:, j_t, ispin), &
1409 sigma_c_ikp_n_time(:, j_t,
positive_time), cfm_mo_coeff, bs_env, ikp)
1410 CALL trafo_to_k_and_nn(bs_env%fm_Sigma_c_R_neg_tau(:, j_t, ispin), &
1411 sigma_c_ikp_n_time(:, j_t,
negative_time), cfm_mo_coeff, bs_env, ikp)
1416 sigma_c_ikp_n_freq(1:bs_env%n_occ(ispin), :) = conjg(sigma_c_ikp_n_freq(1:bs_env%n_occ(ispin), :))
1421 bs_env%v_xc_n(:, ikp, ispin), &
1422 bs_env%eigenval_scf(:, ikp, ispin), ikp, ispin)
1432 CALL timestop(handle)
1434 END SUBROUTINE compute_qp_energies
1444 SUBROUTINE trafo_to_k_and_nn(fm_rs, array_ikp_n, cfm_mo_coeff, bs_env, ikp)
1446 REAL(kind=
dp),
DIMENSION(:) :: array_ikp_n
1451 CHARACTER(LEN=*),
PARAMETER :: routinen =
'trafo_to_k_and_nn'
1453 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: cdiag
1457 CALL timeset(routinen, handle)
1462 CALL fm_rs_to_kp(cfm_ikp, fm_rs, bs_env%kpoints_DOS, ikp)
1468 ALLOCATE (cdiag(
SIZE(array_ikp_n)))
1470 array_ikp_n = real(cdiag, kind=
dp)
1475 CALL timestop(handle)
1477 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....
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public pasquier2025
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_get_diag(matrix, diag, n_active)
returns the diagonal of a complex full matrix: diag(i)= A_{ii}. Each diagonal entry is owned by one p...
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
Redistribution of full matrices and distributed arrays.
subroutine, public cp_fm_to_replicated_array(fm_s, array_s, weight, add)
...
represent a full matrix distributed on many processors
subroutine, public cp_fm_set_submatrix(fm, new_values, start_row, start_col, n_rows, n_cols, alpha, beta, transpose)
sets a submatrix of a full matrix fm(start_row:start_row+n_rows,start_col:start_col+n_cols) = alpha*o...
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....
Redistribute matrices between full-matrix and tensor process layouts.
subroutine, public cp_dbt_to_fm(t_r, fm_r, mat_global, mat_local, para_env)
...
subroutine, public cp_fm_to_dbt(fm_global, mat_global, mat_local, tensor, para_env, num_pe_sub, eps_filter, block_row_ranges)
...
Coulomb matrices and screened interactions for imaginary-time GW.
subroutine, public get_v_tr_r(v_tr_r, pot_type, regularization_ri, bs_env, qs_env)
...
subroutine, public gw_calc_tensor_small_cell_full_kp(qs_env, bs_env)
Perform GW band structure calculation.
Full-matrix operations not provided by the CP2K FM packages.
subroutine, public local_add_on_diag(matrix, alpha)
Add a scalar to the diagonal of a local complex matrix.
subroutine, public cfm_contract_aba(matrix_a, matrix_b, matrix_c, workspace)
Computes A^H B A for complex full matrices.
subroutine, public local_complex_power(matrix, exponent, eps, cond_nr, min_ev, max_ev, relative_eps)
Compute a spectral power of a local complex Hermitian matrix. Eigenvalues not larger than eps (or rel...
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 de_init_bs_env(qs_env, bs_env)
Releases the memory-heavy GW intermediates that cannot be freed in bs_env_release,...
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, i_iter)
...
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_dense(v_k, qs_env, kpoints, size_lattice_sum, basis_type, ikp_start, ikp_end)
Dense 2-center Coulomb matrix V_PQ(k) from a direct real-space lattice sum.
Implements simple k-space/R-space transformations and Gamma-point MIC reconstruction.
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.
subroutine, public get_all_vbm_cbm_bandgaps(bs_env)
...
Utility routines for RPA and GW with imaginary time.
Definition and construction of time/frequency grids for correlation methods.
subroutine, public transform_time_to_frequency(grid, samples_tau, values_omega)
Transform real positive/negative-time samples to complex positive-frequency values....
integer, parameter, public negative_time
integer, parameter, public positive_time
Represent a complex full matrix.