52#include "../base/base_uses.f90"
58 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
"rt_bse_io"
61 INTEGER,
PARAMETER,
PRIVATE :: restart_trace_version = 1
96 IF (rtbse_env%unit_nr > 0)
THEN
97 WRITE (rtbse_env%unit_nr, *)
''
98 WRITE (rtbse_env%unit_nr,
'(A)')
' /-----------------------------------------------'// &
99 '------------------------------\'
100 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
102 WRITE (rtbse_env%unit_nr,
'(A)')
' | Real Time Bethe-Salpeter Propagation'// &
104 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
106 WRITE (rtbse_env%unit_nr,
'(A)')
' \-----------------------------------------------'// &
107 '------------------------------/'
108 WRITE (rtbse_env%unit_nr, *)
''
111 WRITE (rtbse_env%unit_nr,
'(A19)', advance=
"no")
' Exponential method'
112 SELECT CASE (rtbse_env%mat_exp_method)
114 WRITE (rtbse_env%unit_nr,
'(A61)')
'BCH'
116 WRITE (rtbse_env%unit_nr,
'(A61)')
'EXACT'
119 WRITE (rtbse_env%unit_nr,
'(A22)', advance=
"no")
' Reference Hamiltonian'
120 SELECT CASE (rtbse_env%ham_reference_type)
122 WRITE (rtbse_env%unit_nr,
'(A58)')
'G0W0'
124 WRITE (rtbse_env%unit_nr,
'(A58)')
'Kohn-Sham'
127 WRITE (rtbse_env%unit_nr,
'(A18,L62)')
' Apply delta pulse', &
128 rtbse_env%dft_control%rtp_control%apply_delta_pulse
130 WRITE (rtbse_env%unit_nr,
'(A)')
''
142 REAL(kind=
dp) :: metric
147 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
148 WRITE (rtbse_env%unit_nr,
'(A7,I5, E20.8E3)')
' RTBSE|', step, metric
162 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
163 WRITE (rtbse_env%unit_nr,
'(A13, A20)')
' RTBSE| Iter.',
'Convergence'
180 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: electron_num_re
181 REAL(kind=
dp),
OPTIONAL :: convergence
182 INTEGER,
OPTIONAL :: etrs_num
183 REAL(kind=
dp),
OPTIONAL :: step_walltime
185 LOGICAL :: flag_lrrtbse
190 nch =
SIZE(electron_num_re)
192 IF (.NOT.
PRESENT(convergence) .OR. .NOT.
PRESENT(etrs_num))
THEN
193 flag_lrrtbse = .true.
195 flag_lrrtbse = .false.
198 IF (logger%iter_info%print_level >
low_print_level .AND. rtbse_env%unit_nr > 0)
THEN
199 IF (flag_lrrtbse)
THEN
201 IF (
PRESENT(step_walltime))
THEN
202 WRITE (rtbse_env%unit_nr,
'(A45,T70,F11.3)') &
203 " RTBSE| Estimated runtime for propagation [s]", &
204 step_walltime*real(rtbse_env%sim_nsteps,
dp)
205 WRITE (rtbse_env%unit_nr,
'(A)') &
208 WRITE (rtbse_env%unit_nr,
'(A23,T27,A13,T66,A15)') &
209 " RTBSE| Simulation step",
"Step time [s]",
"Electron number"
215 WRITE (rtbse_env%unit_nr,
'(A23,T27,A13,T47,A15,T68,A15)') &
216 " RTBSE| Simulation step",
"Step time [s]", α
"El. number ()", β
"El. number ()"
220 WRITE (rtbse_env%unit_nr,
'(A23,T66,A15)')
" RTBSE| Simulation step",
"Electron number"
222 WRITE (rtbse_env%unit_nr,
'(A23,T47,A15,T68,A15)') &
223 " RTBSE| Simulation step", α
"El. number ()", β
"El. number ()"
227 IF (
PRESENT(step_walltime))
THEN
229 WRITE (rtbse_env%unit_nr,
'(A7,I16,T30,F10.3,T69,E12.3E3)') &
230 ' RTBSE|', step, step_walltime, electron_num_re(1)
232 WRITE (rtbse_env%unit_nr,
'(A7,I16,T30,F10.3,T49,E12.3E3,T69,E12.3E3)') &
233 ' RTBSE|', step, step_walltime, electron_num_re(1), electron_num_re(2)
237 WRITE (rtbse_env%unit_nr,
'(A7,I16,T61,E20.8E3)')
' RTBSE|', step, electron_num_re(1)
239 WRITE (rtbse_env%unit_nr,
'(A7,I16,T49,E12.3E3,T69,E12.3E3)') &
240 ' RTBSE|', step, electron_num_re(1), electron_num_re(2)
244 WRITE (rtbse_env%unit_nr,
'(A23,A20,A20,A17)')
" RTBSE| Simulation step",
"Convergence", &
245 "Electron number",
"ETRS Iterations"
246 WRITE (rtbse_env%unit_nr,
'(A7,I16,E20.8E3,E20.8E3,I17)')
' RTBSE|', step, convergence, &
247 electron_num_re(1), etrs_num
265 INTEGER :: j, rho_unit_re, rho_unit_im
266 CHARACTER(len=14),
DIMENSION(4) :: file_labels
268 file_labels(1) =
"_SPIN_A_RE.dat"
269 file_labels(2) =
"_SPIN_A_IM.dat"
270 file_labels(3) =
"_SPIN_B_RE.dat"
271 file_labels(4) =
"_SPIN_B_IM.dat"
277 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
278 DO j = 1, rtbse_env%n_spin
281 CALL cp_cfm_to_fm(rho(j), rtbse_env%real_workspace_mo(1), rtbse_env%real_workspace_mo(2))
290 DO j = 1, rtbse_env%n_spin
295 CALL multiply_fm_cfm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
296 1.0_dp, rtbse_env%S_fm, rho(j), &
297 0.0_dp, rtbse_env%rho_workspace(1))
299 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
300 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), rtbse_env%rho_workspace(1), &
301 0.0_dp, rtbse_env%rho_workspace(2))
303 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
304 1.0_dp, rtbse_env%rho_workspace(2), rtbse_env%S_fm, &
305 0.0_dp, rtbse_env%rho_workspace(1))
307 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
308 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
309 0.0_dp, rtbse_env%rho_workspace(2))
312 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
331 INTEGER :: j, rho_unit_re, rho_unit_im
332 CHARACTER(len=21),
DIMENSION(4) :: file_labels
334 file_labels(1) =
"_SPIN_A_RE.dat"
335 file_labels(2) =
"_SPIN_A_IM.dat"
336 file_labels(3) =
"_SPIN_B_RE.dat"
337 file_labels(4) =
"_SPIN_B_IM.dat"
339 DO j = 1, rtbse_env%n_spin
343 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
344 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), ham(j), &
345 0.0_dp, rtbse_env%rho_workspace(1))
347 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
348 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
349 0.0_dp, rtbse_env%rho_workspace(2))
352 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
366 LOGICAL,
OPTIONAL :: append_opt
368 INTEGER :: field_unit, n, i
373 IF (
PRESENT(append_opt)) append = .false.
377 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
379 rtbse_env%field_trace(i, n) = cmplx(rtbse_env%field(i), 0.0, kind=
dp)
381 rtbse_env%time_trace(n) = rtbse_env%sim_time
389 CALL print_rt_file(field_unit, xvals=rtbse_env%time_trace(n:n), &
390 yvals=rtbse_env%field_trace(:, n:n), &
395 " field x [at.u.]", &
396 " field y [at.u.]", &
397 " field z [at.u.]"], &
398 rtbse_env%time_trace(n:n), rtbse_env%field_trace(:, n:n), &
412 CHARACTER(len=default_path_length) :: save_name
413 INTEGER :: k, n, field_unit
414 REAL(kind=
dp),
DIMENSION(3) :: real_field
421 CALL open_file(save_name, file_status=
"OLD", file_form=
"FORMATTED", file_action=
"READ", &
422 unit_number=field_unit)
424 READ (field_unit,
'()')
425 DO k = rtbse_env%sim_start_orig, rtbse_env%sim_start
426 n = k - rtbse_env%sim_start_orig + 1
427 READ (field_unit,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') rtbse_env%time_trace(n), &
428 real_field(1), real_field(2), real_field(3)
429 rtbse_env%field_trace(:, n) = cmplx(real_field(:), 0.0, kind=
dp)
431 rtbse_env%time_trace(n) = rtbse_env%time_trace(n)/
femtoseconds
434 ELSE IF (.NOT. rtbse_env%dft_control%rtp_control%apply_delta_pulse .AND. &
435 rtbse_env%dft_control%rtp_control%initial_wfn ==
use_rt_restart)
THEN
436 cpwarn(
"Restart without RT field file - unknown field trace set to zero.")
451 REAL(kind=
dp),
DIMENSION(3) :: moments_re
454 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
457 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
458 ws => rtbse_env%real_workspace_mo
460 ws => rtbse_env%real_workspace
463 DO j = 1, rtbse_env%n_spin
471 moments_re(i) = -moments_re(i)*rtbse_env%spin_degeneracy
472 rtbse_env%moments_trace(j, i, n) = cmplx(moments_re(i), 0.0, kind=
dp)
480 moments_re(i) = -moments_re(i)*rtbse_env%spin_degeneracy
481 rtbse_env%moments_trace(j, i, n) = rtbse_env%moments_trace(j, i, n) + cmplx(0.0, moments_re(i), kind=
dp)
485 CALL print_moments(rtbse_env%moments_section, rtbse_env%unit_nr, rtbse_env%moments_trace(:, :, n), &
486 rtbse_env%sim_time, .true., append_opt=(rtbse_env%sim_step /= rtbse_env%sim_start_orig))
497 INTEGER :: time_index
498 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: workspace
499 CHARACTER(len=17),
DIMENSION(4) :: file_labels
501 INTEGER :: rho_unit_nr, i
504 file_labels(1) =
"_SPIN_A_RE.matrix"
505 file_labels(2) =
"_SPIN_A_IM.matrix"
506 file_labels(3) =
"_SPIN_B_RE.matrix"
507 file_labels(4) =
"_SPIN_B_IM.matrix"
511 workspace => rtbse_env%real_workspace
513 DO i = 1, rtbse_env%n_spin
516 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i - 1), &
517 file_form=
"UNFORMATTED", file_position=
"REWIND")
521 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i), &
522 file_form=
"UNFORMATTED", file_position=
"REWIND")
527 file_form=
"UNFORMATTED", file_position=
"REWIND")
528 IF (rho_unit_nr > 0)
WRITE (rho_unit_nr) time_index
541 CHARACTER(len=default_path_length) :: save_name, save_name_2
542 INTEGER :: rho_unit_nr, j
543 CHARACTER(len=17),
DIMENSION(4) :: file_labels
547 rtbse_env%restart_extracted = .false.
552 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
553 unit_number=rho_unit_nr)
554 READ (rho_unit_nr) rtbse_env%sim_start
556 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A31,I25,A24)')
" RTBSE| Starting from timestep ", &
557 rtbse_env%sim_start,
", delta kick NOT applied"
559 cpwarn(
"Restart required but no info file found - starting from sim_step given in input")
563 file_labels(1) =
"_SPIN_A_RE.matrix"
564 file_labels(2) =
"_SPIN_A_IM.matrix"
565 file_labels(3) =
"_SPIN_B_RE.matrix"
566 file_labels(4) =
"_SPIN_B_IM.matrix"
567 DO j = 1, rtbse_env%n_spin
569 extension=file_labels(2*j - 1), my_local=.false.)
571 extension=file_labels(2*j), my_local=.false.)
573 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
574 unit_number=rho_unit_nr)
577 CALL open_file(save_name_2, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
578 unit_number=rho_unit_nr)
581 CALL cp_fm_to_cfm(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), &
583 rtbse_env%restart_extracted = .true.
585 cpwarn(
"Restart without some restart matrices - starting from SCF density.")
601 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: workspace
602 CHARACTER(len=17),
DIMENSION(4) :: file_labels
603 CHARACTER(len=16),
DIMENSION(2) :: c_file_labels
605 INTEGER :: rho_unit_nr, i
608 file_labels(1) =
"_SPIN_A_RE.matrix"
609 file_labels(2) =
"_SPIN_A_IM.matrix"
610 file_labels(3) =
"_SPIN_B_RE.matrix"
611 file_labels(4) =
"_SPIN_B_IM.matrix"
612 c_file_labels(1) =
"_SPIN_A_C.matrix"
613 c_file_labels(2) =
"_SPIN_B_C.matrix"
618 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
619 workspace => rtbse_env%real_workspace_mo
621 workspace => rtbse_env%real_workspace
624 DO i = 1, rtbse_env%n_spin
627 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i - 1), &
628 file_form=
"UNFORMATTED", file_position=
"REWIND")
632 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i), &
633 file_form=
"UNFORMATTED", file_position=
"REWIND")
638 file_form=
"UNFORMATTED", file_position=
"REWIND")
639 IF (rho_unit_nr > 0)
WRITE (rho_unit_nr) rtbse_env%sim_step
644 IF (
ASSOCIATED(rtbse_env%real_workspace_mo) .AND. .NOT. rtbse_env%restart_C_written)
THEN
645 DO i = 1, rtbse_env%n_spin
646 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=c_file_labels(i), &
647 file_form=
"UNFORMATTED", file_position=
"REWIND")
651 rtbse_env%restart_C_written = .true.
654 CALL write_restart_trace(rtbse_env)
665 SUBROUTINE write_restart_trace(rtbse_env)
668 CHARACTER(len=default_path_length) :: save_name
669 INTEGER :: trace_unit, n, n_eps, n_slot
674 IF (rtbse_env%unit_nr > 0)
THEN
675 n_slot = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
676 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
679 n_eps =
SIZE(rtbse_env%eps_active, 1)
683 IF (.NOT. rtbse_env%restart_trace_written)
THEN
684 CALL open_file(save_name, file_status=
"UNKNOWN", file_form=
"UNFORMATTED", file_action=
"WRITE", &
685 file_position=
"REWIND", unit_number=trace_unit)
686 WRITE (trace_unit) restart_trace_version
687 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
688 WRITE (trace_unit) rtbse_env%n_spin, rtbse_env%mo_active, rtbse_env%n_ao
690 WRITE (trace_unit) rtbse_env%n_spin, rtbse_env%n_ao, rtbse_env%n_ao
692 WRITE (trace_unit) rtbse_env%sim_dt
693 WRITE (trace_unit) real(rtbse_env%dft_control%rtp_control%delta_pulse_direction,
dp), &
694 rtbse_env%dft_control%rtp_control%delta_pulse_scale
695 WRITE (trace_unit) n_eps
696 IF (n_eps > 0)
WRITE (trace_unit) rtbse_env%eps_active
698 WRITE (trace_unit) n, rtbse_env%time_trace(n), rtbse_env%field_trace(:, n), &
699 rtbse_env%moments_trace(:, :, n)
702 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"WRITE", &
703 file_position=
"APPEND", unit_number=trace_unit)
704 WRITE (trace_unit) n_slot, rtbse_env%time_trace(n_slot), rtbse_env%field_trace(:, n_slot), &
705 rtbse_env%moments_trace(:, :, n_slot)
709 rtbse_env%restart_trace_written = .true.
710 END SUBROUTINE write_restart_trace
721 CHARACTER(len=default_path_length) :: save_name
722 INTEGER :: info_unit, trace_unit, version
729 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
730 unit_number=info_unit)
731 READ (info_unit) rtbse_env%sim_start
733 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A31,I25,A24)')
" RTBSE| Starting from timestep ", &
734 rtbse_env%sim_start,
", delta kick NOT applied"
736 cpwarn(
"Restart required but no info file found - starting from sim_step given in input")
744 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
745 unit_number=trace_unit)
746 READ (trace_unit) version
747 IF (version == restart_trace_version)
THEN
749 READ (trace_unit) rtbse_env%sim_dt_restart
755 NULLIFY (scf_control)
756 CALL get_qs_env(rtbse_env%qs_env, scf_control=scf_control)
758 cpwarn(
"RT_RESTART without SCF_GUESS RESTART - SCF may reconverge to a gauge-rotated MO basis.")
771 CHARACTER(len=default_path_length) :: save_name, err_msg
772 INTEGER :: trace_unit, version, n_spin_file, &
773 n_basis_file, n_ao_file, n_eps, n, &
775 REAL(kind=
dp) :: dt_file, kick_scale_file, t_rec
776 REAL(kind=
dp),
DIMENSION(3) :: kick_dir_file
777 REAL(kind=
dp),
DIMENSION(:, :),
ALLOCATABLE :: eps_file
778 COMPLEX(kind=dp),
DIMENSION(3) :: field_rec
779 COMPLEX(kind=dp),
DIMENSION(:, :),
ALLOCATABLE :: mom_rec
787 IF (rtbse_env%sim_start > 0)
THEN
788 CALL cp_abort(__location__, &
789 "RT_RESTART without RESTART.trace - the continuation FT would miss the pre-restart "// &
790 "history. Restore the original run's RESTART.trace next to the density restart files.")
795 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
796 unit_number=trace_unit)
797 READ (trace_unit) version
798 IF (version /= restart_trace_version)
THEN
799 WRITE (err_msg,
'(A,I0,A,I0)')
"RESTART.trace: format version ", version, &
800 " does not match this binary's version ", restart_trace_version
801 CALL cp_abort(__location__, trim(err_msg))
803 READ (trace_unit) n_spin_file, n_basis_file, n_ao_file
804 IF (n_spin_file /= rtbse_env%n_spin) cpabort(
"RESTART.trace: n_spin mismatch")
805 IF (n_ao_file /= rtbse_env%n_ao) cpabort(
"RESTART.trace: n_ao mismatch")
807 IF (
ASSOCIATED(rtbse_env%real_workspace_mo) .AND. n_basis_file /= rtbse_env%mo_active)
THEN
808 CALL cp_abort(__location__, &
809 "RESTART.trace: active-MO count differs from the original run - same-window continuation only")
811 READ (trace_unit) dt_file
814 IF (abs(dt_file - rtbse_env%sim_dt) > 1.0e-12_dp*max(1.0_dp, abs(rtbse_env%sim_dt)))
THEN
815 WRITE (err_msg,
'(A,ES16.9,A)') &
816 "RESTART.trace: TIMESTEP differs from the original run - continuation undefined. "// &
818 " or enable RTBSE%ENFORCE_MAX_DT to inherit it automatically."
819 CALL cp_abort(__location__, trim(err_msg))
821 READ (trace_unit) kick_dir_file, kick_scale_file
822 IF (maxval(abs(kick_dir_file - real(rtbse_env%dft_control%rtp_control%delta_pulse_direction,
dp))) > 1.0e-12_dp .OR. &
823 abs(kick_scale_file - rtbse_env%dft_control%rtp_control%delta_pulse_scale) > 1.0e-12_dp)
THEN
824 CALL cp_warn(__location__, &
825 "RESTART.trace: delta-kick parameters differ from the original run - FT normalization inconsistent.")
827 READ (trace_unit) n_eps
829 ALLOCATE (eps_file(n_eps, rtbse_env%n_spin))
830 READ (trace_unit) eps_file
831 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
832 IF (n_eps /=
SIZE(rtbse_env%eps_active, 1))
THEN
833 CALL cp_abort(__location__,
"RESTART.trace: active-window size mismatch")
837 ALLOCATE (rtbse_env%eps_active_restart(n_eps, rtbse_env%n_spin))
838 rtbse_env%eps_active_restart(:, :) = eps_file
840 DEALLOCATE (eps_file)
843 ALLOCATE (mom_rec(rtbse_env%n_spin, 3))
846 READ (trace_unit, iostat=ios) n, t_rec, field_rec, mom_rec
851 IF (n > rtbse_env%sim_start + 1)
EXIT
852 IF (n >
SIZE(rtbse_env%time_trace))
THEN
853 cpabort(
"RESTART.trace: record index exceeds trace size - increase MOTION%MD%STEPS")
855 rtbse_env%time_trace(n) = t_rec
856 rtbse_env%field_trace(:, n) = field_rec
857 rtbse_env%moments_trace(:, :, n) = mom_rec
858 n_read_max = max(n_read_max, n)
862 IF (n_read_max < rtbse_env%sim_start)
THEN
863 cpwarn(
"RESTART.trace: fewer records than restart step - trace prefix incomplete.")
875 REAL(kind=
dp) :: eps_dev
877 IF (.NOT.
ASSOCIATED(rtbse_env%eps_active_restart))
RETURN
879 eps_dev = maxval(abs(rtbse_env%eps_active_restart - rtbse_env%eps_active))
880 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A,ES12.3,A)') &
881 " RTBSE| Restart eps_active max deviation vs original run ", eps_dev,
" Ha"
883 IF (eps_dev > 1.0e-4_dp/
evolt)
THEN
884 CALL cp_warn(__location__, &
885 "RESTART.trace: active eigenvalues deviate beyond 0.1 meV - "// &
886 "Hamiltonian changed; continuation is physically inconsistent.")
889 DEALLOCATE (rtbse_env%eps_active_restart)
890 NULLIFY (rtbse_env%eps_active_restart)
901 CHARACTER(len=default_path_length) :: save_name, save_name_2
902 INTEGER :: rho_unit_nr, j
903 CHARACTER(len=17),
DIMENSION(4) :: file_labels
908 rtbse_env%restart_extracted = .false.
911 IF (
ASSOCIATED(rtbse_env%real_workspace_mo))
THEN
912 ws => rtbse_env%real_workspace_mo
914 ws => rtbse_env%real_workspace
918 file_labels(1) =
"_SPIN_A_RE.matrix"
919 file_labels(2) =
"_SPIN_A_IM.matrix"
920 file_labels(3) =
"_SPIN_B_RE.matrix"
921 file_labels(4) =
"_SPIN_B_IM.matrix"
922 DO j = 1, rtbse_env%n_spin
924 extension=file_labels(2*j - 1), my_local=.false.)
926 extension=file_labels(2*j), my_local=.false.)
928 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
929 unit_number=rho_unit_nr)
932 CALL open_file(save_name_2, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
933 unit_number=rho_unit_nr)
938 rtbse_env%restart_extracted = .true.
940 cpwarn(
"Restart without some restart matrices - starting from SCF density.")
952 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: c_old
953 LOGICAL,
INTENT(OUT) :: found
955 CHARACTER(len=default_path_length) :: save_name
956 CHARACTER(len=16),
DIMENSION(2) :: c_file_labels
959 c_file_labels(1) =
"_SPIN_A_C.matrix"
960 c_file_labels(2) =
"_SPIN_B_C.matrix"
963 DO j = 1, rtbse_env%n_spin
965 extension=c_file_labels(j), my_local=.false.)
967 cpwarn(
"Restart without C_active file - assuming identical MO gauge (no basis bridge).")
970 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...