29 dbcsr_type_no_symmetry
83#include "./base/base_uses.f90"
87 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'gw_compute_V_and_W'
114 SUBROUTINE compute_w(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_time)
117 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
118 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_time
120 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_W'
122 INTEGER :: handle, i_t, j_w
124 TYPE(
cp_fm_type) :: fm_m_inv_v_sqrt, fm_v, fm_v_sqrt
126 CALL timeset(routinen, handle)
130 CALL create_fm_w_mic_time(bs_env, fm_w_time)
134 CALL cp_fm_create(fm_v_sqrt, bs_env%fm_RI_RI%matrix_struct)
135 CALL cp_fm_create(fm_m_inv_v_sqrt, bs_env%fm_RI_RI%matrix_struct)
138 CALL compute_v_minvvsqrt(bs_env, qs_env, fm_v, fm_v_sqrt, fm_m_inv_v_sqrt)
141 DO j_w = 1, bs_env%num_time_freq_points
143 CALL compute_fm_chi_gamma_freq(bs_env, bs_env%fm_chi_Gamma_freq, j_w, mat_chi_gamma_tau)
147 CALL compute_fm_w_freq(bs_env, bs_env%fm_chi_Gamma_freq, fm_v_sqrt, &
148 fm_m_inv_v_sqrt, bs_env%fm_W_MIC_freq)
151 CALL fourier_transform_w_to_t(bs_env, fm_w_time, bs_env%fm_W_MIC_freq, j_w)
157 IF (bs_env%unit_nr > 0)
THEN
158 WRITE (bs_env%unit_nr,
'(T2,A,T58,A,F7.1,A)') &
159 'Computed W(iτ),',
' Execution time',
m_walltime() - t1,
' s'
172 CALL cp_fm_create(bs_env%fm_W_MIC_freq_zero, bs_env%fm_W_MIC_freq%matrix_struct)
176 DO i_t = 1, bs_env%num_time_freq_points
179 bs_env%time_frequency_grid%time_weights_at_zero_frequency(i_t), fm_w_time(i_t))
182 CALL fm_write(bs_env%fm_W_MIC_freq_zero, 0,
"W_freq_rtp", qs_env)
184 IF (bs_env%unit_nr > 0)
THEN
185 WRITE (bs_env%unit_nr,
'(T2,A,T57,A,F7.1,A)') &
186 'Computed W(0),',
' Execution time',
m_walltime() - t1,
' s'
190 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
192 CALL timestop(handle)
203 SUBROUTINE get_w_mic(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
206 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
207 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
209 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_W_MIC'
213 CALL timeset(routinen, handle)
215 IF (bs_env%all_W_exist)
THEN
216 CALL read_w_mic_time(bs_env, mat_chi_gamma_tau, fm_w_mic_time)
218 CALL compute_w_mic(bs_env, qs_env, mat_chi_gamma_tau, fm_w_mic_time)
221 CALL timestop(handle)
232 SUBROUTINE compute_w_mic(bs_env, qs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
235 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
236 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
238 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_W_MIC'
240 INTEGER :: handle, i_t, ikp, ikp_batch, &
243 TYPE(
cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
244 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: cfm_v_kp
246 CALL timeset(routinen, handle)
248 CALL create_fm_w_mic_time(bs_env, fm_w_mic_time)
250 DO ikp_batch = 1, bs_env%num_chi_eps_W_batches
257 DO ikp_in_batch = 1, bs_env%nkp_chi_eps_W_batch
259 ikp = (ikp_batch - 1)*bs_env%nkp_chi_eps_W_batch + ikp_in_batch
261 IF (ikp > bs_env%nkp_chi_eps_W_orig_plus_extra)
THEN
266 cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp, ikp)
268 CALL bs_env%para_env%sync()
271 DO j_w = 1, bs_env%num_time_freq_points
274 IF (bs_env%approx_kp_extrapol .AND. j_w > 1 .AND. &
275 ikp > bs_env%nkp_chi_eps_W_orig) cycle
277 CALL compute_fm_w_mic_freq_j(bs_env, qs_env, bs_env%fm_W_MIC_freq, j_w, ikp, &
278 mat_chi_gamma_tau, cfm_m_inv_v_sqrt_ikp, &
282 CALL fourier_transform_w_to_t(bs_env, fm_w_mic_time, bs_env%fm_W_MIC_freq, j_w)
288 DEALLOCATE (cfm_v_kp)
290 IF (bs_env%unit_nr > 0)
THEN
291 WRITE (bs_env%unit_nr,
'(T2,A,I12,A,I3,A,F10.1,A)') &
292 'Computed W(iτ,k) for k-point batch', &
293 ikp_batch,
' /', bs_env%num_chi_eps_W_batches, &
299 IF (bs_env%approx_kp_extrapol)
THEN
306 DO i_t = 1, bs_env%num_time_freq_points
307 CALL fm_write(fm_w_mic_time(i_t), i_t, bs_env%W_time_name, qs_env)
317 CALL sum_w_mic_freq_zero(bs_env, fm_w_mic_time)
318 CALL fm_write(bs_env%fm_W_MIC_freq_zero, 0,
"W_freq_rtp", qs_env)
319 ELSE IF (bs_env%keep_W_freq_zero)
THEN
320 CALL sum_w_mic_freq_zero(bs_env, fm_w_mic_time)
323 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
325 CALL timestop(handle)
327 END SUBROUTINE compute_w_mic
339 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: cfm_v_kp
342 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_V_k_by_lattice_sum'
344 INTEGER :: handle, ikp, ikp_end, ikp_start, &
345 nkp_chi_eps_w_batch, re_im
349 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_v_kp
351 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
353 CALL timeset(routinen, handle)
355 nkp_chi_eps_w_batch = bs_env%nkp_chi_eps_W_batch
357 ikp_start = (ikp_batch - 1)*bs_env%nkp_chi_eps_W_batch + 1
358 ikp_end = min(ikp_batch*bs_env%nkp_chi_eps_W_batch, bs_env%kpoints_chi_eps_W%nkp)
361 ALLOCATE (mat_v_kp(ikp_start:ikp_end, 2))
364 DO ikp = ikp_start, ikp_end
365 NULLIFY (mat_v_kp(ikp, re_im)%matrix)
366 ALLOCATE (mat_v_kp(ikp, re_im)%matrix)
367 CALL dbcsr_create(mat_v_kp(ikp, re_im)%matrix, template=bs_env%mat_RI_RI%matrix)
369 CALL dbcsr_set(mat_v_kp(ikp, re_im)%matrix, 0.0_dp)
374 particle_set=particle_set, &
376 qs_kind_set=qs_kind_set, &
377 atomic_kind_set=atomic_kind_set)
379 IF (ikp_end <= bs_env%nkp_chi_eps_W_orig)
THEN
382 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
384 ELSE IF (ikp_start > bs_env%nkp_chi_eps_W_orig .AND. &
385 ikp_end <= bs_env%nkp_chi_eps_W_orig_plus_extra)
THEN
388 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_extra
392 cpabort(
"Error with k-point parallelization.")
397 bs_env%kpoints_chi_eps_W, &
398 basis_type=
"RI_AUX", &
400 particle_set=particle_set, &
401 qs_kind_set=qs_kind_set, &
402 atomic_kind_set=atomic_kind_set, &
403 size_lattice_sum=bs_env%size_lattice_sum_V, &
405 ikp_start=ikp_start, &
408 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
410 ALLOCATE (cfm_v_kp(ikp_start:ikp_end))
411 CALL cp_fm_create(fm_v_kp_work, bs_env%fm_RI_RI%matrix_struct)
412 DO ikp = ikp_start, ikp_end
413 CALL cp_cfm_create(cfm_v_kp(ikp), bs_env%fm_RI_RI%matrix_struct)
416 cfm_v_kp(ikp)%local_data = cmplx(fm_v_kp_work%local_data, 0.0_dp, kind=
dp)
420 cfm_v_kp(ikp)%local_data = cmplx(real(cfm_v_kp(ikp)%local_data, kind=
dp), &
421 fm_v_kp_work%local_data, kind=
dp)
426 CALL timestop(handle)
440 cfm_M_inv_V_sqrt_ikp, ikp)
443 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: cfm_v_kp
444 TYPE(
cp_cfm_type) :: cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp
447 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_MinvVsqrt_Vsqrt'
449 INTEGER :: handle, info, n_ri
451 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: cfm_m_ikp
453 CALL timeset(routinen, handle)
459 bs_env%kpoints_chi_eps_W, regularization_ri=bs_env%regularization_RI, &
460 ikp_ext=ikp, do_build_cell_index=(ikp == 1))
463 CALL cp_cfm_create(cfm_v_sqrt_ikp, cfm_v_kp(ikp)%matrix_struct)
464 CALL cp_cfm_create(cfm_m_inv_v_sqrt_ikp, cfm_v_kp(ikp)%matrix_struct)
466 CALL cp_cfm_create(cfm_m_inv_ikp, cfm_v_kp(ikp)%matrix_struct)
472 DEALLOCATE (cfm_m_ikp)
486 CALL cp_cfm_power(cfm_work, threshold=bs_env%eps_eigval_mat_RI, exponent=-1.0_dp)
495 CALL clean_lower_part(cfm_v_sqrt_ikp)
498 CALL cp_cfm_power(cfm_work, threshold=0.0_dp, exponent=0.5_dp)
504 CALL parallel_gemm(
"N",
"C", n_ri, n_ri, n_ri,
z_one, cfm_m_inv_ikp, cfm_v_sqrt_ikp, &
505 z_zero, cfm_m_inv_v_sqrt_ikp)
509 CALL timestop(handle)
520 SUBROUTINE compute_cfm_w_ikp_freq_j(bs_env, cfm_chi_eps_W_ikp_freq_j, cfm_V_sqrt_ikp, &
521 cfm_M_inv_V_sqrt_ikp)
523 TYPE(
cp_cfm_type),
INTENT(INOUT) :: cfm_chi_eps_w_ikp_freq_j
524 TYPE(
cp_cfm_type),
INTENT(IN) :: cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp
526 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_cfm_W_ikp_freq_j'
528 INTEGER :: handle, info
530 CALL timeset(routinen, handle)
549 CALL timestop(handle)
551 END SUBROUTINE compute_cfm_w_ikp_freq_j
559 SUBROUTINE read_w_mic_time(bs_env, mat_chi_Gamma_tau, fm_W_MIC_time)
561 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
562 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
564 CHARACTER(LEN=*),
PARAMETER :: routinen =
'read_W_MIC_time'
566 INTEGER :: handle, i_t
569 CALL timeset(routinen, handle)
572 CALL create_fm_w_mic_time(bs_env, fm_w_mic_time)
574 DO i_t = 1, bs_env%num_time_freq_points
578 CALL fm_read(fm_w_mic_time(i_t), bs_env, bs_env%W_time_name, i_t)
580 IF (bs_env%unit_nr > 0)
THEN
581 WRITE (bs_env%unit_nr,
'(T2,A,I5,A,I3,A,F10.1,A)') &
582 'Read W^MIC(iτ) from file for time point ', i_t,
' /', bs_env%num_time_freq_points, &
588 IF (bs_env%unit_nr > 0)
WRITE (bs_env%unit_nr,
'(A)')
' '
594 CALL cp_fm_create(bs_env%fm_W_MIC_freq_zero, bs_env%fm_W_MIC_freq%matrix_struct)
596 CALL fm_read(bs_env%fm_W_MIC_freq_zero, bs_env,
"W_freq_rtp", 0)
597 IF (bs_env%unit_nr > 0)
THEN
598 WRITE (bs_env%unit_nr,
'(T2,A,I3,A,I3,A,F10.1,A)') &
599 'Read W^MIC(f=0) from file for freq. point ', 1,
' /', 1, &
602 ELSE IF (bs_env%keep_W_freq_zero)
THEN
604 CALL sum_w_mic_freq_zero(bs_env, fm_w_mic_time)
607 CALL timestop(handle)
609 END SUBROUTINE read_w_mic_time
622 SUBROUTINE compute_fm_w_mic_freq_j(bs_env, qs_env, fm_W_MIC_freq_j, j_w, ikp, mat_chi_Gamma_tau, &
623 cfm_M_inv_V_sqrt_ikp, cfm_V_sqrt_ikp)
628 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
629 TYPE(
cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
631 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_W_MIC_freq_j'
635 CALL timeset(routinen, handle)
638 CALL compute_fm_chi_gamma_freq(bs_env, bs_env%fm_chi_Gamma_freq, j_w, mat_chi_gamma_tau)
642 cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp)
644 CALL timestop(handle)
646 END SUBROUTINE compute_fm_w_mic_freq_j
659 cfm_M_inv_V_sqrt_ikp, cfm_V_sqrt_ikp)
664 TYPE(
cp_cfm_type) :: cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp
666 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_W_MIC_freq_j_from_chi'
671 CALL timeset(routinen, handle)
677 ikp, qs_env, bs_env%kpoints_chi_eps_W,
"RI_AUX")
680 CALL cp_cfm_power(cfm_chi_eps_w_ikp_freq_j, threshold=0.0_dp, exponent=1.0_dp)
683 CALL compute_cfm_w_ikp_freq_j(bs_env, cfm_chi_eps_w_ikp_freq_j, cfm_v_sqrt_ikp, &
684 cfm_m_inv_v_sqrt_ikp)
687 SELECT CASE (bs_env%approx_kp_extrapol)
691 cfm_chi_eps_w_ikp_freq_j, ikp, &
692 bs_env%kpoints_chi_eps_W,
"RI_AUX")
703 cfm_chi_eps_w_ikp_freq_j, ikp, &
704 bs_env%kpoints_chi_eps_W, &
707 IF (ikp <= bs_env%nkp_chi_eps_W_orig)
THEN
709 cfm_chi_eps_w_ikp_freq_j, ikp, &
710 bs_env%kpoints_chi_eps_W, &
711 "RI_AUX", wkp_ext=bs_env%wkp_orig)
717 IF (ikp <= bs_env%nkp_chi_eps_W_orig)
THEN
719 cfm_chi_eps_w_ikp_freq_j, &
720 ikp, bs_env%kpoints_chi_eps_W,
"RI_AUX", &
721 wkp_ext=bs_env%wkp_orig)
727 CALL timestop(handle)
735 SUBROUTINE clean_lower_part(cfm_mat)
738 CHARACTER(LEN=*),
PARAMETER :: routinen =
'clean_lower_part'
740 INTEGER :: handle, i_row, j_col, j_global, &
741 ncol_local, nrow_local
742 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
744 CALL timeset(routinen, handle)
747 nrow_local=nrow_local, ncol_local=ncol_local, &
748 row_indices=row_indices, col_indices=col_indices)
750 DO j_col = 1, ncol_local
751 j_global = col_indices(j_col)
752 DO i_row = 1, nrow_local
753 IF (j_global < row_indices(i_row)) cfm_mat%local_data(i_row, j_col) =
z_zero
757 CALL timestop(handle)
759 END SUBROUTINE clean_lower_part
768 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
770 CHARACTER(LEN=*),
PARAMETER :: routinen =
'apply_extrapol_factor'
771 REAL(kind=
dp),
PARAMETER :: eps_w_no_extra_1 = 1.0e-13_dp
773 INTEGER :: handle, i, i_t, j, ncol_local, nrow_local
774 REAL(kind=
dp) :: extrapol_factor, w_extra_1, w_no_extra_1
776 CALL timeset(routinen, handle)
778 CALL cp_fm_get_info(matrix=fm_w_mic_time(1), nrow_local=nrow_local, ncol_local=ncol_local)
780 DO i_t = 1,
SIZE(fm_w_mic_time)
784 w_extra_1 = bs_env%fm_W_MIC_freq_1_extra%local_data(i, j)
785 w_no_extra_1 = bs_env%fm_W_MIC_freq_1_no_extra%local_data(i, j)
787 IF (abs(w_no_extra_1) > eps_w_no_extra_1)
THEN
788 extrapol_factor = abs(w_extra_1/w_no_extra_1)
790 extrapol_factor = 1.0_dp
794 IF (extrapol_factor > 10.0_dp) extrapol_factor = 1.0_dp
796 fm_w_mic_time(i_t)%local_data(i, j) = fm_w_mic_time(i_t)%local_data(i, j) &
802 CALL timestop(handle)
816 SUBROUTINE compute_v_minvvsqrt(bs_env, qs_env, fm_V, fm_V_sqrt, fm_Minv_Vsqrt)
819 TYPE(
cp_fm_type),
INTENT(INOUT) :: fm_v, fm_v_sqrt, fm_minv_vsqrt
821 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_V_MinvVsqrt'
826 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_v_kp
828 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
830 CALL timeset(routinen, handle)
832 IF (bs_env%auto_ri%enabled)
THEN
842 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, cell=cell, &
843 qs_kind_set=qs_kind_set)
844 atomic_kind_set => bs_env%ri_rs%atomic_kind_set
846 ALLOCATE (mat_v_kp(1:1, 1:2))
847 NULLIFY (mat_v_kp(1, 1)%matrix, mat_v_kp(1, 2)%matrix)
848 ALLOCATE (mat_v_kp(1, 1)%matrix, mat_v_kp(1, 2)%matrix)
849 CALL dbcsr_create(mat_v_kp(1, 1)%matrix, template=bs_env%mat_RI_RI%matrix)
851 CALL dbcsr_set(mat_v_kp(1, 1)%matrix, 0.0_dp)
852 CALL dbcsr_create(mat_v_kp(1, 2)%matrix, template=bs_env%mat_RI_RI%matrix)
855 CALL dbcsr_set(mat_v_kp(1, 2)%matrix, 0.0_dp)
857 bs_env%kpoints_chi_eps_W%nkp_grid = bs_env%nkp_grid_chi_eps_W_orig
859 particle_set, qs_kind_set, atomic_kind_set, &
865 DEALLOCATE (mat_v_kp)
871 CALL fm_sqrt(fm_v, fm_v_sqrt, bs_env%eps_eigval_mat_RI, bs_env%unit_nr)
876 CALL parallel_gemm(
"N",
"T", bs_env%n_RI, bs_env%n_RI, bs_env%n_RI, 1.0_dp, &
877 bs_env%fm_Minv_Gamma, fm_v_sqrt, 0.0_dp, fm_minv_vsqrt)
879 CALL timestop(handle)
881 END SUBROUTINE compute_v_minvvsqrt
895 SUBROUTINE compute_fm_w_freq(bs_env, fm_chi_freq_j, fm_V_sqrt, fm_Minv_Vsqrt, fm_W_freq_j)
897 TYPE(
cp_fm_type),
INTENT(IN) :: fm_chi_freq_j, fm_v_sqrt, fm_minv_vsqrt
898 TYPE(
cp_fm_type),
INTENT(INOUT) :: fm_w_freq_j
900 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_W_freq'
902 INTEGER :: handle, n_ri
905 CALL timeset(routinen, handle)
909 CALL cp_fm_create(fm_eps_freq_j, fm_chi_freq_j%matrix_struct)
917 fm_chi_freq_j, fm_minv_vsqrt, 0.0_dp, fm_work)
921 fm_minv_vsqrt, fm_work, 0.0_dp, fm_eps_freq_j)
934 CALL fm_invert(fm_eps_freq_j, bs_env%eps_eigval_mat_RI, bs_env%unit_nr)
946 CALL timestop(handle)
948 END SUBROUTINE compute_fm_w_freq
960 CHARACTER(LEN=*) :: mat_name
963 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_read'
965 CHARACTER(LEN=default_path_length) :: f_chi
966 INTEGER :: handle, unit_nr
968 CALL timeset(routinen, handle)
971 IF (bs_env%para_env%is_source())
THEN
974 WRITE (f_chi,
'(3A,I1,A)') trim(bs_env%prefix), trim(mat_name),
"_0",
idx,
".matrix"
975 ELSE IF (
idx < 100)
THEN
976 WRITE (f_chi,
'(3A,I2,A)') trim(bs_env%prefix), trim(mat_name),
"_",
idx,
".matrix"
978 cpabort(
'Please implement more than 99 time/frequency points.')
981 CALL open_file(file_name=trim(f_chi), file_action=
"READ", file_form=
"UNFORMATTED", &
982 file_position=
"REWIND", file_status=
"OLD", unit_number=unit_nr)
988 IF (bs_env%para_env%is_source())
CALL close_file(unit_number=unit_nr)
990 CALL timestop(handle)
1002 SUBROUTINE fm_write(fm, matrix_index, matrix_name, qs_env, matrix)
1004 INTEGER :: matrix_index
1005 CHARACTER(LEN=*) :: matrix_name
1007 TYPE(
dbcsr_type),
INTENT(IN),
OPTIONAL :: matrix
1009 CHARACTER(LEN=*),
PARAMETER :: key =
'PROPERTIES%BANDSTRUCTURE%GW%PRINT%RESTART', &
1010 routinen =
'fm_write'
1012 CHARACTER(LEN=default_path_length) :: filename
1013 INTEGER :: handle, unit_nr
1017 CALL timeset(routinen, handle)
1025 IF (
PRESENT(matrix))
THEN
1030 IF (matrix_index < 10)
THEN
1031 WRITE (filename,
'(3A,I1)')
"RESTART_", matrix_name,
"_0", matrix_index
1032 ELSE IF (matrix_index < 100)
THEN
1033 WRITE (filename,
'(3A,I2)')
"RESTART_", matrix_name,
"_", matrix_index
1035 cpabort(
'Please implement more than 99 time/frequency points.')
1039 file_form=
"UNFORMATTED", middle_name=trim(filename), &
1040 file_position=
"REWIND", file_action=
"WRITE")
1043 IF (unit_nr > 0)
THEN
1048 CALL timestop(handle)
1059 SUBROUTINE compute_fm_chi_gamma_freq(bs_env, fm_chi_Gamma_freq, j_w, mat_chi_Gamma_tau)
1063 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_chi_gamma_tau
1065 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_fm_chi_Gamma_freq'
1067 INTEGER :: handle, i_t
1068 REAL(kind=
dp) :: weight_ij
1070 CALL timeset(routinen, handle)
1072 CALL dbcsr_set(bs_env%mat_RI_RI%matrix, 0.0_dp)
1074 DO i_t = 1, bs_env%num_time_freq_points
1076 weight_ij = bs_env%time_frequency_grid%cosine_time_to_frequency(j_w, i_t)
1079 CALL dbcsr_add(bs_env%mat_RI_RI%matrix, mat_chi_gamma_tau(i_t)%matrix, &
1086 CALL timestop(handle)
1088 END SUBROUTINE compute_fm_chi_gamma_freq
1096 SUBROUTINE sum_w_mic_freq_zero(bs_env, fm_W_MIC_time)
1098 TYPE(
cp_fm_type),
DIMENSION(:) :: fm_w_mic_time
1100 CHARACTER(LEN=*),
PARAMETER :: routinen =
'sum_W_MIC_freq_zero'
1102 INTEGER :: handle, i_t
1103 REAL(kind=
dp) :: t_start
1105 CALL timeset(routinen, handle)
1108 CALL cp_fm_create(bs_env%fm_W_MIC_freq_zero, bs_env%fm_W_MIC_freq%matrix_struct)
1110 DO i_t = 1, bs_env%num_time_freq_points
1112 bs_env%time_frequency_grid%time_weights_at_zero_frequency(i_t), &
1115 IF (bs_env%unit_nr > 0)
THEN
1116 WRITE (bs_env%unit_nr,
'(T2,A,I11,A,I3,A,F10.1,A)') &
1117 'Computed W(ω=0,k) for k-point batch', &
1119 ', Execution time',
m_walltime() - t_start,
' s'
1122 CALL timestop(handle)
1124 END SUBROUTINE sum_w_mic_freq_zero
1131 SUBROUTINE create_fm_w_mic_time(bs_env, fm_W_MIC_time)
1133 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1135 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_fm_W_MIC_time'
1137 INTEGER :: handle, i_t
1139 CALL timeset(routinen, handle)
1141 ALLOCATE (fm_w_mic_time(bs_env%num_time_freq_points))
1142 DO i_t = 1, bs_env%num_time_freq_points
1143 CALL cp_fm_create(fm_w_mic_time(i_t), bs_env%fm_RI_RI%matrix_struct, set_zero=.true.)
1146 CALL timestop(handle)
1148 END SUBROUTINE create_fm_w_mic_time
1157 SUBROUTINE fourier_transform_w_to_t(bs_env, fm_W_MIC_time, fm_W_MIC_freq_j, j_w)
1159 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_w_mic_time
1163 CHARACTER(LEN=*),
PARAMETER :: routinen =
'Fourier_transform_w_to_t'
1165 INTEGER :: handle, i_t
1166 REAL(kind=
dp) :: weight_ij
1168 CALL timeset(routinen, handle)
1170 DO i_t = 1, bs_env%num_time_freq_points
1172 weight_ij = bs_env%time_frequency_grid%cosine_frequency_to_time(i_t, j_w)
1176 beta=weight_ij, matrix_b=fm_w_mic_freq_j)
1180 CALL timestop(handle)
1182 END SUBROUTINE fourier_transform_w_to_t
1192 SUBROUTINE get_v_tr_r(V_tr_R, pot_type, regularization_RI, bs_env, qs_env)
1193 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: v_tr_r
1194 TYPE(libint_potential_type) :: pot_type
1195 REAL(kind=
dp) :: regularization_ri
1199 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_V_tr_R'
1201 INTEGER :: handle, img, nimages_scf_desymm
1202 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: sizes_ri
1203 INTEGER,
DIMENSION(:),
POINTER :: col_bsize, row_bsize
1205 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: fm_v_tr_r
1207 TYPE(
dbcsr_type),
ALLOCATABLE,
DIMENSION(:) :: mat_v_tr_r
1212 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1214 CALL timeset(routinen, handle)
1216 NULLIFY (sab_ri, dist_2d)
1219 blacs_env=blacs_env, &
1220 distribution_2d=dist_2d, &
1221 qs_kind_set=qs_kind_set, &
1222 particle_set=particle_set)
1224 ALLOCATE (sizes_ri(bs_env%n_atom))
1225 CALL get_particle_set(particle_set, qs_kind_set, nsgf=sizes_ri, basis=bs_env%basis_set_RI)
1227 pot_type,
"2c_nl_RI", qs_env, sym_ij=.false., &
1230 ALLOCATE (row_bsize(
SIZE(sizes_ri)))
1231 ALLOCATE (col_bsize(
SIZE(sizes_ri)))
1232 row_bsize(:) = sizes_ri
1233 col_bsize(:) = sizes_ri
1235 nimages_scf_desymm = bs_env%nimages_scf_desymm
1236 ALLOCATE (mat_v_tr_r(nimages_scf_desymm))
1237 CALL dbcsr_create(mat_v_tr_r(1),
"(RI|RI)", dbcsr_dist, dbcsr_type_no_symmetry, &
1238 row_bsize, col_bsize)
1239 DEALLOCATE (row_bsize, col_bsize)
1241 DO img = 2, nimages_scf_desymm
1242 CALL dbcsr_create(mat_v_tr_r(img), template=mat_v_tr_r(1))
1246 bs_env%basis_set_RI, pot_type, do_kpoints=.true., &
1247 ext_kpoints=bs_env%kpoints_scf_desymm, &
1248 regularization_ri=regularization_ri)
1250 ALLOCATE (fm_v_tr_r(nimages_scf_desymm))
1251 DO img = 1, nimages_scf_desymm
1252 CALL cp_fm_create(fm_v_tr_r(img), bs_env%fm_RI_RI%matrix_struct)
1257 IF (.NOT.
ALLOCATED(v_tr_r))
THEN
1258 ALLOCATE (v_tr_r(bs_env%n_RI, bs_env%n_RI, nimages_scf_desymm))
1267 CALL timestop(handle)
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.
constants for the different operators of the 2c-integrals
integer, parameter, public operator_coulomb
methods related to the blacs parallel environment
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_uplo_to_full(matrix, workspace, uplo)
...
subroutine, public cp_cfm_add_on_diag(matrix, alpha, n_active)
Adds a scalar to the diagonal of a distributed complex full matrix.
various cholesky decomposition related routines
subroutine, public cp_cfm_cholesky_decompose(matrix, n, info_out)
Used to replace a symmetric positive definite matrix M with its Cholesky decomposition U: M = U^T * U...
subroutine, public cp_cfm_cholesky_invert(matrix, n, info_out)
Used to replace Cholesky decomposition by the inverse.
used for collecting diagonalization schemes available for cp_cfm_type
subroutine, public cp_cfm_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
Raise the positive spectral part of a Hermitian matrix to a real power. Eigenmodes with eigenvalues b...
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, matrix_struct, para_env)
Returns information about a full matrix.
subroutine, public dbcsr_distribution_release(dist)
...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_reserve_all_blocks(matrix)
Reserves all blocks.
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan, check_plan)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_dbcsr_dist2d_to_dist(dist2d, dist)
Creates a DBCSR distribution from a distribution_2d.
Utility routines to open and close files.
subroutine, public open_file(file_name, unit_number, file_status, file_form, file_action, file_position, file_pad, file_access, debug)
Opens a file and returns its logical unit number.
subroutine, public close_file(unit_number, file_status)
Closes an open file given by its logical unit number.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_add_on_diag(matrix, alpha, n_active)
Adds a scalar to the diagonal of a distributed real full matrix.
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....
subroutine, public cp_fm_uplo_to_full(matrix, work, uplo)
given a triangular matrix according to uplo, computes the corresponding full matrix
Redistribution of full matrices and distributed arrays.
subroutine, public cp_fm_to_replicated_array(fm_s, array_s, weight, add)
...
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_write_unformatted(fm, unit)
...
subroutine, public cp_fm_read_unformatted(fm, unit)
...
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
stores a mapping of 2D info (e.g. matrix) on a 2D processor distribution (i.e. blacs grid) where cpus...
Coulomb matrices and screened interactions for imaginary-time GW.
subroutine, public fm_write(fm, matrix_index, matrix_name, qs_env, matrix)
Write a GW restart matrix when requested by the print key.
subroutine, public compute_minvvsqrt_vsqrt(bs_env, qs_env, cfm_v_kp, cfm_v_sqrt_ikp, cfm_m_inv_v_sqrt_ikp, ikp)
...
subroutine, public get_w_mic(bs_env, qs_env, mat_chi_gamma_tau, fm_w_mic_time)
...
subroutine, public compute_fm_w_mic_freq_j_from_chi(bs_env, qs_env, fm_w_mic_freq_j, j_w, ikp, cfm_m_inv_v_sqrt_ikp, cfm_v_sqrt_ikp)
W_PQ^MIC(iω_j) from χ_PQ(iω_j,k=0) in bs_envfm_chi_Gamma_freq.
subroutine, public fm_read(fm, bs_env, mat_name, idx)
...
subroutine, public get_v_tr_r(v_tr_r, pot_type, regularization_ri, bs_env, qs_env)
...
subroutine, public compute_v_k_by_lattice_sum(bs_env, qs_env, cfm_v_kp, ikp_batch)
...
subroutine, public compute_w(bs_env, qs_env, mat_chi_gamma_tau, fm_w_time)
Computes the screened Coulomb interaction on the imaginary-time grid, entirely in the RI auxiliary (P...
subroutine, public apply_extrapol_factor(bs_env, fm_w_mic_time)
...
Full-matrix operations not provided by the CP2K FM packages.
subroutine, public fm_invert(matrix_a, eigenvalue_threshold, unit_nr)
Inverts a symmetric matrix. First, Cholesky decomposition is tried. If it fails, the matrix is diagon...
subroutine, public fm_sqrt(matrix_a, matrix_b, eigenvalue_threshold, unit_nr)
For input A, computes B such that B^T B=A. First, Cholesky decomposition is tried....
subroutine, public cfm_contract_aba(matrix_a, matrix_b, matrix_c, workspace)
Computes A^H B A for complex full matrices.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
Routines to compute the Coulomb integral V_(alpha beta)(k) for a k-point k using lattice summation in...
subroutine, public build_2c_coulomb_matrix_kp(matrix_v_kp, kpoints, basis_type, cell, particle_set, qs_kind_set, atomic_kind_set, size_lattice_sum, operator_type, ikp_start, ikp_end)
...
2- and 3-center electron repulsion integral routines based on libint2 Currently available operators: ...
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 z_zero
Framework for 2c-integrals for RI.
subroutine, public ri_2c_integral_mat_kp(qs_env, cfm_matrix_m_kpoints, fm_matrix_struct, dimen_ri, ri_metric, kpoints, put_mat_ks_env, regularization_ri, ikp_ext, do_build_cell_index)
Computes the complex k-point RI metric as native CFM matrices.
basic linear algebra operations for full matrixes
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis, ncgf)
Get the components of a particle set.
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)
Reconstruct a k-point operator from a real Gamma matrix using one MIC phase.
subroutine, public mic_contribution_from_ikp(bs_env, qs_env, fm_w_mic_freq_j, cfm_w_ikp_freq_j, ikp, kpoints, basis_type, wkp_ext)
...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
Define the neighbor list data types and the corresponding functionality.
subroutine, public release_neighbor_list_sets(nlists)
releases an array of neighbor_list_sets
Utility methods to build 3-center integral tensors of various types.
subroutine, public build_2c_integrals(t2c, filter_eps, qs_env, nl_2c, basis_i, basis_j, potential_parameter, do_kpoints, do_hfx_kpoints, ext_kpoints, regularization_ri)
...
subroutine, public build_2c_neighbor_lists(ij_list, basis_i, basis_j, potential_parameter, name, qs_env, sym_ij, molecular, dist_2d, pot_to_rad)
Build 2-center neighborlists adapted to different operators This mainly wraps build_neighbor_lists fo...
Routines treating GW and RPA calculations with kpoints.
subroutine, public cfm_screened_interaction_from_eps_cholesky(eps_chol, b, wc, n_active)
Form the screened interaction from a Cholesky-factorized dielectric matrix.
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
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...
distributes pairs on a 2d grid of processors
Provides all information about a quickstep kind.