88#include "./base/base_uses.f90"
94 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'gw_large_cell_gamma'
112 CHARACTER(LEN=*),
PARAMETER :: routinen =
'gw_calc_large_cell_Gamma'
115 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma, fm_w_mic_time
116 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
118 CALL timeset(routinen, handle)
125 CALL get_mat_chi_gamma_tau(bs_env, qs_env, bs_env%mat_chi_Gamma_tau)
128 CALL get_w_mic(bs_env, qs_env, bs_env%mat_chi_Gamma_tau, fm_w_mic_time)
132 CALL get_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
136 CALL get_sigma_c(bs_env, qs_env, fm_w_mic_time, fm_sigma_c_gamma_time)
139 CALL compute_qp_energies(bs_env, qs_env, fm_sigma_x_gamma, fm_sigma_c_gamma_time)
143 CALL timestop(handle)
153 SUBROUTINE get_mat_chi_gamma_tau(bs_env, qs_env, mat_chi_Gamma_tau)
156 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
158 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_mat_chi_Gamma_tau'
160 INTEGER :: handle, i_intval_idx, i_t, inner_loop_atoms_interval_index, ispin, j_intval_idx
161 INTEGER,
DIMENSION(2) :: i_atoms, il_atoms, j_atoms
162 LOGICAL :: dist_too_long_i, dist_too_long_j
163 REAL(kind=
dp) :: t1, tau
164 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
165 t_3c_for_gvir, t_3c_x_gocc, &
166 t_3c_x_gocc_2, t_3c_x_gvir, &
169 CALL timeset(routinen, handle)
171 DO i_t = 1, bs_env%num_time_freq_points
175 IF (bs_env%read_chi(i_t))
THEN
177 CALL fm_read(bs_env%fm_RI_RI, bs_env, bs_env%chi_name, i_t)
180 keep_sparsity=.false.)
182 IF (bs_env%unit_nr > 0)
THEN
183 WRITE (bs_env%unit_nr,
'(T2,A,I5,A,I3,A,F7.1,A)') &
184 χτ
'Read (i,k=0) from file for time point ', i_t,
' /', &
185 bs_env%num_time_freq_points, &
193 IF (.NOT. bs_env%calc_chi(i_t)) cycle
195 CALL create_tensors_chi(t_2c_gocc, t_2c_gvir, t_3c_for_gocc, t_3c_for_gvir, &
196 t_3c_x_gocc, t_3c_x_gvir, t_3c_x_gocc_2, t_3c_x_gvir_2, bs_env)
202 tau = bs_env%imag_time_points(i_t)
204 DO ispin = 1, bs_env%n_spin
205 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gocc, ispin, occ=.true., vir=.false.)
206 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gvir, ispin, occ=.false., vir=.true.)
209 bs_env%mat_ao_ao_tensor%matrix, t_2c_gocc, bs_env, &
210 bs_env%atoms_j_t_group)
212 bs_env%mat_ao_ao_tensor%matrix, t_2c_gvir, bs_env, &
213 bs_env%atoms_i_t_group)
217 DO i_intval_idx = 1, bs_env%n_intervals_i
218 DO j_intval_idx = 1, bs_env%n_intervals_j
219 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
220 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
222 DO inner_loop_atoms_interval_index = 1, bs_env%n_intervals_inner_loop_atoms
224 il_atoms = bs_env%inner_loop_atom_intervals(1:2, inner_loop_atoms_interval_index)
226 CALL check_dist(i_atoms, il_atoms, qs_env, bs_env, dist_too_long_i)
227 CALL check_dist(j_atoms, il_atoms, qs_env, bs_env, dist_too_long_j)
228 IF (dist_too_long_i .OR. dist_too_long_j) cycle
234 CALL g_times_3c(t_3c_for_gocc, t_2c_gocc, t_3c_x_gocc, bs_env, &
235 j_atoms, i_atoms, il_atoms)
241 CALL g_times_3c(t_3c_for_gvir, t_2c_gvir, t_3c_x_gvir, bs_env, &
242 i_atoms, j_atoms, il_atoms)
247 CALL dbt_copy(t_3c_x_gocc, t_3c_x_gocc_2, move_data=.true., order=[1, 3, 2])
248 CALL dbt_copy(t_3c_x_gvir, t_3c_x_gvir_2, move_data=.true.)
251 CALL dbt_contract(alpha=bs_env%spin_degeneracy, &
252 tensor_1=t_3c_x_gocc_2, tensor_2=t_3c_x_gvir_2, &
253 beta=1.0_dp, tensor_3=bs_env%t_chi, &
254 contract_1=[2, 3], notcontract_1=[1], map_1=[1], &
255 contract_2=[2, 3], notcontract_2=[1], map_2=[2], &
256 filter_eps=bs_env%eps_filter, move_data=.true.)
266 mat_chi_gamma_tau(i_t)%matrix, bs_env%para_env)
268 CALL write_matrix(mat_chi_gamma_tau(i_t)%matrix, i_t, bs_env%chi_name, &
269 bs_env%fm_RI_RI, qs_env)
271 CALL destroy_tensors_chi(t_2c_gocc, t_2c_gvir, t_3c_for_gocc, t_3c_for_gvir, &
272 t_3c_x_gocc, t_3c_x_gvir, t_3c_x_gocc_2, t_3c_x_gvir_2)
274 IF (bs_env%unit_nr > 0)
THEN
275 WRITE (bs_env%unit_nr,
'(T2,A,I13,A,I3,A,F7.1,A)') &
276 χτ
'Computed (i,k=0) for time point', i_t,
' /', bs_env%num_time_freq_points, &
282 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
284 CALL timestop(handle)
286 END SUBROUTINE get_mat_chi_gamma_tau
295 SUBROUTINE fm_read(fm, bs_env, mat_name, idx)
298 CHARACTER(LEN=*) :: mat_name
301 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_read'
303 CHARACTER(LEN=default_string_length) :: f_chi
304 INTEGER :: handle, unit_nr
306 CALL timeset(routinen, handle)
309 IF (bs_env%para_env%is_source())
THEN
312 WRITE (f_chi,
'(3A,I1,A)') trim(bs_env%prefix), trim(mat_name),
"_0",
idx,
".matrix"
313 ELSE IF (
idx < 100)
THEN
314 WRITE (f_chi,
'(3A,I2,A)') trim(bs_env%prefix), trim(mat_name),
"_",
idx,
".matrix"
316 cpabort(
'Please implement more than 99 time/frequency points.')
319 CALL open_file(file_name=trim(f_chi), file_action=
"READ", file_form=
"UNFORMATTED", &
320 file_position=
"REWIND", file_status=
"OLD", unit_number=unit_nr)
326 IF (bs_env%para_env%is_source())
CALL close_file(unit_number=unit_nr)
328 CALL timestop(handle)
330 END SUBROUTINE fm_read
344 SUBROUTINE create_tensors_chi(t_2c_Gocc, t_2c_Gvir, t_3c_for_Gocc, t_3c_for_Gvir, &
345 t_3c_x_Gocc, t_3c_x_Gvir, t_3c_x_Gocc_2, t_3c_x_Gvir_2, bs_env)
347 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
348 t_3c_for_gvir, t_3c_x_gocc, &
349 t_3c_x_gvir, t_3c_x_gocc_2, &
353 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_tensors_chi'
357 CALL timeset(routinen, handle)
359 CALL dbt_create(bs_env%t_G, t_2c_gocc)
360 CALL dbt_create(bs_env%t_G, t_2c_gvir)
361 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_gocc)
362 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_gvir)
363 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_gocc)
364 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_gvir)
365 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_gocc_2)
366 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_gvir_2)
368 CALL timestop(handle)
370 END SUBROUTINE create_tensors_chi
383 SUBROUTINE destroy_tensors_chi(t_2c_Gocc, t_2c_Gvir, t_3c_for_Gocc, t_3c_for_Gvir, &
384 t_3c_x_Gocc, t_3c_x_Gvir, t_3c_x_Gocc_2, t_3c_x_Gvir_2)
385 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
386 t_3c_for_gvir, t_3c_x_gocc, &
387 t_3c_x_gvir, t_3c_x_gocc_2, &
390 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_tensors_chi'
394 CALL timeset(routinen, handle)
396 CALL dbt_destroy(t_2c_gocc)
397 CALL dbt_destroy(t_2c_gvir)
398 CALL dbt_destroy(t_3c_for_gocc)
399 CALL dbt_destroy(t_3c_for_gvir)
400 CALL dbt_destroy(t_3c_x_gocc)
401 CALL dbt_destroy(t_3c_x_gvir)
402 CALL dbt_destroy(t_3c_x_gocc_2)
403 CALL dbt_destroy(t_3c_x_gvir_2)
405 CALL timestop(handle)
407 END SUBROUTINE destroy_tensors_chi
417 SUBROUTINE write_matrix(matrix, matrix_index, matrix_name, fm, qs_env)
419 INTEGER :: matrix_index
420 CHARACTER(LEN=*) :: matrix_name
424 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_matrix'
428 CALL timeset(routinen, handle)
434 CALL fm_write(fm, matrix_index, matrix_name, qs_env)
436 CALL timestop(handle)
438 END SUBROUTINE write_matrix
447 SUBROUTINE fm_write(fm, matrix_index, matrix_name, qs_env)
449 INTEGER :: matrix_index
450 CHARACTER(LEN=*) :: matrix_name
453 CHARACTER(LEN=*),
PARAMETER :: key =
'PROPERTIES%BANDSTRUCTURE%GW%PRINT%RESTART', &
454 routinen =
'fm_write'
456 CHARACTER(LEN=default_string_length) :: filename
457 INTEGER :: handle, unit_nr
461 CALL timeset(routinen, handle)
469 IF (matrix_index < 10)
THEN
470 WRITE (filename,
'(3A,I1)')
"RESTART_", matrix_name,
"_0", matrix_index
471 ELSE IF (matrix_index < 100)
THEN
472 WRITE (filename,
'(3A,I2)')
"RESTART_", matrix_name,
"_", matrix_index
474 cpabort(
'Please implement more than 99 time/frequency points.')
478 file_form=
"UNFORMATTED", middle_name=trim(filename), &
479 file_position=
"REWIND", file_action=
"WRITE")
482 IF (unit_nr > 0)
THEN
487 CALL timestop(handle)
489 END SUBROUTINE fm_write
500 SUBROUTINE g_occ_vir(bs_env, tau, fm_G_Gamma, ispin, occ, vir)
507 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_occ_vir'
509 INTEGER :: handle, homo, i_row_local, j_col, &
510 j_col_local, n_mo, ncol_local, &
512 INTEGER,
DIMENSION(:),
POINTER :: col_indices
513 REAL(kind=
dp) :: tau_e
515 CALL timeset(routinen, handle)
517 cpassert(occ .NEQV. vir)
520 nrow_local=nrow_local, &
521 ncol_local=ncol_local, &
522 col_indices=col_indices)
525 homo = bs_env%n_occ(ispin)
527 CALL cp_fm_to_fm(bs_env%fm_mo_coeff_Gamma(ispin), bs_env%fm_work_mo(1))
529 DO i_row_local = 1, nrow_local
530 DO j_col_local = 1, ncol_local
532 j_col = col_indices(j_col_local)
534 tau_e = abs(tau*0.5_dp*(bs_env%eigenval_scf_Gamma(j_col, ispin) - bs_env%e_fermi(ispin)))
536 IF (tau_e < bs_env%stabilize_exp)
THEN
537 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = &
538 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local)*exp(-tau_e)
540 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = 0.0_dp
543 IF ((occ .AND. j_col > homo) .OR. (vir .AND. j_col <= homo))
THEN
544 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = 0.0_dp
550 CALL parallel_gemm(transa=
"N", transb=
"T", m=n_mo, n=n_mo, k=n_mo, alpha=1.0_dp, &
551 matrix_a=bs_env%fm_work_mo(1), matrix_b=bs_env%fm_work_mo(1), &
552 beta=0.0_dp, matrix_c=fm_g_gamma)
554 CALL timestop(handle)
556 END SUBROUTINE g_occ_vir
570 TYPE(dbt_type) :: t_3c
571 INTEGER,
DIMENSION(2),
OPTIONAL :: atoms_ao_1, atoms_ao_2, atoms_ri
573 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_3c_integrals'
576 INTEGER,
DIMENSION(2) :: my_atoms_ao_1, my_atoms_ao_2, my_atoms_ri
577 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_3c_array
579 CALL timeset(routinen, handle)
584 ALLOCATE (t_3c_array(1, 1))
585 CALL dbt_create(t_3c, t_3c_array(1, 1))
587 IF (
PRESENT(atoms_ao_1))
THEN
588 my_atoms_ao_1 = atoms_ao_1
590 my_atoms_ao_1 = [1, bs_env%n_atom]
592 IF (
PRESENT(atoms_ao_2))
THEN
593 my_atoms_ao_2 = atoms_ao_2
595 my_atoms_ao_2 = [1, bs_env%n_atom]
597 IF (
PRESENT(atoms_ri))
THEN
598 my_atoms_ri = atoms_ri
600 my_atoms_ri = [1, bs_env%n_atom]
607 int_eps=bs_env%eps_filter, &
608 basis_i=bs_env%basis_set_RI, &
609 basis_j=bs_env%basis_set_AO, &
610 basis_k=bs_env%basis_set_AO, &
611 potential_parameter=bs_env%ri_metric, &
613 bounds_j=atoms_ao_1, &
614 bounds_k=atoms_ao_2, &
615 desymmetrize=.false.)
617 CALL dbt_copy(t_3c_array(1, 1), t_3c, move_data=.true.)
619 CALL dbt_destroy(t_3c_array(1, 1))
620 DEALLOCATE (t_3c_array)
622 CALL timestop(handle)
636 SUBROUTINE g_times_3c(t_3c_for_G, t_G, t_M, bs_env, atoms_AO_1, atoms_AO_2, atoms_IL)
637 TYPE(dbt_type) :: t_3c_for_g, t_g, t_m
639 INTEGER,
DIMENSION(2) :: atoms_ao_1, atoms_ao_2, atoms_il
641 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_times_3c'
644 INTEGER,
DIMENSION(2) :: bounds_il, bounds_l
645 INTEGER,
DIMENSION(2, 2) :: bounds_k
647 CALL timeset(routinen, handle)
653 bounds_il(1:2) = [bs_env%i_ao_start_from_atom(atoms_il(1)), &
654 bs_env%i_ao_end_from_atom(atoms_il(2))]
655 bounds_k(1:2, 1) = [1, bs_env%n_RI]
656 bounds_k(1:2, 2) = [bs_env%i_ao_start_from_atom(atoms_ao_2(1)), &
657 bs_env%i_ao_end_from_atom(atoms_ao_2(2))]
658 bounds_l(1:2) = [bs_env%i_ao_start_from_atom(atoms_ao_1(1)), &
659 bs_env%i_ao_end_from_atom(atoms_ao_1(2))]
661 CALL dbt_contract(alpha=1.0_dp, &
662 tensor_1=t_3c_for_g, &
666 contract_1=[3], notcontract_1=[1, 2], map_1=[1, 2], &
667 contract_2=[2], notcontract_2=[1], map_2=[3], &
668 bounds_1=bounds_il, &
671 filter_eps=bs_env%eps_filter)
673 CALL dbt_clear(t_3c_for_g)
675 CALL timestop(handle)
677 END SUBROUTINE g_times_3c
687 SUBROUTINE check_dist(atoms_1, atoms_2, qs_env, bs_env, dist_too_long)
688 INTEGER,
DIMENSION(2) :: atoms_1, atoms_2
691 LOGICAL :: dist_too_long
693 CHARACTER(LEN=*),
PARAMETER :: routinen =
'check_dist'
695 INTEGER :: atom_1, atom_2, handle
696 REAL(
dp) :: abs_rab, min_dist_ao_atoms
697 REAL(kind=
dp),
DIMENSION(3) :: rab
701 CALL timeset(routinen, handle)
703 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
705 min_dist_ao_atoms = 1.0e5_dp
706 DO atom_1 = atoms_1(1), atoms_1(2)
707 DO atom_2 = atoms_2(1), atoms_2(2)
709 rab =
pbc(particle_set(atom_1)%r(1:3), particle_set(atom_2)%r(1:3), cell)
711 abs_rab = sqrt(rab(1)**2 + rab(2)**2 + rab(3)**2)
713 min_dist_ao_atoms = min(min_dist_ao_atoms, abs_rab)
718 dist_too_long = (min_dist_ao_atoms > bs_env%max_dist_AO_atoms)
720 CALL timestop(handle)
722 END SUBROUTINE check_dist
731 SUBROUTINE get_w_mic(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
734 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
735 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
737 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_W_MIC'
741 CALL timeset(routinen, handle)
743 IF (bs_env%all_W_exist)
THEN
744 CALL read_w_mic_time(bs_env, mat_chi_gamma_tau, fm_w_mic_time)
746 CALL compute_w_mic(bs_env, qs_env, mat_chi_gamma_tau, fm_w_mic_time)
749 CALL timestop(handle)
751 END SUBROUTINE get_w_mic
760 SUBROUTINE compute_v_k_by_lattice_sum(bs_env, qs_env, fm_V_kp, ikp_batch)
763 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_v_kp
766 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_V_k_by_lattice_sum'
768 INTEGER :: handle, ikp, ikp_end, ikp_start, &
769 nkp_chi_eps_w_batch, re_im
772 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_v_kp
774 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
776 CALL timeset(routinen, handle)
778 nkp_chi_eps_w_batch = bs_env%nkp_chi_eps_W_batch
780 ikp_start = (ikp_batch - 1)*bs_env%nkp_chi_eps_W_batch + 1
781 ikp_end = min(ikp_batch*bs_env%nkp_chi_eps_W_batch, bs_env%kpoints_chi_eps_W%nkp)
784 ALLOCATE (mat_v_kp(ikp_start:ikp_end, 2))
787 DO ikp = ikp_start, ikp_end
788 NULLIFY (mat_v_kp(ikp, re_im)%matrix)
789 ALLOCATE (mat_v_kp(ikp, re_im)%matrix)
790 CALL dbcsr_create(mat_v_kp(ikp, re_im)%matrix, template=bs_env%mat_RI_RI%matrix)
792 CALL dbcsr_set(mat_v_kp(ikp, re_im)%matrix, 0.0_dp)
797 particle_set=particle_set, &
799 qs_kind_set=qs_kind_set, &
800 atomic_kind_set=atomic_kind_set)
802 IF (ikp_end <= bs_env%nkp_chi_eps_W_orig)
THEN
805 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
807 ELSE IF (ikp_start > bs_env%nkp_chi_eps_W_orig .AND. &
808 ikp_end <= bs_env%nkp_chi_eps_W_orig_plus_extra)
THEN
811 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_extra
815 cpabort(
"Error with k-point parallelization.")
820 bs_env%kpoints_chi_eps_W, &
821 basis_type=
"RI_AUX", &
823 particle_set=particle_set, &
824 qs_kind_set=qs_kind_set, &
825 atomic_kind_set=atomic_kind_set, &
826 size_lattice_sum=bs_env%size_lattice_sum_V, &
828 ikp_start=ikp_start, &
831 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
833 ALLOCATE (fm_v_kp(ikp_start:ikp_end, 2))
835 DO ikp = ikp_start, ikp_end
836 CALL cp_fm_create(fm_v_kp(ikp, re_im), bs_env%fm_RI_RI%matrix_struct)
841 DEALLOCATE (mat_v_kp)
843 CALL timestop(handle)
845 END SUBROUTINE compute_v_k_by_lattice_sum
856 SUBROUTINE compute_minvvsqrt_vsqrt(bs_env, qs_env, fm_V_kp, cfm_V_sqrt_ikp, &
857 cfm_M_inv_V_sqrt_ikp, ikp)
860 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_v_kp
861 TYPE(
cp_cfm_type) :: cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp
864 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_MinvVsqrt_Vsqrt'
866 INTEGER :: handle, info, n_ri
868 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_m_ikp
870 CALL timeset(routinen, handle)
876 n_ri, bs_env%ri_metric, do_kpoints=.true., &
877 kpoints=bs_env%kpoints_chi_eps_W, &
878 regularization_ri=bs_env%regularization_RI, ikp_ext=ikp, &
879 do_build_cell_index=(ikp == 1))
882 CALL cp_cfm_create(cfm_v_sqrt_ikp, fm_v_kp(ikp, 1)%matrix_struct)
883 CALL cp_cfm_create(cfm_m_inv_v_sqrt_ikp, fm_v_kp(ikp, 1)%matrix_struct)
885 CALL cp_cfm_create(cfm_m_inv_ikp, fm_v_kp(ikp, 1)%matrix_struct)
887 CALL cp_fm_to_cfm(fm_m_ikp(1, 1), fm_m_ikp(1, 2), cfm_m_inv_ikp)
888 CALL cp_fm_to_cfm(fm_v_kp(ikp, 1), fm_v_kp(ikp, 2), cfm_v_sqrt_ikp)
904 CALL cp_cfm_power(cfm_work, threshold=bs_env%eps_eigval_mat_RI, exponent=-1.0_dp)
913 CALL clean_lower_part(cfm_v_sqrt_ikp)
916 CALL cp_cfm_power(cfm_work, threshold=0.0_dp, exponent=0.5_dp)
922 CALL parallel_gemm(
"N",
"C", n_ri, n_ri, n_ri,
z_one, cfm_m_inv_ikp, cfm_v_sqrt_ikp, &
923 z_zero, cfm_m_inv_v_sqrt_ikp)
927 CALL timestop(handle)
929 END SUBROUTINE compute_minvvsqrt_vsqrt
937 SUBROUTINE read_w_mic_time(bs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
939 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
940 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
942 CHARACTER(LEN=*),
PARAMETER :: routinen =
'read_W_MIC_time'
944 INTEGER :: handle, i_t
947 CALL timeset(routinen, handle)
950 CALL create_fm_w_mic_time(bs_env, fm_w_mic_time)
952 DO i_t = 1, bs_env%num_time_freq_points
956 CALL fm_read(fm_w_mic_time(i_t), bs_env, bs_env%W_time_name, i_t)
958 IF (bs_env%unit_nr > 0)
THEN
959 WRITE (bs_env%unit_nr,
'(T2,A,I5,A,I3,A,F7.1,A)') &
960 τ
'Read W^MIC(i) from file for time point ', i_t,
' /', bs_env%num_time_freq_points, &
966 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
971 CALL cp_fm_create(bs_env%fm_W_MIC_freq_zero, bs_env%fm_W_MIC_freq%matrix_struct)
973 CALL fm_read(bs_env%fm_W_MIC_freq_zero, bs_env,
"W_freq_rtp", 0)
974 IF (bs_env%unit_nr > 0)
THEN
975 WRITE (bs_env%unit_nr,
'(T2,A,I3,A,I3,A,F7.1,A)') &
976 'Read W^MIC(f=0) from file for freq. point ', 1,
' /', 1, &
981 CALL timestop(handle)
983 END SUBROUTINE read_w_mic_time
992 SUBROUTINE compute_w_mic(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
995 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
996 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
998 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_W_MIC'
1000 INTEGER :: handle, i_t, ikp, ikp_batch, &
1003 TYPE(
cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
1004 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_v_kp
1006 CALL timeset(routinen, handle)
1008 CALL create_fm_w_mic_time(bs_env, fm_w_mic_time)
1010 DO ikp_batch = 1, bs_env%num_chi_eps_W_batches
1015 CALL compute_v_k_by_lattice_sum(bs_env, qs_env, fm_v_kp, ikp_batch)
1017 DO ikp_in_batch = 1, bs_env%nkp_chi_eps_W_batch
1019 ikp = (ikp_batch - 1)*bs_env%nkp_chi_eps_W_batch + ikp_in_batch
1021 IF (ikp > bs_env%nkp_chi_eps_W_orig_plus_extra) cycle
1023 CALL compute_minvvsqrt_vsqrt(bs_env, qs_env, fm_v_kp, &
1024 cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp, ikp)
1026 CALL bs_env%para_env%sync()
1030 DO j_w = 1, bs_env%num_time_freq_points
1033 IF (bs_env%approx_kp_extrapol .AND. j_w > 1 .AND. &
1034 ikp > bs_env%nkp_chi_eps_W_orig) cycle
1036 CALL compute_fm_w_mic_freq_j(bs_env, qs_env, bs_env%fm_W_MIC_freq, j_w, ikp, &
1037 mat_chi_gamma_tau, cfm_m_inv_v_sqrt_ikp, &
1041 CALL fourier_transform_w_to_t(bs_env, fm_w_mic_time, bs_env%fm_W_MIC_freq, j_w)
1047 DEALLOCATE (fm_v_kp)
1049 IF (bs_env%unit_nr > 0)
THEN
1050 WRITE (bs_env%unit_nr,
'(T2,A,I12,A,I3,A,F7.1,A)') &
1051 τ
'Computed W(i,k) for k-point batch', &
1052 ikp_batch,
' /', bs_env%num_chi_eps_W_batches, &
1058 IF (bs_env%approx_kp_extrapol)
THEN
1059 CALL apply_extrapol_factor(bs_env, fm_w_mic_time)
1063 CALL multiply_fm_w_mic_time_with_minv_gamma(bs_env, qs_env, fm_w_mic_time)
1065 DO i_t = 1, bs_env%num_time_freq_points
1066 CALL fm_write(fm_w_mic_time(i_t), i_t, bs_env%W_time_name, qs_env)
1076 CALL cp_fm_create(bs_env%fm_W_MIC_freq_zero, bs_env%fm_W_MIC_freq%matrix_struct)
1080 DO i_t = 1, bs_env%num_time_freq_points
1083 bs_env%imag_time_weights_freq_zero(i_t), fm_w_mic_time(i_t))
1086 CALL fm_write(bs_env%fm_W_MIC_freq_zero, 0,
"W_freq_rtp", qs_env)
1088 IF (bs_env%unit_nr > 0)
THEN
1089 WRITE (bs_env%unit_nr,
'(T2,A,I11,A,I3,A,F7.1,A)') &
1090 'Computed W(f=0,k) for k-point batch', &
1096 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
1098 CALL timestop(handle)
1100 END SUBROUTINE compute_w_mic
1113 SUBROUTINE compute_fm_w_mic_freq_j(bs_env, qs_env, fm_W_MIC_freq_j, j_w, ikp, mat_chi_Gamma_tau, &
1114 cfm_M_inv_V_sqrt_ikp, cfm_V_sqrt_ikp)
1119 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1120 TYPE(
cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
1122 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_W_MIC_freq_j'
1125 TYPE(
cp_cfm_type) :: cfm_chi_ikp_freq_j, cfm_w_ikp_freq_j
1127 CALL timeset(routinen, handle)
1130 CALL compute_fm_chi_gamma_freq(bs_env, bs_env%fm_chi_Gamma_freq, j_w, mat_chi_gamma_tau)
1136 ikp, qs_env, bs_env%kpoints_chi_eps_W,
"RI_AUX")
1139 CALL cp_cfm_power(cfm_chi_ikp_freq_j, threshold=0.0_dp, exponent=1.0_dp)
1143 CALL compute_cfm_w_ikp_freq_j(bs_env, cfm_chi_ikp_freq_j, cfm_v_sqrt_ikp, &
1144 cfm_m_inv_v_sqrt_ikp, cfm_w_ikp_freq_j)
1147 SELECT CASE (bs_env%approx_kp_extrapol)
1151 bs_env%kpoints_chi_eps_W,
"RI_AUX")
1162 cfm_w_ikp_freq_j, ikp, bs_env%kpoints_chi_eps_W, &
1165 IF (ikp <= bs_env%nkp_chi_eps_W_orig)
THEN
1167 cfm_w_ikp_freq_j, ikp, bs_env%kpoints_chi_eps_W, &
1168 "RI_AUX", wkp_ext=bs_env%wkp_orig)
1174 IF (ikp <= bs_env%nkp_chi_eps_W_orig)
THEN
1176 ikp, bs_env%kpoints_chi_eps_W,
"RI_AUX", &
1177 wkp_ext=bs_env%wkp_orig)
1183 CALL timestop(handle)
1185 END SUBROUTINE compute_fm_w_mic_freq_j
1191 SUBROUTINE clean_lower_part(cfm_mat)
1194 CHARACTER(LEN=*),
PARAMETER :: routinen =
'clean_lower_part'
1196 INTEGER :: handle, i_row, j_col, j_global, &
1197 ncol_local, nrow_local
1198 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
1200 CALL timeset(routinen, handle)
1203 nrow_local=nrow_local, ncol_local=ncol_local, &
1204 row_indices=row_indices, col_indices=col_indices)
1206 DO j_col = 1, ncol_local
1207 j_global = col_indices(j_col)
1208 DO i_row = 1, nrow_local
1209 IF (j_global < row_indices(i_row)) cfm_mat%local_data(i_row, j_col) =
z_zero
1213 CALL timestop(handle)
1215 END SUBROUTINE clean_lower_part
1222 SUBROUTINE apply_extrapol_factor(bs_env, fm_W_MIC_time)
1224 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1226 CHARACTER(LEN=*),
PARAMETER :: routinen =
'apply_extrapol_factor'
1228 INTEGER :: handle, i, i_t, j, ncol_local, nrow_local
1229 REAL(kind=
dp) :: extrapol_factor, w_extra_1, w_no_extra_1
1231 CALL timeset(routinen, handle)
1233 CALL cp_fm_get_info(matrix=fm_w_mic_time(1), nrow_local=nrow_local, ncol_local=ncol_local)
1235 DO i_t = 1, bs_env%num_time_freq_points
1236 DO j = 1, ncol_local
1237 DO i = 1, nrow_local
1239 w_extra_1 = bs_env%fm_W_MIC_freq_1_extra%local_data(i, j)
1240 w_no_extra_1 = bs_env%fm_W_MIC_freq_1_no_extra%local_data(i, j)
1242 IF (abs(w_no_extra_1) > 1.0e-13)
THEN
1243 extrapol_factor = abs(w_extra_1/w_no_extra_1)
1245 extrapol_factor = 1.0_dp
1249 IF (extrapol_factor > 10.0_dp) extrapol_factor = 1.0_dp
1251 fm_w_mic_time(i_t)%local_data(i, j) = fm_w_mic_time(i_t)%local_data(i, j) &
1257 CALL timestop(handle)
1259 END SUBROUTINE apply_extrapol_factor
1268 SUBROUTINE compute_fm_chi_gamma_freq(bs_env, fm_chi_Gamma_freq, j_w, mat_chi_Gamma_tau)
1272 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1274 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_chi_Gamma_freq'
1276 INTEGER :: handle, i_t
1277 REAL(kind=
dp) :: freq_j, time_i, weight_ij
1279 CALL timeset(routinen, handle)
1281 CALL dbcsr_set(bs_env%mat_RI_RI%matrix, 0.0_dp)
1283 freq_j = bs_env%imag_freq_points(j_w)
1285 DO i_t = 1, bs_env%num_time_freq_points
1287 time_i = bs_env%imag_time_points(i_t)
1288 weight_ij = bs_env%weights_cos_t_to_w(j_w, i_t)
1291 CALL dbcsr_add(bs_env%mat_RI_RI%matrix, mat_chi_gamma_tau(i_t)%matrix, &
1292 1.0_dp, cos(time_i*freq_j)*weight_ij)
1298 CALL timestop(handle)
1300 END SUBROUTINE compute_fm_chi_gamma_freq
1311 SUBROUTINE mat_ikp_from_mat_gamma(mat_ikp_re, mat_ikp_im, mat_Gamma, kpoints, ikp, qs_env)
1312 TYPE(
dbcsr_type) :: mat_ikp_re, mat_ikp_im, mat_gamma
1317 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mat_ikp_from_mat_Gamma'
1319 INTEGER :: col, handle, i_cell, j_cell, num_cells, &
1321 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
1322 LOGICAL :: f, i_cell_is_the_minimum_image_cell
1323 REAL(kind=
dp) :: abs_rab_cell_i, abs_rab_cell_j, arg
1324 REAL(kind=
dp),
DIMENSION(3) :: cell_vector, cell_vector_j, rab_cell_i, &
1326 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
1327 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: block_im, block_re, data_block
1332 CALL timeset(routinen, handle)
1340 NULLIFY (cell, particle_set)
1341 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
1344 index_to_cell => kpoints%index_to_cell
1346 num_cells =
SIZE(index_to_cell, 2)
1348 DO i_cell = 1, num_cells
1354 cell_vector(1:3) = matmul(hmat, real(index_to_cell(1:3, i_cell),
dp))
1356 rab_cell_i(1:3) =
pbc(particle_set(row)%r(1:3), cell) - &
1357 (
pbc(particle_set(col)%r(1:3), cell) + cell_vector(1:3))
1358 abs_rab_cell_i = sqrt(rab_cell_i(1)**2 + rab_cell_i(2)**2 + rab_cell_i(3)**2)
1361 i_cell_is_the_minimum_image_cell = .true.
1362 DO j_cell = 1, num_cells
1363 cell_vector_j(1:3) = matmul(hmat, real(index_to_cell(1:3, j_cell),
dp))
1364 rab_cell_j(1:3) =
pbc(particle_set(row)%r(1:3), cell) - &
1365 (
pbc(particle_set(col)%r(1:3), cell) + cell_vector_j(1:3))
1366 abs_rab_cell_j = sqrt(rab_cell_j(1)**2 + rab_cell_j(2)**2 + rab_cell_j(3)**2)
1368 IF (abs_rab_cell_i > abs_rab_cell_j + 1.0e-6_dp)
THEN
1369 i_cell_is_the_minimum_image_cell = .false.
1373 IF (i_cell_is_the_minimum_image_cell)
THEN
1374 NULLIFY (block_re, block_im)
1375 CALL dbcsr_get_block_p(matrix=mat_ikp_re, row=row, col=col, block=block_re, found=f)
1376 CALL dbcsr_get_block_p(matrix=mat_ikp_im, row=row, col=col, block=block_im, found=f)
1377 cpassert(all(abs(block_re) < 1.0e-10_dp))
1378 cpassert(all(abs(block_im) < 1.0e-10_dp))
1380 arg = real(index_to_cell(1, i_cell),
dp)*kpoints%xkp(1, ikp) + &
1381 REAL(index_to_cell(2, i_cell),
dp)*kpoints%xkp(2, ikp) + &
1382 REAL(index_to_cell(3, i_cell),
dp)*kpoints%xkp(3, ikp)
1384 block_re(:, :) = cos(
twopi*arg)*data_block(:, :)
1385 block_im(:, :) = sin(
twopi*arg)*data_block(:, :)
1393 CALL timestop(handle)
1395 END SUBROUTINE mat_ikp_from_mat_gamma
1405 SUBROUTINE compute_cfm_w_ikp_freq_j(bs_env, cfm_chi_ikp_freq_j, cfm_V_sqrt_ikp, &
1406 cfm_M_inv_V_sqrt_ikp, cfm_W_ikp_freq_j)
1409 TYPE(
cp_cfm_type) :: cfm_chi_ikp_freq_j, cfm_v_sqrt_ikp, &
1410 cfm_m_inv_v_sqrt_ikp, cfm_w_ikp_freq_j
1412 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_cfm_W_ikp_freq_j'
1414 INTEGER :: handle, info, n_ri
1417 CALL timeset(routinen, handle)
1419 CALL cp_cfm_create(cfm_work, cfm_chi_ikp_freq_j%matrix_struct)
1426 cfm_chi_ikp_freq_j, cfm_m_inv_v_sqrt_ikp,
z_zero, cfm_work)
1430 CALL cp_cfm_create(cfm_eps_ikp_freq_j, cfm_work%matrix_struct)
1432 cfm_m_inv_v_sqrt_ikp, cfm_work,
z_zero, cfm_eps_ikp_freq_j)
1435 CALL cfm_add_on_diag(cfm_eps_ikp_freq_j,
z_one)
1448 CALL cfm_add_on_diag(cfm_eps_ikp_freq_j, -
z_one)
1451 CALL parallel_gemm(
'N',
'N', n_ri, n_ri, n_ri,
z_one, cfm_eps_ikp_freq_j, cfm_v_sqrt_ikp, &
1455 CALL cp_cfm_create(cfm_w_ikp_freq_j, cfm_work%matrix_struct)
1457 z_zero, cfm_w_ikp_freq_j)
1462 CALL timestop(handle)
1464 END SUBROUTINE compute_cfm_w_ikp_freq_j
1471 SUBROUTINE cfm_add_on_diag(cfm, alpha)
1474 COMPLEX(KIND=dp) :: alpha
1476 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cfm_add_on_diag'
1478 INTEGER :: handle, i_row, j_col, j_global, &
1479 ncol_local, nrow_local
1480 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
1482 CALL timeset(routinen, handle)
1485 nrow_local=nrow_local, &
1486 ncol_local=ncol_local, &
1487 row_indices=row_indices, &
1488 col_indices=col_indices)
1491 DO j_col = 1, ncol_local
1492 j_global = col_indices(j_col)
1493 DO i_row = 1, nrow_local
1494 IF (j_global == row_indices(i_row))
THEN
1495 cfm%local_data(i_row, j_col) = cfm%local_data(i_row, j_col) + alpha
1500 CALL timestop(handle)
1502 END SUBROUTINE cfm_add_on_diag
1509 SUBROUTINE create_fm_w_mic_time(bs_env, fm_W_MIC_time)
1511 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1513 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_fm_W_MIC_time'
1515 INTEGER :: handle, i_t
1517 CALL timeset(routinen, handle)
1519 ALLOCATE (fm_w_mic_time(bs_env%num_time_freq_points))
1520 DO i_t = 1, bs_env%num_time_freq_points
1521 CALL cp_fm_create(fm_w_mic_time(i_t), bs_env%fm_RI_RI%matrix_struct, set_zero=.true.)
1524 CALL timestop(handle)
1526 END SUBROUTINE create_fm_w_mic_time
1535 SUBROUTINE fourier_transform_w_to_t(bs_env, fm_W_MIC_time, fm_W_MIC_freq_j, j_w)
1537 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1541 CHARACTER(LEN=*),
PARAMETER :: routinen =
'Fourier_transform_w_to_t'
1543 INTEGER :: handle, i_t
1544 REAL(kind=
dp) :: freq_j, time_i, weight_ij
1546 CALL timeset(routinen, handle)
1548 freq_j = bs_env%imag_freq_points(j_w)
1550 DO i_t = 1, bs_env%num_time_freq_points
1552 time_i = bs_env%imag_time_points(i_t)
1553 weight_ij = bs_env%weights_cos_w_to_t(i_t, j_w)
1557 beta=weight_ij*cos(time_i*freq_j), matrix_b=fm_w_mic_freq_j)
1561 CALL timestop(handle)
1563 END SUBROUTINE fourier_transform_w_to_t
1571 SUBROUTINE multiply_fm_w_mic_time_with_minv_gamma(bs_env, qs_env, fm_W_MIC_time)
1574 TYPE(
cp_fm_type),
DIMENSION(:) :: fm_w_mic_time
1576 CHARACTER(LEN=*),
PARAMETER :: routinen =
'multiply_fm_W_MIC_time_with_Minv_Gamma'
1578 INTEGER :: handle, i_t, n_ri, ndep
1580 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_minv_gamma
1582 CALL timeset(routinen, handle)
1586 CALL cp_fm_create(fm_work, fm_w_mic_time(1)%matrix_struct)
1590 bs_env%ri_metric, do_kpoints=.false.)
1592 CALL cp_fm_power(fm_minv_gamma(1, 1), fm_work, -1.0_dp, 0.0_dp, ndep)
1595 DO i_t = 1,
SIZE(fm_w_mic_time)
1597 CALL parallel_gemm(
'N',
'N', n_ri, n_ri, n_ri, 1.0_dp, fm_minv_gamma(1, 1), &
1598 fm_w_mic_time(i_t), 0.0_dp, fm_work)
1600 CALL parallel_gemm(
'N',
'N', n_ri, n_ri, n_ri, 1.0_dp, fm_work, &
1601 fm_minv_gamma(1, 1), 0.0_dp, fm_w_mic_time(i_t))
1608 CALL timestop(handle)
1610 END SUBROUTINE multiply_fm_w_mic_time_with_minv_gamma
1618 SUBROUTINE get_sigma_x(bs_env, qs_env, fm_Sigma_x_Gamma)
1621 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
1623 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Sigma_x'
1625 INTEGER :: handle, ispin
1627 CALL timeset(routinen, handle)
1629 ALLOCATE (fm_sigma_x_gamma(bs_env%n_spin))
1630 DO ispin = 1, bs_env%n_spin
1631 CALL cp_fm_create(fm_sigma_x_gamma(ispin), bs_env%fm_s_Gamma%matrix_struct)
1634 IF (bs_env%Sigma_x_exists)
THEN
1635 DO ispin = 1, bs_env%n_spin
1636 CALL fm_read(fm_sigma_x_gamma(ispin), bs_env, bs_env%Sigma_x_name, ispin)
1639 CALL compute_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
1642 CALL timestop(handle)
1644 END SUBROUTINE get_sigma_x
1652 SUBROUTINE compute_sigma_x(bs_env, qs_env, fm_Sigma_x_Gamma)
1655 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
1657 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Sigma_x'
1659 INTEGER :: handle, i_intval_idx, ispin, j_intval_idx
1660 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1662 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_vtr_gamma
1664 TYPE(dbt_type) :: t_2c_d, t_2c_sigma_x, t_2c_v, t_3c_x_v
1666 CALL timeset(routinen, handle)
1670 CALL dbt_create(bs_env%t_G, t_2c_d)
1671 CALL dbt_create(bs_env%t_W, t_2c_v)
1672 CALL dbt_create(bs_env%t_G, t_2c_sigma_x)
1673 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_v)
1674 CALL dbcsr_create(mat_sigma_x_gamma, template=bs_env%mat_ao_ao%matrix)
1678 bs_env%trunc_coulomb, do_kpoints=.false.)
1681 CALL multiply_fm_w_mic_time_with_minv_gamma(bs_env, qs_env, fm_vtr_gamma(:, 1))
1683 DO ispin = 1, bs_env%n_spin
1686 CALL g_occ_vir(bs_env, 0.0_dp, bs_env%fm_work_mo(2), ispin, occ=.true., vir=.false.)
1689 bs_env%mat_ao_ao_tensor%matrix, t_2c_d, bs_env, &
1690 bs_env%atoms_i_t_group)
1693 bs_env%mat_RI_RI_tensor%matrix, t_2c_v, bs_env, &
1694 bs_env%atoms_j_t_group)
1698 DO i_intval_idx = 1, bs_env%n_intervals_i
1699 DO j_intval_idx = 1, bs_env%n_intervals_j
1700 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
1701 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
1705 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_v, t_2c_v)
1709 CALL contract_to_sigma(t_2c_d, t_3c_x_v, t_2c_sigma_x, i_atoms, j_atoms, &
1710 qs_env, bs_env, occ=.true., vir=.false., clear_w=.true.)
1716 mat_sigma_x_gamma, bs_env%para_env)
1718 CALL write_matrix(mat_sigma_x_gamma, ispin, bs_env%Sigma_x_name, &
1719 bs_env%fm_work_mo(1), qs_env)
1725 IF (bs_env%unit_nr > 0)
THEN
1726 WRITE (bs_env%unit_nr,
'(T2,A,T58,A,F7.1,A)') &
1727 Σ
'Computed ^x(k=0),',
' Execution time',
m_walltime() - t1,
' s'
1728 WRITE (bs_env%unit_nr,
'(A)')
' '
1732 CALL dbt_destroy(t_2c_d)
1733 CALL dbt_destroy(t_2c_v)
1734 CALL dbt_destroy(t_2c_sigma_x)
1735 CALL dbt_destroy(t_3c_x_v)
1738 CALL timestop(handle)
1740 END SUBROUTINE compute_sigma_x
1749 SUBROUTINE get_sigma_c(bs_env, qs_env, fm_W_MIC_time, fm_Sigma_c_Gamma_time)
1752 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1753 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
1755 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Sigma_c'
1757 INTEGER :: handle, i_intval_idx, i_t, ispin, &
1758 j_intval_idx, read_write_index
1759 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1760 REAL(kind=
dp) :: t1, tau
1761 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
1762 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, &
1763 t_2c_sigma_neg_tau, &
1764 t_2c_sigma_pos_tau, t_2c_w, t_3c_x_w
1766 CALL timeset(routinen, handle)
1768 CALL create_mat_for_sigma_c(bs_env, t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, &
1769 t_2c_sigma_pos_tau, t_3c_x_w, &
1770 mat_sigma_neg_tau, mat_sigma_pos_tau)
1772 DO i_t = 1, bs_env%num_time_freq_points
1774 DO ispin = 1, bs_env%n_spin
1778 read_write_index = i_t + (ispin - 1)*bs_env%num_time_freq_points
1781 IF (bs_env%Sigma_c_exists(i_t, ispin))
THEN
1782 CALL fm_read(bs_env%fm_work_mo(1), bs_env, bs_env%Sigma_p_name, read_write_index)
1783 CALL copy_fm_to_dbcsr(bs_env%fm_work_mo(1), mat_sigma_pos_tau(i_t, ispin)%matrix, &
1784 keep_sparsity=.false.)
1785 CALL fm_read(bs_env%fm_work_mo(1), bs_env, bs_env%Sigma_n_name, read_write_index)
1786 CALL copy_fm_to_dbcsr(bs_env%fm_work_mo(1), mat_sigma_neg_tau(i_t, ispin)%matrix, &
1787 keep_sparsity=.false.)
1788 IF (bs_env%unit_nr > 0)
THEN
1789 WRITE (bs_env%unit_nr,
'(T2,2A,I3,A,I3,A,F7.1,A)') Στ
'Read ^c(i,k=0) ', &
1790 'from file for time point ', i_t,
' /', bs_env%num_time_freq_points, &
1798 tau = bs_env%imag_time_points(i_t)
1800 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gocc, ispin, occ=.true., vir=.false.)
1801 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gvir, ispin, occ=.false., vir=.true.)
1805 bs_env%mat_ao_ao_tensor%matrix, t_2c_gocc, bs_env, &
1806 bs_env%atoms_i_t_group)
1808 bs_env%mat_ao_ao_tensor%matrix, t_2c_gvir, bs_env, &
1809 bs_env%atoms_i_t_group)
1811 bs_env%mat_RI_RI_tensor%matrix, t_2c_w, bs_env, &
1812 bs_env%atoms_j_t_group)
1816 DO i_intval_idx = 1, bs_env%n_intervals_i
1817 DO j_intval_idx = 1, bs_env%n_intervals_j
1818 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
1819 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
1821 IF (bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx) .AND. &
1822 bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx)) cycle
1826 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_w, t_2c_w)
1830 CALL contract_to_sigma(t_2c_gocc, t_3c_x_w, t_2c_sigma_neg_tau, i_atoms, j_atoms, &
1831 qs_env, bs_env, occ=.true., vir=.false., clear_w=.false., &
1832 can_skip=bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx))
1835 CALL contract_to_sigma(t_2c_gvir, t_3c_x_w, t_2c_sigma_pos_tau, i_atoms, j_atoms, &
1836 qs_env, bs_env, occ=.false., vir=.true., clear_w=.true., &
1837 can_skip=bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx))
1845 mat_sigma_neg_tau(i_t, ispin)%matrix, bs_env%para_env)
1847 mat_sigma_pos_tau(i_t, ispin)%matrix, bs_env%para_env)
1849 CALL write_matrix(mat_sigma_pos_tau(i_t, ispin)%matrix, read_write_index, &
1850 bs_env%Sigma_p_name, bs_env%fm_work_mo(1), qs_env)
1851 CALL write_matrix(mat_sigma_neg_tau(i_t, ispin)%matrix, read_write_index, &
1852 bs_env%Sigma_n_name, bs_env%fm_work_mo(1), qs_env)
1854 IF (bs_env%unit_nr > 0)
THEN
1855 WRITE (bs_env%unit_nr,
'(T2,A,I10,A,I3,A,F7.1,A)') &
1856 Στ
'Computed ^c(i,k=0) for time point ', i_t,
' /', bs_env%num_time_freq_points, &
1864 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
1866 CALL fill_fm_sigma_c_gamma_time(fm_sigma_c_gamma_time, bs_env, &
1867 mat_sigma_pos_tau, mat_sigma_neg_tau)
1869 CALL print_skipping(bs_env)
1871 CALL destroy_mat_sigma_c(t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, &
1872 t_2c_sigma_pos_tau, t_3c_x_w, fm_w_mic_time, &
1873 mat_sigma_neg_tau, mat_sigma_pos_tau)
1875 CALL delete_unnecessary_files(bs_env)
1877 CALL timestop(handle)
1879 END SUBROUTINE get_sigma_c
1893 SUBROUTINE create_mat_for_sigma_c(bs_env, t_2c_Gocc, t_2c_Gvir, t_2c_W, t_2c_Sigma_neg_tau, &
1894 t_2c_Sigma_pos_tau, t_3c_x_W, &
1895 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
1898 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
1899 t_2c_sigma_neg_tau, &
1900 t_2c_sigma_pos_tau, t_3c_x_w
1901 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
1903 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_mat_for_Sigma_c'
1905 INTEGER :: handle, i_t, ispin
1907 CALL timeset(routinen, handle)
1909 CALL dbt_create(bs_env%t_G, t_2c_gocc)
1910 CALL dbt_create(bs_env%t_G, t_2c_gvir)
1911 CALL dbt_create(bs_env%t_W, t_2c_w)
1912 CALL dbt_create(bs_env%t_G, t_2c_sigma_neg_tau)
1913 CALL dbt_create(bs_env%t_G, t_2c_sigma_pos_tau)
1914 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_w)
1916 NULLIFY (mat_sigma_neg_tau, mat_sigma_pos_tau)
1917 ALLOCATE (mat_sigma_neg_tau(bs_env%num_time_freq_points, bs_env%n_spin))
1918 ALLOCATE (mat_sigma_pos_tau(bs_env%num_time_freq_points, bs_env%n_spin))
1920 DO ispin = 1, bs_env%n_spin
1921 DO i_t = 1, bs_env%num_time_freq_points
1922 ALLOCATE (mat_sigma_neg_tau(i_t, ispin)%matrix)
1923 ALLOCATE (mat_sigma_pos_tau(i_t, ispin)%matrix)
1924 CALL dbcsr_create(mat_sigma_neg_tau(i_t, ispin)%matrix, template=bs_env%mat_ao_ao%matrix)
1925 CALL dbcsr_create(mat_sigma_pos_tau(i_t, ispin)%matrix, template=bs_env%mat_ao_ao%matrix)
1929 CALL timestop(handle)
1931 END SUBROUTINE create_mat_for_sigma_c
1942 SUBROUTINE compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_W, t_2c_W)
1946 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1947 TYPE(dbt_type) :: t_3c_x_w, t_2c_w
1949 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_3c_and_contract_W'
1951 INTEGER :: handle, ri_intval_idx
1952 INTEGER,
DIMENSION(2) :: bounds_j, ri_atoms
1953 TYPE(dbt_type) :: t_3c_for_w, t_3c_x_w_tmp
1955 CALL timeset(routinen, handle)
1957 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_w_tmp)
1958 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_for_w)
1960 bounds_j(1:2) = [bs_env%i_RI_start_from_atom(j_atoms(1)), &
1961 bs_env%i_RI_end_from_atom(j_atoms(2))]
1963 DO ri_intval_idx = 1, bs_env%n_intervals_inner_loop_atoms
1964 ri_atoms = bs_env%inner_loop_atom_intervals(1:2, ri_intval_idx)
1968 atoms_ao_1=i_atoms, atoms_ri=ri_atoms)
1971 CALL dbt_contract(alpha=1.0_dp, &
1973 tensor_2=t_3c_for_w, &
1975 tensor_3=t_3c_x_w_tmp, &
1976 contract_1=[2], notcontract_1=[1], map_1=[1], &
1977 contract_2=[1], notcontract_2=[2, 3], map_2=[2, 3], &
1978 bounds_2=bounds_j, &
1979 filter_eps=bs_env%eps_filter)
1984 CALL dbt_copy(t_3c_x_w_tmp, t_3c_x_w, order=[1, 2, 3], move_data=.true.)
1986 CALL dbt_destroy(t_3c_x_w_tmp)
1987 CALL dbt_destroy(t_3c_for_w)
1989 CALL timestop(handle)
1991 END SUBROUTINE compute_3c_and_contract_w
2007 SUBROUTINE contract_to_sigma(t_2c_G, t_3c_x_W, t_2c_Sigma, i_atoms, j_atoms, qs_env, bs_env, &
2008 occ, vir, clear_W, can_skip)
2009 TYPE(dbt_type) :: t_2c_g, t_3c_x_w, t_2c_sigma
2010 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
2013 LOGICAL :: occ, vir, clear_w
2014 LOGICAL,
OPTIONAL :: can_skip
2016 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_to_Sigma'
2018 INTEGER :: handle, inner_loop_atoms_interval_index
2019 INTEGER(KIND=int_8) :: flop
2020 INTEGER,
DIMENSION(2) :: bounds_i, il_atoms
2021 REAL(kind=
dp) :: sign_sigma
2022 TYPE(dbt_type) :: t_3c_for_g, t_3c_x_g, t_3c_x_g_2
2024 CALL timeset(routinen, handle)
2026 cpassert(occ .EQV. (.NOT. vir))
2027 IF (occ) sign_sigma = -1.0_dp
2028 IF (vir) sign_sigma = 1.0_dp
2030 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_g)
2031 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_g)
2032 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_g_2)
2034 bounds_i(1:2) = [bs_env%i_ao_start_from_atom(i_atoms(1)), &
2035 bs_env%i_ao_end_from_atom(i_atoms(2))]
2037 DO inner_loop_atoms_interval_index = 1, bs_env%n_intervals_inner_loop_atoms
2038 il_atoms = bs_env%inner_loop_atom_intervals(1:2, inner_loop_atoms_interval_index)
2041 atoms_ri=j_atoms, atoms_ao_2=il_atoms)
2043 CALL dbt_contract(alpha=1.0_dp, &
2045 tensor_2=t_3c_for_g, &
2047 tensor_3=t_3c_x_g, &
2048 contract_1=[2], notcontract_1=[1], map_1=[3], &
2049 contract_2=[3], notcontract_2=[1, 2], map_2=[1, 2], &
2050 bounds_2=bounds_i, &
2051 filter_eps=bs_env%eps_filter)
2055 CALL dbt_copy(t_3c_x_g, t_3c_x_g_2, order=[1, 3, 2], move_data=.true.)
2057 CALL dbt_contract(alpha=sign_sigma, &
2058 tensor_1=t_3c_x_w, &
2059 tensor_2=t_3c_x_g_2, &
2061 tensor_3=t_2c_sigma, &
2062 contract_1=[1, 2], notcontract_1=[3], map_1=[1], &
2063 contract_2=[1, 2], notcontract_2=[3], map_2=[2], &
2064 filter_eps=bs_env%eps_filter, move_data=clear_w, flop=flop)
2066 IF (
PRESENT(can_skip))
THEN
2067 IF (flop == 0_int_8) can_skip = .true.
2070 CALL dbt_destroy(t_3c_for_g)
2071 CALL dbt_destroy(t_3c_x_g)
2072 CALL dbt_destroy(t_3c_x_g_2)
2074 CALL timestop(handle)
2076 END SUBROUTINE contract_to_sigma
2085 SUBROUTINE fill_fm_sigma_c_gamma_time(fm_Sigma_c_Gamma_time, bs_env, &
2086 mat_Sigma_pos_tau, mat_Sigma_neg_tau)
2088 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
2090 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_pos_tau, mat_sigma_neg_tau
2092 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fill_fm_Sigma_c_Gamma_time'
2094 INTEGER :: handle, i_t, ispin, pos_neg
2096 CALL timeset(routinen, handle)
2098 ALLOCATE (fm_sigma_c_gamma_time(bs_env%num_time_freq_points, 2, bs_env%n_spin))
2099 DO ispin = 1, bs_env%n_spin
2100 DO i_t = 1, bs_env%num_time_freq_points
2102 CALL cp_fm_create(fm_sigma_c_gamma_time(i_t, pos_neg, ispin), &
2103 bs_env%fm_s_Gamma%matrix_struct)
2106 fm_sigma_c_gamma_time(i_t, 1, ispin))
2108 fm_sigma_c_gamma_time(i_t, 2, ispin))
2112 CALL timestop(handle)
2114 END SUBROUTINE fill_fm_sigma_c_gamma_time
2120 SUBROUTINE print_skipping(bs_env)
2124 CHARACTER(LEN=*),
PARAMETER :: routinen =
'print_skipping'
2126 INTEGER :: handle, i_intval_idx, j_intval_idx, &
2129 CALL timeset(routinen, handle)
2133 DO i_intval_idx = 1, bs_env%n_intervals_i
2134 DO j_intval_idx = 1, bs_env%n_intervals_j
2135 IF (bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx) .AND. &
2136 bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx))
THEN
2142 IF (bs_env%unit_nr > 0)
THEN
2143 WRITE (bs_env%unit_nr,
'(T2,A,T74,F7.1,A)') &
2144 Στ
'Sparsity of ^c(i,k=0): Percentage of skipped atom pairs:', &
2145 REAL(100*n_skip, kind=
dp)/real(i_intval_idx*j_intval_idx, kind=
dp),
' %'
2148 CALL timestop(handle)
2150 END SUBROUTINE print_skipping
2164 SUBROUTINE destroy_mat_sigma_c(t_2c_Gocc, t_2c_Gvir, t_2c_W, t_2c_Sigma_neg_tau, &
2165 t_2c_Sigma_pos_tau, t_3c_x_W, fm_W_MIC_time, &
2166 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
2168 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
2169 t_2c_sigma_neg_tau, &
2170 t_2c_sigma_pos_tau, t_3c_x_w
2171 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
2172 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
2174 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_mat_Sigma_c'
2178 CALL timeset(routinen, handle)
2180 CALL dbt_destroy(t_2c_gocc)
2181 CALL dbt_destroy(t_2c_gvir)
2182 CALL dbt_destroy(t_2c_w)
2183 CALL dbt_destroy(t_2c_sigma_neg_tau)
2184 CALL dbt_destroy(t_2c_sigma_pos_tau)
2185 CALL dbt_destroy(t_3c_x_w)
2190 CALL timestop(handle)
2192 END SUBROUTINE destroy_mat_sigma_c
2198 SUBROUTINE delete_unnecessary_files(bs_env)
2201 CHARACTER(LEN=*),
PARAMETER :: routinen =
'delete_unnecessary_files'
2203 CHARACTER(LEN=default_string_length) :: f_chi, f_w_t, prefix
2204 INTEGER :: handle, i_t
2206 CALL timeset(routinen, handle)
2208 prefix = bs_env%prefix
2210 DO i_t = 1, bs_env%num_time_freq_points
2213 WRITE (f_chi,
'(3A,I1,A)') trim(prefix), bs_env%chi_name,
"_00", i_t,
".matrix"
2214 WRITE (f_w_t,
'(3A,I1,A)') trim(prefix), bs_env%W_time_name,
"_00", i_t,
".matrix"
2215 ELSE IF (i_t < 100)
THEN
2216 WRITE (f_chi,
'(3A,I2,A)') trim(prefix), bs_env%chi_name,
"_0", i_t,
".matrix"
2217 WRITE (f_w_t,
'(3A,I2,A)') trim(prefix), bs_env%W_time_name,
"_0", i_t,
".matrix"
2219 cpabort(
'Please implement more than 99 time/frequency points.')
2222 CALL safe_delete(f_chi, bs_env)
2223 CALL safe_delete(f_w_t, bs_env)
2227 CALL timestop(handle)
2229 END SUBROUTINE delete_unnecessary_files
2236 SUBROUTINE safe_delete(filename, bs_env)
2237 CHARACTER(LEN=*) :: filename
2240 CHARACTER(LEN=*),
PARAMETER :: routinen =
'safe_delete'
2245 CALL timeset(routinen, handle)
2247 IF (bs_env%para_env%mepos == 0)
THEN
2254 CALL timestop(handle)
2256 END SUBROUTINE safe_delete
2265 SUBROUTINE compute_qp_energies(bs_env, qs_env, fm_Sigma_x_Gamma, fm_Sigma_c_Gamma_time)
2269 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
2270 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
2272 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_QP_energies'
2274 INTEGER :: handle, ikp, ispin, j_t
2275 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sigma_x_ikp_n, v_xc_ikp_n
2276 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: sigma_c_ikp_n_freq, sigma_c_ikp_n_time
2277 TYPE(
cp_cfm_type) :: cfm_ks_ikp, cfm_mos_ikp, cfm_s_ikp, &
2278 cfm_sigma_x_ikp, cfm_work_ikp
2280 CALL timeset(routinen, handle)
2282 CALL cp_cfm_create(cfm_mos_ikp, bs_env%fm_s_Gamma%matrix_struct)
2283 CALL cp_cfm_create(cfm_work_ikp, bs_env%fm_s_Gamma%matrix_struct)
2285 ALLOCATE (v_xc_ikp_n(bs_env%n_ao), sigma_x_ikp_n(bs_env%n_ao))
2286 ALLOCATE (sigma_c_ikp_n_time(bs_env%n_ao, bs_env%num_time_freq_points, 2))
2287 ALLOCATE (sigma_c_ikp_n_freq(bs_env%n_ao, bs_env%num_time_freq_points, 2))
2289 DO ispin = 1, bs_env%n_spin
2291 DO ikp = 1, bs_env%nkp_bs_and_DOS
2295 ikp, qs_env, bs_env%kpoints_DOS,
"ORB")
2299 ikp, qs_env, bs_env%kpoints_DOS,
"ORB")
2302 CALL cp_cfm_geeig(cfm_ks_ikp, cfm_s_ikp, cfm_mos_ikp, &
2303 bs_env%eigenval_scf(:, ikp, ispin), cfm_work_ikp)
2306 CALL to_ikp_and_mo(v_xc_ikp_n, bs_env%fm_V_xc_Gamma(ispin), &
2307 ikp, qs_env, bs_env, cfm_mos_ikp)
2310 CALL to_ikp_and_mo(sigma_x_ikp_n, fm_sigma_x_gamma(ispin), &
2311 ikp, qs_env, bs_env, cfm_mos_ikp)
2314 DO j_t = 1, bs_env%num_time_freq_points
2315 CALL to_ikp_and_mo(sigma_c_ikp_n_time(:, j_t, 1), &
2316 fm_sigma_c_gamma_time(j_t, 1, ispin), &
2317 ikp, qs_env, bs_env, cfm_mos_ikp)
2318 CALL to_ikp_and_mo(sigma_c_ikp_n_time(:, j_t, 2), &
2319 fm_sigma_c_gamma_time(j_t, 2, ispin), &
2320 ikp, qs_env, bs_env, cfm_mos_ikp)
2324 CALL time_to_freq(bs_env, sigma_c_ikp_n_time, sigma_c_ikp_n_freq, ispin)
2329 bs_env%eigenval_scf(:, ikp, ispin), ikp, ispin)
2345 CALL timestop(handle)
2347 END SUBROUTINE compute_qp_energies
2358 SUBROUTINE to_ikp_and_mo(array_ikp_n, fm_Gamma, ikp, qs_env, bs_env, cfm_mos_ikp)
2360 REAL(kind=
dp),
DIMENSION(:) :: array_ikp_n
2367 CHARACTER(LEN=*),
PARAMETER :: routinen =
'to_ikp_and_mo'
2372 CALL timeset(routinen, handle)
2374 CALL cp_fm_create(fm_ikp_mo_re, fm_gamma%matrix_struct)
2376 CALL fm_gamma_ao_to_cfm_ikp_mo(fm_gamma, fm_ikp_mo_re, ikp, qs_env, bs_env, cfm_mos_ikp)
2382 CALL timestop(handle)
2384 END SUBROUTINE to_ikp_and_mo
2395 SUBROUTINE fm_gamma_ao_to_cfm_ikp_mo(fm_Gamma, fm_ikp_mo_re, ikp, qs_env, bs_env, cfm_mos_ikp)
2402 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_Gamma_ao_to_cfm_ikp_mo'
2404 INTEGER :: handle, nmo
2405 TYPE(
cp_cfm_type) :: cfm_ikp_ao, cfm_ikp_mo, cfm_tmp
2407 CALL timeset(routinen, handle)
2426 CALL timestop(handle)
2428 END SUBROUTINE fm_gamma_ao_to_cfm_ikp_mo
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)
...
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)
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_fm_to_cfm(msourcer, msourcei, mtarget)
Construct a complex full matrix by taking its real and imaginary parts from two separate real-value f...
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_deallocate_matrix(matrix)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_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_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)
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....
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public cp_fm_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
...
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_create(matrix, matrix_struct, name, use_sp, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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
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....
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)
...
Routines from paper [Graml2024].
subroutine, public gw_calc_large_cell_gamma(qs_env, bs_env)
Perform GW band structure calculation.
subroutine, public compute_3c_integrals(qs_env, bs_env, t_3c, atoms_ao_1, atoms_ao_2, atoms_ri)
...
subroutine, public time_to_freq(bs_env, sigma_c_n_time, sigma_c_n_freq, ispin)
...
subroutine, public de_init_bs_env(bs_env)
...
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)
...
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_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_kpoints, fm_matrix_l, dimen_ri, ri_metric, do_kpoints, kpoints, put_mat_ks_env, regularization_ri, ikp_ext, do_build_cell_index)
...
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, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, 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 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.