49#include "../base/base_uses.f90"
55 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
"rt_bse_io"
84 IF (rtbse_env%unit_nr > 0)
THEN
85 WRITE (rtbse_env%unit_nr, *)
''
86 WRITE (rtbse_env%unit_nr,
'(A)')
' /-----------------------------------------------'// &
87 '------------------------------\'
88 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
90 WRITE (rtbse_env%unit_nr,
'(A)')
' | Real Time Bethe-Salpeter Propagation'// &
92 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
94 WRITE (rtbse_env%unit_nr,
'(A)')
' \-----------------------------------------------'// &
95 '------------------------------/'
96 WRITE (rtbse_env%unit_nr, *)
''
99 WRITE (rtbse_env%unit_nr,
'(A19)', advance=
"no")
' Exponential method'
100 SELECT CASE (rtbse_env%mat_exp_method)
102 WRITE (rtbse_env%unit_nr,
'(A61)')
'BCH'
104 WRITE (rtbse_env%unit_nr,
'(A61)')
'EXACT'
107 WRITE (rtbse_env%unit_nr,
'(A22)', advance=
"no")
' Reference Hamiltonian'
108 SELECT CASE (rtbse_env%ham_reference_type)
110 WRITE (rtbse_env%unit_nr,
'(A58)')
'G0W0'
112 WRITE (rtbse_env%unit_nr,
'(A58)')
'Kohn-Sham'
115 WRITE (rtbse_env%unit_nr,
'(A18,L62)')
' Apply delta pulse', &
116 rtbse_env%dft_control%rtp_control%apply_delta_pulse
118 WRITE (rtbse_env%unit_nr,
'(A)')
''
130 REAL(kind=
dp) :: metric
135 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
136 WRITE (rtbse_env%unit_nr,
'(A7,I5, E20.8E3)')
' RTBSE|', step, metric
150 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
151 WRITE (rtbse_env%unit_nr,
'(A13, A20)')
' RTBSE| Iter.',
'Convergence'
162 REAL(kind=
dp) :: convergence
163 REAL(kind=
dp) :: electron_num_re
169 IF (logger%iter_info%print_level >
low_print_level .AND. rtbse_env%unit_nr > 0)
THEN
170 WRITE (rtbse_env%unit_nr,
'(A23,A20,A20,A17)')
" RTBSE| Simulation step",
"Convergence", &
171 "Electron number",
"ETRS Iterations"
172 WRITE (rtbse_env%unit_nr,
'(A7,I16,E20.8E3,E20.8E3,I17)')
' RTBSE|', step, convergence, &
173 electron_num_re, etrs_num
190 INTEGER :: j, rho_unit_re, rho_unit_im
191 CHARACTER(len=14),
DIMENSION(4) :: file_labels
193 file_labels(1) =
"_SPIN_A_RE.dat"
194 file_labels(2) =
"_SPIN_A_IM.dat"
195 file_labels(3) =
"_SPIN_B_RE.dat"
196 file_labels(4) =
"_SPIN_B_IM.dat"
199 DO j = 1, rtbse_env%n_spin
204 CALL multiply_fm_cfm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
205 1.0_dp, rtbse_env%S_fm, rho(j), &
206 0.0_dp, rtbse_env%rho_workspace(1))
208 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
209 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), rtbse_env%rho_workspace(1), &
210 0.0_dp, rtbse_env%rho_workspace(2))
212 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
213 1.0_dp, rtbse_env%rho_workspace(2), rtbse_env%S_fm, &
214 0.0_dp, rtbse_env%rho_workspace(1))
216 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
217 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
218 0.0_dp, rtbse_env%rho_workspace(2))
221 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
240 INTEGER :: j, rho_unit_re, rho_unit_im
241 CHARACTER(len=21),
DIMENSION(4) :: file_labels
243 file_labels(1) =
"_SPIN_A_RE.dat"
244 file_labels(2) =
"_SPIN_A_IM.dat"
245 file_labels(3) =
"_SPIN_B_RE.dat"
246 file_labels(4) =
"_SPIN_B_IM.dat"
248 DO j = 1, rtbse_env%n_spin
252 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
253 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), ham(j), &
254 0.0_dp, rtbse_env%rho_workspace(1))
256 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
257 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
258 0.0_dp, rtbse_env%rho_workspace(2))
261 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
275 LOGICAL,
OPTIONAL :: append_opt
277 INTEGER :: field_unit, n, i
282 IF (
PRESENT(append_opt)) append = .false.
286 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
288 rtbse_env%field_trace(i, n) = cmplx(rtbse_env%field(i), 0.0, kind=
dp)
290 rtbse_env%time_trace(n) = rtbse_env%sim_time
298 CALL print_rt_file(field_unit, xvals=rtbse_env%time_trace(n:n), &
299 yvals=rtbse_env%field_trace(:, n:n), &
304 " field x [at.u.]", &
305 " field y [at.u.]", &
306 " field z [at.u.]"], &
307 rtbse_env%time_trace(n:n), rtbse_env%field_trace(:, n:n), &
321 CHARACTER(len=default_path_length) :: save_name
322 INTEGER :: k, n, field_unit
323 REAL(kind=
dp),
DIMENSION(3) :: real_field
330 CALL open_file(save_name, file_status=
"OLD", file_form=
"FORMATTED", file_action=
"READ", &
331 unit_number=field_unit)
333 READ (field_unit,
'()')
334 DO k = rtbse_env%sim_start_orig, rtbse_env%sim_start
335 n = k - rtbse_env%sim_start_orig + 1
336 READ (field_unit,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') rtbse_env%time_trace(n), &
337 real_field(1), real_field(2), real_field(3)
338 rtbse_env%field_trace(:, n) = cmplx(real_field(:), 0.0, kind=
dp)
340 rtbse_env%time_trace(n) = rtbse_env%time_trace(n)/
femtoseconds
343 ELSE IF (.NOT. rtbse_env%dft_control%rtp_control%apply_delta_pulse .AND. &
344 rtbse_env%dft_control%rtp_control%initial_wfn ==
use_rt_restart)
THEN
345 cpwarn(
"Restart without RT field file - unknown field trace set to zero.")
360 REAL(kind=
dp),
DIMENSION(3) :: moments_re
362 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
364 DO j = 1, rtbse_env%n_spin
366 CALL cp_cfm_to_fm(msource=rho(j), mtargetr=rtbse_env%real_workspace(2))
369 CALL cp_fm_transpose(rtbse_env%moments(i), rtbse_env%real_workspace(1))
370 CALL cp_fm_trace(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), moments_re(i))
372 moments_re(i) = -moments_re(i)*rtbse_env%spin_degeneracy
373 rtbse_env%moments_trace(j, i, n) = cmplx(moments_re(i), 0.0, kind=
dp)
376 CALL cp_cfm_to_fm(msource=rho(j), mtargeti=rtbse_env%real_workspace(2))
378 CALL cp_fm_transpose(rtbse_env%moments(i), rtbse_env%real_workspace(1))
379 CALL cp_fm_trace(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), moments_re(i))
381 moments_re(i) = -moments_re(i)*rtbse_env%spin_degeneracy
382 rtbse_env%moments_trace(j, i, n) = rtbse_env%moments_trace(j, i, n) + cmplx(0.0, moments_re(i), kind=
dp)
386 CALL print_moments(rtbse_env%moments_section, rtbse_env%unit_nr, rtbse_env%moments_trace(:, :, n), &
387 rtbse_env%sim_time, .true., append_opt=(rtbse_env%sim_step /= rtbse_env%sim_start_orig))
398 INTEGER :: time_index
399 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: workspace
400 CHARACTER(len=17),
DIMENSION(4) :: file_labels
402 INTEGER :: rho_unit_nr, i
405 file_labels(1) =
"_SPIN_A_RE.matrix"
406 file_labels(2) =
"_SPIN_A_IM.matrix"
407 file_labels(3) =
"_SPIN_B_RE.matrix"
408 file_labels(4) =
"_SPIN_B_IM.matrix"
412 workspace => rtbse_env%real_workspace
414 DO i = 1, rtbse_env%n_spin
417 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i - 1), &
418 file_form=
"UNFORMATTED", file_position=
"REWIND")
422 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i), &
423 file_form=
"UNFORMATTED", file_position=
"REWIND")
428 file_form=
"UNFORMATTED", file_position=
"REWIND")
429 IF (rho_unit_nr > 0)
WRITE (rho_unit_nr) time_index
442 CHARACTER(len=default_path_length) :: save_name, save_name_2
443 INTEGER :: rho_unit_nr, j
444 CHARACTER(len=17),
DIMENSION(4) :: file_labels
448 rtbse_env%restart_extracted = .false.
453 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
454 unit_number=rho_unit_nr)
455 READ (rho_unit_nr) rtbse_env%sim_start
457 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A31,I25,A24)')
" RTBSE| Starting from timestep ", &
458 rtbse_env%sim_start,
", delta kick NOT applied"
460 cpwarn(
"Restart required but no info file found - starting from sim_step given in input")
464 file_labels(1) =
"_SPIN_A_RE.matrix"
465 file_labels(2) =
"_SPIN_A_IM.matrix"
466 file_labels(3) =
"_SPIN_B_RE.matrix"
467 file_labels(4) =
"_SPIN_B_IM.matrix"
468 DO j = 1, rtbse_env%n_spin
470 extension=file_labels(2*j - 1), my_local=.false.)
472 extension=file_labels(2*j), my_local=.false.)
474 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
475 unit_number=rho_unit_nr)
478 CALL open_file(save_name_2, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
479 unit_number=rho_unit_nr)
482 CALL cp_fm_to_cfm(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), &
484 rtbse_env%restart_extracted = .true.
486 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 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 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_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
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...