81#include "./base/base_uses.f90"
87 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rpa_gw_kpoints_util'
125 Erpa, grid, wkp_W, do_gw_im_time, &
126 do_ri_Sigma_x, do_kpoints_from_Gamma, &
127 cfm_mat_Q, ikp_local, mat_P_omega, mat_P_omega_kp, &
128 qs_env, eps_filter_im_time, unit_nr, kpoints, fm_mat_Minv_L_kpoints, &
129 fm_matrix_L_kpoints, fm_mat_W, &
130 fm_mat_RI_global_work, mat_MinvVMinv, fm_matrix_Minv, &
131 fm_matrix_Minv_Vtrunc_Minv)
133 INTEGER,
INTENT(IN) :: dimen_ri, jquad, nkp, count_ev_sc_gw
135 REAL(kind=
dp),
INTENT(INOUT) :: erpa
137 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wkp_w
138 LOGICAL,
INTENT(IN) :: do_gw_im_time, do_ri_sigma_x, &
139 do_kpoints_from_gamma
141 INTEGER,
INTENT(IN) :: ikp_local
142 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
INTENT(INOUT) :: mat_p_omega, mat_p_omega_kp
144 REAL(kind=
dp),
INTENT(IN) :: eps_filter_im_time
145 INTEGER,
INTENT(IN) :: unit_nr
147 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_mat_minv_l_kpoints, &
149 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: fm_mat_w
152 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_matrix_minv, &
153 fm_matrix_minv_vtrunc_minv
155 CHARACTER(LEN=*),
PARAMETER :: routinen =
'invert_eps_compute_W_and_Erpa_kp'
157 INTEGER :: handle, ikp, num_integ_points
158 LOGICAL :: do_this_ikp
159 REAL(kind=
dp) :: t1, t2
160 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: trace_qomega
162 CALL timeset(routinen, handle)
164 num_integ_points =
SIZE(grid%frequency)
168 IF (do_kpoints_from_gamma)
THEN
172 CALL transform_p_from_real_space_to_kpoints(mat_p_omega, mat_p_omega_kp, &
173 kpoints, eps_filter_im_time, jquad)
175 ALLOCATE (trace_qomega(dimen_ri))
177 IF (unit_nr > 0)
WRITE (unit_nr,
'(/T3,A,1X,I3)') &
178 'GW_INFO| Computing chi and W frequency point', jquad
183 do_this_ikp = (ikp_local == -1) .OR. (ikp_local == 0 .AND. ikp == 1) .OR. (ikp_local == ikp)
184 IF (.NOT. do_this_ikp) cycle
187 CALL compute_q_kp_rpa(cfm_mat_q, &
189 fm_mat_minv_l_kpoints(ikp, 1), &
190 fm_mat_minv_l_kpoints(ikp, 2), &
191 fm_mat_ri_global_work, &
192 dimen_ri, ikp, nkp, ikp_local, para_env, &
193 qs_env%mp2_env%ri_rpa_im_time%make_chi_pos_definite)
196 CALL cholesky_decomp_q(cfm_mat_q, para_env, trace_qomega, dimen_ri)
199 CALL frequency_and_kpoint_integration(erpa, cfm_mat_q, para_env, trace_qomega, &
200 dimen_ri, grid%frequency_weights(jquad), kpoints%wkp(ikp))
202 IF (do_gw_im_time)
THEN
205 IF (do_ri_sigma_x .AND. jquad == 1 .AND. count_ev_sc_gw == 1 .AND. do_kpoints_from_gamma)
THEN
207 CALL dbcsr_set(mat_minvvminv%matrix, 0.0_dp)
208 CALL copy_fm_to_dbcsr(fm_matrix_minv_vtrunc_minv(1, 1), mat_minvvminv%matrix, keep_sparsity=.false.)
211 IF (do_kpoints_from_gamma)
THEN
212 CALL compute_wc_real_space_tau_gw(fm_mat_w, cfm_mat_q, &
213 fm_matrix_l_kpoints(ikp, 1), &
214 fm_matrix_l_kpoints(ikp, 2), &
217 ikp_local, para_env, kpoints, qs_env, wkp_w)
224 IF (do_gw_im_time .AND. do_kpoints_from_gamma .AND. jquad == num_integ_points)
THEN
225 CALL wc_to_minv_wc_minv(fm_mat_w, fm_matrix_minv, para_env, dimen_ri, num_integ_points)
226 CALL deallocate_kp_matrices(fm_matrix_l_kpoints, fm_mat_minv_l_kpoints)
229 DEALLOCATE (trace_qomega)
233 IF (unit_nr > 0)
WRITE (unit_nr,
'(T6,A,T56,F25.1)')
'Execution time (s):', t2 - t1
235 CALL timestop(handle)
244 SUBROUTINE deallocate_kp_matrices(fm_matrix_L_kpoints, fm_mat_Minv_L_kpoints)
246 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: fm_matrix_l_kpoints, &
247 fm_mat_minv_l_kpoints
249 CHARACTER(LEN=*),
PARAMETER :: routinen =
'deallocate_kp_matrices'
253 CALL timeset(routinen, handle)
258 CALL timestop(handle)
260 END SUBROUTINE deallocate_kp_matrices
271 REAL(kind=
dp) :: threshold, exponent
272 REAL(kind=
dp),
OPTIONAL :: min_eigval
274 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_cfm_power'
276 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues_exponent
277 INTEGER :: handle, i, ncol_global, nrow_global
278 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
281 CALL timeset(routinen, handle)
287 CALL cp_cfm_get_info(matrix, nrow_global=nrow_global, ncol_global=ncol_global)
288 cpassert(nrow_global == ncol_global)
289 ALLOCATE (eigenvalues(nrow_global), source=0.0_dp)
290 ALLOCATE (eigenvalues_exponent(nrow_global), source=
z_zero)
295 DO i = 1, nrow_global
296 IF (eigenvalues(i) > threshold)
THEN
297 eigenvalues_exponent(i) = cmplx((eigenvalues(i))**(0.5_dp*exponent), threshold, kind=
dp)
299 IF (
PRESENT(min_eigval))
THEN
300 eigenvalues_exponent(i) = cmplx(min_eigval, 0.0_dp, kind=
dp)
302 eigenvalues_exponent(i) =
z_zero
310 cfm_work, cfm_work,
z_zero, matrix)
312 DEALLOCATE (eigenvalues, eigenvalues_exponent)
316 CALL timestop(handle)
334 SUBROUTINE compute_q_kp_rpa(cfm_mat_Q, mat_P_omega_kp, fm_mat_L_re, fm_mat_L_im, &
335 fm_mat_RI_global_work, dimen_RI, ikp, nkp, ikp_local, para_env, &
336 make_chi_pos_definite)
339 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
INTENT(INOUT) :: mat_p_omega_kp
340 TYPE(
cp_fm_type) :: fm_mat_l_re, fm_mat_l_im, &
341 fm_mat_ri_global_work
342 INTEGER,
INTENT(IN) :: dimen_ri, ikp, nkp, ikp_local
344 LOGICAL,
INTENT(IN) :: make_chi_pos_definite
346 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Q_kp_RPA'
352 CALL timeset(routinen, handle)
360 CALL cp_fm_create(fm_mat_work, fm_mat_l_re%matrix_struct)
365 CALL mat_p_to_subgroup(mat_p_omega_kp, fm_mat_ri_global_work, &
366 fm_mat_work, cfm_mat_q, ikp, nkp, ikp_local, para_env)
369 IF (make_chi_pos_definite)
THEN
370 CALL cp_cfm_power(cfm_mat_q, threshold=0.0_dp, exponent=1.0_dp)
378 CALL parallel_gemm(
'N',
'N', dimen_ri, dimen_ri, dimen_ri,
z_one, cfm_mat_q, cfm_mat_l, &
382 CALL parallel_gemm(
'C',
'N', dimen_ri, dimen_ri, dimen_ri,
z_one, cfm_mat_l, cfm_mat_work, &
389 CALL timestop(handle)
391 END SUBROUTINE compute_q_kp_rpa
404 SUBROUTINE mat_p_to_subgroup(mat_P_omega_kp, fm_mat_RI_global_work, &
405 fm_mat_work, cfm_mat_Q, ikp, nkp, ikp_local, para_env)
407 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
INTENT(INOUT) :: mat_p_omega_kp
408 TYPE(
cp_fm_type),
INTENT(INOUT) :: fm_mat_ri_global_work, fm_mat_work
410 INTEGER,
INTENT(IN) :: ikp, nkp, ikp_local
413 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mat_P_to_subgroup'
415 INTEGER :: handle, jkp
417 TYPE(
dbcsr_type),
POINTER :: mat_p_omega_im, mat_p_omega_re
419 CALL timeset(routinen, handle)
421 IF (ikp_local == -1)
THEN
423 mat_p_omega_re => mat_p_omega_kp(1, ikp)%matrix
428 mat_p_omega_im => mat_p_omega_kp(2, ikp)%matrix
439 mat_p_omega_re => mat_p_omega_kp(1, jkp)%matrix
446 IF (ikp_local == jkp)
THEN
462 mat_p_omega_im => mat_p_omega_kp(2, jkp)%matrix
469 IF (ikp_local == jkp)
THEN
487 CALL timestop(handle)
489 END SUBROUTINE mat_p_to_subgroup
498 SUBROUTINE cholesky_decomp_q(cfm_mat_Q, para_env, trace_Qomega, dimen_RI)
502 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: trace_qomega
503 INTEGER,
INTENT(IN) :: dimen_ri
505 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cholesky_decomp_Q'
507 INTEGER :: handle, i_global, iib, info_chol, &
508 j_global, jjb, ncol_local, nrow_local
509 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
512 CALL timeset(routinen, handle)
522 nrow_local=nrow_local, &
523 ncol_local=ncol_local, &
524 row_indices=row_indices, &
525 col_indices=col_indices)
528 trace_qomega = 0.0_dp
531 DO jjb = 1, ncol_local
532 j_global = col_indices(jjb)
533 DO iib = 1, nrow_local
534 i_global = row_indices(iib)
535 IF (j_global == i_global .AND. i_global <= dimen_ri)
THEN
536 trace_qomega(i_global) = real(cfm_mat_q%local_data(iib, jjb))
537 cfm_mat_q%local_data(iib, jjb) = cfm_mat_q%local_data(iib, jjb) +
z_one
541 CALL para_env%sum(trace_qomega)
547 cpassert(info_chol == 0)
552 CALL timestop(handle)
554 END SUBROUTINE cholesky_decomp_q
566 SUBROUTINE frequency_and_kpoint_integration(Erpa, cfm_mat_Q, para_env, trace_Qomega, &
567 dimen_RI, freq_weight, kp_weight)
569 REAL(kind=
dp),
INTENT(INOUT) :: erpa
572 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: trace_qomega
573 INTEGER,
INTENT(IN) :: dimen_ri
574 REAL(kind=
dp),
INTENT(IN) :: freq_weight, kp_weight
576 CHARACTER(LEN=*),
PARAMETER :: routinen =
'frequency_and_kpoint_integration'
578 INTEGER :: handle, i_global, iib, j_global, jjb, &
579 ncol_local, nrow_local
580 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
581 REAL(kind=
dp) :: fcomega
582 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: q_log
584 CALL timeset(routinen, handle)
588 nrow_local=nrow_local, &
589 ncol_local=ncol_local, &
590 row_indices=row_indices, &
591 col_indices=col_indices)
593 ALLOCATE (q_log(dimen_ri))
597 DO jjb = 1, ncol_local
598 j_global = col_indices(jjb)
599 DO iib = 1, nrow_local
600 i_global = row_indices(iib)
601 IF (j_global == i_global .AND. i_global <= dimen_ri)
THEN
602 q_log(i_global) = 2.0_dp*log(real(cfm_mat_q%local_data(iib, jjb)))
606 CALL para_env%sum(q_log)
610 IF (
modulo(iib, para_env%num_pe) /= para_env%mepos) cycle
612 fcomega = fcomega + (q_log(iib) - trace_qomega(iib))/2.0_dp
615 erpa = erpa + fcomega*freq_weight*kp_weight
619 CALL timestop(handle)
621 END SUBROUTINE frequency_and_kpoint_integration
632 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(IN) :: mat_p_omega
635 INTEGER,
INTENT(IN) :: jquad, unit_nr
637 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_mat_cell_T_from_mat_gamma'
639 INTEGER :: col, handle, i_cell, i_dim, j_cell, &
640 num_cells_p, num_integ_points, row
641 INTEGER,
DIMENSION(3) :: cell_grid_p, periodic
642 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell_p
643 LOGICAL :: i_cell_is_the_minimum_image_cell
644 REAL(kind=
dp) :: abs_rab_cell_i, abs_rab_cell_j
645 REAL(kind=
dp),
DIMENSION(3) :: cell_vector, cell_vector_j, rab_cell_i, &
647 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
648 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: data_block
653 CALL timeset(routinen, handle)
655 NULLIFY (cell, particle_set)
657 particle_set=particle_set)
658 CALL get_cell(cell=cell, h=hmat, periodic=periodic)
663 IF (periodic(i_dim) == 1)
THEN
664 cell_grid_p(i_dim) = max(min((kpoints%nkp_grid(i_dim)/2)*2 - 1, 1), 3)
666 cell_grid_p(i_dim) = 1
673 index_to_cell_p => kpoints%index_to_cell
675 num_cells_p =
SIZE(index_to_cell_p, 2)
677 num_integ_points =
SIZE(mat_p_omega, 1)
681 DO i_cell = 2, num_cells_p
683 mat_p_omega(1)%matrix)
686 IF (jquad == 1 .AND. unit_nr > 0)
THEN
687 WRITE (unit_nr,
'(T3,A,T66,ES15.2)')
'GW_INFO| RI regularization parameter: ', &
688 qs_env%mp2_env%ri_rpa_im_time%regularization_RI
689 WRITE (unit_nr,
'(T3,A,T66,ES15.2)')
'GW_INFO| eps_eigval_S: ', &
690 qs_env%mp2_env%ri_rpa_im_time%eps_eigval_S
691 IF (qs_env%mp2_env%ri_rpa_im_time%make_chi_pos_definite)
THEN
692 WRITE (unit_nr,
'(T3,A,T81)') &
693 'GW_INFO| Make chi(iw,k) positive definite? TRUE'
695 WRITE (unit_nr,
'(T3,A,T81)') &
696 'GW_INFO| Make chi(iw,k) positive definite? FALSE'
701 DO i_cell = 1, num_cells_p
707 cell_vector(1:3) = matmul(hmat, real(index_to_cell_p(1:3, i_cell),
dp))
708 rab_cell_i(1:3) =
pbc(particle_set(row)%r(1:3), cell) - &
709 (
pbc(particle_set(col)%r(1:3), cell) + cell_vector(1:3))
710 abs_rab_cell_i = sqrt(rab_cell_i(1)**2 + rab_cell_i(2)**2 + rab_cell_i(3)**2)
713 i_cell_is_the_minimum_image_cell = .true.
714 DO j_cell = 1, num_cells_p
715 cell_vector_j(1:3) = matmul(hmat, real(index_to_cell_p(1:3, j_cell),
dp))
716 rab_cell_j(1:3) =
pbc(particle_set(row)%r(1:3), cell) - &
717 (
pbc(particle_set(col)%r(1:3), cell) + cell_vector_j(1:3))
718 abs_rab_cell_j = sqrt(rab_cell_j(1)**2 + rab_cell_j(2)**2 + rab_cell_j(3)**2)
720 IF (abs_rab_cell_i > abs_rab_cell_j + 1.0e-6_dp)
THEN
721 i_cell_is_the_minimum_image_cell = .false.
725 IF (.NOT. i_cell_is_the_minimum_image_cell)
THEN
726 data_block(:, :) = data_block(:, :)*0.0_dp
734 CALL timestop(handle)
746 SUBROUTINE transform_p_from_real_space_to_kpoints(mat_P_omega, mat_P_omega_kp, &
747 kpoints, eps_filter_im_time, jquad)
749 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
INTENT(INOUT) :: mat_p_omega, mat_p_omega_kp
751 REAL(kind=
dp),
INTENT(IN) :: eps_filter_im_time
752 INTEGER,
INTENT(IN) :: jquad
754 CHARACTER(LEN=*),
PARAMETER :: routinen =
'transform_P_from_real_space_to_kpoints'
756 INTEGER :: handle, icell, nkp, num_integ_points
758 CALL timeset(routinen, handle)
760 num_integ_points =
SIZE(mat_p_omega, 1)
761 nkp =
SIZE(mat_p_omega, 2)
764 kpoints, eps_filter_im_time)
766 DO icell = 1,
SIZE(mat_p_omega, 2)
767 CALL dbcsr_set(mat_p_omega(jquad, icell)%matrix, 0.0_dp)
768 CALL dbcsr_filter(mat_p_omega(jquad, icell)%matrix, 1.0_dp)
771 CALL timestop(handle)
773 END SUBROUTINE transform_p_from_real_space_to_kpoints
785 kpoints, eps_filter_im_time, real_mat_real_space)
787 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT) :: real_mat_kp, imag_mat_kp, mat_real_space
789 REAL(kind=
dp),
INTENT(IN) :: eps_filter_im_time
790 LOGICAL,
INTENT(IN),
OPTIONAL :: real_mat_real_space
792 CHARACTER(LEN=*),
PARAMETER :: routinen =
'real_space_to_kpoint_transform_rpa'
794 INTEGER :: handle, i_cell, ik, nkp, num_cells
795 INTEGER,
DIMENSION(3) :: cell
796 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
797 LOGICAL :: my_real_mat_real_space
798 REAL(kind=
dp) :: arg, coskl, sinkl
799 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
802 CALL timeset(routinen, handle)
804 my_real_mat_real_space = .true.
805 IF (
PRESENT(real_mat_real_space)) my_real_mat_real_space = real_mat_real_space
808 template=real_mat_kp(1)%matrix, &
809 matrix_type=dbcsr_type_no_symmetry)
816 NULLIFY (index_to_cell)
817 index_to_cell => kpoints%index_to_cell
819 num_cells =
SIZE(index_to_cell, 2)
821 cpassert(
SIZE(mat_real_space) >= num_cells/2 + 1)
828 CALL dbcsr_set(real_mat_kp(ik)%matrix, 0.0_dp)
829 CALL dbcsr_set(imag_mat_kp(ik)%matrix, 0.0_dp)
831 DO i_cell = 1, num_cells/2 + 1
833 cell(:) = index_to_cell(:, i_cell)
835 arg = real(cell(1),
dp)*xkp(1, ik) + real(cell(2),
dp)*xkp(2, ik) + real(cell(3),
dp)*xkp(3, ik)
836 coskl = cos(
twopi*arg)
837 sinkl = sin(
twopi*arg)
839 IF (my_real_mat_real_space)
THEN
840 CALL dbcsr_add_local(real_mat_kp(ik)%matrix, mat_real_space(i_cell)%matrix, 1.0_dp, coskl)
841 CALL dbcsr_add_local(imag_mat_kp(ik)%matrix, mat_real_space(i_cell)%matrix, 1.0_dp, sinkl)
843 CALL dbcsr_add_local(real_mat_kp(ik)%matrix, mat_real_space(i_cell)%matrix, 1.0_dp, -sinkl)
844 CALL dbcsr_add_local(imag_mat_kp(ik)%matrix, mat_real_space(i_cell)%matrix, 1.0_dp, coskl)
847 IF (.NOT. (cell(1) == 0 .AND. cell(2) == 0 .AND. cell(3) == 0))
THEN
851 IF (my_real_mat_real_space)
THEN
852 CALL dbcsr_add_local(real_mat_kp(ik)%matrix, mat_work, 1.0_dp, coskl)
853 CALL dbcsr_add_local(imag_mat_kp(ik)%matrix, mat_work, 1.0_dp, -sinkl)
858 CALL dbcsr_add_local(real_mat_kp(ik)%matrix, mat_work, 1.0_dp, -sinkl)
859 CALL dbcsr_add_local(imag_mat_kp(ik)%matrix, mat_work, 1.0_dp, -coskl)
868 CALL dbcsr_filter(real_mat_kp(ik)%matrix, eps_filter_im_time)
869 CALL dbcsr_filter(imag_mat_kp(ik)%matrix, eps_filter_im_time)
875 CALL timestop(handle)
886 SUBROUTINE dbcsr_add_local(mat_a, mat_b, alpha, beta)
887 TYPE(
dbcsr_type),
INTENT(INOUT) :: mat_a, mat_b
888 REAL(kind=
dp),
INTENT(IN) :: alpha, beta
892 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: block_to_compute, data_block
899 NULLIFY (block_to_compute)
901 row=row, col=col, block=block_to_compute, found=found)
905 block_to_compute(:, :) = alpha*block_to_compute(:, :) + beta*data_block(:, :)
910 END SUBROUTINE dbcsr_add_local
928 SUBROUTINE compute_wc_real_space_tau_gw(fm_mat_W_tau, cfm_mat_Q, fm_mat_L_re, fm_mat_L_im, &
930 ikp, grid, ikp_local, &
931 para_env, kpoints, qs_env, wkp_W)
933 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: fm_mat_w_tau
935 TYPE(
cp_fm_type),
INTENT(IN) :: fm_mat_l_re, fm_mat_l_im
936 INTEGER,
INTENT(IN) :: dimen_ri, jquad, ikp
938 INTEGER,
INTENT(IN) :: ikp_local
942 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: wkp_w
944 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_Wc_real_space_tau_GW'
946 INTEGER :: handle, handle2, i_global, iatom, iatom_old, iib, iquad, irow, j_global, jatom, &
947 jatom_old, jcol, jjb, jkp, ncol_local, nkp, nrow_local, num_cells, num_integ_points
948 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_from_ri_index
949 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
950 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
951 REAL(kind=
dp) :: contribution, omega, tau, weight, &
953 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
954 REAL(kind=
dp),
DIMENSION(:),
POINTER :: wkp
955 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
957 TYPE(
cp_cfm_type) :: cfm_mat_l, cfm_mat_work, cfm_mat_work_2
958 TYPE(
cp_fm_type) :: fm_dummy, fm_mat_work_global, &
962 CALL timeset(routinen, handle)
964 num_integ_points =
SIZE(grid%imaginary_time)
966 CALL timeset(routinen//
"_1", handle2)
981 CALL cp_fm_create(fm_mat_work_global, fm_mat_w_tau(1)%matrix_struct)
984 CALL cp_fm_create(fm_mat_work_local, cfm_mat_q%matrix_struct)
987 CALL timestop(handle2)
989 CALL timeset(routinen//
"_2", handle2)
999 nrow_local=nrow_local, &
1000 ncol_local=ncol_local, &
1001 row_indices=row_indices, &
1002 col_indices=col_indices)
1004 DO jjb = 1, ncol_local
1005 j_global = col_indices(jjb)
1006 DO iib = 1, nrow_local
1007 i_global = row_indices(iib)
1008 IF (j_global == i_global .AND. i_global <= dimen_ri)
THEN
1009 cfm_mat_q%local_data(iib, jjb) = cfm_mat_q%local_data(iib, jjb) -
z_one
1014 CALL timestop(handle2)
1016 CALL timeset(routinen//
"_3", handle2)
1019 CALL parallel_gemm(
'N',
'N', dimen_ri, dimen_ri, dimen_ri,
z_one, cfm_mat_q, cfm_mat_l, &
1023 CALL parallel_gemm(
'N',
'N', dimen_ri, dimen_ri, dimen_ri,
z_one, cfm_mat_l, cfm_mat_work, &
1026 CALL timestop(handle2)
1028 CALL timeset(routinen//
"_4", handle2)
1031 index_to_cell => kpoints%index_to_cell
1032 num_cells =
SIZE(index_to_cell, 2)
1036 ALLOCATE (atom_from_ri_index(dimen_ri))
1040 NULLIFY (cell, particle_set)
1041 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
1047 nrow_local=nrow_local, &
1048 ncol_local=ncol_local, &
1049 row_indices=row_indices, &
1050 col_indices=col_indices)
1052 DO irow = 1, nrow_local
1053 DO jcol = 1, ncol_local
1055 iatom = atom_from_ri_index(row_indices(irow))
1056 jatom = atom_from_ri_index(col_indices(jcol))
1058 IF (iatom /= iatom_old .OR. jatom /= jatom_old)
THEN
1062 num_cells, iatom, jatom, xkp(1:3, ikp), wkp_w(ikp), &
1063 cell, index_to_cell, hmat, particle_set)
1070 contribution = weight_re*real(cfm_mat_work_2%local_data(irow, jcol)) + &
1071 weight_im*aimag(cfm_mat_work_2%local_data(irow, jcol))
1073 fm_mat_work_local%local_data(irow, jcol) = fm_mat_work_local%local_data(irow, jcol) + contribution
1078 CALL timestop(handle2)
1080 CALL timeset(routinen//
"_5", handle2)
1082 IF (ikp_local == -1)
THEN
1086 DO iquad = 1, num_integ_points
1088 omega = grid%frequency(jquad)
1089 tau = grid%imaginary_time(iquad)
1090 weight = grid%cosine_frequency_to_time_weights(iquad, jquad)*cos(tau*omega)
1092 IF (jquad == 1 .AND. ikp == 1)
THEN
1093 CALL cp_fm_set_all(matrix=fm_mat_w_tau(iquad), alpha=0.0_dp)
1096 CALL cp_fm_scale_and_add(alpha=1.0_dp, matrix_a=fm_mat_w_tau(iquad), beta=weight, matrix_b=fm_mat_work_global)
1104 CALL para_env%sync()
1106 IF (ikp_local == jkp)
THEN
1112 CALL para_env%sync()
1114 DO iquad = 1, num_integ_points
1116 omega = grid%frequency(jquad)
1117 tau = grid%imaginary_time(iquad)
1118 weight = grid%cosine_frequency_to_time_weights(iquad, jquad)*cos(tau*omega)
1120 IF (jquad == 1 .AND. jkp == 1)
THEN
1121 CALL cp_fm_set_all(matrix=fm_mat_w_tau(iquad), alpha=0.0_dp)
1125 matrix_b=fm_mat_work_global)
1139 DEALLOCATE (atom_from_ri_index)
1141 CALL timestop(handle2)
1143 CALL timestop(handle)
1145 END SUBROUTINE compute_wc_real_space_tau_gw
1155 SUBROUTINE wc_to_minv_wc_minv(fm_mat_W, fm_matrix_Minv, para_env, dimen_RI, num_integ_points)
1157 TYPE(
cp_fm_type),
DIMENSION(:, :) :: fm_matrix_minv
1159 INTEGER :: dimen_ri, num_integ_points
1161 CHARACTER(LEN=*),
PARAMETER :: routinen =
'Wc_to_Minv_Wc_Minv'
1163 INTEGER :: handle, jquad
1164 TYPE(
cp_fm_type) :: fm_work_minv, fm_work_minv_w
1166 CALL timeset(routinen, handle)
1168 CALL cp_fm_create(fm_work_minv, fm_mat_w(1)%matrix_struct)
1171 CALL cp_fm_create(fm_work_minv_w, fm_mat_w(1)%matrix_struct)
1173 DO jquad = 1, num_integ_points
1175 CALL parallel_gemm(
'N',
'N', dimen_ri, dimen_ri, dimen_ri, 1.0_dp, fm_work_minv, fm_mat_w(jquad), &
1176 0.0_dp, fm_work_minv_w)
1177 CALL parallel_gemm(
'N',
'N', dimen_ri, dimen_ri, dimen_ri, 1.0_dp, fm_work_minv_w, fm_work_minv, &
1178 0.0_dp, fm_mat_w(jquad))
1186 CALL timestop(handle)
1188 END SUBROUTINE wc_to_minv_wc_minv
1202 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:), &
1203 INTENT(OUT) :: wkp_w, wkp_v
1205 REAL(kind=
dp),
DIMENSION(3, 3) :: h_inv
1206 INTEGER,
DIMENSION(3) :: periodic
1208 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_wkp_W'
1210 INTEGER :: handle, i_x, ikp, info, j_y, k_z, &
1211 kpoint_weights_w_method, n_x, n_y, &
1212 n_z, nkp, nsuperfine, num_lin_eqs
1213 REAL(kind=
dp) :: exp_kpoints, integral, k_sq, weight
1214 REAL(kind=
dp),
DIMENSION(3) :: k_vec, x_vec
1215 REAL(kind=
dp),
DIMENSION(:),
POINTER :: right_side, wkp, wkp_tmp
1216 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: matrix_lin_eqs, xkp
1218 CALL timeset(routinen, handle)
1220 kpoint_weights_w_method = qs_env%mp2_env%ri_rpa_im_time%kpoint_weights_W_method
1234 ALLOCATE (wkp_v(nkp), wkp_w(nkp))
1238 IF (
ALLOCATED(qs_env%mp2_env%ri_rpa_im_time%wkp_V))
THEN
1239 wkp_v(:) = qs_env%mp2_env%ri_rpa_im_time%wkp_V(:)
1253 exp_kpoints = qs_env%mp2_env%ri_rpa_im_time%exp_tailored_weights
1257 IF (sum(periodic) == 2) exp_kpoints = -1.0_dp
1264 IF (periodic(1) == 1)
THEN
1269 IF (periodic(2) == 1)
THEN
1274 IF (periodic(3) == 1)
THEN
1282 weight = 1.0_dp/(real(n_x,
dp)*real(n_y,
dp)*real(n_z,
dp))
1287 IF (periodic(1) == 1)
THEN
1288 x_vec(1) = (real(i_x - nsuperfine/2,
dp) - 0.5_dp)/real(nsuperfine,
dp)
1292 IF (periodic(2) == 1)
THEN
1293 x_vec(2) = (real(j_y - nsuperfine/2,
dp) - 0.5_dp)/real(nsuperfine,
dp)
1297 IF (periodic(3) == 1)
THEN
1298 x_vec(3) = (real(k_z - nsuperfine/2,
dp) - 0.5_dp)/real(nsuperfine,
dp)
1303 k_vec = matmul(h_inv(1:3, 1:3), x_vec)
1304 k_sq = k_vec(1)**2 + k_vec(2)**2 + k_vec(3)**2
1305 integral = integral + weight*k_sq**(exp_kpoints*0.5_dp)
1311 num_lin_eqs = nkp + 2
1313 ALLOCATE (matrix_lin_eqs(num_lin_eqs, num_lin_eqs))
1314 matrix_lin_eqs(:, :) = 0.0_dp
1318 k_vec = matmul(h_inv(1:3, 1:3), xkp(1:3, ikp))
1319 k_sq = k_vec(1)**2 + k_vec(2)**2 + k_vec(3)**2
1321 matrix_lin_eqs(ikp, ikp) = 2.0_dp
1322 matrix_lin_eqs(ikp, nkp + 1) = 1.0_dp
1323 matrix_lin_eqs(nkp + 1, ikp) = 1.0_dp
1325 matrix_lin_eqs(ikp, nkp + 2) = k_sq**(exp_kpoints*0.5_dp)
1326 matrix_lin_eqs(nkp + 2, ikp) = k_sq**(exp_kpoints*0.5_dp)
1330 CALL invmat(matrix_lin_eqs, info)
1334 ALLOCATE (right_side(num_lin_eqs))
1336 right_side(nkp + 1) = 1.0_dp
1338 right_side(nkp + 2) = integral
1340 ALLOCATE (wkp_tmp(num_lin_eqs))
1342 wkp_tmp(1:num_lin_eqs) = matmul(matrix_lin_eqs, right_side)
1344 wkp_w(1:nkp) = wkp_tmp(1:nkp)
1346 DEALLOCATE (matrix_lin_eqs, right_side, wkp_tmp)
1350 CALL timestop(handle)
1361 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: eigenval_kp
1363 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_bandstruc_and_k_dependent_MOs'
1365 INTEGER :: handle, ikp, ispin, nmo, nspins
1366 INTEGER,
DIMENSION(3) :: nkp_grid_g
1367 REAL(kind=
dp),
DIMENSION(:),
POINTER :: ev
1368 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: kpgeneral
1372 CALL timeset(routinen, handle)
1374 NULLIFY (qs_env%mp2_env%ri_rpa_im_time%kpoints_G, &
1375 qs_env%mp2_env%ri_rpa_im_time%kpoints_Sigma, &
1376 qs_env%mp2_env%ri_rpa_im_time%kpoints_Sigma_no_xc, &
1379 nkp_grid_g(1:3) = [1, 1, 1]
1381 CALL get_qs_env(qs_env=qs_env, para_env=para_env)
1383 CALL create_kp_and_calc_kp_orbitals(qs_env, qs_env%mp2_env%ri_rpa_im_time%kpoints_G, &
1384 "MONKHORST-PACK", para_env%num_pe, &
1385 mp_grid=nkp_grid_g(1:3))
1387 IF (qs_env%mp2_env%ri_g0w0%do_kpoints_Sigma)
THEN
1390 CALL get_kpgeneral_for_sigma_kpoints(qs_env, kpgeneral)
1392 CALL create_kp_and_calc_kp_orbitals(qs_env, qs_env%mp2_env%ri_rpa_im_time%kpoints_Sigma, &
1393 "GENERAL", para_env%num_pe, &
1394 kpgeneral=kpgeneral)
1396 CALL create_kp_and_calc_kp_orbitals(qs_env, qs_env%mp2_env%ri_rpa_im_time%kpoints_Sigma_no_xc, &
1397 "GENERAL", para_env%num_pe, &
1398 kpgeneral=kpgeneral, with_xc_terms=.false.)
1400 kpoints_sigma => qs_env%mp2_env%ri_rpa_im_time%kpoints_Sigma
1401 nmo =
SIZE(eigenval_kp, 1)
1402 nspins =
SIZE(eigenval_kp, 3)
1404 ALLOCATE (qs_env%mp2_env%ri_rpa_im_time%Eigenval_Gamma(nmo))
1405 qs_env%mp2_env%ri_rpa_im_time%Eigenval_Gamma(:) = eigenval_kp(:, 1, 1)
1407 DEALLOCATE (eigenval_kp)
1409 ALLOCATE (eigenval_kp(nmo, kpoints_sigma%nkp, nspins))
1411 DO ikp = 1, kpoints_sigma%nkp
1413 DO ispin = 1, nspins
1415 ev => kpoints_sigma%kp_env(ikp)%kpoint_env%mos(1, ispin)%eigenvalues
1417 eigenval_kp(:, ikp, ispin) = ev(:)
1423 DEALLOCATE (kpgeneral)
1427 CALL release_hfx_stuff(qs_env)
1429 CALL timestop(handle)
1437 SUBROUTINE release_hfx_stuff(qs_env)
1440 IF (
ASSOCIATED(qs_env%x_data) .AND. .NOT. qs_env%mp2_env%ri_g0w0%do_ri_Sigma_x)
THEN
1444 END SUBROUTINE release_hfx_stuff
1458 SUBROUTINE create_kp_and_calc_kp_orbitals(qs_env, kpoints, scheme, &
1459 group_size_ext, mp_grid, kpgeneral, with_xc_terms, &
1460 kp_shift, gamma_centered)
1464 CHARACTER(LEN=*),
INTENT(IN) :: scheme
1465 INTEGER :: group_size_ext
1466 INTEGER,
DIMENSION(3),
INTENT(IN),
OPTIONAL :: mp_grid
1467 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN), &
1468 OPTIONAL :: kpgeneral
1469 LOGICAL,
OPTIONAL :: with_xc_terms
1470 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN),
OPTIONAL :: kp_shift
1471 LOGICAL,
INTENT(IN),
OPTIONAL :: gamma_centered
1473 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_kp_and_calc_kp_orbitals'
1475 INTEGER :: handle, i_dim, i_re_im, ikp, ispin, nkp, &
1477 INTEGER,
DIMENSION(3) :: cell_grid, periodic
1478 LOGICAL :: my_with_xc_terms
1479 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
1486 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, matrix_s_desymm
1487 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mat_ks_kp, mat_s_kp
1494 CALL timeset(routinen, handle)
1496 my_with_xc_terms = .true.
1497 IF (
PRESENT(with_xc_terms)) my_with_xc_terms = with_xc_terms
1500 para_env=para_env, &
1501 blacs_env=blacs_env, &
1502 matrix_s=matrix_s, &
1504 scf_control=scf_control, &
1509 group_size_ext=group_size_ext, kp_shift=kp_shift, &
1510 gamma_centered=gamma_centered)
1519 CALL get_cell(cell=cell, periodic=periodic)
1524 IF (periodic(i_dim) == 1)
THEN
1525 cell_grid(i_dim) = max(min((kpoints%nkp_grid(i_dim)/2)*2 - 1, 1), 3)
1527 cell_grid(i_dim) = 1
1533 CALL get_qs_env(qs_env, matrix_s=matrix_s, scf_env=scf_env, scf_control=scf_control, dft_control=dft_control)
1535 NULLIFY (matrix_s_desymm)
1537 ALLOCATE (matrix_s_desymm(1)%matrix)
1538 CALL dbcsr_create(matrix=matrix_s_desymm(1)%matrix, template=matrix_s(1)%matrix, &
1539 matrix_type=dbcsr_type_no_symmetry)
1546 matrix_struct => kpoints%kp_env(1)%kpoint_env%wmat(1, 1)%matrix_struct
1554 nspins = dft_control%nspins
1556 DO ispin = 1, nspins
1559 IF (my_with_xc_terms)
THEN
1560 CALL mat_kp_from_mat_gamma(qs_env, mat_ks_kp, qs_env%mp2_env%ri_g0w0%matrix_ks(ispin)%matrix, kpoints, ispin)
1562 CALL mat_kp_from_mat_gamma(qs_env, mat_ks_kp, qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(ispin)%matrix, &
1568 CALL copy_dbcsr_to_fm(mat_ks_kp(ikp, 1)%matrix, kpoints%kp_env(ikp)%kpoint_env%wmat(1, ispin))
1571 CALL copy_dbcsr_to_fm(mat_ks_kp(ikp, 2)%matrix, kpoints%kp_env(ikp)%kpoint_env%wmat(2, ispin))
1580 kp => kpoints%kp_env(ikp)%kpoint_env
1582 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos, eigenvalues=eigenvalues)
1583 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1586 qs_env%mp2_env%ri_rpa_im_time%make_overlap_mat_ao_pos_definite)
THEN
1587 CALL cp_cfm_geeig_canon(cksmat, csmat, cmos, eigenvalues, cwork, scf_control%eps_eigval)
1589 CALL cp_cfm_geeig(cksmat, csmat, cmos, eigenvalues, cwork)
1594 kp%mos(2, ispin)%eigenvalues = eigenvalues
1605 DEALLOCATE (mat_ks_kp)
1612 DEALLOCATE (mat_s_kp)
1615 DEALLOCATE (matrix_s_desymm)
1623 CALL timestop(handle)
1625 END SUBROUTINE create_kp_and_calc_kp_orbitals
1643 LOGICAL,
INTENT(IN),
OPTIONAL :: real_mat_real_space
1645 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mat_kp_from_mat_gamma'
1647 INTEGER :: handle, i_cell, i_re_im, ikp, nkp, &
1649 INTEGER,
DIMENSION(3) :: periodic
1650 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1651 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1653 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: mat_real_space
1655 CALL timeset(routinen, handle)
1658 CALL get_cell(cell=cell, periodic=periodic)
1659 num_cells = 3**(periodic(1) + periodic(2) + periodic(3))
1661 NULLIFY (mat_real_space)
1663 DO i_cell = 1, num_cells
1664 ALLOCATE (mat_real_space(i_cell)%matrix)
1665 CALL dbcsr_create(matrix=mat_real_space(i_cell)%matrix, &
1668 CALL dbcsr_set(mat_real_space(i_cell)%matrix, 0.0_dp)
1671 CALL dbcsr_copy(mat_real_space(1)%matrix, mat_gamma)
1675 NULLIFY (xkp, cell_to_index)
1676 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, cell_to_index=cell_to_index)
1678 IF (ispin == 1)
THEN
1683 ALLOCATE (mat_kp(ikp, i_re_im)%matrix)
1684 CALL dbcsr_create(matrix=mat_kp(ikp, i_re_im)%matrix, template=mat_gamma)
1686 CALL dbcsr_set(mat_kp(ikp, i_re_im)%matrix, 0.0_dp)
1691 IF (
PRESENT(real_mat_real_space))
THEN
1693 real_mat_real_space)
1698 DO i_cell = 1, num_cells
1701 DEALLOCATE (mat_real_space)
1703 CALL timestop(handle)
1712 SUBROUTINE get_kpgeneral_for_sigma_kpoints(qs_env, kpgeneral)
1714 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: kpgeneral
1716 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_kpgeneral_for_Sigma_kpoints'
1718 INTEGER :: handle, i_kp_in_kp_line, i_special_kp, &
1719 i_x, ikk, j_y, k_z, n_kp_in_kp_line, &
1721 INTEGER,
DIMENSION(:),
POINTER :: nkp_grid
1723 CALL timeset(routinen, handle)
1725 n_special_kp = qs_env%mp2_env%ri_g0w0%n_special_kp
1726 n_kp_in_kp_line = qs_env%mp2_env%ri_g0w0%n_kp_in_kp_line
1727 IF (n_special_kp > 0)
THEN
1728 qs_env%mp2_env%ri_g0w0%nkp_self_energy_special_kp = n_kp_in_kp_line*(n_special_kp - 1) + 1
1730 qs_env%mp2_env%ri_g0w0%nkp_self_energy_special_kp = 0
1733 qs_env%mp2_env%ri_g0w0%nkp_self_energy_monkh_pack = qs_env%mp2_env%ri_g0w0%kp_grid_Sigma(1)* &
1734 qs_env%mp2_env%ri_g0w0%kp_grid_Sigma(2)* &
1735 qs_env%mp2_env%ri_g0w0%kp_grid_Sigma(3)
1737 qs_env%mp2_env%ri_g0w0%nkp_self_energy = qs_env%mp2_env%ri_g0w0%nkp_self_energy_special_kp + &
1738 qs_env%mp2_env%ri_g0w0%nkp_self_energy_monkh_pack
1740 ALLOCATE (kpgeneral(3, qs_env%mp2_env%ri_g0w0%nkp_self_energy))
1742 IF (n_special_kp > 0)
THEN
1744 kpgeneral(1:3, 1) = qs_env%mp2_env%ri_g0w0%xkp_special_kp(1:3, 1)
1748 DO i_special_kp = 2, n_special_kp
1749 DO i_kp_in_kp_line = 1, n_kp_in_kp_line
1752 kpgeneral(1:3, ikk) = qs_env%mp2_env%ri_g0w0%xkp_special_kp(1:3, i_special_kp - 1) + &
1753 REAL(i_kp_in_kp_line, kind=
dp)/real(n_kp_in_kp_line, kind=
dp)* &
1754 (qs_env%mp2_env%ri_g0w0%xkp_special_kp(1:3, i_special_kp) - &
1755 qs_env%mp2_env%ri_g0w0%xkp_special_kp(1:3, i_special_kp - 1))
1766 nkp_grid => qs_env%mp2_env%ri_g0w0%kp_grid_Sigma
1768 DO i_x = 1, nkp_grid(1)
1769 DO j_y = 1, nkp_grid(2)
1770 DO k_z = 1, nkp_grid(3)
1772 kpgeneral(1, ikk) = real(2*i_x - nkp_grid(1) - 1, kind=
dp)/(2._dp*real(nkp_grid(1), kind=
dp))
1773 kpgeneral(2, ikk) = real(2*j_y - nkp_grid(2) - 1, kind=
dp)/(2._dp*real(nkp_grid(2), kind=
dp))
1774 kpgeneral(3, ikk) = real(2*k_z - nkp_grid(3) - 1, kind=
dp)/(2._dp*real(nkp_grid(3), kind=
dp))
1779 CALL timestop(handle)
1781 END SUBROUTINE get_kpgeneral_for_sigma_kpoints
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
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.
methods related to the blacs parallel environment
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_scale_and_add_fm(alpha, matrix_a, beta, matrix_b)
Scale and add two BLACS matrices (a = alpha*a + beta*b). where b is a real matrix (adapted from cp_cf...
subroutine, public cp_cfm_uplo_to_full(matrix, workspace, uplo)
...
subroutine, public cp_cfm_column_scale(matrix_a, scaling)
Scales columns of the full matrix by corresponding factors.
various cholesky decomposition related routines
subroutine, public cp_cfm_cholesky_decompose(matrix, n, info_out)
Used to replace a symmetric positive definite matrix M with its Cholesky decomposition U: M = U^T * U...
subroutine, public cp_cfm_cholesky_invert(matrix, n, info_out)
Used to replace Cholesky decomposition by the inverse.
used for collecting diagonalization schemes available for cp_cfm_type
subroutine, public cp_cfm_geeig_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig, nmo_retained)
General Eigenvalue Problem AX = BXE Use canonical orthogonalization.
subroutine, public cp_cfm_heevd(matrix, eigenvectors, eigenvalues)
Perform a diagonalisation of a complex matrix.
subroutine, public cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work, lowest_subset)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, matrix_struct, para_env)
Returns information about a full matrix.
subroutine, public cp_cfm_set_all(matrix, alpha, beta)
Set all elements of the full matrix to alpha. Besides, set all diagonal matrix elements to beta (if g...
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.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_transposed(transposed, normal, shallow_data_copy, transpose_distribution, use_distribution)
...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_reserve_all_blocks(matrix)
Reserves all blocks.
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
represent the structure of a full matrix
represent a full matrix distributed on many processors
subroutine, public cp_fm_copy_general(source, destination, para_env)
General copy of a fm matrix to another fm matrix. Uses non-blocking MPI rather than ScaLAPACK.
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
Types and set/get functions for HFX.
subroutine, public hfx_release(x_data)
This routine deallocates all data structures
Defines the basic variable types.
integer, parameter, public dp
Routines needed for kpoint calculation.
subroutine, public kpoint_initialize_mo_set(kpoint)
...
subroutine, public kpoint_initialize_mos(kpoint, mos, added_mos, for_aux_fit)
Initialize a set of MOs and density matrix for each kpoint (kpoint group).
subroutine, public kpoint_env_initialize(kpoint, para_env, blacs_env, with_aux_fit)
Initialize the kpoint environment.
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered, lattice_fft)
Retrieve information from a kpoint environment.
Machine interface based on Fortran 2003 and POSIX.
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
Collection of simple mathematical functions and subroutines.
subroutine, public invmat(a, info)
returns inverse of matrix using the lapack routines DGETRF and DGETRI
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
Calculation of band structures.
subroutine, public calculate_kpoints_for_bs(kpoint, scheme, group_size_ext, mp_grid, kpgeneral, kp_shift, gamma_centered)
...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Definition and initialisation of the mo data type.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
module that contains the definitions of the scf types
Utility routines for GW with imaginary time.
subroutine, public compute_weight_re_im(weight_re, weight_im, num_cells, iatom, jatom, xkp, wkp_w, cell, index_to_cell, hmat, particle_set)
...
subroutine, public get_atom_index_from_basis_function_index(qs_env, atom_from_basis_index, basis_size, basis_type, first_bf_from_atom)
...
Routines treating GW and RPA calculations with kpoints.
subroutine, public invert_eps_compute_w_and_erpa_kp(dimen_ri, jquad, nkp, count_ev_sc_gw, para_env, erpa, grid, wkp_w, do_gw_im_time, do_ri_sigma_x, do_kpoints_from_gamma, cfm_mat_q, ikp_local, mat_p_omega, mat_p_omega_kp, qs_env, eps_filter_im_time, unit_nr, kpoints, fm_mat_minv_l_kpoints, fm_matrix_l_kpoints, fm_mat_w, fm_mat_ri_global_work, mat_minvvminv, fm_matrix_minv, fm_matrix_minv_vtrunc_minv)
...
subroutine, public get_mat_cell_t_from_mat_gamma(mat_p_omega, qs_env, kpoints, jquad, unit_nr)
...
subroutine, public real_space_to_kpoint_transform_rpa(real_mat_kp, imag_mat_kp, mat_real_space, kpoints, eps_filter_im_time, real_mat_real_space)
...
subroutine, public compute_wkp_w(qs_env, wkp_w, wkp_v, kpoints, h_inv, periodic)
...
subroutine, public get_bandstruc_and_k_dependent_mos(qs_env, eigenval_kp)
...
subroutine, public cp_cfm_power(matrix, threshold, exponent, min_eigval)
...
subroutine, public mat_kp_from_mat_gamma(qs_env, mat_kp, mat_gamma, kpoints, ispin, real_mat_real_space)
...
Routines for low-scaling RPA/GW with imaginary time.
subroutine, public init_cell_index_rpa(cell_grid, cell_to_index, index_to_cell, cell)
...
parameters that control an scf iteration
Definition and construction of time/frequency grids for correlation methods.
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.
keeps the information about the structure of a full matrix
Keeps information about a specific k-point.
Contains information about kpoints.
stores all the informations relevant to an mpi environment