53#include "../base/base_uses.f90"
59 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
"rt_bse_io"
62 INTEGER,
PARAMETER,
PRIVATE :: restart_trace_version = 1
97 IF (rtbse_env%unit_nr > 0)
THEN
98 WRITE (rtbse_env%unit_nr, *)
''
99 WRITE (rtbse_env%unit_nr,
'(A)')
' /-----------------------------------------------'// &
100 '------------------------------\'
101 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
103 WRITE (rtbse_env%unit_nr,
'(A)')
' | Real Time Bethe-Salpeter Propagation'// &
105 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
107 WRITE (rtbse_env%unit_nr,
'(A)')
' \-----------------------------------------------'// &
108 '------------------------------/'
109 WRITE (rtbse_env%unit_nr, *)
''
112 WRITE (rtbse_env%unit_nr,
'(A19)', advance=
"no")
' Exponential method'
113 SELECT CASE (rtbse_env%mat_exp_method)
115 WRITE (rtbse_env%unit_nr,
'(A61)')
'BCH'
117 WRITE (rtbse_env%unit_nr,
'(A61)')
'EXACT'
120 WRITE (rtbse_env%unit_nr,
'(A22)', advance=
"no")
' Reference Hamiltonian'
121 SELECT CASE (rtbse_env%ham_reference_type)
123 IF (rtbse_env%bs_env%gw_flavour ==
evgw0)
THEN
124 WRITE (rtbse_env%unit_nr,
'(A58)')
'evGW0'
126 WRITE (rtbse_env%unit_nr,
'(A58)')
'G0W0'
129 WRITE (rtbse_env%unit_nr,
'(A58)')
'Kohn-Sham'
132 WRITE (rtbse_env%unit_nr,
'(A18,L62)')
' Apply delta pulse', &
133 rtbse_env%dft_control%rtp_control%apply_delta_pulse
135 WRITE (rtbse_env%unit_nr,
'(A)')
''
147 REAL(kind=
dp) :: metric
152 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
153 WRITE (rtbse_env%unit_nr,
'(A7,I5, E20.8E3)')
' RTBSE|', step, metric
167 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
168 WRITE (rtbse_env%unit_nr,
'(A13, A20)')
' RTBSE| Iter.',
'Convergence'
185 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: electron_num_re
186 REAL(kind=
dp),
OPTIONAL :: convergence
187 INTEGER,
OPTIONAL :: etrs_num
188 REAL(kind=
dp),
OPTIONAL :: step_walltime
190 LOGICAL :: flag_lrrtbse
195 nch =
SIZE(electron_num_re)
197 IF (.NOT.
PRESENT(convergence) .OR. .NOT.
PRESENT(etrs_num))
THEN
198 flag_lrrtbse = .true.
200 flag_lrrtbse = .false.
203 IF (logger%iter_info%print_level >
low_print_level .AND. rtbse_env%unit_nr > 0)
THEN
204 IF (flag_lrrtbse)
THEN
206 IF (
PRESENT(step_walltime))
THEN
207 WRITE (rtbse_env%unit_nr,
'(A45,T70,F11.3)') &
208 " RTBSE| Estimated runtime for propagation [s]", &
209 step_walltime*real(rtbse_env%sim_nsteps,
dp)
210 WRITE (rtbse_env%unit_nr,
'(A)') &
213 WRITE (rtbse_env%unit_nr,
'(A23,T27,A13,T66,A15)') &
214 " RTBSE| Simulation step",
"Step time [s]",
"Electron number"
220 WRITE (rtbse_env%unit_nr,
'(A23,T27,A13,T47,A15,T68,A15)') &
221 " RTBSE| Simulation step",
"Step time [s]",
"El. number (α)",
"El. number (β)"
225 WRITE (rtbse_env%unit_nr,
'(A23,T66,A15)')
" RTBSE| Simulation step",
"Electron number"
227 WRITE (rtbse_env%unit_nr,
'(A23,T47,A15,T68,A15)') &
228 " RTBSE| Simulation step",
"El. number (α)",
"El. number (β)"
232 IF (
PRESENT(step_walltime))
THEN
234 WRITE (rtbse_env%unit_nr,
'(A7,I16,T30,F10.3,T69,E12.3E3)') &
235 ' RTBSE|', step, step_walltime, electron_num_re(1)
237 WRITE (rtbse_env%unit_nr,
'(A7,I16,T30,F10.3,T49,E12.3E3,T69,E12.3E3)') &
238 ' RTBSE|', step, step_walltime, electron_num_re(1), electron_num_re(2)
242 WRITE (rtbse_env%unit_nr,
'(A7,I16,T61,E20.8E3)')
' RTBSE|', step, electron_num_re(1)
244 WRITE (rtbse_env%unit_nr,
'(A7,I16,T49,E12.3E3,T69,E12.3E3)') &
245 ' RTBSE|', step, electron_num_re(1), electron_num_re(2)
249 WRITE (rtbse_env%unit_nr,
'(A23,A20,A20,A17)')
" RTBSE| Simulation step",
"Convergence", &
250 "Electron number",
"ETRS Iterations"
251 WRITE (rtbse_env%unit_nr,
'(A7,I16,E20.8E3,E20.8E3,I17)')
' RTBSE|', step, convergence, &
252 electron_num_re(1), etrs_num
270 INTEGER :: j, rho_unit_re, rho_unit_im
271 CHARACTER(len=14),
DIMENSION(4) :: file_labels
273 file_labels(1) =
"_SPIN_A_RE.dat"
274 file_labels(2) =
"_SPIN_A_IM.dat"
275 file_labels(3) =
"_SPIN_B_RE.dat"
276 file_labels(4) =
"_SPIN_B_IM.dat"
282 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
283 DO j = 1, rtbse_env%n_spin
286 CALL cp_cfm_to_fm(rho(j), rtbse_env%real_workspace_mo(1), rtbse_env%real_workspace_mo(2))
295 DO j = 1, rtbse_env%n_spin
300 CALL multiply_fm_cfm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
301 1.0_dp, rtbse_env%S_fm, rho(j), &
302 0.0_dp, rtbse_env%rho_workspace(1))
304 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
305 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), rtbse_env%rho_workspace(1), &
306 0.0_dp, rtbse_env%rho_workspace(2))
308 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
309 1.0_dp, rtbse_env%rho_workspace(2), rtbse_env%S_fm, &
310 0.0_dp, rtbse_env%rho_workspace(1))
312 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
313 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
314 0.0_dp, rtbse_env%rho_workspace(2))
317 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
336 INTEGER :: j, rho_unit_re, rho_unit_im
337 CHARACTER(len=21),
DIMENSION(4) :: file_labels
339 file_labels(1) =
"_SPIN_A_RE.dat"
340 file_labels(2) =
"_SPIN_A_IM.dat"
341 file_labels(3) =
"_SPIN_B_RE.dat"
342 file_labels(4) =
"_SPIN_B_IM.dat"
344 DO j = 1, rtbse_env%n_spin
348 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
349 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), ham(j), &
350 0.0_dp, rtbse_env%rho_workspace(1))
352 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
353 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
354 0.0_dp, rtbse_env%rho_workspace(2))
357 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
371 LOGICAL,
OPTIONAL :: append_opt
373 INTEGER :: field_unit, n, i
378 IF (
PRESENT(append_opt)) append = .false.
382 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
384 rtbse_env%field_trace(i, n) = cmplx(rtbse_env%field(i), 0.0, kind=
dp)
386 rtbse_env%time_trace(n) = rtbse_env%sim_time
394 CALL print_rt_file(field_unit, xvals=rtbse_env%time_trace(n:n), &
395 yvals=rtbse_env%field_trace(:, n:n), &
400 " field x [at.u.]", &
401 " field y [at.u.]", &
402 " field z [at.u.]"], &
403 rtbse_env%time_trace(n:n), rtbse_env%field_trace(:, n:n), &
417 CHARACTER(len=default_path_length) :: save_name
418 INTEGER :: k, n, field_unit
419 REAL(kind=
dp),
DIMENSION(3) :: real_field
426 CALL open_file(save_name, file_status=
"OLD", file_form=
"FORMATTED", file_action=
"READ", &
427 unit_number=field_unit)
429 READ (field_unit,
'()')
430 DO k = rtbse_env%sim_start_orig, rtbse_env%sim_start
431 n = k - rtbse_env%sim_start_orig + 1
432 READ (field_unit,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') rtbse_env%time_trace(n), &
433 real_field(1), real_field(2), real_field(3)
434 rtbse_env%field_trace(:, n) = cmplx(real_field(:), 0.0, kind=
dp)
436 rtbse_env%time_trace(n) = rtbse_env%time_trace(n)/
femtoseconds
439 ELSE IF (.NOT. rtbse_env%dft_control%rtp_control%apply_delta_pulse .AND. &
440 rtbse_env%dft_control%rtp_control%initial_wfn ==
use_rt_restart)
THEN
441 cpwarn(
"Restart without RT field file - unknown field trace set to zero.")
456 REAL(kind=
dp),
DIMENSION(3) :: moments_re
459 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
462 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
463 ws => rtbse_env%real_workspace_mo
465 ws => rtbse_env%real_workspace
468 DO j = 1, rtbse_env%n_spin
476 moments_re(i) = -moments_re(i)*rtbse_env%spin_degeneracy
477 rtbse_env%moments_trace(j, i, n) = cmplx(moments_re(i), 0.0, kind=
dp)
485 moments_re(i) = -moments_re(i)*rtbse_env%spin_degeneracy
486 rtbse_env%moments_trace(j, i, n) = rtbse_env%moments_trace(j, i, n) + cmplx(0.0, moments_re(i), kind=
dp)
490 CALL print_moments(rtbse_env%moments_section, rtbse_env%unit_nr, rtbse_env%moments_trace(:, :, n), &
491 rtbse_env%sim_time, .true., append_opt=(rtbse_env%sim_step /= rtbse_env%sim_start_orig))
502 INTEGER :: time_index
503 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: workspace
504 CHARACTER(len=17),
DIMENSION(4) :: file_labels
506 INTEGER :: rho_unit_nr, i
509 file_labels(1) =
"_SPIN_A_RE.matrix"
510 file_labels(2) =
"_SPIN_A_IM.matrix"
511 file_labels(3) =
"_SPIN_B_RE.matrix"
512 file_labels(4) =
"_SPIN_B_IM.matrix"
516 workspace => rtbse_env%real_workspace
518 DO i = 1, rtbse_env%n_spin
521 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i - 1), &
522 file_form=
"UNFORMATTED", file_position=
"REWIND")
526 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i), &
527 file_form=
"UNFORMATTED", file_position=
"REWIND")
532 file_form=
"UNFORMATTED", file_position=
"REWIND")
533 IF (rho_unit_nr > 0)
WRITE (rho_unit_nr) time_index
546 CHARACTER(len=default_path_length) :: save_name, save_name_2
547 INTEGER :: rho_unit_nr, j
548 CHARACTER(len=17),
DIMENSION(4) :: file_labels
552 rtbse_env%restart_extracted = .false.
557 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
558 unit_number=rho_unit_nr)
559 READ (rho_unit_nr) rtbse_env%sim_start
561 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A31,I25,A24)')
" RTBSE| Starting from timestep ", &
562 rtbse_env%sim_start,
", delta kick NOT applied"
564 cpwarn(
"Restart required but no info file found - starting from sim_step given in input")
568 file_labels(1) =
"_SPIN_A_RE.matrix"
569 file_labels(2) =
"_SPIN_A_IM.matrix"
570 file_labels(3) =
"_SPIN_B_RE.matrix"
571 file_labels(4) =
"_SPIN_B_IM.matrix"
572 DO j = 1, rtbse_env%n_spin
574 extension=file_labels(2*j - 1), my_local=.false.)
576 extension=file_labels(2*j), my_local=.false.)
578 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
579 unit_number=rho_unit_nr)
582 CALL open_file(save_name_2, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
583 unit_number=rho_unit_nr)
586 CALL cp_fm_to_cfm(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), &
588 rtbse_env%restart_extracted = .true.
590 cpwarn(
"Restart without some restart matrices - starting from SCF density.")
606 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: workspace
607 CHARACTER(len=17),
DIMENSION(4) :: file_labels
608 CHARACTER(len=16),
DIMENSION(2) :: c_file_labels
610 INTEGER :: rho_unit_nr, i
613 file_labels(1) =
"_SPIN_A_RE.matrix"
614 file_labels(2) =
"_SPIN_A_IM.matrix"
615 file_labels(3) =
"_SPIN_B_RE.matrix"
616 file_labels(4) =
"_SPIN_B_IM.matrix"
617 c_file_labels(1) =
"_SPIN_A_C.matrix"
618 c_file_labels(2) =
"_SPIN_B_C.matrix"
623 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
624 workspace => rtbse_env%real_workspace_mo
626 workspace => rtbse_env%real_workspace
629 DO i = 1, rtbse_env%n_spin
632 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i - 1), &
633 file_form=
"UNFORMATTED", file_position=
"REWIND")
637 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i), &
638 file_form=
"UNFORMATTED", file_position=
"REWIND")
643 file_form=
"UNFORMATTED", file_position=
"REWIND")
644 IF (rho_unit_nr > 0)
WRITE (rho_unit_nr) rtbse_env%sim_step
649 IF (
ASSOCIATED(rtbse_env%real_workspace_mo) .AND. .NOT. rtbse_env%restart_C_written)
THEN
650 DO i = 1, rtbse_env%n_spin
651 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=c_file_labels(i), &
652 file_form=
"UNFORMATTED", file_position=
"REWIND")
656 rtbse_env%restart_C_written = .true.
659 CALL write_restart_trace(rtbse_env)
670 SUBROUTINE write_restart_trace(rtbse_env)
673 CHARACTER(len=default_path_length) :: save_name
674 INTEGER :: trace_unit, n, n_eps, n_slot
679 IF (rtbse_env%unit_nr > 0)
THEN
680 n_slot = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
681 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
684 n_eps =
SIZE(rtbse_env%eps_active, 1)
688 IF (.NOT. rtbse_env%restart_trace_written)
THEN
689 CALL open_file(save_name, file_status=
"UNKNOWN", file_form=
"UNFORMATTED", file_action=
"WRITE", &
690 file_position=
"REWIND", unit_number=trace_unit)
691 WRITE (trace_unit) restart_trace_version
692 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
693 WRITE (trace_unit) rtbse_env%n_spin, rtbse_env%mo_active, rtbse_env%n_ao
695 WRITE (trace_unit) rtbse_env%n_spin, rtbse_env%n_ao, rtbse_env%n_ao
697 WRITE (trace_unit) rtbse_env%sim_dt
698 WRITE (trace_unit) real(rtbse_env%dft_control%rtp_control%delta_pulse_direction,
dp), &
699 rtbse_env%dft_control%rtp_control%delta_pulse_scale
700 WRITE (trace_unit) n_eps
701 IF (n_eps > 0)
WRITE (trace_unit) rtbse_env%eps_active
703 WRITE (trace_unit) n, rtbse_env%time_trace(n), rtbse_env%field_trace(:, n), &
704 rtbse_env%moments_trace(:, :, n)
707 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"WRITE", &
708 file_position=
"APPEND", unit_number=trace_unit)
709 WRITE (trace_unit) n_slot, rtbse_env%time_trace(n_slot), rtbse_env%field_trace(:, n_slot), &
710 rtbse_env%moments_trace(:, :, n_slot)
714 rtbse_env%restart_trace_written = .true.
715 END SUBROUTINE write_restart_trace
726 CHARACTER(len=default_path_length) :: save_name
727 INTEGER :: info_unit, trace_unit, version
734 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
735 unit_number=info_unit)
736 READ (info_unit) rtbse_env%sim_start
738 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A31,I25,A24)')
" RTBSE| Starting from timestep ", &
739 rtbse_env%sim_start,
", delta kick NOT applied"
741 cpwarn(
"Restart required but no info file found - starting from sim_step given in input")
749 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
750 unit_number=trace_unit)
751 READ (trace_unit) version
752 IF (version == restart_trace_version)
THEN
754 READ (trace_unit) rtbse_env%sim_dt_restart
760 NULLIFY (scf_control)
761 CALL get_qs_env(rtbse_env%qs_env, scf_control=scf_control)
763 cpwarn(
"RT_RESTART without SCF_GUESS RESTART - SCF may reconverge to a gauge-rotated MO basis.")
776 CHARACTER(len=default_path_length) :: save_name, err_msg
777 INTEGER :: trace_unit, version, n_spin_file, &
778 n_basis_file, n_ao_file, n_eps, n, &
780 REAL(kind=
dp) :: dt_file, kick_scale_file, t_rec
781 REAL(kind=
dp),
DIMENSION(3) :: kick_dir_file
782 REAL(kind=
dp),
DIMENSION(:, :),
ALLOCATABLE :: eps_file
783 COMPLEX(kind=dp),
DIMENSION(3) :: field_rec
784 COMPLEX(kind=dp),
DIMENSION(:, :),
ALLOCATABLE :: mom_rec
792 IF (rtbse_env%sim_start > 0)
THEN
793 CALL cp_abort(__location__, &
794 "RT_RESTART without RESTART.trace - the continuation FT would miss the pre-restart "// &
795 "history. Restore the original run's RESTART.trace next to the density restart files.")
800 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
801 unit_number=trace_unit)
802 READ (trace_unit) version
803 IF (version /= restart_trace_version)
THEN
804 WRITE (err_msg,
'(A,I0,A,I0)')
"RESTART.trace: format version ", version, &
805 " does not match this binary's version ", restart_trace_version
806 CALL cp_abort(__location__, trim(err_msg))
808 READ (trace_unit) n_spin_file, n_basis_file, n_ao_file
809 IF (n_spin_file /= rtbse_env%n_spin) cpabort(
"RESTART.trace: n_spin mismatch")
810 IF (n_ao_file /= rtbse_env%n_ao) cpabort(
"RESTART.trace: n_ao mismatch")
812 IF (
ASSOCIATED(rtbse_env%real_workspace_mo) .AND. n_basis_file /= rtbse_env%mo_active)
THEN
813 CALL cp_abort(__location__, &
814 "RESTART.trace: active-MO count differs from the original run - same-window continuation only")
816 READ (trace_unit) dt_file
819 IF (abs(dt_file - rtbse_env%sim_dt) > 1.0e-12_dp*max(1.0_dp, abs(rtbse_env%sim_dt)))
THEN
820 WRITE (err_msg,
'(A,ES16.9,A)') &
821 "RESTART.trace: TIMESTEP differs from the original run - continuation undefined. "// &
823 " or enable RTBSE%ENFORCE_MAX_DT to inherit it automatically."
824 CALL cp_abort(__location__, trim(err_msg))
826 READ (trace_unit) kick_dir_file, kick_scale_file
827 IF (maxval(abs(kick_dir_file - real(rtbse_env%dft_control%rtp_control%delta_pulse_direction,
dp))) > 1.0e-12_dp .OR. &
828 abs(kick_scale_file - rtbse_env%dft_control%rtp_control%delta_pulse_scale) > 1.0e-12_dp)
THEN
829 CALL cp_warn(__location__, &
830 "RESTART.trace: delta-kick parameters differ from the original run - FT normalization inconsistent.")
832 READ (trace_unit) n_eps
834 ALLOCATE (eps_file(n_eps, rtbse_env%n_spin))
835 READ (trace_unit) eps_file
836 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
837 IF (n_eps /=
SIZE(rtbse_env%eps_active, 1))
THEN
838 CALL cp_abort(__location__,
"RESTART.trace: active-window size mismatch")
842 ALLOCATE (rtbse_env%eps_active_restart(n_eps, rtbse_env%n_spin))
843 rtbse_env%eps_active_restart(:, :) = eps_file
845 DEALLOCATE (eps_file)
848 ALLOCATE (mom_rec(rtbse_env%n_spin, 3))
851 READ (trace_unit, iostat=ios) n, t_rec, field_rec, mom_rec
856 IF (n > rtbse_env%sim_start + 1)
EXIT
857 IF (n >
SIZE(rtbse_env%time_trace))
THEN
858 cpabort(
"RESTART.trace: record index exceeds trace size - increase MOTION%MD%STEPS")
860 rtbse_env%time_trace(n) = t_rec
861 rtbse_env%field_trace(:, n) = field_rec
862 rtbse_env%moments_trace(:, :, n) = mom_rec
863 n_read_max = max(n_read_max, n)
867 IF (n_read_max < rtbse_env%sim_start)
THEN
868 cpwarn(
"RESTART.trace: fewer records than restart step - trace prefix incomplete.")
880 REAL(kind=
dp) :: eps_dev
882 IF (.NOT.
ASSOCIATED(rtbse_env%eps_active_restart))
RETURN
884 eps_dev = maxval(abs(rtbse_env%eps_active_restart - rtbse_env%eps_active))
885 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A,ES12.3,A)') &
886 " RTBSE| Restart eps_active max deviation vs original run ", eps_dev,
" Ha"
888 IF (eps_dev > 1.0e-4_dp/
evolt)
THEN
889 CALL cp_warn(__location__, &
890 "RESTART.trace: active eigenvalues deviate beyond 0.1 meV - "// &
891 "Hamiltonian changed; continuation is physically inconsistent.")
894 DEALLOCATE (rtbse_env%eps_active_restart)
895 NULLIFY (rtbse_env%eps_active_restart)
906 CHARACTER(len=default_path_length) :: save_name, save_name_2
907 INTEGER :: rho_unit_nr, j
908 CHARACTER(len=17),
DIMENSION(4) :: file_labels
913 rtbse_env%restart_extracted = .false.
916 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
917 ws => rtbse_env%real_workspace_mo
919 ws => rtbse_env%real_workspace
923 file_labels(1) =
"_SPIN_A_RE.matrix"
924 file_labels(2) =
"_SPIN_A_IM.matrix"
925 file_labels(3) =
"_SPIN_B_RE.matrix"
926 file_labels(4) =
"_SPIN_B_IM.matrix"
927 DO j = 1, rtbse_env%n_spin
929 extension=file_labels(2*j - 1), my_local=.false.)
931 extension=file_labels(2*j), my_local=.false.)
933 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
934 unit_number=rho_unit_nr)
937 CALL open_file(save_name_2, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
938 unit_number=rho_unit_nr)
943 rtbse_env%restart_extracted = .true.
945 cpwarn(
"Restart without some restart matrices - starting from SCF density.")
957 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: c_old
958 LOGICAL,
INTENT(OUT) :: found
960 CHARACTER(len=default_path_length) :: save_name
961 CHARACTER(len=16),
DIMENSION(2) :: c_file_labels
964 c_file_labels(1) =
"_SPIN_A_C.matrix"
965 c_file_labels(2) =
"_SPIN_B_C.matrix"
968 DO j = 1, rtbse_env%n_spin
970 extension=c_file_labels(j), my_local=.false.)
972 cpwarn(
"Restart without C_active file - assuming identical MO gauge (no basis bridge).")
975 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
Represents a complex full matrix distributed on many processors.
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_to_fm(msource, mtargetr, mtargeti)
Copy real and imaginary parts of a complex full matrix into separate real-value full matrices.
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.
logical function, public file_exists(file_name)
Checks if file exists, considering also the file discovery mechanism.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_transpose(matrix, matrixt)
transposes a matrix matrixt = matrix ^ T
represent a full matrix distributed on many processors
subroutine, public cp_fm_write_unformatted(fm, unit)
...
subroutine, public cp_fm_read_unformatted(fm, unit)
...
subroutine, public cp_fm_write_formatted(fm, unit, header, value_format)
Write out a full matrix in plain text.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
integer, parameter, public low_print_level
integer, parameter, public medium_print_level
character(len=default_path_length) function, public cp_print_key_generate_filename(logger, print_key, middle_name, extension, my_local)
Utility function that returns a unit number to write the print key. Might open a file with a unique f...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
Definition of physical constants:
real(kind=dp), parameter, public femtoseconds
real(kind=dp), parameter, public evolt
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Input/output from the propagation via RT-BSE method.
subroutine, public read_restart_c(rtbse_env, c_old, found)
Reads the previous run's C_active slabs (gauge reference for the restart basis bridge).
subroutine, public output_restart_linearized(rtbse_env, rho)
Linearized RT-BSE restart writer. Writes the restart set: lab-frame MO-active density matrices,...
subroutine, public print_rtbse_header_info(rtbse_env)
Writes the header and basic info to the standard output.
subroutine, public output_mos_covariant(rtbse_env, ham, print_key_section)
Outputs the matrix in MO basis for matrix components corresponding to covariant representation,...
subroutine, public output_restart(rtbse_env, rho, time_index)
Outputs the restart info (last finished iteration step) + restard density matrix.
subroutine, public check_restart_eps_consistency(rtbse_env)
Compares the original run's active eigenvalues (stashed by read_restart_trace) against the recomputed...
subroutine, public print_etrs_info(rtbse_env, step, metric)
Writes the update after single etrs iteration - only for log level > medium.
subroutine, public read_field(rtbse_env)
Reads the field from the files provided by input - useful for the continuation run.
subroutine, public print_etrs_info_header(rtbse_env)
Writes the header for the etrs iteration updates - only for log level > medium.
subroutine, public output_mos_contravariant(rtbse_env, rho, print_key_section)
Outputs the matrix in MO basis for matrix coefficients corresponding to contravariant operator,...
subroutine, public output_field(rtbse_env, append_opt)
Prints the current field components into a file provided by input.
subroutine, public print_timestep_info(rtbse_env, step, electron_num_re, convergence, etrs_num, step_walltime)
Writes the summary line of a completed propagation timestep.
subroutine, public read_restart_info(rtbse_env)
Early phase of the restart read: the starting step index from the .info file, the original run's dt p...
subroutine, public read_restart(rtbse_env)
Reads the density matrix from restart files and updates the starting time.
subroutine, public read_restart_density(rtbse_env)
Late phase of the restart read: overwrites rho from the lab-frame restart matrices and sets restart_e...
subroutine, public read_restart_trace(rtbse_env)
Reads the RESTART.trace prefix (records 1..sim_start) into the in-memory moment/field/ time traces so...
subroutine, public output_moments(rtbse_env, rho)
Outputs the expectation value of moments from a given density matrix.
Data storage and other types for propagation via RT-BSE method.
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 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.
Routine for the real time propagation output.
subroutine, public print_rt_file(rt_unit, headers, xvals, yvals, prefix, prefix_format, xscale_opt, comp_opt)
...
subroutine, public print_moments(moments_section, info_unit, moments, time, imag_opt, append_opt)
Print the dipole moments into a file.
integer, parameter, public rt_file_comp_real
parameters that control an scf iteration
Represent a complex full matrix.
type of a logger, at the moment it contains just a print level starting at which level it should be l...