(git:6344619)
Loading...
Searching...
No Matches
gw_tensor_large_cell_gamma_static_cohsex.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 Static COHSEX band structure in the tensor-based large-cell Gamma GW code:
10!> COHSEX DIAGONAL (diagonal energies) or COHSEX QP_UPDATE (canonical energies and MOs)
11!> \author Ritaj Tyagi
12!> \date Jan 2025
13! **************************************************************************************************
16 USE bibliography, ONLY: hedin1965,&
18 tyagi2024,&
19 tyagi2026,&
20 cite_reference
21 USE cell_types, ONLY: cell_type
22 USE cp_cfm_diag, ONLY: cp_cfm_geeig
23 USE cp_cfm_types, ONLY: cp_cfm_create,&
28 USE cp_dbcsr_api, ONLY: dbcsr_add,&
33 USE cp_files, ONLY: close_file,&
37 USE cp_fm_diag, ONLY: cp_fm_syevx
38 USE cp_fm_types, ONLY: cp_fm_create,&
48 USE cp_output_handling, ONLY: cp_p_file,&
53 USE dbt_api, ONLY: dbt_type
58 fm_read,&
67 USE gw_utils, ONLY: de_init_bs_env
68 USE gw_utils_fm, ONLY: cfm_contract_aba,&
74 USE kinds, ONLY: default_path_length,&
76 dp
77 USE machine, ONLY: m_walltime
81 USE physcon, ONLY: evolt
85 USE pw_env_types, ONLY: pw_env_get,&
88 USE pw_types, ONLY: pw_c1d_gs_type,&
95 USE qs_mo_types, ONLY: allocate_mo_set,&
101#include "./base/base_uses.f90"
102
103 IMPLICIT NONE
104
105 PRIVATE
106
107 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'gw_tensor_large_cell_Gamma_static_cohsex'
108
110
111CONTAINS
112
113! **************************************************************************************************
114!> \brief Perform static COHSEX band structure calculation
115!> \param qs_env ...
116!> \param bs_env ...
117!> \par History
118!> * 12.2024 created [Ritaj Tyagi]
119! **************************************************************************************************
121 TYPE(qs_environment_type), POINTER :: qs_env
122 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
123
124 CHARACTER(LEN=*), PARAMETER :: routinen = 'gw_calc_tensor_large_cell_Gamma_static_cohsex'
125
126 INTEGER :: handle
127 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_sigma_c_gamma, fm_sigma_x_gamma, &
128 fm_w_mic_freq_zero
129
130 CALL timeset(routinen, handle)
131
132 ! static COHSEX; with QP_UPDATE the quasiparticle update; scaled self-energy if requested
133 CALL cite_reference(hedin1965)
134 CALL cite_reference(hybertsen1986)
135 IF (bs_env%cohsex_flavor == cohsex_qp_update) CALL cite_reference(tyagi2024)
136 IF (bs_env%cohsex_scale_occ /= 1.0_dp .OR. bs_env%cohsex_scale_virt /= 1.0_dp) THEN
137 CALL cite_reference(tyagi2026)
138 END IF
139
140 IF (bs_env%Sigma_c_freq_zero_exists) THEN
141
142 ! restart: Σ^c_λσ(iω=0,k=0) from file; χ and W are not needed
143 CALL read_sigma_c_freq_zero(bs_env, fm_sigma_c_gamma)
144
145 ELSE
146
147 ! G^occ_µλ(i|τ|,k=0) = sum_n^occ C_µn(k=0) e^(-|(ϵ_nk=0-ϵ_F)τ|) C_λn(k=0)
148 ! G^vir_µλ(i|τ|,k=0) = sum_n^vir C_µn(k=0) e^(-|(ϵ_nk=0-ϵ_F)τ|) C_λn(k=0)
149 ! χ_PQ(iτ,k=0) = sum_λν [sum_µ (µν|P) G^occ_µλ(i|τ|)] [sum_σ (σλ|Q) G^vir_σν(i|τ|)]
150 CALL get_mat_chi_gamma_tau(bs_env, qs_env, bs_env%mat_chi_Gamma_tau)
151
152 ! χ_PQ(iτ,k=0) -> χ_PQ(iω=0,k=0) -> χ_PQ(iω=0,k) -> ε_PQ(iω=0,k) -> W_PQ(iω=0,k)
153 ! -> W^MIC_PQ(iω=0) -> M^-1*W^MIC(iω=0)*M^-1
154 CALL get_w_mic_freq_zero(bs_env, qs_env, bs_env%mat_chi_Gamma_tau, fm_w_mic_freq_zero)
155
156 ! Σ^c_λσ(iω=0,k=0) = 1/2 sum_n sgn(ϵ_n - ϵ_F) sum_νQ [sum_P (νσ|P) W^MIC_PQ(iω=0)]
157 ! [sum_µ (λµ|Q) C_µn C_νn]; written to the Σ^c(iω=0) restart file
158 CALL get_sigma_c(bs_env, qs_env, fm_w_mic_freq_zero, fm_sigma_c_gamma)
159
160 END IF
161
162 ! 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>
163 ! Σ^x_λσ(k=0) = sum_νQ [sum_P (νσ|P) V^trunc_PQ] [sum_µ (λµ|Q) D_µν)]
164 CALL get_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
165
166 ! Σ^c_λσ(k=0) -> Σ^c_nn(ϵ,k); ϵ_nk^GW = ϵ_nk^DFT + Σ^c_nn(ϵ,k) + Σ^x_nn(k) - v^xc_nn(k)
167 CALL compute_qp_energies(bs_env, qs_env, fm_sigma_x_gamma, fm_sigma_c_gamma)
168
169 CALL de_init_bs_env(qs_env, bs_env)
170
171 CALL timestop(handle)
172
174
175! **************************************************************************************************
176!> \brief Static screened Coulomb interaction at iω = 0:
177!> χ_PQ(iω=0,k=0) = sum_i w^0_i χ_PQ(iτ_i,k=0) (w^0: time weights at zero frequency)
178!> χ_PQ(iω=0,k=0) -> χ_PQ(iω=0,k) -> ε_PQ(iω=0,k) -> W_PQ(iω=0,k) -> W^MIC_PQ(iω=0)
179!> as for one frequency point of G0W0 (compute_fm_W_MIC_freq_j_from_chi); then the
180!> k-point extrapolation factor and M^-1(k=0) W^MIC(iω=0) M^-1(k=0)
181!> \param bs_env ...
182!> \param qs_env ...
183!> \param mat_chi_Gamma_tau ...
184!> \param fm_W_MIC_freq_zero ...
185! **************************************************************************************************
186 SUBROUTINE get_w_mic_freq_zero(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_MIC_freq_zero)
187 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
188 TYPE(qs_environment_type), POINTER :: qs_env
189 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: mat_chi_gamma_tau
190 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_w_mic_freq_zero
191
192 CHARACTER(LEN=*), PARAMETER :: routinen = 'get_W_MIC_freq_zero'
193
194 INTEGER :: handle, i_t, ikp, ikp_batch, ikp_in_batch
195 REAL(kind=dp) :: t1
196 TYPE(cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
197 TYPE(cp_cfm_type), ALLOCATABLE, DIMENSION(:) :: cfm_v_kp
198
199 CALL timeset(routinen, handle)
200
201 ! χ_PQ(iω=0,k=0) = sum_i w^0_i χ_PQ(iτ_i,k=0) -> bs_env%fm_chi_Gamma_freq
202 CALL dbcsr_set(bs_env%mat_RI_RI%matrix, 0.0_dp)
203 DO i_t = 1, bs_env%num_time_freq_points
204 CALL dbcsr_add(bs_env%mat_RI_RI%matrix, mat_chi_gamma_tau(i_t)%matrix, 1.0_dp, &
205 bs_env%time_frequency_grid%time_weights_at_zero_frequency(i_t))
206 END DO
207 CALL copy_dbcsr_to_fm(bs_env%mat_RI_RI%matrix, bs_env%fm_chi_Gamma_freq)
208 CALL dbcsr_deallocate_matrix_set(mat_chi_gamma_tau)
209
210 ALLOCATE (fm_w_mic_freq_zero(1))
211 CALL cp_fm_create(fm_w_mic_freq_zero(1), bs_env%fm_RI_RI%matrix_struct)
212 CALL cp_fm_set_all(fm_w_mic_freq_zero(1), 0.0_dp)
213
214 DO ikp_batch = 1, bs_env%num_chi_eps_W_batches
215
216 t1 = m_walltime()
217
218 ! V_PQ(k) = sum_R e^(ikR) <phi_P, cell 0 | 1/r | phi_Q, cell R>
219 CALL compute_v_k_by_lattice_sum(bs_env, qs_env, cfm_v_kp, ikp_batch)
220
221 DO ikp_in_batch = 1, bs_env%nkp_chi_eps_W_batch
222
223 ikp = (ikp_batch - 1)*bs_env%nkp_chi_eps_W_batch + ikp_in_batch
224
225 IF (ikp > bs_env%nkp_chi_eps_W_orig_plus_extra) cycle
226
227 CALL compute_minvvsqrt_vsqrt(bs_env, qs_env, cfm_v_kp, &
228 cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp, ikp)
229
230 CALL bs_env%para_env%sync()
231 CALL cp_cfm_release(cfm_v_kp(ikp))
232
233 ! W^MIC contribution of k-point ikp at iω = 0 (j_w = 1: first frequency point for the
234 ! approximate k-point extrapolation)
235 CALL compute_fm_w_mic_freq_j_from_chi(bs_env, qs_env, bs_env%fm_W_MIC_freq, 1, ikp, &
236 cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp)
237
238 CALL cp_fm_scale_and_add(1.0_dp, fm_w_mic_freq_zero(1), 1.0_dp, bs_env%fm_W_MIC_freq)
239
240 END DO ! ikp_in_batch
241
242 DEALLOCATE (cfm_v_kp)
243
244 IF (bs_env%unit_nr > 0) THEN
245 WRITE (bs_env%unit_nr, '(T2,A,I10,A,I3,A,F10.1,A)') &
246 'Computed W(iω=0,k) for k-point batch', &
247 ikp_batch, ' /', bs_env%num_chi_eps_W_batches, &
248 ', Execution time', m_walltime() - t1, ' s'
249 END IF
250
251 END DO ! ikp_batch
252
253 IF (bs_env%approx_kp_extrapol) THEN
254 CALL apply_extrapol_factor(bs_env, fm_w_mic_freq_zero)
255 END IF
256
257 ! M^-1(k=0) W^MIC(iω=0) M^-1(k=0)
258 CALL fm_contract_aba(bs_env%fm_Minv_Gamma, fm_w_mic_freq_zero(1))
259
260 CALL cp_cfm_release(cfm_m_inv_v_sqrt_ikp)
261 CALL cp_cfm_release(cfm_v_sqrt_ikp)
262
263 IF (bs_env%unit_nr > 0) WRITE (bs_env%unit_nr, '(A)') ' '
264
265 CALL timestop(handle)
266
267 END SUBROUTINE get_w_mic_freq_zero
268
269! **************************************************************************************************
270!> \brief Static COHSEX correlation self-energy at the Γ point in the AO basis,
271!> Σ^c_λσ = 1/2 sum_n sgn(ϵ_n - ϵ_F) sum_νQ [sum_P (νσ|P) W^MIC_PQ(iω=0)] [sum_µ (λµ|Q) C_µn C_νn]
272!> = 1/2 (Σ^neg_λσ(iτ=0) + Σ^pos_λσ(iτ=0)) with W = W^MIC(iω=0),
273!> i.e. the occupied and virtual self-energy parts of G0W0 at τ = 0 (compute_Sigma_c_occ_vir),
274!> symmetrized
275!> \param bs_env ...
276!> \param qs_env ...
277!> \param fm_W_MIC_freq_zero ...
278!> \param fm_Sigma_c_Gamma ...
279! **************************************************************************************************
280 SUBROUTINE get_sigma_c(bs_env, qs_env, fm_W_MIC_freq_zero, fm_Sigma_c_Gamma)
281 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
282 TYPE(qs_environment_type), POINTER :: qs_env
283 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_w_mic_freq_zero, fm_sigma_c_gamma
284
285 CHARACTER(LEN=*), PARAMETER :: routinen = 'get_Sigma_c'
286
287 INTEGER :: handle, ispin
288 REAL(kind=dp) :: t1
289 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: mat_sigma_neg, mat_sigma_pos
290 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_sigma_neg, &
291 t_2c_sigma_pos, t_2c_w, t_3c_x_w
292
293 CALL timeset(routinen, handle)
294
295 CALL create_mat_for_sigma_c(bs_env, t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg, &
296 t_2c_sigma_pos, t_3c_x_w, mat_sigma_neg, mat_sigma_pos)
297
298 ALLOCATE (fm_sigma_c_gamma(bs_env%n_spin))
299 DO ispin = 1, bs_env%n_spin
300
301 t1 = m_walltime()
302
303 ! Σ^neg(iτ=0) = -G^occ(0) W^MIC(iω=0), Σ^pos(iτ=0) = G^vir(0) W^MIC(iω=0)
304 CALL compute_sigma_c_occ_vir(bs_env, qs_env, 0.0_dp, ispin, fm_w_mic_freq_zero(1), &
305 t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg, &
306 t_2c_sigma_pos, t_3c_x_w, mat_sigma_neg(1, ispin)%matrix, &
307 mat_sigma_pos(1, ispin)%matrix, count_skipped=.false.)
308
309 ! Σ^c = 1/2 (Σ^neg + Σ^pos), symmetrized
310 CALL cp_fm_create(fm_sigma_c_gamma(ispin), bs_env%fm_s_Gamma%matrix_struct)
311 CALL copy_dbcsr_to_fm(mat_sigma_neg(1, ispin)%matrix, fm_sigma_c_gamma(ispin))
312 CALL copy_dbcsr_to_fm(mat_sigma_pos(1, ispin)%matrix, bs_env%fm_work_mo(1))
313 CALL cp_fm_scale_and_add(0.5_dp, fm_sigma_c_gamma(ispin), 0.5_dp, bs_env%fm_work_mo(1))
314 CALL cp_fm_transpose(fm_sigma_c_gamma(ispin), bs_env%fm_work_mo(1))
315 CALL cp_fm_scale_and_add(0.5_dp, fm_sigma_c_gamma(ispin), 0.5_dp, bs_env%fm_work_mo(1))
316
317 ! restart file of Σ^c(iω=0,k=0), one per spin
318 CALL fm_write(fm_sigma_c_gamma(ispin), ispin, bs_env%Sigma_c_freq_zero_name, qs_env)
319
320 IF (bs_env%unit_nr > 0) THEN
321 WRITE (bs_env%unit_nr, '(T2,A,T55,A,F10.1,A)') &
322 'Computed Σ^c(k=0),', ' Execution time', m_walltime() - t1, ' s'
323 END IF
324
325 END DO
326
327 IF (bs_env%unit_nr > 0) WRITE (bs_env%unit_nr, '(A)') ' '
328
329 CALL print_skipping(bs_env)
330
331 CALL destroy_mat_sigma_c(t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg, t_2c_sigma_pos, &
332 t_3c_x_w, fm_w_mic_freq_zero, mat_sigma_neg, mat_sigma_pos)
333
334 CALL delete_unnecessary_files(bs_env)
335
336 CALL timestop(handle)
337
338 END SUBROUTINE get_sigma_c
339
340! **************************************************************************************************
341!> \brief Read the static COHSEX restart file Σ^c_λσ(iω=0,k=0), one per spin
342!> \param bs_env ...
343!> \param fm_Sigma_c_Gamma Σ^c_λσ(iω=0,k=0) per spin, created here
344! **************************************************************************************************
345 SUBROUTINE read_sigma_c_freq_zero(bs_env, fm_Sigma_c_Gamma)
346 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
347 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_sigma_c_gamma
348
349 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_Sigma_c_freq_zero'
350
351 INTEGER :: handle, ispin
352 REAL(kind=dp) :: t1
353
354 CALL timeset(routinen, handle)
355
356 ALLOCATE (fm_sigma_c_gamma(bs_env%n_spin))
357 DO ispin = 1, bs_env%n_spin
358 t1 = m_walltime()
359 CALL cp_fm_create(fm_sigma_c_gamma(ispin), bs_env%fm_s_Gamma%matrix_struct)
360 CALL fm_read(fm_sigma_c_gamma(ispin), bs_env, bs_env%Sigma_c_freq_zero_name, ispin)
361 IF (bs_env%unit_nr > 0) THEN
362 WRITE (bs_env%unit_nr, '(T2,A,T55,A,F10.1,A)') &
363 'Read Σ^c(k=0) from file,', ' Execution time', m_walltime() - t1, ' s'
364 END IF
365 END DO
366
367 IF (bs_env%unit_nr > 0) WRITE (bs_env%unit_nr, '(A)') ' '
368
369 CALL timestop(handle)
370
371 END SUBROUTINE read_sigma_c_freq_zero
372
373! **************************************************************************************************
374!> \brief ...
375!> \param bs_env ...
376!> \param qs_env ...
377!> \param fm_Sigma_x_Gamma ...
378!> \param fm_Sigma_c_Gamma ...
379! **************************************************************************************************
380 SUBROUTINE compute_qp_energies(bs_env, qs_env, fm_Sigma_x_Gamma, fm_Sigma_c_Gamma)
381
382 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
383 TYPE(qs_environment_type), POINTER :: qs_env
384 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_sigma_x_gamma, fm_sigma_c_gamma
385
386 CHARACTER(LEN=*), PARAMETER :: routinen = 'compute_QP_energies'
387
388 INTEGER :: handle, ikp, ispin
389 TYPE(cp_cfm_type) :: cfm_ks_ikp, cfm_mos_ikp, cfm_s_ikp, &
390 cfm_work_ikp
391 TYPE(cp_fm_type) :: fm_sigma_c_ikp_mo, fm_sigma_x_ikp_mo, &
392 fm_v_xc_ikp_mo
393
394 CALL timeset(routinen, handle)
395
396 CALL cp_cfm_create(cfm_mos_ikp, bs_env%fm_s_Gamma%matrix_struct)
397 CALL cp_cfm_create(cfm_work_ikp, bs_env%fm_s_Gamma%matrix_struct)
398
399 ! MO-basis operator matrices at k_i (n_ao x n_ao), reused for every k-point
400 CALL cp_fm_create(fm_v_xc_ikp_mo, bs_env%fm_s_Gamma%matrix_struct)
401 CALL cp_fm_create(fm_sigma_x_ikp_mo, bs_env%fm_s_Gamma%matrix_struct)
402 CALL cp_fm_create(fm_sigma_c_ikp_mo, bs_env%fm_s_Gamma%matrix_struct)
403
404 DO ispin = 1, bs_env%n_spin
405
406 DO ikp = 1, bs_env%nkp_bs_and_DOS
407
408 ! 1. get H^KS_µν(k_i) from H^KS_µν(k=0)
409 CALL cfm_ikp_from_fm_gamma(cfm_ks_ikp, bs_env%fm_ks_Gamma(ispin), &
410 ikp, qs_env, bs_env%kpoints_DOS, "ORB")
411
412 ! 2. get S_µν(k_i) from S_µν(k=0)
413 CALL cfm_ikp_from_fm_gamma(cfm_s_ikp, bs_env%fm_s_Gamma, &
414 ikp, qs_env, bs_env%kpoints_DOS, "ORB")
415
416 ! 3. Diagonalize (Roothaan-Hall): H_KS(k_i)*C(k_i) = S(k_i)*C(k_i)*ϵ(k_i)
417 CALL cp_cfm_geeig(cfm_ks_ikp, cfm_s_ikp, cfm_mos_ikp, &
418 bs_env%eigenval_scf(:, ikp, ispin), cfm_work_ikp)
419
420 ! Reuse the KS buffer for the full MO operators. Retain their real parts
421 ! at the existing real COHSEX Hamiltonian boundary.
422 ! 4. V^xc_µν(k=0) -> V^xc_µν(k_i) -> V^xc_mn(k_i)
423 CALL cfm_ikp_from_fm_gamma(cfm_ks_ikp, bs_env%fm_V_xc_Gamma(ispin), &
424 ikp, qs_env, bs_env%kpoints_DOS, "ORB")
425 CALL cfm_contract_aba(cfm_mos_ikp, cfm_ks_ikp, workspace=cfm_work_ikp)
426 CALL cp_cfm_to_fm(cfm_ks_ikp, fm_v_xc_ikp_mo)
427
428 ! 5. Σ^x_µν(k=0) -> Σ^x_µν(k_i) -> Σ^x_mn(k_i)
429 CALL cfm_ikp_from_fm_gamma(cfm_ks_ikp, fm_sigma_x_gamma(ispin), &
430 ikp, qs_env, bs_env%kpoints_DOS, "ORB")
431 CALL cfm_contract_aba(cfm_mos_ikp, cfm_ks_ikp, workspace=cfm_work_ikp)
432 CALL cp_cfm_to_fm(cfm_ks_ikp, fm_sigma_x_ikp_mo)
433
434 ! 6. Σ^c_µν(k=0) -> Σ^c_µν(k_i) -> Σ^c_mn(k_i)
435 CALL cfm_ikp_from_fm_gamma(cfm_ks_ikp, fm_sigma_c_gamma(ispin), &
436 ikp, qs_env, bs_env%kpoints_DOS, "ORB")
437 CALL cfm_contract_aba(cfm_mos_ikp, cfm_ks_ikp, workspace=cfm_work_ikp)
438 CALL cp_cfm_to_fm(cfm_ks_ikp, fm_sigma_c_ikp_mo)
439
440 ! 7. build static COHSEX QP Hamiltonian, diagonalize, and print
441 CALL diagonalize_and_print(bs_env, qs_env, fm_sigma_x_ikp_mo, fm_v_xc_ikp_mo, &
442 fm_sigma_c_ikp_mo, ikp, ispin)
443
444 END DO ! ikp_DOS
445
446 END DO ! ispin
447
448 CALL get_all_vbm_cbm_bandgaps(bs_env)
449
450 CALL cp_fm_release(fm_sigma_x_gamma)
451 CALL cp_fm_release(fm_sigma_c_gamma)
452 CALL cp_fm_release(fm_v_xc_ikp_mo)
453 CALL cp_fm_release(fm_sigma_x_ikp_mo)
454 CALL cp_fm_release(fm_sigma_c_ikp_mo)
455 CALL cp_cfm_release(cfm_ks_ikp)
456 CALL cp_cfm_release(cfm_s_ikp)
457 CALL cp_cfm_release(cfm_mos_ikp)
458 CALL cp_cfm_release(cfm_work_ikp)
459
460 CALL timestop(handle)
461
462 END SUBROUTINE compute_qp_energies
463
464! **************************************************************************************************
465!> \brief Build the static COHSEX quasiparticle Hamiltonian H^QP at k-point ikp and print the
466!> diagonal energies ϵ^DG = H^QP_nn (COHSEX DIAGONAL); with COHSEX QP_UPDATE also
467!> diagonalize H^QP and print the canonical energies ϵ^CN and the canonical MOs
468!> \param bs_env ...
469!> \param qs_env ...
470!> \param fm_Sigma_x_ikp_mo ...
471!> \param fm_V_xc_ikp_mo ...
472!> \param fm_Sigma_c_ikp_mo ...
473!> \param ikp ...
474!> \param ispin ...
475! **************************************************************************************************
476 SUBROUTINE diagonalize_and_print(bs_env, qs_env, fm_Sigma_x_ikp_mo, fm_V_xc_ikp_mo, &
477 fm_Sigma_c_ikp_mo, ikp, ispin)
478
479 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
480 TYPE(qs_environment_type), POINTER :: qs_env
481 TYPE(cp_fm_type) :: fm_sigma_x_ikp_mo, fm_v_xc_ikp_mo, &
482 fm_sigma_c_ikp_mo
483 INTEGER :: ikp, ispin
484
485 CHARACTER(LEN=*), PARAMETER :: routinen = 'diagonalize_and_print'
486
487 CHARACTER(len=3) :: occ_vir
488 CHARACTER(len=default_string_length) :: fname
489 INTEGER :: handle, i_col, i_row, ikp_for_print, &
490 iunit, j_col, j_row, m, n_mo, &
491 ncol_local, nrow_local
492 INTEGER, DIMENSION(:), POINTER :: col_indices, row_indices
493 LOGICAL :: is_bandstruc_kpoint, print_dos_kpoints, &
494 print_ikp, qp_update
495 REAL(kind=dp) :: val
496 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: diag_sigma_c, diag_sigma_x, diag_sp, &
497 diag_v_xc, sp_eigval
498 TYPE(cp_fm_type) :: fm_sp_mat, sp_eigvec, sp_eigvec_ao
499
500 CALL timeset(routinen, handle)
501
502 n_mo = bs_env%n_ao
503 ! COHSEX QP_UPDATE: diagonalize H^QP (canonical energies and MOs); DIAGONAL: ϵ^DG only
504 qp_update = (bs_env%cohsex_flavor == cohsex_qp_update)
505
506 CALL cp_fm_create(fm_sp_mat, bs_env%fm_s_Gamma%matrix_struct)
507
508 ALLOCATE (sp_eigval(n_mo))
509 sp_eigval(:) = 0.0_dp
510
511 ! Build the static COHSEX QP Hamiltonian directly in the distributed fm by looping
512 ! over local elements only (global indices from row_indices/col_indices):
513 ! occ-occ block : Σ^x - v^xc + α Σ^c (α = COHSEX_SCALE_OCC)
514 ! vir-vir block : Σ^x - v^xc + α Σ^c (α = COHSEX_SCALE_VIRT)
515 ! occ-vir / vir-occ : 0, i.e. occupied and virtual states are not mixed
516 ! diagonal additionally gets + ϵ^DFT_nk
517 CALL cp_fm_get_info(fm_sp_mat, nrow_local=nrow_local, ncol_local=ncol_local, &
518 row_indices=row_indices, col_indices=col_indices)
519
520!$OMP PARALLEL DO COLLAPSE(2) DEFAULT(NONE) &
521!$OMP SHARED(ncol_local, nrow_local, col_indices, row_indices, bs_env, ispin, ikp, &
522!$OMP fm_Sigma_x_ikp_mo, fm_V_xc_ikp_mo, fm_Sigma_c_ikp_mo, fm_SP_mat) &
523!$OMP PRIVATE(i_col, i_row, j_col, j_row, val)
524 DO i_col = 1, ncol_local
525 DO i_row = 1, nrow_local
526 j_col = col_indices(i_col)
527 j_row = row_indices(i_row)
528 IF (j_row <= bs_env%n_occ(ispin) .AND. j_col <= bs_env%n_occ(ispin)) THEN
529 val = fm_sigma_x_ikp_mo%local_data(i_row, i_col) &
530 - fm_v_xc_ikp_mo%local_data(i_row, i_col) &
531 + bs_env%cohsex_scale_occ*fm_sigma_c_ikp_mo%local_data(i_row, i_col)
532 ELSE IF (j_row > bs_env%n_occ(ispin) .AND. j_col > bs_env%n_occ(ispin)) THEN
533 val = fm_sigma_x_ikp_mo%local_data(i_row, i_col) &
534 - fm_v_xc_ikp_mo%local_data(i_row, i_col) &
535 + bs_env%cohsex_scale_virt*fm_sigma_c_ikp_mo%local_data(i_row, i_col)
536 ELSE
537 val = 0.0_dp
538 END IF
539 IF (j_row == j_col) val = val + bs_env%eigenval_scf(j_row, ikp, ispin)
540 fm_sp_mat%local_data(i_row, i_col) = val
541 END DO
542 END DO
543!$OMP END PARALLEL DO
544
545 ! diagonal elements (for the per-MO QP printout) before diagonalization
546 ALLOCATE (diag_sp(n_mo), diag_sigma_c(n_mo), diag_sigma_x(n_mo), diag_v_xc(n_mo))
547 CALL cp_fm_get_diag(fm_sp_mat, diag_sp)
548 CALL cp_fm_get_diag(fm_sigma_c_ikp_mo, diag_sigma_c)
549 CALL cp_fm_get_diag(fm_sigma_x_ikp_mo, diag_sigma_x)
550 CALL cp_fm_get_diag(fm_v_xc_ikp_mo, diag_v_xc)
551
552 IF (qp_update) THEN
553 ! canonical static COHSEX: H^QP U = U ϵ^CN (the occ-virt blocks are zero)
554 CALL cp_fm_create(sp_eigvec, bs_env%fm_s_Gamma%matrix_struct)
555 CALL cp_fm_create(sp_eigvec_ao, bs_env%fm_s_Gamma%matrix_struct)
556 CALL cp_fm_syevx(matrix=fm_sp_mat, eigenvectors=sp_eigvec, eigenvalues=sp_eigval)
557 IF (ikp == bs_env%nkp_bs_and_DOS) THEN
558 CALL fm_write_formatted(sp_eigvec, 0, "Singlepole_Eigenvector_Gamma", qs_env)
559 END IF
560
561 ! transform QP eigenvectors from the KS-MO basis to the AO basis
562 CALL parallel_gemm(transa="N", transb="N", m=n_mo, n=n_mo, k=n_mo, alpha=1.0_dp, &
563 matrix_a=bs_env%fm_mo_coeff_Gamma(ispin), matrix_b=sp_eigvec, &
564 beta=0.0_dp, matrix_c=sp_eigvec_ao)
565 ELSE
566 ! diagonal static COHSEX: ϵ^DG = H^QP_nn, no diagonalization
567 sp_eigval(:) = diag_sp(:)
568 END IF
569
570 bs_env%eigenval_GW(:, ikp, ispin) = sp_eigval(:)
571 IF (ALLOCATED(bs_env%eigenval_G0W0)) THEN
572 bs_env%eigenval_G0W0(:, ikp, ispin) = sp_eigval(:)
573 END IF
574 DO m = 1, n_mo
575 bs_env%eigenval_HF(m, ikp, ispin) = bs_env%eigenval_scf(m, ikp, ispin) + &
576 diag_sigma_x(m) - diag_v_xc(m)
577 END DO
578
579 ! only print eigenvalues of DOS k-points in case no bandstructure path has been given;
580 ! in kpoints_DOS the last nkp_only_bs entries are the bandstructure-path k-points
581 print_dos_kpoints = (bs_env%nkp_only_bs <= 0)
582 is_bandstruc_kpoint = (ikp > bs_env%nkp_only_DOS)
583 print_ikp = print_dos_kpoints .OR. is_bandstruc_kpoint
584
585 !! Printing Quasiparticle energies to a file
586 IF (bs_env%para_env%is_source() .AND. print_ikp) THEN
587
588 IF (print_dos_kpoints) THEN
589 ikp_for_print = ikp
590 ELSE
591 ikp_for_print = ikp - bs_env%nkp_only_DOS
592 END IF
593
594 fname = "Quasiparticle_energies_singlepole"
595 IF (ikp_for_print == 1 .AND. ispin == 1) THEN
596 CALL open_file(trim(fname), unit_number=iunit, file_status="REPLACE", file_action="WRITE")
597 ELSE
598 CALL open_file(trim(fname), unit_number=iunit, file_status="OLD", file_action="WRITE", &
599 file_position="APPEND")
600 END IF
601
602 WRITE (iunit, "(A)") " "
603 WRITE (iunit, "(A10,I7,A25,3F10.4)") "kpoint: ", ikp_for_print, "coordinate: ", &
604 bs_env%kpoints_DOS%xkp(:, ikp)
605 WRITE (iunit, "(A)") " "
606 IF (qp_update) THEN
607 WRITE (iunit, "(A5,A24,2A17,A16,A18,A18)") "n", "ϵ_nk^DFT (eV)", "Σ^c_nk (eV)", &
608 "Σ^x_nk (eV)", "v_nk^xc (eV)", "ϵ_nk^DG (eV)", "ϵ_nk^CN (eV)"
609 ELSE
610 WRITE (iunit, "(A5,A24,2A17,A16,A18)") "n", "ϵ_nk^DFT (eV)", "Σ^c_nk (eV)", &
611 "Σ^x_nk (eV)", "v_nk^xc (eV)", "ϵ_nk^DG (eV)"
612 END IF
613 WRITE (iunit, "(A)") " "
614
615 DO m = 1, n_mo
616 IF (m <= bs_env%n_occ(ispin)) occ_vir = 'occ'
617 IF (m > bs_env%n_occ(ispin)) occ_vir = 'vir'
618 IF (qp_update) THEN
619 WRITE (iunit, "(I5,3A,4F16.3,F17.3,F17.3)") m, ' (', occ_vir, ') ', &
620 bs_env%eigenval_scf(m, ikp, ispin)*evolt, &
621 diag_sigma_c(m)*evolt, &
622 diag_sigma_x(m)*evolt, &
623 diag_v_xc(m)*evolt, &
624 diag_sp(m)*evolt, &
625 sp_eigval(m)*evolt
626 ELSE
627 WRITE (iunit, "(I5,3A,4F16.3,F17.3)") m, ' (', occ_vir, ') ', &
628 bs_env%eigenval_scf(m, ikp, ispin)*evolt, &
629 diag_sigma_c(m)*evolt, &
630 diag_sigma_x(m)*evolt, &
631 diag_v_xc(m)*evolt, &
632 diag_sp(m)*evolt
633 END IF
634 END DO
635
636 WRITE (iunit, "(A)") " "
637
638 CALL close_file(iunit)
639 END IF
640
641 IF (qp_update) THEN
642 ! canonical MO energies/coefficients and MO cubes (DFT%PRINT%MO, DFT%PRINT%MO_CUBES),
643 ! Gamma point only
644 IF (ikp == 1) THEN
645 CALL print_static_cohsex_mos(bs_env, qs_env, sp_eigvec_ao, sp_eigval, ispin)
646 END IF
647 CALL cp_fm_release(sp_eigvec)
648 CALL cp_fm_release(sp_eigvec_ao)
649 END IF
650
651 CALL cp_fm_release(fm_sp_mat)
652 DEALLOCATE (sp_eigval, diag_sp, diag_sigma_c, diag_sigma_x, diag_v_xc)
653
654 CALL timestop(handle)
655
656 END SUBROUTINE diagonalize_and_print
657
658! **************************************************************************************************
659!> \brief Print static COHSEX QP MO energies/occupations/coefficients and MO cubes at the Gamma point,
660!> reusing the standard DFT%PRINT%MO / DFT%PRINT%MO_CUBES print keys.
661!> \param bs_env ...
662!> \param qs_env ...
663!> \param fm_qp_mo_ao ...
664!> \param qp_eigval ...
665!> \param ispin ...
666! **************************************************************************************************
667 SUBROUTINE print_static_cohsex_mos(bs_env, qs_env, fm_qp_mo_ao, qp_eigval, ispin)
668 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
669 TYPE(qs_environment_type), POINTER :: qs_env
670 TYPE(cp_fm_type) :: fm_qp_mo_ao
671 REAL(kind=dp), DIMENSION(:) :: qp_eigval
672 INTEGER :: ispin
673
674 CHARACTER(LEN=*), PARAMETER :: routinen = 'print_static_cohsex_mos'
675
676 CHARACTER(LEN=5) :: spin_label
677 CHARACTER(LEN=default_path_length) :: fname, title
678 INTEGER :: first_mo, handle, ivector, last_mo, &
679 n_mo, nelectron, nhomo, nlumo, unit_nr
680 INTEGER, DIMENSION(:), POINTER :: stride
681 LOGICAL :: print_coeff, print_cubes, &
682 print_energies, print_mo, print_occ
683 REAL(kind=dp) :: maxocc
684 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
685 TYPE(cell_type), POINTER :: cell
686 TYPE(cp_logger_type), POINTER :: logger
687 TYPE(dft_control_type), POINTER :: dft_control
688 TYPE(mo_set_type) :: qp_mo_set
689 TYPE(particle_list_type), POINTER :: particles
690 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
691 TYPE(pw_c1d_gs_type) :: wf_g
692 TYPE(pw_env_type), POINTER :: pw_env
693 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
694 TYPE(pw_r3d_rs_type) :: wf_r
695 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
696 TYPE(qs_subsys_type), POINTER :: subsys
697 TYPE(section_vals_type), POINTER :: dft_section, input
698
699 CALL timeset(routinen, handle)
700
701 n_mo = bs_env%n_ao
702
703 CALL get_qs_env(qs_env, input=input)
704 dft_section => section_vals_get_subs_vals(input, "DFT")
705 logger => cp_get_default_logger()
706
707 ! ---------------------------------------------------------------------------------------
708 ! MO energies / occupation numbers / coefficients
709 ! ---------------------------------------------------------------------------------------
710 CALL section_vals_val_get(dft_section, "PRINT%MO%ENERGIES", l_val=print_energies)
711 CALL section_vals_val_get(dft_section, "PRINT%MO%COEFFICIENTS", l_val=print_coeff)
712 CALL section_vals_val_get(dft_section, "PRINT%MO%OCCUPATION_NUMBERS", l_val=print_occ)
713 print_mo = (cp_print_key_should_output(logger%iter_info, dft_section, "PRINT%MO") /= 0)
714
715 IF (print_mo .AND. (print_energies .OR. print_occ .OR. print_coeff)) THEN
716
717 ! occupation numbers of the QP states: the lowest n_occ are occupied
718 IF (bs_env%n_spin == 1) THEN
719 maxocc = 2.0_dp
720 ELSE
721 maxocc = 1.0_dp
722 END IF
723 nelectron = nint(maxocc*real(bs_env%n_occ(ispin), kind=dp))
724
725 CALL allocate_mo_set(qp_mo_set, nao=n_mo, nmo=n_mo, nelectron=nelectron, &
726 n_el_f=real(nelectron, kind=dp), maxocc=maxocc, &
727 flexible_electron_count=0.0_dp)
728 CALL init_mo_set(qp_mo_set, fm_struct=fm_qp_mo_ao%matrix_struct, name="static_cohsex")
729 qp_mo_set%eigenvalues(:) = qp_eigval(:)
730 CALL cp_fm_to_fm(fm_qp_mo_ao, qp_mo_set%mo_coeff)
731
732 CALL get_qs_env(qs_env, particle_set=particle_set, qs_kind_set=qs_kind_set)
733
734 IF (bs_env%n_spin == 1) THEN
735 CALL write_mo_set_to_output_unit(qp_mo_set, qs_kind_set, particle_set, dft_section, &
736 4, 0, final_mos=.true.)
737 ELSE
738 IF (ispin == 1) THEN
739 spin_label = "ALPHA"
740 ELSE
741 spin_label = "BETA"
742 END IF
743 CALL write_mo_set_to_output_unit(qp_mo_set, qs_kind_set, particle_set, dft_section, &
744 4, 0, final_mos=.true., spin=trim(spin_label))
745 END IF
746
747 CALL deallocate_mo_set(qp_mo_set)
748 END IF
749
750 ! ---------------------------------------------------------------------------------------
751 ! MO cubes
752 ! ---------------------------------------------------------------------------------------
753 print_cubes = (cp_print_key_should_output(logger%iter_info, dft_section, "PRINT%MO_CUBES") /= 0)
754
755 IF (print_cubes) THEN
756 CALL section_vals_val_get(dft_section, "PRINT%MO_CUBES%NHOMO", i_val=nhomo)
757 CALL section_vals_val_get(dft_section, "PRINT%MO_CUBES%NLUMO", i_val=nlumo)
758 CALL section_vals_val_get(dft_section, "PRINT%MO_CUBES%STRIDE", i_vals=stride)
759
760 IF (nhomo == -1) nhomo = bs_env%n_occ(ispin)
761 IF (nlumo == -1) nlumo = n_mo - bs_env%n_occ(ispin)
762 first_mo = max(1, bs_env%n_occ(ispin) - nhomo + 1)
763 last_mo = min(n_mo, bs_env%n_occ(ispin) + nlumo)
764
765 CALL get_qs_env(qs_env, &
766 atomic_kind_set=atomic_kind_set, &
767 qs_kind_set=qs_kind_set, &
768 cell=cell, &
769 dft_control=dft_control, &
770 particle_set=particle_set, &
771 pw_env=pw_env, &
772 subsys=subsys)
773 CALL qs_subsys_get(subsys, particles=particles)
774
775 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
776 CALL auxbas_pw_pool%create_pw(wf_r)
777 CALL auxbas_pw_pool%create_pw(wf_g)
778
779 DO ivector = first_mo, last_mo
780 CALL calculate_wavefunction(fm_qp_mo_ao, ivector, wf_r, wf_g, atomic_kind_set, &
781 qs_kind_set, cell, dft_control, particle_set, pw_env)
782
783 WRITE (fname, '(A,I5.5,A,I1)') "static_cohsex_WFN_", ivector, "_", ispin
784 unit_nr = cp_print_key_unit_nr(logger, dft_section, "PRINT%MO_CUBES", &
785 extension=".cube", middle_name=trim(fname), &
786 file_position="REWIND", log_filename=.false.)
787 WRITE (title, *) "static COHSEX WAVEFUNCTION ", ivector, " spin ", ispin, &
788 " i.e. HOMO ", ivector - bs_env%n_occ(ispin)
789 CALL cp_pw_to_cube(wf_r, unit_nr, title, particles, stride=stride)
790 CALL cp_print_key_finished_output(unit_nr, logger, dft_section, "PRINT%MO_CUBES")
791 END DO
792
793 CALL auxbas_pw_pool%give_back_pw(wf_r)
794 CALL auxbas_pw_pool%give_back_pw(wf_g)
795 END IF
796
797 CALL timestop(handle)
798
799 END SUBROUTINE print_static_cohsex_mos
800
801! **************************************************************************************************
802!> \brief ...
803!> \param fm ...
804!> \param matrix_index ...
805!> \param matrix_name ...
806!> \param qs_env ...
807! **************************************************************************************************
808 SUBROUTINE fm_write_formatted(fm, matrix_index, matrix_name, qs_env)
809 TYPE(cp_fm_type) :: fm
810 INTEGER :: matrix_index
811 CHARACTER(LEN=*) :: matrix_name
812 TYPE(qs_environment_type), POINTER :: qs_env
813
814 CHARACTER(LEN=*), PARAMETER :: key = 'PROPERTIES%BANDSTRUCTURE%GW%PRINT%RESTART', &
815 routinen = 'fm_write_formatted'
816
817 CHARACTER(LEN=default_string_length) :: filename
818 INTEGER :: handle, unit_nr
819 TYPE(cp_logger_type), POINTER :: logger
820 TYPE(section_vals_type), POINTER :: input
821
822 CALL timeset(routinen, handle)
823
824 CALL get_qs_env(qs_env, input=input)
825
826 logger => cp_get_default_logger()
827
828 IF (btest(cp_print_key_should_output(logger%iter_info, input, key), cp_p_file)) THEN
829
830 IF (matrix_index < 10) THEN
831 WRITE (filename, '(3A,I1)') "RESTART_", matrix_name, "_0", matrix_index
832 ELSE IF (matrix_index < 100) THEN
833 WRITE (filename, '(3A,I2)') "RESTART_", matrix_name, "_", matrix_index
834 ELSE
835 cpabort('Please implement more than 99 time/frequency points.')
836 END IF
837
838 unit_nr = cp_print_key_unit_nr(logger, input, key, extension=".matrix", &
839 file_form="FORMATTED", middle_name=trim(filename), &
840 file_position="REWIND", file_action="WRITE")
841
842 CALL cp_fm_write_formatted(fm, unit_nr)
843 IF (unit_nr > 0) THEN
844 CALL close_file(unit_nr)
845 END IF
846 END IF
847
848 CALL timestop(handle)
849
850 END SUBROUTINE fm_write_formatted
851
Define the atomic kind types and their sub types.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public tyagi2024
integer, save, public hedin1965
integer, save, public hybertsen1986
integer, save, public tyagi2026
Handles all functions related to the CELL.
Definition cell_types.F:15
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 cp_cfm_to_fm(msource, mtargetr, mtargeti)
Copy real and imaginary parts of a complex full matrix into separate real-value full matrices.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan, check_plan)
Copy a DBCSR matrix to a BLACS matrix.
Utility routines to open and close files.
Definition cp_files.F:22
subroutine, public open_file(file_name, unit_number, file_status, file_form, file_action, file_position, file_pad, file_access, debug)
Opens a file and returns its logical unit number.
Definition cp_files.F:197
subroutine, public close_file(unit_number, file_status)
Closes an open file given by its logical unit number.
Definition cp_files.F:64
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_transpose(matrix, matrixt)
transposes a matrix matrixt = matrix ^ T
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
Definition cp_fm_diag.F:17
subroutine, public cp_fm_syevx(matrix, eigenvectors, eigenvalues, neig, work_syevx)
compute eigenvalues and optionally eigenvectors of a real symmetric matrix using scalapack....
Definition cp_fm_diag.F:814
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_get_diag(matrix, diag, n_active)
returns the diagonal elements of a fm
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_write_formatted(fm, unit, header, value_format)
Write out a full matrix in plain text.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
A wrapper around pw_to_cube() which accepts particle_list_type.
subroutine, public cp_pw_to_cube(pw, unit_nr, title, particles, zeff, stride, max_file_size_mb, zero_tails, silent, mpi_io)
...
This is the start of a dbt_api, all publically needed functions are exported here....
Definition dbt_api.F:17
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 compute_minvvsqrt_vsqrt(bs_env, qs_env, cfm_v_kp, cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp, ikp)
...
subroutine, public compute_fm_w_mic_freq_j_from_chi(bs_env, qs_env, fm_w_mic_freq_j, j_w, ikp, cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp)
W_PQ^MIC(iω_j) from χ_PQ(iω_j,k=0) in bs_envfm_chi_Gamma_freq.
subroutine, public fm_read(fm, bs_env, mat_name, idx)
...
subroutine, public compute_v_k_by_lattice_sum(bs_env, qs_env, cfm_v_kp, ikp_batch)
...
subroutine, public apply_extrapol_factor(bs_env, fm_w_mic_time)
...
Static COHSEX band structure in the tensor-based large-cell Gamma GW code: COHSEX DIAGONAL (diagonal ...
subroutine, public gw_calc_tensor_large_cell_gamma_static_cohsex(qs_env, bs_env)
Perform static COHSEX band structure calculation.
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 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:3330
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public cohsex_qp_update
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
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
basic linear algebra operations for full matrixes
represent a simple array based list of the given type
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public evolt
Definition physcon.F:183
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)
...
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_wavefunction(mo_vectors, ivector, rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env, basis_type)
maps a given wavefunction on the grid
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.
Define the quickstep kind type and their sub types.
Definition and initialisation of the mo data type.
Definition qs_mo_io.F:21
subroutine, public write_mo_set_to_output_unit(mo_set, qs_kind_set, particle_set, dft_section, before, kpoint, final_mos, spin, solver_method, rtp, cpart, sim_step, umo_set, qs_env, para_env_inter_kp)
Write MO information to output file (eigenvalues, occupation numbers, coefficients).
Definition qs_mo_io.F:1027
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public init_mo_set(mo_set, fm_pool, fm_ref, fm_struct, name, counter, complex_coeff)
initializes an allocated mo_set. eigenvalues, mo_coeff, occupation_numbers are valid only after this ...
subroutine, public allocate_mo_set(mo_set, nao, nmo, nelectron, n_el_f, maxocc, flexible_electron_count)
Allocates a mo set and partially initializes it (nao,nmo,nelectron, and flexible_electron_count are v...
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
types that represent a quickstep subsys
subroutine, public qs_subsys_get(subsys, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
Represent a complex full matrix.
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.