(git:27c966b)
Loading...
Searching...
No Matches
gw_tensor_large_cell_gamma.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Routines from paper [Graml2024]
10!> \par History
11!> 01.2026 Maximilian Graml: add more bounds to exploit sparsity in 3c integrals, fixes
12!> \author Jan Wilhelm
13!> \date 07.2023
14! **************************************************************************************************
16 USE bibliography, ONLY: graml2024,&
17 cite_reference
18 USE cell_types, ONLY: cell_type,&
19 pbc
21 USE cp_cfm_diag, ONLY: cp_cfm_geeig
22 USE cp_cfm_types, ONLY: cp_cfm_create,&
25 USE cp_dbcsr_api, ONLY: dbcsr_create,&
32 USE cp_fm_types, ONLY: cp_fm_create,&
35 USE dbt_api, ONLY: dbt_clear,&
36 dbt_contract,&
37 dbt_copy,&
38 dbt_create,&
39 dbt_destroy,&
40 dbt_filter,&
41 dbt_get_nze,&
42 dbt_type
45 USE gw_compute_v_and_w, ONLY: fm_read,&
46 fm_write,&
48 USE gw_utils, ONLY: g_occ_vir,&
51 USE gw_utils_fm, ONLY: cfm_contract_aba,&
54 USE input_constants, ONLY: g0w0
55 USE kinds, ONLY: default_path_length,&
56 dp,&
57 int_8
58 USE machine, ONLY: m_walltime
76#include "./base/base_uses.f90"
77
78 IMPLICIT NONE
79
80 PRIVATE
81
82 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'gw_tensor_large_cell_Gamma'
83
84 ! shares of memory that the kept 3-center integrals may take (estimated uncompressed): compressed
85 ! below a share of MEMORY_PER_PROC, kept as tensors (used in place) only below a small share of
86 ! MEMORY_PER_PROC and of the memory free at that time, since they add to the working set of the
87 ! tensor contractions that the estimate does not cover
88 REAL(KIND=dp), PARAMETER, PRIVATE :: store_3c_share_uncompressed = 0.1_dp, &
89 store_3c_share_compressed = 0.5_dp
90 ! compression stores multiples of EPS_FILTER times this (and drops smaller entries), as the
91 ! default EPS_STORAGE_SCALING of low-scaling RPA/GW
92 REAL(KIND=dp), PARAMETER, PRIVATE :: store_3c_eps_scaling = 1.0e-3_dp
93
96 g_occ_vir, &
100 get_sigma_x, &
105
106CONTAINS
107
108! **************************************************************************************************
109!> \brief Perform GW band structure calculation
110!> \param qs_env ...
111!> \param bs_env Band-structure environment containing GW parameters.
112!> \par History
113!> * 07.2023 created [Jan Wilhelm]
114! **************************************************************************************************
115 SUBROUTINE gw_calc_tensor_large_cell_gamma(qs_env, bs_env)
116 TYPE(qs_environment_type), POINTER :: qs_env
117 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
118
119 CHARACTER(LEN=*), PARAMETER :: routinen = 'gw_calc_tensor_large_cell_Gamma'
120
121 INTEGER :: handle
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
124
125 CALL timeset(routinen, handle)
126
127 CALL cite_reference(graml2024)
128
129 ! G^occ_µλ(i|τ|,k=0) = sum_n^occ C_µn(k=0) e^(-|(ϵ_nk=0-ϵ_F)τ|) C_λn(k=0)
130 ! G^vir_µλ(i|τ|,k=0) = sum_n^vir C_µn(k=0) e^(-|(ϵ_nk=0-ϵ_F)τ|) C_λn(k=0)
131 ! χ_PQ(iτ,k=0) = sum_λν [sum_µ (µν|P) G^occ_µλ(i|τ|)] [sum_σ (σλ|Q) G^vir_σν(i|τ|)]
132 ! (µν|P) does not depend on τ: kept (compressed) for the time points of χ if it fits
133 CALL store_3c_init(bs_env, bs_env%store_3c_chi, bs_env%n_intervals_i + bs_env%n_intervals_j)
134 CALL get_mat_chi_gamma_tau(bs_env, qs_env, bs_env%mat_chi_Gamma_tau)
135 CALL store_3c_finish(bs_env, bs_env%store_3c_chi)
136
137 ! χ_PQ(iτ,k=0) -> χ_PQ(iω,k) -> ε_PQ(iω,k) -> W_PQ(iω,k) -> W^MIC_PQ(iτ) -> M^-1*W^MIC*M^-1
138 CALL get_w_mic(bs_env, qs_env, bs_env%mat_chi_Gamma_tau, fm_w_mic_time)
139
140 ! (νσ|P) and (λµ|Q) kept (compressed) for Σ^x and the time points of Σ^c if they fit
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)
143
144 ! D_µν = sum_n^occ C_µn(k=0) C_νn(k=0), V^trunc_PQ = sum_cell_R <phi_P,0|V^trunc|phi_Q,R>
145 ! Σ^x_λσ(k=0) = sum_νQ [sum_P (νσ|P) V^trunc_PQ] [sum_µ (λµ|Q) D_µν)]
146 CALL get_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
147
148 ! Σ^c_λσ(iτ,k=0) = sum_νQ [sum_P (νσ|P) W^MIC_PQ(iτ)] [sum_µ (λµ|Q) G^occ_µν(i|τ|)], τ < 0
149 ! Σ^c_λσ(iτ,k=0) = sum_νQ [sum_P (νσ|P) W^MIC_PQ(iτ)] [sum_µ (λµ|Q) G^vir_µν(i|τ|)], τ > 0
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)
152
153 ! Σ^c_λσ(iτ,k=0) -> Σ^c_nn(ϵ,k); ϵ_nk^GW = ϵ_nk^DFT + Σ^c_nn(ϵ,k) + Σ^x_nn(k) - v^xc_nn(k)
154 CALL compute_qp_energies(bs_env, qs_env, fm_sigma_x_gamma, fm_sigma_c_gamma_time)
155
156 CALL de_init_bs_env(qs_env, bs_env)
157
158 CALL timestop(handle)
159
161
162! **************************************************************************************************
163!> \brief ...
164!> \param bs_env ...
165!> \param qs_env ...
166!> \param mat_chi_Gamma_tau ...
167! **************************************************************************************************
168 SUBROUTINE get_mat_chi_gamma_tau(bs_env, qs_env, mat_chi_Gamma_tau)
169 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
170 TYPE(qs_environment_type), POINTER :: qs_env
171 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: mat_chi_gamma_tau
172
173 CHARACTER(LEN=*), PARAMETER :: routinen = 'get_mat_chi_Gamma_tau'
174
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, &
178 j_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, &
184 t_3c_x_gvir_2
185 TYPE(dbt_type), POINTER :: t_3c_use
186 TYPE(dbt_type), TARGET :: t_3c_for_gocc, t_3c_for_gvir
187
188 CALL timeset(routinen, handle)
189
190 DO i_t = 1, bs_env%num_time_freq_points
191
192 t1 = m_walltime()
193
194 IF (bs_env%read_chi(i_t)) THEN
195
196 CALL fm_read(bs_env%fm_RI_RI, bs_env, bs_env%chi_name, i_t)
197
198 CALL copy_fm_to_dbcsr(bs_env%fm_RI_RI, mat_chi_gamma_tau(i_t)%matrix, &
199 keep_sparsity=.false.)
200
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, &
205 ', Execution time', m_walltime() - t1, ' s'
206 END IF
207
208 cycle
209
210 END IF
211
212 IF (.NOT. bs_env%calc_chi(i_t)) cycle
213
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)
216
217 ! 1. compute G^occ and G^vir
218 ! Background: G^σ(iτ) = G^occ,σ(iτ) * Θ(-τ) + G^vir,σ(iτ) * Θ(τ), σ ∈ {↑,↓}
219 ! G^occ,σ_µλ(i|τ|,k=0) = sum_n^occ C^σ_µn(k=0) e^(-|(ϵ^σ_nk=0-ϵ_F)τ|) C^σ_λn(k=0)
220 ! G^vir,σ_µλ(i|τ|,k=0) = sum_n^vir C^σ_µn(k=0) e^(-|(ϵ^σ_nk=0-ϵ_F)τ|) C^σ_λn(k=0)
221 tau = bs_env%time_frequency_grid%imaginary_time(i_t)
222
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.)
226
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)
233
234 ! every group has its own range of i_atoms and j_atoms; only deal with a
235 ! limited number of i_atom-j_atom pairs simultaneously in a group to save memory
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)
240
241 IF (bs_env%skip_chi(i_intval_idx, j_intval_idx)) THEN
242 ! Do that only after first timestep to avoid skips due to vanishing G
243 ! caused by gaps
244 IF (i_t == 2) THEN
245 bs_env%n_skip_chi = bs_env%n_skip_chi + 1
246 END IF
247 cycle
248 END IF
249
250 DO inner_loop_atoms_interval_index = 1, bs_env%n_intervals_inner_loop_atoms
251
252 il_atoms = bs_env%inner_loop_atom_intervals(1:2, inner_loop_atoms_interval_index)
253 ! Idea: Use sparsity in 3c integrals behind χ_PQ(iτ,k=0)
254 ! -> λ bounds from j_atoms -> sparse in IL_atoms through σ in
255 ! N_Qλν(iτ) = sum_σ (Qλ|σ) G^vir_νσ(i|τ|,k=0)
256 ! -> ν bounds from i_atoms -> sparse in IL_atoms through µ in
257 ! M_Pνλ(iτ) = sum_µ (Pν|µ) G^occ_λµ(i|τ|,k=0)
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
261 ! 2. compute 3-center integrals (Pν|µ) ("|": truncated Coulomb operator)
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)
264 ! 3. tensor operation M_Pνλ(iτ) = sum_µ (Pν|µ) G^occ_λµ(i|τ|,k=0)
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)
268 END IF
269 IF (.NOT. dist_too_long_j) THEN
270 ! 4. compute 3-center integrals (Qλ|σ) ("|": truncated Coulomb operator)
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)
273 ! 5. tensor operation N_Qλν(iτ) = sum_σ (Qλ|σ) G^vir_νσ(i|τ|,k=0)
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)
277 END IF
278 END DO ! IL_atoms
279
280 ! 6. reorder tensors: M_Pνλ -> M_Pλν
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.)
283
284 ! 7. tensor operation χ_PQ(iτ,k=0) = sum_λν M_Pλν(iτ) N_Qλν(iτ),
285 ! Bounds:
286 ! "comb" (combined index)
287 ! -> λ bounds from j_atoms
288 ! -> ν bounds from i_atoms
289 ! P -> sparse in ν (see 3.)
290 ! Q -> sparse in λ (see 5.)
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))]
295
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)
302
303 IF (bounds_q(1) > bounds_q(2) .OR. bounds_p(1) > bounds_p(2)) THEN
304 flop = 0_int_8
305 ELSE
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, &
312 bounds_2=bounds_p, &
313 bounds_3=bounds_q, &
314 filter_eps=bs_env%eps_filter, move_data=.false., flop=flop)
315 END IF
316 IF (flop == 0_int_8) bs_env%skip_chi(i_intval_idx, j_intval_idx) = .true.
317
318 END DO ! j_atoms
319 END DO ! i_atoms
320 END DO ! ispin
321
322 ! 8. communicate data of χ_PQ(iτ,k=0) in tensor bs_env%t_chi (which local in the
323 ! subgroup) to the global dbcsr matrix mat_chi_Gamma_tau (which stores
324 ! χ_PQ(iτ,k=0) for all time points)
325 CALL cp_dbt_to_dbcsr(bs_env%t_chi, bs_env%mat_RI_RI_tensor%matrix, &
326 mat_chi_gamma_tau(i_t)%matrix, bs_env%para_env)
327
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)
330
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)
333
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, &
337 ', Execution time', m_walltime() - t1, ' s'
338 END IF
339
340 END DO ! i_t
341
342 IF (bs_env%unit_nr > 0) WRITE (bs_env%unit_nr, '(A)') ' '
343
344 CALL timestop(handle)
345
346 END SUBROUTINE get_mat_chi_gamma_tau
347
348! **************************************************************************************************
349!> \brief ...
350!> \param t_2c_Gocc ...
351!> \param t_2c_Gvir ...
352!> \param t_3c_for_Gocc ...
353!> \param t_3c_for_Gvir ...
354!> \param t_3c_x_Gocc ...
355!> \param t_3c_x_Gvir ...
356!> \param t_3c_x_Gocc_2 ...
357!> \param t_3c_x_Gvir_2 ...
358!> \param bs_env ...
359! **************************************************************************************************
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)
362
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, &
366 t_3c_x_gvir_2
367 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
368
369 CHARACTER(LEN=*), PARAMETER :: routinen = 'create_tensors_chi'
370
371 INTEGER :: handle
372
373 CALL timeset(routinen, handle)
374
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)")
383
384 CALL timestop(handle)
385
386 END SUBROUTINE create_tensors_chi
387
388! **************************************************************************************************
389!> \brief ...
390!> \param t_2c_Gocc ...
391!> \param t_2c_Gvir ...
392!> \param t_3c_for_Gocc ...
393!> \param t_3c_for_Gvir ...
394!> \param t_3c_x_Gocc ...
395!> \param t_3c_x_Gvir ...
396!> \param t_3c_x_Gocc_2 ...
397!> \param t_3c_x_Gvir_2 ...
398! **************************************************************************************************
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, &
404 t_3c_x_gvir_2
405
406 CHARACTER(LEN=*), PARAMETER :: routinen = 'destroy_tensors_chi'
407
408 INTEGER :: handle
409
410 CALL timeset(routinen, handle)
411
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)
420
421 CALL timestop(handle)
422
423 END SUBROUTINE destroy_tensors_chi
424
425! **************************************************************************************************
426!> \brief ...
427!> \param qs_env ...
428!> \param bs_env ...
429!> \param t_3c ...
430!> \param atoms_AO_1 ...
431!> \param atoms_AO_2 ...
432!> \param atoms_RI ...
433! **************************************************************************************************
434 SUBROUTINE compute_3c_integrals(qs_env, bs_env, t_3c, atoms_AO_1, atoms_AO_2, atoms_RI)
435 TYPE(qs_environment_type), POINTER :: qs_env
436 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
437 TYPE(dbt_type) :: t_3c
438 INTEGER, DIMENSION(2), OPTIONAL :: atoms_ao_1, atoms_ao_2, atoms_ri
439
440 CHARACTER(LEN=*), PARAMETER :: routinen = 'compute_3c_integrals'
441
442 INTEGER :: handle
443 TYPE(dbt_type), ALLOCATABLE, DIMENSION(:, :) :: t_3c_array
444
445 CALL timeset(routinen, handle)
446
447 ! free memory (not clear whether memory has been freed previously)
448 CALL dbt_clear(t_3c)
449
450 ALLOCATE (t_3c_array(1, 1))
451 CALL dbt_create(t_3c, t_3c_array(1, 1))
452
453 CALL build_3c_integrals(t_3c_array, &
454 bs_env%eps_filter, &
455 qs_env, &
456 bs_env%nl_3c, &
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, &
462 bounds_i=atoms_ri, &
463 bounds_j=atoms_ao_1, &
464 bounds_k=atoms_ao_2, &
465 desymmetrize=.false.)
466
467 CALL dbt_filter(t_3c_array(1, 1), bs_env%eps_filter)
468
469 CALL dbt_copy(t_3c_array(1, 1), t_3c, move_data=.true.)
470
471 CALL dbt_destroy(t_3c_array(1, 1))
472 DEALLOCATE (t_3c_array)
473
474 CALL timestop(handle)
475
476 END SUBROUTINE compute_3c_integrals
477
478! **************************************************************************************************
479!> \brief Provides the 3-center integrals of the given atom ranges. If the store is in use, a set
480!> is computed at its first use and kept: as a tensor that every use takes in place, or
481!> compressed and decompressed into t_3c at every use (also the first), so that all uses
482!> see the same integrals. Otherwise, the integrals are computed into t_3c.
483!> \param qs_env ...
484!> \param bs_env ...
485!> \param store integrals kept for the phase (store_3c_init)
486!> \param t_3c work tensor
487!> \param t_3c_use the integrals: t_3c or a kept tensor (to be read only)
488!> \param atoms_AO_1 ...
489!> \param atoms_AO_2 ...
490!> \param atoms_RI ...
491! **************************************************************************************************
492 SUBROUTINE get_3c_integrals(qs_env, bs_env, store, t_3c, t_3c_use, atoms_AO_1, atoms_AO_2, &
493 atoms_RI)
494 TYPE(qs_environment_type), POINTER :: qs_env
495 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
496 TYPE(store_3c_type), INTENT(INOUT), TARGET :: store
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
500
501 CHARACTER(LEN=*), PARAMETER :: routinen = 'get_3c_integrals'
502
503 INTEGER :: handle, i, iset
504 INTEGER, DIMENSION(2, 3) :: atoms
505
506 CALL timeset(routinen, handle)
507
508 atoms = 0
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
512
513 t_3c_use => t_3c
514 iset = 0
515 IF (ALLOCATED(store%sets)) THEN
516 DO i = 1, store%nsets
517 IF (all(store%sets(i)%atoms == atoms)) iset = i
518 END DO
519 IF (iset == 0 .AND. store%nsets < SIZE(store%sets)) THEN
520 iset = store%nsets + 1
521 store%nsets = iset
522 store%sets(iset)%atoms = atoms
523 IF (store%uncompressed) THEN
524 CALL dbt_create(t_3c, store%sets(iset)%t_3c)
525 CALL compute_3c_integrals(qs_env, bs_env, store%sets(iset)%t_3c, atoms_ao_1, &
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
529 ELSE
530 CALL compute_3c_integrals(qs_env, bs_env, t_3c, atoms_ao_1, atoms_ao_2, atoms_ri)
531 CALL alloc_containers(store%sets(iset)%compressed, 1)
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)
534 END IF
535 END IF
536 END IF
537
538 IF (iset > 0) THEN
539 IF (store%uncompressed) THEN
540 t_3c_use => store%sets(iset)%t_3c
541 ELSE
542 CALL dbt_clear(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)
545 END IF
546 ELSE
547 CALL compute_3c_integrals(qs_env, bs_env, t_3c, atoms_ao_1, atoms_ao_2, atoms_ri)
548 END IF
549
550 CALL timestop(handle)
551
552 END SUBROUTINE get_3c_integrals
553
554! **************************************************************************************************
555!> \brief Puts a store of 3-center integrals in use if the integrals of the group's i and j atoms
556!> (estimated uncompressed) fit into a share of memory: compressed into
557!> store_3c_share_compressed of MEMORY_PER_PROC, uncompressed into
558!> store_3c_share_uncompressed of MEMORY_PER_PROC and of the free memory.
559!> \param bs_env ...
560!> \param store ...
561!> \param n_intervals number of atom intervals the integral sets are keyed by (besides the
562!> inner loop intervals)
563! **************************************************************************************************
564 SUBROUTINE store_3c_init(bs_env, store, n_intervals)
565 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
566 TYPE(store_3c_type), INTENT(INOUT) :: store
567 INTEGER, INTENT(IN) :: n_intervals
568
569 CHARACTER(LEN=*), PARAMETER :: routinen = 'store_3c_init'
570
571 INTEGER :: handle
572 REAL(kind=dp) :: free_gb, memory_gb
573
574 CALL timeset(routinen, handle)
575
576 CALL store_3c_release(store)
577
578 ! free memory per process (zero if not detected), the same on all processes
579 CALL mp_mem_avail_per_rank_gb(bs_env%para_env, free_gb)
580
581 ! non-zero (µν|P) of the group's i and j atoms per process
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)
585
586 ! a negative estimate is an unknown occupation (not kept)
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))
591 END IF
592
593 CALL timestop(handle)
594
595 END SUBROUTINE store_3c_init
596
597! **************************************************************************************************
598!> \brief Prints the memory the kept 3-center integrals took and releases them.
599!> \param bs_env ...
600!> \param store ...
601!> \param store_2 a second store of the same phase
602! **************************************************************************************************
603 SUBROUTINE store_3c_finish(bs_env, store, store_2)
604 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
605 TYPE(store_3c_type), INTENT(INOUT) :: store
606 TYPE(store_3c_type), INTENT(INOUT), OPTIONAL :: store_2
607
608 CHARACTER(LEN=*), PARAMETER :: routinen = 'store_3c_finish'
609
610 INTEGER :: handle
611 LOGICAL :: kept, uncompressed
612 REAL(kind=dp) :: memory
613
614 CALL timeset(routinen, handle)
615
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)
621
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'
626 ELSE IF (kept) THEN
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'
629 ELSE
630 WRITE (bs_env%unit_nr, '(T2,A,A24)') &
631 'Kept 3-center integrals (µν|P), compressed, per process', 'no'
632 END IF
633 END IF
634
635 CALL store_3c_release(store)
636 IF (PRESENT(store_2)) CALL store_3c_release(store_2)
637
638 CALL timestop(handle)
639
640 END SUBROUTINE store_3c_finish
641
642! **************************************************************************************************
643!> \brief ...
644!> \param t_3c_for_G ...
645!> \param t_G ...
646!> \param t_M ...
647!> \param bs_env ...
648!> \param atoms_AO_1 ...
649!> \param atoms_AO_2 ...
650!> \param atoms_IL ...
651! **************************************************************************************************
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
654 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
655 INTEGER, DIMENSION(2) :: atoms_ao_1, atoms_ao_2, atoms_il
656
657 CHARACTER(LEN=*), PARAMETER :: routinen = 'G_times_3c'
658
659 INTEGER :: handle
660 INTEGER(KIND=int_8) :: flop
661 INTEGER, DIMENSION(2) :: bounds_ao_1, bounds_il
662 INTEGER, DIMENSION(2, 2) :: bounds_comb
663
664 CALL timeset(routinen, handle)
665
666 ! Bounds reduce needed memory and therefore scaling behavior
667 ! Operations are of the form, e.g, M_Pνλ = sum_µ (Pν|µ) G_λµ
668 ! "comb" (combined index)
669 ! -> P sparse in ν and µ
670 ! -> λ bounds from j_atoms (via atoms_AO_1)
671 ! µ bounds from inner loop "IL" indices and sparse in P and ν
672 ! ν bounds from i_atoms (via atoms_AO_2) and sparse in P and µ
673
674 ! µ index
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, &
678 atoms_3=atoms_il, &
679 indices_3_start=bs_env%i_ao_start_from_atom, &
680 indices_3_end=bs_env%i_ao_end_from_atom)
681
682 ! P index
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)
686
687 ! ν index
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)
694
695 ! λ index
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))]
698
699 IF (bounds_il(1) > bounds_il(2) .OR. bounds_comb(1, 2) > bounds_comb(2, 2)) THEN
700 flop = 0_int_8
701 ELSE
702 CALL dbt_contract(alpha=1.0_dp, &
703 tensor_1=t_3c_for_g, &
704 tensor_2=t_g, &
705 beta=1.0_dp, &
706 tensor_3=t_m, &
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, &
712 flop=flop, &
713 filter_eps=bs_env%eps_filter)
714 END IF
715
716 CALL timestop(handle)
717
718 END SUBROUTINE g_times_3c
719
720! **************************************************************************************************
721!> \brief ...
722!> \param atoms_1 ...
723!> \param atoms_2 ...
724!> \param qs_env ...
725!> \param bs_env ...
726!> \param dist_too_long ...
727! **************************************************************************************************
728 SUBROUTINE check_dist(atoms_1, atoms_2, qs_env, bs_env, dist_too_long)
729 INTEGER, DIMENSION(2) :: atoms_1, atoms_2
730 TYPE(qs_environment_type), POINTER :: qs_env
731 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
732 LOGICAL :: dist_too_long
733
734 CHARACTER(LEN=*), PARAMETER :: routinen = 'check_dist'
735
736 INTEGER :: atom_1, atom_2, handle
737 REAL(dp) :: abs_rab, min_dist_ao_atoms
738 REAL(kind=dp), DIMENSION(3) :: rab
739 TYPE(cell_type), POINTER :: cell
740 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
741
742 CALL timeset(routinen, handle)
743
744 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
745
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)
750
751 abs_rab = sqrt(rab(1)**2 + rab(2)**2 + rab(3)**2)
752
753 min_dist_ao_atoms = min(min_dist_ao_atoms, abs_rab)
754 END DO
755 END DO
756
757 dist_too_long = (min_dist_ao_atoms > bs_env%max_dist_AO_atoms)
758
759 CALL timestop(handle)
760
761 END SUBROUTINE check_dist
762
763! **************************************************************************************************
764!> \brief ...
765!> \param bs_env ...
766!> \param qs_env ...
767!> \param fm_Sigma_x_Gamma ...
768! **************************************************************************************************
769 SUBROUTINE get_sigma_x(bs_env, qs_env, fm_Sigma_x_Gamma)
770 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
771 TYPE(qs_environment_type), POINTER :: qs_env
772 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_sigma_x_gamma
773
774 CHARACTER(LEN=*), PARAMETER :: routinen = 'get_Sigma_x'
775
776 INTEGER :: handle, ispin
777
778 CALL timeset(routinen, handle)
779
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)
783 END DO
784
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)
788 END DO
789 ELSE
790 CALL compute_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
791 END IF
792
793 CALL timestop(handle)
794
795 END SUBROUTINE get_sigma_x
796
797! **************************************************************************************************
798!> \brief ...
799!> \param bs_env ...
800!> \param qs_env ...
801!> \param fm_Sigma_x_Gamma ...
802! **************************************************************************************************
803 SUBROUTINE compute_sigma_x(bs_env, qs_env, fm_Sigma_x_Gamma)
804 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
805 TYPE(qs_environment_type), POINTER :: qs_env
806 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_sigma_x_gamma
807
808 CHARACTER(LEN=*), PARAMETER :: routinen = 'compute_Sigma_x'
809
810 INTEGER :: handle, i_intval_idx, ispin, j_intval_idx
811 INTEGER, DIMENSION(2) :: i_atoms, j_atoms
812 REAL(kind=dp) :: t1
813 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_vtr_gamma
814 TYPE(dbcsr_type) :: mat_sigma_x_gamma
815 TYPE(dbt_type) :: t_2c_d, t_2c_sigma_x, t_2c_v, t_3c_x_v
816
817 CALL timeset(routinen, handle)
818
819 t1 = m_walltime()
820
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)
826
827 ! 1. Compute truncated Coulomb operator matrix V^tr(k=0) (cutoff rad: cellsize/2)
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)
830
831 ! M^-1(k=0) V^tr M^-1(k=0) -> fm_Vtr_Gamma
832 CALL fm_contract_aba(bs_env%fm_Minv_Gamma, fm_vtr_gamma(:, 1))
833
834 DO ispin = 1, bs_env%n_spin
835
836 ! 3. Compute density matrix D_µν
837 CALL g_occ_vir(bs_env, 0.0_dp, bs_env%fm_work_mo(2), ispin, occ=.true., vir=.false.)
838
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)
842
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)
846
847 ! every group has its own range of i_atoms and j_atoms; only deal with a
848 ! limited number of i_atom-j_atom pairs simultaneously in a group to save memory
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)
853
854 ! 4. compute 3-center integrals (µν|P) ("|": truncated Coulomb operator)
855 ! 5. M_Qνσ(iτ) = sum_P (νσ|P) (M^-1(k=0)*V^tr(k=0)*M^-1(k=0))_QP(iτ)
856 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_v, t_2c_v)
857
858 ! 6. tensor operations with D and computation of Σ^x
859 ! Σ^x_λσ(k=0) = sum_νQ M_Qνσ(iτ) sum_µ (Qλ|µ) D_νµ
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.)
862
863 END DO ! j_atoms
864 END DO ! i_atoms
865
866 CALL cp_dbt_to_dbcsr(t_2c_sigma_x, bs_env%mat_ao_ao_tensor%matrix, &
867 mat_sigma_x_gamma, bs_env%para_env)
868
869 CALL fm_write(bs_env%fm_work_mo(1), ispin, bs_env%Sigma_x_name, qs_env, &
870 matrix=mat_sigma_x_gamma)
871
872 CALL copy_dbcsr_to_fm(mat_sigma_x_gamma, fm_sigma_x_gamma(ispin))
873
874 END DO ! ispin
875
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)') ' '
880 END IF
881
882 CALL dbcsr_release(mat_sigma_x_gamma)
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)
887 CALL cp_fm_release(fm_vtr_gamma)
888
889 CALL timestop(handle)
890
891 END SUBROUTINE compute_sigma_x
892
893! **************************************************************************************************
894!> \brief ...
895!> \param bs_env ...
896!> \param qs_env ...
897!> \param fm_W_MIC_time ...
898!> \param fm_Sigma_c_Gamma_time ...
899! **************************************************************************************************
900 SUBROUTINE get_sigma_c(bs_env, qs_env, fm_W_MIC_time, fm_Sigma_c_Gamma_time)
901 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
902 TYPE(qs_environment_type), POINTER :: qs_env
903 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_w_mic_time
904 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
905
906 CHARACTER(LEN=*), PARAMETER :: routinen = 'get_Sigma_c'
907
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
914
915 CALL timeset(routinen, handle)
916
917 CALL create_mat_for_sigma_c(bs_env, t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, &
918 t_2c_sigma_pos_tau, t_3c_x_w, &
919 mat_sigma_neg_tau, mat_sigma_pos_tau)
920
921 DO i_t = 1, bs_env%num_time_freq_points
922
923 DO ispin = 1, bs_env%n_spin
924
925 t1 = m_walltime()
926
927 read_write_index = i_t + (ispin - 1)*bs_env%num_time_freq_points
928
929 ! read self-energy from restart
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, &
940 ', Execution time', m_walltime() - t1, ' s'
941 END IF
942
943 cycle
944
945 END IF
946
947 tau = bs_env%time_frequency_grid%imaginary_time(i_t)
948
949 CALL compute_sigma_c_occ_vir(bs_env, qs_env, tau, ispin, fm_w_mic_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))
955
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)
960
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, &
964 ', Execution time', m_walltime() - t1, ' s'
965 END IF
966
967 END DO ! ispin
968
969 END DO ! i_t
970
971 IF (bs_env%unit_nr > 0) WRITE (bs_env%unit_nr, '(A)') ' '
972
973 CALL fill_fm_sigma_c_gamma_time(fm_sigma_c_gamma_time, bs_env, &
974 mat_sigma_pos_tau, mat_sigma_neg_tau)
975
976 CALL print_skipping(bs_env)
977
978 CALL destroy_mat_sigma_c(t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_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)
981
982 CALL delete_unnecessary_files(bs_env)
983
984 CALL timestop(handle)
985
986 END SUBROUTINE get_sigma_c
987
988! **************************************************************************************************
989!> \brief ...
990!> \brief Occupied and virtual parts of the correlation self-energy at one imaginary time τ
991!> Σ^neg_λσ(iτ) = -sum_νQ [sum_P (νσ|P) W_PQ] [sum_µ (λµ|Q) G^occ_µν(i|τ|)]
992!> Σ^pos_λσ(iτ) = sum_νQ [sum_P (νσ|P) W_PQ] [sum_µ (λµ|Q) G^vir_µν(i|τ|)]
993!> (G0W0: W = W^MIC(iτ); static COHSEX: W = W^MIC(iω=0))
994!> \param bs_env ...
995!> \param qs_env ...
996!> \param tau imaginary time τ
997!> \param ispin ...
998!> \param fm_W W^MIC_PQ
999!> \param t_2c_Gocc ...
1000!> \param t_2c_Gvir ...
1001!> \param t_2c_W ...
1002!> \param t_2c_Sigma_neg work tensor for Σ^neg
1003!> \param t_2c_Sigma_pos work tensor for Σ^pos
1004!> \param t_3c_x_W ...
1005!> \param mat_Sigma_neg Σ^neg_λσ(iτ) on exit
1006!> \param mat_Sigma_pos Σ^pos_λσ(iτ) on exit
1007!> \param count_skipped count the skipped atom-interval pairs (for print_skipping)
1008! **************************************************************************************************
1009 SUBROUTINE compute_sigma_c_occ_vir(bs_env, qs_env, tau, ispin, fm_W, t_2c_Gocc, t_2c_Gvir, &
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)
1012 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
1013 TYPE(qs_environment_type), POINTER :: qs_env
1014 REAL(kind=dp) :: tau
1015 INTEGER :: ispin
1016 TYPE(cp_fm_type) :: fm_w
1017 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
1018 t_2c_sigma_neg, t_2c_sigma_pos, &
1019 t_3c_x_w
1020 TYPE(dbcsr_type) :: mat_sigma_neg, mat_sigma_pos
1021 LOGICAL :: count_skipped
1022
1023 CHARACTER(LEN=*), PARAMETER :: routinen = 'compute_Sigma_c_occ_vir'
1024
1025 INTEGER :: handle, i_intval_idx, j_intval_idx
1026 INTEGER, DIMENSION(2) :: i_atoms, j_atoms
1027
1028 CALL timeset(routinen, handle)
1029
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.)
1032
1033 ! fm G^occ, G^vir and W to local tensor
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)
1043
1044 ! every group has its own range of i_atoms and j_atoms; only deal with a
1045 ! limited number of i_atom-j_atom pairs simultaneously in a group to save memory
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)
1050
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
1053 ! Do that only after first timestep to avoid skips due to vanishing G
1054 ! caused by gaps
1055 IF (count_skipped) THEN
1056 bs_env%n_skip_sigma = bs_env%n_skip_sigma + 1
1057 END IF
1058 cycle
1059 END IF
1060
1061 ! 1. compute 3-center integrals (µν|P) ("|": truncated Coulomb operator)
1062 ! 2. tensor operation M_Qνσ(iτ) = sum_P (νσ|P) W^MIC_QP(iτ)
1063 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_w, t_2c_w)
1064
1065 ! 3. Σ_λσ(iτ,k=0) = sum_νQ M_Qνσ(iτ) sum_µ (Qλ|µ) G^occ_νµ(i|τ|) for τ < 0
1066 ! (recall M_Qνσ(iτ) = M_Qνσ(-iτ) because W^MIC_PQ(iτ) = W^MIC_PQ(-iτ) )
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))
1070
1071 ! Σ_λσ(iτ,k=0) = sum_νQ M_Qνσ(iτ) sum_µ (Qλ|µ) G^vir_νµ(i|τ|) for τ > 0
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))
1075
1076 END DO ! j_atoms
1077 END DO ! i_atoms
1078
1079 ! 4. communicate data tensor t_2c_Sigma (which is local in the subgroup)
1080 ! to the global dbcsr matrix mat_Sigma_pos/neg_tau (which stores Σ for all iτ)
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)
1085
1086 CALL timestop(handle)
1087
1088 END SUBROUTINE compute_sigma_c_occ_vir
1089
1090! **************************************************************************************************
1091!> \brief ...
1092!> \param bs_env ...
1093!> \param t_2c_Gocc ...
1094!> \param t_2c_Gvir ...
1095!> \param t_2c_W ...
1096!> \param t_2c_Sigma_neg_tau ...
1097!> \param t_2c_Sigma_pos_tau ...
1098!> \param t_3c_x_W ...
1099!> \param mat_Sigma_neg_tau ...
1100!> \param mat_Sigma_pos_tau ...
1101! **************************************************************************************************
1102 SUBROUTINE create_mat_for_sigma_c(bs_env, t_2c_Gocc, t_2c_Gvir, t_2c_W, t_2c_Sigma_neg_tau, &
1103 t_2c_Sigma_pos_tau, t_3c_x_W, &
1104 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
1105
1106 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
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
1111
1112 CHARACTER(LEN=*), PARAMETER :: routinen = 'create_mat_for_Sigma_c'
1113
1114 INTEGER :: handle, i_t, ispin
1115
1116 CALL timeset(routinen, handle)
1117
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)
1124
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))
1128
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)
1135 END DO
1136 END DO
1137
1138 CALL timestop(handle)
1139
1140 END SUBROUTINE create_mat_for_sigma_c
1141
1142! **************************************************************************************************
1143!> \brief ...
1144!> \param qs_env ...
1145!> \param bs_env ...
1146!> \param i_atoms ...
1147!> \param j_atoms ...
1148!> \param t_3c_x_W ...
1149!> \param t_2c_W ...
1150! **************************************************************************************************
1151 SUBROUTINE compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_W, t_2c_W)
1152
1153 TYPE(qs_environment_type), POINTER :: qs_env
1154 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
1155 INTEGER, DIMENSION(2) :: i_atoms, j_atoms
1156 TYPE(dbt_type) :: t_3c_x_w, t_2c_w
1157
1158 CHARACTER(LEN=*), PARAMETER :: routinen = 'compute_3c_and_contract_W'
1159
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
1167
1168 CALL timeset(routinen, handle)
1169
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)
1172
1173 ! final layout will be: M_Qνσ(iτ) = sum_P (P|νσ) W^MIC_QP(iτ)
1174 ! Bounds:
1175 ! "AO"
1176 ! -> ν (AO_1 in compute_3c_integrals) bounds from i_atoms and sparse in σ and P
1177 ! -> σ (AO_2 in compute_3c_integrals) sparse in ν and P
1178 ! Q bounds from j_atoms
1179 ! P bounds from inner loop indices and sparse in ν and σ
1180
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))]
1183
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)
1186
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, &
1190 atoms_3=ri_atoms, &
1191 indices_3_start=bs_env%i_RI_start_from_atom, &
1192 indices_3_end=bs_env%i_RI_end_from_atom)
1193
1194 ! σ
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)
1198 ! ν
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, &
1202 atoms_3=i_atoms, &
1203 indices_3_start=bs_env%i_ao_start_from_atom, &
1204 indices_3_end=bs_env%i_ao_end_from_atom)
1205
1206 IF (bounds_p(1) > bounds_p(2) .OR. bounds_ao(1, 2) > bounds_ao(2, 2)) THEN
1207 cycle
1208 END IF
1209
1210 ! 1. compute 3-center integrals (P|µν) ("|": truncated Coulomb operator)
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)
1213
1214 ! 2. tensor operation M_Qνσ(iτ) = sum_P W^MIC_QP(iτ) (P|νσ)
1215 CALL dbt_contract(alpha=1.0_dp, &
1216 tensor_1=t_2c_w, &
1217 tensor_2=t_3c_use, &
1218 beta=1.0_dp, &
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, &
1225 flop=flop, &
1226 move_data=.false., &
1227 filter_eps=bs_env%eps_filter)
1228
1229 END DO ! RI_atoms
1230
1231 ! 3. reorder tensor
1232 CALL dbt_copy(t_3c_x_w_tmp, t_3c_x_w, order=[1, 2, 3], move_data=.true.)
1233
1234 CALL dbt_destroy(t_3c_x_w_tmp)
1235 CALL dbt_destroy(t_3c_for_w)
1236
1237 CALL timestop(handle)
1238
1239 END SUBROUTINE compute_3c_and_contract_w
1240
1241! **************************************************************************************************
1242!> \brief ...
1243!> \param t_2c_G ...
1244!> \param t_3c_x_W ...
1245!> \param t_2c_Sigma ...
1246!> \param i_atoms ...
1247!> \param j_atoms ...
1248!> \param qs_env ...
1249!> \param bs_env ...
1250!> \param occ ...
1251!> \param vir ...
1252!> \param can_skip ...
1253! **************************************************************************************************
1254 SUBROUTINE contract_to_sigma(t_2c_G, t_3c_x_W, t_2c_Sigma, i_atoms, j_atoms, qs_env, bs_env, &
1255 occ, vir, can_skip)
1256 TYPE(dbt_type) :: t_2c_g, t_3c_x_w, t_2c_sigma
1257 INTEGER, DIMENSION(2) :: i_atoms, j_atoms
1258 TYPE(qs_environment_type), POINTER :: qs_env
1259 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
1260 LOGICAL :: occ, vir
1261 LOGICAL, OPTIONAL :: can_skip
1262
1263 CHARACTER(LEN=*), PARAMETER :: routinen = 'contract_to_Sigma'
1264
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
1274
1275 CALL timeset(routinen, handle)
1276
1277 cpassert(occ .EQV. (.NOT. vir))
1278 IF (occ) sign_sigma = -1.0_dp
1279 IF (vir) sign_sigma = 1.0_dp
1280
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)
1284
1285 ! Here, in the first step e.g., is computed: N_Qλν = sum_µ (Qλ|µ) G_νµ
1286 ! Afterwards e.g., is computed: Σ_λσ = sum_νQ M_Qνσ N_Qνλ (after reordering)
1287 ! Bounds:
1288 ! "comb" (combined index)
1289 ! -> Q bounds from j_atoms and sparse in λ
1290 ! -> λ (AO_1 in compute_3c_integrals) sparse in Q and µ
1291 ! µ (AO_2 in compute_3c_integrals) bounds from inner loop "IL" indices and sparse in Q and λ
1292 ! ν bounds from i_atoms
1293 ! σ sparse in ν
1294
1295 ! ν
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))]
1298
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)
1301
1302 ! µ
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, &
1306 atoms_3=il_atoms, &
1307 indices_3_start=bs_env%i_ao_start_from_atom, &
1308 indices_3_end=bs_env%i_ao_end_from_atom)
1309
1310 ! Q
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, &
1314 atoms_3=j_atoms, &
1315 indices_3_start=bs_env%i_RI_start_from_atom, &
1316 indices_3_end=bs_env%i_RI_end_from_atom)
1317
1318 ! λ
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)
1322
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
1325 cycle
1326 END IF
1327
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)
1330
1331 CALL dbt_contract(alpha=1.0_dp, &
1332 tensor_1=t_2c_g, &
1333 tensor_2=t_3c_use, &
1334 beta=1.0_dp, &
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, &
1341 flop=flop, &
1342 move_data=.false., &
1343 filter_eps=bs_env%eps_filter)
1344 END DO ! IL_atoms
1345
1346 ! Reordering: N_Qλν -> N_Qνλ
1347 CALL dbt_copy(t_3c_x_g, t_3c_x_g_2, order=[1, 3, 2], move_data=.true.)
1348
1349 ! Here, the last contraction is done, e.g., Σ_λσ = sum_νQ M_Qνσ N_Qνλ
1350 ! Bounds as above, new "comb" with upper ingredients
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)
1354
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)
1361
1362 IF (bounds_sigma(1) > bounds_sigma(2) .OR. bounds_lambda(1) > bounds_lambda(2)) THEN
1363 flop = 0_int_8
1364 ELSE
1365 CALL dbt_contract(alpha=sign_sigma, &
1366 tensor_1=t_3c_x_w, &
1367 tensor_2=t_3c_x_g_2, &
1368 beta=1.0_dp, &
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)
1376 END IF
1377
1378 IF (PRESENT(can_skip)) THEN
1379 IF (flop == 0_int_8) can_skip = .true.
1380 END IF
1381
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)
1385
1386 CALL timestop(handle)
1387
1388 END SUBROUTINE contract_to_sigma
1389
1390! **************************************************************************************************
1391!> \brief Copy the positive- and negative-time self-energy matrices to the FM time array.
1392!> \param fm_Sigma_c_Gamma_time allocated output indexed by time, time sector and spin
1393!> \param bs_env time grid, spin count and AO layout
1394!> \param mat_Sigma_pos_tau positive-time self-energy matrices
1395!> \param mat_Sigma_neg_tau negative-time self-energy matrices
1396! **************************************************************************************************
1397 SUBROUTINE fill_fm_sigma_c_gamma_time(fm_Sigma_c_Gamma_time, bs_env, &
1398 mat_Sigma_pos_tau, mat_Sigma_neg_tau)
1399
1400 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
1401 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
1402 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: mat_sigma_pos_tau, mat_sigma_neg_tau
1403
1404 CHARACTER(LEN=*), PARAMETER :: routinen = 'fill_fm_Sigma_c_Gamma_time'
1405
1406 INTEGER :: handle, i_t, ispin, pos_neg
1407
1408 CALL timeset(routinen, handle)
1409
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
1413 DO pos_neg = 1, 2
1414 CALL cp_fm_create(fm_sigma_c_gamma_time(i_t, pos_neg, ispin), &
1415 bs_env%fm_s_Gamma%matrix_struct)
1416 END DO
1417 CALL copy_dbcsr_to_fm(mat_sigma_pos_tau(i_t, ispin)%matrix, &
1418 fm_sigma_c_gamma_time(i_t, 1, ispin))
1419 CALL copy_dbcsr_to_fm(mat_sigma_neg_tau(i_t, ispin)%matrix, &
1420 fm_sigma_c_gamma_time(i_t, 2, ispin))
1421 END DO
1422 END DO
1423
1424 CALL timestop(handle)
1425
1426 END SUBROUTINE fill_fm_sigma_c_gamma_time
1427
1428! **************************************************************************************************
1429!> \brief ...
1430!> \param bs_env ...
1431! **************************************************************************************************
1432 SUBROUTINE print_skipping(bs_env)
1433
1434 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
1435
1436 CHARACTER(LEN=*), PARAMETER :: routinen = 'print_skipping'
1437
1438 INTEGER :: handle, n_pairs
1439
1440 CALL timeset(routinen, handle)
1441
1442 n_pairs = bs_env%n_intervals_i*bs_env%n_intervals_j*bs_env%n_spin
1443
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)
1447
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), ' %'
1455 END IF
1456
1457 CALL timestop(handle)
1458
1459 END SUBROUTINE print_skipping
1460
1461! **************************************************************************************************
1462!> \brief ...
1463!> \param t_2c_Gocc ...
1464!> \param t_2c_Gvir ...
1465!> \param t_2c_W ...
1466!> \param t_2c_Sigma_neg_tau ...
1467!> \param t_2c_Sigma_pos_tau ...
1468!> \param t_3c_x_W ...
1469!> \param fm_W_MIC_time ...
1470!> \param mat_Sigma_neg_tau ...
1471!> \param mat_Sigma_pos_tau ...
1472! **************************************************************************************************
1473 SUBROUTINE destroy_mat_sigma_c(t_2c_Gocc, t_2c_Gvir, t_2c_W, t_2c_Sigma_neg_tau, &
1474 t_2c_Sigma_pos_tau, t_3c_x_W, fm_W_MIC_time, &
1475 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
1476
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
1482
1483 CHARACTER(LEN=*), PARAMETER :: routinen = 'destroy_mat_Sigma_c'
1484
1485 INTEGER :: handle
1486
1487 CALL timeset(routinen, handle)
1488
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)
1495 CALL cp_fm_release(fm_w_mic_time)
1496 CALL dbcsr_deallocate_matrix_set(mat_sigma_neg_tau)
1497 CALL dbcsr_deallocate_matrix_set(mat_sigma_pos_tau)
1498
1499 CALL timestop(handle)
1500
1501 END SUBROUTINE destroy_mat_sigma_c
1502
1503! **************************************************************************************************
1504!> \brief ...
1505!> \param bs_env ...
1506! **************************************************************************************************
1507 SUBROUTINE delete_unnecessary_files(bs_env)
1508 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
1509
1510 CHARACTER(LEN=*), PARAMETER :: routinen = 'delete_unnecessary_files'
1511
1512 CHARACTER(LEN=default_path_length) :: f_chi, f_w_t, prefix
1513 INTEGER :: handle, i_t
1514
1515 CALL timeset(routinen, handle)
1516
1517 prefix = bs_env%prefix
1518
1519 DO i_t = 1, bs_env%num_time_freq_points
1520
1521 IF (i_t < 10) THEN
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"
1527 ELSE
1528 cpabort('Please implement more than 99 time/frequency points.')
1529 END IF
1530
1531 CALL safe_delete(f_chi, bs_env)
1532 CALL safe_delete(f_w_t, bs_env)
1533
1534 END DO
1535
1536 CALL timestop(handle)
1537
1538 END SUBROUTINE delete_unnecessary_files
1539
1540! **************************************************************************************************
1541!> \brief ...
1542!> \param filename ...
1543!> \param bs_env ...
1544! **************************************************************************************************
1545 SUBROUTINE safe_delete(filename, bs_env)
1546 CHARACTER(LEN=*) :: filename
1547 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
1548
1549 CHARACTER(LEN=*), PARAMETER :: routinen = 'safe_delete'
1550
1551 INTEGER :: handle
1552 LOGICAL :: file_exists
1553
1554 CALL timeset(routinen, handle)
1555
1556 IF (bs_env%para_env%mepos == 0) THEN
1557
1558 INQUIRE (file=trim(filename), exist=file_exists)
1559 IF (file_exists) CALL mp_file_delete(trim(filename))
1560
1561 END IF
1562
1563 CALL timestop(handle)
1564
1565 END SUBROUTINE safe_delete
1566
1567! **************************************************************************************************
1568!> \brief ...
1569!> \param bs_env ...
1570!> \param qs_env ...
1571!> \param fm_Sigma_x_Gamma ...
1572!> \param fm_Sigma_c_Gamma_time ...
1573! **************************************************************************************************
1574 SUBROUTINE compute_qp_energies(bs_env, qs_env, fm_Sigma_x_Gamma, fm_Sigma_c_Gamma_time)
1575
1576 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
1577 TYPE(qs_environment_type), POINTER :: qs_env
1578 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_sigma_x_gamma
1579 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
1580
1581 CHARACTER(LEN=*), PARAMETER :: routinen = 'compute_QP_energies'
1582
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, &
1588 cfm_work_ikp
1589
1590 CALL timeset(routinen, handle)
1591
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)
1594 ! JW TODO: fully distribute these arrays at given time; also eigenvalues in bs_env
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))
1598
1599 DO ispin = 1, bs_env%n_spin
1600
1601 DO ikp = 1, bs_env%nkp_bs_and_DOS
1602
1603 ! 1. get H^KS_µν(k_i) from H^KS_µν(k=0)
1604 CALL cfm_ikp_from_fm_gamma(cfm_ks_ikp, bs_env%fm_ks_Gamma(ispin), &
1605 ikp, qs_env, bs_env%kpoints_DOS, "ORB")
1606
1607 ! 2. get S_µν(k_i) from S_µν(k=0)
1608 CALL cfm_ikp_from_fm_gamma(cfm_s_ikp, bs_env%fm_s_Gamma, &
1609 ikp, qs_env, bs_env%kpoints_DOS, "ORB")
1610
1611 ! 3. Diagonalize (Roothaan-Hall): H_KS(k_i)*C(k_i) = S(k_i)*C(k_i)*ϵ(k_i)
1612 CALL cp_cfm_geeig(cfm_ks_ikp, cfm_s_ikp, cfm_mos_ikp, &
1613 bs_env%eigenval_scf(:, ikp, ispin), cfm_work_ikp)
1614
1615 ! 4. V^xc_µν(k=0) -> V^xc_µν(k_i) -> V^xc_nn(k_i)
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)
1618
1619 ! 5. Σ^x_µν(k=0) -> Σ^x_µν(k_i) -> Σ^x_nn(k_i)
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)
1622
1623 ! 6. Σ^c_µν(k=0,+/-i|τ_j|) -> Σ^c_µν(k_i,+/-i|τ_j|) -> Σ^c_nn(k_i,+/-i|τ_j|)
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), &
1626 fm_sigma_c_gamma_time(j_t, positive_time, ispin), &
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), &
1629 fm_sigma_c_gamma_time(j_t, negative_time, ispin), &
1630 ikp, qs_env, bs_env, cfm_mos_ikp, cfm_ks_ikp, cfm_work_ikp)
1631 END DO
1632
1633 ! 7. Σ^c_nn(k_i,iτ) -> Σ^c_nn(k_i,iω)
1634 CALL transform_time_to_frequency(bs_env%time_frequency_grid_sigma, sigma_c_ikp_n_time, sigma_c_ikp_n_freq)
1635 sigma_c_ikp_n_freq(1:bs_env%n_occ(ispin), :) = conjg(sigma_c_ikp_n_freq(1:bs_env%n_occ(ispin), :))
1636
1637 ! 8. Analytic continuation Σ^c_nn(k_i,iω) -> Σ^c_nn(k_i,ϵ) and
1638 ! ϵ_nk_i^GW = ϵ_nk_i^DFT + Σ^c_nn(k_i,ϵ) + Σ^x_nn(k_i) - v^xc_nn(k_i)
1639 CALL analyt_conti_and_print(bs_env, sigma_c_ikp_n_freq, sigma_x_ikp_n, v_xc_ikp_n, &
1640 bs_env%eigenval_scf(:, ikp, ispin), ikp, ispin)
1641
1642 END DO ! ikp_DOS
1643
1644 END DO ! ispin
1645
1646 CALL get_all_vbm_cbm_bandgaps(bs_env)
1647
1648 ! Σ^x is releases here in case of G0W0
1649 IF (bs_env%gw_flavour == g0w0) CALL cp_fm_release(fm_sigma_x_gamma)
1650 CALL cp_fm_release(fm_sigma_c_gamma_time)
1651 CALL cp_cfm_release(cfm_ks_ikp)
1652 CALL cp_cfm_release(cfm_s_ikp)
1653 CALL cp_cfm_release(cfm_mos_ikp)
1654 CALL cp_cfm_release(cfm_work_ikp)
1655
1656 CALL timestop(handle)
1657
1658 END SUBROUTINE compute_qp_energies
1659
1660! **************************************************************************************************
1661!> \brief Reconstruct a k-point Hermitian operator and return its real MO diagonal.
1662!> \param array_ikp_n Real diagonal elements in the MO basis.
1663!> \param fm_Gamma Real AO operator at the Gamma point.
1664!> \param ikp Index of the target k-point.
1665!> \param qs_env Quantum simulation environment.
1666!> \param bs_env Band-structure environment containing the target k-points.
1667!> \param cfm_mos_ikp Complex MO coefficients at the target k-point.
1668!> \param cfm_ikp Reusable AO operator buffer; overwritten by its MO projection.
1669!> \param workspace Reusable projection scratch matrix with the MO coefficient layout.
1670! **************************************************************************************************
1671 SUBROUTINE to_ikp_and_mo(array_ikp_n, fm_Gamma, ikp, qs_env, bs_env, cfm_mos_ikp, cfm_ikp, workspace)
1672
1673 REAL(kind=dp), DIMENSION(:), INTENT(OUT) :: array_ikp_n
1674 TYPE(cp_fm_type), INTENT(IN) :: fm_gamma
1675 INTEGER, INTENT(IN) :: ikp
1676 TYPE(qs_environment_type), POINTER :: qs_env
1677 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
1678 TYPE(cp_cfm_type), INTENT(IN) :: cfm_mos_ikp
1679 TYPE(cp_cfm_type), INTENT(INOUT) :: cfm_ikp, workspace
1680
1681 CHARACTER(LEN=*), PARAMETER :: routinen = 'to_ikp_and_mo'
1682
1683 COMPLEX(KIND=dp), ALLOCATABLE, DIMENSION(:) :: cdiag
1684 INTEGER :: handle
1685
1686 CALL timeset(routinen, handle)
1687
1688 ! get cfm_µν(k_i) from fm_µν(k=0)
1689 CALL cfm_ikp_from_fm_gamma(cfm_ikp, fm_gamma, ikp, qs_env, bs_env%kpoints_DOS, "ORB")
1690
1691 CALL cfm_contract_aba(cfm_mos_ikp, cfm_ikp, workspace=workspace)
1692
1693 ! Taking the real MO diagonal selects the Hermitian part of the operator.
1694 ALLOCATE (cdiag(SIZE(array_ikp_n)))
1695 CALL cp_cfm_get_diag(cfm_ikp, cdiag)
1696 array_ikp_n = real(cdiag, kind=dp)
1697
1698 CALL timestop(handle)
1699
1700 END SUBROUTINE to_ikp_and_mo
1701
1702! **************************************************************************************************
1703!> \brief Computes bounds (AO or RI) for given atom intervals atoms_1 and atoms_2 from indices_min
1704!> and indices_max and returns them in bounds_out.
1705!> In case, atoms_3 and indices_3 are given, the bounds are computed as the intersection
1706!> \param bounds_out Bounds to be computed
1707!> \param atoms_1 First atom interval
1708!> \param atoms_2 Second atom interval
1709!> \param indices_min Minimum indices for each atom pair (typically from bs_env,
1710!> computed in get_i_j_atom_ranges in gw_utils.F, e.g. bs_env%min_RI_idx_from_AO_AO_atom)
1711!> \param indices_max Maximum indices for each atom pair (typically from bs_env,
1712!> computed in get_i_j_atom_ranges in gw_utils.F)
1713!> \param atoms_3 (Optional) Third atom interval for intersection
1714!> \param indices_3_start (Optional) Indices for third atom interval for intersection
1715!> \param indices_3_end (Optional) Indices for third atom interval for intersection
1716! **************************************************************************************************
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)
1719
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
1725
1726 CHARACTER(LEN=*), PARAMETER :: routinen = 'get_bounds_from_atoms'
1727
1728 INTEGER :: handle, i_at, j_at
1729
1730 CALL timeset(routinen, handle)
1731 bounds_out(1) = huge(0)
1732 bounds_out(2) = -1
1733 !Loop over all atoms in the two intervals and find min/max indices
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))
1738 END DO
1739 END DO
1740
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)))
1744 END IF
1745
1746 CALL timestop(handle)
1747
1748 END SUBROUTINE get_bounds_from_atoms
1749
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.
Definition cell_types.F:15
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
Definition cp_cfm_diag.F:14
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
Definition cp_fm_types.F:15
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....
Definition dbt_api.F:17
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.
Definition gw_utils_fm.F:13
subroutine, public cfm_contract_aba(matrix_a, matrix_b, matrix_c, workspace)
Computes A^H B A for complex full matrices.
Definition gw_utils_fm.F:59
subroutine, public de_init_bs_env(qs_env, bs_env)
Releases the memory-heavy GW intermediates that cannot be freed in bs_env_release,...
Definition gw_utils.F:3562
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)
...
Definition gw_utils.F:3653
subroutine, public g_occ_vir(bs_env, tau, fm_g_gamma, ispin, occ, vir)
Build the real Gamma occupied or virtual one-particle propagator.
Definition gw_utils.F:4189
Types and set/get functions for HFX.
Definition hfx_types.F:16
subroutine, public alloc_containers(data, bin_size)
...
Definition hfx_types.F:2935
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public g0w0
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public int_8
Definition kinds.F:54
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_path_length
Definition kinds.F:58
Machine interface based on Fortran 2003 and POSIX.
Definition machine.F:17
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition machine.F:144
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.
Definition mp2_ri_2c.F:14
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)
...
Definition mp2_ri_2c.F:576
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.
Definition qs_tensors.F:11
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.
Definition cell_types.F:60
Represent a complex full matrix.
represent a full matrix