(git:3d5d2e5)
Loading...
Searching...
No Matches
post_scf_bandstructure_types.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
10!> \author Jan Wilhelm
11!> \date 07.2023
12! **************************************************************************************************
15 USE cp_cfm_types, ONLY: cp_cfm_release,&
17 USE cp_dbcsr_api, ONLY: dbcsr_p_type,&
22 USE cp_fm_types, ONLY: cp_fm_release,&
24 USE dbt_api, ONLY: dbt_destroy,&
25 dbt_type
30 USE hfx_types, ONLY: dealloc_containers,&
32 USE input_constants, ONLY: g0w0,&
37 USE kinds, ONLY: default_path_length,&
39 dp,&
40 int_4,&
41 int_8
42 USE kpoint_types, ONLY: kpoint_release,&
46 USE physcon, ONLY: evolt
48 USE ri_rs_types, ONLY: ri_rs_env,&
52#include "./base/base_uses.f90"
53
54 IMPLICIT NONE
55
56 PRIVATE
57
58 CHARACTER(LEN=*), PARAMETER, PRIVATE :: moduleN = 'post_scf_bandstructure_types'
59
62
63 ! valence band maximum (VBM), conduction band minimum (CBM), direct band gap (DBG),
64 ! indirect band gap (IDBG)
66 REAL(kind=dp) :: vbm = -1.0_dp, &
67 cbm = -1.0_dp, &
68 dbg = -1.0_dp, &
69 idbg = -1.0_dp, &
70 e_fermi = -1.0_dp
71 END TYPE band_edges_type
72
73 ! 3-center integrals of one set of atom ranges (RI, AO_1, AO_2; zero: all atoms), compressed
74 ! (blk_indices, compressed) or as a tensor (t_3c)
75 TYPE store_3c_set_type
76 INTEGER, DIMENSION(2, 3) :: atoms = 0
77 INTEGER, DIMENSION(:, :), ALLOCATABLE :: blk_indices
78 TYPE(hfx_compression_type) :: compressed
79 TYPE(dbt_type) :: t_3c
80 END TYPE store_3c_set_type
81
82 ! 3-center integrals kept for the time points of a phase (in use if sets is allocated), all
83 ! sets uncompressed or all compressed; memory is the size on this process [MiB]
85 INTEGER :: nsets = 0
86 LOGICAL :: uncompressed = .false.
87 REAL(kind=dp) :: memory = 0.0_dp
88 TYPE(store_3c_set_type), DIMENSION(:), ALLOCATABLE :: sets
89 END TYPE store_3c_type
90
92
93 ! decide which calculations will be done
94 LOGICAL :: do_gw = .false., &
95 do_soc = .false., &
96 do_ldos = .false., &
97 do_gw_ri_rs = .false., &
98 do_dos_pdos = .false., &
99 do_floquet = .false., &
100 do_static_cohsex = .false., &
101 do_spin_texture = .false.
102
103 ! various eigenvalues computed in GW code, some depend on k-points
104 ! and have therefore three dimensions (band index, k-point, spin)
105 !
106 ! eigenval_GW carries the quasiparticle energies of the highest-level GW flavour requested
107 ! eigenval_G0W0 - the G0W0 result
108 ! eigenval_evGW0 - the evGW0 result
109 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: eigenval_scf_gamma
110 REAL(kind=dp), DIMENSION(:, :, :), ALLOCATABLE :: eigenval_scf, &
111 eigenval_gw, &
112 eigenval_g0w0, &
113 eigenval_evgw0, &
114 eigenval_hf
115 ! the Nevanlinna marks (band, k-point, spin) of eigenval_GW, printed as * and m beside it;
116 ! gw_marks_assessed stays false where no level was assessed (Pade, COHSEX)
117 LOGICAL, DIMENSION(:, :, :), ALLOCATABLE :: gw_multi_solution, &
118 gw_unreliable
119 LOGICAL :: gw_marks_assessed = .false.
120 TYPE(band_edges_type) :: band_edges_scf = band_edges_type(), &
121 band_edges_gw = band_edges_type(), &
122 band_edges_hf = band_edges_type()
123
124 ! parameters that influence the GW flavor
125 LOGICAL :: do_hedin_shift = .false.
126 ! which GW flavour was requested; constants from input_constants (G0W0, evGW0, ...)
127 INTEGER :: gw_flavour = g0w0
128
129 ! parameters for static COHSEX approximation to GW
130 ! static COHSEX: OFF, DIAGONAL (ϵ^DG only) or QP_UPDATE (also diagonalization, ϵ^CN, MOs)
131 INTEGER :: cohsex_flavor = cohsex_off
132 REAL(kind=dp) :: cohsex_scale_occ = 1.0_dp, &
133 cohsex_scale_virt = 1.0_dp
134
135 ! parameters for RI-RS implementation of GW
136 TYPE(ri_rs_env) :: ri_rs
137
138 ! Work data of periodic RI-RS GW with full k-point sampling
139 TYPE(gwkp_type), ALLOCATABLE :: gwkp_env
140
141 ! Eigenvalue self-consistency settings
142 INTEGER :: evgw0_n_iter = 1
143 REAL(kind=dp) :: evgw0_eps_iter = 5.0e-5_dp
144
145 ! Parameters for automatic RI basis set optimization.
146 TYPE(auto_ri_type) :: auto_ri = auto_ri_type()
147
148 ! DBCSR stores each rank's matrix panel in one MPI message whose length is stored in a
149 ! 32-bit default INTEGER (dbcsr_mpiwrap.F: msglen = SIZE(buffer)). Exceeding this ceiling
150 ! overflows the count to a negative/garbage value and multiply_cannon segfaults. This is
151 ! that hard limit in elements (= HUGE(int_4) = 2^31-1), the same bound DBCSR uses
152 ! internally as mp_max_memory_size. Panel sizing keeps every per-rank message below it.
153 INTEGER(KIND=int_8) :: dbcsr_msg_elem_limit = &
154 int(huge(0_int_4), int_8)
155
156 ! general parameters on molecular orbitals and basis sets
157 ! Number of real states; entries above it are linear-dependency placeholders, not states.
158 INTEGER :: n_mo_retained = -1
159 INTEGER :: n_ao = -1, &
160 n_ri = -1, &
161 n_spin = -1, &
162 n_atom = -1, &
163 max_ao_bf_per_atom = -1
164 INTEGER, DIMENSION(:), ALLOCATABLE :: i_ao_start_from_atom, &
165 i_ao_end_from_atom, &
166 i_ri_start_from_atom, &
167 i_ri_end_from_atom
168 INTEGER, DIMENSION(:, :), ALLOCATABLE :: min_ri_idx_from_ao_ao_atom, &
169 max_ri_idx_from_ao_ao_atom, &
170 min_ao_idx_from_ri_ao_atom, &
171 max_ao_idx_from_ri_ao_atom
172 INTEGER, DIMENSION(2) :: n_occ = -1, &
173 n_vir = -1
174 INTEGER, DIMENSION(2) :: n_electron = -1
175 LOGICAL :: do_smear = .false.
176 INTEGER :: smear_method = -1
177 REAL(kind=dp) :: smear_width = 0.0_dp
178 REAL(kind=dp) :: fixed_mag_mom = -1.0_dp
179 REAL(kind=dp) :: spin_degeneracy = -1.0_dp
180 REAL(kind=dp), DIMENSION(2) :: e_fermi = -1.0_dp
181
182 ! kpoint mesh for chi, eps, W
183 INTEGER, DIMENSION(:), POINTER :: nkp_grid_dos_input => null(), &
184 nkp_grid_chi_eps_w_input => null()
185 INTEGER, DIMENSION(3) :: nkp_grid_chi_eps_w_orig = -1, &
186 nkp_grid_chi_eps_w_extra = -1
187 INTEGER :: nkp_chi_eps_w_orig = -1, &
188 nkp_chi_eps_w_orig_plus_extra = -1, &
189 nkp_chi_eps_w_batch = -1, &
190 num_chi_eps_w_batches = -1, &
191 size_lattice_sum_v = -1
192 TYPE(kpoint_type), POINTER :: kpoints_chi_eps_w => null(), &
193 kpoints_dos => null()
194 LOGICAL :: approx_kp_extrapol = .false.
195
196 REAL(kind=dp) :: wkp_orig = -1.0_dp
197 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: wkp_s_p, &
198 wkp_no_extra
199 INTEGER, DIMENSION(:), ALLOCATABLE :: l_ri
200 INTEGER :: input_kp_bs_npoints = -1, &
201 input_kp_bs_n_sp_pts = -1, &
202 nkp_bs_and_dos = -1, &
203 nkp_only_bs = -1, &
204 nkp_only_dos = -1
205 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: xkp_special
206
207 ! parameters for GW band structure calculation with k-points
208 INTEGER :: gw_implementation = -1, &
209 nimages_scf = -1
210 INTEGER, DIMENSION(3) :: periodic = -1
211 LOGICAL :: do_periodic = .false.
212 REAL(kind=dp), DIMENSION(3, 3) :: hmat = -1.0_dp
213
214 ! imaginary time and frequency grids
215 INTEGER :: num_time_freq_points = -1, &
216 num_freq_points_fit = -1, &
217 num_freq_points_pade = -1
218 TYPE(time_frequency_grid_type) :: time_frequency_grid
219 ! same grid points; weights of the transform Σ^c(iτ) -> Σ^c(iω), which for NEVANLINNA are
220 ! fitted by a truncated SVD; χ and W always use time_frequency_grid
221 TYPE(time_frequency_grid_type) :: time_frequency_grid_sigma
222 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: imag_freq_points_fit
223 INTEGER :: nparam_pade = -1, &
224 num_points_per_magnitude = -1
225 REAL(kind=dp) :: freq_max_fit = -1.0_dp, &
226 input_regularization_minimax = -1.0_dp, &
227 regularization_minimax = -1.0_dp, &
228 stabilize_exp = -1.0_dp
229
230 ! analytic continuation of Σ^c(iω): Padé or Nevanlinna, with the parameters of the latter
231 INTEGER :: ac_method = gw_ac_nevanlinna
232 TYPE(gw_nevanlinna_env_type) :: nevanlinna
233
234 ! filter threshold for matrix-tensor operations
235 REAL(kind=dp) :: eps_filter = -1.0_dp, &
236 eps_atom_grid_2d_mat = -1.0_dp
237
238 ! threshold for inverting ao overlap matrix, RI cfm_1d
239 REAL(kind=dp) :: eps_eigval_mat_s = -1.0_dp, &
240 eps_eigval_mat_ri = -1.0_dp, &
241 input_regularization_ri = -1.0_dp, &
242 regularization_ri = -1.0_dp
243 ! metric_pinv: periodic Gamma-only RI-RS GW inverts the RI metric M(0) as a pseudo-inverse
244 ! with relative eigenvalue cut regularization_RI (no Tikhonov shift); see compute_Minv_Gamma
245 LOGICAL :: metric_pinv = .false.
246
247 ! global full cfm_1d used in GW
248 TYPE(cp_fm_type) :: fm_s_gamma = cp_fm_type(), &
249 fm_gocc = cp_fm_type(), &
250 fm_gvir = cp_fm_type()
251 TYPE(cp_fm_type), DIMENSION(2) :: fm_ks_gamma = cp_fm_type(), &
252 fm_v_xc_gamma = cp_fm_type(), &
253 fm_mo_coeff_gamma = cp_fm_type()
254 TYPE(cp_fm_type), DIMENSION(4) :: fm_work_mo = cp_fm_type()
255 TYPE(cp_fm_type) :: fm_ri_ri = cp_fm_type(), &
256 fm_minv_gamma = cp_fm_type(), &
257 fm_chi_gamma_freq = cp_fm_type(), &
258 fm_w_mic_freq = cp_fm_type(), &
259 fm_w_mic_freq_1_extra = cp_fm_type(), &
260 fm_w_mic_freq_1_no_extra = cp_fm_type(), &
261 fm_w_mic_freq_zero = cp_fm_type()
262 TYPE(cp_cfm_type) :: cfm_work_mo = cp_cfm_type(), &
263 cfm_work_mo_2 = cp_cfm_type()
264 ! layout of the dense n_RI x n_RI matrices, kept for use after fm_RI_RI is released
265 TYPE(cp_fm_struct_type), POINTER :: fm_struct_ri_ri => null()
266
267 ! global dbcsr cfm_1d used in GW
268 TYPE(dbcsr_p_type) :: mat_ao_ao = dbcsr_p_type(), &
269 mat_ri_ri = dbcsr_p_type()
270 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: mat_chi_gamma_tau => null()
271
272 ! local dbcsr cfm_1d used in GW (local in tensor group)
273 TYPE(dbcsr_p_type) :: mat_ao_ao_tensor = dbcsr_p_type(), &
274 mat_ri_ri_tensor = dbcsr_p_type()
275
276 ! tensors for sparse matrix-tensor operations
277#if defined(FTN_NO_DEFAULT_INIT)
278 TYPE(dbt_type) :: t_g, &
279 t_chi, &
280 t_w, &
281 t_ri_ao__ao, &
282 t_ri__ao_ao
283#else
284 TYPE(dbt_type) :: t_g = dbt_type(), &
285 t_chi = dbt_type(), &
286 t_w = dbt_type(), &
287 t_ri_ao__ao = dbt_type(), &
288 t_ri__ao_ao = dbt_type()
289#endif
290
291 ! parameters and data for parallelization
292 INTEGER :: group_size_tensor = -1, &
293 tensor_group_color = -1, &
294 num_tensor_groups = -1
295 REAL(kind=dp) :: input_memory_per_proc_gb = -1.0_dp
296 LOGICAL :: auto_memory_per_proc = .false.
297 TYPE(mp_para_env_type), POINTER :: para_env => null(), &
298 para_env_tensor => null()
299 REAL(kind=dp) :: occupation_3c_int = -1.0_dp, &
300 max_dist_ao_atoms = -1.0_dp, &
301 safety_factor_memory = -1.0_dp
302
303 ! parallelization: atom range i and atom range j for tensor group
304 INTEGER, DIMENSION(2) :: atoms_i = -1, &
305 atoms_j = -1
306 INTEGER :: n_atom_i = -1, &
307 n_intervals_i = -1, &
308 n_atom_j = -1, &
309 n_intervals_j = -1, &
310 n_intervals_inner_loop_atoms = -1, &
311 n_skip_sigma = -1, &
312 n_skip_chi = -1
313 INTEGER, DIMENSION(:, :), ALLOCATABLE :: i_atom_intervals, &
314 j_atom_intervals, &
315 inner_loop_atom_intervals, &
316 atoms_i_t_group, &
317 atoms_j_t_group
318 LOGICAL, DIMENSION(:, :), ALLOCATABLE :: skip_sigma_occ, &
319 skip_sigma_vir, &
320 skip_chi
321 ! 3-center integrals kept for χ, and for Σ^x and Σ^c (W and G side)
322 TYPE(store_3c_type) :: store_3c_chi, &
323 store_3c_w, &
324 store_3c_sigma
325 ! rtbse_method (Stepan Marek)
326 INTEGER :: rtp_method = -1
327 ! what PROPERTIES%BSE needs the GW to keep for it; set at init, read at the W(0) and de-init
328 ! sites; the consumer frees both itself once read
329 LOGICAL :: keep_w_freq_zero = .false., &
330 keep_3c_nl = .false.
331
332 ! check-arrays and names for restarting
333 LOGICAL, DIMENSION(:), ALLOCATABLE :: read_chi, &
334 calc_chi
335 LOGICAL, DIMENSION(:, :), ALLOCATABLE :: sigma_c_exists
336 LOGICAL :: all_w_exist = .false., &
337 sigma_x_exists = .false., &
338 sigma_c_freq_zero_exists = .false.
339 CHARACTER(LEN=3) :: chi_name = "chi"
340 CHARACTER(LEN=6) :: w_time_name = "W_time"
341 CHARACTER(LEN=7) :: sigma_x_name = "Sigma_x"
342 CHARACTER(LEN=17) :: sigma_c_freq_zero_name = "Sigma_c_freq_zero"
343 CHARACTER(LEN=13) :: sigma_p_name = "Sigma_pos_tau", &
344 sigma_n_name = "Sigma_neg_tau"
345 CHARACTER(LEN=default_path_length) :: prefix = ""
346 INTEGER :: unit_nr = -1
347
348 ! parameters and data for basis sets
350 DIMENSION(:), ALLOCATABLE :: basis_set_ao, &
351 basis_set_ri
352 INTEGER, DIMENSION(:), ALLOCATABLE :: sizes_ao, &
353 sizes_ri
356 trunc_coulomb = coulomb_operator_type()
357
358 ! parameters for SOC calculation
359 REAL(kind=dp) :: soc_window_occ = -1.0_dp
360 REAL(kind=dp) :: soc_window_virt = -1.0_dp
361 REAL(kind=dp) :: soc_window_smearing = 1.0_dp/evolt
362 REAL(kind=dp) :: soc_diag_occ = -1.0_dp
363 REAL(kind=dp) :: soc_diag_virt = -1.0_dp
364 ! spin texture: atoms for the layer-projected spin (SPIN_TEXTURE_ATOMS) and, after each
365 ! call of SOC_ev, the spinor-state index (in eigenval_spinor) of every column of the
366 ! spinor wavefunction matrix that holds a valid eigenvector (all 2*n_ao columns for the
367 ! untruncated SOC, the window columns for SOC_DIAG_OCC/VIRT)
368 INTEGER, DIMENSION(:), ALLOCATABLE :: spin_texture_atoms, &
369 soc_wf_state_index
370
371 ! sizes: mat_V_SOC_xyz: xyz, img
372 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: mat_v_soc_xyz => null()
373 ! small-cell GW: dimension = number of kpoints; large-cell GW: Gamma-point, dimension = 1
374 TYPE(cp_cfm_type), DIMENSION(:), ALLOCATABLE :: cfm_soc_spinor_ao
375
376 ! parameters for DOS and PDOS calculation
377 REAL(kind=dp) :: energy_window_dos = -1.0_dp, &
378 energy_step_dos = -1.0_dp, &
379 broadening_dos = -1.0_dp
380
381 ! parameters for LDOS calculation (LDOS: local density of states)
382 INTEGER :: int_ldos_xyz = -1
383 INTEGER, DIMENSION(:), POINTER :: bin_mesh => null()
384 INTEGER :: n_bins_max_for_printing = -1
385 REAL(kind=dp) :: unit_ldos_int_z_inv_ang2_ev = -1.0_dp
386
387 ! parameters for Floquet band structure calculations
388 INTEGER :: max_floquet_index = -1
389 INTEGER :: max_nmo_floquet = -1
390 REAL(kind=dp), DIMENSION(:), POINTER :: floquet_polarisation => null(), &
391 floquet_phi => null()
392 REAL(kind=dp) :: floquet_omega = -1.0_dp, &
393 floquet_amplitude = -1.0_dp, &
394 eps_floquet = -1.0_dp, &
395 broadening_floquet = -1.0_dp, &
396 energy_step_floquet = -1.0_dp, &
397 energy_window_floquet = -1.0_dp, &
398 floquet_mem_fill_fraction = -1.0_dp, &
399 floquet_temperature = -1.0_dp
400 CHARACTER(LEN=default_string_length) :: floquet_dos_file = "", &
401 floquet_qe_file = "", &
402 floquet_bs_file = ""
403
404 ! quantities only needed for small cells and k-point sampling in DFT (tensor_small_cell_full_kp)
405 INTEGER :: nkp_scf_desymm = -1, &
406 nimages_3c = -1, &
407 nimages_scf_desymm = -1, &
408 nimages_delta_r = -1
409 TYPE(kpoint_type), POINTER :: kpoints_scf_desymm => null()
410 INTEGER, DIMENSION(3) :: cell_grid_scf_desymm = -1
411 INTEGER, DIMENSION(:, :), ALLOCATABLE :: index_to_cell_3c, &
412 index_to_cell_delta_r
413 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index_3c => null(), &
414 cell_to_index_delta_r => null()
415 REAL(kind=dp) :: heuristic_filter_factor = -1.0_dp
416
417 ! tensor_small_cell_full_kp parallelization
418 INTEGER :: n_tasks_delta_r_local = -1
419 INTEGER, DIMENSION(:), ALLOCATABLE :: task_delta_r
420 INTEGER, DIMENSION(:, :), ALLOCATABLE :: nblocks_3c
421 LOGICAL, DIMENSION(:), ALLOCATABLE :: skip_dr_chi, &
422 skip_dr_sigma
423 LOGICAL, DIMENSION(:, :, :), ALLOCATABLE :: skip_dr_r_r2_mxm_chi, &
424 skip_dr_r1_r_mxm_sigma, &
425 skip_dr_r12_s_goccx3c_chi, &
426 skip_dr_r12_s_gvirx3c_chi, &
427 skip_dr_r1_s2_gx3c_sigma
428
429 ! cfm for k-dep overl mat S_µν(k), KS mat h_µν(k,spin) and mo coeff C_μn(k,spin) from SCF
430 TYPE(cp_cfm_type), DIMENSION(:), ALLOCATABLE :: cfm_s_kp
431 TYPE(cp_cfm_type), DIMENSION(:, :), ALLOCATABLE :: cfm_mo_coeff_kp, &
432 cfm_ks_kp
433 TYPE(cp_fm_type), DIMENSION(:), ALLOCATABLE :: fm_g_s, &
434 fm_sigma_x_r
435 TYPE(cp_fm_type), DIMENSION(:, :), ALLOCATABLE :: fm_v_xc_r, &
436 fm_chi_r_t, &
437 fm_mwm_r_t
438 TYPE(cp_fm_type), DIMENSION(:, :, :), ALLOCATABLE :: fm_sigma_c_r_neg_tau, &
439 fm_sigma_c_r_pos_tau
440 REAL(kind=dp), DIMENSION(:, :, :), ALLOCATABLE :: v_xc_n
441 TYPE(dbt_type), ALLOCATABLE, DIMENSION(:, :) :: t_3c_int
442
444
445 ! Sanity bounds on a quasiparticle gap (Hartree): inverted below -eps_qp_gap, diverged above max_qp_gap
446 REAL(kind=dp), PARAMETER, PUBLIC :: eps_qp_gap = 0.01_dp/evolt, &
447 max_qp_gap = 200.0_dp/evolt
448
449CONTAINS
450
451! **************************************************************************************************
452!> \brief ...
453!> \param bs_env ...
454! **************************************************************************************************
455 SUBROUTINE bs_env_release(bs_env)
456 TYPE(post_scf_bandstructure_type), POINTER :: bs_env
457
458 CHARACTER(LEN=*), PARAMETER :: routinen = 'bs_env_release'
459
460 INTEGER :: handle
461
462 CALL timeset(routinen, handle)
463
464 cpassert(ASSOCIATED(bs_env))
465
466 CALL safe_kpoints_release(bs_env%kpoints_chi_eps_W)
467 CALL safe_kpoints_release(bs_env%kpoints_DOS)
468 CALL safe_kpoints_release(bs_env%kpoints_scf_desymm)
469
470 IF (ALLOCATED(bs_env%wkp_s_p)) DEALLOCATE (bs_env%wkp_s_p)
471 IF (ALLOCATED(bs_env%wkp_no_extra)) DEALLOCATE (bs_env%wkp_no_extra)
472 IF (ALLOCATED(bs_env%l_RI)) DEALLOCATE (bs_env%l_RI)
473 IF (ALLOCATED(bs_env%xkp_special)) DEALLOCATE (bs_env%xkp_special)
474 CALL time_frequency_grid_release(bs_env%time_frequency_grid)
475 CALL time_frequency_grid_release(bs_env%time_frequency_grid_sigma)
476 IF (ALLOCATED(bs_env%eigenval_scf_Gamma)) DEALLOCATE (bs_env%eigenval_scf_Gamma)
477 IF (ALLOCATED(bs_env%eigenval_scf)) DEALLOCATE (bs_env%eigenval_scf)
478 IF (ALLOCATED(bs_env%eigenval_GW)) DEALLOCATE (bs_env%eigenval_GW)
479 IF (ALLOCATED(bs_env%eigenval_G0W0)) DEALLOCATE (bs_env%eigenval_G0W0)
480 IF (ALLOCATED(bs_env%eigenval_HF)) DEALLOCATE (bs_env%eigenval_HF)
481 IF (ALLOCATED(bs_env%gw_unreliable)) DEALLOCATE (bs_env%gw_unreliable)
482 IF (ALLOCATED(bs_env%gw_multi_solution)) DEALLOCATE (bs_env%gw_multi_solution)
483 IF (ALLOCATED(bs_env%eigenval_evGW0)) DEALLOCATE (bs_env%eigenval_evGW0)
484 IF (ALLOCATED(bs_env%i_ao_start_from_atom)) DEALLOCATE (bs_env%i_ao_start_from_atom)
485 IF (ALLOCATED(bs_env%i_ao_end_from_atom)) DEALLOCATE (bs_env%i_ao_end_from_atom)
486 IF (ALLOCATED(bs_env%i_RI_start_from_atom)) DEALLOCATE (bs_env%i_RI_start_from_atom)
487 IF (ALLOCATED(bs_env%i_RI_end_from_atom)) DEALLOCATE (bs_env%i_RI_end_from_atom)
488 IF (ALLOCATED(bs_env%min_RI_idx_from_AO_AO_atom)) DEALLOCATE (bs_env%min_RI_idx_from_AO_AO_atom)
489 IF (ALLOCATED(bs_env%max_RI_idx_from_AO_AO_atom)) DEALLOCATE (bs_env%max_RI_idx_from_AO_AO_atom)
490 IF (ALLOCATED(bs_env%min_AO_idx_from_RI_AO_atom)) DEALLOCATE (bs_env%min_AO_idx_from_RI_AO_atom)
491 IF (ALLOCATED(bs_env%max_AO_idx_from_RI_AO_atom)) DEALLOCATE (bs_env%max_AO_idx_from_RI_AO_atom)
492 IF (ALLOCATED(bs_env%i_atom_intervals)) DEALLOCATE (bs_env%i_atom_intervals)
493 IF (ALLOCATED(bs_env%j_atom_intervals)) DEALLOCATE (bs_env%j_atom_intervals)
494 IF (ALLOCATED(bs_env%atoms_i_t_group)) DEALLOCATE (bs_env%atoms_i_t_group)
495 IF (ALLOCATED(bs_env%atoms_j_t_group)) DEALLOCATE (bs_env%atoms_j_t_group)
496 IF (ALLOCATED(bs_env%skip_Sigma_occ)) DEALLOCATE (bs_env%skip_Sigma_occ)
497 IF (ALLOCATED(bs_env%skip_Sigma_vir)) DEALLOCATE (bs_env%skip_Sigma_vir)
498 IF (ALLOCATED(bs_env%skip_chi)) DEALLOCATE (bs_env%skip_chi)
499 IF (ALLOCATED(bs_env%read_chi)) DEALLOCATE (bs_env%read_chi)
500 IF (ALLOCATED(bs_env%calc_chi)) DEALLOCATE (bs_env%calc_chi)
501 IF (ALLOCATED(bs_env%Sigma_c_exists)) DEALLOCATE (bs_env%Sigma_c_exists)
502 IF (ALLOCATED(bs_env%sizes_AO)) DEALLOCATE (bs_env%sizes_AO)
503 IF (ALLOCATED(bs_env%sizes_RI)) DEALLOCATE (bs_env%sizes_RI)
504 IF (ALLOCATED(bs_env%index_to_cell_3c)) DEALLOCATE (bs_env%index_to_cell_3c)
505 IF (ALLOCATED(bs_env%index_to_cell_Delta_R)) DEALLOCATE (bs_env%index_to_cell_Delta_R)
506 IF (ASSOCIATED(bs_env%cell_to_index_3c)) DEALLOCATE (bs_env%cell_to_index_3c)
507 IF (ASSOCIATED(bs_env%cell_to_index_Delta_R)) DEALLOCATE (bs_env%cell_to_index_Delta_R)
508 IF (ALLOCATED(bs_env%task_Delta_R)) DEALLOCATE (bs_env%task_Delta_R)
509 IF (ALLOCATED(bs_env%nblocks_3c)) DEALLOCATE (bs_env%nblocks_3c)
510 IF (ALLOCATED(bs_env%skip_DR_chi)) DEALLOCATE (bs_env%skip_DR_chi)
511 IF (ALLOCATED(bs_env%skip_DR_Sigma)) DEALLOCATE (bs_env%skip_DR_Sigma)
512 IF (ALLOCATED(bs_env%skip_DR_R_R2_MxM_chi)) DEALLOCATE (bs_env%skip_DR_R_R2_MxM_chi)
513 IF (ALLOCATED(bs_env%skip_DR_R1_R_MxM_Sigma)) DEALLOCATE (bs_env%skip_DR_R1_R_MxM_Sigma)
514 IF (ALLOCATED(bs_env%skip_DR_R12_S_Goccx3c_chi)) DEALLOCATE (bs_env%skip_DR_R12_S_Goccx3c_chi)
515 IF (ALLOCATED(bs_env%skip_DR_R12_S_Gvirx3c_chi)) DEALLOCATE (bs_env%skip_DR_R12_S_Gvirx3c_chi)
516 IF (ALLOCATED(bs_env%skip_DR_R1_S2_Gx3c_Sigma)) DEALLOCATE (bs_env%skip_DR_R1_S2_Gx3c_Sigma)
517
518 CALL cp_fm_release(bs_env%fm_s_Gamma)
519 CALL cp_fm_release(bs_env%fm_ks_Gamma(1))
520 CALL cp_fm_release(bs_env%fm_ks_Gamma(2))
521 CALL cp_fm_release(bs_env%fm_V_xc_Gamma(1))
522 CALL cp_fm_release(bs_env%fm_V_xc_Gamma(2))
523 CALL cp_fm_release(bs_env%fm_mo_coeff_Gamma(1))
524 CALL cp_fm_release(bs_env%fm_mo_coeff_Gamma(2))
525 CALL cp_fm_release(bs_env%fm_Gocc)
526 CALL cp_fm_release(bs_env%fm_Gvir)
527 CALL cp_fm_release(bs_env%fm_work_mo(1))
528 CALL cp_fm_release(bs_env%fm_work_mo(2))
529 CALL cp_fm_release(bs_env%fm_work_mo(3))
530 CALL cp_fm_release(bs_env%fm_work_mo(4))
531 CALL cp_fm_release(bs_env%fm_RI_RI)
532 CALL cp_fm_struct_release(bs_env%fm_struct_RI_RI)
533 CALL cp_fm_release(bs_env%fm_Minv_Gamma)
534 CALL cp_fm_release(bs_env%fm_chi_Gamma_freq)
535 CALL cp_fm_release(bs_env%fm_W_MIC_freq)
536 CALL cp_fm_release(bs_env%fm_W_MIC_freq_zero)
537 CALL cp_fm_release(bs_env%fm_W_MIC_freq_1_extra)
538 CALL cp_fm_release(bs_env%fm_W_MIC_freq_1_no_extra)
539 CALL cp_cfm_release(bs_env%cfm_work_mo)
540 CALL cp_cfm_release(bs_env%cfm_work_mo_2)
541
542 CALL safe_fm_destroy_1d(bs_env%fm_G_S)
543 CALL safe_fm_destroy_1d(bs_env%fm_Sigma_x_R)
544 CALL safe_fm_destroy_2d(bs_env%fm_V_xc_R)
545 CALL safe_fm_destroy_2d(bs_env%fm_chi_R_t)
546 CALL safe_fm_destroy_2d(bs_env%fm_MWM_R_t)
547 CALL safe_fm_destroy_3d(bs_env%fm_Sigma_c_R_neg_tau)
548 CALL safe_fm_destroy_3d(bs_env%fm_Sigma_c_R_pos_tau)
549
550 CALL t_destroy_2d(bs_env%t_3c_int)
551
552 CALL release_dbcsr_p_type(bs_env%mat_ao_ao)
553 CALL release_dbcsr_p_type(bs_env%mat_RI_RI)
554 CALL safe_dbcsr_deallocate_matrix_set_1d(bs_env%mat_chi_Gamma_tau)
555
556 CALL release_dbcsr_p_type(bs_env%mat_ao_ao_tensor)
557 CALL release_dbcsr_p_type(bs_env%mat_RI_RI_tensor)
558
559 CALL safe_cfm_destroy_1d(bs_env%cfm_s_kp)
560 CALL safe_cfm_destroy_2d(bs_env%cfm_ks_kp)
561 CALL safe_cfm_destroy_2d(bs_env%cfm_mo_coeff_kp)
562
563 CALL ri_rs_release(bs_env%ri_rs)
564 CALL mp_para_env_release(bs_env%para_env)
565 IF (ASSOCIATED(bs_env%para_env_tensor)) CALL mp_para_env_release(bs_env%para_env_tensor)
566
567 CALL safe_dbt_destroy(bs_env%t_G)
568 CALL safe_dbt_destroy(bs_env%t_chi)
569 CALL safe_dbt_destroy(bs_env%t_W)
570 CALL safe_dbt_destroy(bs_env%t_RI_AO__AO)
571 CALL safe_dbt_destroy(bs_env%t_RI__AO_AO)
572
573 CALL store_3c_release(bs_env%store_3c_chi)
574 CALL store_3c_release(bs_env%store_3c_W)
575 CALL store_3c_release(bs_env%store_3c_Sigma)
576
577 IF (ALLOCATED(bs_env%basis_set_AO)) DEALLOCATE (bs_env%basis_set_AO)
578 IF (ALLOCATED(bs_env%basis_set_RI)) DEALLOCATE (bs_env%basis_set_RI)
579
580 ! SOC cfm_1d and arrays
581 CALL safe_dbcsr_deallocate_matrix_set_2d(bs_env%mat_V_SOC_xyz)
582 CALL safe_cfm_destroy_1d(bs_env%cfm_SOC_spinor_ao)
583
584 CALL auto_ri_release(bs_env%auto_ri)
585
586 IF (ALLOCATED(bs_env%spin_texture_atoms)) DEALLOCATE (bs_env%spin_texture_atoms)
587 IF (ALLOCATED(bs_env%soc_wf_state_index)) DEALLOCATE (bs_env%soc_wf_state_index)
588
589 DEALLOCATE (bs_env)
590
591 CALL timestop(handle)
592
593 END SUBROUTINE bs_env_release
594
595! **************************************************************************************************
596!> \brief ...
597!> \param kpoints ...
598! **************************************************************************************************
599 SUBROUTINE safe_kpoints_release(kpoints)
600 TYPE(kpoint_type), POINTER :: kpoints
601
602 IF (ASSOCIATED(kpoints)) CALL kpoint_release(kpoints)
603
604 END SUBROUTINE safe_kpoints_release
605
606! **************************************************************************************************
607!> \brief ...
608!> \param dbcsr_p_type_matrix ...
609! **************************************************************************************************
610 SUBROUTINE release_dbcsr_p_type(dbcsr_p_type_matrix)
611 TYPE(dbcsr_p_type) :: dbcsr_p_type_matrix
612
613 IF (ASSOCIATED(dbcsr_p_type_matrix%matrix)) THEN
614 CALL dbcsr_release(dbcsr_p_type_matrix%matrix)
615 DEALLOCATE (dbcsr_p_type_matrix%matrix)
616 END IF
617
618 END SUBROUTINE release_dbcsr_p_type
619
620! **************************************************************************************************
621!> \brief Releases the kept 3-center integrals (the store is no longer in use).
622!> \param store ...
623! **************************************************************************************************
624 SUBROUTINE store_3c_release(store)
625 TYPE(store_3c_type), INTENT(INOUT) :: store
626
627 INTEGER :: i, unused
628
629 IF (ALLOCATED(store%sets)) THEN
630 DO i = 1, store%nsets
631 IF (store%uncompressed) THEN
632 CALL safe_dbt_destroy(store%sets(i)%t_3c)
633 ELSE
634 CALL dealloc_containers(store%sets(i)%compressed, unused)
635 END IF
636 END DO
637 DEALLOCATE (store%sets)
638 END IF
639 store%nsets = 0
640 store%uncompressed = .false.
641 store%memory = 0.0_dp
642
643 END SUBROUTINE store_3c_release
644
645! **************************************************************************************************
646!> \brief ...
647!> \param t ...
648! **************************************************************************************************
649 SUBROUTINE safe_dbt_destroy(t)
650 TYPE(dbt_type) :: t
651
652 IF (ASSOCIATED(t%matrix_rep)) CALL dbt_destroy(t)
653
654 END SUBROUTINE safe_dbt_destroy
655
656! **************************************************************************************************
657!> \brief ...
658!> \param dbcsr_array ...
659! **************************************************************************************************
660 SUBROUTINE safe_dbcsr_deallocate_matrix_set_1d(dbcsr_array)
661 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: dbcsr_array
662
663 IF (ASSOCIATED(dbcsr_array)) CALL dbcsr_deallocate_matrix_set(dbcsr_array)
664
665 END SUBROUTINE safe_dbcsr_deallocate_matrix_set_1d
666
667! **************************************************************************************************
668!> \brief ...
669!> \param dbcsr_array ...
670! **************************************************************************************************
671 SUBROUTINE safe_dbcsr_deallocate_matrix_set_2d(dbcsr_array)
672 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: dbcsr_array
673
674 IF (ASSOCIATED(dbcsr_array)) CALL dbcsr_deallocate_matrix_set(dbcsr_array)
675
676 END SUBROUTINE safe_dbcsr_deallocate_matrix_set_2d
677
678! **************************************************************************************************
679!> \brief ...
680!> \param fm_1d ...
681! **************************************************************************************************
682 SUBROUTINE safe_fm_destroy_1d(fm_1d)
683 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: fm_1d
684
685 INTEGER :: i
686
687 IF (ALLOCATED(fm_1d)) THEN
688 DO i = 1, SIZE(fm_1d, 1)
689 CALL cp_fm_release(fm_1d(i))
690 END DO
691 DEALLOCATE (fm_1d)
692 END IF
693
694 END SUBROUTINE safe_fm_destroy_1d
695
696! **************************************************************************************************
697!> \brief ...
698!> \param fm_2d ...
699! **************************************************************************************************
700 SUBROUTINE safe_fm_destroy_2d(fm_2d)
701 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_2d
702
703 INTEGER :: i, j
704
705 IF (ALLOCATED(fm_2d)) THEN
706 DO i = 1, SIZE(fm_2d, 1)
707 DO j = 1, SIZE(fm_2d, 2)
708 CALL cp_fm_release(fm_2d(i, j))
709 END DO
710 END DO
711 DEALLOCATE (fm_2d)
712 END IF
713
714 END SUBROUTINE safe_fm_destroy_2d
715
716! **************************************************************************************************
717!> \brief ...
718!> \param fm_3d ...
719! **************************************************************************************************
720 SUBROUTINE safe_fm_destroy_3d(fm_3d)
721 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :, :) :: fm_3d
722
723 INTEGER :: i, j, k
724
725 IF (ALLOCATED(fm_3d)) THEN
726 DO i = 1, SIZE(fm_3d, 1)
727 DO j = 1, SIZE(fm_3d, 2)
728 DO k = 1, SIZE(fm_3d, 3)
729 CALL cp_fm_release(fm_3d(i, j, k))
730 END DO
731 END DO
732 END DO
733 DEALLOCATE (fm_3d)
734 END IF
735
736 END SUBROUTINE safe_fm_destroy_3d
737
738! **************************************************************************************************
739!> \brief ...
740!> \param cfm_1d ...
741! **************************************************************************************************
742 SUBROUTINE safe_cfm_destroy_1d(cfm_1d)
743 TYPE(cp_cfm_type), ALLOCATABLE, DIMENSION(:) :: cfm_1d
744
745 INTEGER :: i
746
747 IF (ALLOCATED(cfm_1d)) THEN
748 DO i = 1, SIZE(cfm_1d, 1)
749 CALL cp_cfm_release(cfm_1d(i))
750 END DO
751 DEALLOCATE (cfm_1d)
752 END IF
753
754 END SUBROUTINE safe_cfm_destroy_1d
755
756! **************************************************************************************************
757!> \brief ...
758!> \param cfm_2d ...
759! **************************************************************************************************
760 SUBROUTINE safe_cfm_destroy_2d(cfm_2d)
761 TYPE(cp_cfm_type), ALLOCATABLE, DIMENSION(:, :) :: cfm_2d
762
763 INTEGER :: i, j
764
765 IF (ALLOCATED(cfm_2d)) THEN
766 DO i = 1, SIZE(cfm_2d, 1)
767 DO j = 1, SIZE(cfm_2d, 2)
768 CALL cp_cfm_release(cfm_2d(i, j))
769 END DO
770 END DO
771 DEALLOCATE (cfm_2d)
772 END IF
773
774 END SUBROUTINE safe_cfm_destroy_2d
775
776! **************************************************************************************************
777!> \brief ...
778!> \param t_2d ...
779! **************************************************************************************************
780 SUBROUTINE t_destroy_2d(t_2d)
781 TYPE(dbt_type), ALLOCATABLE, DIMENSION(:, :) :: t_2d
782
783 INTEGER :: i, j
784
785 IF (ALLOCATED(t_2d)) THEN
786 DO i = 1, SIZE(t_2d, 1)
787 DO j = 1, SIZE(t_2d, 2)
788 CALL dbt_destroy(t_2d(i, j))
789 END DO
790 END DO
791 DEALLOCATE (t_2d)
792 END IF
793
794 END SUBROUTINE t_destroy_2d
795
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public dbcsr_release(matrix)
...
DBCSR operations in CP2K.
represent the structure of a full matrix
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
This is the start of a dbt_api, all publically needed functions are exported here....
Definition dbt_api.F:17
Input and persistent data for automatic RI basis optimization.
subroutine, public auto_ri_release(auto_ri)
Releases all data owned by an optimized AUTO_RI basis.
Work data of periodic RI-RS GW with full k-point sampling.
Nevanlinna analytic continuation of the GW correlation self-energy from the imaginary to the real fre...
Types and set/get functions for HFX.
Definition hfx_types.F:16
subroutine, public dealloc_containers(data, memory_usage)
...
Definition hfx_types.F:2841
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public tensor_small_cell_full_kp
integer, parameter, public g0w0
integer, parameter, public cohsex_off
integer, parameter, public gw_ac_nevanlinna
Library choices for electronic integral APIs.
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_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
integer, parameter, public int_4
Definition kinds.F:51
Types and basic routines needed for a kpoint calculation.
subroutine, public kpoint_release(kpoint)
Release a kpoint environment, deallocate all data.
Interface to the message passing library MPI.
subroutine, public mp_para_env_release(para_env)
releases the para object (to be called when you don't want anymore the shared copy of this object)
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public evolt
Definition physcon.F:189
subroutine, public bs_env_release(bs_env)
...
real(kind=dp), parameter, public max_qp_gap
real(kind=dp), parameter, public eps_qp_gap
subroutine, public store_3c_release(store)
Releases the kept 3-center integrals (the store is no longer in use).
Utility methods to build 3-center integral tensors of various types.
Shared real-space resolution-of-identity grid and matrix data.
Definition ri_rs_types.F:11
subroutine, public ri_rs_release(ri_rs)
Release owned RI-RS matrices and grid data, then clear construction state. Input settings and restart...
Definition and construction of time/frequency grids for correlation methods.
subroutine, public time_frequency_grid_release(grid)
Release all data owned by a time_frequency_grid_type object.
Represent a complex full matrix.
keeps the information about the structure of a full matrix
represent a full matrix
Parameters of the quasiparticle solution with the Nevanlinna continuation; they are set in set_heuris...
Contains information about kpoints.
stores all the informations relevant to an mpi environment