44 USE dbcsr_api,
ONLY: &
45 dbcsr_add, dbcsr_copy, dbcsr_create, dbcsr_deallocate_matrix, dbcsr_filter, &
46 dbcsr_get_block_p, dbcsr_iterator_blocks_left, dbcsr_iterator_next_block, &
47 dbcsr_iterator_start, dbcsr_iterator_stop, dbcsr_iterator_type, dbcsr_p_type, &
48 dbcsr_release, dbcsr_reserve_all_blocks, dbcsr_set, dbcsr_type
52 dbt_copy_matrix_to_tensor,&
53 dbt_copy_tensor_to_matrix,&
90#include "./base/base_uses.f90"
96 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'gw_methods'
110 SUBROUTINE gw(qs_env, bs_env, post_scf_bandstructure_section)
115 CHARACTER(LEN=*),
PARAMETER :: routinen =
'gw'
118 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma, fm_w_mic_time
119 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
122 CALL timeset(routinen, handle)
131 CALL get_mat_chi_gamma_tau(bs_env, qs_env, bs_env%mat_chi_Gamma_tau)
134 CALL get_w_mic(bs_env, qs_env, bs_env%mat_chi_Gamma_tau, fm_w_mic_time)
138 CALL get_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
142 CALL get_sigma_c(bs_env, qs_env, fm_w_mic_time, fm_sigma_c_gamma_time)
145 CALL compute_qp_energies(bs_env, qs_env, fm_sigma_x_gamma, fm_sigma_c_gamma_time)
149 CALL timestop(handle)
159 SUBROUTINE get_mat_chi_gamma_tau(bs_env, qs_env, mat_chi_Gamma_tau)
162 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
164 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_mat_chi_Gamma_tau'
166 INTEGER :: handle, i_intval_idx, i_t, inner_loop_atoms_interval_index, ispin, j_intval_idx
167 INTEGER,
DIMENSION(2) :: i_atoms, il_atoms, j_atoms
168 LOGICAL :: dist_too_long_i, dist_too_long_j
170 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
171 t_3c_for_gvir, t_3c_x_gocc, &
172 t_3c_x_gocc_2, t_3c_x_gvir, &
175 CALL timeset(routinen, handle)
177 DO i_t = 1, bs_env%num_time_freq_points
181 IF (bs_env%read_chi(i_t))
THEN
183 CALL fm_read(bs_env%fm_RI_RI, bs_env, bs_env%chi_name, i_t)
185 keep_sparsity=.false.)
187 IF (bs_env%unit_nr > 0)
THEN
188 WRITE (bs_env%unit_nr,
'(T2,A,I5,A,I3,A,F7.1,A)') &
189 χτ
'Read (i,k=0) from file for time point ', i_t,
' /', &
190 bs_env%num_time_freq_points, &
191 ', Execution time',
m_walltime() - bs_env%t1,
' s'
198 IF (.NOT. bs_env%calc_chi(i_t)) cycle
200 CALL create_tensors_chi(t_2c_gocc, t_2c_gvir, t_3c_for_gocc, t_3c_for_gvir, &
201 t_3c_x_gocc, t_3c_x_gvir, t_3c_x_gocc_2, t_3c_x_gvir_2, bs_env)
207 tau = bs_env%imag_time_points(i_t)
209 DO ispin = 1, bs_env%n_spin
210 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gocc, ispin, occ=.true., vir=.false.)
211 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gvir, ispin, occ=.false., vir=.true.)
212 CALL fm_to_local_tensor(bs_env%fm_Gocc, bs_env%mat_ao_ao%matrix, &
213 bs_env%mat_ao_ao_tensor%matrix, t_2c_gocc, bs_env, &
214 bs_env%atoms_j_t_group)
215 CALL fm_to_local_tensor(bs_env%fm_Gvir, bs_env%mat_ao_ao%matrix, &
216 bs_env%mat_ao_ao_tensor%matrix, t_2c_gvir, bs_env, &
217 bs_env%atoms_i_t_group)
221 DO i_intval_idx = 1, bs_env%n_intervals_i
222 DO j_intval_idx = 1, bs_env%n_intervals_j
223 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
224 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
226 DO inner_loop_atoms_interval_index = 1, bs_env%n_intervals_inner_loop_atoms
228 il_atoms = bs_env%inner_loop_atom_intervals(1:2, inner_loop_atoms_interval_index)
230 CALL check_dist(i_atoms, il_atoms, qs_env, bs_env, dist_too_long_i)
231 CALL check_dist(j_atoms, il_atoms, qs_env, bs_env, dist_too_long_j)
232 IF (dist_too_long_i .OR. dist_too_long_j) cycle
235 CALL compute_3c_integrals(qs_env, bs_env, t_3c_for_gocc, i_atoms, il_atoms)
238 CALL g_times_3c(t_3c_for_gocc, t_2c_gocc, t_3c_x_gocc, bs_env, &
239 j_atoms, i_atoms, il_atoms)
242 CALL compute_3c_integrals(qs_env, bs_env, t_3c_for_gvir, j_atoms, il_atoms)
245 CALL g_times_3c(t_3c_for_gvir, t_2c_gvir, t_3c_x_gvir, bs_env, &
246 i_atoms, j_atoms, il_atoms)
251 CALL dbt_copy(t_3c_x_gocc, t_3c_x_gocc_2, move_data=.true., order=[1, 3, 2])
252 CALL dbt_copy(t_3c_x_gvir, t_3c_x_gvir_2, move_data=.true.)
255 CALL dbt_contract(alpha=bs_env%spin_degeneracy, &
256 tensor_1=t_3c_x_gocc_2, tensor_2=t_3c_x_gvir_2, &
257 beta=1.0_dp, tensor_3=bs_env%t_chi, &
258 contract_1=[2, 3], notcontract_1=[1], map_1=[1], &
259 contract_2=[2, 3], notcontract_2=[1], map_2=[2], &
260 filter_eps=bs_env%eps_filter, move_data=.true.)
269 CALL local_dbt_to_global_mat(bs_env%t_chi, bs_env%mat_RI_RI_tensor%matrix, &
270 mat_chi_gamma_tau(i_t)%matrix, bs_env%para_env)
272 CALL write_matrix(mat_chi_gamma_tau(i_t)%matrix, i_t, bs_env%chi_name, &
273 bs_env%fm_RI_RI, qs_env)
275 CALL destroy_tensors_chi(t_2c_gocc, t_2c_gvir, t_3c_for_gocc, t_3c_for_gvir, &
276 t_3c_x_gocc, t_3c_x_gvir, t_3c_x_gocc_2, t_3c_x_gvir_2)
278 IF (bs_env%unit_nr > 0)
THEN
279 WRITE (bs_env%unit_nr,
'(T2,A,I13,A,I3,A,F7.1,A)') &
280 χτ
'Computed (i,k=0) for time point', i_t,
' /', bs_env%num_time_freq_points, &
281 ', Execution time',
m_walltime() - bs_env%t1,
' s'
286 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
288 CALL timestop(handle)
290 END SUBROUTINE get_mat_chi_gamma_tau
299 SUBROUTINE fm_read(fm, bs_env, mat_name, idx)
302 CHARACTER(LEN=*) :: mat_name
305 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_read'
307 CHARACTER(LEN=default_string_length) :: f_chi
308 INTEGER :: handle, unit_nr
310 CALL timeset(routinen, handle)
313 IF (bs_env%para_env%is_source())
THEN
316 WRITE (f_chi,
'(3A,I1,A)') trim(bs_env%prefix), trim(mat_name),
"_0",
idx,
".matrix"
317 ELSE IF (
idx < 100)
THEN
318 WRITE (f_chi,
'(3A,I2,A)') trim(bs_env%prefix), trim(mat_name),
"_",
idx,
".matrix"
320 cpabort(
'Please implement more than 99 time/frequency points.')
323 CALL open_file(file_name=trim(f_chi), file_action=
"READ", file_form=
"UNFORMATTED", &
324 file_position=
"REWIND", file_status=
"OLD", unit_number=unit_nr)
330 IF (bs_env%para_env%is_source())
CALL close_file(unit_number=unit_nr)
332 CALL timestop(handle)
334 END SUBROUTINE fm_read
348 SUBROUTINE create_tensors_chi(t_2c_Gocc, t_2c_Gvir, t_3c_for_Gocc, t_3c_for_Gvir, &
349 t_3c_x_Gocc, t_3c_x_Gvir, t_3c_x_Gocc_2, t_3c_x_Gvir_2, bs_env)
351 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
352 t_3c_for_gvir, t_3c_x_gocc, &
353 t_3c_x_gvir, t_3c_x_gocc_2, &
357 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_tensors_chi'
361 CALL timeset(routinen, handle)
363 CALL dbt_create(bs_env%t_G, t_2c_gocc)
364 CALL dbt_create(bs_env%t_G, t_2c_gvir)
365 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_gocc)
366 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_gvir)
367 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_gocc)
368 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_gvir)
369 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_gocc_2)
370 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_gvir_2)
372 CALL timestop(handle)
374 END SUBROUTINE create_tensors_chi
387 SUBROUTINE destroy_tensors_chi(t_2c_Gocc, t_2c_Gvir, t_3c_for_Gocc, t_3c_for_Gvir, &
388 t_3c_x_Gocc, t_3c_x_Gvir, t_3c_x_Gocc_2, t_3c_x_Gvir_2)
389 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_3c_for_gocc, &
390 t_3c_for_gvir, t_3c_x_gocc, &
391 t_3c_x_gvir, t_3c_x_gocc_2, &
394 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_tensors_chi'
398 CALL timeset(routinen, handle)
400 CALL dbt_destroy(t_2c_gocc)
401 CALL dbt_destroy(t_2c_gvir)
402 CALL dbt_destroy(t_3c_for_gocc)
403 CALL dbt_destroy(t_3c_for_gvir)
404 CALL dbt_destroy(t_3c_x_gocc)
405 CALL dbt_destroy(t_3c_x_gvir)
406 CALL dbt_destroy(t_3c_x_gocc_2)
407 CALL dbt_destroy(t_3c_x_gvir_2)
409 CALL timestop(handle)
411 END SUBROUTINE destroy_tensors_chi
422 SUBROUTINE g_occ_vir(bs_env, tau, fm_GGamma, ispin, occ, vir)
429 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_occ_vir'
431 INTEGER :: handle, homo, i_row_local, j_col, &
432 j_col_local, n_mo, ncol_local, &
434 INTEGER,
DIMENSION(:),
POINTER :: col_indices
435 REAL(kind=
dp) :: tau_e
437 CALL timeset(routinen, handle)
439 cpassert(occ .NEQV. vir)
442 nrow_local=nrow_local, &
443 ncol_local=ncol_local, &
444 col_indices=col_indices)
447 homo = bs_env%n_occ(ispin)
449 CALL cp_fm_to_fm(bs_env%fm_mo_coeff_Gamma(ispin), bs_env%fm_work_mo(1))
451 DO i_row_local = 1, nrow_local
452 DO j_col_local = 1, ncol_local
454 j_col = col_indices(j_col_local)
456 tau_e = abs(tau*0.5_dp*(bs_env%eigenval_scf_Gamma(j_col, ispin) - bs_env%e_fermi(ispin)))
458 IF (tau_e < bs_env%stabilize_exp)
THEN
459 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = &
460 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local)*exp(-tau_e)
462 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = 0.0_dp
465 IF ((occ .AND. j_col > homo) .OR. (vir .AND. j_col <= homo))
THEN
466 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = 0.0_dp
472 CALL parallel_gemm(transa=
"N", transb=
"T", m=n_mo, n=n_mo, k=n_mo, alpha=1.0_dp, &
473 matrix_a=bs_env%fm_work_mo(1), matrix_b=bs_env%fm_work_mo(1), &
474 beta=0.0_dp, matrix_c=fm_ggamma)
476 CALL timestop(handle)
478 END SUBROUTINE g_occ_vir
489 SUBROUTINE fm_to_local_tensor(fm_global, mat_global, mat_local, tensor, bs_env, atom_ranges)
492 TYPE(dbcsr_type) :: mat_global, mat_local
495 INTEGER,
DIMENSION(:, :),
OPTIONAL :: atom_ranges
497 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_to_local_tensor'
500 TYPE(dbt_type) :: tensor_tmp
502 CALL timeset(routinen, handle)
506 CALL dbcsr_filter(mat_global, bs_env%eps_filter)
507 IF (
PRESENT(atom_ranges))
THEN
509 bs_env%para_env_tensor%num_pe, atom_ranges)
512 bs_env%para_env_tensor%num_pe)
514 CALL dbt_create(mat_local, tensor_tmp)
515 CALL dbt_copy_matrix_to_tensor(mat_local, tensor_tmp)
516 CALL dbt_copy(tensor_tmp,
tensor, move_data=.true.)
517 CALL dbt_destroy(tensor_tmp)
518 CALL dbcsr_set(mat_local, 0.0_dp)
519 CALL dbcsr_filter(mat_local, 1.0_dp)
521 CALL timestop(handle)
523 END SUBROUTINE fm_to_local_tensor
532 SUBROUTINE local_dbt_to_global_mat(tensor, mat_tensor, mat_global, para_env)
535 TYPE(dbcsr_type) :: mat_tensor, mat_global
538 CHARACTER(LEN=*),
PARAMETER :: routinen =
'local_dbt_to_global_mat'
542 CALL timeset(routinen, handle)
544 CALL dbt_copy_tensor_to_matrix(
tensor, mat_tensor)
551 CALL timestop(handle)
553 END SUBROUTINE local_dbt_to_global_mat
563 SUBROUTINE write_matrix(matrix, matrix_index, matrix_name, fm, qs_env)
564 TYPE(dbcsr_type) :: matrix
565 INTEGER :: matrix_index
566 CHARACTER(LEN=*) :: matrix_name
570 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_matrix'
574 CALL timeset(routinen, handle)
580 CALL fm_write(fm, matrix_index, matrix_name, qs_env)
582 CALL timestop(handle)
584 END SUBROUTINE write_matrix
593 SUBROUTINE fm_write(fm, matrix_index, matrix_name, qs_env)
595 INTEGER :: matrix_index
596 CHARACTER(LEN=*) :: matrix_name
599 CHARACTER(LEN=*),
PARAMETER :: key =
'PROPERTIES%BANDSTRUCTURE%GW%PRINT%RESTART', &
600 routinen =
'fm_write'
602 CHARACTER(LEN=default_string_length) :: filename
603 INTEGER :: handle, unit_nr
607 CALL timeset(routinen, handle)
615 IF (matrix_index < 10)
THEN
616 WRITE (filename,
'(3A,I1)')
"RESTART_", matrix_name,
"_0", matrix_index
617 ELSE IF (matrix_index < 100)
THEN
618 WRITE (filename,
'(3A,I2)')
"RESTART_", matrix_name,
"_", matrix_index
620 cpabort(
'Please implement more than 99 time/frequency points.')
624 file_form=
"UNFORMATTED", middle_name=trim(filename), &
625 file_position=
"REWIND", file_action=
"WRITE")
628 IF (unit_nr > 0)
THEN
633 CALL timestop(handle)
635 END SUBROUTINE fm_write
646 SUBROUTINE compute_3c_integrals(qs_env, bs_env, t_3c, atoms_AO_1, atoms_AO_2, atoms_RI)
649 TYPE(dbt_type) :: t_3c
650 INTEGER,
DIMENSION(2),
OPTIONAL :: atoms_ao_1, atoms_ao_2, atoms_ri
652 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_3c_integrals'
655 INTEGER,
DIMENSION(2) :: my_atoms_ao_1, my_atoms_ao_2, my_atoms_ri
656 TYPE(dbt_type),
ALLOCATABLE,
DIMENSION(:, :) :: t_3c_array
658 CALL timeset(routinen, handle)
663 ALLOCATE (t_3c_array(1, 1))
664 CALL dbt_create(t_3c, t_3c_array(1, 1))
666 IF (
PRESENT(atoms_ao_1))
THEN
667 my_atoms_ao_1 = atoms_ao_1
669 my_atoms_ao_1 = [1, bs_env%n_atom]
671 IF (
PRESENT(atoms_ao_2))
THEN
672 my_atoms_ao_2 = atoms_ao_2
674 my_atoms_ao_2 = [1, bs_env%n_atom]
676 IF (
PRESENT(atoms_ri))
THEN
677 my_atoms_ri = atoms_ri
679 my_atoms_ri = [1, bs_env%n_atom]
686 int_eps=bs_env%eps_3c_int, &
687 basis_i=bs_env%basis_set_RI, &
688 basis_j=bs_env%basis_set_AO, &
689 basis_k=bs_env%basis_set_AO, &
690 potential_parameter=bs_env%ri_metric, &
692 bounds_j=atoms_ao_1, &
693 bounds_k=atoms_ao_2, &
694 desymmetrize=.false.)
696 CALL dbt_copy(t_3c_array(1, 1), t_3c, move_data=.true.)
698 CALL dbt_destroy(t_3c_array(1, 1))
699 DEALLOCATE (t_3c_array)
701 CALL timestop(handle)
703 END SUBROUTINE compute_3c_integrals
715 SUBROUTINE g_times_3c(t_3c_for_G, t_G, t_M, bs_env, atoms_AO_1, atoms_AO_2, atoms_IL)
716 TYPE(dbt_type) :: t_3c_for_g, t_g, t_m
718 INTEGER,
DIMENSION(2) :: atoms_ao_1, atoms_ao_2, atoms_il
720 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G_times_3c'
723 INTEGER,
DIMENSION(2) :: bounds_il, bounds_l
724 INTEGER,
DIMENSION(2, 2) :: bounds_k
726 CALL timeset(routinen, handle)
732 bounds_il(1:2) = [bs_env%i_ao_start_from_atom(atoms_il(1)), &
733 bs_env%i_ao_end_from_atom(atoms_il(2))]
734 bounds_k(1:2, 1) = [1, bs_env%n_RI]
735 bounds_k(1:2, 2) = [bs_env%i_ao_start_from_atom(atoms_ao_2(1)), &
736 bs_env%i_ao_end_from_atom(atoms_ao_2(2))]
737 bounds_l(1:2) = [bs_env%i_ao_start_from_atom(atoms_ao_1(1)), &
738 bs_env%i_ao_end_from_atom(atoms_ao_1(2))]
740 CALL dbt_contract(alpha=1.0_dp, &
741 tensor_1=t_3c_for_g, &
745 contract_1=[3], notcontract_1=[1, 2], map_1=[1, 2], &
746 contract_2=[2], notcontract_2=[1], map_2=[3], &
747 bounds_1=bounds_il, &
750 filter_eps=bs_env%eps_filter)
752 CALL dbt_clear(t_3c_for_g)
754 CALL timestop(handle)
756 END SUBROUTINE g_times_3c
766 SUBROUTINE check_dist(atoms_1, atoms_2, qs_env, bs_env, dist_too_long)
767 INTEGER,
DIMENSION(2) :: atoms_1, atoms_2
770 LOGICAL :: dist_too_long
772 CHARACTER(LEN=*),
PARAMETER :: routinen =
'check_dist'
774 INTEGER :: atom_1, atom_2, handle
775 REAL(
dp) :: abs_rab, min_dist_ao_atoms
776 REAL(kind=
dp),
DIMENSION(3) :: rab
780 CALL timeset(routinen, handle)
782 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
784 min_dist_ao_atoms = 1.0e5_dp
785 DO atom_1 = atoms_1(1), atoms_1(2)
786 DO atom_2 = atoms_2(1), atoms_2(2)
788 rab =
pbc(particle_set(atom_1)%r(1:3), particle_set(atom_2)%r(1:3), cell)
790 abs_rab = sqrt(rab(1)**2 + rab(2)**2 + rab(3)**2)
792 min_dist_ao_atoms = min(min_dist_ao_atoms, abs_rab)
797 dist_too_long = (min_dist_ao_atoms > bs_env%max_dist_AO_atoms)
799 CALL timestop(handle)
801 END SUBROUTINE check_dist
810 SUBROUTINE get_w_mic(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
813 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
814 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
816 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_W_MIC'
820 CALL timeset(routinen, handle)
822 IF (bs_env%all_W_exist)
THEN
823 CALL read_w_mic_time(bs_env, mat_chi_gamma_tau, fm_w_mic_time)
825 CALL compute_w_mic(bs_env, qs_env, mat_chi_gamma_tau, fm_w_mic_time)
828 CALL timestop(handle)
830 END SUBROUTINE get_w_mic
839 SUBROUTINE compute_v_k_by_lattice_sum(bs_env, qs_env, fm_V_kp, ikp_batch)
842 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_v_kp
845 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_V_k_by_lattice_sum'
847 INTEGER :: handle, ikp, ikp_end, ikp_start, &
848 nkp_chi_eps_w_batch, re_im
851 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_v_kp
853 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
855 CALL timeset(routinen, handle)
857 nkp_chi_eps_w_batch = bs_env%nkp_chi_eps_W_batch
859 ikp_start = (ikp_batch - 1)*bs_env%nkp_chi_eps_W_batch + 1
860 ikp_end = min(ikp_batch*bs_env%nkp_chi_eps_W_batch, bs_env%kpoints_chi_eps_W%nkp)
863 ALLOCATE (mat_v_kp(ikp_start:ikp_end, 2))
865 DO ikp = ikp_start, ikp_end
867 NULLIFY (mat_v_kp(ikp, re_im)%matrix)
868 ALLOCATE (mat_v_kp(ikp, re_im)%matrix)
869 CALL dbcsr_create(mat_v_kp(ikp, re_im)%matrix, template=bs_env%mat_RI_RI%matrix)
870 CALL dbcsr_reserve_all_blocks(mat_v_kp(ikp, re_im)%matrix)
871 CALL dbcsr_set(mat_v_kp(ikp, re_im)%matrix, 0.0_dp)
877 particle_set=particle_set, &
879 qs_kind_set=qs_kind_set, &
880 atomic_kind_set=atomic_kind_set)
882 IF (ikp_end .LE. bs_env%nkp_chi_eps_W_orig)
THEN
885 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
887 ELSE IF (ikp_start > bs_env%nkp_chi_eps_W_orig .AND. &
888 ikp_end .LE. bs_env%nkp_chi_eps_W_orig_plus_extra)
THEN
891 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_extra
895 cpabort(
"Error with k-point parallelization.")
900 bs_env%kpoints_chi_eps_W, &
901 basis_type=
"RI_AUX", &
903 particle_set=particle_set, &
904 qs_kind_set=qs_kind_set, &
905 atomic_kind_set=atomic_kind_set, &
906 size_lattice_sum=bs_env%size_lattice_sum_V, &
908 ikp_start=ikp_start, &
911 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
913 ALLOCATE (fm_v_kp(ikp_start:ikp_end, 2))
914 DO ikp = ikp_start, ikp_end
916 CALL cp_fm_create(fm_v_kp(ikp, re_im), bs_env%fm_RI_RI%matrix_struct)
918 CALL dbcsr_deallocate_matrix(mat_v_kp(ikp, re_im)%matrix)
921 DEALLOCATE (mat_v_kp)
923 CALL timestop(handle)
925 END SUBROUTINE compute_v_k_by_lattice_sum
936 SUBROUTINE compute_minvvsqrt_vsqrt(bs_env, qs_env, fm_V_kp, cfm_V_sqrt_ikp, &
937 cfm_M_inv_V_sqrt_ikp, ikp)
940 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_v_kp
941 TYPE(
cp_cfm_type) :: cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp
944 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_MinvVsqrt_Vsqrt'
946 INTEGER :: handle, info, n_ri
948 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_m_ikp
950 CALL timeset(routinen, handle)
956 bs_env%n_RI, bs_env%ri_metric, do_kpoints=.true., &
957 kpoints=bs_env%kpoints_chi_eps_W, &
958 regularization_ri=bs_env%regularization_RI, ikp_ext=ikp)
961 CALL cp_cfm_create(cfm_v_sqrt_ikp, fm_v_kp(ikp, 1)%matrix_struct)
962 CALL cp_cfm_create(cfm_m_inv_v_sqrt_ikp, fm_v_kp(ikp, 1)%matrix_struct)
964 CALL cp_cfm_create(cfm_m_inv_ikp, fm_v_kp(ikp, 1)%matrix_struct)
966 CALL cp_fm_to_cfm(fm_m_ikp(1, 1), fm_m_ikp(1, 2), cfm_m_inv_ikp)
967 CALL cp_fm_to_cfm(fm_v_kp(ikp, 1), fm_v_kp(ikp, 2), cfm_v_sqrt_ikp)
983 CALL cp_cfm_power(cfm_work, threshold=bs_env%eps_eigval_mat_RI, exponent=-1.0_dp)
992 CALL clean_lower_part(cfm_v_sqrt_ikp)
995 CALL cp_cfm_power(cfm_work, threshold=0.0_dp, exponent=0.5_dp)
1001 CALL parallel_gemm(
"N",
"C", n_ri, n_ri, n_ri,
z_one, cfm_m_inv_ikp, cfm_v_sqrt_ikp, &
1002 z_zero, cfm_m_inv_v_sqrt_ikp)
1006 CALL timestop(handle)
1008 END SUBROUTINE compute_minvvsqrt_vsqrt
1016 SUBROUTINE read_w_mic_time(bs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
1018 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1019 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1021 CHARACTER(LEN=*),
PARAMETER :: routinen =
'read_W_MIC_time'
1023 INTEGER :: handle, i_t
1025 CALL timeset(routinen, handle)
1028 CALL create_fm_w_mic_time(bs_env, fm_w_mic_time)
1030 DO i_t = 1, bs_env%num_time_freq_points
1034 CALL fm_read(fm_w_mic_time(i_t), bs_env, bs_env%W_time_name, i_t)
1036 IF (bs_env%unit_nr > 0)
THEN
1037 WRITE (bs_env%unit_nr,
'(T2,A,I5,A,I3,A,F7.1,A)') &
1038 τ
'Read W^MIC(i) from file for time point ', i_t,
' /', bs_env%num_time_freq_points, &
1039 ', Execution time',
m_walltime() - bs_env%t1,
' s'
1044 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
1046 CALL timestop(handle)
1048 END SUBROUTINE read_w_mic_time
1057 SUBROUTINE compute_w_mic(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
1060 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1061 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1063 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_W_MIC'
1065 INTEGER :: handle, i_t, ikp, ikp_batch, &
1067 TYPE(
cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
1068 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_v_kp
1070 CALL timeset(routinen, handle)
1072 CALL create_fm_w_mic_time(bs_env, fm_w_mic_time)
1074 DO ikp_batch = 1, bs_env%num_chi_eps_W_batches
1079 CALL compute_v_k_by_lattice_sum(bs_env, qs_env, fm_v_kp, ikp_batch)
1081 DO ikp_in_batch = 1, bs_env%nkp_chi_eps_W_batch
1083 ikp = (ikp_batch - 1)*bs_env%nkp_chi_eps_W_batch + ikp_in_batch
1085 IF (ikp > bs_env%nkp_chi_eps_W_orig_plus_extra) cycle
1087 CALL compute_minvvsqrt_vsqrt(bs_env, qs_env, fm_v_kp, &
1088 cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp, ikp)
1090 CALL bs_env%para_env%sync()
1092 DO j_w = 1, bs_env%num_time_freq_points
1095 IF (bs_env%approx_kp_extrapol .AND. j_w > 1 .AND. &
1096 ikp > bs_env%nkp_chi_eps_W_orig) cycle
1098 CALL compute_fm_w_mic_freq_j(bs_env, qs_env, bs_env%fm_W_MIC_freq, j_w, ikp, &
1099 mat_chi_gamma_tau, cfm_m_inv_v_sqrt_ikp, &
1103 CALL fourier_transform_w_to_t(bs_env, fm_w_mic_time, bs_env%fm_W_MIC_freq, j_w)
1112 DEALLOCATE (fm_v_kp)
1114 IF (bs_env%unit_nr > 0)
THEN
1115 WRITE (bs_env%unit_nr,
'(T2,A,I12,A,I3,A,F7.1,A)') &
1116 τ
'Computed W(i,k) for k-point batch', &
1117 ikp_batch,
' /', bs_env%num_chi_eps_W_batches, &
1118 ', Execution time',
m_walltime() - bs_env%t1,
' s'
1123 IF (bs_env%approx_kp_extrapol)
THEN
1124 CALL apply_extrapol_factor(bs_env, fm_w_mic_time)
1128 CALL multiply_fm_w_mic_time_with_minv_gamma(bs_env, qs_env, fm_w_mic_time)
1130 DO i_t = 1, bs_env%num_time_freq_points
1131 CALL fm_write(fm_w_mic_time(i_t), i_t, bs_env%W_time_name, qs_env)
1138 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
1140 CALL timestop(handle)
1142 END SUBROUTINE compute_w_mic
1155 SUBROUTINE compute_fm_w_mic_freq_j(bs_env, qs_env, fm_W_MIC_freq_j, j_w, ikp, mat_chi_Gamma_tau, &
1156 cfm_M_inv_V_sqrt_ikp, cfm_V_sqrt_ikp)
1161 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1162 TYPE(
cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
1164 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_W_MIC_freq_j'
1167 TYPE(
cp_cfm_type) :: cfm_chi_ikp_freq_j, cfm_w_ikp_freq_j
1169 CALL timeset(routinen, handle)
1172 CALL compute_fm_chi_gamma_freq(bs_env, bs_env%fm_chi_Gamma_freq, j_w, mat_chi_gamma_tau)
1178 ikp, qs_env, bs_env%kpoints_chi_eps_W,
"RI_AUX")
1181 CALL cp_cfm_power(cfm_chi_ikp_freq_j, threshold=0.0_dp, exponent=1.0_dp)
1185 CALL compute_cfm_w_ikp_freq_j(bs_env, cfm_chi_ikp_freq_j, cfm_v_sqrt_ikp, &
1186 cfm_m_inv_v_sqrt_ikp, cfm_w_ikp_freq_j)
1189 SELECT CASE (bs_env%approx_kp_extrapol)
1193 bs_env%kpoints_chi_eps_W,
"RI_AUX")
1204 cfm_w_ikp_freq_j, ikp, bs_env%kpoints_chi_eps_W, &
1207 IF (ikp .LE. bs_env%nkp_chi_eps_W_orig)
THEN
1209 cfm_w_ikp_freq_j, ikp, bs_env%kpoints_chi_eps_W, &
1210 "RI_AUX", wkp_ext=bs_env%wkp_orig)
1216 IF (ikp .LE. bs_env%nkp_chi_eps_W_orig)
THEN
1218 ikp, bs_env%kpoints_chi_eps_W,
"RI_AUX", &
1219 wkp_ext=bs_env%wkp_orig)
1225 CALL timestop(handle)
1227 END SUBROUTINE compute_fm_w_mic_freq_j
1233 SUBROUTINE clean_lower_part(cfm_mat)
1236 CHARACTER(LEN=*),
PARAMETER :: routinen =
'clean_lower_part'
1238 INTEGER :: handle, i_global, i_row, j_col, &
1239 j_global, ncol_local, nrow_local
1240 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
1242 CALL timeset(routinen, handle)
1245 nrow_local=nrow_local, ncol_local=ncol_local, &
1246 row_indices=row_indices, col_indices=col_indices)
1248 DO i_row = 1, nrow_local
1249 DO j_col = 1, ncol_local
1250 i_global = row_indices(i_row)
1251 j_global = col_indices(j_col)
1252 IF (j_global < i_global) cfm_mat%local_data(i_row, j_col) =
z_zero
1256 CALL timestop(handle)
1258 END SUBROUTINE clean_lower_part
1265 SUBROUTINE apply_extrapol_factor(bs_env, fm_W_MIC_time)
1267 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1269 CHARACTER(LEN=*),
PARAMETER :: routinen =
'apply_extrapol_factor'
1271 INTEGER :: handle, i, i_t, j, ncol_local, nrow_local
1272 REAL(kind=
dp) :: extrapol_factor, w_extra_1, w_no_extra_1
1274 CALL timeset(routinen, handle)
1276 CALL cp_fm_get_info(matrix=fm_w_mic_time(1), nrow_local=nrow_local, ncol_local=ncol_local)
1278 DO i_t = 1, bs_env%num_time_freq_points
1279 DO i = 1, nrow_local
1280 DO j = 1, ncol_local
1282 w_extra_1 = bs_env%fm_W_MIC_freq_1_extra%local_data(i, j)
1283 w_no_extra_1 = bs_env%fm_W_MIC_freq_1_no_extra%local_data(i, j)
1285 IF (abs(w_no_extra_1) > 1.0e-13)
THEN
1286 extrapol_factor = w_extra_1/w_no_extra_1
1288 extrapol_factor = 1.0_dp
1292 IF (abs(extrapol_factor) > 10.0_dp) extrapol_factor = 1.0_dp
1294 fm_w_mic_time(i_t)%local_data(i, j) = fm_w_mic_time(i_t)%local_data(i, j) &
1300 CALL timestop(handle)
1302 END SUBROUTINE apply_extrapol_factor
1311 SUBROUTINE compute_fm_chi_gamma_freq(bs_env, fm_chi_Gamma_freq, j_w, mat_chi_Gamma_tau)
1315 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1317 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_chi_Gamma_freq'
1319 INTEGER :: handle, i_t
1320 REAL(kind=
dp) :: freq_j, time_i, weight_ij
1322 CALL timeset(routinen, handle)
1324 CALL dbcsr_set(bs_env%mat_RI_RI%matrix, 0.0_dp)
1326 freq_j = bs_env%imag_freq_points(j_w)
1328 DO i_t = 1, bs_env%num_time_freq_points
1330 time_i = bs_env%imag_time_points(i_t)
1331 weight_ij = bs_env%weights_cos_t_to_w(j_w, i_t)
1334 CALL dbcsr_add(bs_env%mat_RI_RI%matrix, mat_chi_gamma_tau(i_t)%matrix, &
1335 1.0_dp, cos(time_i*freq_j)*weight_ij)
1341 CALL timestop(handle)
1343 END SUBROUTINE compute_fm_chi_gamma_freq
1354 SUBROUTINE mat_ikp_from_mat_gamma(mat_ikp_re, mat_ikp_im, mat_Gamma, kpoints, ikp, qs_env)
1355 TYPE(dbcsr_type) :: mat_ikp_re, mat_ikp_im, mat_gamma
1360 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mat_ikp_from_mat_Gamma'
1362 INTEGER :: col, handle, i_cell, j_cell, num_cells, &
1364 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
1365 LOGICAL :: f, i_cell_is_the_minimum_image_cell
1366 REAL(kind=
dp) :: abs_rab_cell_i, abs_rab_cell_j, arg
1367 REAL(kind=
dp),
DIMENSION(3) :: cell_vector, cell_vector_j, rab_cell_i, &
1369 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
1370 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: block_im, block_re, data_block
1372 TYPE(dbcsr_iterator_type) :: iter
1375 CALL timeset(routinen, handle)
1378 CALL dbcsr_copy(mat_ikp_re, mat_gamma)
1379 CALL dbcsr_copy(mat_ikp_im, mat_gamma)
1380 CALL dbcsr_set(mat_ikp_re, 0.0_dp)
1381 CALL dbcsr_set(mat_ikp_im, 0.0_dp)
1383 NULLIFY (cell, particle_set)
1384 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
1387 index_to_cell => kpoints%index_to_cell
1389 num_cells =
SIZE(index_to_cell, 2)
1391 DO i_cell = 1, num_cells
1393 CALL dbcsr_iterator_start(iter, mat_gamma)
1394 DO WHILE (dbcsr_iterator_blocks_left(iter))
1395 CALL dbcsr_iterator_next_block(iter, row, col, data_block)
1397 cell_vector(1:3) = matmul(hmat, real(index_to_cell(1:3, i_cell),
dp))
1399 rab_cell_i(1:3) =
pbc(particle_set(row)%r(1:3), cell) - &
1400 (
pbc(particle_set(col)%r(1:3), cell) + cell_vector(1:3))
1401 abs_rab_cell_i = sqrt(rab_cell_i(1)**2 + rab_cell_i(2)**2 + rab_cell_i(3)**2)
1404 i_cell_is_the_minimum_image_cell = .true.
1405 DO j_cell = 1, num_cells
1406 cell_vector_j(1:3) = matmul(hmat, real(index_to_cell(1:3, j_cell),
dp))
1407 rab_cell_j(1:3) =
pbc(particle_set(row)%r(1:3), cell) - &
1408 (
pbc(particle_set(col)%r(1:3), cell) + cell_vector_j(1:3))
1409 abs_rab_cell_j = sqrt(rab_cell_j(1)**2 + rab_cell_j(2)**2 + rab_cell_j(3)**2)
1411 IF (abs_rab_cell_i > abs_rab_cell_j + 1.0e-6_dp)
THEN
1412 i_cell_is_the_minimum_image_cell = .false.
1416 IF (i_cell_is_the_minimum_image_cell)
THEN
1417 NULLIFY (block_re, block_im)
1418 CALL dbcsr_get_block_p(matrix=mat_ikp_re, row=row, col=col, block=block_re, found=f)
1419 CALL dbcsr_get_block_p(matrix=mat_ikp_im, row=row, col=col, block=block_im, found=f)
1420 cpassert(all(abs(block_re) < 1.0e-10_dp))
1421 cpassert(all(abs(block_im) < 1.0e-10_dp))
1423 arg = real(index_to_cell(1, i_cell),
dp)*kpoints%xkp(1, ikp) + &
1424 REAL(index_to_cell(2, i_cell),
dp)*kpoints%xkp(2, ikp) + &
1425 REAL(index_to_cell(3, i_cell),
dp)*kpoints%xkp(3, ikp)
1427 block_re(:, :) = cos(
twopi*arg)*data_block(:, :)
1428 block_im(:, :) = sin(
twopi*arg)*data_block(:, :)
1432 CALL dbcsr_iterator_stop(iter)
1436 CALL timestop(handle)
1438 END SUBROUTINE mat_ikp_from_mat_gamma
1448 SUBROUTINE compute_cfm_w_ikp_freq_j(bs_env, cfm_chi_ikp_freq_j, cfm_V_sqrt_ikp, &
1449 cfm_M_inv_V_sqrt_ikp, cfm_W_ikp_freq_j)
1452 TYPE(
cp_cfm_type) :: cfm_chi_ikp_freq_j, cfm_v_sqrt_ikp, &
1453 cfm_m_inv_v_sqrt_ikp, cfm_w_ikp_freq_j
1455 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_cfm_W_ikp_freq_j'
1457 INTEGER :: handle, info, n_ri
1460 CALL timeset(routinen, handle)
1462 CALL cp_cfm_create(cfm_work, cfm_chi_ikp_freq_j%matrix_struct)
1469 cfm_chi_ikp_freq_j, cfm_m_inv_v_sqrt_ikp,
z_zero, cfm_work)
1473 CALL cp_cfm_create(cfm_eps_ikp_freq_j, cfm_work%matrix_struct)
1475 cfm_m_inv_v_sqrt_ikp, cfm_work,
z_zero, cfm_eps_ikp_freq_j)
1478 CALL cfm_add_on_diag(cfm_eps_ikp_freq_j,
z_one)
1491 CALL cfm_add_on_diag(cfm_eps_ikp_freq_j, -
z_one)
1494 CALL parallel_gemm(
'N',
'N', n_ri, n_ri, n_ri,
z_one, cfm_eps_ikp_freq_j, cfm_v_sqrt_ikp, &
1498 CALL cp_cfm_create(cfm_w_ikp_freq_j, cfm_work%matrix_struct)
1500 z_zero, cfm_w_ikp_freq_j)
1505 CALL timestop(handle)
1507 END SUBROUTINE compute_cfm_w_ikp_freq_j
1514 SUBROUTINE cfm_add_on_diag(cfm, alpha)
1517 COMPLEX(KIND=dp) :: alpha
1519 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cfm_add_on_diag'
1521 INTEGER :: handle, i_global, i_row, j_col, &
1522 j_global, ncol_local, nrow_local
1523 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
1525 CALL timeset(routinen, handle)
1528 nrow_local=nrow_local, &
1529 ncol_local=ncol_local, &
1530 row_indices=row_indices, &
1531 col_indices=col_indices)
1534 DO j_col = 1, ncol_local
1535 j_global = col_indices(j_col)
1536 DO i_row = 1, nrow_local
1537 i_global = row_indices(i_row)
1538 IF (j_global == i_global)
THEN
1539 cfm%local_data(i_row, j_col) = cfm%local_data(i_row, j_col) + alpha
1544 CALL timestop(handle)
1546 END SUBROUTINE cfm_add_on_diag
1553 SUBROUTINE create_fm_w_mic_time(bs_env, fm_W_MIC_time)
1555 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1557 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_fm_W_MIC_time'
1559 INTEGER :: handle, i_t
1561 CALL timeset(routinen, handle)
1563 ALLOCATE (fm_w_mic_time(bs_env%num_time_freq_points))
1564 DO i_t = 1, bs_env%num_time_freq_points
1565 CALL cp_fm_create(fm_w_mic_time(i_t), bs_env%fm_RI_RI%matrix_struct)
1568 CALL timestop(handle)
1570 END SUBROUTINE create_fm_w_mic_time
1579 SUBROUTINE fourier_transform_w_to_t(bs_env, fm_W_MIC_time, fm_W_MIC_freq_j, j_w)
1581 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1585 CHARACTER(LEN=*),
PARAMETER :: routinen =
'Fourier_transform_w_to_t'
1587 INTEGER :: handle, i_t
1588 REAL(kind=
dp) :: freq_j, time_i, weight_ij
1590 CALL timeset(routinen, handle)
1592 freq_j = bs_env%imag_freq_points(j_w)
1594 DO i_t = 1, bs_env%num_time_freq_points
1596 time_i = bs_env%imag_time_points(i_t)
1597 weight_ij = bs_env%weights_cos_w_to_t(i_t, j_w)
1601 beta=weight_ij*cos(time_i*freq_j), matrix_b=fm_w_mic_freq_j)
1605 CALL timestop(handle)
1607 END SUBROUTINE fourier_transform_w_to_t
1615 SUBROUTINE multiply_fm_w_mic_time_with_minv_gamma(bs_env, qs_env, fm_W_MIC_time)
1618 TYPE(
cp_fm_type),
DIMENSION(:) :: fm_w_mic_time
1620 CHARACTER(LEN=*),
PARAMETER :: routinen =
'multiply_fm_W_MIC_time_with_Minv_Gamma'
1622 INTEGER :: handle, i_t, n_ri, ndep
1624 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_minv_gamma
1626 CALL timeset(routinen, handle)
1630 CALL cp_fm_create(fm_work, fm_w_mic_time(1)%matrix_struct)
1634 bs_env%ri_metric, do_kpoints=.false., &
1635 regularization_ri=bs_env%regularization_RI)
1637 CALL cp_fm_power(fm_minv_gamma(1, 1), fm_work, -1.0_dp, 0.0_dp, ndep)
1640 DO i_t = 1,
SIZE(fm_w_mic_time)
1642 CALL parallel_gemm(
'N',
'N', n_ri, n_ri, n_ri, 1.0_dp, fm_minv_gamma(1, 1), &
1643 fm_w_mic_time(i_t), 0.0_dp, fm_work)
1645 CALL parallel_gemm(
'N',
'N', n_ri, n_ri, n_ri, 1.0_dp, fm_work, &
1646 fm_minv_gamma(1, 1), 0.0_dp, fm_w_mic_time(i_t))
1653 CALL timestop(handle)
1655 END SUBROUTINE multiply_fm_w_mic_time_with_minv_gamma
1663 SUBROUTINE get_sigma_x(bs_env, qs_env, fm_Sigma_x_Gamma)
1666 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
1668 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Sigma_x'
1670 INTEGER :: handle, ispin
1672 CALL timeset(routinen, handle)
1674 ALLOCATE (fm_sigma_x_gamma(bs_env%n_spin))
1675 DO ispin = 1, bs_env%n_spin
1676 CALL cp_fm_create(fm_sigma_x_gamma(ispin), bs_env%fm_s_Gamma%matrix_struct)
1679 IF (bs_env%Sigma_x_exists)
THEN
1680 DO ispin = 1, bs_env%n_spin
1681 CALL fm_read(fm_sigma_x_gamma(ispin), bs_env, bs_env%Sigma_x_name, ispin)
1684 CALL compute_sigma_x(bs_env, qs_env, fm_sigma_x_gamma)
1687 CALL timestop(handle)
1689 END SUBROUTINE get_sigma_x
1697 SUBROUTINE compute_sigma_x(bs_env, qs_env, fm_Sigma_x_Gamma)
1700 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
1702 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Sigma_x'
1704 INTEGER :: handle, i_intval_idx, ispin, j_intval_idx
1705 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1706 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_vtr_gamma
1707 TYPE(dbcsr_type) :: mat_sigma_x_gamma
1708 TYPE(dbt_type) :: t_2c_d, t_2c_sigma_x, t_2c_v, t_3c_x_v
1710 CALL timeset(routinen, handle)
1714 CALL dbt_create(bs_env%t_G, t_2c_d)
1715 CALL dbt_create(bs_env%t_W, t_2c_v)
1716 CALL dbt_create(bs_env%t_G, t_2c_sigma_x)
1717 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_v)
1718 CALL dbcsr_create(mat_sigma_x_gamma, template=bs_env%mat_ao_ao%matrix)
1722 bs_env%trunc_coulomb, do_kpoints=.false., &
1723 regularization_ri=bs_env%regularization_RI)
1726 CALL multiply_fm_w_mic_time_with_minv_gamma(bs_env, qs_env, fm_vtr_gamma(:, 1))
1728 DO ispin = 1, bs_env%n_spin
1731 CALL g_occ_vir(bs_env, 0.0_dp, bs_env%fm_work_mo(2), ispin, occ=.true., vir=.false.)
1732 CALL fm_to_local_tensor(bs_env%fm_work_mo(2), bs_env%mat_ao_ao%matrix, &
1733 bs_env%mat_ao_ao_tensor%matrix, t_2c_d, bs_env, &
1734 bs_env%atoms_i_t_group)
1736 CALL fm_to_local_tensor(fm_vtr_gamma(1, 1), bs_env%mat_RI_RI%matrix, &
1737 bs_env%mat_RI_RI_tensor%matrix, t_2c_v, bs_env, &
1738 bs_env%atoms_j_t_group)
1742 DO i_intval_idx = 1, bs_env%n_intervals_i
1743 DO j_intval_idx = 1, bs_env%n_intervals_j
1744 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
1745 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
1749 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_v, t_2c_v)
1753 CALL contract_to_sigma(t_2c_d, t_3c_x_v, t_2c_sigma_x, i_atoms, j_atoms, &
1754 qs_env, bs_env, occ=.true., vir=.false., clear_w=.true.)
1759 CALL local_dbt_to_global_mat(t_2c_sigma_x, bs_env%mat_ao_ao_tensor%matrix, &
1760 mat_sigma_x_gamma, bs_env%para_env)
1762 CALL write_matrix(mat_sigma_x_gamma, ispin, bs_env%Sigma_x_name, &
1763 bs_env%fm_work_mo(1), qs_env)
1769 IF (bs_env%unit_nr > 0)
THEN
1770 WRITE (bs_env%unit_nr,
'(T2,A,T58,A,F7.1,A)') &
1771 Σ
'Computed ^x(k=0),',
' Execution time',
m_walltime() - bs_env%t1,
' s'
1772 WRITE (bs_env%unit_nr,
'(A)')
' '
1775 CALL dbcsr_release(mat_sigma_x_gamma)
1776 CALL dbt_destroy(t_2c_d)
1777 CALL dbt_destroy(t_2c_v)
1778 CALL dbt_destroy(t_2c_sigma_x)
1779 CALL dbt_destroy(t_3c_x_v)
1782 CALL timestop(handle)
1784 END SUBROUTINE compute_sigma_x
1793 SUBROUTINE get_sigma_c(bs_env, qs_env, fm_W_MIC_time, fm_Sigma_c_Gamma_time)
1796 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1797 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
1799 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_Sigma_c'
1801 INTEGER :: handle, i_intval_idx, i_t, ispin, &
1802 j_intval_idx, read_write_index
1803 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1804 REAL(kind=
dp) :: tau
1805 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
1806 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, &
1807 t_2c_sigma_neg_tau, &
1808 t_2c_sigma_pos_tau, t_2c_w, t_3c_x_w
1810 CALL timeset(routinen, handle)
1812 CALL create_mat_for_sigma_c(bs_env, t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, &
1813 t_2c_sigma_pos_tau, t_3c_x_w, &
1814 mat_sigma_neg_tau, mat_sigma_pos_tau)
1816 DO i_t = 1, bs_env%num_time_freq_points
1818 DO ispin = 1, bs_env%n_spin
1822 read_write_index = i_t + (ispin - 1)*bs_env%num_time_freq_points
1825 IF (bs_env%Sigma_c_exists(i_t, ispin))
THEN
1826 CALL fm_read(bs_env%fm_work_mo(1), bs_env, bs_env%Sigma_p_name, read_write_index)
1827 CALL copy_fm_to_dbcsr(bs_env%fm_work_mo(1), mat_sigma_pos_tau(i_t, ispin)%matrix, &
1828 keep_sparsity=.false.)
1829 CALL fm_read(bs_env%fm_work_mo(1), bs_env, bs_env%Sigma_n_name, read_write_index)
1830 CALL copy_fm_to_dbcsr(bs_env%fm_work_mo(1), mat_sigma_neg_tau(i_t, ispin)%matrix, &
1831 keep_sparsity=.false.)
1832 IF (bs_env%unit_nr > 0)
THEN
1833 WRITE (bs_env%unit_nr,
'(T2,2A,I3,A,I3,A,F7.1,A)') Στ
'Read ^c(i,k=0) ', &
1834 'from file for time point ', i_t,
' /', bs_env%num_time_freq_points, &
1835 ', Execution time',
m_walltime() - bs_env%t1,
' s'
1842 tau = bs_env%imag_time_points(i_t)
1844 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gocc, ispin, occ=.true., vir=.false.)
1845 CALL g_occ_vir(bs_env, tau, bs_env%fm_Gvir, ispin, occ=.false., vir=.true.)
1848 CALL fm_to_local_tensor(bs_env%fm_Gocc, bs_env%mat_ao_ao%matrix, &
1849 bs_env%mat_ao_ao_tensor%matrix, t_2c_gocc, bs_env, &
1850 bs_env%atoms_i_t_group)
1851 CALL fm_to_local_tensor(bs_env%fm_Gvir, bs_env%mat_ao_ao%matrix, &
1852 bs_env%mat_ao_ao_tensor%matrix, t_2c_gvir, bs_env, &
1853 bs_env%atoms_i_t_group)
1854 CALL fm_to_local_tensor(fm_w_mic_time(i_t), bs_env%mat_RI_RI%matrix, &
1855 bs_env%mat_RI_RI_tensor%matrix, t_2c_w, bs_env, &
1856 bs_env%atoms_j_t_group)
1860 DO i_intval_idx = 1, bs_env%n_intervals_i
1861 DO j_intval_idx = 1, bs_env%n_intervals_j
1862 i_atoms = bs_env%i_atom_intervals(1:2, i_intval_idx)
1863 j_atoms = bs_env%j_atom_intervals(1:2, j_intval_idx)
1865 IF (bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx) .AND. &
1866 bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx)) cycle
1870 CALL compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_w, t_2c_w)
1874 CALL contract_to_sigma(t_2c_gocc, t_3c_x_w, t_2c_sigma_neg_tau, i_atoms, j_atoms, &
1875 qs_env, bs_env, occ=.true., vir=.false., clear_w=.false., &
1876 can_skip=bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx))
1879 CALL contract_to_sigma(t_2c_gvir, t_3c_x_w, t_2c_sigma_pos_tau, i_atoms, j_atoms, &
1880 qs_env, bs_env, occ=.false., vir=.true., clear_w=.true., &
1881 can_skip=bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx))
1888 CALL local_dbt_to_global_mat(t_2c_sigma_neg_tau, bs_env%mat_ao_ao_tensor%matrix, &
1889 mat_sigma_neg_tau(i_t, ispin)%matrix, bs_env%para_env)
1890 CALL local_dbt_to_global_mat(t_2c_sigma_pos_tau, bs_env%mat_ao_ao_tensor%matrix, &
1891 mat_sigma_pos_tau(i_t, ispin)%matrix, bs_env%para_env)
1893 CALL write_matrix(mat_sigma_pos_tau(i_t, ispin)%matrix, read_write_index, &
1894 bs_env%Sigma_p_name, bs_env%fm_work_mo(1), qs_env)
1895 CALL write_matrix(mat_sigma_neg_tau(i_t, ispin)%matrix, read_write_index, &
1896 bs_env%Sigma_n_name, bs_env%fm_work_mo(1), qs_env)
1898 IF (bs_env%unit_nr > 0)
THEN
1899 WRITE (bs_env%unit_nr,
'(T2,A,I10,A,I3,A,F7.1,A)') &
1900 Στ
'Computed ^c(i,k=0) for time point ', i_t,
' /', bs_env%num_time_freq_points, &
1901 ', Execution time',
m_walltime() - bs_env%t1,
' s'
1908 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
1910 CALL fill_fm_sigma_c_gamma_time(fm_sigma_c_gamma_time, bs_env, &
1911 mat_sigma_pos_tau, mat_sigma_neg_tau)
1913 CALL print_skipping(bs_env)
1915 CALL destroy_mat_sigma_c(t_2c_gocc, t_2c_gvir, t_2c_w, t_2c_sigma_neg_tau, &
1916 t_2c_sigma_pos_tau, t_3c_x_w, fm_w_mic_time, &
1917 mat_sigma_neg_tau, mat_sigma_pos_tau)
1919 CALL delete_unnecessary_files(bs_env)
1921 CALL timestop(handle)
1923 END SUBROUTINE get_sigma_c
1937 SUBROUTINE create_mat_for_sigma_c(bs_env, t_2c_Gocc, t_2c_Gvir, t_2c_W, t_2c_Sigma_neg_tau, &
1938 t_2c_Sigma_pos_tau, t_3c_x_W, &
1939 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
1942 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
1943 t_2c_sigma_neg_tau, &
1944 t_2c_sigma_pos_tau, t_3c_x_w
1945 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
1947 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_mat_for_Sigma_c'
1949 INTEGER :: handle, i_t, ispin
1951 CALL timeset(routinen, handle)
1953 CALL dbt_create(bs_env%t_G, t_2c_gocc)
1954 CALL dbt_create(bs_env%t_G, t_2c_gvir)
1955 CALL dbt_create(bs_env%t_W, t_2c_w)
1956 CALL dbt_create(bs_env%t_G, t_2c_sigma_neg_tau)
1957 CALL dbt_create(bs_env%t_G, t_2c_sigma_pos_tau)
1958 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_w)
1960 NULLIFY (mat_sigma_neg_tau, mat_sigma_pos_tau)
1961 ALLOCATE (mat_sigma_neg_tau(bs_env%num_time_freq_points, bs_env%n_spin))
1962 ALLOCATE (mat_sigma_pos_tau(bs_env%num_time_freq_points, bs_env%n_spin))
1964 DO i_t = 1, bs_env%num_time_freq_points
1965 DO ispin = 1, bs_env%n_spin
1966 ALLOCATE (mat_sigma_neg_tau(i_t, ispin)%matrix)
1967 ALLOCATE (mat_sigma_pos_tau(i_t, ispin)%matrix)
1968 CALL dbcsr_create(mat_sigma_neg_tau(i_t, ispin)%matrix, template=bs_env%mat_ao_ao%matrix)
1969 CALL dbcsr_create(mat_sigma_pos_tau(i_t, ispin)%matrix, template=bs_env%mat_ao_ao%matrix)
1973 CALL timestop(handle)
1975 END SUBROUTINE create_mat_for_sigma_c
1986 SUBROUTINE compute_3c_and_contract_w(qs_env, bs_env, i_atoms, j_atoms, t_3c_x_W, t_2c_W)
1990 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
1991 TYPE(dbt_type) :: t_3c_x_w, t_2c_w
1993 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_3c_and_contract_W'
1995 INTEGER :: handle, ri_intval_idx
1996 INTEGER,
DIMENSION(2) :: bounds_j, ri_atoms
1997 TYPE(dbt_type) :: t_3c_for_w, t_3c_x_w_tmp
1999 CALL timeset(routinen, handle)
2001 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_x_w_tmp)
2002 CALL dbt_create(bs_env%t_RI__AO_AO, t_3c_for_w)
2004 bounds_j(1:2) = [bs_env%i_RI_start_from_atom(j_atoms(1)), &
2005 bs_env%i_RI_end_from_atom(j_atoms(2))]
2007 DO ri_intval_idx = 1, bs_env%n_intervals_inner_loop_atoms
2008 ri_atoms = bs_env%inner_loop_atom_intervals(1:2, ri_intval_idx)
2011 CALL compute_3c_integrals(qs_env, bs_env, t_3c_for_w, &
2012 atoms_ao_1=i_atoms, atoms_ri=ri_atoms)
2015 CALL dbt_contract(alpha=1.0_dp, &
2017 tensor_2=t_3c_for_w, &
2019 tensor_3=t_3c_x_w_tmp, &
2020 contract_1=[2], notcontract_1=[1], map_1=[1], &
2021 contract_2=[1], notcontract_2=[2, 3], map_2=[2, 3], &
2022 bounds_2=bounds_j, &
2023 filter_eps=bs_env%eps_filter)
2028 CALL dbt_copy(t_3c_x_w_tmp, t_3c_x_w, order=[1, 2, 3], move_data=.true.)
2030 CALL dbt_destroy(t_3c_x_w_tmp)
2031 CALL dbt_destroy(t_3c_for_w)
2033 CALL timestop(handle)
2035 END SUBROUTINE compute_3c_and_contract_w
2051 SUBROUTINE contract_to_sigma(t_2c_G, t_3c_x_W, t_2c_Sigma, i_atoms, j_atoms, qs_env, bs_env, &
2052 occ, vir, clear_W, can_skip)
2053 TYPE(dbt_type) :: t_2c_g, t_3c_x_w, t_2c_sigma
2054 INTEGER,
DIMENSION(2) :: i_atoms, j_atoms
2057 LOGICAL :: occ, vir, clear_w
2058 LOGICAL,
OPTIONAL :: can_skip
2060 CHARACTER(LEN=*),
PARAMETER :: routinen =
'contract_to_Sigma'
2062 INTEGER :: handle, inner_loop_atoms_interval_index
2063 INTEGER(KIND=int_8) :: flop
2064 INTEGER,
DIMENSION(2) :: bounds_i, il_atoms
2065 REAL(kind=
dp) :: sign_sigma
2066 TYPE(dbt_type) :: t_3c_for_g, t_3c_x_g, t_3c_x_g_2
2068 CALL timeset(routinen, handle)
2070 cpassert(occ .EQV. (.NOT. vir))
2071 IF (occ) sign_sigma = -1.0_dp
2072 IF (vir) sign_sigma = 1.0_dp
2074 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_for_g)
2075 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_g)
2076 CALL dbt_create(bs_env%t_RI_AO__AO, t_3c_x_g_2)
2078 bounds_i(1:2) = [bs_env%i_ao_start_from_atom(i_atoms(1)), &
2079 bs_env%i_ao_end_from_atom(i_atoms(2))]
2081 DO inner_loop_atoms_interval_index = 1, bs_env%n_intervals_inner_loop_atoms
2082 il_atoms = bs_env%inner_loop_atom_intervals(1:2, inner_loop_atoms_interval_index)
2084 CALL compute_3c_integrals(qs_env, bs_env, t_3c_for_g, &
2085 atoms_ri=j_atoms, atoms_ao_2=il_atoms)
2087 CALL dbt_contract(alpha=1.0_dp, &
2089 tensor_2=t_3c_for_g, &
2091 tensor_3=t_3c_x_g, &
2092 contract_1=[2], notcontract_1=[1], map_1=[3], &
2093 contract_2=[3], notcontract_2=[1, 2], map_2=[1, 2], &
2094 bounds_2=bounds_i, &
2095 filter_eps=bs_env%eps_filter)
2099 CALL dbt_copy(t_3c_x_g, t_3c_x_g_2, order=[1, 3, 2], move_data=.true.)
2101 CALL dbt_contract(alpha=sign_sigma, &
2102 tensor_1=t_3c_x_w, &
2103 tensor_2=t_3c_x_g_2, &
2105 tensor_3=t_2c_sigma, &
2106 contract_1=[1, 2], notcontract_1=[3], map_1=[1], &
2107 contract_2=[1, 2], notcontract_2=[3], map_2=[2], &
2108 filter_eps=bs_env%eps_filter, move_data=clear_w, flop=flop)
2110 IF (
PRESENT(can_skip))
THEN
2111 IF (flop == 0_int_8) can_skip = .true.
2114 CALL dbt_destroy(t_3c_for_g)
2115 CALL dbt_destroy(t_3c_x_g)
2116 CALL dbt_destroy(t_3c_x_g_2)
2118 CALL timestop(handle)
2120 END SUBROUTINE contract_to_sigma
2129 SUBROUTINE fill_fm_sigma_c_gamma_time(fm_Sigma_c_Gamma_time, bs_env, &
2130 mat_Sigma_pos_tau, mat_Sigma_neg_tau)
2132 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
2134 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_pos_tau, mat_sigma_neg_tau
2136 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fill_fm_Sigma_c_Gamma_time'
2138 INTEGER :: handle, i_t, ispin, pos_neg
2140 CALL timeset(routinen, handle)
2142 ALLOCATE (fm_sigma_c_gamma_time(bs_env%num_time_freq_points, 2, bs_env%n_spin))
2143 DO i_t = 1, bs_env%num_time_freq_points
2144 DO ispin = 1, bs_env%n_spin
2146 CALL cp_fm_create(fm_sigma_c_gamma_time(i_t, pos_neg, ispin), &
2147 bs_env%fm_s_Gamma%matrix_struct)
2150 fm_sigma_c_gamma_time(i_t, 1, ispin))
2152 fm_sigma_c_gamma_time(i_t, 2, ispin))
2156 CALL timestop(handle)
2158 END SUBROUTINE fill_fm_sigma_c_gamma_time
2164 SUBROUTINE print_skipping(bs_env)
2168 CHARACTER(LEN=*),
PARAMETER :: routinen =
'print_skipping'
2170 INTEGER :: handle, i_intval_idx, j_intval_idx, &
2173 CALL timeset(routinen, handle)
2177 DO i_intval_idx = 1, bs_env%n_intervals_i
2178 DO j_intval_idx = 1, bs_env%n_intervals_j
2179 IF (bs_env%skip_Sigma_occ(i_intval_idx, j_intval_idx) .AND. &
2180 bs_env%skip_Sigma_vir(i_intval_idx, j_intval_idx))
THEN
2186 IF (bs_env%unit_nr > 0)
THEN
2187 WRITE (bs_env%unit_nr,
'(T2,A,T74,F7.1,A)') &
2188 Στ
'Sparsity of ^c(i,k=0): Percentage of skipped atom pairs:', &
2189 REAL(100*n_skip, kind=
dp)/real(i_intval_idx*j_intval_idx, kind=
dp),
' %'
2192 CALL timestop(handle)
2194 END SUBROUTINE print_skipping
2208 SUBROUTINE destroy_mat_sigma_c(t_2c_Gocc, t_2c_Gvir, t_2c_W, t_2c_Sigma_neg_tau, &
2209 t_2c_Sigma_pos_tau, t_3c_x_W, fm_W_MIC_time, &
2210 mat_Sigma_neg_tau, mat_Sigma_pos_tau)
2212 TYPE(dbt_type) :: t_2c_gocc, t_2c_gvir, t_2c_w, &
2213 t_2c_sigma_neg_tau, &
2214 t_2c_sigma_pos_tau, t_3c_x_w
2215 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
2216 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_sigma_neg_tau, mat_sigma_pos_tau
2218 CHARACTER(LEN=*),
PARAMETER :: routinen =
'destroy_mat_Sigma_c'
2222 CALL timeset(routinen, handle)
2224 CALL dbt_destroy(t_2c_gocc)
2225 CALL dbt_destroy(t_2c_gvir)
2226 CALL dbt_destroy(t_2c_w)
2227 CALL dbt_destroy(t_2c_sigma_neg_tau)
2228 CALL dbt_destroy(t_2c_sigma_pos_tau)
2229 CALL dbt_destroy(t_3c_x_w)
2234 CALL timestop(handle)
2236 END SUBROUTINE destroy_mat_sigma_c
2242 SUBROUTINE delete_unnecessary_files(bs_env)
2245 CHARACTER(LEN=*),
PARAMETER :: routinen =
'delete_unnecessary_files'
2247 CHARACTER(LEN=default_string_length) :: f_chi, f_w_t, prefix
2248 INTEGER :: handle, i_t
2250 CALL timeset(routinen, handle)
2252 prefix = bs_env%prefix
2254 DO i_t = 1, bs_env%num_time_freq_points
2257 WRITE (f_chi,
'(3A,I1,A)') trim(prefix), bs_env%chi_name,
"_00", i_t,
".matrix"
2258 WRITE (f_w_t,
'(3A,I1,A)') trim(prefix), bs_env%W_time_name,
"_00", i_t,
".matrix"
2259 ELSE IF (i_t < 100)
THEN
2260 WRITE (f_chi,
'(3A,I2,A)') trim(prefix), bs_env%chi_name,
"_0", i_t,
".matrix"
2261 WRITE (f_w_t,
'(3A,I2,A)') trim(prefix), bs_env%W_time_name,
"_0", i_t,
".matrix"
2263 cpabort(
'Please implement more than 99 time/frequency points.')
2266 CALL safe_delete(f_chi, bs_env)
2267 CALL safe_delete(f_w_t, bs_env)
2271 CALL timestop(handle)
2273 END SUBROUTINE delete_unnecessary_files
2280 SUBROUTINE safe_delete(filename, bs_env)
2281 CHARACTER(LEN=*) :: filename
2284 CHARACTER(LEN=*),
PARAMETER :: routinen =
'safe_delete'
2289 CALL timeset(routinen, handle)
2291 IF (bs_env%para_env%mepos == 0)
THEN
2298 CALL timestop(handle)
2300 END SUBROUTINE safe_delete
2309 SUBROUTINE time_to_freq(bs_env, Sigma_c_n_time, Sigma_c_n_freq, ispin)
2311 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: sigma_c_n_time, sigma_c_n_freq
2314 CHARACTER(LEN=*),
PARAMETER :: routinen =
'time_to_freq'
2316 INTEGER :: handle, i_t, j_w, n_occ
2317 REAL(kind=
dp) :: freq_j, time_i, w_cos_ij, w_sin_ij
2318 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: sigma_c_n_cos_time, sigma_c_n_sin_time
2320 CALL timeset(routinen, handle)
2322 ALLOCATE (sigma_c_n_cos_time(bs_env%n_ao, bs_env%num_time_freq_points))
2323 ALLOCATE (sigma_c_n_sin_time(bs_env%n_ao, bs_env%num_time_freq_points))
2325 sigma_c_n_cos_time(:, :) = 0.5_dp*(sigma_c_n_time(:, :, 1) + sigma_c_n_time(:, :, 2))
2326 sigma_c_n_sin_time(:, :) = 0.5_dp*(sigma_c_n_time(:, :, 1) - sigma_c_n_time(:, :, 2))
2328 sigma_c_n_freq(:, :, :) = 0.0_dp
2330 DO i_t = 1, bs_env%num_time_freq_points
2332 DO j_w = 1, bs_env%num_time_freq_points
2334 freq_j = bs_env%imag_freq_points(j_w)
2335 time_i = bs_env%imag_time_points(i_t)
2337 w_cos_ij = bs_env%weights_cos_t_to_w(j_w, i_t)*cos(freq_j*time_i)
2338 w_sin_ij = bs_env%weights_sin_t_to_w(j_w, i_t)*sin(freq_j*time_i)
2341 sigma_c_n_freq(:, j_w, 1) = sigma_c_n_freq(:, j_w, 1) + &
2342 w_cos_ij*sigma_c_n_cos_time(:, i_t)
2345 sigma_c_n_freq(:, j_w, 2) = sigma_c_n_freq(:, j_w, 2) + &
2346 w_sin_ij*sigma_c_n_sin_time(:, i_t)
2355 n_occ = bs_env%n_occ(ispin)
2356 sigma_c_n_freq(1:n_occ, :, 2) = -sigma_c_n_freq(1:n_occ, :, 2)
2358 CALL timestop(handle)
2360 END SUBROUTINE time_to_freq
2369 SUBROUTINE compute_qp_energies(bs_env, qs_env, fm_Sigma_x_Gamma, fm_Sigma_c_Gamma_time)
2373 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_sigma_x_gamma
2374 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :, :) :: fm_sigma_c_gamma_time
2376 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_QP_energies'
2378 INTEGER :: handle, ikp, ispin, j_t
2379 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sigma_x_ikp_n, v_xc_ikp_n
2380 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: sigma_c_ikp_n_freq, sigma_c_ikp_n_time
2381 TYPE(
cp_cfm_type) :: cfm_ks_ikp, cfm_mos_ikp, cfm_s_ikp, &
2382 cfm_sigma_x_ikp, cfm_work_ikp
2384 CALL timeset(routinen, handle)
2386 CALL cp_cfm_create(cfm_mos_ikp, bs_env%fm_s_Gamma%matrix_struct)
2387 CALL cp_cfm_create(cfm_work_ikp, bs_env%fm_s_Gamma%matrix_struct)
2389 ALLOCATE (v_xc_ikp_n(bs_env%n_ao), sigma_x_ikp_n(bs_env%n_ao))
2390 ALLOCATE (sigma_c_ikp_n_time(bs_env%n_ao, bs_env%num_time_freq_points, 2))
2391 ALLOCATE (sigma_c_ikp_n_freq(bs_env%n_ao, bs_env%num_time_freq_points, 2))
2393 DO ispin = 1, bs_env%n_spin
2395 DO ikp = 1, bs_env%kpoints_DOS%nkp
2399 ikp, qs_env, bs_env%kpoints_DOS,
"ORB")
2403 ikp, qs_env, bs_env%kpoints_DOS,
"ORB")
2406 CALL cp_cfm_geeig(cfm_ks_ikp, cfm_s_ikp, cfm_mos_ikp, &
2407 bs_env%eigenval_scf(:, ikp, ispin), cfm_work_ikp)
2410 CALL to_ikp_and_mo(v_xc_ikp_n, bs_env%fm_V_xc_Gamma(ispin), &
2411 ikp, qs_env, bs_env, cfm_mos_ikp)
2414 CALL to_ikp_and_mo(sigma_x_ikp_n, fm_sigma_x_gamma(ispin), &
2415 ikp, qs_env, bs_env, cfm_mos_ikp)
2418 DO j_t = 1, bs_env%num_time_freq_points
2419 CALL to_ikp_and_mo(sigma_c_ikp_n_time(:, j_t, 1), &
2420 fm_sigma_c_gamma_time(j_t, 1, ispin), &
2421 ikp, qs_env, bs_env, cfm_mos_ikp)
2422 CALL to_ikp_and_mo(sigma_c_ikp_n_time(:, j_t, 2), &
2423 fm_sigma_c_gamma_time(j_t, 2, ispin), &
2424 ikp, qs_env, bs_env, cfm_mos_ikp)
2428 CALL time_to_freq(bs_env, sigma_c_ikp_n_time, sigma_c_ikp_n_freq, ispin)
2432 CALL analyt_conti_and_print(bs_env, sigma_c_ikp_n_freq, sigma_x_ikp_n, v_xc_ikp_n, &
2439 CALL get_vbm_cbm_bandgaps(bs_env)
2442 CALL g0w0_hamiltonian(bs_env)
2452 CALL timestop(handle)
2454 END SUBROUTINE compute_qp_energies
2465 SUBROUTINE to_ikp_and_mo(array_ikp_n, fm_Gamma, ikp, qs_env, bs_env, cfm_mos_ikp)
2467 REAL(kind=
dp),
DIMENSION(:) :: array_ikp_n
2474 CHARACTER(LEN=*),
PARAMETER :: routinen =
'to_ikp_and_mo'
2479 CALL timeset(routinen, handle)
2481 CALL cp_fm_create(fm_ikp_mo_re, fm_gamma%matrix_struct)
2483 CALL fm_gamma_ao_to_cfm_ikp_mo(fm_gamma, fm_ikp_mo_re, ikp, qs_env, bs_env, cfm_mos_ikp)
2489 CALL timestop(handle)
2491 END SUBROUTINE to_ikp_and_mo
2502 SUBROUTINE fm_gamma_ao_to_cfm_ikp_mo(fm_Gamma, fm_ikp_mo_re, ikp, qs_env, bs_env, cfm_mos_ikp)
2509 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_Gamma_ao_to_cfm_ikp_mo'
2511 INTEGER :: handle, nmo
2512 TYPE(
cp_cfm_type) :: cfm_ikp_ao, cfm_ikp_mo, cfm_tmp
2514 CALL timeset(routinen, handle)
2533 CALL timestop(handle)
2535 END SUBROUTINE fm_gamma_ao_to_cfm_ikp_mo
2546 SUBROUTINE analyt_conti_and_print(bs_env, Sigma_c_ikp_n_freq, Sigma_x_ikp_n, V_xc_ikp_n, ikp, ispin)
2549 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: sigma_c_ikp_n_freq
2550 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sigma_x_ikp_n, v_xc_ikp_n
2551 INTEGER :: ikp, ispin
2553 CHARACTER(LEN=*),
PARAMETER :: routinen =
'analyt_conti_and_print'
2555 CHARACTER(len=3) :: occ_vir
2556 CHARACTER(len=default_string_length) :: fname
2557 INTEGER :: handle, i_mo, iunit, n_mo
2558 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: dummy, sigma_c_ikp_n_qp
2560 CALL timeset(routinen, handle)
2563 ALLOCATE (dummy(n_mo), sigma_c_ikp_n_qp(n_mo))
2564 sigma_c_ikp_n_qp(:) = 0.0_dp
2568 IF (
modulo(i_mo, bs_env%para_env%num_pe) /= bs_env%para_env%mepos) cycle
2571 bs_env%imag_freq_points_fit, dummy, dummy, &
2572 sigma_c_ikp_n_freq(:, 1:bs_env%num_freq_points_fit, 1)*
z_one + &
2573 sigma_c_ikp_n_freq(:, 1:bs_env%num_freq_points_fit, 2)*
gaussi, &
2574 sigma_x_ikp_n(:) - v_xc_ikp_n(:), &
2575 bs_env%eigenval_scf(:, ikp, ispin), &
2576 bs_env%eigenval_scf(:, ikp, ispin), &
2577 i_mo, bs_env%n_occ(ispin), bs_env%nparam_pade, &
2578 bs_env%num_freq_points_fit, &
2580 0.0_dp, .true., .false., 1)
2584 CALL bs_env%para_env%sum(sigma_c_ikp_n_qp)
2586 bs_env%eigenval_G0W0(:, ikp, ispin) = bs_env%eigenval_scf(:, ikp, ispin) + &
2587 sigma_c_ikp_n_qp(:) + &
2588 sigma_x_ikp_n(:) - &
2591 CALL get_fname(fname, bs_env, ikp,
"SCF_and_G0W0", ispin=ispin)
2593 IF (bs_env%para_env%is_source())
THEN
2595 CALL open_file(trim(fname), unit_number=iunit, file_status=
"REPLACE", file_action=
"WRITE")
2597 WRITE (iunit,
"(A)")
" "
2598 WRITE (iunit,
"(A10,3F10.4)")
"kpoint: ", bs_env%kpoints_DOS%xkp(:, ikp)
2599 WRITE (iunit,
"(A)")
" "
2600 WRITE (iunit,
"(A5,A24,2A17,A16,A18)")
"n", ϵ
"_nk^DFT (eV)", Σ
"^c_nk (eV)", &
2601 Σ
"^x_nk (eV)",
"v_n^xc (eV)", ϵ
"_nk^G0W0 (eV)"
2602 WRITE (iunit,
"(A)")
" "
2605 IF (i_mo .LE. bs_env%n_occ(ispin)) occ_vir =
'occ'
2606 IF (i_mo > bs_env%n_occ(ispin)) occ_vir =
'vir'
2607 WRITE (iunit,
"(I5,3A,4F16.3,F17.3)") i_mo,
' (', occ_vir,
') ', &
2608 bs_env%eigenval_scf(i_mo, ikp, ispin)*
evolt, &
2609 sigma_c_ikp_n_qp(i_mo)*
evolt, &
2610 sigma_x_ikp_n(i_mo)*
evolt, &
2611 v_xc_ikp_n(i_mo)*
evolt, &
2612 bs_env%eigenval_G0W0(i_mo, ikp, ispin)*
evolt
2619 CALL timestop(handle)
2621 END SUBROUTINE analyt_conti_and_print
2627 SUBROUTINE get_vbm_cbm_bandgaps(bs_env)
2631 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_VBM_CBM_bandgaps'
2633 INTEGER :: handle, homo, homo_1, homo_2, ikp, &
2634 ispin, lumo, lumo_1, lumo_2, n_mo
2635 REAL(kind=
dp) :: e_dbg_g0w0_at_ikp, e_dbg_scf_at_ikp
2637 CALL timeset(routinen, handle)
2641 bs_env%band_edges_scf%DBG = 1000.0_dp
2642 bs_env%band_edges_G0W0%DBG = 1000.0_dp
2644 SELECT CASE (bs_env%n_spin)
2646 homo = bs_env%n_occ(1)
2648 bs_env%band_edges_scf%VBM = maxval(bs_env%eigenval_scf(1:homo, :, 1))
2649 bs_env%band_edges_scf%CBM = minval(bs_env%eigenval_scf(homo + 1:n_mo, :, 1))
2650 bs_env%band_edges_G0W0%VBM = maxval(bs_env%eigenval_G0W0(1:homo, :, 1))
2651 bs_env%band_edges_G0W0%CBM = minval(bs_env%eigenval_G0W0(homo + 1:n_mo, :, 1))
2653 homo_1 = bs_env%n_occ(1)
2655 homo_2 = bs_env%n_occ(2)
2657 bs_env%band_edges_scf%VBM = max(maxval(bs_env%eigenval_scf(1:homo_1, :, 1)), &
2658 maxval(bs_env%eigenval_scf(1:homo_2, :, 2)))
2659 bs_env%band_edges_scf%CBM = min(minval(bs_env%eigenval_scf(homo_1 + 1:n_mo, :, 1)), &
2660 minval(bs_env%eigenval_scf(homo_2 + 1:n_mo, :, 2)))
2661 bs_env%band_edges_G0W0%VBM = max(maxval(bs_env%eigenval_G0W0(1:homo_1, :, 1)), &
2662 maxval(bs_env%eigenval_G0W0(1:homo_2, :, 2)))
2663 bs_env%band_edges_G0W0%CBM = min(minval(bs_env%eigenval_G0W0(homo_1 + 1:n_mo, :, 1)), &
2664 minval(bs_env%eigenval_G0W0(homo_2 + 1:n_mo, :, 2)))
2666 cpabort(
"Error with number of spins.")
2669 bs_env%band_edges_scf%IDBG = bs_env%band_edges_scf%CBM - bs_env%band_edges_scf%VBM
2670 bs_env%band_edges_G0W0%IDBG = bs_env%band_edges_G0W0%CBM - bs_env%band_edges_G0W0%VBM
2672 DO ispin = 1, bs_env%n_spin
2674 homo = bs_env%n_occ(ispin)
2676 DO ikp = 1, bs_env%kpoints_DOS%nkp
2677 e_dbg_scf_at_ikp = -maxval(bs_env%eigenval_scf(1:homo, ikp, ispin)) + &
2678 minval(bs_env%eigenval_scf(homo + 1:n_mo, ikp, ispin))
2679 IF (e_dbg_scf_at_ikp < bs_env%band_edges_scf%DBG)
THEN
2680 bs_env%band_edges_scf%DBG = e_dbg_scf_at_ikp
2683 e_dbg_g0w0_at_ikp = -maxval(bs_env%eigenval_G0W0(1:homo, ikp, ispin)) + &
2684 minval(bs_env%eigenval_G0W0(homo + 1:n_mo, ikp, ispin))
2685 IF (e_dbg_g0w0_at_ikp < bs_env%band_edges_G0W0%DBG)
THEN
2686 bs_env%band_edges_G0W0%DBG = e_dbg_g0w0_at_ikp
2691 CALL timestop(handle)
2693 END SUBROUTINE get_vbm_cbm_bandgaps
2699 SUBROUTINE g0w0_hamiltonian(bs_env)
2702 CHARACTER(LEN=*),
PARAMETER :: routinen =
'G0W0_hamiltonian'
2704 INTEGER :: handle, i_row_local, j_col, j_col_local, &
2705 n_mo, ncol_local, nrow_local
2706 INTEGER,
DIMENSION(:),
POINTER :: col_indices
2707 REAL(kind=
dp) :: e_j
2709 CALL timeset(routinen, handle)
2714 nrow_local=nrow_local, &
2715 ncol_local=ncol_local, &
2716 col_indices=col_indices)
2718 CALL cp_fm_to_fm(bs_env%fm_mo_coeff_Gamma(1), bs_env%fm_work_mo(1))
2721 DO i_row_local = 1, nrow_local
2722 DO j_col_local = 1, ncol_local
2724 j_col = col_indices(j_col_local)
2727 e_j = bs_env%eigenval_G0W0(j_col, bs_env%nkp_DOS, 1)
2729 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local) = &
2730 bs_env%fm_work_mo(1)%local_data(i_row_local, j_col_local)*e_j
2740 CALL parallel_gemm(transa=
"N", transb=
"T", m=n_mo, n=n_mo, k=n_mo, alpha=1.0_dp, &
2741 matrix_a=bs_env%fm_mo_coeff_Gamma(1), matrix_b=bs_env%fm_work_mo(1), &
2742 beta=0.0_dp, matrix_c=bs_env%fm_work_mo(2))
2745 CALL parallel_gemm(transa=
"N", transb=
"N", m=n_mo, n=n_mo, k=n_mo, alpha=1.0_dp, &
2746 matrix_a=bs_env%fm_s_Gamma, matrix_b=bs_env%fm_work_mo(2), &
2747 beta=0.0_dp, matrix_c=bs_env%fm_work_mo(1))
2750 CALL parallel_gemm(transa=
"N", transb=
"N", m=n_mo, n=n_mo, k=n_mo, alpha=1.0_dp, &
2751 matrix_a=bs_env%fm_work_mo(1), matrix_b=bs_env%fm_s_Gamma, &
2752 beta=0.0_dp, matrix_c=bs_env%fm_h_G0W0_Gamma)
2754 CALL timestop(handle)
2756 END SUBROUTINE g0w0_hamiltonian
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
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.
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_cholesky_invert(matrix, n, info_out)
Used to replace Cholesky decomposition by the inverse.
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...
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_create(matrix, matrix_struct, name)
Creates a new full matrix with the given structure.
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_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.
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_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, use_sp)
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....
subroutine, public global_matrix_to_local_matrix(mat_global, mat_local, para_env, num_pe_sub, atom_ranges)
...
subroutine, public local_matrix_to_global_matrix(mat_local, mat_global, para_env)
...
subroutine, public gw(qs_env, bs_env, post_scf_bandstructure_section)
Perform GW band structure calculation.
subroutine, public de_init_bs_env(bs_env)
...
subroutine, public create_and_init_bs_env_for_gw(qs_env, bs_env, bs_sec)
...
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
complex(kind=dp), parameter, public gaussi
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)
...
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public evolt
subroutine, public cfm_ikp_from_fm_gamma(cfm_ikp, fm_gamma, ikp, qs_env, kpoints, basis_type)
...
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_fname(fname, bs_env, ikp, scf_gw, ispin, soc)
...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, 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, rhs)
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, bounds_i, bounds_j, bounds_k, ri_range, img_to_ri_cell)
Build 3-center integral tensor.
Routines treating GW and RPA calculations with kpoints.
subroutine, public cp_cfm_upper_to_full(cfm_mat_q)
...
subroutine, public cp_cfm_power(matrix, threshold, exponent, min_eigval)
...
Routines for GW, continuous development [Jan Wilhelm].
subroutine, public continuation_pade(vec_gw_energ, vec_omega_fit_gw, z_value, m_value, vec_sigma_c_gw, vec_sigma_x_minus_vxc_gw, eigenval, eigenval_scf, n_level_gw, gw_corr_lev_occ, nparam_pade, num_fit_points, crossing_search, homo, fermi_level_offset, do_gw_im_time, print_self_energy, count_ev_sc_gw, vec_gw_dos, dos_lower_bound, dos_precision, ndos, min_level_self_energy, max_level_self_energy, dos_eta, dos_min, dos_max)
perform analytic continuation with pade approximation
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.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.