38 dbt_contract, dbt_copy, dbt_copy_matrix_to_tensor, dbt_create, dbt_default_distvec, &
39 dbt_destroy, dbt_get_info, dbt_pgrid_create, dbt_pgrid_destroy, dbt_pgrid_type, dbt_type
64#include "./base/base_uses.f90"
70 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rpa_gw_im_time_util'
103 t_3c_overl_int_ao_mo, t_3c_O_mo_compressed, t_3c_O_mo_ind, &
104 t_3c_overl_int_gw_RI, t_3c_overl_int_gw_AO, &
105 starts_array_mc, ends_array_mc, &
106 mo_coeff, matrix_s, &
107 gw_corr_lev_occ, gw_corr_lev_virt, homo, nmo, &
110 t_3c_overl_nnP_ic, t_3c_overl_nnP_ic_reflected, &
111 qs_env, unit_nr, do_alpha)
113 TYPE(dbt_type),
DIMENSION(:, :) :: t_3c_overl_int
116 TYPE(dbt_type) :: t_3c_overl_int_ao_mo
118 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: t_3c_o_mo_ind
119 TYPE(dbt_type) :: t_3c_overl_int_gw_ri, &
121 INTEGER,
DIMENSION(:),
INTENT(IN) :: starts_array_mc, ends_array_mc
124 INTEGER,
INTENT(IN) :: gw_corr_lev_occ, gw_corr_lev_virt, homo, &
127 LOGICAL,
INTENT(IN) :: do_ic_model
128 TYPE(dbt_type) :: t_3c_overl_nnp_ic, &
129 t_3c_overl_nnp_ic_reflected
131 INTEGER,
INTENT(IN) :: unit_nr
132 LOGICAL,
INTENT(IN),
OPTIONAL :: do_alpha
134 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_tensor_3c_overl_int_gw'
136 INTEGER :: cut_memory, handle, i_mem, icol_global, imo, irow_global, min_bsize, &
137 min_bsize_mo, nkind, nmo_blk_gw, npcols, nprows, size_mo, unit_nr_prv
138 INTEGER(int_8) :: nze
139 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: dist1, dist2, dist3, sizes_ao, &
140 sizes_ao_split, sizes_mo, sizes_mo_1, &
141 sizes_ri, sizes_ri_split, tmp
142 INTEGER,
DIMENSION(2) :: pdims_2d
143 INTEGER,
DIMENSION(2, 1) :: bounds
144 INTEGER,
DIMENSION(2, 3) :: ibounds
145 INTEGER,
DIMENSION(3) :: bounds_3c, pdims
146 INTEGER,
DIMENSION(:),
POINTER :: distp_1, distp_2, sizes_mo_blocked, &
147 sizes_mo_p1, sizes_mo_p2
148 LOGICAL :: memory_info, my_do_alpha
149 REAL(
dp) :: compression_factor, memory_3c, occ
150 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: norm
154 TYPE(
dbcsr_type) :: mat_mo_coeff_gw_reflected_norm, &
155 mat_norm, mat_norm_diag, mat_work
156 TYPE(
dbcsr_type),
POINTER :: mat_mo_coeff_gw, &
157 mat_mo_coeff_gw_reflected
158 TYPE(dbt_pgrid_type) :: pgrid_2d, pgrid_ao, pgrid_ic, pgrid_mo
159 TYPE(dbt_type) :: mo_coeff_gw_t, mo_coeff_gw_t_tmp, &
160 t_3c_overl_int_ao_ao, &
161 t_3c_overl_int_mo_ao, &
165 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
167 memory_info = qs_env%mp2_env%ri_rpa_im_time%memory_info
168 IF (memory_info)
THEN
169 unit_nr_prv = unit_nr
174 my_do_alpha = .false.
175 IF (
PRESENT(do_alpha)) my_do_alpha = do_alpha
177 CALL timeset(routinen, handle)
179 CALL get_qs_env(qs_env, nkind=nkind, qs_kind_set=qs_kind_set, particle_set=particle_set, atomic_kind_set=atomic_kind_set)
181 CALL cp_fm_create(fm_mat_mo_coeff_gw, mo_coeff%matrix_struct)
185 DO irow_global = 1, nmo
186 DO icol_global = 1, homo - gw_corr_lev_occ
189 DO icol_global = homo + gw_corr_lev_virt + 1, nmo
194 NULLIFY (mat_mo_coeff_gw)
198 sym=dbcsr_type_no_symmetry)
202 keep_sparsity=.false.)
207 min_bsize = qs_env%mp2_env%ri_rpa_im_time%min_bsize
208 min_bsize_mo = qs_env%mp2_env%ri_rpa_im_time%min_bsize_mo
210 CALL split_block_sizes([gw_corr_lev_occ + gw_corr_lev_virt], sizes_mo, min_bsize_mo)
211 ALLOCATE (sizes_mo_1(nmo))
214 nmo_blk_gw =
SIZE(sizes_mo)
215 CALL move_alloc(sizes_mo, tmp)
216 ALLOCATE (sizes_mo(nmo_blk_gw + 2))
217 sizes_mo(1) = homo - gw_corr_lev_occ
218 sizes_mo(2:
SIZE(tmp) + 1) = tmp(:)
219 sizes_mo(
SIZE(tmp) + 2) = nmo - (homo + gw_corr_lev_virt)
221 ALLOCATE (basis_set_ri_aux(nkind), basis_set_ao(nkind))
223 CALL get_particle_set(particle_set, qs_kind_set, nsgf=sizes_ri, basis=basis_set_ri_aux)
225 CALL get_particle_set(particle_set, qs_kind_set, nsgf=sizes_ao, basis=basis_set_ao)
227 CALL pgf_block_sizes(atomic_kind_set, basis_set_ao, min_bsize, sizes_ao_split)
228 CALL pgf_block_sizes(atomic_kind_set, basis_set_ri_aux, min_bsize, sizes_ri_split)
230 DEALLOCATE (basis_set_ao, basis_set_ri_aux)
233 CALL dbt_pgrid_create(para_env, pdims, pgrid_ao, &
234 tensor_dims=[
SIZE(sizes_ri_split),
SIZE(sizes_ao_split),
SIZE(sizes_ao_split)])
240 pdims = [pdims_2d(1), pdims_2d(2), 1]
241 CALL dbt_pgrid_create(para_env, pdims, pgrid_mo, &
242 tensor_dims=[
SIZE(sizes_ri_split),
SIZE(sizes_ao_split), 1])
245 CALL dbt_pgrid_create(para_env, pdims_2d, pgrid_2d, &
246 tensor_dims=[
SIZE(sizes_ao_split), nmo])
248 CALL create_3c_tensor(t_3c_overl_int_ao_ao, dist1, dist2, dist3, pgrid_ao, &
249 sizes_ri_split, sizes_ao_split, sizes_ao_split, [1, 2], [3], name=
"(RI AO | AO)")
250 DEALLOCATE (dist1, dist2, dist3)
252 IF (.NOT. qs_env%mp2_env%ri_g0w0%do_kpoints_Sigma)
THEN
253 CALL create_3c_tensor(t_3c_overl_int_ao_mo, dist1, dist2, dist3, pgrid_ao, &
254 sizes_ri_split, sizes_ao_split, sizes_mo_1, [1, 2], [3], name=
"(RI AO | MO)")
255 DEALLOCATE (dist1, dist2, dist3)
258 CALL create_3c_tensor(t_3c_overl_int_gw_ri, dist1, dist2, dist3, pgrid_mo, &
259 sizes_ri_split, sizes_ao_split, sizes_mo, [1], [2, 3], name=
"(RI | AO MO)")
260 DEALLOCATE (dist1, dist2, dist3)
262 CALL create_3c_tensor(t_3c_overl_int_gw_ao, dist1, dist2, dist3, pgrid_mo, &
263 sizes_ao_split, sizes_ri_split, sizes_mo, [1], [2, 3], name=
"(AO | RI MO)")
264 DEALLOCATE (dist1, dist2, dist3)
266 CALL dbt_pgrid_destroy(pgrid_ao)
267 CALL dbt_pgrid_destroy(pgrid_mo)
269 CALL create_2c_tensor(mo_coeff_gw_t, dist1, dist2, pgrid_2d, sizes_ao_split, sizes_mo_1, name=
"(AO|MO)")
270 DEALLOCATE (dist1, dist2)
271 CALL dbt_pgrid_destroy(pgrid_2d)
273 CALL dbt_create(mat_mo_coeff_gw, mo_coeff_gw_t_tmp, name=
"MO coeffs")
274 CALL dbt_copy_matrix_to_tensor(mat_mo_coeff_gw, mo_coeff_gw_t_tmp)
276 CALL dbt_copy(mo_coeff_gw_t_tmp, mo_coeff_gw_t)
278 bounds(1, 1) = homo - gw_corr_lev_occ + 1
279 bounds(2, 1) = homo + gw_corr_lev_virt
281 CALL dbt_get_info(t_3c_overl_int_ao_ao, nfull_total=bounds_3c)
283 ibounds(:, 1) = [1, bounds_3c(1)]
284 ibounds(:, 3) = [1, bounds_3c(3)]
286 cut_memory =
SIZE(starts_array_mc)
288 IF (.NOT. qs_env%mp2_env%ri_g0w0%do_kpoints_Sigma)
THEN
289 DO i_mem = 1, cut_memory
290 CALL decompress_tensor(t_3c_overl_int(1, 1), t_3c_o_ind(1, 1, i_mem)%ind, t_3c_o_compressed(1, 1, i_mem), &
291 qs_env%mp2_env%ri_rpa_im_time%eps_compress)
293 ibounds(:, 2) = [starts_array_mc(i_mem), ends_array_mc(i_mem)]
295 CALL dbt_copy(t_3c_overl_int(1, 1), t_3c_overl_int_ao_ao, move_data=.true.)
297 CALL dbt_contract(1.0_dp, mo_coeff_gw_t, t_3c_overl_int_ao_ao, 1.0_dp, &
298 t_3c_overl_int_ao_mo, contract_1=[1], notcontract_1=[2], &
299 contract_2=[3], notcontract_2=[1, 2], map_1=[3], map_2=[1, 2], &
300 bounds_2=ibounds, move_data=.false., unit_nr=unit_nr_prv)
307 IF (do_ic_model)
THEN
309 CALL dbt_pgrid_create(para_env, pdims, pgrid_ic, &
310 tensor_dims=[
SIZE(sizes_ri_split), nmo, nmo])
312 CALL create_3c_tensor(t_3c_overl_int_mo_ao, dist1, dist2, dist3, pgrid_ic, &
313 sizes_ri_split, sizes_mo_1, sizes_ao_split, [1, 2], [3], name=
"(RI MO | AO)")
314 DEALLOCATE (dist1, dist2, dist3)
315 CALL create_3c_tensor(t_3c_overl_int_mo_mo, dist1, dist2, dist3, pgrid_ic, &
316 sizes_ri_split, sizes_mo_1, sizes_mo_1, [1, 2], [3], name=
"(RI MO | MO)")
317 DEALLOCATE (dist1, dist2, dist3)
318 CALL dbt_create(t_3c_overl_int_mo_mo, t_3c_overl_nnp_ic)
319 CALL create_3c_tensor(t_3c_overl_nnp_ic_reflected, dist1, dist2, dist3, pgrid_ic, &
320 sizes_ri_split, sizes_mo_1, sizes_mo_1, [1], [2, 3], name=
"(RI | MO MO)")
321 DEALLOCATE (dist1, dist2, dist3)
323 CALL dbt_pgrid_destroy(pgrid_ic)
325 CALL dbt_copy(t_3c_overl_int_ao_mo, t_3c_overl_int_mo_ao, order=[1, 3, 2])
326 CALL dbt_contract(1.0_dp, mo_coeff_gw_t, t_3c_overl_int_mo_ao, 0.0_dp, &
327 t_3c_overl_int_mo_mo, contract_1=[1], notcontract_1=[2], &
328 contract_2=[3], notcontract_2=[1, 2], map_1=[3], map_2=[1, 2], &
329 bounds_2=bounds, move_data=.false., unit_nr=unit_nr_prv)
330 CALL dbt_copy(t_3c_overl_int_mo_mo, t_3c_overl_nnp_ic)
332 NULLIFY (mat_mo_coeff_gw_reflected)
336 sym=dbcsr_type_no_symmetry)
338 CALL reflect_mat_row(mat_mo_coeff_gw_reflected, mat_mo_coeff_gw, para_env, qs_env, unit_nr, do_alpha=my_do_alpha)
342 CALL dbcsr_create(matrix=mat_work, template=mat_mo_coeff_gw_reflected, matrix_type=dbcsr_type_no_symmetry)
344 CALL dbcsr_get_info(mat_work, distribution=dist_templ, nblkcols_total=size_mo, col_blk_size=sizes_mo_blocked)
348 ALLOCATE (distp_1(size_mo), distp_2(size_mo))
349 CALL dbt_default_distvec(size_mo, nprows, sizes_mo_blocked, distp_1)
350 CALL dbt_default_distvec(size_mo, npcols, sizes_mo_blocked, distp_2)
351 CALL dbcsr_distribution_new(dist, template=dist_templ, row_dist=distp_1, col_dist=distp_2, reuse_arrays=.true.)
353 ALLOCATE (sizes_mo_p1(size_mo))
354 ALLOCATE (sizes_mo_p2(size_mo))
355 sizes_mo_p1(:) = sizes_mo_blocked
356 sizes_mo_p2(:) = sizes_mo_blocked
357 CALL dbcsr_create(mat_norm,
"mo norm", dist, dbcsr_type_no_symmetry, sizes_mo_p1, sizes_mo_p2, &
361 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix_s(1)%matrix, mat_mo_coeff_gw_reflected, 0.0_dp, mat_work)
362 CALL dbcsr_multiply(
"T",
"N", 1.0_dp, mat_mo_coeff_gw_reflected, mat_work, 0.0_dp, mat_norm)
370 CALL para_env%sum(norm)
372 DO imo = bounds(1, 1), bounds(2, 1)
373 norm(imo) = 1.0_dp/sqrt(norm(imo))
383 CALL dbcsr_create(mat_mo_coeff_gw_reflected_norm, template=mat_mo_coeff_gw_reflected)
384 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, mat_mo_coeff_gw_reflected, mat_norm_diag, 0.0_dp, mat_mo_coeff_gw_reflected_norm)
387 CALL dbcsr_filter(mat_mo_coeff_gw_reflected_norm, 1.0e-20_dp)
389 CALL dbt_copy_matrix_to_tensor(mat_mo_coeff_gw_reflected_norm, mo_coeff_gw_t_tmp)
391 CALL dbt_copy(mo_coeff_gw_t_tmp, mo_coeff_gw_t)
393 CALL dbt_contract(1.0_dp, mo_coeff_gw_t, t_3c_overl_int_ao_ao, 0.0_dp, &
394 t_3c_overl_int_ao_mo, contract_1=[1], notcontract_1=[2], &
395 contract_2=[3], notcontract_2=[1, 2], map_1=[3], map_2=[1, 2], &
396 bounds_2=bounds, move_data=.false., unit_nr=unit_nr_prv)
398 CALL dbt_copy(t_3c_overl_int_ao_mo, t_3c_overl_int_mo_ao, order=[1, 3, 2])
399 CALL dbt_contract(1.0_dp, mo_coeff_gw_t, t_3c_overl_int_mo_ao, 0.0_dp, &
400 t_3c_overl_int_mo_mo, contract_1=[1], notcontract_1=[2], &
401 contract_2=[3], notcontract_2=[1, 2], map_1=[3], map_2=[1, 2], &
402 bounds_2=bounds, move_data=.false., unit_nr=unit_nr_prv)
403 CALL dbt_copy(t_3c_overl_int_mo_mo, t_3c_overl_nnp_ic_reflected)
404 CALL dbt_destroy(t_3c_overl_int_mo_ao)
405 CALL dbt_destroy(t_3c_overl_int_mo_mo)
411 IF (.NOT. qs_env%mp2_env%ri_g0w0%do_kpoints_Sigma)
THEN
416 CALL compress_tensor(t_3c_overl_int_ao_mo, t_3c_o_mo_ind, t_3c_o_mo_compressed, &
417 qs_env%mp2_env%ri_rpa_im_time%eps_compress, memory_3c)
419 CALL para_env%sum(memory_3c)
420 compression_factor = real(nze,
dp)*1.0e-06*8.0_dp/memory_3c
422 IF (unit_nr > 0)
THEN
423 WRITE (unit=unit_nr, fmt=
"((T3,A,T66,F11.2,A4))") &
424 "MEMORY_INFO| Memory of MO-contracted tensor (compressed):", memory_3c,
' MiB'
426 WRITE (unit=unit_nr, fmt=
"((T3,A,T60,F21.2))") &
427 "MEMORY_INFO| Compression factor: ", compression_factor
433 CALL dbt_destroy(t_3c_overl_int_ao_ao)
434 CALL dbt_destroy(mo_coeff_gw_t)
435 CALL dbt_destroy(mo_coeff_gw_t_tmp)
437 CALL timestop(handle)
451 SUBROUTINE reflect_mat_row(mat_reflected, mat_orig, para_env, qs_env, unit_nr, do_alpha)
452 TYPE(
dbcsr_type),
INTENT(INOUT) :: mat_reflected
456 INTEGER,
INTENT(IN) :: unit_nr
457 LOGICAL,
INTENT(IN) :: do_alpha
459 CHARACTER(LEN=*),
PARAMETER :: routinen =
'reflect_mat_row'
461 INTEGER :: block, block_size, col, col_rec, col_size, handle, i_atom, i_block, imepos, &
462 j_atom, natom, nblkcols_total, nblkrows_total, offset, row, row_rec, row_reflected, &
464 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: block_counter, entry_counter, image_atom, &
465 num_blocks_rec, num_blocks_send, num_entries_rec, num_entries_send, sizes_rec, sizes_send
466 INTEGER,
DIMENSION(:),
POINTER :: col_blk_sizes, row_blk_sizes
467 LOGICAL :: found_image_atom
468 REAL(kind=
dp) :: avg_z_dist, delta, eps_dist2, &
469 min_z_dist, ra(3), rb(3), sum_z, &
471 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: data_block
475 DIMENSION(:) :: buffer_rec, buffer_send
479 CALL timeset(routinen, handle)
484 particle_set=particle_set)
488 nblkrows_total=nblkrows_total, &
489 nblkcols_total=nblkcols_total, &
490 row_blk_size=row_blk_sizes, &
491 col_blk_size=col_blk_sizes)
493 natom =
SIZE(particle_set)
494 cpassert(natom == nblkrows_total)
496 eps_dist2 = qs_env%mp2_env%ri_g0w0%eps_dist
497 eps_dist2 = eps_dist2*eps_dist2
503 ra(:) =
pbc(particle_set(i_atom)%r, cell)
505 sum_z = sum_z + ra(3)
509 z_reflection = sum_z/real(natom, kind=
dp)
515 ra(:) =
pbc(particle_set(i_atom)%r, cell)
517 sum_z = sum_z + abs(ra(3) - z_reflection)
521 avg_z_dist = sum_z/real(natom, kind=
dp)
523 min_z_dist = avg_z_dist
527 ra(:) =
pbc(particle_set(i_atom)%r, cell)
529 IF (abs(ra(3) - z_reflection) < min_z_dist)
THEN
530 min_z_dist = abs(ra(3) - z_reflection)
535 IF (unit_nr > 0 .AND. do_alpha)
THEN
536 WRITE (unit_nr,
'(T3,A,T70,F9.2,A2)')
'IC_MODEL| Average distance of the molecule to the image plane:', &
537 avg_z_dist*0.529_dp,
' A'
538 WRITE (unit_nr,
'(T3,A,T70,F9.2,A2)')
'IC_MODEL| Minimum distance of the molecule to the image plane:', &
539 min_z_dist*0.529_dp,
' A'
542 ALLOCATE (image_atom(nblkrows_total))
547 found_image_atom = .false.
549 ra(:) =
pbc(particle_set(i_atom)%r, cell)
553 rb(:) =
pbc(particle_set(j_atom)%r, cell)
555 delta = (ra(1) - rb(1))**2 + (ra(2) - rb(2))**2 + (ra(3) + rb(3) - 2.0_dp*z_reflection)**2
558 IF (delta < eps_dist2)
THEN
560 cpassert(.NOT. found_image_atom)
561 image_atom(i_atom) = j_atom
562 found_image_atom = .true.
565 cpassert(row_blk_sizes(i_atom) == row_blk_sizes(j_atom))
571 cpassert(found_image_atom)
575 ALLOCATE (buffer_rec(0:para_env%num_pe - 1))
576 ALLOCATE (buffer_send(0:para_env%num_pe - 1))
578 ALLOCATE (num_entries_rec(0:para_env%num_pe - 1))
579 ALLOCATE (num_blocks_rec(0:para_env%num_pe - 1))
580 ALLOCATE (num_entries_send(0:para_env%num_pe - 1))
581 ALLOCATE (num_blocks_send(0:para_env%num_pe - 1))
592 row_reflected = image_atom(row)
596 num_entries_send(imepos) = num_entries_send(imepos) + row_size*col_size
597 num_blocks_send(imepos) = num_blocks_send(imepos) + 1
603 IF (para_env%num_pe > 1)
THEN
605 ALLOCATE (sizes_rec(0:2*para_env%num_pe - 1))
606 ALLOCATE (sizes_send(0:2*para_env%num_pe - 1))
608 DO imepos = 0, para_env%num_pe - 1
610 sizes_send(2*imepos) = num_entries_send(imepos)
611 sizes_send(2*imepos + 1) = num_blocks_send(imepos)
615 CALL para_env%alltoall(sizes_send, sizes_rec, 2)
617 DO imepos = 0, para_env%num_pe - 1
618 num_entries_rec(imepos) = sizes_rec(2*imepos)
619 num_blocks_rec(imepos) = sizes_rec(2*imepos + 1)
622 DEALLOCATE (sizes_rec, sizes_send)
626 num_entries_rec(0) = num_entries_send(0)
627 num_blocks_rec(0) = num_blocks_send(0)
632 DO imepos = 0, para_env%num_pe - 1
634 ALLOCATE (buffer_rec(imepos)%msg(num_entries_rec(imepos)))
635 buffer_rec(imepos)%msg = 0.0_dp
637 ALLOCATE (buffer_send(imepos)%msg(num_entries_send(imepos)))
638 buffer_send(imepos)%msg = 0.0_dp
640 ALLOCATE (buffer_rec(imepos)%indx(num_blocks_rec(imepos), 3))
641 buffer_rec(imepos)%indx = 0
643 ALLOCATE (buffer_send(imepos)%indx(num_blocks_send(imepos), 3))
644 buffer_send(imepos)%indx = 0
648 ALLOCATE (block_counter(0:para_env%num_pe - 1))
651 ALLOCATE (entry_counter(0:para_env%num_pe - 1))
658 row_size=row_size, col_size=col_size)
660 row_reflected = image_atom(row)
664 block_size = row_size*col_size
666 offset = entry_counter(imepos)
668 buffer_send(imepos)%msg(offset + 1:offset + block_size) = &
669 reshape(data_block(1:row_size, 1:col_size), (/block_size/))
671 block = block_counter(imepos) + 1
673 buffer_send(imepos)%indx(block, 1) = row_reflected
674 buffer_send(imepos)%indx(block, 2) = col
675 buffer_send(imepos)%indx(block, 3) = offset
677 entry_counter(imepos) = entry_counter(imepos) + block_size
679 block_counter(imepos) = block_counter(imepos) + 1
685 ALLOCATE (req_array(1:para_env%num_pe, 4))
687 CALL communicate_buffer(para_env, num_entries_rec, num_entries_send, buffer_rec, buffer_send, req_array)
689 DEALLOCATE (req_array)
692 DO imepos = 0, para_env%num_pe - 1
694 DO i_block = 1, num_blocks_rec(imepos)
696 row_rec = buffer_rec(imepos)%indx(i_block, 1)
697 col_rec = buffer_rec(imepos)%indx(i_block, 2)
703 row_size=row_size, col_size=col_size)
705 IF (row_rec == row .AND. col_rec == col)
THEN
707 offset = buffer_rec(imepos)%indx(i_block, 3)
709 data_block(:, :) = reshape(buffer_rec(imepos)%msg(offset + 1:offset + row_size*col_size), &
710 (/row_size, col_size/))
722 DO imepos = 0, para_env%num_pe - 1
723 DEALLOCATE (buffer_rec(imepos)%msg)
724 DEALLOCATE (buffer_rec(imepos)%indx)
725 DEALLOCATE (buffer_send(imepos)%msg)
726 DEALLOCATE (buffer_send(imepos)%indx)
729 DEALLOCATE (buffer_rec, buffer_send)
730 DEALLOCATE (block_counter, entry_counter)
731 DEALLOCATE (num_entries_rec)
732 DEALLOCATE (num_blocks_rec)
733 DEALLOCATE (num_entries_send)
734 DEALLOCATE (num_blocks_send)
736 CALL timestop(handle)
749 basis_type, first_bf_from_atom)
751 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_from_basis_index
752 INTEGER :: basis_size
753 CHARACTER(LEN=*) :: basis_type
754 INTEGER,
ALLOCATABLE,
DIMENSION(:),
OPTIONAL :: first_bf_from_atom
756 INTEGER :: iatom, lll, natom, nkind
757 INTEGER,
DIMENSION(:),
POINTER :: row_blk_end, row_blk_start
760 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
762 NULLIFY (qs_kind_set, particle_set)
763 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, natom=natom, nkind=nkind, &
764 particle_set=particle_set)
766 ALLOCATE (row_blk_start(natom))
767 ALLOCATE (row_blk_end(natom))
768 ALLOCATE (basis_set(nkind))
770 CALL get_particle_set(particle_set, qs_kind_set, first_sgf=row_blk_start, last_sgf=row_blk_end, &
772 DO lll = 1, basis_size
774 IF (lll >= row_blk_start(iatom) .AND. lll <= row_blk_end(iatom))
THEN
775 atom_from_basis_index(lll) = iatom
780 IF (
PRESENT(first_bf_from_atom)) first_bf_from_atom(1:natom) = row_blk_start(:)
782 DEALLOCATE (basis_set)
783 DEALLOCATE (row_blk_start)
784 DEALLOCATE (row_blk_end)
803 num_cells, iatom, jatom, xkp, wkp_W, &
804 cell, index_to_cell, hmat, particle_set)
806 REAL(kind=
dp) :: weight_re, weight_im
807 INTEGER :: num_cells, iatom, jatom
808 REAL(kind=
dp),
DIMENSION(3) :: xkp
809 REAL(kind=
dp) :: wkp_w
811 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
812 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
815 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_weight_re_im'
817 INTEGER :: handle, icell, n_equidistant_cells, &
819 REAL(kind=
dp) :: abs_rab_cell, abs_rab_cell_min, arg
820 REAL(kind=
dp),
DIMENSION(3) :: cell_vector, rab_cell_i
822 CALL timeset(routinen, handle)
827 abs_rab_cell_min = 1.0e10_dp
829 n_equidistant_cells = 0
831 DO icell = 1, num_cells
833 xcell = index_to_cell(1, icell)
834 ycell = index_to_cell(2, icell)
835 zcell = index_to_cell(3, icell)
837 cell_vector(1:3) = matmul(hmat, real((/xcell, ycell, zcell/),
dp))
839 rab_cell_i(1:3) =
pbc(particle_set(iatom)%r(1:3), cell) - &
840 (
pbc(particle_set(jatom)%r(1:3), cell) + cell_vector(1:3))
842 abs_rab_cell = sqrt(rab_cell_i(1)**2 + rab_cell_i(2)**2 + rab_cell_i(3)**2)
844 IF (abs_rab_cell < abs_rab_cell_min)
THEN
845 abs_rab_cell_min = abs_rab_cell
850 DO icell = 1, num_cells
852 xcell = index_to_cell(1, icell)
853 ycell = index_to_cell(2, icell)
854 zcell = index_to_cell(3, icell)
856 cell_vector(1:3) = matmul(hmat, real((/xcell, ycell, zcell/),
dp))
858 rab_cell_i(1:3) =
pbc(particle_set(iatom)%r(1:3), cell) - &
859 (
pbc(particle_set(jatom)%r(1:3), cell) + cell_vector(1:3))
861 abs_rab_cell = sqrt(rab_cell_i(1)**2 + rab_cell_i(2)**2 + rab_cell_i(3)**2)
863 IF (abs_rab_cell < abs_rab_cell_min + 0.1_dp)
THEN
865 arg = real(xcell,
dp)*xkp(1) + real(ycell,
dp)*xkp(2) + real(zcell,
dp)*xkp(3)
867 weight_re = weight_re + wkp_w*cos(
twopi*arg)
868 weight_im = weight_im + wkp_w*sin(
twopi*arg)
870 n_equidistant_cells = n_equidistant_cells + 1
876 weight_re = weight_re/real(n_equidistant_cells, kind=
dp)
877 weight_im = weight_im/real(n_equidistant_cells, kind=
dp)
879 CALL timestop(handle)
Define the atomic kind types and their sub types.
Handles all functions related to the CELL.
subroutine, public dbcsr_distribution_release(dist)
...
subroutine, public dbcsr_release_p(matrix)
...
subroutine, public dbcsr_distribution_new(dist, template, group, pgrid, row_dist, col_dist, reuse_arrays)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, first_row, last_row, first_column, last_column, first_k, last_k, retain_sparsity, filter_eps, flop)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_get_stored_coordinates(matrix, row, column, processor)
...
subroutine, public dbcsr_init_p(matrix)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_iterator_readonly_start(iterator, matrix, shared, dynamic, dynamic_byrows)
Like dbcsr_iterator_start() but with matrix being INTENT(IN). When invoking this routine,...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
subroutine, public dbcsr_set_diag(matrix, diag)
Copies the diagonal elements from the given array into the given matrix.
subroutine, public dbcsr_get_diag(matrix, diag)
Copies the diagonal elements from the given matrix into the given array.
subroutine, public dbcsr_add_on_diag(matrix, alpha)
Adds the given scalar to the diagonal of the matrix. Reserves any missing diagonal blocks.
subroutine, public dbcsr_reserve_all_blocks(matrix)
Reserves all blocks.
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_m_by_n_from_row_template(matrix, template, n, sym)
Utility function to create dbcsr matrix, m x n matrix (n arbitrary) with the same processor grid and ...
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
represent a full matrix distributed on many processors
subroutine, public cp_fm_set_element(matrix, irow_global, icol_global, alpha)
sets an element of a matrix
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
This is the start of a dbt_api, all publically needed functions are exported here....
Types and set/get functions for HFX.
subroutine, public alloc_containers(data, bin_size)
...
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
Interface to the message passing library MPI.
subroutine, public mp_dims_create(nodes, dims)
wrapper to MPI_Dims_create
Types needed for MP2 calculations.
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis)
Get the components of a particle set.
Define the data structure for the particle information.
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, 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, 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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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)
Get the QUICKSTEP environment.
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
Define the quickstep kind type and their sub types.
Utility methods to build 3-center integral tensors of various types.
subroutine, public create_2c_tensor(t2c, dist_1, dist_2, pgrid, sizes_1, sizes_2, order, name)
...
subroutine, public split_block_sizes(blk_sizes, blk_sizes_split, max_size)
...
subroutine, public pgf_block_sizes(atomic_kind_set, basis, min_blk_size, pgf_blk_sizes)
...
subroutine, public create_3c_tensor(t3c, dist_1, dist_2, dist_3, pgrid, sizes_1, sizes_2, sizes_3, map1, map2, name)
...
Utility methods to build 3-center integral tensors of various types.
subroutine, public compress_tensor(tensor, blk_indices, compressed, eps, memory)
...
subroutine, public decompress_tensor(tensor, blk_indices, compressed, eps)
...
subroutine, public get_tensor_occupancy(tensor, nze, occ)
...
Auxiliary routines necessary to redistribute an fm_matrix from a given blacs_env to another.
subroutine, public communicate_buffer(para_env, num_entries_rec, num_entries_send, buffer_rec, buffer_send, req_array, do_indx, do_msg)
...
Utility routines for GW with imaginary time.
subroutine, public compute_weight_re_im(weight_re, weight_im, num_cells, iatom, jatom, xkp, wkp_w, cell, index_to_cell, hmat, particle_set)
...
subroutine, public get_tensor_3c_overl_int_gw(t_3c_overl_int, t_3c_o_compressed, t_3c_o_ind, t_3c_overl_int_ao_mo, t_3c_o_mo_compressed, t_3c_o_mo_ind, t_3c_overl_int_gw_ri, t_3c_overl_int_gw_ao, starts_array_mc, ends_array_mc, mo_coeff, matrix_s, gw_corr_lev_occ, gw_corr_lev_virt, homo, nmo, para_env, do_ic_model, t_3c_overl_nnp_ic, t_3c_overl_nnp_ic_reflected, qs_env, unit_nr, do_alpha)
...
subroutine, public get_atom_index_from_basis_function_index(qs_env, atom_from_basis_index, basis_size, basis_type, first_bf_from_atom)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.