47#include "../base/base_uses.f90"
53 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
"rt_bse_io"
82 IF (rtbse_env%unit_nr > 0)
THEN
83 WRITE (rtbse_env%unit_nr, *)
''
84 WRITE (rtbse_env%unit_nr,
'(A)')
' /-----------------------------------------------'// &
85 '------------------------------\'
86 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
88 WRITE (rtbse_env%unit_nr,
'(A)')
' | Real Time Bethe-Salpeter Propagation'// &
90 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
92 WRITE (rtbse_env%unit_nr,
'(A)')
' \-----------------------------------------------'// &
93 '------------------------------/'
94 WRITE (rtbse_env%unit_nr, *)
''
97 WRITE (rtbse_env%unit_nr,
'(A19)', advance=
"no")
' Exponential method'
98 SELECT CASE (rtbse_env%mat_exp_method)
100 WRITE (rtbse_env%unit_nr,
'(A61)')
'BCH'
102 WRITE (rtbse_env%unit_nr,
'(A61)')
'EXACT'
105 WRITE (rtbse_env%unit_nr,
'(A22)', advance=
"no")
' Reference Hamiltonian'
106 SELECT CASE (rtbse_env%ham_reference_type)
108 WRITE (rtbse_env%unit_nr,
'(A58)')
'G0W0'
110 WRITE (rtbse_env%unit_nr,
'(A58)')
'Kohn-Sham'
113 WRITE (rtbse_env%unit_nr,
'(A18,L62)')
' Apply delta pulse', &
114 rtbse_env%dft_control%rtp_control%apply_delta_pulse
116 WRITE (rtbse_env%unit_nr,
'(A)')
''
128 REAL(kind=
dp) :: metric
133 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
134 WRITE (rtbse_env%unit_nr,
'(A7,I5, E20.8E3)')
' RTBSE|', step, metric
148 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
149 WRITE (rtbse_env%unit_nr,
'(A13, A20)')
' RTBSE| Iter.',
'Convergence'
160 REAL(kind=
dp) :: convergence
161 REAL(kind=
dp) :: electron_num_re
167 IF (logger%iter_info%print_level >
low_print_level .AND. rtbse_env%unit_nr > 0)
THEN
168 WRITE (rtbse_env%unit_nr,
'(A23,A20,A20,A17)')
" RTBSE| Simulation step",
"Convergence", &
169 "Electron number",
"ETRS Iterations"
170 WRITE (rtbse_env%unit_nr,
'(A7,I16,E20.8E3,E20.8E3,I17)')
' RTBSE|', step, convergence, &
171 electron_num_re, etrs_num
188 INTEGER :: j, rho_unit_re, rho_unit_im
189 CHARACTER(len=14),
DIMENSION(4) :: file_labels
191 file_labels(1) =
"_SPIN_A_RE.dat"
192 file_labels(2) =
"_SPIN_A_IM.dat"
193 file_labels(3) =
"_SPIN_B_RE.dat"
194 file_labels(4) =
"_SPIN_B_IM.dat"
197 DO j = 1, rtbse_env%n_spin
202 CALL multiply_fm_cfm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
203 1.0_dp, rtbse_env%S_fm, rho(j), &
204 0.0_dp, rtbse_env%rho_workspace(1))
206 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
207 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), rtbse_env%rho_workspace(1), &
208 0.0_dp, rtbse_env%rho_workspace(2))
210 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
211 1.0_dp, rtbse_env%rho_workspace(2), rtbse_env%S_fm, &
212 0.0_dp, rtbse_env%rho_workspace(1))
214 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
215 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
216 0.0_dp, rtbse_env%rho_workspace(2))
219 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
238 INTEGER :: j, rho_unit_re, rho_unit_im
239 CHARACTER(len=21),
DIMENSION(4) :: file_labels
241 file_labels(1) =
"_SPIN_A_RE.dat"
242 file_labels(2) =
"_SPIN_A_IM.dat"
243 file_labels(3) =
"_SPIN_B_RE.dat"
244 file_labels(4) =
"_SPIN_B_IM.dat"
246 DO j = 1, rtbse_env%n_spin
250 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
251 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), ham(j), &
252 0.0_dp, rtbse_env%rho_workspace(1))
254 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
255 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
256 0.0_dp, rtbse_env%rho_workspace(2))
259 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
274 INTEGER :: field_unit, n, i
282 IF (field_unit /= -1)
THEN
283 WRITE (field_unit,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') rtbse_env%sim_time*
femtoseconds, &
284 rtbse_env%field(1), rtbse_env%field(2), rtbse_env%field(3)
288 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
290 rtbse_env%field_trace(i, n) = cmplx(rtbse_env%field(i), 0.0, kind=
dp)
292 rtbse_env%time_trace(n) = rtbse_env%sim_time
304 CHARACTER(len=default_path_length) :: save_name
305 INTEGER :: k, n, field_unit
306 REAL(kind=
dp),
DIMENSION(3) :: real_field
313 CALL open_file(save_name, file_status=
"OLD", file_form=
"FORMATTED", file_action=
"READ", &
314 unit_number=field_unit)
315 DO k = rtbse_env%sim_start_orig, rtbse_env%sim_start
316 n = k - rtbse_env%sim_start_orig + 1
317 READ (field_unit,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') rtbse_env%time_trace(n), &
318 real_field(1), real_field(2), real_field(3)
319 rtbse_env%field_trace(:, n) = cmplx(real_field(:), 0.0, kind=
dp)
321 rtbse_env%time_trace(n) = rtbse_env%time_trace(n)/
femtoseconds
324 ELSE IF (.NOT. rtbse_env%dft_control%rtp_control%apply_delta_pulse .AND. &
325 rtbse_env%dft_control%rtp_control%initial_wfn ==
use_rt_restart)
THEN
326 cpwarn(
"Restart without RT field file - unknown field trace set to zero.")
341 REAL(kind=
dp),
DIMENSION(3) :: moments_re
343 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
345 DO j = 1, rtbse_env%n_spin
347 CALL cp_cfm_to_fm(msource=rho(j), mtargetr=rtbse_env%real_workspace(2))
350 CALL cp_fm_transpose(rtbse_env%moments(i), rtbse_env%real_workspace(1))
351 CALL cp_fm_trace(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), moments_re(i))
353 moments_re(i) = -moments_re(i)*rtbse_env%spin_degeneracy
354 rtbse_env%moments_trace(j, i, n) = cmplx(moments_re(i), 0.0, kind=
dp)
357 CALL cp_cfm_to_fm(msource=rho(j), mtargeti=rtbse_env%real_workspace(2))
359 CALL cp_fm_transpose(rtbse_env%moments(i), rtbse_env%real_workspace(1))
360 CALL cp_fm_trace(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), moments_re(i))
362 moments_re(i) = -moments_re(i)*rtbse_env%spin_degeneracy
363 rtbse_env%moments_trace(j, i, n) = rtbse_env%moments_trace(j, i, n) + cmplx(0.0, moments_re(i), kind=
dp)
367 CALL print_moments(rtbse_env%moments_section, rtbse_env%unit_nr, rtbse_env%moments_trace(:, :, n), &
368 rtbse_env%sim_time, .true.)
379 INTEGER :: time_index
380 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: workspace
381 CHARACTER(len=17),
DIMENSION(4) :: file_labels
383 INTEGER :: rho_unit_nr, i
386 file_labels(1) =
"_SPIN_A_RE.matrix"
387 file_labels(2) =
"_SPIN_A_IM.matrix"
388 file_labels(3) =
"_SPIN_B_RE.matrix"
389 file_labels(4) =
"_SPIN_B_IM.matrix"
393 workspace => rtbse_env%real_workspace
395 DO i = 1, rtbse_env%n_spin
398 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i - 1), &
399 file_form=
"UNFORMATTED", file_position=
"REWIND")
403 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i), &
404 file_form=
"UNFORMATTED", file_position=
"REWIND")
409 file_form=
"UNFORMATTED", file_position=
"REWIND")
410 IF (rho_unit_nr > 0)
WRITE (rho_unit_nr) time_index
423 CHARACTER(len=default_path_length) :: save_name, save_name_2
424 INTEGER :: rho_unit_nr, j
425 CHARACTER(len=17),
DIMENSION(4) :: file_labels
429 rtbse_env%restart_extracted = .false.
434 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
435 unit_number=rho_unit_nr)
436 READ (rho_unit_nr) rtbse_env%sim_start
438 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A31,I25,A24)')
" RTBSE| Starting from timestep ", &
439 rtbse_env%sim_start,
", delta kick NOT applied"
441 cpwarn(
"Restart required but no info file found - starting from sim_step given in input")
445 file_labels(1) =
"_SPIN_A_RE.matrix"
446 file_labels(2) =
"_SPIN_A_IM.matrix"
447 file_labels(3) =
"_SPIN_B_RE.matrix"
448 file_labels(4) =
"_SPIN_B_IM.matrix"
449 DO j = 1, rtbse_env%n_spin
451 extension=file_labels(2*j - 1), my_local=.false.)
453 extension=file_labels(2*j), my_local=.false.)
455 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
456 unit_number=rho_unit_nr)
459 CALL open_file(save_name_2, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
460 unit_number=rho_unit_nr)
463 CALL cp_fm_to_cfm(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), &
465 rtbse_env%restart_extracted = .true.
467 cpwarn(
"Restart without some restart matrices - starting from SCF density.")
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
Input/output from the propagation via RT-BSE method.
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 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 output_field(rtbse_env)
Prints the current field components into a file provided by input.
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 read_restart(rtbse_env)
Reads the density matrix from restart files and updates the starting time.
subroutine, public print_timestep_info(rtbse_env, step, convergence, electron_num_re, etrs_num)
Writes the header for the etrs iteration updates - only for log level > low.
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_moments(moments_section, info_unit, moments, time, imag_opt)
Print the dipole moments into a file.
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...