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)
464 rtbse_env%rtbse_energy_cutoff_occ = -1.0_dp
465 rtbse_env%rtbse_energy_cutoff_empty = -1.0_dp
466 rtbse_env%enforce_max_dt = .false.
467 rtbse_env%debug_disable_hartree = .false.
468 rtbse_env%debug_disable_sex = .false.
469 rtbse_env%tda_shift_to_first_peak = .false.
471 rtbse_env%diagnose_liouvillian_eig = .false.
474 IF (.NOT. rtbse_env%tda_active) rtbse_env%tda_shift_to_first_peak = .false.
475 rtbse_env%omega_shift = 0.0_dp
477 IF (rtbse_env%tda_active .AND. .NOT. rtbse_env%linearized)
THEN
478 cpabort(
"RTBSE TDA keyword requires LINEARIZED_BSE_PROPAGATION=.TRUE.")
482 IF (rtbse_env%tda_shift_to_first_peak .AND. rtbse_env%n_spin > 1)
THEN
483 CALL cp_abort(__location__, &
484 "TDA_SHIFT_TO_FIRST_PEAK is not implemented for open-shell (n_spin>1) "// &
485 "systems - the first-peak gap estimate would mix spin channels. "// &
486 "Set TDA_SHIFT_TO_FIRST_PEAK=.FALSE. for open-shell runs.")
488 CALL check_qp_gap_sanity(rtbse_env, bs_env)
489 CALL determine_active_mo_window(rtbse_env, bs_env)
492 NULLIFY (rtbse_env%fm_struct_mo_active)
494 bs_env%fm_ks_Gamma(1)%matrix_struct%para_env, &
495 bs_env%fm_ks_Gamma(1)%matrix_struct%context, &
496 rtbse_env%mo_active, rtbse_env%mo_active)
498 NULLIFY (rtbse_env%fm_struct_ao_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%n_ao, rtbse_env%mo_active)
505 IF (rtbse_env%linearized)
THEN
506 mo_struct => rtbse_env%fm_struct_mo_active
508 mo_struct => bs_env%fm_ks_Gamma(1)%matrix_struct
511 rtbse_env%unit_nr = bs_env%unit_nr
515 rtbse_env%sim_start_orig = rtbse_env%sim_start
518 rtbse_env%ft_damping = rtbse_env%dft_control%rtp_control%ft_damping
519 rtbse_env%ft_damping = rtbse_env%dft_control%rtp_control%ft_t0
520 rtbse_env%pol_elements => rtbse_env%dft_control%rtp_control%print_pol_elements
525 rtbse_env%restart_extracted = .false.
530 i_val=rtbse_env%moment_ref_type)
532 r_vals=rtbse_env%user_moment_ref_point)
539 "CURRENT print section not yet implemented for RTBSE.")
541 "E_CONSTITUENTS print section not yet implemented for RTBSE.")
543 "PROGRAM_RUN_INFO print section not yet implemented for RTBSE.")
545 "PROJECTION_MO print section not yet implemented for RTBSE.")
547 "RESTART_HISTORY print section not yet implemented for RTBSE.")
549 rtbse_env%qs_env => force_env%qs_env
550 rtbse_env%bs_env => bs_env
552 rtbse_env%pade_requested = rtbse_env%dft_control%rtp_control%pade_requested
553 rtbse_env%pade_e_min = rtbse_env%dft_control%rtp_control%pade_e_min
554 rtbse_env%pade_e_step = rtbse_env%dft_control%rtp_control%pade_e_step
555 rtbse_env%pade_e_max = rtbse_env%dft_control%rtp_control%pade_e_max
556 rtbse_env%pade_fit_e_min = rtbse_env%dft_control%rtp_control%pade_fit_e_min
557 rtbse_env%pade_fit_e_max = rtbse_env%dft_control%rtp_control%pade_fit_e_max
558 rtbse_env%pade_npoints = int((rtbse_env%pade_e_max - rtbse_env%pade_e_min)/rtbse_env%pade_e_step)
560 IF (rtbse_env%pade_requested)
THEN
561 NULLIFY (rtbse_env%pade_x_eval)
562 ALLOCATE (rtbse_env%pade_x_eval(rtbse_env%pade_npoints))
563 DO i = 1, rtbse_env%pade_npoints
564 rtbse_env%pade_x_eval(i) = cmplx(rtbse_env%pade_e_step*real(i - 1, kind=
dp), 0.0, kind=
dp)
571 NULLIFY (rtbse_env%moments)
572 ALLOCATE (rtbse_env%moments(3, rtbse_env%n_spin))
573 NULLIFY (rtbse_env%moments_field)
574 ALLOCATE (rtbse_env%moments_field(3, rtbse_env%n_spin))
575 DO i_spin = 1, rtbse_env%n_spin
577 CALL cp_fm_create(rtbse_env%moments(k, i_spin), mo_struct)
578 CALL cp_fm_create(rtbse_env%moments_field(k, i_spin), mo_struct)
585 NULLIFY (rtbse_env%rho_workspace)
586 ALLOCATE (rtbse_env%rho_workspace(4))
587 DO i = 1,
SIZE(rtbse_env%rho_workspace)
595 NULLIFY (rtbse_env%real_workspace)
596 IF (rtbse_env%linearized)
THEN
597 ALLOCATE (rtbse_env%real_workspace(2))
599 SELECT CASE (rtbse_env%mat_exp_method)
601 ALLOCATE (rtbse_env%real_workspace(4))
603 ALLOCATE (rtbse_env%real_workspace(2))
605 cpabort(
"Only exact and BCH matrix propagation implemented in RT-BSE")
608 DO i = 1,
SIZE(rtbse_env%real_workspace)
609 CALL cp_fm_create(rtbse_env%real_workspace(i), bs_env%fm_ks_Gamma(1)%matrix_struct)
612 NULLIFY (rtbse_env%sigma_complex_workspace)
613 ALLOCATE (rtbse_env%sigma_complex_workspace(1))
614 CALL cp_cfm_create(rtbse_env%sigma_complex_workspace(1), bs_env%fm_ks_Gamma(1)%matrix_struct)
615 CALL cp_cfm_set_all(rtbse_env%sigma_complex_workspace(1), cmplx(0.0_dp, 0.0_dp, kind=
dp))
617 NULLIFY (rtbse_env%rho)
618 ALLOCATE (rtbse_env%rho(rtbse_env%n_spin))
619 DO i = 1, rtbse_env%n_spin
620 CALL cp_cfm_create(rtbse_env%rho(i), matrix_struct=mo_struct)
624 IF (rtbse_env%linearized)
THEN
625 NULLIFY (rtbse_env%rho_ao_scratch)
626 ALLOCATE (rtbse_env%rho_ao_scratch(rtbse_env%n_spin))
627 DO i = 1, rtbse_env%n_spin
628 CALL cp_cfm_create(rtbse_env%rho_ao_scratch(i), matrix_struct=bs_env%fm_s_Gamma%matrix_struct)
633 CALL cp_fm_create(rtbse_env%S_fm, bs_env%fm_s_Gamma%matrix_struct)
634 CALL cp_fm_create(rtbse_env%S_inv_fm, bs_env%fm_s_Gamma%matrix_struct)
635 CALL cp_cfm_create(rtbse_env%S_cfm, bs_env%fm_s_Gamma%matrix_struct)
639 NULLIFY (rtbse_env%ham_workspace)
640 ALLOCATE (rtbse_env%ham_workspace(rtbse_env%n_spin))
641 DO i = 1, rtbse_env%n_spin
648 NULLIFY (rtbse_env%ham_reference)
649 ALLOCATE (rtbse_env%ham_reference(rtbse_env%n_spin))
650 DO i = 1, rtbse_env%n_spin
654 IF (rtbse_env%linearized)
THEN
655 NULLIFY (rtbse_env%ham_reference_singleparticle)
656 ALLOCATE (rtbse_env%ham_reference_singleparticle(rtbse_env%n_spin))
657 DO i = 1, rtbse_env%n_spin
658 CALL cp_cfm_create(rtbse_env%ham_reference_singleparticle(i), mo_struct)
660 NULLIFY (rtbse_env%eps_active)
661 ALLOCATE (rtbse_env%eps_active(rtbse_env%mo_active, rtbse_env%n_spin))
662 rtbse_env%eps_active(:, :) = 0.0_dp
666 NULLIFY (rtbse_env%ham_effective)
667 NULLIFY (rtbse_env%rho_new)
668 NULLIFY (rtbse_env%rho_new_last)
669 NULLIFY (rtbse_env%rho_M)
670 NULLIFY (rtbse_env%rho_orig)
671 ALLOCATE (rtbse_env%ham_effective(rtbse_env%n_spin))
672 ALLOCATE (rtbse_env%rho_new(rtbse_env%n_spin))
673 ALLOCATE (rtbse_env%rho_new_last(rtbse_env%n_spin))
674 ALLOCATE (rtbse_env%rho_M(rtbse_env%n_spin))
675 ALLOCATE (rtbse_env%rho_orig(rtbse_env%n_spin))
676 DO i = 1, rtbse_env%n_spin
689 IF (rtbse_env%linearized)
THEN
693 NULLIFY (rtbse_env%rk4_coefficients)
694 ALLOCATE (rtbse_env%rk4_coefficients(rtbse_env%n_spin))
695 DO i = 1, rtbse_env%n_spin
697 CALL cp_cfm_set_all(rtbse_env%rk4_coefficients(i), cmplx(0.0, 0.0, kind=
dp))
702 NULLIFY (rtbse_env%real_eigvals)
703 ALLOCATE (rtbse_env%real_eigvals(rtbse_env%n_ao))
704 rtbse_env%real_eigvals(:) = 0.0_dp
705 NULLIFY (rtbse_env%exp_eigvals)
706 ALLOCATE (rtbse_env%exp_eigvals(rtbse_env%n_ao))
707 rtbse_env%exp_eigvals(:) = cmplx(0.0, 0.0, kind=
dp)
710 NULLIFY (rtbse_env%moments_trace)
712 ALLOCATE (rtbse_env%moments_trace(rtbse_env%n_spin, 3, rtbse_env%sim_nsteps + 1), source=
z_zero)
713 NULLIFY (rtbse_env%field_trace)
714 ALLOCATE (rtbse_env%field_trace(3, rtbse_env%sim_nsteps + 1), source=
z_zero)
715 NULLIFY (rtbse_env%time_trace)
716 ALLOCATE (rtbse_env%time_trace(rtbse_env%sim_nsteps + 1), source=0.0_dp)
721 NULLIFY (rtbse_env%hartree_curr)
722 NULLIFY (rtbse_env%sigma_SEX)
723 NULLIFY (rtbse_env%sigma_COH)
724 ALLOCATE (rtbse_env%hartree_curr(rtbse_env%n_spin))
725 ALLOCATE (rtbse_env%sigma_SEX(rtbse_env%n_spin))
726 ALLOCATE (rtbse_env%sigma_COH(rtbse_env%n_spin))
727 DO i = 1, rtbse_env%n_spin
736 IF (rtbse_env%linearized)
THEN
737 NULLIFY (rtbse_env%hartree_curr_ao)
738 NULLIFY (rtbse_env%sigma_SEX_ao)
739 ALLOCATE (rtbse_env%hartree_curr_ao(rtbse_env%n_spin))
740 ALLOCATE (rtbse_env%sigma_SEX_ao(rtbse_env%n_spin))
741 DO i = 1, rtbse_env%n_spin
742 CALL cp_cfm_create(rtbse_env%sigma_SEX_ao(i), bs_env%fm_ks_Gamma(1)%matrix_struct)
743 CALL cp_fm_create(rtbse_env%hartree_curr_ao(i), bs_env%fm_ks_Gamma(1)%matrix_struct)
748 NULLIFY (rtbse_env%real_workspace_mo)
749 ALLOCATE (rtbse_env%real_workspace_mo(2))
750 DO i = 1,
SIZE(rtbse_env%real_workspace_mo)
751 CALL cp_fm_create(rtbse_env%real_workspace_mo(i), rtbse_env%fm_struct_mo_active)
754 NULLIFY (rtbse_env%ao_mo_workspace)
755 ALLOCATE (rtbse_env%ao_mo_workspace(1))
756 CALL cp_fm_create(rtbse_env%ao_mo_workspace(1), rtbse_env%fm_struct_ao_mo_active)
760 NULLIFY (rtbse_env%C_active)
761 ALLOCATE (rtbse_env%C_active(rtbse_env%n_spin))
762 DO i = 1, rtbse_env%n_spin
763 CALL cp_fm_create(rtbse_env%C_active(i), rtbse_env%fm_struct_ao_mo_active)
768 NULLIFY (rtbse_env%rho_delta_mo)
769 ALLOCATE (rtbse_env%rho_delta_mo(rtbse_env%n_spin))
770 DO i = 1, rtbse_env%n_spin
771 CALL cp_cfm_create(rtbse_env%rho_delta_mo(i), rtbse_env%fm_struct_mo_active)
772 CALL cp_cfm_set_all(rtbse_env%rho_delta_mo(i), cmplx(0.0_dp, 0.0_dp, kind=
dp))
776 IF (.NOT. rtbse_env%debug_disable_hartree)
THEN
777 CALL cp_cfm_create(rtbse_env%rho_total_ao_scratch, bs_env%fm_s_Gamma%matrix_struct)
778 CALL cp_cfm_create(rtbse_env%hartree_total_ao, bs_env%fm_ks_Gamma(1)%matrix_struct)
779 CALL cp_cfm_set_all(rtbse_env%rho_total_ao_scratch, cmplx(0.0_dp, 0.0_dp, kind=
dp))
780 CALL cp_cfm_set_all(rtbse_env%hartree_total_ao, cmplx(0.0_dp, 0.0_dp, kind=
dp))
786 IF (rtbse_env%diagnose_liouvillian_eig)
THEN
790 DO i = 1, rtbse_env%n_spin
791 n_ov = n_ov + (rtbse_env%n_occ(i) - rtbse_env%first_active_mo + 1)* &
792 (rtbse_env%last_active_mo - rtbse_env%n_occ(i))
794 NULLIFY (rtbse_env%fm_struct_ov_pairs)
796 bs_env%fm_ks_Gamma(1)%matrix_struct%para_env, &
797 bs_env%fm_ks_Gamma(1)%matrix_struct%context, &
799 ALLOCATE (rtbse_env%drho_probe(rtbse_env%n_spin))
800 ALLOCATE (rtbse_env%L_drho(rtbse_env%n_spin))
801 DO i = 1, rtbse_env%n_spin
802 CALL cp_cfm_create(rtbse_env%drho_probe(i), rtbse_env%fm_struct_mo_active)
803 CALL cp_cfm_create(rtbse_env%L_drho(i), rtbse_env%fm_struct_mo_active)
804 CALL cp_cfm_set_all(rtbse_env%drho_probe(i), cmplx(0.0_dp, 0.0_dp, kind=
dp))
807 CALL cp_cfm_create(rtbse_env%L_pairs, rtbse_env%fm_struct_ov_pairs)
808 CALL cp_cfm_create(rtbse_env%eigvecs_pairs, rtbse_env%fm_struct_ov_pairs)
810 CALL cp_cfm_set_all(rtbse_env%eigvecs_pairs, cmplx(0.0_dp, 0.0_dp, kind=
dp))
811 NULLIFY (rtbse_env%eigenvalues_liouvillian)
812 ALLOCATE (rtbse_env%eigenvalues_liouvillian(n_ov))
813 rtbse_env%eigenvalues_liouvillian = 0.0_dp
815 IF (.NOT. rtbse_env%tda_active)
THEN
816 CALL cp_cfm_create(rtbse_env%A_mat, rtbse_env%fm_struct_ov_pairs)
817 CALL cp_cfm_create(rtbse_env%B_mat, rtbse_env%fm_struct_ov_pairs)
818 CALL cp_cfm_create(rtbse_env%AmB_scratch, rtbse_env%fm_struct_ov_pairs)
819 CALL cp_cfm_create(rtbse_env%ApB_scratch, rtbse_env%fm_struct_ov_pairs)
829 CALL create_sigma_workspace(rtbse_env)
832 CALL create_hartree_ri_workspace(rtbse_env)
842 SUBROUTINE cp_cfm_release_pa1(matrices)
843 TYPE(
cp_cfm_type),
DIMENSION(:),
POINTER :: matrices
846 DO i = 1,
SIZE(matrices)
849 DEALLOCATE (matrices)
851 END SUBROUTINE cp_cfm_release_pa1
862 CALL cp_cfm_release_pa1(rtbse_env%ham_effective)
863 CALL cp_cfm_release_pa1(rtbse_env%ham_workspace)
865 CALL cp_cfm_release_pa1(rtbse_env%sigma_SEX)
867 CALL cp_cfm_release_pa1(rtbse_env%ham_reference)
868 IF (
ASSOCIATED(rtbse_env%ham_reference_singleparticle))
THEN
869 CALL cp_cfm_release_pa1(rtbse_env%ham_reference_singleparticle)
871 IF (
ASSOCIATED(rtbse_env%eps_active))
DEALLOCATE (rtbse_env%eps_active)
872 IF (
ASSOCIATED(rtbse_env%eps_active_restart))
DEALLOCATE (rtbse_env%eps_active_restart)
873 CALL cp_cfm_release_pa1(rtbse_env%rho)
874 CALL cp_cfm_release_pa1(rtbse_env%rho_workspace)
875 CALL cp_cfm_release_pa1(rtbse_env%rho_new)
876 CALL cp_cfm_release_pa1(rtbse_env%rho_new_last)
877 CALL cp_cfm_release_pa1(rtbse_env%rho_M)
878 CALL cp_cfm_release_pa1(rtbse_env%rho_orig)
879 IF (
ASSOCIATED(rtbse_env%rk4_coefficients))
THEN
880 CALL cp_cfm_release_pa1(rtbse_env%rk4_coefficients)
883 IF (
ASSOCIATED(rtbse_env%sigma_complex_workspace))
CALL cp_cfm_release_pa1(rtbse_env%sigma_complex_workspace)
891 CALL release_sigma_workspace(rtbse_env)
893 CALL release_hartree_ri_workspace(rtbse_env)
895 DEALLOCATE (rtbse_env%real_eigvals)
896 DEALLOCATE (rtbse_env%exp_eigvals)
897 DEALLOCATE (rtbse_env%moments_trace)
898 DEALLOCATE (rtbse_env%field_trace)
899 DEALLOCATE (rtbse_env%time_trace)
901 IF (
ASSOCIATED(rtbse_env%pol_elements))
DEALLOCATE (rtbse_env%pol_elements)
902 IF (
ASSOCIATED(rtbse_env%pade_x_eval))
DEALLOCATE (rtbse_env%pade_x_eval)
907 IF (
ASSOCIATED(rtbse_env%rho_ao_scratch))
CALL cp_cfm_release_pa1(rtbse_env%rho_ao_scratch)
908 IF (
ASSOCIATED(rtbse_env%sigma_SEX_ao))
CALL cp_cfm_release_pa1(rtbse_env%sigma_SEX_ao)
909 IF (
ASSOCIATED(rtbse_env%hartree_curr_ao))
CALL cp_fm_release(rtbse_env%hartree_curr_ao)
910 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
CALL cp_fm_release(rtbse_env%real_workspace_mo)
911 IF (
ASSOCIATED(rtbse_env%ao_mo_workspace))
CALL cp_fm_release(rtbse_env%ao_mo_workspace)
912 IF (
ASSOCIATED(rtbse_env%C_active))
CALL cp_fm_release(rtbse_env%C_active)
913 IF (
ASSOCIATED(rtbse_env%rho_delta_mo))
CALL cp_cfm_release_pa1(rtbse_env%rho_delta_mo)
917 IF (rtbse_env%linearized .AND. .NOT. rtbse_env%debug_disable_hartree)
THEN
922 IF (
ALLOCATED(rtbse_env%hartree_diag_re))
DEALLOCATE (rtbse_env%hartree_diag_re)
923 IF (
ALLOCATED(rtbse_env%hartree_diag_im))
DEALLOCATE (rtbse_env%hartree_diag_im)
925 IF (rtbse_env%diagnose_liouvillian_eig)
THEN
926 IF (
ASSOCIATED(rtbse_env%drho_probe))
CALL cp_cfm_release_pa1(rtbse_env%drho_probe)
927 IF (
ASSOCIATED(rtbse_env%L_drho))
CALL cp_cfm_release_pa1(rtbse_env%L_drho)
930 IF (
ASSOCIATED(rtbse_env%eigenvalues_liouvillian))
DEALLOCATE (rtbse_env%eigenvalues_liouvillian)
931 IF (.NOT. rtbse_env%tda_active)
THEN
937 IF (
ASSOCIATED(rtbse_env%fm_struct_ov_pairs))
THEN
942 IF (
ASSOCIATED(rtbse_env%fm_struct_mo_active))
THEN
945 IF (
ASSOCIATED(rtbse_env%fm_struct_ao_mo_active))
THEN
949 DEALLOCATE (rtbse_env)
964 SUBROUTINE check_qp_gap_sanity(rtbse_env, bs_env)
968 INTEGER :: homo, ispin
969 REAL(kind=
dp) :: gap, gap_scf
973 DO ispin = 1, rtbse_env%n_spin
974 homo = rtbse_env%n_occ(ispin)
975 IF (homo < 1 .OR. homo >= rtbse_env%n_ao) cycle
977 gap = minval(bs_env%eigenval_G0W0(homo + 1:rtbse_env%n_ao, 1, ispin)) - &
978 maxval(bs_env%eigenval_G0W0(1:homo, 1, ispin))
979 gap_scf = minval(bs_env%eigenval_scf_Gamma(homo + 1:rtbse_env%n_ao, ispin)) - &
980 maxval(bs_env%eigenval_scf_Gamma(1:homo, ispin))
984 CALL cp_abort(__location__, &
985 "RTBSE: G0W0 gap of spin "//trim(adjustl(
cp_to_string(ispin)))// &
987 " eV): propagating an inverted spectrum is meaningless. Check the GW "// &
988 "numerical parameters, or use RTBSE_HAMILTONIAN KS.")
990 CALL cp_abort(__location__, &
991 "RTBSE: G0W0 gap of spin "//trim(adjustl(
cp_to_string(ispin)))// &
992 " is implausibly large ("// &
994 "has likely diverged. Check the GW numerical parameters, or use "// &
995 "RTBSE_HAMILTONIAN KS.")
999 END SUBROUTINE check_qp_gap_sanity
1013 SUBROUTINE determine_active_mo_window(rtbse_env, bs_env)
1016 CHARACTER(LEN=*),
PARAMETER :: routinen =
"determine_active_mo_window"
1018 INTEGER :: handle, ispin, n_ao_full, n_virt
1019 INTEGER :: homo_red, virt_red, homo_incl, virt_incl
1020 INTEGER :: combined_first_occ, combined_last_virt
1021 INTEGER :: first_occ_prev, last_virt_prev
1022 LOGICAL :: spins_differ, do_truncation
1023 REAL(kind=
dp) :: cutoff_occ, cutoff_empty
1025 CALL timeset(routinen, handle)
1027 n_ao_full = rtbse_env%n_ao
1028 cutoff_occ = rtbse_env%rtbse_energy_cutoff_occ
1029 cutoff_empty = rtbse_env%rtbse_energy_cutoff_empty
1030 do_truncation = rtbse_env%linearized .AND. (cutoff_occ > 0.0_dp .OR. cutoff_empty > 0.0_dp)
1033 rtbse_env%first_active_mo = 1
1034 rtbse_env%last_active_mo = n_ao_full
1035 rtbse_env%mo_active = n_ao_full
1036 rtbse_env%active_mo_truncation = .false.
1038 IF (.NOT. do_truncation)
THEN
1039 CALL timestop(handle)
1043 combined_first_occ = n_ao_full
1044 combined_last_virt = 1
1047 spins_differ = .false.
1049 DO ispin = 1, rtbse_env%n_spin
1050 n_virt = n_ao_full - rtbse_env%n_occ(ispin)
1055 rtbse_env%n_occ(ispin), n_virt, &
1056 homo_red, virt_red, homo_incl, virt_incl, &
1057 cutoff_occ, cutoff_empty)
1060 IF (homo_incl /= first_occ_prev .OR. (rtbse_env%n_occ(ispin) + virt_incl) /= last_virt_prev)
THEN
1061 spins_differ = .true.
1064 first_occ_prev = homo_incl
1065 last_virt_prev = rtbse_env%n_occ(ispin) + virt_incl
1066 combined_first_occ = min(combined_first_occ, homo_incl)
1067 combined_last_virt = max(combined_last_virt, rtbse_env%n_occ(ispin) + virt_incl)
1070 IF (spins_differ)
THEN
1071 cpwarn(
"RTBSE: spin-resolved active MO cutoff candidates differ; using combined window.")
1074 rtbse_env%first_active_mo = combined_first_occ
1075 rtbse_env%last_active_mo = combined_last_virt
1076 rtbse_env%mo_active = combined_last_virt - combined_first_occ + 1
1077 rtbse_env%active_mo_truncation = (rtbse_env%mo_active < n_ao_full)
1079 CALL timestop(handle)
1080 END SUBROUTINE determine_active_mo_window
1089 SUBROUTINE create_hartree_ri_workspace(rtbse_env)
1099 IF (rtbse_env%rirs_kernel)
RETURN
1101 CALL get_qs_env(rtbse_env%qs_env, bs_env=bs_env)
1103 CALL dbcsr_create(rtbse_env%rho_dbcsr, name=
"Sparse density", template=bs_env%mat_ao_ao%matrix)
1104 CALL dbcsr_create(rtbse_env%v_ao_dbcsr, name=
"Sparse Hartree", template=bs_env%mat_ao_ao%matrix)
1106 CALL create_hartree_ri_3c(rtbse_env%rho_dbcsr, rtbse_env%int_3c_array, rtbse_env%n_ao, rtbse_env%n_RI, &
1107 bs_env%basis_set_AO, bs_env%basis_set_RI, bs_env%i_RI_start_from_atom, &
1108 bs_env%ri_metric, rtbse_env%qs_env, rtbse_env%unit_nr)
1109 END SUBROUTINE create_hartree_ri_workspace
1125 i_RI_start_from_atom, ri_metric, qs_env, unit_nr)
1127 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: int_3c
1128 INTEGER :: n_ao, n_ri
1131 INTEGER,
DIMENSION(:) :: i_ri_start_from_atom
1135 REAL(kind=
dp) :: size_mb
1136 INTEGER :: nblkrows_local, &
1148 INTEGER,
DIMENSION(:),
POINTER :: local_blk_rows, &
1153 size_mb = real(n_ao, kind=
dp)*real(n_ao, kind=
dp)*real(n_ri, kind=
dp)* &
1154 REAL(storage_size(size_mb), kind=
dp)/8.0_dp/1024.0_dp/1024.0_dp
1155 IF (unit_nr > 0)
WRITE (unit_nr,
'(A44,E32.2E3,A4)') &
1156 " RTBSE| Approximate size of the 3c integrals", size_mb,
" MiB"
1159 CALL dbcsr_get_info(rho_dbcsr, nblkrows_local=nblkrows_local, nblkcols_local=nblkcols_local)
1161 CALL dbcsr_get_info(rho_dbcsr, local_rows=local_blk_rows, local_cols=local_blk_cols)
1163 CALL dbcsr_get_info(rho_dbcsr, row_blk_size=row_blk_size, col_blk_size=col_blk_size)
1167 DO i_blk_local = 1, nblkrows_local
1168 nrows_local = nrows_local + row_blk_size(local_blk_rows(i_blk_local))
1171 DO j_blk_local = 1, nblkcols_local
1172 ncols_local = ncols_local + col_blk_size(local_blk_cols(j_blk_local))
1176 ALLOCATE (int_3c(nrows_local, ncols_local, n_ri))
1179 row_local_offset = 1
1180 DO i_blk_local = 1, nblkrows_local
1181 col_local_offset = 1
1182 DO j_blk_local = 1, nblkcols_local
1183 start_row_index = row_local_offset
1184 end_row_index = start_row_index + row_blk_size(local_blk_rows(i_blk_local)) - 1
1185 start_col_index = col_local_offset
1186 end_col_index = start_col_index + col_blk_size(local_blk_cols(j_blk_local)) - 1
1188 start_col_index:end_col_index, &
1190 qs_env, potential_parameter=ri_metric, &
1191 basis_j=basis_set_ao, basis_k=basis_set_ao, &
1192 basis_i=basis_set_ri, &
1193 atom_j=local_blk_rows(i_blk_local), &
1194 atom_k=local_blk_cols(j_blk_local), &
1195 i_bf_start_from_atom=i_ri_start_from_atom)
1196 col_local_offset = col_local_offset + col_blk_size(local_blk_cols(j_blk_local))
1198 row_local_offset = row_local_offset + row_blk_size(local_blk_rows(i_blk_local))
1207 SUBROUTINE release_hartree_ri_workspace(rtbse_env)
1213 IF (.NOT. rtbse_env%rirs_kernel)
THEN
1214 DEALLOCATE (rtbse_env%int_3c_array)
1219 END SUBROUTINE release_hartree_ri_workspace
1226 SUBROUTINE create_sigma_workspace(rtbse_env)
1232 IF (rtbse_env%rirs_kernel)
RETURN
1235 rtbse_env%t_3c_w, rtbse_env%t_3c_work_RI_AO__AO, &
1236 rtbse_env%t_3c_work2_RI_AO__AO, rtbse_env%greens_dbt)
1237 END SUBROUTINE create_sigma_workspace
1248 work_dbt_3c_1, work_dbt_3c_2, work_dbt_2c)
1251 TYPE(dbt_type) :: screened_dbt, &
1261 CALL dbt_create(bs_env%t_RI__AO_AO, int_3c_dbt)
1265 CALL dbt_create(bs_env%t_RI_AO__AO, work_dbt_3c_1)
1267 CALL dbt_create(bs_env%t_RI_AO__AO, work_dbt_3c_2)
1270 CALL dbcsr_create(screened_dbcsr, name=
"W", template=bs_env%mat_RI_RI%matrix)
1271 CALL dbt_create(screened_dbcsr, screened_dbt)
1273 CALL dbt_create(bs_env%mat_ao_ao%matrix, work_dbt_2c)
1281 SUBROUTINE release_sigma_workspace(rtbse_env)
1285 IF (rtbse_env%rirs_kernel)
RETURN
1287 CALL dbt_destroy(rtbse_env%t_3c_w)
1288 CALL dbt_destroy(rtbse_env%t_3c_work_RI_AO__AO)
1289 CALL dbt_destroy(rtbse_env%t_3c_work2_RI_AO__AO)
1290 CALL dbt_destroy(rtbse_env%screened_dbt)
1291 CALL dbt_destroy(rtbse_env%greens_dbt)
1293 END SUBROUTINE release_sigma_workspace
1302 alpha, matrix_r, matrix_c, beta, res)
1304 CHARACTER(len=1) :: trans_r, trans_c
1305 INTEGER :: na, nb, nc
1308 REAL(kind=
dp) :: alpha, beta
1311 TYPE(
cp_fm_type) :: work_re, work_im, res_re, res_im
1312 REAL(kind=
dp) :: i_unit
1313 CHARACTER(len=1) :: trans_cr
1320 SELECT CASE (trans_c)
1333 alpha, matrix_r, work_re, beta, res_re)
1335 i_unit*alpha, matrix_r, work_im, beta, res_im)
1351 alpha, matrix_c, matrix_r, beta, res)
1353 CHARACTER(len=1) :: trans_c, trans_r
1354 INTEGER :: na, nb, nc
1357 REAL(kind=
dp) :: alpha, beta
1360 TYPE(
cp_fm_type) :: work_re, work_im, res_re, res_im
1361 REAL(kind=
dp) :: i_unit
1362 CHARACTER(len=1) :: trans_cr
1369 SELECT CASE (trans_c)
1382 alpha, work_re, matrix_r, beta, res_re)
1384 i_unit*alpha, work_im, matrix_r, beta, res_im)
Auxiliary routines for GW + Bethe-Salpeter for computing electronic excitations.
subroutine, public determine_cutoff_indices(eigenval, homo, virtual, homo_red, virt_red, homo_incl, virt_incl, cutoff_occ, cutoff_empty)
Reads cutoffs for BSE from mp2_env and compares to energies in Eigenval to extract reduced homo/virtu...
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.
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)
...
Routines from paper [Graml2024].
subroutine, public compute_3c_integrals(qs_env, bs_env, t_3c, atoms_ao_1, atoms_ao_2, atoms_ri)
...
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
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