95#include "./base/base_uses.f90"
101 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'gw_tensor_large_cell_Gamma'
122 CHARACTER(LEN=*),
PARAMETER :: routinen =
'gw_calc_tensor_large_cell_Gamma'
125 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma, fm_w_mic_time
126 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
128 CALL timeset(routinen, handle)
135 CALL get_mat_chi_gamma_tau(bs_env, qs_env, bs_env%mat_chi_Gamma_tau)
138 CALL get_w_mic(bs_env, qs_env, bs_env%mat_chi_Gamma_tau, fm_w_mic_time)
142 CALL get_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
146 CALL get_sigma_c(bs_env, qs_env, fm_w_mic_time, fm_sigma_c_gamma_time)
153 CALL timestop(handle)
163 SUBROUTINE get_mat_chi_gamma_tau(bs_env, qs_env, mat_chi_Gamma_tau)
166 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
168 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_mat_chi_Gamma_tau'
170 INTEGER :: handle, i_intval_idx, i_t, inner_loop_atoms_interval_index, ispin, j_intval_idx
171 INTEGER(KIND=int_8) :: flop
172 INTEGER,
DIMENSION(2) :: bounds_p, bounds_q, i_atoms, il_atoms, &
174 INTEGER,
DIMENSION(2, 2) :: bounds_comb
175 LOGICAL :: dist_too_long_i, dist_too_long_j
176 REAL(kind=
dp) :: t1, tau
177 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
178 t_3c_for_gvir, t_3c_x_gocc, &
179 t_3c_x_gocc_2, t_3c_x_gvir, &
182 CALL timeset(routinen, handle)
184 DO i_t = 1, bs_env%num_time_freq_points
188 IF (bs_env%read_chi(i_t))
THEN
190 CALL fm_read(bs_env%fm_RI_RI, bs_env, bs_env%chi_name, i_t)
193 keep_sparsity=.false.)
195 IF (bs_env%unit_nr > 0)
THEN
196 WRITE (bs_env%unit_nr,
'(T2,A,I5,A,I3,A,F10.1,A)') &
197 'Read χ(iτ,k=0) from file for time point ', i_t,
' /', &
198 bs_env%num_time_freq_points, &
206 IF (.NOT. bs_env%calc_chi(i_t)) cycle
208 CALL create_tensors_chi(t_2c_gocc, t_2c_gvir, t_3c_for_gocc, t_3c_for_gvir, &
209 t_3c_x_gocc, t_3c_x_gvir, t_3c_x_gocc_2, t_3c_x_gvir_2, bs_env)
215 tau = bs_env%time_frequency_grid%imaginary_time(i_t)
217 DO ispin = 1, bs_env%n_spin
218 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gocc, ispin, occ=.true., vir=.false.)
219 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gvir, ispin, occ=.false., vir=.true.)
222 bs_env%mat_ao_ao_tensor%matrix, t_2c_gocc, bs_env, &
223 bs_env%atoms_j_t_group)
225 bs_env%mat_ao_ao_tensor%matrix, t_2c_gvir, bs_env, &
226 bs_env%atoms_i_t_group)
230 DO i_intval_idx = 1, bs_env%n_intervals_i
231 DO j_intval_idx = 1, bs_env%n_intervals_j
232 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
233 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
235 IF (bs_env%skip_chi(i_intval_idx, j_intval_idx))
THEN
239 bs_env%n_skip_chi = bs_env%n_skip_chi + 1
244 DO inner_loop_atoms_interval_index = 1, bs_env%n_intervals_inner_loop_atoms
246 il_atoms = bs_env%inner_loop_atom_intervals(1:2, inner_loop_atoms_interval_index)
252 CALL check_dist(i_atoms, il_atoms, qs_env, bs_env, dist_too_long_i)
253 CALL check_dist(j_atoms, il_atoms, qs_env, bs_env, dist_too_long_j)
254 IF (.NOT. dist_too_long_i)
THEN
257 atoms_ao_1=i_atoms, atoms_ao_2=il_atoms)
259 CALL g_times_3c(t_3c_for_gocc, t_2c_gocc, t_3c_x_gocc, bs_env, &
260 j_atoms, i_atoms, il_atoms)
262 IF (.NOT. dist_too_long_j)
THEN
265 atoms_ao_1=j_atoms, atoms_ao_2=il_atoms)
267 CALL g_times_3c(t_3c_for_gvir, t_2c_gvir, t_3c_x_gvir, bs_env, &
268 i_atoms, j_atoms, il_atoms)
273 CALL dbt_copy(t_3c_x_gocc, t_3c_x_gocc_2, move_data=.true., order=[1, 3, 2])
274 CALL dbt_copy(t_3c_x_gvir, t_3c_x_gvir_2, move_data=.true.)
283 bounds_comb(1:2, 1) = [bs_env%i_ao_start_from_atom(j_atoms(1)), &
284 bs_env%i_ao_end_from_atom(j_atoms(2))]
285 bounds_comb(1:2, 2) = [bs_env%i_ao_start_from_atom(i_atoms(1)), &
286 bs_env%i_ao_end_from_atom(i_atoms(2))]
288 CALL get_bounds_from_atoms(bounds_p, i_atoms, [1, bs_env%n_atom], &
289 bs_env%min_RI_idx_from_AO_AO_atom, &
290 bs_env%max_RI_idx_from_AO_AO_atom)
291 CALL get_bounds_from_atoms(bounds_q, [1, bs_env%n_atom], j_atoms, &
292 bs_env%min_RI_idx_from_AO_AO_atom, &
293 bs_env%max_RI_idx_from_AO_AO_atom)
295 IF (bounds_q(1) > bounds_q(2) .OR. bounds_p(1) > bounds_p(2))
THEN
298 CALL dbt_contract(alpha=bs_env%spin_degeneracy, &
299 tensor_1=t_3c_x_gocc_2, tensor_2=t_3c_x_gvir_2, &
300 beta=1.0_dp, tensor_3=bs_env%t_chi, &
301 contract_1=[2, 3], notcontract_1=[1], map_1=[1], &
302 contract_2=[2, 3], notcontract_2=[1], map_2=[2], &
303 bounds_1=bounds_comb, &
306 filter_eps=bs_env%eps_filter, move_data=.false., flop=flop)
308 IF (flop == 0_int_8) bs_env%skip_chi(i_intval_idx, j_intval_idx) = .true.
318 mat_chi_gamma_tau(i_t)%matrix, bs_env%para_env)
320 CALL write_matrix(mat_chi_gamma_tau(i_t)%matrix, i_t, bs_env%chi_name, &
321 bs_env%fm_RI_RI, qs_env)
323 CALL destroy_tensors_chi(t_2c_gocc, t_2c_gvir, t_3c_for_gocc, t_3c_for_gvir, &
324 t_3c_x_gocc, t_3c_x_gvir, t_3c_x_gocc_2, t_3c_x_gvir_2)
326 IF (bs_env%unit_nr > 0)
THEN
327 WRITE (bs_env%unit_nr,
'(T2,A,I13,A,I3,A,F10.1,A)') &
328 'Computed χ(iτ,k=0) for time point', i_t,
' /', bs_env%num_time_freq_points, &
334 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
336 CALL timestop(handle)
338 END SUBROUTINE get_mat_chi_gamma_tau
350 CHARACTER(LEN=*) :: mat_name
353 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_read'
355 CHARACTER(LEN=default_path_length) :: f_chi
356 INTEGER :: handle, unit_nr
358 CALL timeset(routinen, handle)
361 IF (bs_env%para_env%is_source())
THEN
364 WRITE (f_chi,
'(3A,I1,A)') trim(bs_env%prefix), trim(mat_name),
"_0",
idx,
".matrix"
365 ELSE IF (
idx < 100)
THEN
366 WRITE (f_chi,
'(3A,I2,A)') trim(bs_env%prefix), trim(mat_name),
"_",
idx,
".matrix"
368 cpabort(
'Please implement more than 99 time/frequency points.')
371 CALL open_file(file_name=trim(f_chi), file_action=
"READ", file_form=
"UNFORMATTED", &
372 file_position=
"REWIND", file_status=
"OLD", unit_number=unit_nr)
378 IF (bs_env%para_env%is_source())
CALL close_file(unit_number=unit_nr)
380 CALL timestop(handle)
396 SUBROUTINE create_tensors_chi(t_2c_Gocc, t_2c_Gvir, t_3c_for_Gocc, t_3c_for_Gvir, &
397 t_3c_x_Gocc, t_3c_x_Gvir, t_3c_x_Gocc_2, t_3c_x_Gvir_2, bs_env)
399 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
400 t_3c_for_gvir, t_3c_x_gocc, &
401 t_3c_x_gvir, t_3c_x_gocc_2, &
405 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_tensors_chi'
409 CALL timeset(routinen, handle)
411 CALL dbt_create(bs_env%t_G, t_2c_gocc, name=
"Gocc 2c (AO|AO)")
412 CALL dbt_create(bs_env%t_G, t_2c_gvir, name=
"Gvir 2c (AO|AO)")
413 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_gocc, name=
"Gocc 3c (RI AO|AO)")
414 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_gvir, name=
"Gvir 3c (RI AO|AO)")
415 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_gocc, name=
"xGocc 3c (RI AO|AO)")
416 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_gvir, name=
"xGvir 3c (RI AO|AO)")
417 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_gocc_2, name=
"x2Gocc 3c (RI AO|AO)")
418 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_gvir_2, name=
"x2Gvir 3c (RI AO|AO)")
420 CALL timestop(handle)
422 END SUBROUTINE create_tensors_chi
435 SUBROUTINE destroy_tensors_chi(t_2c_Gocc, t_2c_Gvir, t_3c_for_Gocc, t_3c_for_Gvir, &
436 t_3c_x_Gocc, t_3c_x_Gvir, t_3c_x_Gocc_2, t_3c_x_Gvir_2)
437 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
438 t_3c_for_gvir, t_3c_x_gocc, &
439 t_3c_x_gvir, t_3c_x_gocc_2, &
442 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_tensors_chi'
446 CALL timeset(routinen, handle)
448 CALL dbt_destroy(t_2c_gocc)
449 CALL dbt_destroy(t_2c_gvir)
450 CALL dbt_destroy(t_3c_for_gocc)
451 CALL dbt_destroy(t_3c_for_gvir)
452 CALL dbt_destroy(t_3c_x_gocc)
453 CALL dbt_destroy(t_3c_x_gvir)
454 CALL dbt_destroy(t_3c_x_gocc_2)
455 CALL dbt_destroy(t_3c_x_gvir_2)
457 CALL timestop(handle)
459 END SUBROUTINE destroy_tensors_chi
471 INTEGER :: matrix_index
472 CHARACTER(LEN=*) :: matrix_name
476 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_matrix'
480 CALL timeset(routinen, handle)
486 CALL fm_write(fm, matrix_index, matrix_name, qs_env)
488 CALL timestop(handle)
499 SUBROUTINE fm_write(fm, matrix_index, matrix_name, qs_env)
501 INTEGER :: matrix_index
502 CHARACTER(LEN=*) :: matrix_name
505 CHARACTER(LEN=*),
PARAMETER :: key =
'PROPERTIES%BANDSTRUCTURE%GW%PRINT%RESTART', &
506 routinen =
'fm_write'
508 CHARACTER(LEN=default_path_length) :: filename
509 INTEGER :: handle, unit_nr
513 CALL timeset(routinen, handle)
521 IF (matrix_index < 10)
THEN
522 WRITE (filename,
'(3A,I1)')
"RESTART_", matrix_name,
"_0", matrix_index
523 ELSE IF (matrix_index < 100)
THEN
524 WRITE (filename,
'(3A,I2)')
"RESTART_", matrix_name,
"_", matrix_index
526 cpabort(
'Please implement more than 99 time/frequency points.')
530 file_form=
"UNFORMATTED", middle_name=trim(filename), &
531 file_position=
"REWIND", file_action=
"WRITE")
534 IF (unit_nr > 0)
THEN
539 CALL timestop(handle)
552 SUBROUTINE g_occ_vir(bs_env, tau, fm_G_Gamma, ispin, occ, vir)
559 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_occ_vir'
561 INTEGER :: handle, homo, i_row_local, j_col, &
562 j_col_local, n_mo, ncol_local, &
564 INTEGER,
DIMENSION(:),
POINTER :: col_indices
565 REAL(kind=
dp) :: tau_e
567 CALL timeset(routinen, handle)
569 cpassert(occ .NEQV. vir)
572 nrow_local=nrow_local, &
573 ncol_local=ncol_local, &
574 col_indices=col_indices)
577 homo = bs_env%n_occ(ispin)
579 CALL cp_fm_to_fm(bs_env%fm_mo_coeff_Gamma(ispin), bs_env%fm_work_mo(1))
581 DO i_row_local = 1, nrow_local
582 DO j_col_local = 1, ncol_local
584 j_col = col_indices(j_col_local)
586 tau_e = abs(tau*0.5_dp*(bs_env%eigenval_scf_Gamma(j_col, ispin) - bs_env%e_fermi(ispin)))
588 IF (tau_e < bs_env%stabilize_exp)
THEN
589 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = &
590 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local)*exp(-tau_e)
592 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = 0.0_dp
595 IF ((occ .AND. j_col > homo) .OR. (vir .AND. j_col <= homo))
THEN
596 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = 0.0_dp
602 CALL parallel_gemm(transa=
"N", transb=
"T", m=n_mo, n=n_mo, k=n_mo, alpha=1.0_dp, &
603 matrix_a=bs_env%fm_work_mo(1), matrix_b=bs_env%fm_work_mo(1), &
604 beta=0.0_dp, matrix_c=fm_g_gamma)
606 CALL timestop(handle)
622 TYPE(dbt_type) :: t_3c
623 INTEGER,
DIMENSION(2),
OPTIONAL :: atoms_ao_1, atoms_ao_2, atoms_ri
625 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_3c_integrals'
628 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_3c_array
630 CALL timeset(routinen, handle)
635 ALLOCATE (t_3c_array(1, 1))
636 CALL dbt_create(t_3c, t_3c_array(1, 1))
642 int_eps=bs_env%eps_filter, &
643 basis_i=bs_env%basis_set_RI, &
644 basis_j=bs_env%basis_set_AO, &
645 basis_k=bs_env%basis_set_AO, &
646 potential_parameter=bs_env%ri_metric, &
648 bounds_j=atoms_ao_1, &
649 bounds_k=atoms_ao_2, &
650 desymmetrize=.false.)
652 CALL dbt_filter(t_3c_array(1, 1), bs_env%eps_filter)
654 CALL dbt_copy(t_3c_array(1, 1), t_3c, move_data=.true.)
656 CALL dbt_destroy(t_3c_array(1, 1))
657 DEALLOCATE (t_3c_array)
659 CALL timestop(handle)
673 SUBROUTINE g_times_3c(t_3c_for_G, t_G, t_M, bs_env, atoms_AO_1, atoms_AO_2, atoms_IL)
674 TYPE(dbt_type) :: t_3c_for_g, t_g, t_m
676 INTEGER,
DIMENSION(2) :: atoms_ao_1, atoms_ao_2, atoms_il
678 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_times_3c'
681 INTEGER(KIND=int_8) :: flop
682 INTEGER,
DIMENSION(2) :: bounds_ao_1, bounds_il
683 INTEGER,
DIMENSION(2, 2) :: bounds_comb
685 CALL timeset(routinen, handle)
696 CALL get_bounds_from_atoms(bounds_il, [1, bs_env%n_atom], atoms_ao_2, &
697 bs_env%min_AO_idx_from_RI_AO_atom, &
698 bs_env%max_AO_idx_from_RI_AO_atom, &
700 indices_3_start=bs_env%i_ao_start_from_atom, &
701 indices_3_end=bs_env%i_ao_end_from_atom)
704 CALL get_bounds_from_atoms(bounds_comb(:, 1), atoms_il, atoms_ao_2, &
705 bs_env%min_RI_idx_from_AO_AO_atom, &
706 bs_env%max_RI_idx_from_AO_AO_atom)
709 CALL get_bounds_from_atoms(bounds_comb(:, 2), [1, bs_env%n_atom], atoms_il, &
710 bs_env%min_AO_idx_from_RI_AO_atom, &
711 bs_env%max_AO_idx_from_RI_AO_atom, &
712 atoms_3=atoms_ao_2, &
713 indices_3_start=bs_env%i_ao_start_from_atom, &
714 indices_3_end=bs_env%i_ao_end_from_atom)
717 bounds_ao_1(1:2) = [bs_env%i_ao_start_from_atom(atoms_ao_1(1)), &
718 bs_env%i_ao_end_from_atom(atoms_ao_1(2))]
720 IF (bounds_il(1) > bounds_il(2) .OR. bounds_comb(1, 2) > bounds_comb(2, 2))
THEN
723 CALL dbt_contract(alpha=1.0_dp, &
724 tensor_1=t_3c_for_g, &
728 contract_1=[3], notcontract_1=[1, 2], map_1=[1, 2], &
729 contract_2=[2], notcontract_2=[1], map_2=[3], &
730 bounds_1=bounds_il, &
731 bounds_2=bounds_comb, &
732 bounds_3=bounds_ao_1, &
734 filter_eps=bs_env%eps_filter)
737 CALL dbt_clear(t_3c_for_g)
739 CALL timestop(handle)
741 END SUBROUTINE g_times_3c
751 SUBROUTINE check_dist(atoms_1, atoms_2, qs_env, bs_env, dist_too_long)
752 INTEGER,
DIMENSION(2) :: atoms_1, atoms_2
755 LOGICAL :: dist_too_long
757 CHARACTER(LEN=*),
PARAMETER :: routinen =
'check_dist'
759 INTEGER :: atom_1, atom_2, handle
760 REAL(
dp) :: abs_rab, min_dist_ao_atoms
761 REAL(kind=
dp),
DIMENSION(3) :: rab
765 CALL timeset(routinen, handle)
767 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
769 min_dist_ao_atoms = huge(1.0_dp)
770 DO atom_1 = atoms_1(1), atoms_1(2)
771 DO atom_2 = atoms_2(1), atoms_2(2)
772 rab =
pbc(particle_set(atom_1)%r(1:3), particle_set(atom_2)%r(1:3), cell)
774 abs_rab = sqrt(rab(1)**2 + rab(2)**2 + rab(3)**2)
776 min_dist_ao_atoms = min(min_dist_ao_atoms, abs_rab)
780 dist_too_long = (min_dist_ao_atoms > bs_env%max_dist_AO_atoms)
782 CALL timestop(handle)
784 END SUBROUTINE check_dist
793 SUBROUTINE get_w_mic(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
796 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
797 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
799 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_W_MIC'
803 CALL timeset(routinen, handle)
805 IF (bs_env%all_W_exist)
THEN
806 CALL read_w_mic_time(bs_env, mat_chi_gamma_tau, fm_w_mic_time)
808 CALL compute_w_mic(bs_env, qs_env, mat_chi_gamma_tau, fm_w_mic_time)
811 CALL timestop(handle)
822 SUBROUTINE compute_v_k_by_lattice_sum(bs_env, qs_env, cfm_V_kp, ikp_batch)
825 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: cfm_v_kp
828 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_V_k_by_lattice_sum'
830 INTEGER :: handle, ikp, ikp_end, ikp_start, &
831 nkp_chi_eps_w_batch, re_im
835 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_v_kp
837 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
839 CALL timeset(routinen, handle)
841 nkp_chi_eps_w_batch = bs_env%nkp_chi_eps_W_batch
843 ikp_start = (ikp_batch - 1)*bs_env%nkp_chi_eps_W_batch + 1
844 ikp_end = min(ikp_batch*bs_env%nkp_chi_eps_W_batch, bs_env%kpoints_chi_eps_W%nkp)
847 ALLOCATE (mat_v_kp(ikp_start:ikp_end, 2))
850 DO ikp = ikp_start, ikp_end
851 NULLIFY (mat_v_kp(ikp, re_im)%matrix)
852 ALLOCATE (mat_v_kp(ikp, re_im)%matrix)
853 CALL dbcsr_create(mat_v_kp(ikp, re_im)%matrix, template=bs_env%mat_RI_RI%matrix)
855 CALL dbcsr_set(mat_v_kp(ikp, re_im)%matrix, 0.0_dp)
860 particle_set=particle_set, &
862 qs_kind_set=qs_kind_set, &
863 atomic_kind_set=atomic_kind_set)
865 IF (ikp_end <= bs_env%nkp_chi_eps_W_orig)
THEN
868 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
870 ELSE IF (ikp_start > bs_env%nkp_chi_eps_W_orig .AND. &
871 ikp_end <= bs_env%nkp_chi_eps_W_orig_plus_extra)
THEN
874 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_extra
878 cpabort(
"Error with k-point parallelization.")
883 bs_env%kpoints_chi_eps_W, &
884 basis_type=
"RI_AUX", &
886 particle_set=particle_set, &
887 qs_kind_set=qs_kind_set, &
888 atomic_kind_set=atomic_kind_set, &
889 size_lattice_sum=bs_env%size_lattice_sum_V, &
891 ikp_start=ikp_start, &
894 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
896 ALLOCATE (cfm_v_kp(ikp_start:ikp_end))
897 CALL cp_fm_create(fm_v_kp_work, bs_env%fm_RI_RI%matrix_struct)
898 DO ikp = ikp_start, ikp_end
899 CALL cp_cfm_create(cfm_v_kp(ikp), bs_env%fm_RI_RI%matrix_struct)
902 cfm_v_kp(ikp)%local_data = cmplx(fm_v_kp_work%local_data, 0.0_dp, kind=
dp)
906 cfm_v_kp(ikp)%local_data = cmplx(real(cfm_v_kp(ikp)%local_data, kind=
dp), &
907 fm_v_kp_work%local_data, kind=
dp)
912 CALL timestop(handle)
914 END SUBROUTINE compute_v_k_by_lattice_sum
925 SUBROUTINE compute_minvvsqrt_vsqrt(bs_env, qs_env, cfm_V_kp, cfm_V_sqrt_ikp, &
926 cfm_M_inv_V_sqrt_ikp, ikp)
929 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: cfm_v_kp
930 TYPE(
cp_cfm_type) :: cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp
933 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_MinvVsqrt_Vsqrt'
935 INTEGER :: handle, info, n_ri
937 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: cfm_m_ikp
939 CALL timeset(routinen, handle)
945 bs_env%kpoints_chi_eps_W, regularization_ri=bs_env%regularization_RI, &
946 ikp_ext=ikp, do_build_cell_index=(ikp == 1))
949 CALL cp_cfm_create(cfm_v_sqrt_ikp, cfm_v_kp(ikp)%matrix_struct)
950 CALL cp_cfm_create(cfm_m_inv_v_sqrt_ikp, cfm_v_kp(ikp)%matrix_struct)
952 CALL cp_cfm_create(cfm_m_inv_ikp, cfm_v_kp(ikp)%matrix_struct)
958 DEALLOCATE (cfm_m_ikp)
972 CALL cp_cfm_power(cfm_work, threshold=bs_env%eps_eigval_mat_RI, exponent=-1.0_dp)
981 CALL clean_lower_part(cfm_v_sqrt_ikp)
984 CALL cp_cfm_power(cfm_work, threshold=0.0_dp, exponent=0.5_dp)
990 CALL parallel_gemm(
"N",
"C", n_ri, n_ri, n_ri,
z_one, cfm_m_inv_ikp, cfm_v_sqrt_ikp, &
991 z_zero, cfm_m_inv_v_sqrt_ikp)
995 CALL timestop(handle)
997 END SUBROUTINE compute_minvvsqrt_vsqrt
1006 SUBROUTINE compute_cfm_w_ikp_freq_j(bs_env, cfm_chi_eps_W_ikp_freq_j, cfm_V_sqrt_ikp, &
1007 cfm_M_inv_V_sqrt_ikp)
1009 TYPE(
cp_cfm_type),
INTENT(INOUT) :: cfm_chi_eps_w_ikp_freq_j
1010 TYPE(
cp_cfm_type),
INTENT(IN) :: cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp
1012 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_cfm_W_ikp_freq_j'
1014 INTEGER :: handle, info
1016 CALL timeset(routinen, handle)
1035 CALL timestop(handle)
1037 END SUBROUTINE compute_cfm_w_ikp_freq_j
1045 SUBROUTINE read_w_mic_time(bs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
1047 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1048 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1050 CHARACTER(LEN=*),
PARAMETER :: routinen =
'read_W_MIC_time'
1052 INTEGER :: handle, i_t
1055 CALL timeset(routinen, handle)
1060 DO i_t = 1, bs_env%num_time_freq_points
1064 CALL fm_read(fm_w_mic_time(i_t), bs_env, bs_env%W_time_name, i_t)
1066 IF (bs_env%unit_nr > 0)
THEN
1067 WRITE (bs_env%unit_nr,
'(T2,A,I5,A,I3,A,F10.1,A)') &
1068 'Read W^MIC(iτ) from file for time point ', i_t,
' /', bs_env%num_time_freq_points, &
1074 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
1086 CALL cp_fm_create(bs_env%fm_W_MIC_freq_zero, bs_env%fm_W_MIC_freq%matrix_struct)
1088 CALL fm_read(bs_env%fm_W_MIC_freq_zero, bs_env,
"W_freq_rtp", 0)
1089 IF (bs_env%unit_nr > 0)
THEN
1090 WRITE (bs_env%unit_nr,
'(T2,A,I3,A,I3,A,F10.1,A)') &
1091 'Read W^MIC(f=0) from file for freq. point ', 1,
' /', 1, &
1096 CALL timestop(handle)
1098 END SUBROUTINE read_w_mic_time
1107 SUBROUTINE compute_w_mic(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
1110 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1111 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1113 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_W_MIC'
1115 INTEGER :: handle, i_t, ikp, ikp_batch, &
1118 TYPE(
cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
1119 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: cfm_v_kp
1121 CALL timeset(routinen, handle)
1125 DO ikp_batch = 1, bs_env%num_chi_eps_W_batches
1130 CALL compute_v_k_by_lattice_sum(bs_env, qs_env, cfm_v_kp, ikp_batch)
1132 DO ikp_in_batch = 1, bs_env%nkp_chi_eps_W_batch
1134 ikp = (ikp_batch - 1)*bs_env%nkp_chi_eps_W_batch + ikp_in_batch
1136 IF (ikp > bs_env%nkp_chi_eps_W_orig_plus_extra)
THEN
1140 CALL compute_minvvsqrt_vsqrt(bs_env, qs_env, cfm_v_kp, &
1141 cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp, ikp)
1143 CALL bs_env%para_env%sync()
1146 DO j_w = 1, bs_env%num_time_freq_points
1149 IF (bs_env%approx_kp_extrapol .AND. j_w > 1 .AND. &
1150 ikp > bs_env%nkp_chi_eps_W_orig) cycle
1152 CALL compute_fm_w_mic_freq_j(bs_env, qs_env, bs_env%fm_W_MIC_freq, j_w, ikp, &
1153 mat_chi_gamma_tau, cfm_m_inv_v_sqrt_ikp, &
1163 DEALLOCATE (cfm_v_kp)
1165 IF (bs_env%unit_nr > 0)
THEN
1166 WRITE (bs_env%unit_nr,
'(T2,A,I12,A,I3,A,F10.1,A)') &
1167 'Computed W(iτ,k) for k-point batch', &
1168 ikp_batch,
' /', bs_env%num_chi_eps_W_batches, &
1174 IF (bs_env%approx_kp_extrapol)
THEN
1175 CALL apply_extrapol_factor(bs_env, fm_w_mic_time)
1181 DO i_t = 1, bs_env%num_time_freq_points
1182 CALL fm_write(fm_w_mic_time(i_t), i_t, bs_env%W_time_name, qs_env)
1194 CALL cp_fm_create(bs_env%fm_W_MIC_freq_zero, bs_env%fm_W_MIC_freq%matrix_struct)
1198 DO i_t = 1, bs_env%num_time_freq_points
1201 bs_env%time_frequency_grid%time_weights_at_zero_frequency(i_t), fm_w_mic_time(i_t))
1204 CALL fm_write(bs_env%fm_W_MIC_freq_zero, 0,
"W_freq_rtp", qs_env)
1206 IF (bs_env%unit_nr > 0)
THEN
1207 WRITE (bs_env%unit_nr,
'(T2,A,I11,A,I3,A,F10.1,A)') &
1208 'Computed W(f=0,k) for k-point batch', &
1214 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
1216 CALL timestop(handle)
1218 END SUBROUTINE compute_w_mic
1231 SUBROUTINE compute_fm_w_mic_freq_j(bs_env, qs_env, fm_W_MIC_freq_j, j_w, ikp, mat_chi_Gamma_tau, &
1232 cfm_M_inv_V_sqrt_ikp, cfm_V_sqrt_ikp)
1237 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1238 TYPE(
cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
1240 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_W_MIC_freq_j'
1245 CALL timeset(routinen, handle)
1254 ikp, qs_env, bs_env%kpoints_chi_eps_W,
"RI_AUX")
1257 CALL cp_cfm_power(cfm_chi_eps_w_ikp_freq_j, threshold=0.0_dp, exponent=1.0_dp)
1260 CALL compute_cfm_w_ikp_freq_j(bs_env, cfm_chi_eps_w_ikp_freq_j, cfm_v_sqrt_ikp, &
1261 cfm_m_inv_v_sqrt_ikp)
1264 SELECT CASE (bs_env%approx_kp_extrapol)
1268 cfm_chi_eps_w_ikp_freq_j, ikp, &
1269 bs_env%kpoints_chi_eps_W,
"RI_AUX")
1280 cfm_chi_eps_w_ikp_freq_j, ikp, &
1281 bs_env%kpoints_chi_eps_W, &
1284 IF (ikp <= bs_env%nkp_chi_eps_W_orig)
THEN
1286 cfm_chi_eps_w_ikp_freq_j, ikp, &
1287 bs_env%kpoints_chi_eps_W, &
1288 "RI_AUX", wkp_ext=bs_env%wkp_orig)
1294 IF (ikp <= bs_env%nkp_chi_eps_W_orig)
THEN
1296 cfm_chi_eps_w_ikp_freq_j, &
1297 ikp, bs_env%kpoints_chi_eps_W,
"RI_AUX", &
1298 wkp_ext=bs_env%wkp_orig)
1304 CALL timestop(handle)
1306 END SUBROUTINE compute_fm_w_mic_freq_j
1312 SUBROUTINE clean_lower_part(cfm_mat)
1315 CHARACTER(LEN=*),
PARAMETER :: routinen =
'clean_lower_part'
1317 INTEGER :: handle, i_row, j_col, j_global, &
1318 ncol_local, nrow_local
1319 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
1321 CALL timeset(routinen, handle)
1324 nrow_local=nrow_local, ncol_local=ncol_local, &
1325 row_indices=row_indices, col_indices=col_indices)
1327 DO j_col = 1, ncol_local
1328 j_global = col_indices(j_col)
1329 DO i_row = 1, nrow_local
1330 IF (j_global < row_indices(i_row)) cfm_mat%local_data(i_row, j_col) =
z_zero
1334 CALL timestop(handle)
1336 END SUBROUTINE clean_lower_part
1343 SUBROUTINE apply_extrapol_factor(bs_env, fm_W_MIC_time)
1345 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1347 CHARACTER(LEN=*),
PARAMETER :: routinen =
'apply_extrapol_factor'
1348 REAL(kind=
dp),
PARAMETER :: eps_w_no_extra_1 = 1.0e-13_dp
1350 INTEGER :: handle, i, i_t, j, ncol_local, nrow_local
1351 REAL(kind=
dp) :: extrapol_factor, w_extra_1, w_no_extra_1
1353 CALL timeset(routinen, handle)
1355 CALL cp_fm_get_info(matrix=fm_w_mic_time(1), nrow_local=nrow_local, ncol_local=ncol_local)
1357 DO i_t = 1, bs_env%num_time_freq_points
1358 DO j = 1, ncol_local
1359 DO i = 1, nrow_local
1361 w_extra_1 = bs_env%fm_W_MIC_freq_1_extra%local_data(i, j)
1362 w_no_extra_1 = bs_env%fm_W_MIC_freq_1_no_extra%local_data(i, j)
1364 IF (abs(w_no_extra_1) > eps_w_no_extra_1)
THEN
1365 extrapol_factor = abs(w_extra_1/w_no_extra_1)
1367 extrapol_factor = 1.0_dp
1371 IF (extrapol_factor > 10.0_dp) extrapol_factor = 1.0_dp
1373 fm_w_mic_time(i_t)%local_data(i, j) = fm_w_mic_time(i_t)%local_data(i, j) &
1379 CALL timestop(handle)
1381 END SUBROUTINE apply_extrapol_factor
1394 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1396 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_chi_Gamma_freq'
1398 INTEGER :: handle, i_t
1399 REAL(kind=
dp) :: freq_j, time_i, weight_ij
1401 CALL timeset(routinen, handle)
1403 CALL dbcsr_set(bs_env%mat_RI_RI%matrix, 0.0_dp)
1405 freq_j = bs_env%time_frequency_grid%frequency(j_w)
1407 DO i_t = 1, bs_env%num_time_freq_points
1409 time_i = bs_env%time_frequency_grid%imaginary_time(i_t)
1410 weight_ij = bs_env%time_frequency_grid%cosine_time_to_frequency_weights(j_w, i_t)
1413 CALL dbcsr_add(bs_env%mat_RI_RI%matrix, mat_chi_gamma_tau(i_t)%matrix, &
1414 1.0_dp, cos(time_i*freq_j)*weight_ij)
1420 CALL timestop(handle)
1433 SUBROUTINE mat_ikp_from_mat_gamma(mat_ikp_re, mat_ikp_im, mat_Gamma, kpoints, ikp, qs_env)
1434 TYPE(
dbcsr_type) :: mat_ikp_re, mat_ikp_im, mat_gamma
1439 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mat_ikp_from_mat_Gamma'
1441 INTEGER :: col, handle, i_cell, j_cell, num_cells, &
1443 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
1444 LOGICAL :: f, i_cell_is_the_minimum_image_cell
1445 REAL(kind=
dp) :: abs_rab_cell_i, abs_rab_cell_j, arg
1446 REAL(kind=
dp),
DIMENSION(3) :: cell_vector, cell_vector_j, rab_cell_i, &
1448 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
1449 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: block_im, block_re, data_block
1454 CALL timeset(routinen, handle)
1462 NULLIFY (cell, particle_set)
1463 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
1466 index_to_cell => kpoints%index_to_cell
1468 num_cells =
SIZE(index_to_cell, 2)
1470 DO i_cell = 1, num_cells
1476 cell_vector(1:3) = matmul(hmat, real(index_to_cell(1:3, i_cell),
dp))
1478 rab_cell_i(1:3) =
pbc(particle_set(row)%r(1:3), cell) - &
1479 (
pbc(particle_set(col)%r(1:3), cell) + cell_vector(1:3))
1480 abs_rab_cell_i = sqrt(rab_cell_i(1)**2 + rab_cell_i(2)**2 + rab_cell_i(3)**2)
1483 i_cell_is_the_minimum_image_cell = .true.
1484 DO j_cell = 1, num_cells
1485 cell_vector_j(1:3) = matmul(hmat, real(index_to_cell(1:3, j_cell),
dp))
1486 rab_cell_j(1:3) =
pbc(particle_set(row)%r(1:3), cell) - &
1487 (
pbc(particle_set(col)%r(1:3), cell) + cell_vector_j(1:3))
1488 abs_rab_cell_j = sqrt(rab_cell_j(1)**2 + rab_cell_j(2)**2 + rab_cell_j(3)**2)
1490 IF (abs_rab_cell_i > abs_rab_cell_j + 1.0e-6_dp)
THEN
1491 i_cell_is_the_minimum_image_cell = .false.
1495 IF (i_cell_is_the_minimum_image_cell)
THEN
1496 NULLIFY (block_re, block_im)
1497 CALL dbcsr_get_block_p(matrix=mat_ikp_re, row=row, col=col, block=block_re, found=f)
1498 CALL dbcsr_get_block_p(matrix=mat_ikp_im, row=row, col=col, block=block_im, found=f)
1499 cpassert(all(abs(block_re) < 1.0e-10_dp))
1500 cpassert(all(abs(block_im) < 1.0e-10_dp))
1502 arg = real(index_to_cell(1, i_cell),
dp)*kpoints%xkp(1, ikp) + &
1503 REAL(index_to_cell(2, i_cell),
dp)*kpoints%xkp(2, ikp) + &
1504 REAL(index_to_cell(3, i_cell),
dp)*kpoints%xkp(3, ikp)
1506 block_re(:, :) = cos(
twopi*arg)*data_block(:, :)
1507 block_im(:, :) = sin(
twopi*arg)*data_block(:, :)
1515 CALL timestop(handle)
1517 END SUBROUTINE mat_ikp_from_mat_gamma
1526 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1528 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_fm_W_MIC_time'
1530 INTEGER :: handle, i_t
1532 CALL timeset(routinen, handle)
1534 ALLOCATE (fm_w_mic_time(bs_env%num_time_freq_points))
1535 DO i_t = 1, bs_env%num_time_freq_points
1536 CALL cp_fm_create(fm_w_mic_time(i_t), bs_env%fm_RI_RI%matrix_struct, set_zero=.true.)
1539 CALL timestop(handle)
1552 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1556 CHARACTER(LEN=*),
PARAMETER :: routinen =
'Fourier_transform_w_to_t'
1558 INTEGER :: handle, i_t
1559 REAL(kind=
dp) :: freq_j, time_i, weight_ij
1561 CALL timeset(routinen, handle)
1563 freq_j = bs_env%time_frequency_grid%frequency(j_w)
1565 DO i_t = 1, bs_env%num_time_freq_points
1567 time_i = bs_env%time_frequency_grid%imaginary_time(i_t)
1568 weight_ij = bs_env%time_frequency_grid%cosine_frequency_to_time_weights(i_t, j_w)
1572 beta=weight_ij*cos(time_i*freq_j), matrix_b=fm_w_mic_freq_j)
1576 CALL timestop(handle)
1586 SUBROUTINE get_sigma_x(bs_env, qs_env, fm_Sigma_x_Gamma)
1589 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
1591 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Sigma_x'
1593 INTEGER :: handle, ispin
1595 CALL timeset(routinen, handle)
1597 ALLOCATE (fm_sigma_x_gamma(bs_env%n_spin))
1598 DO ispin = 1, bs_env%n_spin
1599 CALL cp_fm_create(fm_sigma_x_gamma(ispin), bs_env%fm_s_Gamma%matrix_struct)
1602 IF (bs_env%Sigma_x_exists)
THEN
1603 DO ispin = 1, bs_env%n_spin
1604 CALL fm_read(fm_sigma_x_gamma(ispin), bs_env, bs_env%Sigma_x_name, ispin)
1607 CALL compute_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
1610 CALL timestop(handle)
1612 END SUBROUTINE get_sigma_x
1620 SUBROUTINE compute_sigma_x(bs_env, qs_env, fm_Sigma_x_Gamma)
1623 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
1625 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Sigma_x'
1627 INTEGER :: handle, i_intval_idx, ispin, j_intval_idx
1628 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1630 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_vtr_gamma
1632 TYPE(dbt_type) :: t_2c_d, t_2c_sigma_x, t_2c_v, t_3c_x_v
1634 CALL timeset(routinen, handle)
1638 CALL dbt_create(bs_env%t_G, t_2c_d)
1639 CALL dbt_create(bs_env%t_W, t_2c_v)
1640 CALL dbt_create(bs_env%t_G, t_2c_sigma_x)
1641 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_v)
1642 CALL dbcsr_create(mat_sigma_x_gamma, template=bs_env%mat_ao_ao%matrix)
1645 CALL ri_2c_integral_mat(qs_env, fm_vtr_gamma, bs_env%fm_RI_RI%matrix_struct, bs_env%n_RI, &
1646 bs_env%trunc_coulomb)
1651 DO ispin = 1, bs_env%n_spin
1654 CALL g_occ_vir(bs_env, 0.0_dp, bs_env%fm_work_mo(2), ispin, occ=.true., vir=.false.)
1657 bs_env%mat_ao_ao_tensor%matrix, t_2c_d, bs_env, &
1658 bs_env%atoms_i_t_group)
1661 bs_env%mat_RI_RI_tensor%matrix, t_2c_v, bs_env, &
1662 bs_env%atoms_j_t_group)
1666 DO i_intval_idx = 1, bs_env%n_intervals_i
1667 DO j_intval_idx = 1, bs_env%n_intervals_j
1668 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
1669 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
1673 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_v, t_2c_v)
1677 CALL contract_to_sigma(t_2c_d, t_3c_x_v, t_2c_sigma_x, i_atoms, j_atoms, &
1678 qs_env, bs_env, occ=.true., vir=.false.)
1684 mat_sigma_x_gamma, bs_env%para_env)
1686 CALL write_matrix(mat_sigma_x_gamma, ispin, bs_env%Sigma_x_name, &
1687 bs_env%fm_work_mo(1), qs_env)
1693 IF (bs_env%unit_nr > 0)
THEN
1694 WRITE (bs_env%unit_nr,
'(T2,A,T55,A,F10.1,A)') &
1695 'Computed Σ^x(k=0),',
' Execution time',
m_walltime() - t1,
' s'
1696 WRITE (bs_env%unit_nr,
'(A)')
' '
1700 CALL dbt_destroy(t_2c_d)
1701 CALL dbt_destroy(t_2c_v)
1702 CALL dbt_destroy(t_2c_sigma_x)
1703 CALL dbt_destroy(t_3c_x_v)
1706 CALL timestop(handle)
1708 END SUBROUTINE compute_sigma_x
1717 SUBROUTINE get_sigma_c(bs_env, qs_env, fm_W_MIC_time, fm_Sigma_c_Gamma_time)
1720 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1721 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
1723 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Sigma_c'
1725 INTEGER :: handle, i_intval_idx, i_t, ispin, &
1726 j_intval_idx, read_write_index
1727 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1728 REAL(kind=
dp) :: t1, tau
1729 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
1730 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, &
1731 t_2c_sigma_neg_tau, &
1732 t_2c_sigma_pos_tau, t_2c_w, t_3c_x_w
1734 CALL timeset(routinen, handle)
1736 CALL create_mat_for_sigma_c(bs_env, t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, &
1737 t_2c_sigma_pos_tau, t_3c_x_w, &
1738 mat_sigma_neg_tau, mat_sigma_pos_tau)
1740 DO i_t = 1, bs_env%num_time_freq_points
1742 DO ispin = 1, bs_env%n_spin
1746 read_write_index = i_t + (ispin - 1)*bs_env%num_time_freq_points
1749 IF (bs_env%Sigma_c_exists(i_t, ispin))
THEN
1750 CALL fm_read(bs_env%fm_work_mo(1), bs_env, bs_env%Sigma_p_name, read_write_index)
1751 CALL copy_fm_to_dbcsr(bs_env%fm_work_mo(1), mat_sigma_pos_tau(i_t, ispin)%matrix, &
1752 keep_sparsity=.false.)
1753 CALL fm_read(bs_env%fm_work_mo(1), bs_env, bs_env%Sigma_n_name, read_write_index)
1754 CALL copy_fm_to_dbcsr(bs_env%fm_work_mo(1), mat_sigma_neg_tau(i_t, ispin)%matrix, &
1755 keep_sparsity=.false.)
1756 IF (bs_env%unit_nr > 0)
THEN
1757 WRITE (bs_env%unit_nr,
'(T2,2A,I3,A,I3,A,F10.1,A)')
'Read Σ^c(iτ,k=0) ', &
1758 'from file for time point ', i_t,
' /', bs_env%num_time_freq_points, &
1766 tau = bs_env%time_frequency_grid%imaginary_time(i_t)
1768 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gocc, ispin, occ=.true., vir=.false.)
1769 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gvir, ispin, occ=.false., vir=.true.)
1773 bs_env%mat_ao_ao_tensor%matrix, t_2c_gocc, bs_env, &
1774 bs_env%atoms_i_t_group)
1776 bs_env%mat_ao_ao_tensor%matrix, t_2c_gvir, bs_env, &
1777 bs_env%atoms_i_t_group)
1779 bs_env%mat_RI_RI_tensor%matrix, t_2c_w, bs_env, &
1780 bs_env%atoms_j_t_group)
1784 DO i_intval_idx = 1, bs_env%n_intervals_i
1785 DO j_intval_idx = 1, bs_env%n_intervals_j
1786 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
1787 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
1789 IF (bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx) .AND. &
1790 bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx))
THEN
1794 bs_env%n_skip_sigma = bs_env%n_skip_sigma + 1
1801 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_w, t_2c_w)
1805 CALL contract_to_sigma(t_2c_gocc, t_3c_x_w, t_2c_sigma_neg_tau, i_atoms, j_atoms, &
1806 qs_env, bs_env, occ=.true., vir=.false., &
1807 can_skip=bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx))
1810 CALL contract_to_sigma(t_2c_gvir, t_3c_x_w, t_2c_sigma_pos_tau, i_atoms, j_atoms, &
1811 qs_env, bs_env, occ=.false., vir=.true., &
1812 can_skip=bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx))
1820 mat_sigma_neg_tau(i_t, ispin)%matrix, bs_env%para_env)
1822 mat_sigma_pos_tau(i_t, ispin)%matrix, bs_env%para_env)
1824 CALL write_matrix(mat_sigma_pos_tau(i_t, ispin)%matrix, read_write_index, &
1825 bs_env%Sigma_p_name, bs_env%fm_work_mo(1), qs_env)
1826 CALL write_matrix(mat_sigma_neg_tau(i_t, ispin)%matrix, read_write_index, &
1827 bs_env%Sigma_n_name, bs_env%fm_work_mo(1), qs_env)
1829 IF (bs_env%unit_nr > 0)
THEN
1830 WRITE (bs_env%unit_nr,
'(T2,A,I10,A,I3,A,F10.1,A)') &
1831 'Computed Σ^c(iτ,k=0) for time point ', i_t,
' /', bs_env%num_time_freq_points, &
1839 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
1842 mat_sigma_pos_tau, mat_sigma_neg_tau)
1844 CALL print_skipping(bs_env)
1846 CALL destroy_mat_sigma_c(t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, &
1847 t_2c_sigma_pos_tau, t_3c_x_w, fm_w_mic_time, &
1848 mat_sigma_neg_tau, mat_sigma_pos_tau)
1852 CALL timestop(handle)
1854 END SUBROUTINE get_sigma_c
1868 SUBROUTINE create_mat_for_sigma_c(bs_env, t_2c_Gocc, t_2c_Gvir, t_2c_W, t_2c_Sigma_neg_tau, &
1869 t_2c_Sigma_pos_tau, t_3c_x_W, &
1870 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
1873 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
1874 t_2c_sigma_neg_tau, &
1875 t_2c_sigma_pos_tau, t_3c_x_w
1876 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
1878 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_mat_for_Sigma_c'
1880 INTEGER :: handle, i_t, ispin
1882 CALL timeset(routinen, handle)
1884 CALL dbt_create(bs_env%t_G, t_2c_gocc)
1885 CALL dbt_create(bs_env%t_G, t_2c_gvir)
1886 CALL dbt_create(bs_env%t_W, t_2c_w)
1887 CALL dbt_create(bs_env%t_G, t_2c_sigma_neg_tau)
1888 CALL dbt_create(bs_env%t_G, t_2c_sigma_pos_tau)
1889 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_w)
1891 NULLIFY (mat_sigma_neg_tau, mat_sigma_pos_tau)
1892 ALLOCATE (mat_sigma_neg_tau(bs_env%num_time_freq_points, bs_env%n_spin))
1893 ALLOCATE (mat_sigma_pos_tau(bs_env%num_time_freq_points, bs_env%n_spin))
1895 DO ispin = 1, bs_env%n_spin
1896 DO i_t = 1, bs_env%num_time_freq_points
1897 ALLOCATE (mat_sigma_neg_tau(i_t, ispin)%matrix)
1898 ALLOCATE (mat_sigma_pos_tau(i_t, ispin)%matrix)
1899 CALL dbcsr_create(mat_sigma_neg_tau(i_t, ispin)%matrix, template=bs_env%mat_ao_ao%matrix)
1900 CALL dbcsr_create(mat_sigma_pos_tau(i_t, ispin)%matrix, template=bs_env%mat_ao_ao%matrix)
1904 CALL timestop(handle)
1906 END SUBROUTINE create_mat_for_sigma_c
1917 SUBROUTINE compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_W, t_2c_W)
1921 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1922 TYPE(dbt_type) :: t_3c_x_w, t_2c_w
1924 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_3c_and_contract_W'
1926 INTEGER :: handle, ri_intval_idx
1927 INTEGER(KIND=int_8) :: flop
1928 INTEGER,
DIMENSION(2) :: bounds_p, bounds_q, ri_atoms
1929 INTEGER,
DIMENSION(2, 2) :: bounds_ao
1930 TYPE(dbt_type) :: t_3c_for_w, t_3c_x_w_tmp
1932 CALL timeset(routinen, handle)
1934 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_w_tmp)
1935 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_for_w)
1945 bounds_q(1:2) = [bs_env%i_RI_start_from_atom(j_atoms(1)), &
1946 bs_env%i_RI_end_from_atom(j_atoms(2))]
1948 DO ri_intval_idx = 1, bs_env%n_intervals_inner_loop_atoms
1949 ri_atoms = bs_env%inner_loop_atom_intervals(1:2, ri_intval_idx)
1951 CALL get_bounds_from_atoms(bounds_p, i_atoms, [1, bs_env%n_atom], &
1952 bs_env%min_RI_idx_from_AO_AO_atom, &
1953 bs_env%max_RI_idx_from_AO_AO_atom, &
1955 indices_3_start=bs_env%i_RI_start_from_atom, &
1956 indices_3_end=bs_env%i_RI_end_from_atom)
1959 CALL get_bounds_from_atoms(bounds_ao(:, 2), ri_atoms, i_atoms, &
1960 bs_env%min_AO_idx_from_RI_AO_atom, &
1961 bs_env%max_AO_idx_from_RI_AO_atom)
1963 CALL get_bounds_from_atoms(bounds_ao(:, 1), ri_atoms, [1, bs_env%n_atom], &
1964 bs_env%min_AO_idx_from_RI_AO_atom, &
1965 bs_env%max_AO_idx_from_RI_AO_atom, &
1967 indices_3_start=bs_env%i_ao_start_from_atom, &
1968 indices_3_end=bs_env%i_ao_end_from_atom)
1970 IF (bounds_p(1) > bounds_p(2) .OR. bounds_ao(1, 2) > bounds_ao(2, 2))
THEN
1976 atoms_ao_1=i_atoms, atoms_ri=ri_atoms)
1979 CALL dbt_contract(alpha=1.0_dp, &
1981 tensor_2=t_3c_for_w, &
1983 tensor_3=t_3c_x_w_tmp, &
1984 contract_1=[2], notcontract_1=[1], map_1=[1], &
1985 contract_2=[1], notcontract_2=[2, 3], map_2=[2, 3], &
1986 bounds_1=bounds_p, &
1987 bounds_2=bounds_q, &
1988 bounds_3=bounds_ao, &
1990 move_data=.false., &
1991 filter_eps=bs_env%eps_filter)
1996 CALL dbt_copy(t_3c_x_w_tmp, t_3c_x_w, order=[1, 2, 3], move_data=.true.)
1998 CALL dbt_destroy(t_3c_x_w_tmp)
1999 CALL dbt_destroy(t_3c_for_w)
2001 CALL timestop(handle)
2003 END SUBROUTINE compute_3c_and_contract_w
2018 SUBROUTINE contract_to_sigma(t_2c_G, t_3c_x_W, t_2c_Sigma, i_atoms, j_atoms, qs_env, bs_env, &
2020 TYPE(dbt_type) :: t_2c_g, t_3c_x_w, t_2c_sigma
2021 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
2025 LOGICAL,
OPTIONAL :: can_skip
2027 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_to_Sigma'
2029 INTEGER :: handle, inner_loop_atoms_interval_index
2030 INTEGER(KIND=int_8) :: flop
2031 INTEGER,
DIMENSION(2) :: bounds_lambda, bounds_mu, bounds_nu, &
2032 bounds_sigma, il_atoms
2033 INTEGER,
DIMENSION(2, 2) :: bounds_comb
2034 REAL(kind=
dp) :: sign_sigma
2035 TYPE(dbt_type) :: t_3c_for_g, t_3c_x_g, t_3c_x_g_2
2037 CALL timeset(routinen, handle)
2039 cpassert(occ .EQV. (.NOT. vir))
2040 IF (occ) sign_sigma = -1.0_dp
2041 IF (vir) sign_sigma = 1.0_dp
2043 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_g)
2044 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_g)
2045 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_g_2)
2058 bounds_nu(1:2) = [bs_env%i_ao_start_from_atom(i_atoms(1)), &
2059 bs_env%i_ao_end_from_atom(i_atoms(2))]
2061 DO inner_loop_atoms_interval_index = 1, bs_env%n_intervals_inner_loop_atoms
2062 il_atoms = bs_env%inner_loop_atom_intervals(1:2, inner_loop_atoms_interval_index)
2065 CALL get_bounds_from_atoms(bounds_mu, j_atoms, [1, bs_env%n_atom], &
2066 bs_env%min_AO_idx_from_RI_AO_atom, &
2067 bs_env%max_AO_idx_from_RI_AO_atom, &
2069 indices_3_start=bs_env%i_ao_start_from_atom, &
2070 indices_3_end=bs_env%i_ao_end_from_atom)
2073 CALL get_bounds_from_atoms(bounds_comb(:, 1), il_atoms, [1, bs_env%n_atom], &
2074 bs_env%min_RI_idx_from_AO_AO_atom, &
2075 bs_env%max_RI_idx_from_AO_AO_atom, &
2077 indices_3_start=bs_env%i_RI_start_from_atom, &
2078 indices_3_end=bs_env%i_RI_end_from_atom)
2081 CALL get_bounds_from_atoms(bounds_comb(:, 2), j_atoms, il_atoms, &
2082 bs_env%min_AO_idx_from_RI_AO_atom, &
2083 bs_env%max_AO_idx_from_RI_AO_atom)
2085 IF (bounds_mu(1) > bounds_mu(2) .OR. bounds_comb(1, 1) > bounds_comb(2, 1) .OR. &
2086 bounds_comb(1, 2) > bounds_comb(2, 2))
THEN
2091 atoms_ri=j_atoms, atoms_ao_2=il_atoms)
2093 CALL dbt_contract(alpha=1.0_dp, &
2095 tensor_2=t_3c_for_g, &
2097 tensor_3=t_3c_x_g, &
2098 contract_1=[2], notcontract_1=[1], map_1=[3], &
2099 contract_2=[3], notcontract_2=[1, 2], map_2=[1, 2], &
2100 bounds_1=bounds_mu, &
2101 bounds_2=bounds_nu, &
2102 bounds_3=bounds_comb, &
2104 move_data=.false., &
2105 filter_eps=bs_env%eps_filter)
2109 CALL dbt_copy(t_3c_x_g, t_3c_x_g_2, order=[1, 3, 2], move_data=.true.)
2113 bounds_comb(1:2, 1) = [bs_env%i_RI_start_from_atom(j_atoms(1)), &
2114 bs_env%i_RI_end_from_atom(j_atoms(2))]
2115 bounds_comb(1:2, 2) = bounds_nu(1:2)
2117 CALL get_bounds_from_atoms(bounds_lambda, j_atoms, [1, bs_env%n_atom], &
2118 bs_env%min_AO_idx_from_RI_AO_atom, &
2119 bs_env%max_AO_idx_from_RI_AO_atom)
2120 CALL get_bounds_from_atoms(bounds_sigma, [1, bs_env%n_atom], i_atoms, &
2121 bs_env%min_AO_idx_from_RI_AO_atom, &
2122 bs_env%max_AO_idx_from_RI_AO_atom)
2124 IF (bounds_sigma(1) > bounds_sigma(2) .OR. bounds_lambda(1) > bounds_lambda(2))
THEN
2127 CALL dbt_contract(alpha=sign_sigma, &
2128 tensor_1=t_3c_x_w, &
2129 tensor_2=t_3c_x_g_2, &
2131 tensor_3=t_2c_sigma, &
2132 contract_1=[1, 2], notcontract_1=[3], map_1=[1], &
2133 contract_2=[1, 2], notcontract_2=[3], map_2=[2], &
2134 bounds_1=bounds_comb, &
2135 bounds_2=bounds_sigma, &
2136 bounds_3=bounds_lambda, &
2137 filter_eps=bs_env%eps_filter, move_data=.false., flop=flop)
2140 IF (
PRESENT(can_skip))
THEN
2141 IF (flop == 0_int_8) can_skip = .true.
2144 CALL dbt_destroy(t_3c_for_g)
2145 CALL dbt_destroy(t_3c_x_g)
2146 CALL dbt_destroy(t_3c_x_g_2)
2148 CALL timestop(handle)
2150 END SUBROUTINE contract_to_sigma
2160 mat_Sigma_pos_tau, mat_Sigma_neg_tau)
2162 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
2164 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_pos_tau, mat_sigma_neg_tau
2166 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fill_fm_Sigma_c_Gamma_time'
2168 INTEGER :: handle, i_t, ispin, pos_neg
2170 CALL timeset(routinen, handle)
2172 ALLOCATE (fm_sigma_c_gamma_time(bs_env%num_time_freq_points, 2, bs_env%n_spin))
2173 DO ispin = 1, bs_env%n_spin
2174 DO i_t = 1, bs_env%num_time_freq_points
2176 CALL cp_fm_create(fm_sigma_c_gamma_time(i_t, pos_neg, ispin), &
2177 bs_env%fm_s_Gamma%matrix_struct)
2180 fm_sigma_c_gamma_time(i_t, 1, ispin))
2182 fm_sigma_c_gamma_time(i_t, 2, ispin))
2186 CALL timestop(handle)
2194 SUBROUTINE print_skipping(bs_env)
2198 CHARACTER(LEN=*),
PARAMETER :: routinen =
'print_skipping'
2200 INTEGER :: handle, n_pairs
2202 CALL timeset(routinen, handle)
2204 n_pairs = bs_env%n_intervals_i*bs_env%n_intervals_j*bs_env%n_spin
2206 CALL bs_env%para_env_tensor%sum(bs_env%n_skip_sigma)
2207 CALL bs_env%para_env_tensor%sum(bs_env%n_skip_chi)
2208 CALL bs_env%para_env_tensor%sum(n_pairs)
2210 IF (bs_env%unit_nr > 0)
THEN
2211 WRITE (bs_env%unit_nr,
'(T2,A,T74,F7.1,A)') &
2212 'Sparsity of Σ^c(iτ,k=0): Percentage of skipped atom pairs:', &
2213 REAL(100*bs_env%n_skip_sigma, kind=
dp)/real(n_pairs, kind=
dp),
' %'
2214 WRITE (bs_env%unit_nr,
'(T2,A,T74,F7.1,A)') &
2215 'Sparsity of χ(iτ,k=0): Percentage of skipped atom pairs:', &
2216 REAL(100*bs_env%n_skip_chi, kind=
dp)/real(n_pairs, kind=
dp),
' %'
2219 CALL timestop(handle)
2221 END SUBROUTINE print_skipping
2235 SUBROUTINE destroy_mat_sigma_c(t_2c_Gocc, t_2c_Gvir, t_2c_W, t_2c_Sigma_neg_tau, &
2236 t_2c_Sigma_pos_tau, t_3c_x_W, fm_W_MIC_time, &
2237 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
2239 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
2240 t_2c_sigma_neg_tau, &
2241 t_2c_sigma_pos_tau, t_3c_x_w
2242 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
2243 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
2245 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_mat_Sigma_c'
2249 CALL timeset(routinen, handle)
2251 CALL dbt_destroy(t_2c_gocc)
2252 CALL dbt_destroy(t_2c_gvir)
2253 CALL dbt_destroy(t_2c_w)
2254 CALL dbt_destroy(t_2c_sigma_neg_tau)
2255 CALL dbt_destroy(t_2c_sigma_pos_tau)
2256 CALL dbt_destroy(t_3c_x_w)
2261 CALL timestop(handle)
2263 END SUBROUTINE destroy_mat_sigma_c
2272 CHARACTER(LEN=*),
PARAMETER :: routinen =
'delete_unnecessary_files'
2274 CHARACTER(LEN=default_path_length) :: f_chi, f_w_t, prefix
2275 INTEGER :: handle, i_t
2277 CALL timeset(routinen, handle)
2279 prefix = bs_env%prefix
2281 DO i_t = 1, bs_env%num_time_freq_points
2284 WRITE (f_chi,
'(3A,I1,A)') trim(prefix), bs_env%chi_name,
"_00", i_t,
".matrix"
2285 WRITE (f_w_t,
'(3A,I1,A)') trim(prefix), bs_env%W_time_name,
"_00", i_t,
".matrix"
2286 ELSE IF (i_t < 100)
THEN
2287 WRITE (f_chi,
'(3A,I2,A)') trim(prefix), bs_env%chi_name,
"_0", i_t,
".matrix"
2288 WRITE (f_w_t,
'(3A,I2,A)') trim(prefix), bs_env%W_time_name,
"_0", i_t,
".matrix"
2290 cpabort(
'Please implement more than 99 time/frequency points.')
2293 CALL safe_delete(f_chi, bs_env)
2294 CALL safe_delete(f_w_t, bs_env)
2298 CALL timestop(handle)
2307 SUBROUTINE safe_delete(filename, bs_env)
2308 CHARACTER(LEN=*) :: filename
2311 CHARACTER(LEN=*),
PARAMETER :: routinen =
'safe_delete'
2316 CALL timeset(routinen, handle)
2318 IF (bs_env%para_env%mepos == 0)
THEN
2325 CALL timestop(handle)
2327 END SUBROUTINE safe_delete
2340 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
2341 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
2343 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_QP_energies'
2345 INTEGER :: handle, ikp, ispin, j_t
2346 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sigma_x_ikp_n, v_xc_ikp_n
2347 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: sigma_c_ikp_n_freq, sigma_c_ikp_n_time
2348 TYPE(
cp_cfm_type) :: cfm_ks_ikp, cfm_mos_ikp, cfm_s_ikp, &
2349 cfm_sigma_x_ikp, cfm_work_ikp
2351 CALL timeset(routinen, handle)
2353 CALL cp_cfm_create(cfm_mos_ikp, bs_env%fm_s_Gamma%matrix_struct)
2354 CALL cp_cfm_create(cfm_work_ikp, bs_env%fm_s_Gamma%matrix_struct)
2356 ALLOCATE (v_xc_ikp_n(bs_env%n_ao), sigma_x_ikp_n(bs_env%n_ao))
2357 ALLOCATE (sigma_c_ikp_n_time(bs_env%n_ao, bs_env%num_time_freq_points, 2))
2358 ALLOCATE (sigma_c_ikp_n_freq(bs_env%n_ao, bs_env%num_time_freq_points, 2))
2360 DO ispin = 1, bs_env%n_spin
2362 DO ikp = 1, bs_env%nkp_bs_and_DOS
2366 ikp, qs_env, bs_env%kpoints_DOS,
"ORB")
2370 ikp, qs_env, bs_env%kpoints_DOS,
"ORB")
2373 CALL cp_cfm_geeig(cfm_ks_ikp, cfm_s_ikp, cfm_mos_ikp, &
2374 bs_env%eigenval_scf(:, ikp, ispin), cfm_work_ikp)
2377 CALL to_ikp_and_mo(v_xc_ikp_n, bs_env%fm_V_xc_Gamma(ispin), &
2378 ikp, qs_env, bs_env, cfm_mos_ikp)
2381 CALL to_ikp_and_mo(sigma_x_ikp_n, fm_sigma_x_gamma(ispin), &
2382 ikp, qs_env, bs_env, cfm_mos_ikp)
2385 DO j_t = 1, bs_env%num_time_freq_points
2386 CALL to_ikp_and_mo(sigma_c_ikp_n_time(:, j_t, 1), &
2387 fm_sigma_c_gamma_time(j_t, 1, ispin), &
2388 ikp, qs_env, bs_env, cfm_mos_ikp)
2389 CALL to_ikp_and_mo(sigma_c_ikp_n_time(:, j_t, 2), &
2390 fm_sigma_c_gamma_time(j_t, 2, ispin), &
2391 ikp, qs_env, bs_env, cfm_mos_ikp)
2395 CALL time_to_freq(bs_env, sigma_c_ikp_n_time, sigma_c_ikp_n_freq, ispin)
2400 bs_env%eigenval_scf(:, ikp, ispin), ikp, ispin)
2417 CALL timestop(handle)
2430 SUBROUTINE to_ikp_and_mo(array_ikp_n, fm_Gamma, ikp, qs_env, bs_env, cfm_mos_ikp)
2432 REAL(kind=
dp),
DIMENSION(:) :: array_ikp_n
2439 CHARACTER(LEN=*),
PARAMETER :: routinen =
'to_ikp_and_mo'
2444 CALL timeset(routinen, handle)
2446 CALL cp_fm_create(fm_ikp_mo_re, fm_gamma%matrix_struct)
2448 CALL fm_gamma_ao_to_cfm_ikp_mo(fm_gamma, fm_ikp_mo_re, ikp, qs_env, bs_env, cfm_mos_ikp)
2454 CALL timestop(handle)
2456 END SUBROUTINE to_ikp_and_mo
2467 SUBROUTINE fm_gamma_ao_to_cfm_ikp_mo(fm_Gamma, fm_ikp_mo_re, ikp, qs_env, bs_env, cfm_mos_ikp)
2474 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_Gamma_ao_to_cfm_ikp_mo'
2479 CALL timeset(routinen, handle)
2494 CALL timestop(handle)
2496 END SUBROUTINE fm_gamma_ao_to_cfm_ikp_mo
2513 SUBROUTINE get_bounds_from_atoms(bounds_out, atoms_1, atoms_2, indices_min, indices_max, &
2514 atoms_3, indices_3_start, indices_3_end)
2516 INTEGER,
DIMENSION(2),
INTENT(OUT) :: bounds_out
2517 INTEGER,
DIMENSION(2),
INTENT(IN) :: atoms_1, atoms_2
2518 INTEGER,
DIMENSION(:, :) :: indices_min, indices_max
2519 INTEGER,
DIMENSION(2),
INTENT(IN),
OPTIONAL :: atoms_3
2520 INTEGER,
DIMENSION(:),
OPTIONAL :: indices_3_start, indices_3_end
2522 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_bounds_from_atoms'
2524 INTEGER :: handle, i_at, j_at
2526 CALL timeset(routinen, handle)
2527 bounds_out(1) = huge(0)
2530 DO i_at = atoms_1(1), atoms_1(2)
2531 DO j_at = atoms_2(1), atoms_2(2)
2532 bounds_out(1) = min(bounds_out(1), indices_min(i_at, j_at))
2533 bounds_out(2) = max(bounds_out(2), indices_max(i_at, j_at))
2537 IF (
PRESENT(atoms_3) .AND.
PRESENT(indices_3_start) .AND.
PRESENT(indices_3_end))
THEN
2538 bounds_out(1) = max(bounds_out(1), indices_3_start(atoms_3(1)))
2539 bounds_out(2) = min(bounds_out(2), indices_3_end(atoms_3(2)))
2542 CALL timestop(handle)
2544 END SUBROUTINE get_bounds_from_atoms
static GRID_HOST_DEVICE int idx(const orbital a)
Return coset index of given orbital angular momentum.
Define the atomic kind types and their sub types.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public graml2024
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.
constants for the different operators of the 2c-integrals
integer, parameter, public operator_coulomb
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_uplo_to_full(matrix, workspace, uplo)
...
subroutine, public cp_cfm_add_on_diag(matrix, alpha, n_active)
Adds a scalar to the diagonal of a distributed complex full matrix.
various cholesky decomposition related routines
subroutine, public cp_cfm_cholesky_decompose(matrix, n, info_out)
Used to replace a symmetric positive definite matrix M with its Cholesky decomposition U: M = U^T * U...
subroutine, public cp_cfm_cholesky_invert(matrix, n, info_out)
Used to replace Cholesky decomposition by the inverse.
used for collecting diagonalization schemes available for cp_cfm_type
subroutine, public cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work, lowest_subset)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_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.
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_reserve_all_blocks(matrix)
Reserves all blocks.
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
logical function, public file_exists(file_name)
Checks if file exists, considering also the file discovery mechanism.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_diag(matrix, diag)
returns the diagonal elements of a fm
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_write_unformatted(fm, unit)
...
subroutine, public cp_fm_read_unformatted(fm, unit)
...
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
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
This is the start of a dbt_api, all publically needed functions are exported here....
Routines from paper [Graml2024].
subroutine, public gw_calc_tensor_large_cell_gamma(qs_env, bs_env)
Perform GW band structure calculation.
subroutine, public compute_fm_chi_gamma_freq(bs_env, fm_chi_gamma_freq, j_w, mat_chi_gamma_tau)
...
subroutine, public write_matrix(matrix, matrix_index, matrix_name, fm, qs_env)
...
subroutine, public compute_3c_integrals(qs_env, bs_env, t_3c, atoms_ao_1, atoms_ao_2, atoms_ri)
...
subroutine, public compute_qp_energies(bs_env, qs_env, fm_sigma_x_gamma, fm_sigma_c_gamma_time)
...
subroutine, public fourier_transform_w_to_t(bs_env, fm_w_mic_time, fm_w_mic_freq_j, j_w)
...
subroutine, public fm_write(fm, matrix_index, matrix_name, qs_env)
...
subroutine, public create_fm_w_mic_time(bs_env, fm_w_mic_time)
...
subroutine, public fill_fm_sigma_c_gamma_time(fm_sigma_c_gamma_time, bs_env, mat_sigma_pos_tau, mat_sigma_neg_tau)
...
subroutine, public g_occ_vir(bs_env, tau, fm_g_gamma, ispin, occ, vir)
...
subroutine, public fm_read(fm, bs_env, mat_name, idx)
...
subroutine, public get_w_mic(bs_env, qs_env, mat_chi_gamma_tau, fm_w_mic_time)
...
subroutine, public delete_unnecessary_files(bs_env)
...
subroutine, public fm_to_local_tensor(fm_global, mat_global, mat_local, tensor, bs_env, atom_ranges)
...
subroutine, public local_dbt_to_global_mat(tensor, mat_tensor, mat_global, para_env)
...
Full-matrix operations not provided by the CP2K FM packages.
subroutine, public cfm_contract_aba(matrix_a, matrix_b, matrix_c)
Computes A^H B A for complex full matrices.
subroutine, public time_to_freq(bs_env, sigma_c_n_time, sigma_c_n_freq, ispin)
...
subroutine, public analyt_conti_and_print(bs_env, sigma_c_ikp_n_freq, sigma_x_ikp_n, v_xc_ikp_n, eigenval_scf, ikp, ispin)
...
subroutine, public de_init_bs_env(qs_env, bs_env)
Releases the memory-heavy GW intermediates that cannot be freed in bs_env_release,...
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_path_length
Routines to compute the Coulomb integral V_(alpha beta)(k) for a k-point k using lattice summation in...
subroutine, public build_2c_coulomb_matrix_kp(matrix_v_kp, kpoints, basis_type, cell, particle_set, qs_kind_set, atomic_kind_set, size_lattice_sum, operator_type, ikp_start, ikp_end)
...
Types and basic routines needed for a kpoint calculation.
Machine interface based on Fortran 2003 and POSIX.
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.
complex(kind=dp), parameter, public z_one
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
subroutine, public mp_file_delete(filepath, info)
Deletes a file. Auxiliary routine to emulate 'replace' action for mp_file_open. Only the master proce...
Framework for 2c-integrals for RI.
subroutine, public ri_2c_integral_mat(qs_env, fm_matrix_minv_l_gamma, fm_matrix_l_struct, dimen_ri, ri_metric, put_mat_ks_env, regularization_ri)
...
subroutine, public ri_2c_integral_mat_kp(qs_env, cfm_matrix_m_kpoints, fm_matrix_struct, dimen_ri, ri_metric, kpoints, put_mat_ks_env, regularization_ri, ikp_ext, do_build_cell_index)
Computes the complex k-point RI metric as native CFM matrices.
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
subroutine, public cfm_ikp_from_fm_gamma(cfm_ikp, fm_gamma, ikp, qs_env, kpoints, basis_type)
...
subroutine, public get_all_vbm_cbm_bandgaps(bs_env)
...
subroutine, public mic_contribution_from_ikp(bs_env, qs_env, fm_w_mic_freq_j, cfm_w_ikp_freq_j, ikp, kpoints, basis_type, wkp_ext)
...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
Utility methods to build 3-center integral tensors of various types.
subroutine, public build_3c_integrals(t3c, filter_eps, qs_env, nl_3c, basis_i, basis_j, basis_k, potential_parameter, int_eps, op_pos, do_kpoints, do_hfx_kpoints, desymmetrize, cell_sym, bounds_i, bounds_j, bounds_k, ri_range, img_to_ri_cell, cell_to_index_ext)
Build 3-center integral tensor.
Routines treating GW and RPA calculations with kpoints.
subroutine, public cfm_screened_interaction_from_eps_cholesky(eps_chol, b, wc, n_active)
Form the screened interaction from a Cholesky-factorized dielectric matrix.
subroutine, public cp_cfm_power(matrix, threshold, exponent, min_eigval)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Represent a complex full matrix.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains information about kpoints.
Provides all information about a quickstep kind.