76#include "./base/base_uses.f90"
82 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'gw_tensor_large_cell_Gamma'
88 REAL(KIND=
dp),
PARAMETER,
PRIVATE :: store_3c_share_uncompressed = 0.1_dp, &
89 store_3c_share_compressed = 0.5_dp
92 REAL(KIND=
dp),
PARAMETER,
PRIVATE :: store_3c_eps_scaling = 1.0e-3_dp
119 CHARACTER(LEN=*),
PARAMETER :: routinen =
'gw_calc_tensor_large_cell_Gamma'
122 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma, fm_w_mic_time
123 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
125 CALL timeset(routinen, handle)
133 CALL store_3c_init(bs_env, bs_env%store_3c_chi, bs_env%n_intervals_i + bs_env%n_intervals_j)
135 CALL store_3c_finish(bs_env, bs_env%store_3c_chi)
138 CALL get_w_mic(bs_env, qs_env, bs_env%mat_chi_Gamma_tau, fm_w_mic_time)
141 CALL store_3c_init(bs_env, bs_env%store_3c_W, bs_env%n_intervals_i)
142 CALL store_3c_init(bs_env, bs_env%store_3c_Sigma, bs_env%n_intervals_j)
150 CALL get_sigma_c(bs_env, qs_env, fm_w_mic_time, fm_sigma_c_gamma_time)
151 CALL store_3c_finish(bs_env, bs_env%store_3c_W, bs_env%store_3c_Sigma)
158 CALL timestop(handle)
171 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
173 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_mat_chi_Gamma_tau'
175 INTEGER :: handle, i_intval_idx, i_t, inner_loop_atoms_interval_index, ispin, j_intval_idx
176 INTEGER(KIND=int_8) :: flop
177 INTEGER,
DIMENSION(2) :: bounds_p, bounds_q, i_atoms, il_atoms, &
179 INTEGER,
DIMENSION(2, 2) :: bounds_comb
180 LOGICAL :: dist_too_long_i, dist_too_long_j
181 REAL(kind=
dp) :: t1, tau
182 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_x_gocc, &
183 t_3c_x_gocc_2, t_3c_x_gvir, &
185 TYPE(dbt_type),
POINTER :: t_3c_use
186 TYPE(dbt_type),
TARGET :: t_3c_for_gocc, t_3c_for_gvir
188 CALL timeset(routinen, handle)
190 DO i_t = 1, bs_env%num_time_freq_points
194 IF (bs_env%read_chi(i_t))
THEN
196 CALL fm_read(bs_env%fm_RI_RI, bs_env, bs_env%chi_name, i_t)
199 keep_sparsity=.false.)
201 IF (bs_env%unit_nr > 0)
THEN
202 WRITE (bs_env%unit_nr,
'(T2,A,I5,A,I3,A,F10.1,A)') &
203 'Read χ(iτ,k=0) from file for time point ', i_t,
' /', &
204 bs_env%num_time_freq_points, &
212 IF (.NOT. bs_env%calc_chi(i_t)) cycle
214 CALL create_tensors_chi(t_2c_gocc, t_2c_gvir, t_3c_for_gocc, t_3c_for_gvir, &
215 t_3c_x_gocc, t_3c_x_gvir, t_3c_x_gocc_2, t_3c_x_gvir_2, bs_env)
221 tau = bs_env%time_frequency_grid%imaginary_time(i_t)
223 DO ispin = 1, bs_env%n_spin
224 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gocc, ispin, occ=.true., vir=.false.)
225 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gvir, ispin, occ=.false., vir=.true.)
227 CALL cp_fm_to_dbt(bs_env%fm_Gocc, bs_env%mat_ao_ao%matrix, bs_env%mat_ao_ao_tensor%matrix, t_2c_gocc, &
228 bs_env%para_env, bs_env%para_env_tensor%num_pe, bs_env%eps_filter, &
229 bs_env%atoms_j_t_group)
230 CALL cp_fm_to_dbt(bs_env%fm_Gvir, bs_env%mat_ao_ao%matrix, bs_env%mat_ao_ao_tensor%matrix, t_2c_gvir, &
231 bs_env%para_env, bs_env%para_env_tensor%num_pe, bs_env%eps_filter, &
232 bs_env%atoms_i_t_group)
236 DO i_intval_idx = 1, bs_env%n_intervals_i
237 DO j_intval_idx = 1, bs_env%n_intervals_j
238 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
239 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
241 IF (bs_env%skip_chi(i_intval_idx, j_intval_idx))
THEN
245 bs_env%n_skip_chi = bs_env%n_skip_chi + 1
250 DO inner_loop_atoms_interval_index = 1, bs_env%n_intervals_inner_loop_atoms
252 il_atoms = bs_env%inner_loop_atom_intervals(1:2, inner_loop_atoms_interval_index)
258 CALL check_dist(i_atoms, il_atoms, qs_env, bs_env, dist_too_long_i)
259 CALL check_dist(j_atoms, il_atoms, qs_env, bs_env, dist_too_long_j)
260 IF (.NOT. dist_too_long_i)
THEN
262 CALL get_3c_integrals(qs_env, bs_env, bs_env%store_3c_chi, t_3c_for_gocc, &
263 t_3c_use, atoms_ao_1=i_atoms, atoms_ao_2=il_atoms)
265 CALL g_times_3c(t_3c_use, t_2c_gocc, t_3c_x_gocc, bs_env, &
266 j_atoms, i_atoms, il_atoms)
267 CALL dbt_clear(t_3c_for_gocc)
269 IF (.NOT. dist_too_long_j)
THEN
271 CALL get_3c_integrals(qs_env, bs_env, bs_env%store_3c_chi, t_3c_for_gvir, &
272 t_3c_use, atoms_ao_1=j_atoms, atoms_ao_2=il_atoms)
274 CALL g_times_3c(t_3c_use, t_2c_gvir, t_3c_x_gvir, bs_env, &
275 i_atoms, j_atoms, il_atoms)
276 CALL dbt_clear(t_3c_for_gvir)
281 CALL dbt_copy(t_3c_x_gocc, t_3c_x_gocc_2, move_data=.true., order=[1, 3, 2])
282 CALL dbt_copy(t_3c_x_gvir, t_3c_x_gvir_2, move_data=.true.)
291 bounds_comb(1:2, 1) = [bs_env%i_ao_start_from_atom(j_atoms(1)), &
292 bs_env%i_ao_end_from_atom(j_atoms(2))]
293 bounds_comb(1:2, 2) = [bs_env%i_ao_start_from_atom(i_atoms(1)), &
294 bs_env%i_ao_end_from_atom(i_atoms(2))]
296 CALL get_bounds_from_atoms(bounds_p, i_atoms, [1, bs_env%n_atom], &
297 bs_env%min_RI_idx_from_AO_AO_atom, &
298 bs_env%max_RI_idx_from_AO_AO_atom)
299 CALL get_bounds_from_atoms(bounds_q, [1, bs_env%n_atom], j_atoms, &
300 bs_env%min_RI_idx_from_AO_AO_atom, &
301 bs_env%max_RI_idx_from_AO_AO_atom)
303 IF (bounds_q(1) > bounds_q(2) .OR. bounds_p(1) > bounds_p(2))
THEN
306 CALL dbt_contract(alpha=bs_env%spin_degeneracy, &
307 tensor_1=t_3c_x_gocc_2, tensor_2=t_3c_x_gvir_2, &
308 beta=1.0_dp, tensor_3=bs_env%t_chi, &
309 contract_1=[2, 3], notcontract_1=[1], map_1=[1], &
310 contract_2=[2, 3], notcontract_2=[1], map_2=[2], &
311 bounds_1=bounds_comb, &
314 filter_eps=bs_env%eps_filter, move_data=.false., flop=flop)
316 IF (flop == 0_int_8) bs_env%skip_chi(i_intval_idx, j_intval_idx) = .true.
326 mat_chi_gamma_tau(i_t)%matrix, bs_env%para_env)
328 CALL fm_write(bs_env%fm_RI_RI, i_t, bs_env%chi_name, qs_env, &
329 matrix=mat_chi_gamma_tau(i_t)%matrix)
331 CALL destroy_tensors_chi(t_2c_gocc, t_2c_gvir, t_3c_for_gocc, t_3c_for_gvir, &
332 t_3c_x_gocc, t_3c_x_gvir, t_3c_x_gocc_2, t_3c_x_gvir_2)
334 IF (bs_env%unit_nr > 0)
THEN
335 WRITE (bs_env%unit_nr,
'(T2,A,I13,A,I3,A,F10.1,A)') &
336 'Computed χ(iτ,k=0) for time point', i_t,
' /', bs_env%num_time_freq_points, &
342 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
344 CALL timestop(handle)
360 SUBROUTINE create_tensors_chi(t_2c_Gocc, t_2c_Gvir, t_3c_for_Gocc, t_3c_for_Gvir, &
361 t_3c_x_Gocc, t_3c_x_Gvir, t_3c_x_Gocc_2, t_3c_x_Gvir_2, bs_env)
363 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
364 t_3c_for_gvir, t_3c_x_gocc, &
365 t_3c_x_gvir, t_3c_x_gocc_2, &
369 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_tensors_chi'
373 CALL timeset(routinen, handle)
375 CALL dbt_create(bs_env%t_G, t_2c_gocc, name=
"Gocc 2c (AO|AO)")
376 CALL dbt_create(bs_env%t_G, t_2c_gvir, name=
"Gvir 2c (AO|AO)")
377 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_gocc, name=
"Gocc 3c (RI AO|AO)")
378 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_gvir, name=
"Gvir 3c (RI AO|AO)")
379 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_gocc, name=
"xGocc 3c (RI AO|AO)")
380 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_gvir, name=
"xGvir 3c (RI AO|AO)")
381 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_gocc_2, name=
"x2Gocc 3c (RI AO|AO)")
382 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_gvir_2, name=
"x2Gvir 3c (RI AO|AO)")
384 CALL timestop(handle)
386 END SUBROUTINE create_tensors_chi
399 SUBROUTINE destroy_tensors_chi(t_2c_Gocc, t_2c_Gvir, t_3c_for_Gocc, t_3c_for_Gvir, &
400 t_3c_x_Gocc, t_3c_x_Gvir, t_3c_x_Gocc_2, t_3c_x_Gvir_2)
401 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
402 t_3c_for_gvir, t_3c_x_gocc, &
403 t_3c_x_gvir, t_3c_x_gocc_2, &
406 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_tensors_chi'
410 CALL timeset(routinen, handle)
412 CALL dbt_destroy(t_2c_gocc)
413 CALL dbt_destroy(t_2c_gvir)
414 CALL dbt_destroy(t_3c_for_gocc)
415 CALL dbt_destroy(t_3c_for_gvir)
416 CALL dbt_destroy(t_3c_x_gocc)
417 CALL dbt_destroy(t_3c_x_gvir)
418 CALL dbt_destroy(t_3c_x_gocc_2)
419 CALL dbt_destroy(t_3c_x_gvir_2)
421 CALL timestop(handle)
423 END SUBROUTINE destroy_tensors_chi
437 TYPE(dbt_type) :: t_3c
438 INTEGER,
DIMENSION(2),
OPTIONAL :: atoms_ao_1, atoms_ao_2, atoms_ri
440 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_3c_integrals'
443 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_3c_array
445 CALL timeset(routinen, handle)
450 ALLOCATE (t_3c_array(1, 1))
451 CALL dbt_create(t_3c, t_3c_array(1, 1))
457 int_eps=bs_env%eps_filter, &
458 basis_i=bs_env%basis_set_RI, &
459 basis_j=bs_env%basis_set_AO, &
460 basis_k=bs_env%basis_set_AO, &
461 potential_parameter=bs_env%ri_metric, &
463 bounds_j=atoms_ao_1, &
464 bounds_k=atoms_ao_2, &
465 desymmetrize=.false.)
467 CALL dbt_filter(t_3c_array(1, 1), bs_env%eps_filter)
469 CALL dbt_copy(t_3c_array(1, 1), t_3c, move_data=.true.)
471 CALL dbt_destroy(t_3c_array(1, 1))
472 DEALLOCATE (t_3c_array)
474 CALL timestop(handle)
492 SUBROUTINE get_3c_integrals(qs_env, bs_env, store, t_3c, t_3c_use, atoms_AO_1, atoms_AO_2, &
497 TYPE(dbt_type),
TARGET :: t_3c
498 TYPE(dbt_type),
POINTER :: t_3c_use
499 INTEGER,
DIMENSION(2),
OPTIONAL :: atoms_ao_1, atoms_ao_2, atoms_ri
501 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_3c_integrals'
503 INTEGER :: handle, i, iset
504 INTEGER,
DIMENSION(2, 3) :: atoms
506 CALL timeset(routinen, handle)
509 IF (
PRESENT(atoms_ri)) atoms(:, 1) = atoms_ri
510 IF (
PRESENT(atoms_ao_1)) atoms(:, 2) = atoms_ao_1
511 IF (
PRESENT(atoms_ao_2)) atoms(:, 3) = atoms_ao_2
515 IF (
ALLOCATED(store%sets))
THEN
516 DO i = 1, store%nsets
517 IF (all(store%sets(i)%atoms == atoms)) iset = i
519 IF (iset == 0 .AND. store%nsets <
SIZE(store%sets))
THEN
520 iset = store%nsets + 1
522 store%sets(iset)%atoms = atoms
523 IF (store%uncompressed)
THEN
524 CALL dbt_create(t_3c, store%sets(iset)%t_3c)
526 atoms_ao_2, atoms_ri)
527 store%memory = store%memory + &
528 REAL(dbt_get_nze(store%sets(iset)%t_3c), kind=
dp)*8.0_dp/1024.0_dp**2
532 CALL compress_tensor(t_3c, store%sets(iset)%blk_indices, store%sets(iset)%compressed, &
533 store_3c_eps_scaling*bs_env%eps_filter, store%memory)
539 IF (store%uncompressed)
THEN
540 t_3c_use => store%sets(iset)%t_3c
543 CALL decompress_tensor(t_3c, store%sets(iset)%blk_indices, store%sets(iset)%compressed, &
544 store_3c_eps_scaling*bs_env%eps_filter)
550 CALL timestop(handle)
552 END SUBROUTINE get_3c_integrals
564 SUBROUTINE store_3c_init(bs_env, store, n_intervals)
567 INTEGER,
INTENT(IN) :: n_intervals
569 CHARACTER(LEN=*),
PARAMETER :: routinen =
'store_3c_init'
572 REAL(kind=
dp) :: free_gb, memory_gb
574 CALL timeset(routinen, handle)
582 memory_gb = 8.0e-9_dp*bs_env%occupation_3c_int*real(bs_env%n_RI, kind=
dp)* &
583 REAL(bs_env%n_ao, kind=
dp)**2*real(bs_env%n_atom_i + bs_env%n_atom_j, kind=
dp)/ &
584 REAL(bs_env%n_atom, kind=
dp)/real(bs_env%para_env_tensor%num_pe, kind=
dp)
587 IF (0.0_dp <= memory_gb .AND. memory_gb <= store_3c_share_compressed*bs_env%input_memory_per_proc_GB)
THEN
588 ALLOCATE (store%sets(n_intervals*bs_env%n_intervals_inner_loop_atoms))
589 store%uncompressed = (memory_gb <= store_3c_share_uncompressed* &
590 min(bs_env%input_memory_per_proc_GB, free_gb))
593 CALL timestop(handle)
595 END SUBROUTINE store_3c_init
603 SUBROUTINE store_3c_finish(bs_env, store, store_2)
608 CHARACTER(LEN=*),
PARAMETER :: routinen =
'store_3c_finish'
611 LOGICAL :: kept, uncompressed
612 REAL(kind=
dp) :: memory
614 CALL timeset(routinen, handle)
616 kept =
ALLOCATED(store%sets)
617 uncompressed = store%uncompressed
618 memory = store%memory
619 IF (
PRESENT(store_2)) memory = memory + store_2%memory
620 CALL bs_env%para_env%max(memory)
622 IF (bs_env%unit_nr > 0)
THEN
623 IF (kept .AND. uncompressed)
THEN
624 WRITE (bs_env%unit_nr,
'(T2,A,F19.1,A)') &
625 'Kept 3-center integrals (µν|P), uncompressed, per process', memory/1024.0_dp,
' GB'
627 WRITE (bs_env%unit_nr,
'(T2,A,F21.1,A)') &
628 'Kept 3-center integrals (µν|P), compressed, per process', memory/1024.0_dp,
' GB'
630 WRITE (bs_env%unit_nr,
'(T2,A,A24)') &
631 'Kept 3-center integrals (µν|P), compressed, per process',
'no'
638 CALL timestop(handle)
640 END SUBROUTINE store_3c_finish
652 SUBROUTINE g_times_3c(t_3c_for_G, t_G, t_M, bs_env, atoms_AO_1, atoms_AO_2, atoms_IL)
653 TYPE(dbt_type) :: t_3c_for_g, t_g, t_m
655 INTEGER,
DIMENSION(2) :: atoms_ao_1, atoms_ao_2, atoms_il
657 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_times_3c'
660 INTEGER(KIND=int_8) :: flop
661 INTEGER,
DIMENSION(2) :: bounds_ao_1, bounds_il
662 INTEGER,
DIMENSION(2, 2) :: bounds_comb
664 CALL timeset(routinen, handle)
675 CALL get_bounds_from_atoms(bounds_il, [1, bs_env%n_atom], atoms_ao_2, &
676 bs_env%min_AO_idx_from_RI_AO_atom, &
677 bs_env%max_AO_idx_from_RI_AO_atom, &
679 indices_3_start=bs_env%i_ao_start_from_atom, &
680 indices_3_end=bs_env%i_ao_end_from_atom)
683 CALL get_bounds_from_atoms(bounds_comb(:, 1), atoms_il, atoms_ao_2, &
684 bs_env%min_RI_idx_from_AO_AO_atom, &
685 bs_env%max_RI_idx_from_AO_AO_atom)
688 CALL get_bounds_from_atoms(bounds_comb(:, 2), [1, bs_env%n_atom], atoms_il, &
689 bs_env%min_AO_idx_from_RI_AO_atom, &
690 bs_env%max_AO_idx_from_RI_AO_atom, &
691 atoms_3=atoms_ao_2, &
692 indices_3_start=bs_env%i_ao_start_from_atom, &
693 indices_3_end=bs_env%i_ao_end_from_atom)
696 bounds_ao_1(1:2) = [bs_env%i_ao_start_from_atom(atoms_ao_1(1)), &
697 bs_env%i_ao_end_from_atom(atoms_ao_1(2))]
699 IF (bounds_il(1) > bounds_il(2) .OR. bounds_comb(1, 2) > bounds_comb(2, 2))
THEN
702 CALL dbt_contract(alpha=1.0_dp, &
703 tensor_1=t_3c_for_g, &
707 contract_1=[3], notcontract_1=[1, 2], map_1=[1, 2], &
708 contract_2=[2], notcontract_2=[1], map_2=[3], &
709 bounds_1=bounds_il, &
710 bounds_2=bounds_comb, &
711 bounds_3=bounds_ao_1, &
713 filter_eps=bs_env%eps_filter)
716 CALL timestop(handle)
718 END SUBROUTINE g_times_3c
728 SUBROUTINE check_dist(atoms_1, atoms_2, qs_env, bs_env, dist_too_long)
729 INTEGER,
DIMENSION(2) :: atoms_1, atoms_2
732 LOGICAL :: dist_too_long
734 CHARACTER(LEN=*),
PARAMETER :: routinen =
'check_dist'
736 INTEGER :: atom_1, atom_2, handle
737 REAL(
dp) :: abs_rab, min_dist_ao_atoms
738 REAL(kind=
dp),
DIMENSION(3) :: rab
742 CALL timeset(routinen, handle)
744 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
746 min_dist_ao_atoms = huge(1.0_dp)
747 DO atom_1 = atoms_1(1), atoms_1(2)
748 DO atom_2 = atoms_2(1), atoms_2(2)
749 rab =
pbc(particle_set(atom_1)%r(1:3), particle_set(atom_2)%r(1:3), cell)
751 abs_rab = sqrt(rab(1)**2 + rab(2)**2 + rab(3)**2)
753 min_dist_ao_atoms = min(min_dist_ao_atoms, abs_rab)
757 dist_too_long = (min_dist_ao_atoms > bs_env%max_dist_AO_atoms)
759 CALL timestop(handle)
761 END SUBROUTINE check_dist
772 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
774 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Sigma_x'
776 INTEGER :: handle, ispin
778 CALL timeset(routinen, handle)
780 ALLOCATE (fm_sigma_x_gamma(bs_env%n_spin))
781 DO ispin = 1, bs_env%n_spin
782 CALL cp_fm_create(fm_sigma_x_gamma(ispin), bs_env%fm_s_Gamma%matrix_struct)
785 IF (bs_env%Sigma_x_exists)
THEN
786 DO ispin = 1, bs_env%n_spin
787 CALL fm_read(fm_sigma_x_gamma(ispin), bs_env, bs_env%Sigma_x_name, ispin)
790 CALL compute_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
793 CALL timestop(handle)
803 SUBROUTINE compute_sigma_x(bs_env, qs_env, fm_Sigma_x_Gamma)
806 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
808 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Sigma_x'
810 INTEGER :: handle, i_intval_idx, ispin, j_intval_idx
811 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
813 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_vtr_gamma
815 TYPE(dbt_type) :: t_2c_d, t_2c_sigma_x, t_2c_v, t_3c_x_v
817 CALL timeset(routinen, handle)
821 CALL dbt_create(bs_env%t_G, t_2c_d)
822 CALL dbt_create(bs_env%t_W, t_2c_v)
823 CALL dbt_create(bs_env%t_G, t_2c_sigma_x)
824 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_v)
825 CALL dbcsr_create(mat_sigma_x_gamma, template=bs_env%mat_ao_ao%matrix)
828 CALL ri_2c_integral_mat(qs_env, fm_vtr_gamma, bs_env%fm_RI_RI%matrix_struct, bs_env%n_RI, &
829 bs_env%trunc_coulomb)
834 DO ispin = 1, bs_env%n_spin
837 CALL g_occ_vir(bs_env, 0.0_dp, bs_env%fm_work_mo(2), ispin, occ=.true., vir=.false.)
839 CALL cp_fm_to_dbt(bs_env%fm_work_mo(2), bs_env%mat_ao_ao%matrix, bs_env%mat_ao_ao_tensor%matrix, t_2c_d, &
840 bs_env%para_env, bs_env%para_env_tensor%num_pe, bs_env%eps_filter, &
841 bs_env%atoms_i_t_group)
843 CALL cp_fm_to_dbt(fm_vtr_gamma(1, 1), bs_env%mat_RI_RI%matrix, bs_env%mat_RI_RI_tensor%matrix, t_2c_v, &
844 bs_env%para_env, bs_env%para_env_tensor%num_pe, bs_env%eps_filter, &
845 bs_env%atoms_j_t_group)
849 DO i_intval_idx = 1, bs_env%n_intervals_i
850 DO j_intval_idx = 1, bs_env%n_intervals_j
851 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
852 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
856 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_v, t_2c_v)
860 CALL contract_to_sigma(t_2c_d, t_3c_x_v, t_2c_sigma_x, i_atoms, j_atoms, &
861 qs_env, bs_env, occ=.true., vir=.false.)
867 mat_sigma_x_gamma, bs_env%para_env)
869 CALL fm_write(bs_env%fm_work_mo(1), ispin, bs_env%Sigma_x_name, qs_env, &
870 matrix=mat_sigma_x_gamma)
876 IF (bs_env%unit_nr > 0)
THEN
877 WRITE (bs_env%unit_nr,
'(T2,A,T55,A,F10.1,A)') &
878 'Computed Σ^x(k=0),',
' Execution time',
m_walltime() - t1,
' s'
879 WRITE (bs_env%unit_nr,
'(A)')
' '
883 CALL dbt_destroy(t_2c_d)
884 CALL dbt_destroy(t_2c_v)
885 CALL dbt_destroy(t_2c_sigma_x)
886 CALL dbt_destroy(t_3c_x_v)
889 CALL timestop(handle)
891 END SUBROUTINE compute_sigma_x
900 SUBROUTINE get_sigma_c(bs_env, qs_env, fm_W_MIC_time, fm_Sigma_c_Gamma_time)
903 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
904 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
906 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Sigma_c'
908 INTEGER :: handle, i_t, ispin, read_write_index
909 REAL(kind=
dp) :: t1, tau
910 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
911 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, &
912 t_2c_sigma_neg_tau, &
913 t_2c_sigma_pos_tau, t_2c_w, t_3c_x_w
915 CALL timeset(routinen, handle)
918 t_2c_sigma_pos_tau, t_3c_x_w, &
919 mat_sigma_neg_tau, mat_sigma_pos_tau)
921 DO i_t = 1, bs_env%num_time_freq_points
923 DO ispin = 1, bs_env%n_spin
927 read_write_index = i_t + (ispin - 1)*bs_env%num_time_freq_points
930 IF (bs_env%Sigma_c_exists(i_t, ispin))
THEN
931 CALL fm_read(bs_env%fm_work_mo(1), bs_env, bs_env%Sigma_p_name, read_write_index)
932 CALL copy_fm_to_dbcsr(bs_env%fm_work_mo(1), mat_sigma_pos_tau(i_t, ispin)%matrix, &
933 keep_sparsity=.false.)
934 CALL fm_read(bs_env%fm_work_mo(1), bs_env, bs_env%Sigma_n_name, read_write_index)
935 CALL copy_fm_to_dbcsr(bs_env%fm_work_mo(1), mat_sigma_neg_tau(i_t, ispin)%matrix, &
936 keep_sparsity=.false.)
937 IF (bs_env%unit_nr > 0)
THEN
938 WRITE (bs_env%unit_nr,
'(T2,2A,I3,A,I3,A,F10.1,A)')
'Read Σ^c(iτ,k=0) ', &
939 'from file for time point ', i_t,
' /', bs_env%num_time_freq_points, &
947 tau = bs_env%time_frequency_grid%imaginary_time(i_t)
950 t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, &
951 t_2c_sigma_pos_tau, t_3c_x_w, &
952 mat_sigma_neg_tau(i_t, ispin)%matrix, &
953 mat_sigma_pos_tau(i_t, ispin)%matrix, &
954 count_skipped=(i_t == 2))
956 CALL fm_write(bs_env%fm_work_mo(1), read_write_index, bs_env%Sigma_p_name, qs_env, &
957 matrix=mat_sigma_pos_tau(i_t, ispin)%matrix)
958 CALL fm_write(bs_env%fm_work_mo(1), read_write_index, bs_env%Sigma_n_name, qs_env, &
959 matrix=mat_sigma_neg_tau(i_t, ispin)%matrix)
961 IF (bs_env%unit_nr > 0)
THEN
962 WRITE (bs_env%unit_nr,
'(T2,A,I10,A,I3,A,F10.1,A)') &
963 'Computed Σ^c(iτ,k=0) for time point ', i_t,
' /', bs_env%num_time_freq_points, &
971 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
973 CALL fill_fm_sigma_c_gamma_time(fm_sigma_c_gamma_time, bs_env, &
974 mat_sigma_pos_tau, mat_sigma_neg_tau)
979 t_2c_sigma_pos_tau, t_3c_x_w, fm_w_mic_time, &
980 mat_sigma_neg_tau, mat_sigma_pos_tau)
984 CALL timestop(handle)
986 END SUBROUTINE get_sigma_c
1010 t_2c_W, t_2c_Sigma_neg, t_2c_Sigma_pos, t_3c_x_W, &
1011 mat_Sigma_neg, mat_Sigma_pos, count_skipped)
1014 REAL(kind=
dp) :: tau
1017 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
1018 t_2c_sigma_neg, t_2c_sigma_pos, &
1020 TYPE(
dbcsr_type) :: mat_sigma_neg, mat_sigma_pos
1021 LOGICAL :: count_skipped
1023 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Sigma_c_occ_vir'
1025 INTEGER :: handle, i_intval_idx, j_intval_idx
1026 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1028 CALL timeset(routinen, handle)
1030 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gocc, ispin, occ=.true., vir=.false.)
1031 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gvir, ispin, occ=.false., vir=.true.)
1034 CALL cp_fm_to_dbt(bs_env%fm_Gocc, bs_env%mat_ao_ao%matrix, bs_env%mat_ao_ao_tensor%matrix, t_2c_gocc, &
1035 bs_env%para_env, bs_env%para_env_tensor%num_pe, bs_env%eps_filter, &
1036 bs_env%atoms_i_t_group)
1037 CALL cp_fm_to_dbt(bs_env%fm_Gvir, bs_env%mat_ao_ao%matrix, bs_env%mat_ao_ao_tensor%matrix, t_2c_gvir, &
1038 bs_env%para_env, bs_env%para_env_tensor%num_pe, bs_env%eps_filter, &
1039 bs_env%atoms_i_t_group)
1040 CALL cp_fm_to_dbt(fm_w, bs_env%mat_RI_RI%matrix, bs_env%mat_RI_RI_tensor%matrix, t_2c_w, &
1041 bs_env%para_env, bs_env%para_env_tensor%num_pe, bs_env%eps_filter, &
1042 bs_env%atoms_j_t_group)
1046 DO i_intval_idx = 1, bs_env%n_intervals_i
1047 DO j_intval_idx = 1, bs_env%n_intervals_j
1048 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
1049 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
1051 IF (bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx) .AND. &
1052 bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx))
THEN
1055 IF (count_skipped)
THEN
1056 bs_env%n_skip_sigma = bs_env%n_skip_sigma + 1
1063 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_w, t_2c_w)
1067 CALL contract_to_sigma(t_2c_gocc, t_3c_x_w, t_2c_sigma_neg, i_atoms, j_atoms, &
1068 qs_env, bs_env, occ=.true., vir=.false., &
1069 can_skip=bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx))
1072 CALL contract_to_sigma(t_2c_gvir, t_3c_x_w, t_2c_sigma_pos, i_atoms, j_atoms, &
1073 qs_env, bs_env, occ=.false., vir=.true., &
1074 can_skip=bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx))
1081 CALL cp_dbt_to_dbcsr(t_2c_sigma_neg, bs_env%mat_ao_ao_tensor%matrix, &
1082 mat_sigma_neg, bs_env%para_env)
1083 CALL cp_dbt_to_dbcsr(t_2c_sigma_pos, bs_env%mat_ao_ao_tensor%matrix, &
1084 mat_sigma_pos, bs_env%para_env)
1086 CALL timestop(handle)
1103 t_2c_Sigma_pos_tau, t_3c_x_W, &
1104 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
1107 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
1108 t_2c_sigma_neg_tau, &
1109 t_2c_sigma_pos_tau, t_3c_x_w
1110 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
1112 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_mat_for_Sigma_c'
1114 INTEGER :: handle, i_t, ispin
1116 CALL timeset(routinen, handle)
1118 CALL dbt_create(bs_env%t_G, t_2c_gocc)
1119 CALL dbt_create(bs_env%t_G, t_2c_gvir)
1120 CALL dbt_create(bs_env%t_W, t_2c_w)
1121 CALL dbt_create(bs_env%t_G, t_2c_sigma_neg_tau)
1122 CALL dbt_create(bs_env%t_G, t_2c_sigma_pos_tau)
1123 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_w)
1125 NULLIFY (mat_sigma_neg_tau, mat_sigma_pos_tau)
1126 ALLOCATE (mat_sigma_neg_tau(bs_env%num_time_freq_points, bs_env%n_spin))
1127 ALLOCATE (mat_sigma_pos_tau(bs_env%num_time_freq_points, bs_env%n_spin))
1129 DO ispin = 1, bs_env%n_spin
1130 DO i_t = 1, bs_env%num_time_freq_points
1131 ALLOCATE (mat_sigma_neg_tau(i_t, ispin)%matrix)
1132 ALLOCATE (mat_sigma_pos_tau(i_t, ispin)%matrix)
1133 CALL dbcsr_create(mat_sigma_neg_tau(i_t, ispin)%matrix, template=bs_env%mat_ao_ao%matrix)
1134 CALL dbcsr_create(mat_sigma_pos_tau(i_t, ispin)%matrix, template=bs_env%mat_ao_ao%matrix)
1138 CALL timestop(handle)
1151 SUBROUTINE compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_W, t_2c_W)
1155 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1156 TYPE(dbt_type) :: t_3c_x_w, t_2c_w
1158 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_3c_and_contract_W'
1160 INTEGER :: handle, ri_intval_idx
1161 INTEGER(KIND=int_8) :: flop
1162 INTEGER,
DIMENSION(2) :: bounds_p, bounds_q, ri_atoms
1163 INTEGER,
DIMENSION(2, 2) :: bounds_ao
1164 TYPE(dbt_type) :: t_3c_x_w_tmp
1165 TYPE(dbt_type),
POINTER :: t_3c_use
1166 TYPE(dbt_type),
TARGET :: t_3c_for_w
1168 CALL timeset(routinen, handle)
1170 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_w_tmp)
1171 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_for_w)
1181 bounds_q(1:2) = [bs_env%i_RI_start_from_atom(j_atoms(1)), &
1182 bs_env%i_RI_end_from_atom(j_atoms(2))]
1184 DO ri_intval_idx = 1, bs_env%n_intervals_inner_loop_atoms
1185 ri_atoms = bs_env%inner_loop_atom_intervals(1:2, ri_intval_idx)
1187 CALL get_bounds_from_atoms(bounds_p, i_atoms, [1, bs_env%n_atom], &
1188 bs_env%min_RI_idx_from_AO_AO_atom, &
1189 bs_env%max_RI_idx_from_AO_AO_atom, &
1191 indices_3_start=bs_env%i_RI_start_from_atom, &
1192 indices_3_end=bs_env%i_RI_end_from_atom)
1195 CALL get_bounds_from_atoms(bounds_ao(:, 2), ri_atoms, i_atoms, &
1196 bs_env%min_AO_idx_from_RI_AO_atom, &
1197 bs_env%max_AO_idx_from_RI_AO_atom)
1199 CALL get_bounds_from_atoms(bounds_ao(:, 1), ri_atoms, [1, bs_env%n_atom], &
1200 bs_env%min_AO_idx_from_RI_AO_atom, &
1201 bs_env%max_AO_idx_from_RI_AO_atom, &
1203 indices_3_start=bs_env%i_ao_start_from_atom, &
1204 indices_3_end=bs_env%i_ao_end_from_atom)
1206 IF (bounds_p(1) > bounds_p(2) .OR. bounds_ao(1, 2) > bounds_ao(2, 2))
THEN
1211 CALL get_3c_integrals(qs_env, bs_env, bs_env%store_3c_W, t_3c_for_w, t_3c_use, &
1212 atoms_ao_1=i_atoms, atoms_ri=ri_atoms)
1215 CALL dbt_contract(alpha=1.0_dp, &
1217 tensor_2=t_3c_use, &
1219 tensor_3=t_3c_x_w_tmp, &
1220 contract_1=[2], notcontract_1=[1], map_1=[1], &
1221 contract_2=[1], notcontract_2=[2, 3], map_2=[2, 3], &
1222 bounds_1=bounds_p, &
1223 bounds_2=bounds_q, &
1224 bounds_3=bounds_ao, &
1226 move_data=.false., &
1227 filter_eps=bs_env%eps_filter)
1232 CALL dbt_copy(t_3c_x_w_tmp, t_3c_x_w, order=[1, 2, 3], move_data=.true.)
1234 CALL dbt_destroy(t_3c_x_w_tmp)
1235 CALL dbt_destroy(t_3c_for_w)
1237 CALL timestop(handle)
1239 END SUBROUTINE compute_3c_and_contract_w
1254 SUBROUTINE contract_to_sigma(t_2c_G, t_3c_x_W, t_2c_Sigma, i_atoms, j_atoms, qs_env, bs_env, &
1256 TYPE(dbt_type) :: t_2c_g, t_3c_x_w, t_2c_sigma
1257 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1261 LOGICAL,
OPTIONAL :: can_skip
1263 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_to_Sigma'
1265 INTEGER :: handle, inner_loop_atoms_interval_index
1266 INTEGER(KIND=int_8) :: flop
1267 INTEGER,
DIMENSION(2) :: bounds_lambda, bounds_mu, bounds_nu, &
1268 bounds_sigma, il_atoms
1269 INTEGER,
DIMENSION(2, 2) :: bounds_comb
1270 REAL(kind=
dp) :: sign_sigma
1271 TYPE(dbt_type) :: t_3c_x_g, t_3c_x_g_2
1272 TYPE(dbt_type),
POINTER :: t_3c_use
1273 TYPE(dbt_type),
TARGET :: t_3c_for_g
1275 CALL timeset(routinen, handle)
1277 cpassert(occ .EQV. (.NOT. vir))
1278 IF (occ) sign_sigma = -1.0_dp
1279 IF (vir) sign_sigma = 1.0_dp
1281 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_g)
1282 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_g)
1283 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_g_2)
1296 bounds_nu(1:2) = [bs_env%i_ao_start_from_atom(i_atoms(1)), &
1297 bs_env%i_ao_end_from_atom(i_atoms(2))]
1299 DO inner_loop_atoms_interval_index = 1, bs_env%n_intervals_inner_loop_atoms
1300 il_atoms = bs_env%inner_loop_atom_intervals(1:2, inner_loop_atoms_interval_index)
1303 CALL get_bounds_from_atoms(bounds_mu, j_atoms, [1, bs_env%n_atom], &
1304 bs_env%min_AO_idx_from_RI_AO_atom, &
1305 bs_env%max_AO_idx_from_RI_AO_atom, &
1307 indices_3_start=bs_env%i_ao_start_from_atom, &
1308 indices_3_end=bs_env%i_ao_end_from_atom)
1311 CALL get_bounds_from_atoms(bounds_comb(:, 1), il_atoms, [1, bs_env%n_atom], &
1312 bs_env%min_RI_idx_from_AO_AO_atom, &
1313 bs_env%max_RI_idx_from_AO_AO_atom, &
1315 indices_3_start=bs_env%i_RI_start_from_atom, &
1316 indices_3_end=bs_env%i_RI_end_from_atom)
1319 CALL get_bounds_from_atoms(bounds_comb(:, 2), j_atoms, il_atoms, &
1320 bs_env%min_AO_idx_from_RI_AO_atom, &
1321 bs_env%max_AO_idx_from_RI_AO_atom)
1323 IF (bounds_mu(1) > bounds_mu(2) .OR. bounds_comb(1, 1) > bounds_comb(2, 1) .OR. &
1324 bounds_comb(1, 2) > bounds_comb(2, 2))
THEN
1328 CALL get_3c_integrals(qs_env, bs_env, bs_env%store_3c_Sigma, t_3c_for_g, t_3c_use, &
1329 atoms_ri=j_atoms, atoms_ao_2=il_atoms)
1331 CALL dbt_contract(alpha=1.0_dp, &
1333 tensor_2=t_3c_use, &
1335 tensor_3=t_3c_x_g, &
1336 contract_1=[2], notcontract_1=[1], map_1=[3], &
1337 contract_2=[3], notcontract_2=[1, 2], map_2=[1, 2], &
1338 bounds_1=bounds_mu, &
1339 bounds_2=bounds_nu, &
1340 bounds_3=bounds_comb, &
1342 move_data=.false., &
1343 filter_eps=bs_env%eps_filter)
1347 CALL dbt_copy(t_3c_x_g, t_3c_x_g_2, order=[1, 3, 2], move_data=.true.)
1351 bounds_comb(1:2, 1) = [bs_env%i_RI_start_from_atom(j_atoms(1)), &
1352 bs_env%i_RI_end_from_atom(j_atoms(2))]
1353 bounds_comb(1:2, 2) = bounds_nu(1:2)
1355 CALL get_bounds_from_atoms(bounds_lambda, j_atoms, [1, bs_env%n_atom], &
1356 bs_env%min_AO_idx_from_RI_AO_atom, &
1357 bs_env%max_AO_idx_from_RI_AO_atom)
1358 CALL get_bounds_from_atoms(bounds_sigma, [1, bs_env%n_atom], i_atoms, &
1359 bs_env%min_AO_idx_from_RI_AO_atom, &
1360 bs_env%max_AO_idx_from_RI_AO_atom)
1362 IF (bounds_sigma(1) > bounds_sigma(2) .OR. bounds_lambda(1) > bounds_lambda(2))
THEN
1365 CALL dbt_contract(alpha=sign_sigma, &
1366 tensor_1=t_3c_x_w, &
1367 tensor_2=t_3c_x_g_2, &
1369 tensor_3=t_2c_sigma, &
1370 contract_1=[1, 2], notcontract_1=[3], map_1=[1], &
1371 contract_2=[1, 2], notcontract_2=[3], map_2=[2], &
1372 bounds_1=bounds_comb, &
1373 bounds_2=bounds_sigma, &
1374 bounds_3=bounds_lambda, &
1375 filter_eps=bs_env%eps_filter, move_data=.false., flop=flop)
1378 IF (
PRESENT(can_skip))
THEN
1379 IF (flop == 0_int_8) can_skip = .true.
1382 CALL dbt_destroy(t_3c_for_g)
1383 CALL dbt_destroy(t_3c_x_g)
1384 CALL dbt_destroy(t_3c_x_g_2)
1386 CALL timestop(handle)
1388 END SUBROUTINE contract_to_sigma
1397 SUBROUTINE fill_fm_sigma_c_gamma_time(fm_Sigma_c_Gamma_time, bs_env, &
1398 mat_Sigma_pos_tau, mat_Sigma_neg_tau)
1400 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
1402 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_pos_tau, mat_sigma_neg_tau
1404 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fill_fm_Sigma_c_Gamma_time'
1406 INTEGER :: handle, i_t, ispin, pos_neg
1408 CALL timeset(routinen, handle)
1410 ALLOCATE (fm_sigma_c_gamma_time(bs_env%num_time_freq_points, 2, bs_env%n_spin))
1411 DO ispin = 1, bs_env%n_spin
1412 DO i_t = 1, bs_env%num_time_freq_points
1414 CALL cp_fm_create(fm_sigma_c_gamma_time(i_t, pos_neg, ispin), &
1415 bs_env%fm_s_Gamma%matrix_struct)
1418 fm_sigma_c_gamma_time(i_t, 1, ispin))
1420 fm_sigma_c_gamma_time(i_t, 2, ispin))
1424 CALL timestop(handle)
1426 END SUBROUTINE fill_fm_sigma_c_gamma_time
1436 CHARACTER(LEN=*),
PARAMETER :: routinen =
'print_skipping'
1438 INTEGER :: handle, n_pairs
1440 CALL timeset(routinen, handle)
1442 n_pairs = bs_env%n_intervals_i*bs_env%n_intervals_j*bs_env%n_spin
1444 CALL bs_env%para_env_tensor%sum(bs_env%n_skip_sigma)
1445 CALL bs_env%para_env_tensor%sum(bs_env%n_skip_chi)
1446 CALL bs_env%para_env_tensor%sum(n_pairs)
1448 IF (bs_env%unit_nr > 0)
THEN
1449 WRITE (bs_env%unit_nr,
'(T2,A,T74,F7.1,A)') &
1450 'Sparsity of Σ^c(iτ,k=0): Percentage of skipped atom pairs:', &
1451 REAL(100*bs_env%n_skip_sigma, kind=
dp)/real(n_pairs, kind=
dp),
' %'
1452 WRITE (bs_env%unit_nr,
'(T2,A,T74,F7.1,A)') &
1453 'Sparsity of χ(iτ,k=0): Percentage of skipped atom pairs:', &
1454 REAL(100*bs_env%n_skip_chi, kind=
dp)/real(n_pairs, kind=
dp),
' %'
1457 CALL timestop(handle)
1474 t_2c_Sigma_pos_tau, t_3c_x_W, fm_W_MIC_time, &
1475 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
1477 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
1478 t_2c_sigma_neg_tau, &
1479 t_2c_sigma_pos_tau, t_3c_x_w
1480 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1481 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
1483 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_mat_Sigma_c'
1487 CALL timeset(routinen, handle)
1489 CALL dbt_destroy(t_2c_gocc)
1490 CALL dbt_destroy(t_2c_gvir)
1491 CALL dbt_destroy(t_2c_w)
1492 CALL dbt_destroy(t_2c_sigma_neg_tau)
1493 CALL dbt_destroy(t_2c_sigma_pos_tau)
1494 CALL dbt_destroy(t_3c_x_w)
1499 CALL timestop(handle)
1510 CHARACTER(LEN=*),
PARAMETER :: routinen =
'delete_unnecessary_files'
1512 CHARACTER(LEN=default_path_length) :: f_chi, f_w_t, prefix
1513 INTEGER :: handle, i_t
1515 CALL timeset(routinen, handle)
1517 prefix = bs_env%prefix
1519 DO i_t = 1, bs_env%num_time_freq_points
1522 WRITE (f_chi,
'(3A,I1,A)') trim(prefix), bs_env%chi_name,
"_0", i_t,
".matrix"
1523 WRITE (f_w_t,
'(3A,I1,A)') trim(prefix), bs_env%W_time_name,
"_0", i_t,
".matrix"
1524 ELSE IF (i_t < 100)
THEN
1525 WRITE (f_chi,
'(3A,I2,A)') trim(prefix), bs_env%chi_name,
"_", i_t,
".matrix"
1526 WRITE (f_w_t,
'(3A,I2,A)') trim(prefix), bs_env%W_time_name,
"_", i_t,
".matrix"
1528 cpabort(
'Please implement more than 99 time/frequency points.')
1531 CALL safe_delete(f_chi, bs_env)
1532 CALL safe_delete(f_w_t, bs_env)
1536 CALL timestop(handle)
1545 SUBROUTINE safe_delete(filename, bs_env)
1546 CHARACTER(LEN=*) :: filename
1549 CHARACTER(LEN=*),
PARAMETER :: routinen =
'safe_delete'
1552 LOGICAL :: file_exists
1554 CALL timeset(routinen, handle)
1556 IF (bs_env%para_env%mepos == 0)
THEN
1558 INQUIRE (file=trim(filename), exist=file_exists)
1563 CALL timestop(handle)
1565 END SUBROUTINE safe_delete
1578 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
1579 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
1581 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_QP_energies'
1583 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: sigma_c_ikp_n_freq
1584 INTEGER :: handle, ikp, ispin, j_t
1585 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sigma_x_ikp_n, v_xc_ikp_n
1586 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: sigma_c_ikp_n_time
1587 TYPE(
cp_cfm_type) :: cfm_ks_ikp, cfm_mos_ikp, cfm_s_ikp, &
1590 CALL timeset(routinen, handle)
1592 CALL cp_cfm_create(cfm_mos_ikp, bs_env%fm_s_Gamma%matrix_struct)
1593 CALL cp_cfm_create(cfm_work_ikp, bs_env%fm_s_Gamma%matrix_struct)
1595 ALLOCATE (v_xc_ikp_n(bs_env%n_ao), sigma_x_ikp_n(bs_env%n_ao))
1596 ALLOCATE (sigma_c_ikp_n_time(bs_env%n_ao, bs_env%num_time_freq_points, 2))
1597 ALLOCATE (sigma_c_ikp_n_freq(bs_env%n_ao, bs_env%num_freq_points_fit))
1599 DO ispin = 1, bs_env%n_spin
1601 DO ikp = 1, bs_env%nkp_bs_and_DOS
1605 ikp, qs_env, bs_env%kpoints_DOS,
"ORB")
1609 ikp, qs_env, bs_env%kpoints_DOS,
"ORB")
1612 CALL cp_cfm_geeig(cfm_ks_ikp, cfm_s_ikp, cfm_mos_ikp, &
1613 bs_env%eigenval_scf(:, ikp, ispin), cfm_work_ikp)
1616 CALL to_ikp_and_mo(v_xc_ikp_n, bs_env%fm_V_xc_Gamma(ispin), &
1617 ikp, qs_env, bs_env, cfm_mos_ikp, cfm_ks_ikp, cfm_work_ikp)
1620 CALL to_ikp_and_mo(sigma_x_ikp_n, fm_sigma_x_gamma(ispin), &
1621 ikp, qs_env, bs_env, cfm_mos_ikp, cfm_ks_ikp, cfm_work_ikp)
1624 DO j_t = 1, bs_env%num_time_freq_points
1625 CALL to_ikp_and_mo(sigma_c_ikp_n_time(:, j_t,
positive_time), &
1627 ikp, qs_env, bs_env, cfm_mos_ikp, cfm_ks_ikp, cfm_work_ikp)
1628 CALL to_ikp_and_mo(sigma_c_ikp_n_time(:, j_t,
negative_time), &
1630 ikp, qs_env, bs_env, cfm_mos_ikp, cfm_ks_ikp, cfm_work_ikp)
1635 sigma_c_ikp_n_freq(1:bs_env%n_occ(ispin), :) = conjg(sigma_c_ikp_n_freq(1:bs_env%n_occ(ispin), :))
1640 bs_env%eigenval_scf(:, ikp, ispin), ikp, ispin)
1656 CALL timestop(handle)
1671 SUBROUTINE to_ikp_and_mo(array_ikp_n, fm_Gamma, ikp, qs_env, bs_env, cfm_mos_ikp, cfm_ikp, workspace)
1673 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: array_ikp_n
1675 INTEGER,
INTENT(IN) :: ikp
1679 TYPE(
cp_cfm_type),
INTENT(INOUT) :: cfm_ikp, workspace
1681 CHARACTER(LEN=*),
PARAMETER :: routinen =
'to_ikp_and_mo'
1683 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: cdiag
1686 CALL timeset(routinen, handle)
1694 ALLOCATE (cdiag(
SIZE(array_ikp_n)))
1696 array_ikp_n = real(cdiag, kind=
dp)
1698 CALL timestop(handle)
1700 END SUBROUTINE to_ikp_and_mo
1717 SUBROUTINE get_bounds_from_atoms(bounds_out, atoms_1, atoms_2, indices_min, indices_max, &
1718 atoms_3, indices_3_start, indices_3_end)
1720 INTEGER,
DIMENSION(2),
INTENT(OUT) :: bounds_out
1721 INTEGER,
DIMENSION(2),
INTENT(IN) :: atoms_1, atoms_2
1722 INTEGER,
DIMENSION(:, :) :: indices_min, indices_max
1723 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: atoms_3
1724 INTEGER,
DIMENSION(:),
OPTIONAL :: indices_3_start, indices_3_end
1726 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_bounds_from_atoms'
1728 INTEGER :: handle, i_at, j_at
1730 CALL timeset(routinen, handle)
1731 bounds_out(1) = huge(0)
1734 DO i_at = atoms_1(1), atoms_1(2)
1735 DO j_at = atoms_2(1), atoms_2(2)
1736 bounds_out(1) = min(bounds_out(1), indices_min(i_at, j_at))
1737 bounds_out(2) = max(bounds_out(2), indices_max(i_at, j_at))
1741 IF (
PRESENT(atoms_3) .AND.
PRESENT(indices_3_start) .AND.
PRESENT(indices_3_end))
THEN
1742 bounds_out(1) = max(bounds_out(1), indices_3_start(atoms_3(1)))
1743 bounds_out(2) = min(bounds_out(2), indices_3_end(atoms_3(2)))
1746 CALL timestop(handle)
1748 END SUBROUTINE get_bounds_from_atoms
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public graml2024
Handles all functions related to the CELL.
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...
used for collecting diagonalization schemes available for cp_cfm_type
subroutine, public cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work, lowest_subset)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
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.
subroutine, public dbcsr_release(matrix)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan, check_plan)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
represent a full matrix distributed on many processors
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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_dbcsr(tensor, mat_tensor, mat_global, 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 fm_write(fm, matrix_index, matrix_name, qs_env, matrix)
Write a GW restart matrix when requested by the print key.
subroutine, public get_w_mic(bs_env, qs_env, mat_chi_gamma_tau, fm_w_mic_time)
...
subroutine, public fm_read(fm, bs_env, mat_name, idx)
...
Routines from paper [Graml2024].
subroutine, public compute_sigma_c_occ_vir(bs_env, qs_env, tau, ispin, fm_w, t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg, t_2c_sigma_pos, t_3c_x_w, mat_sigma_neg, mat_sigma_pos, count_skipped)
...
subroutine, public get_mat_chi_gamma_tau(bs_env, qs_env, mat_chi_gamma_tau)
...
subroutine, public get_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
...
subroutine, public create_mat_for_sigma_c(bs_env, t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, t_2c_sigma_pos_tau, t_3c_x_w, mat_sigma_neg_tau, mat_sigma_pos_tau)
...
subroutine, public gw_calc_tensor_large_cell_gamma(qs_env, bs_env)
Perform GW band structure calculation.
subroutine, public compute_3c_integrals(qs_env, bs_env, t_3c, atoms_ao_1, atoms_ao_2, atoms_ri)
...
subroutine, public compute_qp_energies(bs_env, qs_env, fm_sigma_x_gamma, fm_sigma_c_gamma_time)
...
subroutine, public delete_unnecessary_files(bs_env)
...
subroutine, public destroy_mat_sigma_c(t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, t_2c_sigma_pos_tau, t_3c_x_w, fm_w_mic_time, mat_sigma_neg_tau, mat_sigma_pos_tau)
...
subroutine, public print_skipping(bs_env)
...
Full-matrix operations not provided by the CP2K FM packages.
subroutine, public cfm_contract_aba(matrix_a, matrix_b, matrix_c, workspace)
Computes A^H B A for complex full matrices.
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 g_occ_vir(bs_env, tau, fm_g_gamma, ispin, occ, vir)
Build the real Gamma occupied or virtual one-particle propagator.
Types and set/get functions for HFX.
subroutine, public alloc_containers(data, bin_size)
...
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_path_length
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
Interface to the message passing library MPI.
subroutine, public mp_mem_avail_per_rank_gb(comm, mem_avail_gb)
Memory that is currently free on the node, per MPI rank of that node, in GB.
subroutine, public mp_file_delete(filepath, info)
Deletes a file. Auxiliary routine to emulate 'replace' action for mp_file_open. Only the master proce...
Framework for 2c-integrals for RI.
subroutine, public ri_2c_integral_mat(qs_env, fm_matrix_minv_l_gamma, fm_matrix_l_struct, dimen_ri, ri_metric, put_mat_ks_env, regularization_ri)
...
Define the data structure for the particle information.
subroutine, public store_3c_release(store)
Releases the kept 3-center integrals (the store is no longer in use).
subroutine, public cfm_ikp_from_fm_gamma(cfm_ikp, fm_gamma, ikp, qs_env, kpoints, basis_type)
Reconstruct a k-point operator from a real Gamma matrix using one MIC phase.
subroutine, public get_all_vbm_cbm_bandgaps(bs_env)
...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Utility methods to build 3-center integral tensors of various types.
subroutine, public build_3c_integrals(t3c, filter_eps, qs_env, nl_3c, basis_i, basis_j, basis_k, potential_parameter, int_eps, op_pos, do_kpoints, do_hfx_kpoints, desymmetrize, cell_sym, bounds_i, bounds_j, bounds_k, ri_range, img_to_ri_cell, cell_to_index_ext)
Build 3-center integral tensor.
subroutine, public compress_tensor(tensor, blk_indices, compressed, eps, memory)
...
subroutine, public decompress_tensor(tensor, blk_indices, compressed, eps)
...
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
Type defining parameters related to the simulation cell.
Represent a complex full matrix.