29 dbcsr_type_antisymmetric, dbcsr_type_symmetric
89#include "./base/base_uses.f90"
95 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rpa_gw_sigma_x'
117 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(IN) :: mos_mp2
118 REAL(kind=
dp),
INTENT(OUT) :: energy_ex, energy_xc_admm(2), t3
119 INTEGER,
INTENT(IN) :: unit_nr
121 CHARACTER(len=*),
PARAMETER :: routinen =
'compute_vec_Sigma_x_minus_vxc_gw'
123 CHARACTER(4) :: occ_virt
124 CHARACTER(LEN=40) :: line
125 INTEGER :: corr_mos_occ_input, corr_mos_virt_input, dimen, gw_corr_lev_occ, gw_corr_lev_tot, &
126 gw_corr_lev_virt, handle, homo, homo_reduced_bse, i_img, ikp, irep, ispin, iunit, &
127 max_corr_lev_occ, max_corr_lev_virt, myfun, myfun_aux, myfun_prim, n_level_gw, &
128 n_level_gw_ref, n_rep_hf, nkp, nkp_sigma, nmo, nspins, print_exx, virtual_reduced_bse
129 LOGICAL :: calc_ints, charge_constrain_tmp, do_admm_rpa, do_hfx, do_kpoints_cubic_rpa, &
130 do_kpoints_from_gamma, do_ri_sigma_x, really_read_line
131 REAL(kind=
dp) :: e_gap_gw, e_homo_gw, e_lumo_gw, eh1, ehfx, eigval_dft, eigval_hf_at_dft, &
132 energy_exc, energy_exc1, energy_exc1_aux_fit, energy_exc_aux_fit, energy_total, &
133 exx_minus_vxc, hfx_fraction, min_direct_hf_at_dft_gap, t1, t2, tmp
134 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: matrix_tmp_2_diag
135 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: eigenval_kp_hf_at_dft, vec_sigma_x
136 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: eigenval_kp, vec_sigma_x_minus_vxc_gw, &
137 vec_sigma_x_minus_vxc_gw_im
140 TYPE(
dbcsr_p_type),
ALLOCATABLE,
DIMENSION(:) :: mat_exchange_for_kp_from_gamma
141 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_ks_aux_fit, &
142 matrix_ks_aux_fit_hfx, rho_ao, &
144 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_2d, matrix_ks_kp_im, &
145 matrix_ks_kp_re, matrix_ks_transl, matrix_sigma_x_minus_vxc, matrix_sigma_x_minus_vxc_im, &
147 TYPE(
dbcsr_type) :: matrix_tmp, matrix_tmp_2, mo_coeff_b
149 TYPE(
kpoint_type),
POINTER :: kpoints, kpoints_sigma
156 xc_section_admm_aux, &
159 NULLIFY (admm_env, matrix_ks, matrix_ks_aux_fit, rho_ao, matrix_sigma_x_minus_vxc, input, &
160 xc_section, xc_section_admm_aux, xc_section_admm_prim, hfx_sections, rho, &
161 dft_control, para_env, ks_env, mo_coeff, matrix_sigma_x_minus_vxc_im, matrix_ks_aux_fit_hfx, &
162 rho_aux_fit, rho_ao_aux_fit)
164 CALL timeset(routinen, handle)
168 do_admm_rpa = mp2_env%ri_rpa%do_admm
169 do_ri_sigma_x = mp2_env%ri_g0w0%do_ri_Sigma_x
170 do_kpoints_cubic_rpa = qs_env%mp2_env%ri_rpa_im_time%do_im_time_kpoints
171 do_kpoints_from_gamma = qs_env%mp2_env%ri_rpa_im_time%do_kpoints_from_Gamma
172 print_exx = mp2_env%ri_g0w0%print_exx
174 IF (do_kpoints_cubic_rpa)
THEN
175 cpassert(do_ri_sigma_x)
178 IF (do_kpoints_cubic_rpa)
THEN
182 matrix_ks_kp=matrix_ks_transl, &
185 dft_control=dft_control, &
196 matrix_ks=matrix_ks, &
199 dft_control=dft_control, &
206 IF (do_admm_rpa)
THEN
207 CALL get_admm_env(admm_env, matrix_ks_aux_fit=matrix_ks_aux_fit, rho_aux_fit=rho_aux_fit, &
208 matrix_ks_aux_fit_hfx=matrix_ks_aux_fit_hfx)
209 CALL qs_rho_get(rho_aux_fit, rho_ao=rho_ao_aux_fit)
220 nspins = dft_control%nspins
224 IF (do_kpoints_from_gamma)
THEN
226 ALLOCATE (qs_env%mp2_env%ri_g0w0%matrix_ks(nspins))
228 NULLIFY (qs_env%mp2_env%ri_g0w0%matrix_ks(ispin)%matrix)
229 ALLOCATE (qs_env%mp2_env%ri_g0w0%matrix_ks(ispin)%matrix)
230 CALL dbcsr_create(qs_env%mp2_env%ri_g0w0%matrix_ks(ispin)%matrix, &
231 template=matrix_ks(ispin)%matrix)
233 qs_env%mp2_env%ri_g0w0%matrix_ks(ispin)%matrix)
238 IF (do_kpoints_cubic_rpa)
THEN
240 CALL allocate_matrix_ks_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
241 CALL transform_matrix_ks_to_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
244 DO i_img = 1,
SIZE(matrix_ks_transl, 2)
245 CALL dbcsr_set(matrix_ks_transl(ispin, i_img)%matrix, 0.0_dp)
252 NULLIFY (matrix_sigma_x_minus_vxc)
254 IF (do_kpoints_cubic_rpa)
THEN
255 NULLIFY (matrix_sigma_x_minus_vxc_im)
262 IF (do_kpoints_cubic_rpa)
THEN
264 ALLOCATE (matrix_sigma_x_minus_vxc(ispin, ikp)%matrix)
265 CALL dbcsr_create(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, &
266 template=matrix_ks_kp_re(1, 1)%matrix, &
267 matrix_type=dbcsr_type_symmetric)
269 CALL dbcsr_copy(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, matrix_ks_kp_re(ispin, ikp)%matrix)
270 CALL dbcsr_set(matrix_ks_kp_re(ispin, ikp)%matrix, 0.0_dp)
272 ALLOCATE (matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix)
273 CALL dbcsr_create(matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix, &
274 template=matrix_ks_kp_im(1, 1)%matrix, &
275 matrix_type=dbcsr_type_antisymmetric)
277 CALL dbcsr_copy(matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix, matrix_ks_kp_im(ispin, ikp)%matrix)
278 CALL dbcsr_set(matrix_ks_kp_im(ispin, ikp)%matrix, 0.0_dp)
282 ALLOCATE (matrix_sigma_x_minus_vxc(ispin, ikp)%matrix)
283 CALL dbcsr_create(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, &
284 template=matrix_ks(1)%matrix)
286 CALL dbcsr_copy(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, matrix_ks(ispin)%matrix)
287 CALL dbcsr_set(matrix_ks(ispin)%matrix, 0.0_dp)
299 hfx_fraction = qs_env%x_data(1, 1)%general_parameter%fraction
300 qs_env%x_data(:, :)%general_parameter%fraction = 0.0_dp
310 IF (dft_control%do_admm)
THEN
327 charge_constrain_tmp = .false.
328 IF (admm_env%charge_constrain)
THEN
329 admm_env%charge_constrain = .false.
330 charge_constrain_tmp = .true.
337 IF (do_admm_rpa)
THEN
339 CALL dbcsr_set(matrix_ks_aux_fit(ispin)%matrix, 0.0_dp)
343 IF (.NOT. mp2_env%ri_g0w0%update_xc_energy)
THEN
344 energy_total = energy%total
345 energy_exc = energy%exc
346 energy_exc1 = energy%exc1
347 energy_exc_aux_fit = energy%ex
348 energy_exc1_aux_fit = energy%exc_aux_fit
349 energy_ex = energy%exc1_aux_fit
353 energy%total = energy%total - (energy%exc + energy%exc1 + energy%ex + &
354 energy%exc_aux_fit + energy%exc1_aux_fit)
360 IF (.NOT. mp2_env%ri_g0w0%update_xc_energy)
THEN
361 energy%exc = energy_exc
362 energy%exc1 = energy_exc1
363 energy%exc_aux_fit = energy_ex
364 energy%exc1_aux_fit = energy_exc_aux_fit
365 energy%ex = energy_exc1_aux_fit
366 energy%total = energy_total
373 qs_env%x_data(:, :)%general_parameter%fraction = hfx_fraction
376 IF (dft_control%do_admm)
THEN
386 IF (charge_constrain_tmp)
THEN
387 admm_env%charge_constrain = .true.
391 IF (do_kpoints_cubic_rpa)
THEN
392 CALL transform_matrix_ks_to_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
397 IF (do_kpoints_cubic_rpa)
THEN
399 CALL dbcsr_add(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, matrix_ks_kp_re(ispin, ikp)%matrix, -1.0_dp, 1.0_dp)
400 CALL dbcsr_add(matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix, matrix_ks_kp_im(ispin, ikp)%matrix, -1.0_dp, 1.0_dp)
403 CALL dbcsr_add(matrix_sigma_x_minus_vxc(ispin, 1)%matrix, matrix_ks(ispin)%matrix, -1.0_dp, 1.0_dp)
413 IF (mp2_env%ri_g0w0%do_static_cohsex .AND. .NOT. do_kpoints_cubic_rpa)
THEN
414 ALLOCATE (mp2_env%ri_g0w0%matrix_vxc(nspins))
416 ALLOCATE (mp2_env%ri_g0w0%matrix_vxc(ispin)%matrix)
417 CALL dbcsr_create(mp2_env%ri_g0w0%matrix_vxc(ispin)%matrix, template=matrix_ks(1)%matrix)
418 CALL dbcsr_copy(mp2_env%ri_g0w0%matrix_vxc(ispin)%matrix, matrix_sigma_x_minus_vxc(ispin, 1)%matrix)
419 CALL dbcsr_scale(mp2_env%ri_g0w0%matrix_vxc(ispin)%matrix, -1.0_dp)
423 IF (do_kpoints_cubic_rpa)
THEN
425 CALL transform_sigma_x_minus_vxc_to_mo_basis(kpoints, matrix_sigma_x_minus_vxc, &
426 matrix_sigma_x_minus_vxc_im, &
427 vec_sigma_x_minus_vxc_gw, &
428 vec_sigma_x_minus_vxc_gw_im, &
429 para_env, nmo, mp2_env)
434 CALL dbcsr_set(matrix_ks(ispin)%matrix, 0.0_dp)
435 IF (do_admm_rpa)
THEN
436 CALL dbcsr_set(matrix_ks_aux_fit(ispin)%matrix, 0.0_dp)
447 IF (.NOT. do_ri_sigma_x)
THEN
449 CALL exx_pre_hfx(hfx_sections, qs_env%mp2_env%ri_rpa%x_data, qs_env%mp2_env%ri_rpa%reuse_hfx)
450 calc_ints = .NOT. qs_env%mp2_env%ri_rpa%reuse_hfx
453 DO irep = 1, n_rep_hf
454 IF (do_admm_rpa)
THEN
455 matrix_ks_2d(1:nspins, 1:1) => matrix_ks_aux_fit(1:nspins)
456 rho_ao_2d(1:nspins, 1:1) => rho_ao_aux_fit(1:nspins)
458 matrix_ks_2d(1:nspins, 1:1) => matrix_ks(1:nspins)
459 rho_ao_2d(1:nspins, 1:1) => rho_ao(1:nspins)
462 IF (qs_env%mp2_env%ri_rpa%x_data(irep, 1)%do_hfx_ri)
THEN
463 CALL hfx_ri_update_ks(qs_env, qs_env%mp2_env%ri_rpa%x_data(irep, 1)%ri_data, matrix_ks_2d, ehfx, &
464 rho_ao=rho_ao_2d, geometry_did_change=calc_ints, nspins=nspins, &
465 hf_fraction=qs_env%mp2_env%ri_rpa%x_data(irep, 1)%general_parameter%fraction)
467 IF (do_admm_rpa)
THEN
470 CALL dbcsr_copy(matrix_ks_aux_fit_hfx(ispin)%matrix, matrix_ks_2d(ispin, 1)%matrix, &
471 name=
"HF exch. part of matrix_ks_aux_fit for ADMMS")
476 rho_ao_2d, hfx_sections, &
477 para_env, calc_ints, irep, .true., &
484 IF (do_admm_rpa)
THEN
486 matrix_prim=matrix_ks, &
487 matrix_aux=matrix_ks_aux_fit, &
488 x_data=qs_env%mp2_env%ri_rpa%x_data, &
489 exc=energy_xc_admm(1), &
490 exc_aux_fit=energy_xc_admm(2), &
491 calc_forces=.false., &
495 IF (do_kpoints_from_gamma .AND. print_exx ==
gw_print_exx)
THEN
496 ALLOCATE (mat_exchange_for_kp_from_gamma(1))
499 NULLIFY (mat_exchange_for_kp_from_gamma(ispin)%matrix)
500 ALLOCATE (mat_exchange_for_kp_from_gamma(ispin)%matrix)
501 CALL dbcsr_create(mat_exchange_for_kp_from_gamma(ispin)%matrix, template=matrix_ks(ispin)%matrix)
502 CALL dbcsr_desymmetrize(matrix_ks(ispin)%matrix, mat_exchange_for_kp_from_gamma(ispin)%matrix)
507 CALL exx_post_hfx(qs_env, qs_env%mp2_env%ri_rpa%x_data, qs_env%mp2_env%ri_rpa%reuse_hfx)
514 IF (do_admm_rpa)
THEN
519 CALL dbcsr_add(matrix_sigma_x_minus_vxc(ispin, 1)%matrix, matrix_ks(ispin)%matrix, 1.0_dp, 1.0_dp)
526 IF (do_kpoints_from_gamma .OR. mp2_env%ri_g0w0%do_static_cohsex)
THEN
528 ALLOCATE (qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(nspins))
530 NULLIFY (qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(ispin)%matrix)
531 ALLOCATE (qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(ispin)%matrix)
532 CALL dbcsr_create(qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(ispin)%matrix, &
533 template=matrix_ks(ispin)%matrix)
536 qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(ispin)%matrix)
545 corr_mos_occ_input = mp2_env%ri_g0w0%corr_mos_occ
546 corr_mos_virt_input = mp2_env%ri_g0w0%corr_mos_virt
549 IF (mp2_env%bse%do_bse)
THEN
550 CALL bse_window_from_mos(mos_mp2, mp2_env%bse%bse_cutoff_occ, mp2_env%bse%bse_cutoff_empty, &
551 bse_window, warn=.false.)
565 ALLOCATE (vec_sigma_x_minus_vxc_gw(nmo, nspins, nkp))
566 vec_sigma_x_minus_vxc_gw = 0.0_dp
568 ALLOCATE (matrix_tmp_2_diag(dimen))
585 gw_corr_lev_occ = corr_mos_occ_input
586 gw_corr_lev_virt = corr_mos_virt_input
591 max_corr_lev_occ = homo
592 max_corr_lev_virt = nmo - homo
595 IF (mp2_env%bse%do_bse)
THEN
600 IF (mp2_env%bse%bse_cutoff_occ < 0)
THEN
603 IF (gw_corr_lev_occ > 0)
THEN
608 IF (mp2_env%bse%bse_cutoff_empty < 0)
THEN
609 gw_corr_lev_virt = -1
611 IF (gw_corr_lev_virt > 0)
THEN
612 gw_corr_lev_virt = -2
617 homo_reduced_bse = homo - bse_window%first_mo + 1
618 virtual_reduced_bse = bse_window%last_mo - homo
619 IF (gw_corr_lev_occ == -2)
THEN
620 cpwarn(
"BSE cutoff overwrites user input for CORR_MOS_OCC")
621 gw_corr_lev_occ = homo_reduced_bse
623 IF (gw_corr_lev_virt == -2)
THEN
624 cpwarn(
"BSE cutoff overwrites user input for CORR_MOS_VIRT")
625 gw_corr_lev_virt = virtual_reduced_bse
632 IF (gw_corr_lev_occ > homo .OR. gw_corr_lev_occ < 0) gw_corr_lev_occ = max_corr_lev_occ
633 IF (gw_corr_lev_virt > max_corr_lev_virt .OR. gw_corr_lev_virt < 0) gw_corr_lev_virt = max_corr_lev_virt
635 mp2_env%ri_g0w0%corr_mos_occ = gw_corr_lev_occ
636 mp2_env%ri_g0w0%corr_mos_virt = gw_corr_lev_virt
637 ELSE IF (ispin == 2)
THEN
640 IF (mp2_env%ri_g0w0%corr_mos_occ + mp2_env%ri_g0w0%corr_mos_virt /= &
641 gw_corr_lev_occ + gw_corr_lev_virt)
THEN
642 gw_corr_lev_virt = mp2_env%ri_g0w0%corr_mos_occ + mp2_env%ri_g0w0%corr_mos_virt - gw_corr_lev_occ
644 mp2_env%ri_g0w0%corr_mos_occ_beta = gw_corr_lev_occ
645 mp2_env%ri_g0w0%corr_mos_virt_beta = gw_corr_lev_virt
649 CALL dbcsr_multiply(
'N',
'N', 1.0_dp, matrix_sigma_x_minus_vxc(ispin, 1)%matrix, &
650 mo_coeff_b, 0.0_dp, matrix_tmp, first_column=homo + 1 - gw_corr_lev_occ, &
651 last_column=homo + gw_corr_lev_virt)
654 matrix_tmp, 0.0_dp, matrix_tmp_2, first_row=homo + 1 - gw_corr_lev_occ, &
655 last_row=homo + gw_corr_lev_virt)
658 vec_sigma_x_minus_vxc_gw(1:nmo, ispin, 1) = matrix_tmp_2_diag(1:nmo)
665 CALL para_env%sum(vec_sigma_x_minus_vxc_gw)
672 IF (do_kpoints_cubic_rpa)
THEN
680 IF (do_kpoints_cubic_rpa)
THEN
686 ALLOCATE (mp2_env%ri_g0w0%vec_Sigma_x_minus_vxc_gw(nmo, nspins, nkp))
690 IF (do_kpoints_from_gamma)
THEN
692 gw_corr_lev_tot = gw_corr_lev_occ + gw_corr_lev_virt
701 ALLOCATE (eigenval_kp(nmo, 1, nspins))
707 nkp_sigma =
SIZE(eigenval_kp, 2)
709 ALLOCATE (vec_sigma_x(nmo, nkp_sigma))
710 vec_sigma_x(:, :) = 0.0_dp
713 mat_exchange_for_kp_from_gamma(1)%matrix, &
714 vec_sigma_x(homo - gw_corr_lev_occ + 1:homo + gw_corr_lev_virt, :), &
715 homo, gw_corr_lev_occ, gw_corr_lev_virt, 1)
718 DEALLOCATE (mat_exchange_for_kp_from_gamma(1)%matrix)
719 DEALLOCATE (mat_exchange_for_kp_from_gamma)
721 DEALLOCATE (vec_sigma_x_minus_vxc_gw)
723 ALLOCATE (vec_sigma_x_minus_vxc_gw(nmo, nspins, nkp_sigma))
725 vec_sigma_x_minus_vxc_gw(:, 1, :) = vec_sigma_x(:, :) + &
726 qs_env%mp2_env%ri_g0w0%vec_Sigma_x_minus_vxc_gw(:, 1, :)
728 kpoints_sigma => qs_env%mp2_env%ri_rpa_im_time%kpoints_Sigma
736 IF (unit_nr > 0)
THEN
738 ALLOCATE (eigenval_kp_hf_at_dft(nmo, nkp_sigma))
739 eigenval_kp_hf_at_dft(:, :) = eigenval_kp(:, :, 1) + vec_sigma_x_minus_vxc_gw(:, 1, :)
741 min_direct_hf_at_dft_gap = 100.0_dp
743 WRITE (unit_nr,
'(T3,A)')
''
744 WRITE (unit_nr,
'(T3,A)')
'Exchange energies'
745 WRITE (unit_nr,
'(T3,A)')
'-----------------'
746 WRITE (unit_nr,
'(T3,A)')
''
747 WRITE (unit_nr,
'(T6,2A)')
'MO e_n^DFT Sigma_x-vxc e_n^HF@DFT'
748 DO ikp = 1, nkp_sigma
749 IF (nkp_sigma > 1)
THEN
750 WRITE (unit_nr,
'(T3,A)')
''
751 WRITE (unit_nr,
'(T3,A7,I3,A3,I3,A8,3F7.3,A12,3F7.3)')
'Kpoint ', ikp,
' /', nkp_sigma, &
752 ' xkp =', kpoints_sigma%xkp(1, ikp), kpoints_sigma%xkp(2, ikp), &
753 kpoints_sigma%xkp(3, ikp),
' and xkp =', -kpoints_sigma%xkp(1, ikp), &
754 -kpoints_sigma%xkp(2, ikp), -kpoints_sigma%xkp(3, ikp)
755 WRITE (unit_nr,
'(T3,A)')
''
757 DO n_level_gw = 1, gw_corr_lev_occ + gw_corr_lev_virt
759 n_level_gw_ref = n_level_gw + homo - gw_corr_lev_occ
760 IF (n_level_gw <= gw_corr_lev_occ)
THEN
766 eigval_dft = eigenval_kp(n_level_gw_ref, ikp, 1)*
evolt
767 exx_minus_vxc = real(vec_sigma_x_minus_vxc_gw(n_level_gw_ref, 1, ikp)*
evolt, kind=
dp)
768 eigval_hf_at_dft = eigenval_kp_hf_at_dft(n_level_gw_ref, ikp)*
evolt
770 WRITE (unit_nr,
'(T4,I4,3A,3F21.3,3F21.3,3F21.3)') &
771 n_level_gw_ref,
' ( ', occ_virt,
') ', eigval_dft, exx_minus_vxc, eigval_hf_at_dft
774 e_homo_gw = maxval(eigenval_kp_hf_at_dft(homo - gw_corr_lev_occ + 1:homo, ikp))
775 e_lumo_gw = minval(eigenval_kp_hf_at_dft(homo + 1:homo + gw_corr_lev_virt, ikp))
776 e_gap_gw = e_lumo_gw - e_homo_gw
777 IF (e_gap_gw < min_direct_hf_at_dft_gap) min_direct_hf_at_dft_gap = e_gap_gw
778 WRITE (unit_nr,
'(T3,A)')
''
779 WRITE (unit_nr,
'(T3,A,F53.2)')
'HF@DFT HOMO-LUMO gap (eV)', e_gap_gw*
evolt
780 WRITE (unit_nr,
'(T3,A)')
''
783 WRITE (unit_nr,
'(T3,A)')
''
784 WRITE (unit_nr,
'(T3,A)')
''
785 WRITE (unit_nr,
'(T3,A,F63.3)')
'HF@DFT direct bandgap (eV)', min_direct_hf_at_dft_gap*
evolt
787 WRITE (unit_nr,
'(T3,A)')
''
788 WRITE (unit_nr,
'(T3,A)')
'End of exchange energies'
789 WRITE (unit_nr,
'(T3,A)')
'------------------------'
790 WRITE (unit_nr,
'(T3,A)')
''
792 cpabort(
'Stop after printing exchange energies.')
802 CALL open_file(unit_number=iunit, file_name=
"exx.out")
804 really_read_line = .false.
808 READ (iunit,
'(A)') line
810 IF (line ==
" End of exchange energies ")
EXIT
812 IF (really_read_line)
THEN
814 READ (line(1:7), *) n_level_gw_ref
815 READ (line(17:40), *) tmp
817 DO ikp = 1,
SIZE(vec_sigma_x_minus_vxc_gw, 3)
818 vec_sigma_x_minus_vxc_gw(n_level_gw_ref, 1, ikp) = tmp/
evolt
823 IF (line ==
" MO Sigma_x-vxc ") really_read_line = .true.
832 mp2_env%ri_g0w0%vec_Sigma_x_minus_vxc_gw(:, :, :) = vec_sigma_x_minus_vxc_gw(:, :, :)
835 DEALLOCATE (matrix_sigma_x_minus_vxc, vec_sigma_x_minus_vxc_gw)
836 IF (do_kpoints_cubic_rpa)
THEN
837 DEALLOCATE (matrix_sigma_x_minus_vxc_im)
844 CALL timestop(handle)
859 SUBROUTINE transform_sigma_x_minus_vxc_to_mo_basis(kpoints, matrix_sigma_x_minus_vxc, &
860 matrix_sigma_x_minus_vxc_im, vec_Sigma_x_minus_vxc_gw, &
861 vec_Sigma_x_minus_vxc_gw_im, para_env, nmo, mp2_env)
864 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_sigma_x_minus_vxc, &
865 matrix_sigma_x_minus_vxc_im
866 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: vec_sigma_x_minus_vxc_gw, &
867 vec_sigma_x_minus_vxc_gw_im
872 CHARACTER(LEN=*),
PARAMETER :: routinen =
'transform_sigma_x_minus_vxc_to_MO_basis'
874 INTEGER :: dimen, gw_corr_lev_occ, gw_corr_lev_virt, handle, homo, i_global, iib, ikp, &
875 ispin, j_global, jjb, max_corr_lev_occ, max_corr_lev_virt, ncol_local, nkp, nrow_local, &
877 INTEGER,
DIMENSION(2) :: kp_range
878 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
879 REAL(kind=
dp) :: imval, reval
881 cfm_sigma_x_minus_vxc_mo_basis, cfm_tmp
888 CALL timeset(routinen, handle)
890 mo_set => kpoints%kp_env(1)%kpoint_env%mos(1)
893 nspins =
SIZE(matrix_sigma_x_minus_vxc, 1)
898 cpassert(kp_range(1) == 1 .AND. kp_range(2) == nkp)
900 ALLOCATE (vec_sigma_x_minus_vxc_gw(nmo, nspins, nkp))
901 vec_sigma_x_minus_vxc_gw = 0.0_dp
903 ALLOCATE (vec_sigma_x_minus_vxc_gw_im(nmo, nspins, nkp))
904 vec_sigma_x_minus_vxc_gw_im = 0.0_dp
910 CALL cp_cfm_create(cfm_sigma_x_minus_vxc_mo_basis, matrix_struct)
914 nrow_local=nrow_local, &
915 ncol_local=ncol_local, &
916 row_indices=row_indices, &
917 col_indices=col_indices)
922 kp => kpoints%kp_env(ikp)%kpoint_env
927 CALL copy_dbcsr_to_fm(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, fwork_re)
928 CALL copy_dbcsr_to_fm(matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix, fwork_im)
933 cmo_coeff => kp%mos(ispin)%cmo_coeff
937 cmo_coeff,
z_zero, cfm_tmp)
941 z_zero, cfm_sigma_x_minus_vxc_mo_basis)
943 DO jjb = 1, ncol_local
945 j_global = col_indices(jjb)
947 DO iib = 1, nrow_local
949 i_global = row_indices(iib)
951 IF (j_global == i_global .AND. i_global <= nmo)
THEN
953 reval = real(cfm_sigma_x_minus_vxc_mo_basis%local_data(iib, jjb), kind=
dp)
954 imval = aimag(cfm_sigma_x_minus_vxc_mo_basis%local_data(iib, jjb))
956 vec_sigma_x_minus_vxc_gw(i_global, ispin, ikp) = reval
957 vec_sigma_x_minus_vxc_gw_im(i_global, ispin, ikp) = imval
969 CALL para_env%sum(vec_sigma_x_minus_vxc_gw)
970 CALL para_env%sum(vec_sigma_x_minus_vxc_gw_im)
973 CALL get_mo_set(mo_set=kpoints%kp_env(1)%kpoint_env%mos(ispin), &
974 homo=homo, nao=dimen)
978 max_corr_lev_occ = homo
979 max_corr_lev_virt = nmo - homo
981 gw_corr_lev_occ = mp2_env%ri_g0w0%corr_mos_occ
982 gw_corr_lev_virt = mp2_env%ri_g0w0%corr_mos_virt
985 IF (gw_corr_lev_occ > homo .OR. gw_corr_lev_occ < 0) gw_corr_lev_occ = max_corr_lev_occ
986 IF (gw_corr_lev_virt > max_corr_lev_virt .OR. gw_corr_lev_virt < 0) gw_corr_lev_virt = max_corr_lev_virt
988 mp2_env%ri_g0w0%corr_mos_occ = gw_corr_lev_occ
989 mp2_env%ri_g0w0%corr_mos_virt = gw_corr_lev_virt
990 ELSE IF (ispin == 2)
THEN
993 IF (mp2_env%ri_g0w0%corr_mos_occ + mp2_env%ri_g0w0%corr_mos_virt /= &
994 gw_corr_lev_occ + gw_corr_lev_virt)
THEN
995 gw_corr_lev_virt = mp2_env%ri_g0w0%corr_mos_occ + mp2_env%ri_g0w0%corr_mos_virt - gw_corr_lev_occ
997 mp2_env%ri_g0w0%corr_mos_occ_beta = gw_corr_lev_occ
998 mp2_env%ri_g0w0%corr_mos_virt_beta = gw_corr_lev_virt
1008 CALL timestop(handle)
1010 END SUBROUTINE transform_sigma_x_minus_vxc_to_mo_basis
1019 SUBROUTINE transform_matrix_ks_to_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
1021 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_transl, matrix_ks_kp_re, &
1025 CHARACTER(len=*),
PARAMETER :: routinen =
'transform_matrix_ks_to_kp'
1027 INTEGER :: handle, ikp, ispin, nkp, nspin
1028 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1029 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1033 CALL timeset(routinen, handle)
1036 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, sab_nl=sab_nl, cell_to_index=cell_to_index)
1038 cpassert(
ASSOCIATED(sab_nl))
1040 nspin =
SIZE(matrix_ks_transl, 1)
1045 CALL dbcsr_set(matrix_ks_kp_re(ispin, ikp)%matrix, 0.0_dp)
1046 CALL dbcsr_set(matrix_ks_kp_im(ispin, ikp)%matrix, 0.0_dp)
1047 CALL rskp_transform(rmatrix=matrix_ks_kp_re(ispin, ikp)%matrix, &
1048 cmatrix=matrix_ks_kp_im(ispin, ikp)%matrix, &
1049 rsmat=matrix_ks_transl, ispin=ispin, &
1050 xkp=xkp(1:3, ikp), cell_to_index=cell_to_index, sab_nl=sab_nl)
1055 CALL timestop(handle)
1057 END SUBROUTINE transform_matrix_ks_to_kp
1066 SUBROUTINE allocate_matrix_ks_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
1068 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_transl, matrix_ks_kp_re, &
1072 CHARACTER(len=*),
PARAMETER :: routinen =
'allocate_matrix_ks_kp'
1074 INTEGER :: handle, ikp, ispin, nkp, nspin
1075 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1076 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1080 CALL timeset(routinen, handle)
1083 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, sab_nl=sab_nl, cell_to_index=cell_to_index)
1085 cpassert(
ASSOCIATED(sab_nl))
1087 nspin =
SIZE(matrix_ks_transl, 1)
1089 NULLIFY (matrix_ks_kp_re, matrix_ks_kp_im)
1096 ALLOCATE (matrix_ks_kp_re(ispin, ikp)%matrix)
1097 ALLOCATE (matrix_ks_kp_im(ispin, ikp)%matrix)
1099 CALL dbcsr_create(matrix_ks_kp_re(ispin, ikp)%matrix, &
1100 template=matrix_ks_transl(1, 1)%matrix, &
1101 matrix_type=dbcsr_type_symmetric)
1102 CALL dbcsr_create(matrix_ks_kp_im(ispin, ikp)%matrix, &
1103 template=matrix_ks_transl(1, 1)%matrix, &
1104 matrix_type=dbcsr_type_antisymmetric)
1109 CALL dbcsr_set(matrix_ks_kp_re(ispin, ikp)%matrix, 0.0_dp)
1110 CALL dbcsr_set(matrix_ks_kp_im(ispin, ikp)%matrix, 0.0_dp)
1115 CALL timestop(handle)
1117 END SUBROUTINE allocate_matrix_ks_kp
Contains ADMM methods which require molecular orbitals.
subroutine, public admm_mo_merge_ks_matrix(qs_env)
...
Types and set/get functions for auxiliary density matrix methods.
subroutine, public get_admm_env(admm_env, mo_derivs_aux_fit, mos_aux_fit, sab_aux_fit, sab_aux_fit_asymm, sab_aux_fit_vs_orb, matrix_s_aux_fit, matrix_s_aux_fit_kp, matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp, task_list_aux_fit, matrix_ks_aux_fit, matrix_ks_aux_fit_kp, matrix_ks_aux_fit_im, matrix_ks_aux_fit_dft, matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_dft_kp, matrix_ks_aux_fit_hfx_kp, rho_aux_fit, rho_aux_fit_buffer, admm_dm)
Get routine for the ADMM env.
Auxiliary routines for GW + Bethe-Salpeter for computing electronic excitations.
subroutine, public bse_window_from_mos(mos, cutoff_occ, cutoff_empty, window, warn)
The active MO window of bse_window_from_dft, from the DFT eigenvalues of the MO sets.
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...
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.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_release_p(matrix)
...
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, first_row, last_row, first_column, last_column, first_k, last_k, retain_sparsity, filter_eps, flop)
...
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_get_diag(matrix, diag)
Copies the diagonal elements from the given matrix into the given array.
Routines that link DBCSR and CP2K concepts together.
subroutine, public cp_dbcsr_alloc_block_from_nbl(matrix, sab_orb, desymmetrize)
allocate the blocks of a dbcsr based on the neighbor list
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 copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
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.
represent the structure of a full matrix
represent a full matrix distributed on many processors
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
Routines to calculate HFX energy and potential.
subroutine, public integrate_four_center(qs_env, x_data, ks_matrix, ehfx, rho_ao, hfx_section, para_env, geometry_did_change, irep, distribute_fock_matrix, ispin, nspins)
computes four center integrals for a full basis set and updates the Kohn-Sham-Matrix and energy....
Routines to calculate EXX in RPA and energy correction methods.
subroutine, public calc_exx_admm_xc_contributions(qs_env, matrix_prim, matrix_aux, x_data, exc, exc_aux_fit, calc_forces, use_virial)
Calculate the RI_RPAHF / EC_ENVHF ADMM XC contributions to the KS matrices and the respective energie...
subroutine, public exx_pre_hfx(ext_hfx_section, x_data, reuse_hfx)
Prepare the external x_data for integration. Simply change the HFX fraction in case the qs_envx_data ...
subroutine, public exx_post_hfx(qs_env, x_data, reuse_hfx)
Revert back to the proper HFX fraction in case qs_envx_data is reused.
subroutine, public hfx_ri_update_ks(qs_env, ri_data, ks_matrix, ehfx, mos, rho_ao, geometry_did_change, nspins, hf_fraction)
...
Defines the basic variable types.
integer, parameter, public dp
Routines needed for kpoint calculation.
subroutine, public rskp_transform(rmatrix, cmatrix, rsmat, ispin, xkp, cell_to_index, sab_nl, is_complex, rs_sign)
Transformation of real space matrices to a kpoint.
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
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
Common selection and union operations for contiguous molecular-orbital windows.
Routines to calculate and distribute 2c- and 3c- integrals for RI.
subroutine, public compute_kpoints(qs_env, kpoints, unit_nr)
...
Framework for 2c-integrals for RI.
subroutine, public trunc_coulomb_for_exchange(qs_env, trunc_coulomb, rel_cutoff_trunc_coulomb_ri_x, cell_grid, do_bvk_cell)
...
Types needed for MP2 calculations.
basic linear algebra operations for full matrixes
Definition of physical constants:
real(kind=dp), parameter, public evolt
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.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_build_kohn_sham_matrix(qs_env, calculate_forces, just_energy, print_active, ext_ks_matrix, ext_xc_section)
routine where the real calculations are made: the KS matrix is calculated
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, cmo_coeff)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Routines treating GW and RPA calculations with kpoints.
subroutine, public get_bandstruc_and_k_dependent_mos(qs_env, eigenval_kp)
...
Routines to calculate EXX within GW.
subroutine, public compute_vec_sigma_x_minus_vxc_gw(qs_env, mp2_env, mos_mp2, energy_ex, energy_xc_admm, t3, unit_nr)
...
Routines for GW, continuous development [Jan Wilhelm].
subroutine, public trafo_to_mo_and_kpoints(qs_env, mat_self_energy_ao_ao, vec_sigma, homo, gw_corr_lev_occ, gw_corr_lev_virt, ispin)
...
subroutine, public compute_minus_vxc_kpoints(qs_env)
...
stores some data used in wavefunction fitting
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
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.