67#include "../base/base_uses.f90"
73 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
"rt_bse"
152 INTEGER :: n_spin = 1, &
155 INTEGER,
DIMENSION(2) :: n_occ = -1
159 INTEGER :: first_active_mo = 1, &
160 last_active_mo = -1, &
162 REAL(kind=
dp) :: rtbse_energy_cutoff_occ = -1.0_dp, &
163 rtbse_energy_cutoff_empty = -1.0_dp
164 LOGICAL :: active_mo_truncation = .false.
165 LOGICAL :: linearized = .false.
167 LOGICAL :: tda_active = .false.
174 LOGICAL :: tda_shift_to_first_peak = .false.
175 REAL(kind=
dp) :: omega_shift = 0.0_dp
177 LOGICAL :: debug_disable_hartree = .false., &
178 debug_disable_sex = .false.
183 LOGICAL :: rirs_kernel = .false.
189 LOGICAL :: diagnose_liouvillian_eig = .false.
191 LOGICAL :: enforce_max_dt = .false.
202 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: c_active => null()
204 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: ao_mo_workspace => null()
205 REAL(kind=
dp) :: spin_degeneracy = 2
206 REAL(kind=
dp),
DIMENSION(3) :: field = 0.0_dp
207 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: moments => null(), &
208 moments_field => null()
209 INTEGER :: sim_step = 0, &
212 sim_start_orig = 0, &
219 LOGICAL :: restart_trace_written = .false., &
220 restart_c_written = .false.
221 REAL(kind=
dp),
DIMENSION(:),
POINTER :: user_moment_ref_point => null()
222 REAL(kind=
dp) :: sim_time = 0.0_dp, &
226 sim_dt_restart = -1.0_dp, &
227 maximum_timestep = -1.0_dp, &
228 omega_max = -1.0_dp, &
229 etrs_threshold = 1.0e-7_dp, &
230 exp_accuracy = 1.0e-10_dp, &
231 ft_damping = 0.0_dp, &
234 INTEGER,
DIMENSION(:, :),
POINTER :: pol_elements => null()
241 field_section => null(), &
242 rho_section => null(), &
243 ft_section => null(), &
244 pol_section => null(), &
245 eig_section => null(), &
246 moments_section => null(), &
247 rtp_section => null()
248 LOGICAL :: restart_extracted = .false.
251 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: ham_effective => null()
252 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: ham_reference => null()
254 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: ham_reference_singleparticle => null()
257 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: eps_active => null()
260 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: eps_active_restart => null()
261 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: ham_workspace => null()
263 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: sigma_coh => null(), &
264 hartree_curr => null()
268 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: sigma_sex_ao => null()
269 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: hartree_curr_ao => null()
280 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: hartree_diag_re, hartree_diag_im
282 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: real_workspace_mo => null()
297 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues_liouvillian => null()
301 rho_new_last => null(), &
303 rho_orig => null(), &
304 rho_ao_scratch => null(), &
305 rho_delta_mo => null(), &
306 drho_probe => null(), &
309 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: rk4_coefficients => null()
318 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: rho_workspace => null()
320 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: real_workspace => null()
322 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: sigma_complex_workspace => null()
324 REAL(kind=
dp),
DIMENSION(:),
POINTER :: real_eigvals => null()
325 COMPLEX(kind=dp),
DIMENSION(:),
POINTER :: exp_eigvals => null()
329 COMPLEX(kind=dp),
DIMENSION(:, :, :),
POINTER :: moments_trace => null()
330 REAL(kind=
dp),
DIMENSION(:),
POINTER :: time_trace => null()
332 COMPLEX(kind=dp),
DIMENSION(:, :),
POINTER :: field_trace => null()
336#if defined(FTN_NO_DEFAULT_INIT)
337 TYPE(dbt_type) :: screened_dbt, &
340 t_3c_work_ri_ao__ao, &
343 TYPE(dbt_type) :: screened_dbt = dbt_type(), &
344 greens_dbt = dbt_type(), &
345 t_3c_w = dbt_type(), &
346 t_3c_work_ri_ao__ao = dbt_type(), &
347 t_3c_work2_ri_ao__ao = dbt_type()
350 INTEGER :: etrs_max_iter = 10
351 INTEGER :: ham_reference_type = 2
352 INTEGER :: mat_exp_method = 4
353 INTEGER :: unit_nr = -1
354 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: int_3c_array => null()
356 REAL(kind=
dp) :: pade_e_min = 0.0_dp, &
357 pade_e_max = 100.0_dp, &
358 pade_e_step = 0.05_dp, &
359 pade_fit_e_min = 0.0_dp, &
360 pade_fit_e_max = -1.0_dp
361 INTEGER :: pade_npoints = 0
362 LOGICAL :: pade_requested = .false.
363 COMPLEX(kind=dp),
DIMENSION(:),
POINTER :: pade_x_eval => null()
380 LOGICAL,
OPTIONAL :: linearized
385 INTEGER :: i, k, n_ov, i_spin
390 NULLIFY (rtbse_env, mo_struct)
392 IF (
PRESENT(linearized)) rtbse_env%linearized = linearized
399 dft_control=rtbse_env%dft_control, &
402 IF (.NOT.
ASSOCIATED(bs_env))
THEN
403 cpabort(
"Cannot run RT-BSE without running GW calculation (PROPERTIES) before")
406 rtbse_env%n_spin = bs_env%n_spin
409 IF (rtbse_env%n_spin > 1 .AND. .NOT. rtbse_env%linearized)
THEN
410 CALL cp_abort(__location__, &
411 "Open-shell (n_spin>1) RT-BSE is only implemented and tested for the "// &
412 "linearized propagation. Set DFT%REAL_TIME_PROPAGATION%RTBSE%LRRTBSE "// &
413 ".TRUE.; the full (non-linearized) open-shell RT-BSE path is untested.")
416 rtbse_env%n_ao = bs_env%n_ao
418 rtbse_env%n_RI = bs_env%n_RI
420 rtbse_env%n_occ(:) = bs_env%n_occ(:)
422 rtbse_env%spin_degeneracy = bs_env%spin_degeneracy
424 rtbse_env%field(:) = 0.0_dp
426 rtbse_env%sim_step = 0
427 rtbse_env%sim_time = 0
433 rtbse_env%etrs_threshold = rtbse_env%dft_control%rtp_control%eps_ener
434 rtbse_env%exp_accuracy = rtbse_env%dft_control%rtp_control%eps_exp
437 i_val=rtbse_env%ham_reference_type)
439 i_val=rtbse_env%etrs_max_iter)
441 i_val=rtbse_env%mat_exp_method)
443 r_val=rtbse_env%rtbse_energy_cutoff_occ)
445 r_val=rtbse_env%rtbse_energy_cutoff_empty)
447 l_val=rtbse_env%tda_active)
449 l_val=rtbse_env%tda_shift_to_first_peak)
451 l_val=rtbse_env%enforce_max_dt)
453 l_val=rtbse_env%debug_disable_hartree)
455 l_val=rtbse_env%debug_disable_sex)
461 l_val=rtbse_env%diagnose_liouvillian_eig)
463 r_val=bs_env%ri_rs%eps_filter_rho)
465 r_val=bs_env%ri_rs%cutoff_radius_w0)
468 rtbse_env%rtbse_energy_cutoff_occ = -1.0_dp
469 rtbse_env%rtbse_energy_cutoff_empty = -1.0_dp
470 rtbse_env%enforce_max_dt = .false.
471 rtbse_env%debug_disable_hartree = .false.
472 rtbse_env%debug_disable_sex = .false.
473 rtbse_env%tda_shift_to_first_peak = .false.
475 rtbse_env%diagnose_liouvillian_eig = .false.
476 bs_env%ri_rs%eps_filter_rho = -1.0_dp
477 bs_env%ri_rs%cutoff_radius_w0 = -1.0_dp
480 IF (.NOT. rtbse_env%tda_active) rtbse_env%tda_shift_to_first_peak = .false.
481 rtbse_env%omega_shift = 0.0_dp
483 IF (rtbse_env%tda_active .AND. .NOT. rtbse_env%linearized)
THEN
484 cpabort(
"RTBSE TDA keyword requires LINEARIZED_BSE_PROPAGATION=.TRUE.")
488 IF (rtbse_env%tda_shift_to_first_peak .AND. rtbse_env%n_spin > 1)
THEN
489 CALL cp_abort(__location__, &
490 "TDA_SHIFT_TO_FIRST_PEAK is not implemented for open-shell (n_spin>1) "// &
491 "systems - the first-peak gap estimate would mix spin channels. "// &
492 "Set TDA_SHIFT_TO_FIRST_PEAK=.FALSE. for open-shell runs.")
494 CALL check_qp_gap_sanity(rtbse_env, bs_env)
495 CALL determine_active_mo_window(rtbse_env, bs_env)
498 NULLIFY (rtbse_env%fm_struct_mo_active)
500 bs_env%fm_ks_Gamma(1)%matrix_struct%para_env, &
501 bs_env%fm_ks_Gamma(1)%matrix_struct%context, &
502 rtbse_env%mo_active, rtbse_env%mo_active)
504 NULLIFY (rtbse_env%fm_struct_ao_mo_active)
506 bs_env%fm_ks_Gamma(1)%matrix_struct%para_env, &
507 bs_env%fm_ks_Gamma(1)%matrix_struct%context, &
508 rtbse_env%n_ao, rtbse_env%mo_active)
511 IF (rtbse_env%linearized)
THEN
512 mo_struct => rtbse_env%fm_struct_mo_active
514 mo_struct => bs_env%fm_ks_Gamma(1)%matrix_struct
517 rtbse_env%unit_nr = bs_env%unit_nr
521 rtbse_env%sim_start_orig = rtbse_env%sim_start
524 rtbse_env%ft_damping = rtbse_env%dft_control%rtp_control%ft_damping
525 rtbse_env%ft_damping = rtbse_env%dft_control%rtp_control%ft_t0
526 rtbse_env%pol_elements => rtbse_env%dft_control%rtp_control%print_pol_elements
531 rtbse_env%restart_extracted = .false.
536 i_val=rtbse_env%moment_ref_type)
538 r_vals=rtbse_env%user_moment_ref_point)
545 "CURRENT print section not yet implemented for RTBSE.")
547 "E_CONSTITUENTS print section not yet implemented for RTBSE.")
549 "PROGRAM_RUN_INFO print section not yet implemented for RTBSE.")
551 "PROJECTION_MO print section not yet implemented for RTBSE.")
553 "RESTART_HISTORY print section not yet implemented for RTBSE.")
555 rtbse_env%qs_env => force_env%qs_env
556 rtbse_env%bs_env => bs_env
558 rtbse_env%pade_requested = rtbse_env%dft_control%rtp_control%pade_requested
559 rtbse_env%pade_e_min = rtbse_env%dft_control%rtp_control%pade_e_min
560 rtbse_env%pade_e_step = rtbse_env%dft_control%rtp_control%pade_e_step
561 rtbse_env%pade_e_max = rtbse_env%dft_control%rtp_control%pade_e_max
562 rtbse_env%pade_fit_e_min = rtbse_env%dft_control%rtp_control%pade_fit_e_min
563 rtbse_env%pade_fit_e_max = rtbse_env%dft_control%rtp_control%pade_fit_e_max
564 rtbse_env%pade_npoints = int((rtbse_env%pade_e_max - rtbse_env%pade_e_min)/rtbse_env%pade_e_step)
566 IF (rtbse_env%pade_requested)
THEN
567 NULLIFY (rtbse_env%pade_x_eval)
568 ALLOCATE (rtbse_env%pade_x_eval(rtbse_env%pade_npoints))
569 DO i = 1, rtbse_env%pade_npoints
570 rtbse_env%pade_x_eval(i) = cmplx(rtbse_env%pade_e_step*real(i - 1, kind=
dp), 0.0, kind=
dp)
577 NULLIFY (rtbse_env%moments)
578 ALLOCATE (rtbse_env%moments(3, rtbse_env%n_spin))
579 NULLIFY (rtbse_env%moments_field)
580 ALLOCATE (rtbse_env%moments_field(3, rtbse_env%n_spin))
581 DO i_spin = 1, rtbse_env%n_spin
583 CALL cp_fm_create(rtbse_env%moments(k, i_spin), mo_struct)
584 CALL cp_fm_create(rtbse_env%moments_field(k, i_spin), mo_struct)
591 NULLIFY (rtbse_env%rho_workspace)
592 ALLOCATE (rtbse_env%rho_workspace(4))
593 DO i = 1,
SIZE(rtbse_env%rho_workspace)
601 NULLIFY (rtbse_env%real_workspace)
602 IF (rtbse_env%linearized)
THEN
603 ALLOCATE (rtbse_env%real_workspace(2))
605 SELECT CASE (rtbse_env%mat_exp_method)
607 ALLOCATE (rtbse_env%real_workspace(4))
609 ALLOCATE (rtbse_env%real_workspace(2))
611 cpabort(
"Only exact and BCH matrix propagation implemented in RT-BSE")
614 DO i = 1,
SIZE(rtbse_env%real_workspace)
615 CALL cp_fm_create(rtbse_env%real_workspace(i), bs_env%fm_ks_Gamma(1)%matrix_struct)
618 NULLIFY (rtbse_env%sigma_complex_workspace)
619 ALLOCATE (rtbse_env%sigma_complex_workspace(1))
620 CALL cp_cfm_create(rtbse_env%sigma_complex_workspace(1), bs_env%fm_ks_Gamma(1)%matrix_struct)
621 CALL cp_cfm_set_all(rtbse_env%sigma_complex_workspace(1), cmplx(0.0_dp, 0.0_dp, kind=
dp))
623 NULLIFY (rtbse_env%rho)
624 ALLOCATE (rtbse_env%rho(rtbse_env%n_spin))
625 DO i = 1, rtbse_env%n_spin
626 CALL cp_cfm_create(rtbse_env%rho(i), matrix_struct=mo_struct)
630 IF (rtbse_env%linearized)
THEN
631 NULLIFY (rtbse_env%rho_ao_scratch)
632 ALLOCATE (rtbse_env%rho_ao_scratch(rtbse_env%n_spin))
633 DO i = 1, rtbse_env%n_spin
634 CALL cp_cfm_create(rtbse_env%rho_ao_scratch(i), matrix_struct=bs_env%fm_s_Gamma%matrix_struct)
639 CALL cp_fm_create(rtbse_env%S_fm, bs_env%fm_s_Gamma%matrix_struct)
640 CALL cp_fm_create(rtbse_env%S_inv_fm, bs_env%fm_s_Gamma%matrix_struct)
641 CALL cp_cfm_create(rtbse_env%S_cfm, bs_env%fm_s_Gamma%matrix_struct)
645 NULLIFY (rtbse_env%ham_workspace)
646 ALLOCATE (rtbse_env%ham_workspace(rtbse_env%n_spin))
647 DO i = 1, rtbse_env%n_spin
654 NULLIFY (rtbse_env%ham_reference)
655 ALLOCATE (rtbse_env%ham_reference(rtbse_env%n_spin))
656 DO i = 1, rtbse_env%n_spin
660 IF (rtbse_env%linearized)
THEN
661 NULLIFY (rtbse_env%ham_reference_singleparticle)
662 ALLOCATE (rtbse_env%ham_reference_singleparticle(rtbse_env%n_spin))
663 DO i = 1, rtbse_env%n_spin
664 CALL cp_cfm_create(rtbse_env%ham_reference_singleparticle(i), mo_struct)
666 NULLIFY (rtbse_env%eps_active)
667 ALLOCATE (rtbse_env%eps_active(rtbse_env%mo_active, rtbse_env%n_spin))
668 rtbse_env%eps_active(:, :) = 0.0_dp
672 NULLIFY (rtbse_env%ham_effective)
673 NULLIFY (rtbse_env%rho_new)
674 NULLIFY (rtbse_env%rho_new_last)
675 NULLIFY (rtbse_env%rho_M)
676 NULLIFY (rtbse_env%rho_orig)
677 ALLOCATE (rtbse_env%ham_effective(rtbse_env%n_spin))
678 ALLOCATE (rtbse_env%rho_new(rtbse_env%n_spin))
679 ALLOCATE (rtbse_env%rho_new_last(rtbse_env%n_spin))
680 ALLOCATE (rtbse_env%rho_M(rtbse_env%n_spin))
681 ALLOCATE (rtbse_env%rho_orig(rtbse_env%n_spin))
682 DO i = 1, rtbse_env%n_spin
695 IF (rtbse_env%linearized)
THEN
699 NULLIFY (rtbse_env%rk4_coefficients)
700 ALLOCATE (rtbse_env%rk4_coefficients(rtbse_env%n_spin))
701 DO i = 1, rtbse_env%n_spin
703 CALL cp_cfm_set_all(rtbse_env%rk4_coefficients(i), cmplx(0.0, 0.0, kind=
dp))
708 NULLIFY (rtbse_env%real_eigvals)
709 ALLOCATE (rtbse_env%real_eigvals(rtbse_env%n_ao))
710 rtbse_env%real_eigvals(:) = 0.0_dp
711 NULLIFY (rtbse_env%exp_eigvals)
712 ALLOCATE (rtbse_env%exp_eigvals(rtbse_env%n_ao))
713 rtbse_env%exp_eigvals(:) = cmplx(0.0, 0.0, kind=
dp)
716 NULLIFY (rtbse_env%moments_trace)
718 ALLOCATE (rtbse_env%moments_trace(rtbse_env%n_spin, 3, rtbse_env%sim_nsteps + 1), source=
z_zero)
719 NULLIFY (rtbse_env%field_trace)
720 ALLOCATE (rtbse_env%field_trace(3, rtbse_env%sim_nsteps + 1), source=
z_zero)
721 NULLIFY (rtbse_env%time_trace)
722 ALLOCATE (rtbse_env%time_trace(rtbse_env%sim_nsteps + 1), source=0.0_dp)
727 NULLIFY (rtbse_env%hartree_curr)
728 NULLIFY (rtbse_env%sigma_SEX)
729 NULLIFY (rtbse_env%sigma_COH)
730 ALLOCATE (rtbse_env%hartree_curr(rtbse_env%n_spin))
731 ALLOCATE (rtbse_env%sigma_SEX(rtbse_env%n_spin))
732 ALLOCATE (rtbse_env%sigma_COH(rtbse_env%n_spin))
733 DO i = 1, rtbse_env%n_spin
742 IF (rtbse_env%linearized)
THEN
743 NULLIFY (rtbse_env%hartree_curr_ao)
744 NULLIFY (rtbse_env%sigma_SEX_ao)
745 ALLOCATE (rtbse_env%hartree_curr_ao(rtbse_env%n_spin))
746 ALLOCATE (rtbse_env%sigma_SEX_ao(rtbse_env%n_spin))
747 DO i = 1, rtbse_env%n_spin
748 CALL cp_cfm_create(rtbse_env%sigma_SEX_ao(i), bs_env%fm_ks_Gamma(1)%matrix_struct)
749 CALL cp_fm_create(rtbse_env%hartree_curr_ao(i), bs_env%fm_ks_Gamma(1)%matrix_struct)
754 NULLIFY (rtbse_env%real_workspace_mo)
755 ALLOCATE (rtbse_env%real_workspace_mo(2))
756 DO i = 1,
SIZE(rtbse_env%real_workspace_mo)
757 CALL cp_fm_create(rtbse_env%real_workspace_mo(i), rtbse_env%fm_struct_mo_active)
760 NULLIFY (rtbse_env%ao_mo_workspace)
761 ALLOCATE (rtbse_env%ao_mo_workspace(1))
762 CALL cp_fm_create(rtbse_env%ao_mo_workspace(1), rtbse_env%fm_struct_ao_mo_active)
766 NULLIFY (rtbse_env%C_active)
767 ALLOCATE (rtbse_env%C_active(rtbse_env%n_spin))
768 DO i = 1, rtbse_env%n_spin
769 CALL cp_fm_create(rtbse_env%C_active(i), rtbse_env%fm_struct_ao_mo_active)
774 NULLIFY (rtbse_env%rho_delta_mo)
775 ALLOCATE (rtbse_env%rho_delta_mo(rtbse_env%n_spin))
776 DO i = 1, rtbse_env%n_spin
777 CALL cp_cfm_create(rtbse_env%rho_delta_mo(i), rtbse_env%fm_struct_mo_active)
778 CALL cp_cfm_set_all(rtbse_env%rho_delta_mo(i), cmplx(0.0_dp, 0.0_dp, kind=
dp))
782 IF (.NOT. rtbse_env%debug_disable_hartree)
THEN
783 CALL cp_cfm_create(rtbse_env%rho_total_ao_scratch, bs_env%fm_s_Gamma%matrix_struct)
784 CALL cp_cfm_create(rtbse_env%hartree_total_ao, bs_env%fm_ks_Gamma(1)%matrix_struct)
785 CALL cp_cfm_set_all(rtbse_env%rho_total_ao_scratch, cmplx(0.0_dp, 0.0_dp, kind=
dp))
786 CALL cp_cfm_set_all(rtbse_env%hartree_total_ao, cmplx(0.0_dp, 0.0_dp, kind=
dp))
792 IF (rtbse_env%diagnose_liouvillian_eig)
THEN
796 DO i = 1, rtbse_env%n_spin
797 n_ov = n_ov + (rtbse_env%n_occ(i) - rtbse_env%first_active_mo + 1)* &
798 (rtbse_env%last_active_mo - rtbse_env%n_occ(i))
800 NULLIFY (rtbse_env%fm_struct_ov_pairs)
802 bs_env%fm_ks_Gamma(1)%matrix_struct%para_env, &
803 bs_env%fm_ks_Gamma(1)%matrix_struct%context, &
805 ALLOCATE (rtbse_env%drho_probe(rtbse_env%n_spin))
806 ALLOCATE (rtbse_env%L_drho(rtbse_env%n_spin))
807 DO i = 1, rtbse_env%n_spin
808 CALL cp_cfm_create(rtbse_env%drho_probe(i), rtbse_env%fm_struct_mo_active)
809 CALL cp_cfm_create(rtbse_env%L_drho(i), rtbse_env%fm_struct_mo_active)
810 CALL cp_cfm_set_all(rtbse_env%drho_probe(i), cmplx(0.0_dp, 0.0_dp, kind=
dp))
813 CALL cp_cfm_create(rtbse_env%L_pairs, rtbse_env%fm_struct_ov_pairs)
814 CALL cp_cfm_create(rtbse_env%eigvecs_pairs, rtbse_env%fm_struct_ov_pairs)
816 CALL cp_cfm_set_all(rtbse_env%eigvecs_pairs, cmplx(0.0_dp, 0.0_dp, kind=
dp))
817 NULLIFY (rtbse_env%eigenvalues_liouvillian)
818 ALLOCATE (rtbse_env%eigenvalues_liouvillian(n_ov))
819 rtbse_env%eigenvalues_liouvillian = 0.0_dp
821 IF (.NOT. rtbse_env%tda_active)
THEN
822 CALL cp_cfm_create(rtbse_env%A_mat, rtbse_env%fm_struct_ov_pairs)
823 CALL cp_cfm_create(rtbse_env%B_mat, rtbse_env%fm_struct_ov_pairs)
824 CALL cp_cfm_create(rtbse_env%AmB_scratch, rtbse_env%fm_struct_ov_pairs)
825 CALL cp_cfm_create(rtbse_env%ApB_scratch, rtbse_env%fm_struct_ov_pairs)
835 CALL create_sigma_workspace(rtbse_env)
838 CALL create_hartree_ri_workspace(rtbse_env)
848 SUBROUTINE cp_cfm_release_pa1(matrices)
849 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: matrices
852 DO i = 1,
SIZE(matrices)
855 DEALLOCATE (matrices)
857 END SUBROUTINE cp_cfm_release_pa1
868 CALL cp_cfm_release_pa1(rtbse_env%ham_effective)
869 CALL cp_cfm_release_pa1(rtbse_env%ham_workspace)
871 CALL cp_cfm_release_pa1(rtbse_env%sigma_SEX)
873 CALL cp_cfm_release_pa1(rtbse_env%ham_reference)
874 IF (
ASSOCIATED(rtbse_env%ham_reference_singleparticle))
THEN
875 CALL cp_cfm_release_pa1(rtbse_env%ham_reference_singleparticle)
877 IF (
ASSOCIATED(rtbse_env%eps_active))
DEALLOCATE (rtbse_env%eps_active)
878 IF (
ASSOCIATED(rtbse_env%eps_active_restart))
DEALLOCATE (rtbse_env%eps_active_restart)
879 CALL cp_cfm_release_pa1(rtbse_env%rho)
880 CALL cp_cfm_release_pa1(rtbse_env%rho_workspace)
881 CALL cp_cfm_release_pa1(rtbse_env%rho_new)
882 CALL cp_cfm_release_pa1(rtbse_env%rho_new_last)
883 CALL cp_cfm_release_pa1(rtbse_env%rho_M)
884 CALL cp_cfm_release_pa1(rtbse_env%rho_orig)
885 IF (
ASSOCIATED(rtbse_env%rk4_coefficients))
THEN
886 CALL cp_cfm_release_pa1(rtbse_env%rk4_coefficients)
889 IF (
ASSOCIATED(rtbse_env%sigma_complex_workspace))
CALL cp_cfm_release_pa1(rtbse_env%sigma_complex_workspace)
897 CALL release_sigma_workspace(rtbse_env)
899 CALL release_hartree_ri_workspace(rtbse_env)
901 DEALLOCATE (rtbse_env%real_eigvals)
902 DEALLOCATE (rtbse_env%exp_eigvals)
903 DEALLOCATE (rtbse_env%moments_trace)
904 DEALLOCATE (rtbse_env%field_trace)
905 DEALLOCATE (rtbse_env%time_trace)
907 IF (
ASSOCIATED(rtbse_env%pol_elements))
DEALLOCATE (rtbse_env%pol_elements)
908 IF (
ASSOCIATED(rtbse_env%pade_x_eval))
DEALLOCATE (rtbse_env%pade_x_eval)
913 IF (
ASSOCIATED(rtbse_env%rho_ao_scratch))
CALL cp_cfm_release_pa1(rtbse_env%rho_ao_scratch)
914 IF (
ASSOCIATED(rtbse_env%sigma_SEX_ao))
CALL cp_cfm_release_pa1(rtbse_env%sigma_SEX_ao)
915 IF (
ASSOCIATED(rtbse_env%hartree_curr_ao))
CALL cp_fm_release(rtbse_env%hartree_curr_ao)
916 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
CALL cp_fm_release(rtbse_env%real_workspace_mo)
917 IF (
ASSOCIATED(rtbse_env%ao_mo_workspace))
CALL cp_fm_release(rtbse_env%ao_mo_workspace)
918 IF (
ASSOCIATED(rtbse_env%C_active))
CALL cp_fm_release(rtbse_env%C_active)
919 IF (
ASSOCIATED(rtbse_env%rho_delta_mo))
CALL cp_cfm_release_pa1(rtbse_env%rho_delta_mo)
923 IF (rtbse_env%linearized .AND. .NOT. rtbse_env%debug_disable_hartree)
THEN
928 IF (
ALLOCATED(rtbse_env%hartree_diag_re))
DEALLOCATE (rtbse_env%hartree_diag_re)
929 IF (
ALLOCATED(rtbse_env%hartree_diag_im))
DEALLOCATE (rtbse_env%hartree_diag_im)
931 IF (rtbse_env%diagnose_liouvillian_eig)
THEN
932 IF (
ASSOCIATED(rtbse_env%drho_probe))
CALL cp_cfm_release_pa1(rtbse_env%drho_probe)
933 IF (
ASSOCIATED(rtbse_env%L_drho))
CALL cp_cfm_release_pa1(rtbse_env%L_drho)
936 IF (
ASSOCIATED(rtbse_env%eigenvalues_liouvillian))
DEALLOCATE (rtbse_env%eigenvalues_liouvillian)
937 IF (.NOT. rtbse_env%tda_active)
THEN
943 IF (
ASSOCIATED(rtbse_env%fm_struct_ov_pairs))
THEN
948 IF (
ASSOCIATED(rtbse_env%fm_struct_mo_active))
THEN
951 IF (
ASSOCIATED(rtbse_env%fm_struct_ao_mo_active))
THEN
955 DEALLOCATE (rtbse_env)
970 SUBROUTINE check_qp_gap_sanity(rtbse_env, bs_env)
974 INTEGER :: homo, ispin
975 REAL(kind=
dp) :: gap, gap_scf
979 DO ispin = 1, rtbse_env%n_spin
980 homo = rtbse_env%n_occ(ispin)
981 IF (homo < 1 .OR. homo >= rtbse_env%n_ao) cycle
983 gap = minval(bs_env%eigenval_GW(homo + 1:rtbse_env%n_ao, 1, ispin)) - &
984 maxval(bs_env%eigenval_GW(1:homo, 1, ispin))
985 gap_scf = minval(bs_env%eigenval_scf_Gamma(homo + 1:rtbse_env%n_ao, ispin)) - &
986 maxval(bs_env%eigenval_scf_Gamma(1:homo, ispin))
990 CALL cp_abort(__location__, &
991 "RTBSE: G0W0 gap of spin "//trim(adjustl(
cp_to_string(ispin)))// &
993 " eV): propagating an inverted spectrum is meaningless. Check the GW "// &
994 "numerical parameters, or use RTBSE_HAMILTONIAN KS.")
996 CALL cp_abort(__location__, &
997 "RTBSE: G0W0 gap of spin "//trim(adjustl(
cp_to_string(ispin)))// &
998 " is implausibly large ("// &
1000 "has likely diverged. Check the GW numerical parameters, or use "// &
1001 "RTBSE_HAMILTONIAN KS.")
1005 END SUBROUTINE check_qp_gap_sanity
1019 SUBROUTINE determine_active_mo_window(rtbse_env, bs_env)
1022 CHARACTER(LEN=*),
PARAMETER :: routinen =
"determine_active_mo_window"
1024 INTEGER :: handle, ispin, n_ao_full
1025 LOGICAL :: spins_differ, do_truncation
1026 REAL(kind=
dp) :: cutoff_occ, cutoff_empty
1030 CALL timeset(routinen, handle)
1032 n_ao_full = rtbse_env%n_ao
1033 cutoff_occ = rtbse_env%rtbse_energy_cutoff_occ
1034 cutoff_empty = rtbse_env%rtbse_energy_cutoff_empty
1035 do_truncation = rtbse_env%linearized .AND. (cutoff_occ > 0.0_dp .OR. cutoff_empty > 0.0_dp)
1038 rtbse_env%first_active_mo = 1
1039 rtbse_env%last_active_mo = n_ao_full
1040 rtbse_env%mo_active = n_ao_full
1041 rtbse_env%active_mo_truncation = .false.
1043 IF (.NOT. do_truncation)
THEN
1044 CALL timestop(handle)
1048 ALLOCATE (spin_windows(rtbse_env%n_spin))
1049 DO ispin = 1, rtbse_env%n_spin
1054 rtbse_env%n_occ(ispin), cutoff_occ, cutoff_empty, &
1055 spin_windows(ispin))
1059 IF (spins_differ)
THEN
1060 cpwarn(
"RTBSE: spin-resolved active MO cutoff candidates differ; using combined window.")
1063 rtbse_env%first_active_mo = combined_window%first_mo
1064 rtbse_env%last_active_mo = combined_window%last_mo
1065 rtbse_env%mo_active = combined_window%last_mo - combined_window%first_mo + 1
1066 rtbse_env%active_mo_truncation = (rtbse_env%mo_active < n_ao_full)
1068 DEALLOCATE (spin_windows)
1069 CALL timestop(handle)
1070 END SUBROUTINE determine_active_mo_window
1079 SUBROUTINE create_hartree_ri_workspace(rtbse_env)
1089 IF (rtbse_env%rirs_kernel)
RETURN
1091 CALL get_qs_env(rtbse_env%qs_env, bs_env=bs_env)
1093 CALL dbcsr_create(rtbse_env%rho_dbcsr, name=
"Sparse density", template=bs_env%mat_ao_ao%matrix)
1094 CALL dbcsr_create(rtbse_env%v_ao_dbcsr, name=
"Sparse Hartree", template=bs_env%mat_ao_ao%matrix)
1096 CALL create_hartree_ri_3c(rtbse_env%rho_dbcsr, rtbse_env%int_3c_array, rtbse_env%n_ao, rtbse_env%n_RI, &
1097 bs_env%basis_set_AO, bs_env%basis_set_RI, bs_env%i_RI_start_from_atom, &
1098 bs_env%ri_metric, rtbse_env%qs_env, rtbse_env%unit_nr)
1099 END SUBROUTINE create_hartree_ri_workspace
1115 i_RI_start_from_atom, ri_metric, qs_env, unit_nr)
1117 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: int_3c
1118 INTEGER :: n_ao, n_ri
1121 INTEGER,
DIMENSION(:) :: i_ri_start_from_atom
1122 TYPE(libint_potential_type) :: ri_metric
1125 REAL(kind=
dp) :: size_mb
1126 INTEGER :: nblkrows_local, &
1138 INTEGER,
DIMENSION(:),
POINTER :: local_blk_rows, &
1143 size_mb = real(n_ao, kind=
dp)*real(n_ao, kind=
dp)*real(n_ri, kind=
dp)* &
1144 REAL(storage_size(size_mb), kind=
dp)/8.0_dp/1024.0_dp/1024.0_dp
1145 IF (unit_nr > 0)
WRITE (unit_nr,
'(A44,E32.2E3,A4)') &
1146 " RTBSE| Approximate size of the 3c integrals", size_mb,
" MiB"
1149 CALL dbcsr_get_info(rho_dbcsr, nblkrows_local=nblkrows_local, nblkcols_local=nblkcols_local)
1151 CALL dbcsr_get_info(rho_dbcsr, local_rows=local_blk_rows, local_cols=local_blk_cols)
1153 CALL dbcsr_get_info(rho_dbcsr, row_blk_size=row_blk_size, col_blk_size=col_blk_size)
1157 DO i_blk_local = 1, nblkrows_local
1158 nrows_local = nrows_local + row_blk_size(local_blk_rows(i_blk_local))
1161 DO j_blk_local = 1, nblkcols_local
1162 ncols_local = ncols_local + col_blk_size(local_blk_cols(j_blk_local))
1166 ALLOCATE (int_3c(nrows_local, ncols_local, n_ri))
1169 row_local_offset = 1
1170 DO i_blk_local = 1, nblkrows_local
1171 col_local_offset = 1
1172 DO j_blk_local = 1, nblkcols_local
1173 start_row_index = row_local_offset
1174 end_row_index = start_row_index + row_blk_size(local_blk_rows(i_blk_local)) - 1
1175 start_col_index = col_local_offset
1176 end_col_index = start_col_index + col_blk_size(local_blk_cols(j_blk_local)) - 1
1178 start_col_index:end_col_index, &
1180 qs_env, potential_parameter=ri_metric, &
1181 basis_j=basis_set_ao, basis_k=basis_set_ao, &
1182 basis_i=basis_set_ri, &
1183 atom_j=local_blk_rows(i_blk_local), &
1184 atom_k=local_blk_cols(j_blk_local), &
1185 i_bf_start_from_atom=i_ri_start_from_atom)
1186 col_local_offset = col_local_offset + col_blk_size(local_blk_cols(j_blk_local))
1188 row_local_offset = row_local_offset + row_blk_size(local_blk_rows(i_blk_local))
1197 SUBROUTINE release_hartree_ri_workspace(rtbse_env)
1203 IF (.NOT. rtbse_env%rirs_kernel)
THEN
1204 DEALLOCATE (rtbse_env%int_3c_array)
1209 END SUBROUTINE release_hartree_ri_workspace
1216 SUBROUTINE create_sigma_workspace(rtbse_env)
1222 IF (rtbse_env%rirs_kernel)
RETURN
1225 rtbse_env%t_3c_w, rtbse_env%t_3c_work_RI_AO__AO, &
1226 rtbse_env%t_3c_work2_RI_AO__AO, rtbse_env%greens_dbt)
1227 END SUBROUTINE create_sigma_workspace
1238 work_dbt_3c_1, work_dbt_3c_2, work_dbt_2c)
1241 TYPE(dbt_type) :: screened_dbt, &
1251 CALL dbt_create(bs_env%t_RI__AO_AO, int_3c_dbt)
1255 CALL dbt_create(bs_env%t_RI_AO__AO, work_dbt_3c_1)
1257 CALL dbt_create(bs_env%t_RI_AO__AO, work_dbt_3c_2)
1260 CALL dbcsr_create(screened_dbcsr, name=
"W", template=bs_env%mat_RI_RI%matrix)
1261 CALL dbt_create(screened_dbcsr, screened_dbt)
1263 CALL dbt_create(bs_env%mat_ao_ao%matrix, work_dbt_2c)
1271 SUBROUTINE release_sigma_workspace(rtbse_env)
1275 IF (rtbse_env%rirs_kernel)
RETURN
1277 CALL dbt_destroy(rtbse_env%t_3c_w)
1278 CALL dbt_destroy(rtbse_env%t_3c_work_RI_AO__AO)
1279 CALL dbt_destroy(rtbse_env%t_3c_work2_RI_AO__AO)
1280 CALL dbt_destroy(rtbse_env%screened_dbt)
1281 CALL dbt_destroy(rtbse_env%greens_dbt)
1283 END SUBROUTINE release_sigma_workspace
1292 alpha, matrix_r, matrix_c, beta, res)
1294 CHARACTER(len=1) :: trans_r, trans_c
1295 INTEGER :: na, nb, nc
1298 REAL(kind=
dp) :: alpha, beta
1301 TYPE(
cp_fm_type) :: work_re, work_im, res_re, res_im
1302 REAL(kind=
dp) :: i_unit
1303 CHARACTER(len=1) :: trans_cr
1310 SELECT CASE (trans_c)
1323 alpha, matrix_r, work_re, beta, res_re)
1325 i_unit*alpha, matrix_r, work_im, beta, res_im)
1341 alpha, matrix_c, matrix_r, beta, res)
1343 CHARACTER(len=1) :: trans_c, trans_r
1344 INTEGER :: na, nb, nc
1347 REAL(kind=
dp) :: alpha, beta
1350 TYPE(
cp_fm_type) :: work_re, work_im, res_re, res_im
1351 REAL(kind=
dp) :: i_unit
1352 CHARACTER(len=1) :: trans_cr
1359 SELECT CASE (trans_c)
1372 alpha, work_re, matrix_r, beta, res_re)
1374 i_unit*alpha, work_im, matrix_r, beta, res_im)
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_fm_to_cfm(msourcer, msourcei, mtarget)
Construct a complex full matrix by taking its real and imaginary parts from two separate real-value f...
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
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_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_release(matrix)
...
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
This is the start of a dbt_api, all publically needed functions are exported here....
Interface for the force calculations.
Routines from paper [Graml2024].
subroutine, public compute_3c_integrals(qs_env, bs_env, t_3c, atoms_ao_1, atoms_ao_2, atoms_ri)
...
Utility method to build 3-center integrals for small cell GW.
subroutine, public build_3c_integral_block(int_3c, qs_env, potential_parameter, basis_j, basis_k, basis_i, cell_j, cell_k, cell_i, atom_j, atom_k, atom_i, j_bf_start_from_atom, k_bf_start_from_atom, i_bf_start_from_atom)
...
subroutine, public rtbse_resolve_rirs_flag(qs_env, bs_env, rirs_kernel)
Resolve the linRTBSE RI-RS kernel switch from the KERNEL_RI input and the GW default.
Defines the basic variable types.
integer, parameter, public dp
2- and 3-center electron repulsion integral routines based on libint2 Currently available operators: ...
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_zero
Common selection and union operations for contiguous molecular-orbital windows.
subroutine, public combine_mo_windows(spin_windows, combined_window, windows_differ)
Forms the smallest contiguous window covering all supplied spin windows.
subroutine, public determine_mo_window(eigenvalues, n_mo, n_occ, cutoff_occ, cutoff_empty, window)
Selects one contiguous MO window from an ordered reference spectrum.
basic linear algebra operations for full matrixes
Definition of physical constants:
real(kind=dp), parameter, public evolt
real(kind=dp), parameter, public max_qp_gap
real(kind=dp), parameter, public eps_qp_gap
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.
Utility methods to build 3-center integral tensors of various types.
subroutine, public neighbor_list_3c_destroy(ijk_list)
Destroy 3c neighborlist.
Data storage and other types for propagation via RT-BSE method.
subroutine, public create_rtbse_env(rtbse_env, force_env, linearized)
Allocates structures and prepares rtbse_env for run.
subroutine, public release_rtbse_env(rtbse_env)
Releases the environment allocated structures.
subroutine, public create_hartree_ri_3c(rho_dbcsr, int_3c, n_ao, n_ri, basis_set_ao, basis_set_ri, i_ri_start_from_atom, ri_metric, qs_env, unit_nr)
Separated method for allocating the 3c integrals for RI Hartree.
subroutine, public multiply_cfm_fm(trans_c, trans_r, na, nb, nc, alpha, matrix_c, matrix_r, beta, res)
Multiplies complex matrix by a real matrix from the right.
subroutine, public create_sigma_workspace_qs_only(qs_env, screened_dbt, screened_dbcsr, int_3c_dbt, work_dbt_3c_1, work_dbt_3c_2, work_dbt_2c)
Allocates the workspaces for self-energy determination routine.
subroutine, public multiply_fm_cfm(trans_r, trans_c, na, nb, nc, alpha, matrix_r, matrix_c, beta, res)
Multiplies real matrix by a complex matrix from the right.
Types and set_get for real time propagation depending on runtype and diagonalization method different...
subroutine, public warn_section_unused(section, subsection_name, error_message)
Warn about unused sections of the print section - only implemented for some of the methods.
Represent a complex full matrix.
keeps the information about the structure of a full matrix
wrapper to abstract the force evaluation of the various methods