38 dbt_batched_contract_finalize, dbt_batched_contract_init, dbt_contract, dbt_copy, &
39 dbt_copy_matrix_to_tensor, dbt_copy_tensor_to_matrix, dbt_create, dbt_destroy, dbt_filter, &
40 dbt_get_info, dbt_nblks_total, dbt_nd_mp_comm, dbt_pgrid_destroy, dbt_pgrid_type, dbt_type
67#include "./base/base_uses.f90"
73 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rpa_im_time'
97 TYPE(
dbcsr_p_type),
DIMENSION(:, :, :),
POINTER :: propagator
98 INTEGER,
INTENT(IN) :: ntime
99 TYPE(
dbcsr_type),
INTENT(IN) :: matrix_template
100 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: index_to_cell
102 INTEGER :: icell, isector, jtime, ncell
105 cpassert(
SIZE(index_to_cell, 1) == 3)
106 ncell =
SIZE(index_to_cell, 2)
114 ALLOCATE (propagator(isector, jtime, icell)%matrix)
115 CALL dbcsr_create(matrix=propagator(isector, jtime, icell)%matrix, &
116 template=matrix_template, &
117 matrix_type=dbcsr_type_no_symmetry)
164 t_3c_M, t_3c_O, t_3c_O_compressed, t_3c_O_ind, &
165 starts_array_mc, ends_array_mc, &
166 starts_array_mc_block, ends_array_mc_block, &
167 grid, e_fermi, eps_filter, &
168 alpha, eps_filter_im_time, Eigenval, nmo, &
169 cut_memory, unit_nr, &
171 qs_env, do_kpoints_from_Gamma, &
172 index_to_cell_3c, cell_to_index_3c, &
173 has_mat_P_blocks, do_ri_sos_laplace_mp2, &
174 dbcsr_time, dbcsr_nflop)
175 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
INTENT(IN) :: mat_p_omega
177 INTEGER,
INTENT(IN) :: homo
180 INTEGER,
INTENT(IN) :: ispin
181 TYPE(dbt_type),
INTENT(INOUT) :: t_3c_m
182 TYPE(dbt_type),
DIMENSION(:, :),
INTENT(INOUT) :: t_3c_o
184 INTENT(INOUT) :: t_3c_o_compressed
186 INTENT(INOUT) :: t_3c_o_ind
187 INTEGER,
DIMENSION(:),
INTENT(IN) :: starts_array_mc, ends_array_mc, &
188 starts_array_mc_block, &
191 REAL(kind=
dp),
INTENT(IN) :: e_fermi, eps_filter, alpha, &
193 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: eigenval
194 INTEGER,
INTENT(IN) :: nmo, cut_memory, unit_nr
198 LOGICAL,
INTENT(IN) :: do_kpoints_from_gamma
199 INTEGER,
ALLOCATABLE,
DIMENSION(:, :),
INTENT(IN) :: index_to_cell_3c
200 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :), &
201 INTENT(IN) :: cell_to_index_3c
202 LOGICAL,
DIMENSION(:, :, :, :, :),
INTENT(INOUT) :: has_mat_p_blocks
203 LOGICAL,
INTENT(IN) :: do_ri_sos_laplace_mp2
204 REAL(
dp),
INTENT(INOUT) :: dbcsr_time
205 INTEGER(int_8),
INTENT(INOUT) :: dbcsr_nflop
207 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_mat_P_omega'
209 INTEGER :: comm_2d_handle, handle, handle2, handle3, i, i_cell, i_cell_r_1, &
210 i_cell_r_1_minus_s, i_cell_r_1_minus_t, i_cell_r_2, i_cell_r_2_minus_s_minus_t, i_cell_s, &
211 i_cell_t, i_mem, iquad, j, j_mem, jquad, num_3c_repl, num_cells_dm, num_integ_points, &
213 INTEGER(int_8) :: nze, nze_dm_occ, nze_dm_virt, nze_m_occ, &
215 INTEGER(KIND=int_8) :: flops_1_occ, flops_1_virt, flops_2
216 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: dist_1, dist_2, mc_ranges, size_dm, &
218 INTEGER,
DIMENSION(2) :: pdims_2d
219 INTEGER,
DIMENSION(2, 1) :: ibounds_2, jbounds_2
220 INTEGER,
DIMENSION(2, 2) :: ibounds_1, jbounds_1
221 INTEGER,
DIMENSION(3) :: bounds_3c
222 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell_dm
223 LOGICAL :: do_gamma_rpa, do_kpoints_cubic_rpa, first_cycle_im_time, memory_info, &
224 r_1_minus_s_needed, r_1_minus_t_needed, r_2_minus_s_minus_t_needed
225 REAL(
dp) :: occ, occ_dm_occ, occ_dm_virt, occ_m_occ, &
226 occ_m_virt, occ_o, t1_flop
227 REAL(kind=
dp) :: t1, t2, weight
229 TYPE(
dbcsr_p_type),
DIMENSION(:, :, :),
POINTER :: propagator
230 TYPE(dbt_pgrid_type) :: pgrid_2d
231 TYPE(dbt_type) :: t_3c_m_occ, t_3c_m_occ_tmp, t_3c_m_virt, &
232 t_3c_m_virt_tmp, t_dm, t_dm_tmp, t_p, &
234 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:) :: t_dm_occ, t_dm_virt
235 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_3c_o_occ, t_3c_o_virt
238 CALL timeset(routinen, handle)
240 DO jquad = 1,
SIZE(mat_p_omega, 1)
241 DO i_cell_t = 1,
SIZE(mat_p_omega, 2)
242 CALL dbcsr_set(mat_p_omega(jquad, i_cell_t)%matrix, 0.0_dp)
246 IF (do_ri_sos_laplace_mp2)
THEN
247 num_integ_points =
SIZE(grid%imaginary_time)
249 num_integ_points =
SIZE(grid%frequency)
254 memory_info = mp2_env%ri_rpa_im_time%memory_info
255 IF (memory_info)
THEN
256 unit_nr_dbcsr = unit_nr
261 do_kpoints_cubic_rpa = qs_env%mp2_env%ri_rpa_im_time%do_im_time_kpoints
262 do_gamma_rpa = .NOT. do_kpoints_cubic_rpa
263 num_3c_repl = maxval(cell_to_index_3c)
265 first_cycle_im_time = .true.
266 ALLOCATE (t_3c_o_occ(
SIZE(t_3c_o, 1),
SIZE(t_3c_o, 2)), t_3c_o_virt(
SIZE(t_3c_o, 1),
SIZE(t_3c_o, 2)))
267 DO i = 1,
SIZE(t_3c_o, 1)
268 DO j = 1,
SIZE(t_3c_o, 2)
269 CALL dbt_create(t_3c_o(i, j), t_3c_o_occ(i, j))
270 CALL dbt_create(t_3c_o(i, j), t_3c_o_virt(i, j))
274 CALL dbt_create(t_3c_m, t_3c_m_occ, name=
"M occ (RI | AO AO)")
275 CALL dbt_create(t_3c_m, t_3c_m_virt, name=
"M virt (RI | AO AO)")
277 ALLOCATE (mc_ranges(cut_memory + 1))
278 mc_ranges(:cut_memory) = starts_array_mc_block(:)
279 mc_ranges(cut_memory + 1) = ends_array_mc_block(cut_memory) + 1
281 DO jquad = 1, num_integ_points
288 eigenval, e_fermi, eps_filter, memory_info, unit_nr, &
289 jquad, do_kpoints_cubic_rpa, do_kpoints_from_gamma, qs_env, &
290 num_cells_dm, index_to_cell_dm, para_env)
292 ALLOCATE (t_dm_virt(num_cells_dm))
293 ALLOCATE (t_dm_occ(num_cells_dm))
296 CALL comm_2d%set_handle(comm_2d_handle)
298 pgrid_2d = dbt_nd_mp_comm(comm_2d, [1], [2], pdims_2d=pdims_2d)
299 ALLOCATE (size_p(dbt_nblks_total(t_3c_m, 1)))
300 CALL dbt_get_info(t_3c_m, blk_size_1=size_p)
302 ALLOCATE (size_dm(dbt_nblks_total(t_3c_o(1, 1), 3)))
303 CALL dbt_get_info(t_3c_o(1, 1), blk_size_3=size_dm)
304 CALL create_2c_tensor(t_dm, dist_1, dist_2, pgrid_2d, size_dm, size_dm, name=
"D (AO | AO)")
306 DEALLOCATE (dist_1, dist_2)
307 CALL create_2c_tensor(t_p, dist_1, dist_2, pgrid_2d, size_p, size_p, name=
"P (RI | RI)")
309 DEALLOCATE (dist_1, dist_2)
310 CALL dbt_pgrid_destroy(pgrid_2d)
312 DO i_cell = 1, num_cells_dm
313 CALL dbt_create(t_dm, t_dm_virt(i_cell), name=
"D virt (AO | AO)")
316 CALL dbt_copy(t_dm_tmp, t_dm_virt(i_cell), move_data=.true.)
319 CALL dbt_create(t_dm, t_dm_occ(i_cell), name=
"D occ (AO | AO)")
321 CALL dbt_copy(t_dm_tmp, t_dm_occ(i_cell), move_data=.true.)
322 CALL dbt_destroy(t_dm_tmp)
329 CALL dbt_destroy(t_dm)
331 CALL dbt_create(t_3c_o_occ(1, 1), t_3c_m_occ_tmp, name=
"M (RI AO | AO)")
332 CALL dbt_create(t_3c_o_virt(1, 1), t_3c_m_virt_tmp, name=
"M (RI AO | AO)")
334 CALL timeset(routinen//
"_contract", handle2)
339 DO i = 1,
SIZE(t_3c_o_occ, 1)
340 DO j = 1,
SIZE(t_3c_o_occ, 2)
341 CALL dbt_batched_contract_init(t_3c_o_occ(i, j), batch_range_2=mc_ranges, batch_range_3=mc_ranges)
344 DO i = 1,
SIZE(t_3c_o_virt, 1)
345 DO j = 1,
SIZE(t_3c_o_virt, 2)
346 CALL dbt_batched_contract_init(t_3c_o_virt(i, j), batch_range_2=mc_ranges, batch_range_3=mc_ranges)
349 CALL dbt_batched_contract_init(t_3c_m_occ_tmp, batch_range_2=mc_ranges, batch_range_3=mc_ranges)
350 CALL dbt_batched_contract_init(t_3c_m_virt_tmp, batch_range_2=mc_ranges, batch_range_3=mc_ranges)
351 CALL dbt_batched_contract_init(t_3c_m_occ, batch_range_2=mc_ranges, batch_range_3=mc_ranges)
352 CALL dbt_batched_contract_init(t_3c_m_virt, batch_range_2=mc_ranges, batch_range_3=mc_ranges)
354 DO i_cell_t = 1, num_cells_dm/2 + 1
356 IF (.NOT. any(has_mat_p_blocks(i_cell_t, :, :, :, :))) cycle
358 CALL dbt_batched_contract_init(t_p)
360 IF (do_gamma_rpa)
THEN
369 DO j_mem = 1, cut_memory
371 CALL dbt_get_info(t_3c_o_occ(1, 1), nfull_total=bounds_3c)
373 jbounds_1(:, 1) = [1, bounds_3c(1)]
374 jbounds_1(:, 2) = [starts_array_mc(j_mem), ends_array_mc(j_mem)]
376 jbounds_2(:, 1) = [starts_array_mc(j_mem), ends_array_mc(j_mem)]
378 IF (do_gamma_rpa)
CALL dbt_batched_contract_init(t_dm_virt(1))
380 DO i_mem = 1, cut_memory
382 IF (.NOT. any(has_mat_p_blocks(i_cell_t, i_mem, j_mem, :, :))) cycle
384 ibounds_1(:, 1) = [1, bounds_3c(1)]
385 ibounds_1(:, 2) = [starts_array_mc(i_mem), ends_array_mc(i_mem)]
387 ibounds_2(:, 1) = [starts_array_mc(i_mem), ends_array_mc(i_mem)]
389 IF (unit_nr_dbcsr > 0)
WRITE (unit=unit_nr_dbcsr, fmt=
"(T3,A,I3,1X,I3)") &
390 "RPA_LOW_SCALING_INFO| Memory Cut iteration", i_mem, j_mem
392 DO i_cell_r_1 = 1, num_3c_repl
394 DO i_cell_r_2 = 1, num_3c_repl
396 IF (.NOT. has_mat_p_blocks(i_cell_t, i_mem, j_mem, i_cell_r_1, i_cell_r_2)) cycle
398 CALL get_diff_index_3c(i_cell_r_1, i_cell_t, i_cell_r_1_minus_t, &
399 index_to_cell_3c, cell_to_index_3c, index_to_cell_dm, &
400 r_1_minus_t_needed, do_kpoints_cubic_rpa)
402 IF (do_gamma_rpa)
CALL dbt_batched_contract_init(t_dm_occ(1))
403 DO i_cell_s = 1, num_cells_dm
404 CALL get_diff_index_3c(i_cell_r_1, i_cell_s, i_cell_r_1_minus_s, index_to_cell_3c, &
405 cell_to_index_3c, index_to_cell_dm, r_1_minus_s_needed, &
406 do_kpoints_cubic_rpa)
407 IF (r_1_minus_s_needed)
THEN
409 CALL timeset(routinen//
"_calc_M_occ_t", handle3)
411 t_3c_o_ind(i_cell_r_1_minus_s, i_cell_r_2, j_mem)%ind, &
412 t_3c_o_compressed(i_cell_r_1_minus_s, i_cell_r_2, j_mem), &
413 qs_env%mp2_env%ri_rpa_im_time%eps_compress)
415 IF (do_gamma_rpa .AND. i_mem == 1)
THEN
421 CALL dbt_copy(t_3c_o(i_cell_r_1_minus_s, i_cell_r_2), &
422 t_3c_o_occ(i_cell_r_1_minus_s, i_cell_r_2), move_data=.true.)
424 CALL dbt_contract(alpha=1.0_dp, &
425 tensor_1=t_3c_o_occ(i_cell_r_1_minus_s, i_cell_r_2), &
426 tensor_2=t_dm_occ(i_cell_s), &
428 tensor_3=t_3c_m_occ_tmp, &
429 contract_1=[3], notcontract_1=[1, 2], &
430 contract_2=[2], notcontract_2=[1], &
431 map_1=[1, 2], map_2=[3], &
432 bounds_2=jbounds_1, bounds_3=ibounds_2, &
433 filter_eps=eps_filter, unit_nr=unit_nr_dbcsr, &
435 CALL timestop(handle3)
437 dbcsr_nflop = dbcsr_nflop + flops_1_occ
442 IF (do_gamma_rpa)
CALL dbt_batched_contract_finalize(t_dm_occ(1))
447 CALL timeset(routinen//
"_copy_M_occ_t", handle3)
448 CALL dbt_copy(t_3c_m_occ_tmp, t_3c_m_occ, order=[1, 3, 2], move_data=.true.)
449 CALL dbt_filter(t_3c_m_occ, eps_filter)
450 CALL timestop(handle3)
452 IF (do_gamma_rpa)
THEN
454 nze_m_occ = nze_m_occ + nze
455 occ_m_occ = occ_m_occ + occ
458 DO i_cell_s = 1, num_cells_dm
459 CALL get_diff_diff_index_3c(i_cell_r_2, i_cell_s, i_cell_t, i_cell_r_2_minus_s_minus_t, &
460 index_to_cell_3c, cell_to_index_3c, index_to_cell_dm, &
461 r_2_minus_s_minus_t_needed, do_kpoints_cubic_rpa)
463 IF (r_1_minus_t_needed .AND. r_2_minus_s_minus_t_needed)
THEN
465 t_3c_o_ind(i_cell_r_2_minus_s_minus_t, i_cell_r_1_minus_t, i_mem)%ind, &
466 t_3c_o_compressed(i_cell_r_2_minus_s_minus_t, i_cell_r_1_minus_t, i_mem), &
467 qs_env%mp2_env%ri_rpa_im_time%eps_compress)
469 CALL dbt_copy(t_3c_o(i_cell_r_2_minus_s_minus_t, i_cell_r_1_minus_t), &
470 t_3c_o_virt(i_cell_r_2_minus_s_minus_t, i_cell_r_1_minus_t), move_data=.true.)
472 CALL timeset(routinen//
"_calc_M_virt_t", handle3)
473 CALL dbt_contract(alpha=alpha/2.0_dp, &
474 tensor_1=t_3c_o_virt( &
475 i_cell_r_2_minus_s_minus_t, i_cell_r_1_minus_t), &
476 tensor_2=t_dm_virt(i_cell_s), &
478 tensor_3=t_3c_m_virt_tmp, &
479 contract_1=[3], notcontract_1=[1, 2], &
480 contract_2=[2], notcontract_2=[1], &
481 map_1=[1, 2], map_2=[3], &
482 bounds_2=ibounds_1, bounds_3=jbounds_2, &
483 filter_eps=eps_filter, unit_nr=unit_nr_dbcsr, &
485 CALL timestop(handle3)
487 dbcsr_nflop = dbcsr_nflop + flops_1_virt
492 CALL timeset(routinen//
"_copy_M_virt_t", handle3)
493 CALL dbt_copy(t_3c_m_virt_tmp, t_3c_m_virt, move_data=.true.)
494 CALL dbt_filter(t_3c_m_virt, eps_filter)
495 CALL timestop(handle3)
497 IF (do_gamma_rpa)
THEN
499 nze_m_virt = nze_m_virt + nze
500 occ_m_virt = occ_m_virt + occ
505 CALL timeset(routinen//
"_calc_P_t", handle3)
507 CALL dbt_contract(alpha=1.0_dp, tensor_1=t_3c_m_occ, &
508 tensor_2=t_3c_m_virt, &
511 contract_1=[2, 3], notcontract_1=[1], &
512 contract_2=[2, 3], notcontract_2=[1], &
513 map_1=[1], map_2=[2], &
514 filter_eps=eps_filter_im_time/real(cut_memory**2, kind=
dp), &
517 unit_nr=unit_nr_dbcsr)
519 CALL timestop(handle3)
521 first_cycle_im_time = .false.
523 IF (jquad == 1 .AND. flops_2 == 0)
THEN
524 has_mat_p_blocks(i_cell_t, i_mem, j_mem, i_cell_r_1, i_cell_r_2) = .false.
530 IF (do_gamma_rpa)
CALL dbt_batched_contract_finalize(t_dm_virt(1))
533 CALL dbt_batched_contract_finalize(t_p, unit_nr=unit_nr_dbcsr)
535 CALL dbt_create(mat_p_global%matrix, t_p_tmp)
536 CALL dbt_copy(t_p, t_p_tmp, move_data=.true.)
537 CALL dbt_copy_tensor_to_matrix(t_p_tmp, mat_p_global%matrix)
538 CALL dbt_destroy(t_p_tmp)
540 IF (do_ri_sos_laplace_mp2)
THEN
544 CALL dbcsr_add(mat_p_omega(jquad, i_cell_t)%matrix, mat_p_global%matrix, 1.0_dp, 1.0_dp)
546 CALL timeset(routinen//
"_Fourier_transform", handle3)
549 DO iquad = 1, num_integ_points
551 weight = grid%cosine_time_to_frequency(iquad, jquad)
555 CALL dbcsr_add(mat_p_omega(iquad, i_cell_t)%matrix, mat_p_global%matrix, &
560 CALL timestop(handle3)
565 CALL timestop(handle2)
567 CALL dbt_batched_contract_finalize(t_3c_m_occ_tmp)
568 CALL dbt_batched_contract_finalize(t_3c_m_virt_tmp)
569 CALL dbt_batched_contract_finalize(t_3c_m_occ)
570 CALL dbt_batched_contract_finalize(t_3c_m_virt)
572 DO i = 1,
SIZE(t_3c_o_occ, 1)
573 DO j = 1,
SIZE(t_3c_o_occ, 2)
574 CALL dbt_batched_contract_finalize(t_3c_o_occ(i, j))
578 DO i = 1,
SIZE(t_3c_o_virt, 1)
579 DO j = 1,
SIZE(t_3c_o_virt, 2)
580 CALL dbt_batched_contract_finalize(t_3c_o_virt(i, j))
584 CALL dbt_destroy(t_p)
585 DO i_cell = 1, num_cells_dm
586 CALL dbt_destroy(t_dm_virt(i_cell))
587 CALL dbt_destroy(t_dm_occ(i_cell))
590 CALL dbt_destroy(t_3c_m_occ_tmp)
591 CALL dbt_destroy(t_3c_m_virt_tmp)
592 DEALLOCATE (t_dm_virt)
593 DEALLOCATE (t_dm_occ)
598 dbcsr_time = dbcsr_time + t2 - t1_flop
600 IF (unit_nr > 0)
THEN
601 WRITE (unit_nr,
'(/T3,A,1X,I3)') &
602 'RPA_LOW_SCALING_INFO| Info for time point', jquad
603 WRITE (unit_nr,
'(T6,A,T56,F25.1)') &
604 'Execution time (s):', t2 - t1
605 WRITE (unit_nr,
'(T6,A,T63,ES7.1,1X,A1,1X,F7.3,A1)') &
606 'Occupancy of D occ:', real(nze_dm_occ,
dp),
'/', occ_dm_occ*100,
'%'
607 WRITE (unit_nr,
'(T6,A,T63,ES7.1,1X,A1,1X,F7.3,A1)') &
608 'Occupancy of D virt:', real(nze_dm_virt,
dp),
'/', occ_dm_virt*100,
'%'
609 IF (do_gamma_rpa)
THEN
610 WRITE (unit_nr,
'(T6,A,T63,ES7.1,1X,A1,1X,F7.3,A1)') &
611 'Occupancy of 3c ints:', real(nze_o,
dp),
'/', occ_o*100,
'%'
612 WRITE (unit_nr,
'(T6,A,T63,ES7.1,1X,A1,1X,F7.3,A1)') &
613 'Occupancy of M occ:', real(nze_m_occ,
dp),
'/', occ_m_occ*100,
'%'
614 WRITE (unit_nr,
'(T6,A,T63,ES7.1,1X,A1,1X,F7.3,A1)') &
615 'Occupancy of M virt:', real(nze_m_virt,
dp),
'/', occ_m_virt*100,
'%'
623 CALL dbt_destroy(t_3c_m_occ)
624 CALL dbt_destroy(t_3c_m_virt)
626 DO i = 1,
SIZE(t_3c_o, 1)
627 DO j = 1,
SIZE(t_3c_o, 2)
628 CALL dbt_destroy(t_3c_o_occ(i, j))
629 CALL dbt_destroy(t_3c_o_virt(i, j))
635 CALL timestop(handle)
663 Eigenval, e_fermi, eps_filter, memory_info, unit_nr, &
664 jquad, do_kpoints_cubic_RPA, do_kpoints_from_Gamma, qs_env, &
665 num_cells_dm, index_to_cell_dm, para_env)
668 INTEGER,
INTENT(IN) :: nmo
670 INTEGER,
INTENT(IN) :: homo
672 INTENT(INOUT),
POINTER :: propagator
673 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(IN) :: matrix_s
674 INTEGER,
INTENT(IN) :: ispin
675 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: eigenval
676 REAL(kind=
dp),
INTENT(IN) :: e_fermi, eps_filter
677 LOGICAL,
INTENT(IN) :: memory_info
678 INTEGER,
INTENT(IN) :: unit_nr, jquad
679 LOGICAL,
INTENT(IN) :: do_kpoints_cubic_rpa, &
680 do_kpoints_from_gamma
682 INTEGER,
INTENT(OUT) :: num_cells_dm
683 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell_dm
686 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_mat_dm_global'
688 INTEGER :: handle, num_integ_points
689 INTEGER,
DIMENSION(3, 1) :: index_to_cell_zero
692 index_to_cell_zero = 0
693 num_integ_points =
SIZE(grid%imaginary_time)
695 CALL timeset(routinen, handle)
697 IF (memory_info .AND. unit_nr > 0)
WRITE (unit=unit_nr, fmt=
"(T3,A,T75,i6)") &
698 "RPA_LOW_SCALING_INFO| Started with time point: ", jquad
700 tau = grid%imaginary_time(jquad)
702 IF (do_kpoints_cubic_rpa)
THEN
705 ispin, num_integ_points, jquad, e_fermi, tau, &
706 eps_filter, num_cells_dm, index_to_cell_dm, &
710 ispin, num_integ_points, jquad, e_fermi, tau, &
711 eps_filter, num_cells_dm, index_to_cell_dm, &
714 ELSE IF (do_kpoints_from_gamma)
THEN
717 ispin, num_integ_points, jquad, e_fermi, tau, &
721 ispin, num_integ_points, jquad, e_fermi, tau, &
736 eps_filter, e_fermi, tau, para_env)
748 CALL timestop(handle)
766 eps_filter, e_fermi, tau, para_env)
768 INTENT(INOUT),
POINTER :: propagator
769 INTEGER,
INTENT(IN) :: jquad
771 INTEGER,
INTENT(IN) :: homo
772 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: eigenval
773 INTEGER,
INTENT(IN) :: nmo
774 REAL(kind=
dp),
INTENT(IN) :: eps_filter, e_fermi, tau
777 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_gamma_propagator'
778 REAL(kind=
dp),
PARAMETER :: stabilize_exp = 70.0_dp
780 INTEGER :: first_mo, handle, i_mo, isector, &
782 REAL(kind=
dp) :: column_factors(nmo), tau_e
783 TYPE(
cp_fm_type) :: fm_mo_coeff_scaled, fm_scaled_dm_tau
786 CALL timeset(routinen, handle)
790 CALL cp_fm_create(fm_scaled_dm_tau, fm_mo_coeff%matrix_struct, nrow=nao, ncol=nao)
791 CALL cp_fm_create(fm_mo_coeff_scaled, fm_mo_coeff%matrix_struct)
794 tau_e = tau*0.5_dp*(eigenval(i_mo) - e_fermi)
795 IF (abs(tau_e) < stabilize_exp)
THEN
796 IF (i_mo > homo) tau_e = -tau_e
797 column_factors(i_mo) = exp(tau_e)
799 column_factors(i_mo) = 0.0_dp
813 fm_mo_coeff_scaled, fm_scaled_dm_tau)
816 mat => propagator(isector, jquad, 1)%matrix
824 CALL timestop(handle)
838 SUBROUTINE build_kpoint_density_matrix_rpa(kpoint, ikpgr, ispin, tau, e_fermi, sector, density)
841 INTEGER,
INTENT(IN) :: ikpgr, ispin
842 REAL(kind=
dp),
INTENT(IN) :: tau, e_fermi
843 INTEGER,
INTENT(IN) :: sector
846 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_kpoint_density_matrix_rpa'
847 REAL(kind=
dp),
PARAMETER :: stabilize_exp = 70.0_dp
849 INTEGER :: handle, i_mo, nao, nmo, nspin
850 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues, exp_scaling, occupation
856 CALL timeset(routinen, handle)
859 cpassert(kpoint%use_real_wfn .EQV. .false.)
861 kp => kpoint%kp_env(ikpgr)%kpoint_env
863 cpassert(ispin >= 1 .AND. ispin <= nspin)
864 mo_set => kp%mos(ispin)
865 CALL get_mo_set(mo_set, cmo_coeff=cfm_mo_coeff, nao=nao, nmo=nmo, &
866 eigenvalues=eigenvalues, occupation_numbers=occupation)
872 ALLOCATE (exp_scaling(nmo))
880 cmplx(2.0_dp/real(nspin, kind=
dp) - occupation, 0.0_dp, kind=
dp))
888 IF (abs(tau*0.5_dp*(eigenvalues(i_mo) - e_fermi)) < stabilize_exp)
THEN
889 exp_scaling(i_mo) = exp(-abs(tau*(eigenvalues(i_mo) - e_fermi)))
891 exp_scaling(i_mo) = 0.0_dp
896 CALL parallel_gemm(
"N",
"C", nao, nao, nmo, (1.0_dp, 0.0_dp), cfm_mo_coeff, cfm_work, &
897 (0.0_dp, 0.0_dp), density)
900 DEALLOCATE (exp_scaling)
902 CALL timestop(handle)
904 END SUBROUTINE build_kpoint_density_matrix_rpa
920 SUBROUTINE compute_transl_dm(propagator, qs_env, ispin, num_integ_points, jquad, e_fermi, tau, &
921 eps_filter, num_cells_dm, index_to_cell_dm, &
924 INTENT(INOUT),
POINTER :: propagator
926 INTEGER,
INTENT(IN) :: ispin, num_integ_points, jquad
927 REAL(kind=
dp),
INTENT(IN) :: e_fermi, tau, eps_filter
928 INTEGER,
INTENT(OUT) :: num_cells_dm
929 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell_dm
930 INTEGER,
INTENT(IN) :: sector
932 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_transl_dm'
934 INTEGER :: handle, i_dim, i_img, nao
935 INTEGER,
DIMENSION(3) :: cell_grid_dm
938 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_dm_global_work
939 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp
942 CALL timeset(routinen, handle)
945 matrix_s_kp=matrix_s_kp, &
952 cell_grid_dm(i_dim) = (kpoints%nkp_grid(i_dim)/2)*2 - 1
955 num_cells_dm = cell_grid_dm(1)*cell_grid_dm(2)*cell_grid_dm(3)
957 NULLIFY (mat_dm_global_work)
961 DO i_img = 1, num_cells_dm
963 ALLOCATE (mat_dm_global_work(i_img)%matrix)
964 CALL dbcsr_create(matrix=mat_dm_global_work(i_img)%matrix, &
965 template=matrix_s_kp(1, 1)%matrix, &
967 matrix_type=dbcsr_type_no_symmetry)
974 CALL get_mo_set(kpoints%kp_env(1)%kpoint_env%mos(1), nao=nao)
975 CALL cp_cfm_create(cfm_density, kpoints%kp_env(1)%kpoint_env%mos(1)%cmo_coeff%matrix_struct, &
983 CALL density_matrix_from_kp_to_transl(kpoints, cfm_density, mat_dm_global_work, kpoints%index_to_cell, &
984 ispin, tau, e_fermi, sector)
989 index_to_cell_dm => kpoints%index_to_cell
992 IF (.NOT.
ASSOCIATED(propagator))
THEN
994 kpoints%index_to_cell)
997 DO i_img = 1, num_cells_dm
1000 CALL dbcsr_filter(mat_dm_global_work(i_img)%matrix, eps_filter)
1002 CALL dbcsr_copy(propagator(sector, jquad, i_img)%matrix, &
1003 mat_dm_global_work(i_img)%matrix)
1009 CALL timestop(handle)
1027 INTENT(INOUT),
POINTER :: propagator
1029 INTEGER,
INTENT(IN) :: ispin, num_integ_points, jquad
1030 REAL(kind=
dp),
INTENT(IN) :: e_fermi, tau
1031 INTEGER,
INTENT(IN) :: sector
1033 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_periodic_dm'
1035 INTEGER :: handle, nao, num_cells_dm
1036 INTEGER,
DIMENSION(3, 1) :: index_to_cell_zero
1038 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_dm_global_work
1039 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp
1042 CALL timeset(routinen, handle)
1044 NULLIFY (matrix_s_kp)
1047 matrix_s_kp=matrix_s_kp)
1049 kpoints_g => qs_env%mp2_env%ri_rpa_im_time%kpoints_G
1052 index_to_cell_zero = 0
1054 NULLIFY (mat_dm_global_work)
1059 IF (.NOT.
ASSOCIATED(propagator))
THEN
1064 ALLOCATE (mat_dm_global_work(1)%matrix)
1065 CALL dbcsr_create(matrix=mat_dm_global_work(1)%matrix, &
1066 template=matrix_s_kp(1, 1)%matrix, &
1067 matrix_type=dbcsr_type_no_symmetry)
1071 CALL dbcsr_set(mat_dm_global_work(1)%matrix, 0.0_dp)
1074 CALL get_mo_set(kpoints_g%kp_env(1)%kpoint_env%mos(1), nao=nao)
1075 CALL cp_cfm_create(cfm_density, kpoints_g%kp_env(1)%kpoint_env%mos(1)%cmo_coeff%matrix_struct, &
1078 CALL density_matrix_from_kp_to_mic(kpoints_g, cfm_density, mat_dm_global_work, qs_env, ispin, tau, e_fermi, sector)
1082 CALL dbcsr_copy(propagator(sector, jquad, 1)%matrix, &
1083 mat_dm_global_work(1)%matrix)
1087 CALL timestop(handle)
1102 SUBROUTINE density_matrix_from_kp_to_mic(kpoints_G, density, mat_dm_global_work, qs_env, ispin, tau, e_fermi, sector)
1106 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_dm_global_work
1108 INTEGER,
INTENT(IN) :: ispin
1109 REAL(kind=
dp),
INTENT(IN) :: tau, e_fermi
1110 INTEGER,
INTENT(IN) :: sector
1112 CHARACTER(LEN=*),
PARAMETER :: routinen =
'density_matrix_from_kp_to_mic'
1114 COMPLEX(KIND=dp),
CONTIGUOUS,
DIMENSION(:, :), &
1116 INTEGER :: handle, iatom, iatom_old, ik, ik_global, &
1117 ik_old, irow, jatom, jatom_old, jcol, &
1118 nao, ncol_local, nrow_local, num_cells
1119 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_from_ao_index
1120 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
1121 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
1122 REAL(kind=
dp) :: contribution, weight_im, weight_re
1123 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
1124 REAL(kind=
dp),
DIMENSION(:),
POINTER :: wkp
1125 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1131 CALL timeset(routinen, handle)
1136 index_to_cell => kpoints_g%index_to_cell
1137 num_cells =
SIZE(index_to_cell, 2)
1139 CALL cp_cfm_get_info(density, nrow_global=nao, nrow_local=nrow_local, ncol_local=ncol_local, &
1140 row_indices=row_indices, col_indices=col_indices)
1141 CALL cp_fm_create(fm_mat_work, density%matrix_struct, set_zero=.true.)
1143 ALLOCATE (atom_from_ao_index(nao))
1147 NULLIFY (cell, particle_set)
1148 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
1155 CALL dbcsr_set(mat_dm_global_work(1)%matrix, 0.0_dp)
1157 DO ik = 1,
SIZE(kpoints_g%kp_env)
1159 kp => kpoints_g%kp_env(ik)%kpoint_env
1160 ik_global = kp%nkpoint
1161 CALL build_kpoint_density_matrix_rpa(kpoints_g, ik, ispin, tau, e_fermi, sector, density)
1164 DO irow = 1, nrow_local
1165 DO jcol = 1, ncol_local
1167 iatom = atom_from_ao_index(row_indices(irow))
1168 jatom = atom_from_ao_index(col_indices(jcol))
1170 IF (ik_global /= ik_old .OR. iatom /= iatom_old .OR. jatom /= jatom_old)
THEN
1173 num_cells, iatom, jatom, xkp(1:3, ik_global), wkp(ik_global), &
1174 cell, index_to_cell, hmat, particle_set)
1182 contribution = real(cmplx(weight_re, -weight_im, kind=
dp)*cfm_data(irow, jcol), kind=
dp)
1184 fm_mat_work%local_data(irow, jcol) = fm_mat_work%local_data(irow, jcol) + contribution
1191 CALL copy_fm_to_dbcsr(fm_mat_work, mat_dm_global_work(1)%matrix, keep_sparsity=.false.)
1196 DEALLOCATE (atom_from_ao_index)
1198 CALL timestop(handle)
1200 END SUBROUTINE density_matrix_from_kp_to_mic
1213 SUBROUTINE density_matrix_from_kp_to_transl(kpoints, density, mat_dm_global_work, index_to_cell, &
1214 ispin, tau, e_fermi, sector)
1218 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(IN) :: mat_dm_global_work
1219 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: index_to_cell
1220 INTEGER,
INTENT(IN) :: ispin
1221 REAL(kind=
dp),
INTENT(IN) :: tau, e_fermi
1222 INTEGER,
INTENT(IN) :: sector
1224 CHARACTER(LEN=*),
PARAMETER :: routinen =
'density_matrix_from_kp_to_transl'
1226 INTEGER :: handle, icell, ik, ik_global, xcell, &
1228 REAL(kind=
dp) :: arg, coskl, sinkl
1229 REAL(kind=
dp),
DIMENSION(:),
POINTER :: wkp
1230 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1232 TYPE(
dbcsr_type),
POINTER :: mat_work_im, mat_work_re
1235 CALL timeset(routinen, handle)
1239 NULLIFY (mat_work_re)
1242 template=mat_dm_global_work(1)%matrix, &
1243 matrix_type=dbcsr_type_no_symmetry)
1245 NULLIFY (mat_work_im)
1248 template=mat_dm_global_work(1)%matrix, &
1249 matrix_type=dbcsr_type_no_symmetry)
1256 cpassert(
SIZE(mat_dm_global_work) ==
SIZE(index_to_cell, 2))
1258 DO icell = 1,
SIZE(mat_dm_global_work)
1260 CALL dbcsr_set(mat_dm_global_work(icell)%matrix, 0.0_dp)
1264 DO ik = 1,
SIZE(kpoints%kp_env)
1266 kp => kpoints%kp_env(ik)%kpoint_env
1267 ik_global = kp%nkpoint
1268 CALL build_kpoint_density_matrix_rpa(kpoints, ik, ispin, tau, e_fermi, sector, density)
1274 DO icell = 1,
SIZE(mat_dm_global_work)
1276 xcell = index_to_cell(1, icell)
1277 ycell = index_to_cell(2, icell)
1278 zcell = index_to_cell(3, icell)
1280 arg = real(xcell,
dp)*xkp(1, ik_global) + real(ycell,
dp)*xkp(2, ik_global) + &
1281 REAL(zcell,
dp)*xkp(3, ik_global)
1282 coskl = wkp(ik_global)*cos(
twopi*arg)
1283 sinkl = wkp(ik_global)*sin(
twopi*arg)
1285 CALL dbcsr_add(mat_dm_global_work(icell)%matrix, mat_work_re, 1.0_dp, coskl)
1287 CALL dbcsr_add(mat_dm_global_work(icell)%matrix, mat_work_im, 1.0_dp, -sinkl)
1298 CALL timestop(handle)
1300 END SUBROUTINE density_matrix_from_kp_to_transl
1310 INTEGER,
DIMENSION(3),
INTENT(IN) :: cell_grid
1311 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1312 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
1313 TYPE(
cell_type),
INTENT(IN),
POINTER :: cell
1315 CHARACTER(LEN=*),
PARAMETER :: routinen =
'init_cell_index_rpa'
1317 INTEGER :: cell_counter, handle, i_cell, &
1318 index_min_dist, num_cells, xcell, &
1320 INTEGER,
DIMENSION(3) :: itm
1321 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell_unsorted
1322 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index_unsorted
1323 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: abs_cell_vectors
1324 REAL(kind=
dp),
DIMENSION(3) :: cell_vector
1325 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
1327 CALL timeset(routinen, handle)
1331 num_cells = cell_grid(1)*cell_grid(2)*cell_grid(3)
1332 itm(:) = cell_grid(:)/2
1336 cpassert(cell_grid(1) /= itm(1)*2)
1337 cpassert(cell_grid(2) /= itm(2)*2)
1338 cpassert(cell_grid(3) /= itm(3)*2)
1340 IF (
ASSOCIATED(cell_to_index))
DEALLOCATE (cell_to_index)
1341 IF (
ASSOCIATED(index_to_cell))
DEALLOCATE (index_to_cell)
1343 ALLOCATE (cell_to_index_unsorted(-itm(1):itm(1), -itm(2):itm(2), -itm(3):itm(3)))
1344 cell_to_index_unsorted(:, :, :) = 0
1346 ALLOCATE (index_to_cell_unsorted(3, num_cells))
1347 index_to_cell_unsorted(:, :) = 0
1349 ALLOCATE (cell_to_index(-itm(1):itm(1), -itm(2):itm(2), -itm(3):itm(3)))
1350 cell_to_index(:, :, :) = 0
1352 ALLOCATE (index_to_cell(3, num_cells))
1353 index_to_cell(:, :) = 0
1355 ALLOCATE (abs_cell_vectors(1:num_cells))
1359 DO xcell = -itm(1), itm(1)
1360 DO ycell = -itm(2), itm(2)
1361 DO zcell = -itm(3), itm(3)
1363 cell_counter = cell_counter + 1
1364 cell_to_index_unsorted(xcell, ycell, zcell) = cell_counter
1366 index_to_cell_unsorted(1, cell_counter) = xcell
1367 index_to_cell_unsorted(2, cell_counter) = ycell
1368 index_to_cell_unsorted(3, cell_counter) = zcell
1370 cell_vector(1:3) = matmul(hmat, real(index_to_cell_unsorted(1:3, cell_counter),
dp))
1372 abs_cell_vectors(cell_counter) = sqrt(cell_vector(1)**2 + cell_vector(2)**2 + cell_vector(3)**2)
1380 DO i_cell = 1, num_cells/2 + 1
1382 index_min_dist = minloc(abs_cell_vectors(1:num_cells/2 + 1), dim=1)
1384 xcell = index_to_cell_unsorted(1, index_min_dist)
1385 ycell = index_to_cell_unsorted(2, index_min_dist)
1386 zcell = index_to_cell_unsorted(3, index_min_dist)
1388 index_to_cell(1, i_cell) = xcell
1389 index_to_cell(2, i_cell) = ycell
1390 index_to_cell(3, i_cell) = zcell
1392 cell_to_index(xcell, ycell, zcell) = i_cell
1394 abs_cell_vectors(index_min_dist) = 10000000000.0_dp
1399 DO i_cell = num_cells/2 + 2, num_cells
1401 index_min_dist = minloc(abs_cell_vectors(1:num_cells), dim=1)
1403 xcell = index_to_cell_unsorted(1, index_min_dist)
1404 ycell = index_to_cell_unsorted(2, index_min_dist)
1405 zcell = index_to_cell_unsorted(3, index_min_dist)
1407 index_to_cell(1, i_cell) = xcell
1408 index_to_cell(2, i_cell) = ycell
1409 index_to_cell(3, i_cell) = zcell
1411 cell_to_index(xcell, ycell, zcell) = i_cell
1413 abs_cell_vectors(index_min_dist) = 10000000000.0_dp
1417 DEALLOCATE (index_to_cell_unsorted, cell_to_index_unsorted, abs_cell_vectors)
1419 CALL timestop(handle)
1434 SUBROUTINE get_diff_index_3c(i_cell_R, i_cell_S, i_cell_R_minus_S, index_to_cell_3c, &
1435 cell_to_index_3c, index_to_cell_dm, R_minus_S_needed, &
1436 do_kpoints_cubic_RPA)
1438 INTEGER,
INTENT(IN) :: i_cell_r, i_cell_s
1439 INTEGER,
INTENT(OUT) :: i_cell_r_minus_s
1440 INTEGER,
ALLOCATABLE,
DIMENSION(:, :),
INTENT(IN) :: index_to_cell_3c
1441 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :), &
1442 INTENT(IN) :: cell_to_index_3c
1443 INTEGER,
DIMENSION(:, :),
INTENT(IN),
POINTER :: index_to_cell_dm
1444 LOGICAL,
INTENT(OUT) :: r_minus_s_needed
1445 LOGICAL,
INTENT(IN) :: do_kpoints_cubic_rpa
1447 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_diff_index_3c'
1449 INTEGER :: handle, x_cell_r, x_cell_r_minus_s, x_cell_s, y_cell_r, y_cell_r_minus_s, &
1450 y_cell_s, z_cell_r, z_cell_r_minus_s, z_cell_s
1452 CALL timeset(routinen, handle)
1454 IF (do_kpoints_cubic_rpa)
THEN
1456 x_cell_r = index_to_cell_3c(1, i_cell_r)
1457 y_cell_r = index_to_cell_3c(2, i_cell_r)
1458 z_cell_r = index_to_cell_3c(3, i_cell_r)
1460 x_cell_s = index_to_cell_dm(1, i_cell_s)
1461 y_cell_s = index_to_cell_dm(2, i_cell_s)
1462 z_cell_s = index_to_cell_dm(3, i_cell_s)
1464 x_cell_r_minus_s = x_cell_r - x_cell_s
1465 y_cell_r_minus_s = y_cell_r - y_cell_s
1466 z_cell_r_minus_s = z_cell_r - z_cell_s
1468 IF (x_cell_r_minus_s >= lbound(cell_to_index_3c, 1) .AND. &
1469 x_cell_r_minus_s <= ubound(cell_to_index_3c, 1) .AND. &
1470 y_cell_r_minus_s >= lbound(cell_to_index_3c, 2) .AND. &
1471 y_cell_r_minus_s <= ubound(cell_to_index_3c, 2) .AND. &
1472 z_cell_r_minus_s >= lbound(cell_to_index_3c, 3) .AND. &
1473 z_cell_r_minus_s <= ubound(cell_to_index_3c, 3))
THEN
1475 i_cell_r_minus_s = cell_to_index_3c(x_cell_r_minus_s, y_cell_r_minus_s, z_cell_r_minus_s)
1478 IF (i_cell_r_minus_s == 0)
THEN
1480 r_minus_s_needed = .false.
1481 i_cell_r_minus_s = 0
1485 r_minus_s_needed = .true.
1491 i_cell_r_minus_s = 0
1492 r_minus_s_needed = .false.
1498 r_minus_s_needed = .true.
1499 i_cell_r_minus_s = 1
1503 CALL timestop(handle)
1505 END SUBROUTINE get_diff_index_3c
1519 SUBROUTINE get_diff_diff_index_3c(i_cell_R, i_cell_S, i_cell_T, i_cell_R_minus_S_minus_T, &
1520 index_to_cell_3c, cell_to_index_3c, index_to_cell_dm, &
1521 R_minus_S_minus_T_needed, &
1522 do_kpoints_cubic_RPA)
1524 INTEGER,
INTENT(IN) :: i_cell_r, i_cell_s, i_cell_t
1525 INTEGER,
INTENT(OUT) :: i_cell_r_minus_s_minus_t
1526 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: index_to_cell_3c
1527 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :), &
1528 INTENT(IN) :: cell_to_index_3c
1529 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: index_to_cell_dm
1530 LOGICAL,
INTENT(OUT) :: r_minus_s_minus_t_needed
1531 LOGICAL,
INTENT(IN) :: do_kpoints_cubic_rpa
1533 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_diff_diff_index_3c'
1535 INTEGER :: handle, x_cell_r, x_cell_r_minus_s_minus_t, x_cell_s, x_cell_t, y_cell_r, &
1536 y_cell_r_minus_s_minus_t, y_cell_s, y_cell_t, z_cell_r, z_cell_r_minus_s_minus_t, &
1539 CALL timeset(routinen, handle)
1541 IF (do_kpoints_cubic_rpa)
THEN
1543 x_cell_r = index_to_cell_3c(1, i_cell_r)
1544 y_cell_r = index_to_cell_3c(2, i_cell_r)
1545 z_cell_r = index_to_cell_3c(3, i_cell_r)
1547 x_cell_s = index_to_cell_dm(1, i_cell_s)
1548 y_cell_s = index_to_cell_dm(2, i_cell_s)
1549 z_cell_s = index_to_cell_dm(3, i_cell_s)
1551 x_cell_t = index_to_cell_dm(1, i_cell_t)
1552 y_cell_t = index_to_cell_dm(2, i_cell_t)
1553 z_cell_t = index_to_cell_dm(3, i_cell_t)
1555 x_cell_r_minus_s_minus_t = x_cell_r - x_cell_s - x_cell_t
1556 y_cell_r_minus_s_minus_t = y_cell_r - y_cell_s - y_cell_t
1557 z_cell_r_minus_s_minus_t = z_cell_r - z_cell_s - z_cell_t
1559 IF (x_cell_r_minus_s_minus_t >= lbound(cell_to_index_3c, 1) .AND. &
1560 x_cell_r_minus_s_minus_t <= ubound(cell_to_index_3c, 1) .AND. &
1561 y_cell_r_minus_s_minus_t >= lbound(cell_to_index_3c, 2) .AND. &
1562 y_cell_r_minus_s_minus_t <= ubound(cell_to_index_3c, 2) .AND. &
1563 z_cell_r_minus_s_minus_t >= lbound(cell_to_index_3c, 3) .AND. &
1564 z_cell_r_minus_s_minus_t <= ubound(cell_to_index_3c, 3))
THEN
1566 i_cell_r_minus_s_minus_t = cell_to_index_3c(x_cell_r_minus_s_minus_t, &
1567 y_cell_r_minus_s_minus_t, &
1568 z_cell_r_minus_s_minus_t)
1571 IF (i_cell_r_minus_s_minus_t == 0)
THEN
1573 r_minus_s_minus_t_needed = .false.
1577 r_minus_s_minus_t_needed = .true.
1583 i_cell_r_minus_s_minus_t = 0
1584 r_minus_s_minus_t_needed = .false.
1591 r_minus_s_minus_t_needed = .true.
1592 i_cell_r_minus_s_minus_t = 1
1596 CALL timestop(handle)
1598 END SUBROUTINE get_diff_diff_index_3c
Handles all functions related to the CELL.
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_column_scale(matrix_a, scaling, first_col, source)
Scales columns of the full matrix by corresponding factors.
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_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, matrix_struct, para_env)
Returns information about a full matrix.
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.
subroutine, public dbcsr_release_p(matrix)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
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_init_p(matrix)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_clear(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
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_reserve_all_blocks(matrix)
Reserves all blocks.
DBCSR operations in CP2K.
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_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_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
This is the start of a dbt_api, all publically needed functions are exported here....
Types and set/get functions for HFX.
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered, lattice_fft)
Retrieve information from a kpoint environment.
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
Interface to the message passing library MPI.
Types needed for MP2 calculations.
basic linear algebra operations for full matrixes
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, 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.
Definition and initialisation of the mo data type.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count, cmo_coeff)
Get the components of a MO set data structure.
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)
...
Utility methods to build 3-center integral tensors of various types.
subroutine, public decompress_tensor(tensor, blk_indices, compressed, eps)
...
subroutine, public get_tensor_occupancy(tensor, nze, occ)
...
Utility routines for RPA and 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_atom_index_from_basis_function_index(qs_env, atom_from_basis_index, basis_size, basis_type, first_bf_from_atom)
...
Routines for low-scaling RPA/GW with imaginary time.
subroutine, public create_propagator_matrix_set(propagator, ntime, matrix_template, index_to_cell)
Creates the sector-, time-, and cell-resolved propagator matrix set.
integer, parameter, public propagator_sector_virtual
subroutine, public compute_periodic_dm(propagator, qs_env, ispin, num_integ_points, jquad, e_fermi, tau, sector)
...
subroutine, public init_cell_index_rpa(cell_grid, cell_to_index, index_to_cell, cell)
...
integer, parameter, public propagator_sector_occupied
subroutine, public compute_mat_p_omega(mat_p_omega, fm_mo_coeff, homo, mat_p_global, matrix_s, ispin, t_3c_m, t_3c_o, t_3c_o_compressed, t_3c_o_ind, starts_array_mc, ends_array_mc, starts_array_mc_block, ends_array_mc_block, grid, e_fermi, eps_filter, alpha, eps_filter_im_time, eigenval, nmo, cut_memory, unit_nr, mp2_env, para_env, qs_env, do_kpoints_from_gamma, index_to_cell_3c, cell_to_index_3c, has_mat_p_blocks, do_ri_sos_laplace_mp2, dbcsr_time, dbcsr_nflop)
...
subroutine, public compute_gamma_propagator(propagator, jquad, fm_mo_coeff, homo, eigenval, nmo, eps_filter, e_fermi, tau, para_env)
Builds the Gamma-point occupied and virtual propagators.
subroutine, public compute_transl_dm(propagator, qs_env, ispin, num_integ_points, jquad, e_fermi, tau, eps_filter, num_cells_dm, index_to_cell_dm, sector)
...
subroutine, public compute_mat_dm_global(grid, nmo, fm_mo_coeff, homo, propagator, matrix_s, ispin, eigenval, e_fermi, eps_filter, memory_info, unit_nr, jquad, do_kpoints_cubic_rpa, do_kpoints_from_gamma, qs_env, num_cells_dm, index_to_cell_dm, para_env)
...
integer, parameter, public propagator_number_of_sectors
Definition and construction of time/frequency grids for correlation methods.
Type defining parameters related to the simulation cell.
Represent a complex full matrix.
Keeps information about a specific k-point.
Contains information about kpoints.
stores all the informations relevant to an mpi environment