36 USE dbcsr_api,
ONLY: &
37 dbcsr_add, dbcsr_copy, dbcsr_create, dbcsr_desymmetrize, dbcsr_get_diag, dbcsr_multiply, &
38 dbcsr_p_type, dbcsr_release, dbcsr_release_p, dbcsr_set, dbcsr_type, &
39 dbcsr_type_antisymmetric, dbcsr_type_symmetric
86 #include "./base/base_uses.f90"
92 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rpa_gw_sigma_x'
112 TYPE(qs_environment_type),
POINTER :: qs_env
113 TYPE(mp2_type) :: mp2_env
114 TYPE(mo_set_type),
DIMENSION(:),
INTENT(IN) :: mos_mp2
115 REAL(kind=
dp),
INTENT(OUT) :: energy_ex, energy_xc_admm(2), t3
116 INTEGER,
INTENT(IN) :: unit_nr
118 CHARACTER(len=*),
PARAMETER :: routinen =
'compute_vec_Sigma_x_minus_vxc_gw'
120 CHARACTER(4) :: occ_virt
121 CHARACTER(LEN=40) :: line
122 INTEGER :: dimen, gw_corr_lev_occ, gw_corr_lev_tot, gw_corr_lev_virt, handle, homo, i_img, &
123 ikp, irep, ispin, iunit, myfun, myfun_aux, myfun_prim, n_level_gw, n_level_gw_ref, &
124 n_rep_hf, nkp, nkp_sigma, nmo, nspins, print_exx
125 LOGICAL :: calc_ints, charge_constrain_tmp, do_admm_rpa, do_hfx, do_kpoints_cubic_rpa, &
126 do_kpoints_from_gamma, do_ri_sigma_x, really_read_line
127 REAL(kind=
dp) :: e_gap_gw, e_homo_gw, e_lumo_gw, eh1, ehfx, eigval_dft, eigval_hf_at_dft, &
128 energy_exc, energy_exc1, energy_exc1_aux_fit, energy_exc_aux_fit, energy_total, &
129 exx_minus_vxc, hfx_fraction, min_direct_hf_at_dft_gap, t1, t2, tmp
130 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: eigenval_kp_hf_at_dft, vec_sigma_x
131 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: eigenval_kp, vec_sigma_x_minus_vxc_gw, &
132 vec_sigma_x_minus_vxc_gw_im
133 TYPE(admm_type),
POINTER :: admm_env
134 TYPE(cp_fm_type),
POINTER :: mo_coeff
135 TYPE(dbcsr_p_type),
ALLOCATABLE,
DIMENSION(:) :: mat_exchange_for_kp_from_gamma
136 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_ks_aux_fit, &
137 matrix_ks_aux_fit_hfx, rho_ao, &
139 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_2d, matrix_ks_kp_im, &
140 matrix_ks_kp_re, matrix_ks_transl, matrix_sigma_x_minus_vxc, matrix_sigma_x_minus_vxc_im, &
142 TYPE(dbcsr_type) :: matrix_tmp, matrix_tmp_2, mo_coeff_b
143 TYPE(dft_control_type),
POINTER :: dft_control
144 TYPE(kpoint_type),
POINTER :: kpoints, kpoints_sigma
145 TYPE(mp_para_env_type),
POINTER :: para_env
146 TYPE(qs_energy_type),
POINTER :: energy
147 TYPE(qs_ks_env_type),
POINTER :: ks_env
148 TYPE(qs_rho_type),
POINTER :: rho, rho_aux_fit
149 TYPE(section_vals_type),
POINTER :: hfx_sections, input, xc_section, &
150 xc_section_admm_aux, &
153 NULLIFY (admm_env, matrix_ks, matrix_ks_aux_fit, rho_ao, matrix_sigma_x_minus_vxc, input, &
154 xc_section, xc_section_admm_aux, xc_section_admm_prim, hfx_sections, rho, &
155 dft_control, para_env, ks_env, mo_coeff, matrix_sigma_x_minus_vxc_im, matrix_ks_aux_fit_hfx, &
156 rho_aux_fit, rho_ao_aux_fit)
158 CALL timeset(routinen, handle)
162 do_admm_rpa = mp2_env%ri_rpa%do_admm
163 do_ri_sigma_x = mp2_env%ri_g0w0%do_ri_Sigma_x
164 do_kpoints_cubic_rpa = qs_env%mp2_env%ri_rpa_im_time%do_im_time_kpoints
165 do_kpoints_from_gamma = qs_env%mp2_env%ri_rpa_im_time%do_kpoints_from_Gamma
166 print_exx = mp2_env%ri_g0w0%print_exx
168 IF (do_kpoints_cubic_rpa)
THEN
169 cpassert(do_ri_sigma_x)
172 IF (do_kpoints_cubic_rpa)
THEN
176 matrix_ks_kp=matrix_ks_transl, &
179 dft_control=dft_control, &
190 matrix_ks=matrix_ks, &
193 dft_control=dft_control, &
200 IF (do_admm_rpa)
THEN
201 CALL get_admm_env(admm_env, matrix_ks_aux_fit=matrix_ks_aux_fit, rho_aux_fit=rho_aux_fit, &
202 matrix_ks_aux_fit_hfx=matrix_ks_aux_fit_hfx)
203 CALL qs_rho_get(rho_aux_fit, rho_ao=rho_ao_aux_fit)
214 nspins = dft_control%nspins
218 IF (do_kpoints_from_gamma)
THEN
220 ALLOCATE (qs_env%mp2_env%ri_g0w0%matrix_ks(nspins))
222 NULLIFY (qs_env%mp2_env%ri_g0w0%matrix_ks(ispin)%matrix)
223 ALLOCATE (qs_env%mp2_env%ri_g0w0%matrix_ks(ispin)%matrix)
224 CALL dbcsr_create(qs_env%mp2_env%ri_g0w0%matrix_ks(ispin)%matrix, &
225 template=matrix_ks(ispin)%matrix)
226 CALL dbcsr_desymmetrize(matrix_ks(ispin)%matrix, &
227 qs_env%mp2_env%ri_g0w0%matrix_ks(ispin)%matrix)
232 IF (do_kpoints_cubic_rpa)
THEN
234 CALL allocate_matrix_ks_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
235 CALL transform_matrix_ks_to_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
238 DO i_img = 1,
SIZE(matrix_ks_transl, 2)
239 CALL dbcsr_set(matrix_ks_transl(ispin, i_img)%matrix, 0.0_dp)
246 NULLIFY (matrix_sigma_x_minus_vxc)
248 IF (do_kpoints_cubic_rpa)
THEN
249 NULLIFY (matrix_sigma_x_minus_vxc_im)
256 IF (do_kpoints_cubic_rpa)
THEN
258 ALLOCATE (matrix_sigma_x_minus_vxc(ispin, ikp)%matrix)
259 CALL dbcsr_create(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, &
260 template=matrix_ks_kp_re(1, 1)%matrix, &
261 matrix_type=dbcsr_type_symmetric)
263 CALL dbcsr_copy(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, matrix_ks_kp_re(ispin, ikp)%matrix)
264 CALL dbcsr_set(matrix_ks_kp_re(ispin, ikp)%matrix, 0.0_dp)
266 ALLOCATE (matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix)
267 CALL dbcsr_create(matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix, &
268 template=matrix_ks_kp_im(1, 1)%matrix, &
269 matrix_type=dbcsr_type_antisymmetric)
271 CALL dbcsr_copy(matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix, matrix_ks_kp_im(ispin, ikp)%matrix)
272 CALL dbcsr_set(matrix_ks_kp_im(ispin, ikp)%matrix, 0.0_dp)
276 ALLOCATE (matrix_sigma_x_minus_vxc(ispin, ikp)%matrix)
277 CALL dbcsr_create(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, &
278 template=matrix_ks(1)%matrix)
280 CALL dbcsr_copy(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, matrix_ks(ispin)%matrix)
281 CALL dbcsr_set(matrix_ks(ispin)%matrix, 0.0_dp)
293 hfx_fraction = qs_env%x_data(1, 1)%general_parameter%fraction
294 qs_env%x_data(:, :)%general_parameter%fraction = 0.0_dp
304 IF (dft_control%do_admm)
THEN
321 charge_constrain_tmp = .false.
322 IF (admm_env%charge_constrain)
THEN
323 admm_env%charge_constrain = .false.
324 charge_constrain_tmp = .true.
331 IF (do_admm_rpa)
THEN
333 CALL dbcsr_set(matrix_ks_aux_fit(ispin)%matrix, 0.0_dp)
337 IF (.NOT. mp2_env%ri_g0w0%update_xc_energy)
THEN
338 energy_total = energy%total
339 energy_exc = energy%exc
340 energy_exc1 = energy%exc1
341 energy_exc_aux_fit = energy%ex
342 energy_exc1_aux_fit = energy%exc_aux_fit
343 energy_ex = energy%exc1_aux_fit
347 energy%total = energy%total - (energy%exc + energy%exc1 + energy%ex + &
348 energy%exc_aux_fit + energy%exc1_aux_fit)
354 IF (.NOT. mp2_env%ri_g0w0%update_xc_energy)
THEN
355 energy%exc = energy_exc
356 energy%exc1 = energy_exc1
357 energy%exc_aux_fit = energy_ex
358 energy%exc1_aux_fit = energy_exc_aux_fit
359 energy%ex = energy_exc1_aux_fit
360 energy%total = energy_total
367 qs_env%x_data(:, :)%general_parameter%fraction = hfx_fraction
370 IF (dft_control%do_admm)
THEN
380 IF (charge_constrain_tmp)
THEN
381 admm_env%charge_constrain = .true.
385 IF (do_kpoints_cubic_rpa)
THEN
386 CALL transform_matrix_ks_to_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
391 IF (do_kpoints_cubic_rpa)
THEN
393 CALL dbcsr_add(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, matrix_ks_kp_re(ispin, ikp)%matrix, -1.0_dp, 1.0_dp)
394 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)
397 CALL dbcsr_add(matrix_sigma_x_minus_vxc(ispin, 1)%matrix, matrix_ks(ispin)%matrix, -1.0_dp, 1.0_dp)
401 IF (do_kpoints_cubic_rpa)
THEN
403 CALL transform_sigma_x_minus_vxc_to_mo_basis(kpoints, matrix_sigma_x_minus_vxc, &
404 matrix_sigma_x_minus_vxc_im, &
405 vec_sigma_x_minus_vxc_gw, &
406 vec_sigma_x_minus_vxc_gw_im, &
407 para_env, nmo, mp2_env)
412 CALL dbcsr_set(matrix_ks(ispin)%matrix, 0.0_dp)
413 IF (do_admm_rpa)
THEN
414 CALL dbcsr_set(matrix_ks_aux_fit(ispin)%matrix, 0.0_dp)
425 IF (.NOT. do_ri_sigma_x)
THEN
427 CALL exx_pre_hfx(hfx_sections, qs_env%mp2_env%ri_rpa%x_data, qs_env%mp2_env%ri_rpa%reuse_hfx)
428 calc_ints = .NOT. qs_env%mp2_env%ri_rpa%reuse_hfx
431 DO irep = 1, n_rep_hf
432 IF (do_admm_rpa)
THEN
433 matrix_ks_2d(1:nspins, 1:1) => matrix_ks_aux_fit(1:nspins)
434 rho_ao_2d(1:nspins, 1:1) => rho_ao_aux_fit(1:nspins)
436 matrix_ks_2d(1:nspins, 1:1) => matrix_ks(1:nspins)
437 rho_ao_2d(1:nspins, 1:1) => rho_ao(1:nspins)
440 IF (qs_env%mp2_env%ri_rpa%x_data(irep, 1)%do_hfx_ri)
THEN
441 CALL hfx_ri_update_ks(qs_env, qs_env%mp2_env%ri_rpa%x_data(irep, 1)%ri_data, matrix_ks_2d, ehfx, &
442 rho_ao=rho_ao_2d, geometry_did_change=calc_ints, nspins=nspins, &
443 hf_fraction=qs_env%mp2_env%ri_rpa%x_data(irep, 1)%general_parameter%fraction)
445 IF (do_admm_rpa)
THEN
448 CALL dbcsr_copy(matrix_ks_aux_fit_hfx(ispin)%matrix, matrix_ks_2d(ispin, 1)%matrix, &
449 name=
"HF exch. part of matrix_ks_aux_fit for ADMMS")
454 rho_ao_2d, hfx_sections, &
455 para_env, calc_ints, irep, .true., &
462 IF (do_admm_rpa)
THEN
464 matrix_prim=matrix_ks, &
465 matrix_aux=matrix_ks_aux_fit, &
466 x_data=qs_env%mp2_env%ri_rpa%x_data, &
467 exc=energy_xc_admm(1), &
468 exc_aux_fit=energy_xc_admm(2), &
469 calc_forces=.false., &
473 IF (do_kpoints_from_gamma .AND. print_exx ==
gw_print_exx)
THEN
475 ALLOCATE (mat_exchange_for_kp_from_gamma(1))
478 NULLIFY (mat_exchange_for_kp_from_gamma(ispin)%matrix)
479 ALLOCATE (mat_exchange_for_kp_from_gamma(ispin)%matrix)
480 CALL dbcsr_create(mat_exchange_for_kp_from_gamma(ispin)%matrix, template=matrix_ks(ispin)%matrix)
481 CALL dbcsr_desymmetrize(matrix_ks(ispin)%matrix, mat_exchange_for_kp_from_gamma(ispin)%matrix)
486 CALL exx_post_hfx(qs_env, qs_env%mp2_env%ri_rpa%x_data, qs_env%mp2_env%ri_rpa%reuse_hfx)
493 IF (do_admm_rpa)
THEN
498 CALL dbcsr_add(matrix_sigma_x_minus_vxc(ispin, 1)%matrix, matrix_ks(ispin)%matrix, 1.0_dp, 1.0_dp)
503 IF (do_kpoints_from_gamma)
THEN
505 ALLOCATE (qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(nspins))
507 NULLIFY (qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(ispin)%matrix)
508 ALLOCATE (qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(ispin)%matrix)
509 CALL dbcsr_create(qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(ispin)%matrix, &
510 template=matrix_ks(ispin)%matrix)
512 CALL dbcsr_desymmetrize(matrix_sigma_x_minus_vxc(ispin, 1)%matrix, &
513 qs_env%mp2_env%ri_g0w0%matrix_sigma_x_minus_vxc(ispin)%matrix)
518 CALL dbcsr_desymmetrize(matrix_ks(1)%matrix, mo_coeff_b)
519 CALL dbcsr_set(mo_coeff_b, 0.0_dp)
532 ALLOCATE (vec_sigma_x_minus_vxc_gw(nmo, nspins, nkp))
533 vec_sigma_x_minus_vxc_gw = 0.0_dp
536 CALL dbcsr_set(mo_coeff_b, 0.0_dp)
541 CALL dbcsr_create(matrix_tmp, template=mo_coeff_b)
542 CALL dbcsr_copy(matrix_tmp, mo_coeff_b)
543 CALL dbcsr_set(matrix_tmp, 0.0_dp)
545 CALL dbcsr_create(matrix_tmp_2, template=mo_coeff_b)
546 CALL dbcsr_copy(matrix_tmp_2, mo_coeff_b)
547 CALL dbcsr_set(matrix_tmp_2, 0.0_dp)
550 gw_corr_lev_occ = mp2_env%ri_g0w0%corr_mos_occ
551 gw_corr_lev_virt = mp2_env%ri_g0w0%corr_mos_virt
555 IF (gw_corr_lev_occ > homo .OR. gw_corr_lev_occ < 0) gw_corr_lev_occ = homo
556 IF (gw_corr_lev_virt > dimen - homo .OR. gw_corr_lev_virt < 0) gw_corr_lev_virt = dimen - homo
558 mp2_env%ri_g0w0%corr_mos_occ = gw_corr_lev_occ
559 mp2_env%ri_g0w0%corr_mos_virt = gw_corr_lev_virt
560 ELSE IF (ispin == 2)
THEN
563 IF (mp2_env%ri_g0w0%corr_mos_occ + mp2_env%ri_g0w0%corr_mos_virt /= &
564 gw_corr_lev_occ + gw_corr_lev_virt)
THEN
565 gw_corr_lev_virt = mp2_env%ri_g0w0%corr_mos_occ + mp2_env%ri_g0w0%corr_mos_virt - gw_corr_lev_occ
567 mp2_env%ri_g0w0%corr_mos_occ_beta = gw_corr_lev_occ
568 mp2_env%ri_g0w0%corr_mos_virt_beta = gw_corr_lev_virt
572 CALL dbcsr_multiply(
'N',
'N', 1.0_dp, matrix_sigma_x_minus_vxc(ispin, 1)%matrix, &
573 mo_coeff_b, 0.0_dp, matrix_tmp, first_column=homo + 1 - gw_corr_lev_occ, &
574 last_column=homo + gw_corr_lev_virt)
576 CALL dbcsr_multiply(
'T',
'N', 1.0_dp, mo_coeff_b, &
577 matrix_tmp, 0.0_dp, matrix_tmp_2, first_row=homo + 1 - gw_corr_lev_occ, &
578 last_row=homo + gw_corr_lev_virt)
580 CALL dbcsr_get_diag(matrix_tmp_2, vec_sigma_x_minus_vxc_gw(:, ispin, 1))
582 CALL dbcsr_set(matrix_tmp, 0.0_dp)
583 CALL dbcsr_set(matrix_tmp_2, 0.0_dp)
587 CALL para_env%sum(vec_sigma_x_minus_vxc_gw)
591 CALL dbcsr_release(mo_coeff_b)
592 CALL dbcsr_release(matrix_tmp)
593 CALL dbcsr_release(matrix_tmp_2)
594 IF (do_kpoints_cubic_rpa)
THEN
601 CALL dbcsr_release_p(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix)
602 IF (do_kpoints_cubic_rpa)
THEN
603 CALL dbcsr_release_p(matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix)
608 ALLOCATE (mp2_env%ri_g0w0%vec_Sigma_x_minus_vxc_gw(nmo, nspins, nkp))
612 IF (do_kpoints_from_gamma)
THEN
614 gw_corr_lev_tot = gw_corr_lev_occ + gw_corr_lev_virt
623 ALLOCATE (eigenval_kp(nmo, 1, nspins))
629 nkp_sigma =
SIZE(eigenval_kp, 2)
631 ALLOCATE (vec_sigma_x(nmo, nkp_sigma))
632 vec_sigma_x(:, :) = 0.0_dp
635 mat_exchange_for_kp_from_gamma(1)%matrix, &
636 vec_sigma_x(homo - gw_corr_lev_occ + 1:homo + gw_corr_lev_virt, :), &
637 homo, gw_corr_lev_occ, gw_corr_lev_virt, 1)
639 CALL dbcsr_release(mat_exchange_for_kp_from_gamma(1)%matrix)
640 DEALLOCATE (mat_exchange_for_kp_from_gamma(1)%matrix)
641 DEALLOCATE (mat_exchange_for_kp_from_gamma)
643 DEALLOCATE (vec_sigma_x_minus_vxc_gw)
645 ALLOCATE (vec_sigma_x_minus_vxc_gw(nmo, nspins, nkp_sigma))
647 vec_sigma_x_minus_vxc_gw(:, 1, :) = vec_sigma_x(:, :) + &
648 qs_env%mp2_env%ri_g0w0%vec_Sigma_x_minus_vxc_gw(:, 1, :)
650 kpoints_sigma => qs_env%mp2_env%ri_rpa_im_time%kpoints_Sigma
658 IF (unit_nr > 0)
THEN
660 ALLOCATE (eigenval_kp_hf_at_dft(nmo, nkp_sigma))
661 eigenval_kp_hf_at_dft(:, :) = eigenval_kp(:, :, 1) + vec_sigma_x_minus_vxc_gw(:, 1, :)
663 min_direct_hf_at_dft_gap = 100.0_dp
665 WRITE (unit_nr,
'(T3,A)')
''
666 WRITE (unit_nr,
'(T3,A)')
'Exchange energies'
667 WRITE (unit_nr,
'(T3,A)')
'-----------------'
668 WRITE (unit_nr,
'(T3,A)')
''
669 WRITE (unit_nr,
'(T6,2A)')
'MO e_n^DFT Sigma_x-vxc e_n^HF@DFT'
670 DO ikp = 1, nkp_sigma
671 IF (nkp_sigma > 1)
THEN
672 WRITE (unit_nr,
'(T3,A)')
''
673 WRITE (unit_nr,
'(T3,A7,I3,A3,I3,A8,3F7.3,A12,3F7.3)')
'Kpoint ', ikp,
' /', nkp_sigma, &
674 ' xkp =', kpoints_sigma%xkp(1, ikp), kpoints_sigma%xkp(2, ikp), &
675 kpoints_sigma%xkp(3, ikp),
' and xkp =', -kpoints_sigma%xkp(1, ikp), &
676 -kpoints_sigma%xkp(2, ikp), -kpoints_sigma%xkp(3, ikp)
677 WRITE (unit_nr,
'(T3,A)')
''
679 DO n_level_gw = 1, gw_corr_lev_occ + gw_corr_lev_virt
681 n_level_gw_ref = n_level_gw + homo - gw_corr_lev_occ
682 IF (n_level_gw <= gw_corr_lev_occ)
THEN
688 eigval_dft = eigenval_kp(n_level_gw_ref, ikp, 1)*
evolt
689 exx_minus_vxc = real(vec_sigma_x_minus_vxc_gw(n_level_gw_ref, 1, ikp)*
evolt, kind=
dp)
690 eigval_hf_at_dft = eigenval_kp_hf_at_dft(n_level_gw_ref, ikp)*
evolt
692 WRITE (unit_nr,
'(T4,I4,3A,3F21.3,3F21.3,3F21.3)') &
693 n_level_gw_ref,
' ( ', occ_virt,
') ', eigval_dft, exx_minus_vxc, eigval_hf_at_dft
696 e_homo_gw = maxval(eigenval_kp_hf_at_dft(homo - gw_corr_lev_occ + 1:homo, ikp))
697 e_lumo_gw = minval(eigenval_kp_hf_at_dft(homo + 1:homo + gw_corr_lev_virt, ikp))
698 e_gap_gw = e_lumo_gw - e_homo_gw
699 IF (e_gap_gw < min_direct_hf_at_dft_gap) min_direct_hf_at_dft_gap = e_gap_gw
700 WRITE (unit_nr,
'(T3,A)')
''
701 WRITE (unit_nr,
'(T3,A,F53.2)')
'HF@DFT HOMO-LUMO gap (eV)', e_gap_gw*
evolt
702 WRITE (unit_nr,
'(T3,A)')
''
705 WRITE (unit_nr,
'(T3,A)')
''
706 WRITE (unit_nr,
'(T3,A)')
''
707 WRITE (unit_nr,
'(T3,A,F63.3)')
'HF@DFT direct bandgap (eV)', min_direct_hf_at_dft_gap*
evolt
709 WRITE (unit_nr,
'(T3,A)')
''
710 WRITE (unit_nr,
'(T3,A)')
'End of exchange energies'
711 WRITE (unit_nr,
'(T3,A)')
'------------------------'
712 WRITE (unit_nr,
'(T3,A)')
''
714 cpabort(
'Stop after printing exchange energies.')
724 CALL open_file(unit_number=iunit, file_name=
"exx.out")
726 really_read_line = .false.
730 READ (iunit,
'(A)') line
732 IF (line ==
" End of exchange energies ")
EXIT
734 IF (really_read_line)
THEN
736 READ (line(1:7), *) n_level_gw_ref
737 READ (line(17:40), *) tmp
739 DO ikp = 1,
SIZE(vec_sigma_x_minus_vxc_gw, 3)
740 vec_sigma_x_minus_vxc_gw(n_level_gw_ref, 1, ikp) = tmp/
evolt
745 IF (line ==
" MO Sigma_x-vxc ") really_read_line = .true.
754 mp2_env%ri_g0w0%vec_Sigma_x_minus_vxc_gw(:, :, :) = vec_sigma_x_minus_vxc_gw(:, :, :)
757 DEALLOCATE (matrix_sigma_x_minus_vxc, vec_sigma_x_minus_vxc_gw)
758 IF (do_kpoints_cubic_rpa)
THEN
759 DEALLOCATE (matrix_sigma_x_minus_vxc_im)
766 CALL timestop(handle)
781 SUBROUTINE transform_sigma_x_minus_vxc_to_mo_basis(kpoints, matrix_sigma_x_minus_vxc, &
782 matrix_sigma_x_minus_vxc_im, vec_Sigma_x_minus_vxc_gw, &
783 vec_Sigma_x_minus_vxc_gw_im, para_env, nmo, mp2_env)
785 TYPE(kpoint_type),
POINTER :: kpoints
786 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_sigma_x_minus_vxc, &
787 matrix_sigma_x_minus_vxc_im
788 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: vec_sigma_x_minus_vxc_gw, &
789 vec_sigma_x_minus_vxc_gw_im
790 TYPE(mp_para_env_type),
INTENT(IN) :: para_env
792 TYPE(mp2_type) :: mp2_env
794 CHARACTER(LEN=*),
PARAMETER :: routinen =
'transform_sigma_x_minus_vxc_to_MO_basis'
796 INTEGER :: dimen, gw_corr_lev_occ, gw_corr_lev_virt, handle, homo, i_global, iib, ikp, &
797 ispin, j_global, jjb, ncol_local, nkp, nrow_local, nspins
798 INTEGER,
DIMENSION(2) :: kp_range
799 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
800 REAL(kind=
dp) :: imval, reval
801 TYPE(cp_cfm_type) :: cfm_mos, cfm_sigma_x_minus_vxc, &
802 cfm_sigma_x_minus_vxc_mo_basis, cfm_tmp
803 TYPE(cp_fm_struct_type),
POINTER :: matrix_struct
804 TYPE(cp_fm_type) :: fwork_im, fwork_re
805 TYPE(kpoint_env_type),
POINTER :: kp
806 TYPE(mo_set_type),
POINTER :: mo_set, mo_set_im, mo_set_re
808 CALL timeset(routinen, handle)
810 mo_set => kpoints%kp_env(1)%kpoint_env%mos(1, 1)
813 nspins =
SIZE(matrix_sigma_x_minus_vxc, 1)
818 cpassert(kp_range(1) == 1 .AND. kp_range(2) == nkp)
820 ALLOCATE (vec_sigma_x_minus_vxc_gw(nmo, nspins, nkp))
821 vec_sigma_x_minus_vxc_gw = 0.0_dp
823 ALLOCATE (vec_sigma_x_minus_vxc_gw_im(nmo, nspins, nkp))
824 vec_sigma_x_minus_vxc_gw_im = 0.0_dp
831 CALL cp_cfm_create(cfm_sigma_x_minus_vxc_mo_basis, matrix_struct)
835 nrow_local=nrow_local, &
836 ncol_local=ncol_local, &
837 row_indices=row_indices, &
838 col_indices=col_indices)
843 kp => kpoints%kp_env(ikp)%kpoint_env
848 CALL copy_dbcsr_to_fm(matrix_sigma_x_minus_vxc(ispin, ikp)%matrix, fwork_re)
849 CALL copy_dbcsr_to_fm(matrix_sigma_x_minus_vxc_im(ispin, ikp)%matrix, fwork_im)
855 mo_set_re => kp%mos(1, ispin)
856 mo_set_im => kp%mos(2, ispin)
862 CALL parallel_gemm(
'N',
'N', nmo, nmo, nmo,
z_one, cfm_sigma_x_minus_vxc, &
866 CALL parallel_gemm(
'C',
'N', nmo, nmo, nmo,
z_one, cfm_mos, cfm_tmp, &
867 z_zero, cfm_sigma_x_minus_vxc_mo_basis)
869 DO jjb = 1, ncol_local
871 j_global = col_indices(jjb)
873 DO iib = 1, nrow_local
875 i_global = row_indices(iib)
877 IF (j_global == i_global .AND. i_global <= nmo)
THEN
879 reval = real(cfm_sigma_x_minus_vxc_mo_basis%local_data(iib, jjb), kind=
dp)
880 imval = aimag(cfm_sigma_x_minus_vxc_mo_basis%local_data(iib, jjb))
882 vec_sigma_x_minus_vxc_gw(i_global, ispin, ikp) = reval
883 vec_sigma_x_minus_vxc_gw_im(i_global, ispin, ikp) = imval
895 CALL para_env%sum(vec_sigma_x_minus_vxc_gw)
896 CALL para_env%sum(vec_sigma_x_minus_vxc_gw_im)
900 CALL get_mo_set(mo_set=kpoints%kp_env(1)%kpoint_env%mos(ispin, 1), &
901 homo=homo, nao=dimen)
902 gw_corr_lev_occ = mp2_env%ri_g0w0%corr_mos_occ
903 gw_corr_lev_virt = mp2_env%ri_g0w0%corr_mos_virt
906 IF (gw_corr_lev_occ > homo) gw_corr_lev_occ = homo
907 IF (gw_corr_lev_virt > dimen - homo) gw_corr_lev_virt = dimen - homo
909 mp2_env%ri_g0w0%corr_mos_occ = gw_corr_lev_occ
910 mp2_env%ri_g0w0%corr_mos_virt = gw_corr_lev_virt
911 ELSE IF (ispin == 2)
THEN
914 IF (mp2_env%ri_g0w0%corr_mos_occ + mp2_env%ri_g0w0%corr_mos_virt /= &
915 gw_corr_lev_occ + gw_corr_lev_virt)
THEN
916 gw_corr_lev_virt = mp2_env%ri_g0w0%corr_mos_occ + mp2_env%ri_g0w0%corr_mos_virt - gw_corr_lev_occ
918 mp2_env%ri_g0w0%corr_mos_occ_beta = gw_corr_lev_occ
919 mp2_env%ri_g0w0%corr_mos_virt_beta = gw_corr_lev_virt
923 CALL cp_fm_release(fwork_re)
924 CALL cp_fm_release(fwork_im)
930 CALL timestop(handle)
941 SUBROUTINE transform_matrix_ks_to_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
943 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_transl, matrix_ks_kp_re, &
945 TYPE(kpoint_type),
POINTER :: kpoints
947 CHARACTER(len=*),
PARAMETER :: routinen =
'transform_matrix_ks_to_kp'
949 INTEGER :: handle, ikp, ispin, nkp, nspin
950 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
951 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
952 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
955 CALL timeset(routinen, handle)
958 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, sab_nl=sab_nl, cell_to_index=cell_to_index)
960 cpassert(
ASSOCIATED(sab_nl))
962 nspin =
SIZE(matrix_ks_transl, 1)
967 CALL dbcsr_set(matrix_ks_kp_re(ispin, ikp)%matrix, 0.0_dp)
968 CALL dbcsr_set(matrix_ks_kp_im(ispin, ikp)%matrix, 0.0_dp)
970 cmatrix=matrix_ks_kp_im(ispin, ikp)%matrix, &
971 rsmat=matrix_ks_transl, ispin=ispin, &
972 xkp=xkp(1:3, ikp), cell_to_index=cell_to_index, sab_nl=sab_nl)
977 CALL timestop(handle)
988 SUBROUTINE allocate_matrix_ks_kp(matrix_ks_transl, matrix_ks_kp_re, matrix_ks_kp_im, kpoints)
990 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_transl, matrix_ks_kp_re, &
992 TYPE(kpoint_type),
POINTER :: kpoints
994 CHARACTER(len=*),
PARAMETER :: routinen =
'allocate_matrix_ks_kp'
996 INTEGER :: handle, ikp, ispin, nkp, nspin
997 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
998 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
999 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
1002 CALL timeset(routinen, handle)
1005 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, sab_nl=sab_nl, cell_to_index=cell_to_index)
1007 cpassert(
ASSOCIATED(sab_nl))
1009 nspin =
SIZE(matrix_ks_transl, 1)
1011 NULLIFY (matrix_ks_kp_re, matrix_ks_kp_im)
1018 ALLOCATE (matrix_ks_kp_re(ispin, ikp)%matrix)
1019 ALLOCATE (matrix_ks_kp_im(ispin, ikp)%matrix)
1021 CALL dbcsr_create(matrix_ks_kp_re(ispin, ikp)%matrix, &
1022 template=matrix_ks_transl(1, 1)%matrix, &
1023 matrix_type=dbcsr_type_symmetric)
1024 CALL dbcsr_create(matrix_ks_kp_im(ispin, ikp)%matrix, &
1025 template=matrix_ks_transl(1, 1)%matrix, &
1026 matrix_type=dbcsr_type_antisymmetric)
1031 CALL dbcsr_set(matrix_ks_kp_re(ispin, ikp)%matrix, 0.0_dp)
1032 CALL dbcsr_set(matrix_ks_kp_im(ispin, ikp)%matrix, 0.0_dp)
1037 CALL timestop(handle)
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.
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_create(matrix, matrix_struct, name)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_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...
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)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
represent the structure of a full matrix
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_create(matrix, matrix_struct, name, use_sp)
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)
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)
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.
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 setup_trunc_coulomb_pot_for_exchange_self_energy(qs_env, trunc_coulomb, rel_cutoff_trunc_coulomb_ri_x)
...
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, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, WannierCentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Get the QUICKSTEP environment.
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)
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)
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)
...