(git:97501a3)
Loading...
Searching...
No Matches
rt_bse_io.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Input/output from the propagation via RT-BSE method.
10!> \author Stepan Marek (08.24)
11! **************************************************************************************************
12
14 USE cp_fm_types, ONLY: cp_fm_type, &
21 USE cp_cfm_types, ONLY: cp_cfm_type, &
25 USE kinds, ONLY: dp, &
39 USE rt_bse_types, ONLY: rtbse_env_type, &
42 USE cp_files, ONLY: open_file, &
45 USE input_constants, ONLY: do_exact, &
46 do_bch, &
50 USE physcon, ONLY: femtoseconds, &
51 evolt
52 USE mathconstants, ONLY: twopi
54
55#include "../base/base_uses.f90"
56
57 IMPLICIT NONE
58
59 PRIVATE
60
61 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = "rt_bse_io"
62
63
64
65
66 PUBLIC :: output_moments, &
71 read_field, &
80
81CONTAINS
82
83! **************************************************************************************************
84!> \brief Writes the header and basic info to the standard output
85!> \param rtbse_env Entry point - rtbse environment
86! **************************************************************************************************
87 SUBROUTINE print_rtbse_header_info(rtbse_env)
88 TYPE(rtbse_env_type) :: rtbse_env
89
90 WRITE (rtbse_env%unit_nr, *) ''
91 WRITE (rtbse_env%unit_nr, '(A)') ' /-----------------------------------------------'// &
92 '------------------------------\'
93 WRITE (rtbse_env%unit_nr, '(A)') ' | '// &
94 ' |'
95 WRITE (rtbse_env%unit_nr, '(A)') ' | Real Time Bethe-Salpeter Propagation'// &
96 ' |'
97 WRITE (rtbse_env%unit_nr, '(A)') ' | '// &
98 ' |'
99 WRITE (rtbse_env%unit_nr, '(A)') ' \-----------------------------------------------'// &
100 '------------------------------/'
101 WRITE (rtbse_env%unit_nr, *) ''
102
103 ! Methods used
104 WRITE (rtbse_env%unit_nr, '(A19)', advance="no") ' Exponential method'
105 SELECT CASE (rtbse_env%mat_exp_method)
106 CASE (do_bch)
107 WRITE (rtbse_env%unit_nr, '(A61)') 'BCH'
108 CASE (do_exact)
109 WRITE (rtbse_env%unit_nr, '(A61)') 'EXACT'
110 END SELECT
111
112 WRITE (rtbse_env%unit_nr, '(A22)', advance="no") ' Reference Hamiltonian'
113 SELECT CASE (rtbse_env%ham_reference_type)
114 CASE (rtp_bse_ham_g0w0)
115 WRITE (rtbse_env%unit_nr, '(A58)') 'G0W0'
116 CASE (rtp_bse_ham_ks)
117 WRITE (rtbse_env%unit_nr, '(A58)') 'Kohn-Sham'
118 END SELECT
119
120 WRITE (rtbse_env%unit_nr, '(A18,L62)') ' Apply delta pulse', &
121 rtbse_env%dft_control%rtp_control%apply_delta_pulse
122
123 WRITE (rtbse_env%unit_nr, '(A)') ''
124
125 END SUBROUTINE
126
127! **************************************************************************************************
128!> \brief Writes the update after single etrs iteration - only for log level > medium
129!> \param rtbse_env Entry point - rtbse environment
130! **************************************************************************************************
131 SUBROUTINE print_etrs_info(rtbse_env, step, metric)
132 TYPE(rtbse_env_type) :: rtbse_env
133 INTEGER :: step
134 REAL(kind=dp) :: metric
135 TYPE(cp_logger_type), POINTER :: logger
136
137 logger => cp_get_default_logger()
138
139 IF (logger%iter_info%print_level > medium_print_level .AND. rtbse_env%unit_nr > 0) THEN
140 WRITE (rtbse_env%unit_nr, '(A7,I5, E20.8E3)') ' RTBSE|', step, metric
141 END IF
142
143 END SUBROUTINE
144! **************************************************************************************************
145!> \brief Writes the header for the etrs iteration updates - only for log level > medium
146!> \param rtbse_env Entry point - rtbse environment
147! **************************************************************************************************
148 SUBROUTINE print_etrs_info_header(rtbse_env)
149 TYPE(rtbse_env_type) :: rtbse_env
150 TYPE(cp_logger_type), POINTER :: logger
151
152 logger => cp_get_default_logger()
153
154 IF (logger%iter_info%print_level > medium_print_level .AND. rtbse_env%unit_nr > 0) THEN
155 WRITE (rtbse_env%unit_nr, '(A13, A20)') ' RTBSE| Iter.', 'Convergence'
156 END IF
157
158 END SUBROUTINE
159! **************************************************************************************************
160!> \brief Writes the header for the etrs iteration updates - only for log level > medium
161!> \param rtbse_env Entry point - rtbse environment
162! **************************************************************************************************
163 SUBROUTINE print_timestep_info(rtbse_env, step, convergence, electron_num_re, etrs_num)
164 TYPE(rtbse_env_type) :: rtbse_env
165 INTEGER :: step
166 REAL(kind=dp) :: convergence
167 REAL(kind=dp) :: electron_num_re
168 INTEGER :: etrs_num
169 TYPE(cp_logger_type), POINTER :: logger
170
171 logger => cp_get_default_logger()
172
173 IF (logger%iter_info%print_level > low_print_level .AND. rtbse_env%unit_nr > 0) THEN
174 WRITE (rtbse_env%unit_nr, '(A23,A20,A20,A17)') " RTBSE| Simulation step", "Convergence", &
175 "Electron number", "ETRS Iterations"
176 WRITE (rtbse_env%unit_nr, '(A7,I16,E20.8E3,E20.8E3,I17)') ' RTBSE|', step, convergence, &
177 electron_num_re, etrs_num
178 END IF
179
180 END SUBROUTINE
181
182! **************************************************************************************************
183!> \brief Outputs the matrix in MO basis for matrix coefficients corresponding to contravariant
184!> operator, i.e. density matrix
185!> \param rtbse_env Entry point - gwbse environment
186!> \param rho Density matrix in AO basis
187!> \param rtp_section RTP input section
188! **************************************************************************************************
189 SUBROUTINE output_mos_contravariant(rtbse_env, rho, print_key_section)
190 TYPE(rtbse_env_type) :: rtbse_env
191 TYPE(cp_cfm_type), DIMENSION(:), POINTER :: rho
192 TYPE(section_vals_type), POINTER :: print_key_section
193 TYPE(cp_logger_type), POINTER :: logger
194 INTEGER :: j, rho_unit_re, rho_unit_im
195 CHARACTER(len=14), DIMENSION(4) :: file_labels
196
197 file_labels(1) = "_SPIN_A_RE.dat"
198 file_labels(2) = "_SPIN_A_IM.dat"
199 file_labels(3) = "_SPIN_B_RE.dat"
200 file_labels(4) = "_SPIN_B_IM.dat"
201 logger => cp_get_default_logger()
202 ! Start by multiplying the current density by MOS
203 DO j = 1, rtbse_env%n_spin
204 rho_unit_re = cp_print_key_unit_nr(logger, print_key_section, extension=file_labels(2*j - 1))
205 rho_unit_im = cp_print_key_unit_nr(logger, print_key_section, extension=file_labels(2*j))
206 ! Transform the density matrix into molecular orbitals basis and print it out
207 ! S * rho
208 CALL multiply_fm_cfm("N", "N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
209 1.0_dp, rtbse_env%S_fm, rho(j), &
210 0.0_dp, rtbse_env%rho_workspace(1))
211 ! C^T * S * rho
212 CALL multiply_fm_cfm("T", "N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
213 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), rtbse_env%rho_workspace(1), &
214 0.0_dp, rtbse_env%rho_workspace(2))
215 ! C^T * S * rho * S
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(2), rtbse_env%S_fm, &
218 0.0_dp, rtbse_env%rho_workspace(1))
219 ! C^T * S * rho * S * C
220 CALL multiply_cfm_fm("N", "N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
221 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
222 0.0_dp, rtbse_env%rho_workspace(2))
223 ! Print real and imaginary parts separately
224 CALL cp_cfm_to_fm(rtbse_env%rho_workspace(2), &
225 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
226 CALL cp_fm_write_formatted(rtbse_env%real_workspace(1), rho_unit_re)
227 CALL cp_fm_write_formatted(rtbse_env%real_workspace(2), rho_unit_im)
228 CALL cp_print_key_finished_output(rho_unit_re, logger, print_key_section)
229 CALL cp_print_key_finished_output(rho_unit_im, logger, print_key_section)
230 END DO
231 END SUBROUTINE
232! **************************************************************************************************
233!> \brief Outputs the matrix in MO basis for matrix components corresponding to covariant representation,
234!> i.e. the Hamiltonian matrix
235!> \param rtbse_env Entry point - gwbse environment
236!> \param cohsex cohsex matrix in AO basis, covariant representation
237!> \param rtp_section RTP input section
238! **************************************************************************************************
239 SUBROUTINE output_mos_covariant(rtbse_env, ham, print_key_section)
240 TYPE(rtbse_env_type) :: rtbse_env
241 TYPE(cp_cfm_type), DIMENSION(:), POINTER :: ham
242 TYPE(section_vals_type), POINTER :: print_key_section
243 TYPE(cp_logger_type), POINTER :: logger
244 INTEGER :: j, rho_unit_re, rho_unit_im
245 CHARACTER(len=21), DIMENSION(4) :: file_labels
246
247 file_labels(1) = "_SPIN_A_RE.dat"
248 file_labels(2) = "_SPIN_A_IM.dat"
249 file_labels(3) = "_SPIN_B_RE.dat"
250 file_labels(4) = "_SPIN_B_IM.dat"
251 logger => cp_get_default_logger()
252 DO j = 1, rtbse_env%n_spin
253 rho_unit_re = cp_print_key_unit_nr(logger, print_key_section, extension=file_labels(2*j - 1))
254 rho_unit_im = cp_print_key_unit_nr(logger, print_key_section, extension=file_labels(2*j))
255 ! C^T * cohsex
256 CALL multiply_fm_cfm("T", "N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
257 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), ham(j), &
258 0.0_dp, rtbse_env%rho_workspace(1))
259 ! C^T * cohsex * C
260 CALL multiply_cfm_fm("N", "N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
261 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
262 0.0_dp, rtbse_env%rho_workspace(2))
263 ! Print real and imaginary parts separately
264 CALL cp_cfm_to_fm(rtbse_env%rho_workspace(2), &
265 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
266 CALL cp_fm_write_formatted(rtbse_env%real_workspace(1), rho_unit_re)
267 CALL cp_fm_write_formatted(rtbse_env%real_workspace(2), rho_unit_im)
268 CALL cp_print_key_finished_output(rho_unit_re, logger, print_key_section)
269 CALL cp_print_key_finished_output(rho_unit_im, logger, print_key_section)
270 END DO
271 END SUBROUTINE
272! **************************************************************************************************
273!> \brief Prints the current field components into a file provided by input
274!> \param rtbse_env Entry point - gwbse environment
275!> \param rtp_section RTP input section
276! **************************************************************************************************
277 SUBROUTINE output_field(rtbse_env)
278 TYPE(rtbse_env_type) :: rtbse_env
279 TYPE(cp_logger_type), POINTER :: logger
280 INTEGER :: field_unit, n, i
281
282 ! Get logger
283 logger => cp_get_default_logger()
284 ! Get file descriptor
285 field_unit = cp_print_key_unit_nr(logger, rtbse_env%field_section, extension=".dat")
286 ! If the file descriptor is non-zero, output field
287 ! TODO : Output also in SI
288 IF (field_unit /= -1) THEN
289 WRITE (field_unit, '(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') rtbse_env%sim_time*femtoseconds, &
290 rtbse_env%field(1), rtbse_env%field(2), rtbse_env%field(3)
291 END IF
292 ! Write the output to memory for FT
293 ! Need the absolute index
294 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
295 DO i = 1, 3
296 rtbse_env%field_trace(i)%series(n) = rtbse_env%field(i)
297 END DO
298 rtbse_env%time_trace%series(n) = rtbse_env%sim_time
299 CALL cp_print_key_finished_output(field_unit, logger, rtbse_env%field_section)
300
301 END SUBROUTINE
302! **************************************************************************************************
303!> \brief Reads the field from the files provided by input - useful for the continuation run
304!> \param rtbse_env Entry point - gwbse environment
305!> \param rtp_section RTP input section
306! **************************************************************************************************
307 SUBROUTINE read_field(rtbse_env)
308 TYPE(rtbse_env_type) :: rtbse_env
309 TYPE(cp_logger_type), POINTER :: logger
310 CHARACTER(len=default_path_length) :: save_name
311 INTEGER :: k, n, field_unit
312
313 ! Get logger
314 logger => cp_get_default_logger()
315 ! Get file name
316 save_name = cp_print_key_generate_filename(logger, rtbse_env%field_section, extension=".dat", my_local=.false.)
317 IF (file_exists(save_name)) THEN
318 CALL open_file(save_name, file_status="OLD", file_form="FORMATTED", file_action="READ", &
319 unit_number=field_unit)
320 DO k = rtbse_env%sim_start_orig, rtbse_env%sim_start
321 n = k - rtbse_env%sim_start_orig + 1
322 READ (field_unit, '(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') rtbse_env%time_trace%series(n), &
323 rtbse_env%field_trace(1)%series(n), rtbse_env%field_trace(2)%series(n), rtbse_env%field_trace(3)%series(n)
324 ! Set the time units back to atomic units
325 rtbse_env%time_trace%series(n) = rtbse_env%time_trace%series(n)/femtoseconds
326 END DO
327 CALL close_file(field_unit)
328 ELSE IF (.NOT. rtbse_env%dft_control%rtp_control%apply_delta_pulse .AND. &
329 rtbse_env%dft_control%rtp_control%initial_wfn == use_rt_restart) THEN
330 cpwarn("Restart without RT field file - unknown field trace set to zero.")
331 END IF
332 END SUBROUTINE read_field
333
334! **************************************************************************************************
335!> \brief Outputs the expectation value of moments from a given density matrix
336!> \note Moments matrix is provided by the rtbse_env, uses rho_workspace(1:3)
337!> \param rtbse_env Entry point - gwbse environment
338!> \param rho Density matrix in AO basis
339!> \param rtp_section RTP section of the input parameters, where moments destination may be present
340! **************************************************************************************************
341 SUBROUTINE output_moments(rtbse_env, rho)
342 TYPE(rtbse_env_type) :: rtbse_env
343 TYPE(cp_cfm_type), DIMENSION(:), POINTER :: rho
344 TYPE(cp_logger_type), POINTER :: logger
345 INTEGER :: i, j, n, moments_unit_re, moments_unit_im
346 CHARACTER(len=14), DIMENSION(4) :: file_labels
347 REAL(kind=dp), DIMENSION(3) :: moments
348
349 ! Start by getting the relevant file unit
350 file_labels(1) = "_SPIN_A_RE.dat"
351 file_labels(2) = "_SPIN_A_IM.dat"
352 file_labels(3) = "_SPIN_B_RE.dat"
353 file_labels(4) = "_SPIN_B_IM.dat"
354 logger => cp_get_default_logger()
355 DO j = 1, rtbse_env%n_spin
356 moments_unit_re = cp_print_key_unit_nr(logger, rtbse_env%moments_section, extension=file_labels(2*j - 1))
357 moments_unit_im = cp_print_key_unit_nr(logger, rtbse_env%moments_section, extension=file_labels(2*j))
358 ! If, for any reason, the file unit is not provided, skip to next cycle immediately
359 ! TODO : Specify output units in config
360 ! Need to transpose due to the definition of trace function
361 CALL cp_cfm_to_fm(msource=rho(j), mtargetr=rtbse_env%real_workspace(2))
362 DO i = 1, 3
363 ! Moments should be symmetric, test without transopose?
364 CALL cp_fm_transpose(rtbse_env%moments(i), rtbse_env%real_workspace(1))
365 CALL cp_fm_trace(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), moments(i))
366 ! Scale by spin degeneracy and electron charge
367 moments(i) = -moments(i)*rtbse_env%spin_degeneracy
368 END DO
369 ! Output to the file
370 IF (moments_unit_re > 0) THEN
371 ! If outputting to standard output, also prepend identifying 'MOMENTS_TRACE|' string
372 IF (rtbse_env%unit_nr == moments_unit_re) THEN
373 WRITE (moments_unit_re, '(A18,E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
374 " MOMENTS_TRACE_RE|", rtbse_env%sim_time*femtoseconds, moments(1), moments(2), moments(3)
375 ELSE
376 WRITE (moments_unit_re, '(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
377 rtbse_env%sim_time*femtoseconds, moments(1), moments(2), moments(3)
378 CALL cp_print_key_finished_output(moments_unit_re, logger, rtbse_env%moments_section)
379 END IF
380 END IF
381 ! Save to memory for FT - real part
382 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
383 DO i = 1, 3
384 rtbse_env%moments_trace(i)%series(n) = cmplx(moments(i), 0.0, kind=dp)
385 END DO
386 ! Same for imaginary part
387 CALL cp_cfm_to_fm(msource=rho(j), mtargeti=rtbse_env%real_workspace(2))
388 DO i = 1, 3
389 CALL cp_fm_transpose(rtbse_env%moments(i), rtbse_env%real_workspace(1))
390 CALL cp_fm_trace(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), moments(i))
391 ! Scale by spin degeneracy and electron charge
392 moments(i) = -moments(i)*rtbse_env%spin_degeneracy
393 END DO
394 ! Output to the file
395 IF (moments_unit_im > 0) THEN
396 ! If outputting to standard output, also prepend identifying 'MOMENTS_TRACE|' string
397 IF (rtbse_env%unit_nr == moments_unit_im) THEN
398 WRITE (moments_unit_im, '(A18,E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
399 " MOMENTS_TRACE_IM|", rtbse_env%sim_time*femtoseconds, moments(1), moments(2), moments(3)
400 ELSE
401 WRITE (moments_unit_im, '(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
402 rtbse_env%sim_time*femtoseconds, moments(1), moments(2), moments(3)
403 ! Close the files
404 CALL cp_print_key_finished_output(moments_unit_im, logger, rtbse_env%moments_section)
405 END IF
406 END IF
407 ! Save to memory for FT - imag part
408 DO i = 1, 3
409 rtbse_env%moments_trace(i)%series(n) = rtbse_env%moments_trace(i)%series(n) + cmplx(0.0, moments(i), kind=dp)
410 END DO
411 END DO
412 END SUBROUTINE
413! **************************************************************************************************
414!> \brief Outputs the restart info (last finished iteration step) + restard density matrix
415!> \param restart_section Print key section for the restart files
416!> \param rho Density matrix in AO basis
417!> \param time_index Time index to be written into the info file
418! **************************************************************************************************
419 SUBROUTINE output_restart(rtbse_env, rho, time_index)
420 TYPE(rtbse_env_type), POINTER :: rtbse_env
421 TYPE(cp_cfm_type), DIMENSION(:), POINTER :: rho
422 INTEGER :: time_index
423 TYPE(cp_fm_type), DIMENSION(:), POINTER :: workspace
424 CHARACTER(len=17), DIMENSION(4) :: file_labels
425 TYPE(cp_logger_type), POINTER :: logger
426 INTEGER :: rho_unit_nr, i
427
428 ! Default labels distinguishing up to two spin species and real/imaginary parts
429 file_labels(1) = "_SPIN_A_RE.matrix"
430 file_labels(2) = "_SPIN_A_IM.matrix"
431 file_labels(3) = "_SPIN_B_RE.matrix"
432 file_labels(4) = "_SPIN_B_IM.matrix"
433
434 logger => cp_get_default_logger()
435
436 workspace => rtbse_env%real_workspace
437
438 DO i = 1, rtbse_env%n_spin
439 CALL cp_cfm_to_fm(rho(i), workspace(1), workspace(2))
440 ! Real part
441 rho_unit_nr = cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i - 1), &
442 file_form="UNFORMATTED", file_position="REWIND")
443 CALL cp_fm_write_unformatted(workspace(1), rho_unit_nr)
444 CALL cp_print_key_finished_output(rho_unit_nr, logger, rtbse_env%restart_section)
445 ! Imag part
446 rho_unit_nr = cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i), &
447 file_form="UNFORMATTED", file_position="REWIND")
448 CALL cp_fm_write_unformatted(workspace(2), rho_unit_nr)
449 CALL cp_print_key_finished_output(rho_unit_nr, logger, rtbse_env%restart_section)
450 ! Info
451 rho_unit_nr = cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=".info", &
452 file_form="UNFORMATTED", file_position="REWIND")
453 IF (rho_unit_nr > 0) WRITE (rho_unit_nr) time_index
454 CALL cp_print_key_finished_output(rho_unit_nr, logger, rtbse_env%restart_section)
455 END DO
456 END SUBROUTINE output_restart
457! **************************************************************************************************
458!> \brief Reads the density matrix from restart files and updates the starting time
459!> \param restart_section Print key section for the restart files
460!> \param rho Density matrix in AO basis
461!> \param time_index Time index to be written into the info file
462! **************************************************************************************************
463 SUBROUTINE read_restart(rtbse_env)
464 TYPE(rtbse_env_type), POINTER :: rtbse_env
465 TYPE(cp_logger_type), POINTER :: logger
466 CHARACTER(len=default_path_length) :: save_name, save_name_2
467 INTEGER :: rho_unit_nr, j
468 CHARACTER(len=17), DIMENSION(4) :: file_labels
469
470 ! This allows the delta kick and output of moment at time 0 in all cases
471 ! except the case when both imaginary and real parts of the density are read
472 rtbse_env%restart_extracted = .false.
473 logger => cp_get_default_logger()
474 ! Start by probing/loading info file
475 save_name = cp_print_key_generate_filename(logger, rtbse_env%restart_section, extension=".info", my_local=.false.)
476 IF (file_exists(save_name)) THEN
477 CALL open_file(save_name, file_status="OLD", file_form="UNFORMATTED", file_action="READ", &
478 unit_number=rho_unit_nr)
479 READ (rho_unit_nr) rtbse_env%sim_start
480 CALL close_file(rho_unit_nr)
481 IF (rtbse_env%unit_nr > 0) WRITE (rtbse_env%unit_nr, '(A31,I25,A24)') " RTBSE| Starting from timestep ", &
482 rtbse_env%sim_start, ", delta kick NOT applied"
483 ELSE
484 cpwarn("Restart required but no info file found - starting from sim_step given in input")
485 END IF
486
487 ! Default labels distinguishing up to two spin species and real/imaginary parts
488 file_labels(1) = "_SPIN_A_RE.matrix"
489 file_labels(2) = "_SPIN_A_IM.matrix"
490 file_labels(3) = "_SPIN_B_RE.matrix"
491 file_labels(4) = "_SPIN_B_IM.matrix"
492 DO j = 1, rtbse_env%n_spin
493 save_name = cp_print_key_generate_filename(logger, rtbse_env%restart_section, &
494 extension=file_labels(2*j - 1), my_local=.false.)
495 save_name_2 = cp_print_key_generate_filename(logger, rtbse_env%restart_section, &
496 extension=file_labels(2*j), my_local=.false.)
497 IF (file_exists(save_name) .AND. file_exists(save_name_2)) THEN
498 CALL open_file(save_name, file_status="OLD", file_form="UNFORMATTED", file_action="READ", &
499 unit_number=rho_unit_nr)
500 CALL cp_fm_read_unformatted(rtbse_env%real_workspace(1), rho_unit_nr)
501 CALL close_file(rho_unit_nr)
502 CALL open_file(save_name_2, file_status="OLD", file_form="UNFORMATTED", file_action="READ", &
503 unit_number=rho_unit_nr)
504 CALL cp_fm_read_unformatted(rtbse_env%real_workspace(2), rho_unit_nr)
505 CALL close_file(rho_unit_nr)
506 CALL cp_fm_to_cfm(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), &
507 rtbse_env%rho(j))
508 rtbse_env%restart_extracted = .true.
509 ELSE
510 cpwarn("Restart without some restart matrices - starting from SCF density.")
511 END IF
512 END DO
513 END SUBROUTINE read_restart
514! **************************************************************************************************
515!> \brief Reads the moments and time traces from the save files
516!> \param rtbse_env GW-BSE environment (assumes consistent setup, i.e. a continuation run).
517!> Otherwise, the traces are set at zero
518! **************************************************************************************************
519 SUBROUTINE read_moments(rtbse_env)
520 TYPE(rtbse_env_type), POINTER :: rtbse_env
521 TYPE(cp_logger_type), POINTER :: logger
522 CHARACTER(len=default_path_length) :: save_name, save_name_2
523 INTEGER :: i, j, k, moments_unit_re, moments_unit_im, n
524 CHARACTER(len=17), DIMENSION(4) :: file_labels
525 REAL(kind=dp), DIMENSION(3) :: moments_re, moments_im
526 REAL(kind=dp) :: timestamp
527
528 logger => cp_get_default_logger()
529
530 ! Read moments from the previous run
531 ! Default labels distinguishing up to two spin species and real/imaginary parts
532 file_labels(1) = "_SPIN_A_RE.dat"
533 file_labels(2) = "_SPIN_A_IM.dat"
534 file_labels(3) = "_SPIN_B_RE.dat"
535 file_labels(4) = "_SPIN_B_IM.dat"
536 DO j = 1, rtbse_env%n_spin
537 save_name = cp_print_key_generate_filename(logger, rtbse_env%moments_section, &
538 extension=file_labels(2*j - 1), my_local=.false.)
539 save_name_2 = cp_print_key_generate_filename(logger, rtbse_env%moments_section, &
540 extension=file_labels(2*j), my_local=.false.)
541 IF (file_exists(save_name) .AND. file_exists(save_name_2)) THEN
542 CALL open_file(save_name, file_status="OLD", file_form="FORMATTED", file_action="READ", &
543 unit_number=moments_unit_re)
544 CALL open_file(save_name_2, file_status="OLD", file_form="FORMATTED", file_action="READ", &
545 unit_number=moments_unit_im)
546 ! Extra time step for the initial one
547 DO k = rtbse_env%sim_start_orig, rtbse_env%sim_start
548 ! Determine the absolute time step - offset in memory
549 n = k - rtbse_env%sim_start_orig + 1
550 READ (moments_unit_re, '(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') timestamp, &
551 moments_re(1), moments_re(2), moments_re(3)
552 READ (moments_unit_im, '(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') timestamp, &
553 moments_im(1), moments_im(2), moments_im(3)
554 DO i = 1, 3
555 rtbse_env%moments_trace(i)%series(n) = cmplx(moments_re(i), moments_im(i), kind=dp)
556 END DO
557 rtbse_env%time_trace%series(n) = timestamp
558 END DO
559 ! Change back to atomic units in the trace
560 rtbse_env%time_trace%series(:) = rtbse_env%time_trace%series(:)/femtoseconds
561 CALL close_file(moments_unit_re)
562 CALL close_file(moments_unit_im)
563 ELSE IF (rtbse_env%dft_control%rtp_control%initial_wfn == use_rt_restart) THEN
564 cpwarn("Restart without previous moments - unknown moments trace set to zero.")
565 END IF
566 END DO
567 END SUBROUTINE read_moments
568! **************************************************************************************************
569!> \brief Outputs the Fourier transform of moments stored in the environment memory to the configured file
570!> \param rtbse_env GW-BSE environment
571! **************************************************************************************************
572 SUBROUTINE output_moments_ft(rtbse_env)
573 TYPE(rtbse_env_type), POINTER :: rtbse_env
574 TYPE(cp_logger_type), POINTER :: logger
575 REAL(kind=dp), DIMENSION(:), POINTER :: omega_series, &
576 ft_real_series, &
577 ft_imag_series, &
578 value_series
579 ! Stores the data in ready for output format
580 ! - first dimension is 6 - 1 - real part along x, 2 - imag part along x, 3 - real part along y, ...
581 REAL(kind=dp), DIMENSION(:, :), ALLOCATABLE :: ft_full_series
582 INTEGER :: i, n, ft_unit
583
584 logger => cp_get_default_logger()
585
586 n = rtbse_env%sim_nsteps + 2
587 NULLIFY (omega_series)
588 ALLOCATE (omega_series(n), source=0.0_dp)
589 NULLIFY (ft_real_series)
590 ALLOCATE (ft_real_series(n), source=0.0_dp)
591 NULLIFY (ft_imag_series)
592 ALLOCATE (ft_imag_series(n), source=0.0_dp)
593 NULLIFY (value_series)
594 ALLOCATE (value_series(n), source=0.0_dp)
595 ALLOCATE (ft_full_series(6, n))
596 ! Carry out for each direction independently and real and imaginary parts also independently
597 DO i = 1, 3
598 ! Real part of the value first
599 value_series(:) = real(rtbse_env%moments_trace(i)%series(:))
600 CALL ft_simple(rtbse_env%time_trace%series, value_series, ft_real_series, ft_imag_series, &
601 damping_opt=rtbse_env%ft_damping, t0_opt=rtbse_env%ft_start, subtract_initial_opt=.true.)
602 ft_full_series(2*i - 1, :) = ft_real_series(:)
603 ft_full_series(2*i, :) = ft_imag_series(:)
604 ! Now imaginary part
605 value_series(:) = aimag(rtbse_env%moments_trace(i)%series(:))
606 CALL ft_simple(rtbse_env%time_trace%series, value_series, ft_real_series, ft_imag_series, omega_series, &
607 damping_opt=rtbse_env%ft_damping, t0_opt=rtbse_env%ft_start, subtract_initial_opt=.true.)
608 ft_full_series(2*i - 1, :) = ft_full_series(2*i - 1, :) - ft_imag_series
609 ft_full_series(2*i, :) = ft_full_series(2*i, :) + ft_real_series
610 END DO
611 DEALLOCATE (value_series)
612 ! Now, write these to file
613 ft_unit = cp_print_key_unit_nr(logger, rtbse_env%ft_section, extension=".dat", &
614 file_form="FORMATTED", file_position="REWIND")
615 IF (ft_unit > 0) THEN
616 DO i = 1, n
617 WRITE (ft_unit, '(E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
618 omega_series(i), ft_full_series(1, i), ft_full_series(2, i), &
619 ft_full_series(3, i), ft_full_series(4, i), &
620 ft_full_series(5, i), ft_full_series(6, i)
621 END DO
622 END IF
623 CALL cp_print_key_finished_output(ft_unit, logger, rtbse_env%ft_section)
624 DEALLOCATE (ft_real_series)
625 DEALLOCATE (ft_imag_series)
626 IF (rtbse_env%pade_requested) THEN
627 CALL greenx_refine_pade(rtbse_env%pade_e_min, rtbse_env%pade_e_max, rtbse_env%pade_x_eval, &
628 n, rtbse_env%pade_npoints, logger, rtbse_env%ft_section, &
629 rtbse_env%unit_nr, omega_series, ft_full_series)
630 END IF
631 DEALLOCATE (omega_series)
632 DEALLOCATE (ft_full_series)
633 ! Perform control with gx_ac
634 END SUBROUTINE output_moments_ft
635! **************************************************************************************************
636!> \brief Outputs the isotropic polarizability tensor element alpha _ ij = mu_i(omega)/E_j(omega),
637!> where i and j are provided by the configuration. The tensor element is energy dependent and
638!> has real and imaginary parts
639!> \param rtbse_env GW-BSE environment
640! **************************************************************************************************
641 SUBROUTINE output_polarizability(rtbse_env)
642 TYPE(rtbse_env_type), POINTER :: rtbse_env
643 TYPE(cp_logger_type), POINTER :: logger
644 REAL(kind=dp), DIMENSION(:), ALLOCATABLE :: omega_series, &
645 ft_real_series, &
646 ft_imag_series, &
647 value_series
648 COMPLEX(kind=dp), DIMENSION(:), ALLOCATABLE :: moment_series, &
649 field_series, &
650 moment_refined, &
651 field_refined, &
652 omega_complex
653 COMPLEX(kind=dp), DIMENSION(:, :), ALLOCATABLE :: polarizability_series, &
654 polarizability_refined
655 INTEGER :: pol_unit, &
656 i, k, n, n_elems
657
658 logger => cp_get_default_logger()
659
660 n = rtbse_env%sim_nsteps + 2
661 n_elems = SIZE(rtbse_env%pol_elements, 1)
662 ! All allocations together, although could save some memory, if required by consequent deallocations
663 ALLOCATE (omega_series(n), source=0.0_dp)
664 ALLOCATE (ft_real_series(n), source=0.0_dp)
665 ALLOCATE (ft_imag_series(n), source=0.0_dp)
666 ALLOCATE (value_series(n), source=0.0_dp)
667 ALLOCATE (moment_series(n), source=cmplx(0.0, 0.0, kind=dp))
668 ALLOCATE (field_series(n), source=cmplx(0.0, 0.0, kind=dp))
669 ALLOCATE (polarizability_series(n_elems, n), source=cmplx(0.0, 0.0, kind=dp))
670
671 ! Allocations for Padé refinement
672 IF (rtbse_env%pade_requested) THEN
673 ALLOCATE (omega_complex(n), source=cmplx(0.0, 0.0, kind=dp))
674 ALLOCATE (field_refined(rtbse_env%pade_npoints), source=cmplx(0.0, 0.0, kind=dp))
675 ALLOCATE (moment_refined(rtbse_env%pade_npoints), source=cmplx(0.0, 0.0, kind=dp))
676 ALLOCATE (polarizability_refined(n_elems, rtbse_env%pade_npoints), source=cmplx(0.0, 0.0, kind=dp))
677 ELSE
678 ALLOCATE (omega_complex(0), source=cmplx(0.0, 0.0, kind=dp))
679 ALLOCATE (field_refined(0), source=cmplx(0.0, 0.0, kind=dp))
680 ALLOCATE (moment_refined(0), source=cmplx(0.0, 0.0, kind=dp))
681 ALLOCATE (polarizability_refined(0, 0), source=cmplx(0.0, 0.0, kind=dp))
682 END IF
683
684 DO k = 1, n_elems
685 ! The moment ft
686 ! Real part
687 value_series(:) = real(rtbse_env%moments_trace(rtbse_env%pol_elements(k, 1))%series(:))
688 CALL ft_simple(rtbse_env%time_trace%series, value_series, ft_real_series, ft_imag_series, &
689 damping_opt=rtbse_env%ft_damping, t0_opt=rtbse_env%ft_start, subtract_initial_opt=.true.)
690 moment_series(:) = cmplx(ft_real_series(:), ft_imag_series(:), kind=dp)
691 ! Imaginary part
692 value_series(:) = aimag(rtbse_env%moments_trace(rtbse_env%pol_elements(k, 1))%series(:))
693 CALL ft_simple(rtbse_env%time_trace%series, value_series, ft_real_series, ft_imag_series, omega_series, &
694 damping_opt=rtbse_env%ft_damping, t0_opt=rtbse_env%ft_start, subtract_initial_opt=.true.)
695 moment_series(:) = moment_series(:) + cmplx(-ft_imag_series(:), ft_real_series(:), kind=dp)
696
697 ! Calculate the field transform - store it in ft_real_series
698 IF (rtbse_env%dft_control%rtp_control%apply_delta_pulse) THEN
699 ! Only divide by constant magnitude in atomic units
700 ! TODO : Fix for field with more than one direction
701 field_series(:) = cmplx( &
702 rtbse_env%dft_control%rtp_control%delta_pulse_direction(rtbse_env%pol_elements(k, 2))* &
703 rtbse_env%dft_control%rtp_control%delta_pulse_scale, 0.0, kind=dp)
704 ELSE
705 ! Calculate the transform of the field as well and divide by it
706 ! The field FT is not damped - assume field is localised in time
707 ! The field is strictly real
708 CALL ft_simple(rtbse_env%time_trace%series, rtbse_env%field_trace(rtbse_env%pol_elements(k, 2))%series, &
709 ft_real_series, ft_imag_series, omega_series, &
710 0.0_dp, rtbse_env%ft_start, .false.)
711 ! Regularization for the case when ft_series becomes identically zero - TODO : Set in config
712 field_series(:) = cmplx(ft_real_series(:), ft_imag_series(:) + 1.0e-20, kind=dp)
713 END IF
714 ! Divide to get the polarizability series
715 ! Real part
716 polarizability_series(k, :) = moment_series(:)/field_series(:)
717
718 ! Refinement of the grid via Padé approximants, if requested
719 IF (rtbse_env%pade_requested) THEN
720 omega_complex(:) = cmplx(omega_series(:), 0.0, kind=dp)
721 ! No need to refine the field if it is known exactly
722 ! Also GreenX has trouble fitting constant functions
723 IF (rtbse_env%dft_control%rtp_control%apply_delta_pulse) THEN
724 field_refined(:) = cmplx( &
725 rtbse_env%dft_control%rtp_control%delta_pulse_direction(rtbse_env%pol_elements(k, 2))* &
726 rtbse_env%dft_control%rtp_control%delta_pulse_scale, 0.0, kind=dp)
727 ELSE
728 CALL greenx_refine_ft(rtbse_env%pade_fit_e_min, rtbse_env%pade_fit_e_max, omega_complex, field_series, &
729 rtbse_env%pade_x_eval, field_refined)
730 END IF
731 CALL greenx_refine_ft(rtbse_env%pade_fit_e_min, rtbse_env%pade_fit_e_max, omega_complex, moment_series, &
732 rtbse_env%pade_x_eval, moment_refined)
733 polarizability_refined(k, :) = moment_refined(:)/field_refined(:)
734 END IF
735 END DO
736
737 ! Change units to eV for energy
738 ! use value_series for energy and moment_series for polarizability
739 value_series(:) = omega_series(:)*evolt
740 ! Print out the polarizability to a file
741 pol_unit = cp_print_key_unit_nr(logger, rtbse_env%pol_section, extension=".dat", &
742 file_form="FORMATTED", file_position="REWIND")
743 ! Printing for both the stdout and separate file
744 IF (pol_unit > 0) THEN
745 IF (pol_unit == rtbse_env%unit_nr) THEN
746 ! Print the stdout preline
747 WRITE (pol_unit, '(A16)', advance="no") " POLARIZABILITY|"
748 ELSE
749 ! Print also the energy in atomic units
750 WRITE (pol_unit, '(A1,A19)', advance="no") "#", "omega [a.u.]"
751 END IF
752 ! Common - print the energy in eV
753 WRITE (pol_unit, '(A20)', advance="no") "Energy [eV]"
754 ! Print a header for each polarizability element
755 DO k = 1, n_elems - 1
756 WRITE (pol_unit, '(A16,I2,I2,A16,I2,I2)', advance="no") &
757 "Real pol.", rtbse_env%pol_elements(k, 1), rtbse_env%pol_elements(k, 2), &
758 "Imag pol.", rtbse_env%pol_elements(k, 1), rtbse_env%pol_elements(k, 2)
759 END DO
760 WRITE (pol_unit, '(A16,I2,I2,A16,I2,I2)') &
761 "Real pol.", rtbse_env%pol_elements(n_elems, 1), rtbse_env%pol_elements(n_elems, 2), &
762 "Imag pol.", rtbse_env%pol_elements(n_elems, 1), rtbse_env%pol_elements(n_elems, 2)
763 DO i = 1, n
764 IF (pol_unit == rtbse_env%unit_nr) THEN
765 ! Print the stdout preline
766 WRITE (pol_unit, '(A16)', advance="no") " POLARIZABILITY|"
767 ELSE
768 ! omega in a.u.
769 WRITE (pol_unit, '(E20.8E3)', advance="no") omega_series(i)
770 END IF
771 ! Common values
772 WRITE (pol_unit, '(E20.8E3)', advance="no") value_series(i)
773 DO k = 1, n_elems - 1
774 WRITE (pol_unit, '(E20.8E3,E20.8E3)', advance="no") &
775 REAL(polarizability_series(k, i)), aimag(polarizability_series(k, i))
776 END DO
777 ! Print the final value and advance
778 WRITE (pol_unit, '(E20.8E3,E20.8E3)') &
779 REAL(polarizability_series(n_elems, i)), aimag(polarizability_series(n_elems, i))
780 END DO
781 CALL cp_print_key_finished_output(pol_unit, logger, rtbse_env%pol_section)
782 END IF
783
784 IF (rtbse_env%pade_requested) THEN
785 CALL greenx_output_polarizability(logger, rtbse_env%pol_section, rtbse_env%unit_nr, &
786 rtbse_env%pol_elements, rtbse_env%pade_x_eval, polarizability_refined)
787 END IF
788
789 DEALLOCATE (value_series)
790 DEALLOCATE (ft_real_series)
791 DEALLOCATE (ft_imag_series)
792
793 DEALLOCATE (field_series)
794 DEALLOCATE (moment_series)
795
796 DEALLOCATE (omega_series)
797 DEALLOCATE (polarizability_series)
798
799 DEALLOCATE (omega_complex)
800 DEALLOCATE (field_refined)
801 DEALLOCATE (moment_refined)
802 DEALLOCATE (polarizability_refined)
803 END SUBROUTINE output_polarizability
804! **************************************************************************************************
805!> \brief Naively calculates the Fourier transform - it is not the bottleneck of this calculation
806!> \param time_series Timestamps in atomic units of time
807!> \param value_series Values to be Fourier transformed - moments, field etc. So far only real.
808!> \param omega_series Array to be filled by sampled values of frequency
809!> \param result_series FT of the value series - real values (cosines)
810!> \param iresult_series FT of the value series - imaginary values (sines)
811!> \param damping_opt Supply custom exponential damping - default is 4.0/totalTime, i.e. ratio
812!> of last and first element in windowed value series is reduced by e^(-4)
813!> \param t0_opt Carry the FT only starting from certain time - allows for exclusion of trace before
814!> the pulse application etc.
815!> \author Stepan Marek
816!> \date 09.2024
817! **************************************************************************************************
818 ! So far only for defined one dimensional series
819 SUBROUTINE ft_simple(time_series, value_series, result_series, iresult_series, omega_series, &
820 damping_opt, t0_opt, subtract_initial_opt)
821 REAL(kind=dp), DIMENSION(:) :: time_series
822 REAL(kind=dp), DIMENSION(:) :: value_series
823 REAL(kind=dp), DIMENSION(:) :: result_series
824 REAL(kind=dp), DIMENSION(:) :: iresult_series
825 REAL(kind=dp), DIMENSION(:), OPTIONAL :: omega_series
826 REAL(kind=dp), OPTIONAL :: damping_opt
827 REAL(kind=dp), OPTIONAL :: t0_opt
828 LOGICAL, OPTIONAL :: subtract_initial_opt
829 CHARACTER(len=*), PARAMETER :: routinen = "ft_simple"
830 INTEGER :: n, i, j, t0_i, j_wrap, handle
831 REAL(kind=dp) :: t0, delta_t, delta_omega, damping, &
832 value_subtract
833 LOGICAL :: subtract_initial
834
835 CALL timeset(routinen, handle)
836
837 n = SIZE(time_series)
838
839 t0_i = 1
840 IF (PRESENT(t0_opt)) THEN
841 ! Determine the index at which we start applying the damping
842 ! Also the index around which we fold around
843 DO i = 1, n
844 ! Increase until we break or reach the end of the time series
845 t0_i = i
846 IF (time_series(i) >= t0_opt) THEN
847 EXIT
848 END IF
849 END DO
850 END IF
851
852 t0 = time_series(t0_i)
853
854 ! Default damping so that at the end of the time series, divide value by e^-4
855 damping = 4.0_dp/(time_series(n) - time_series(t0_i))
856 IF (PRESENT(damping_opt)) THEN
857 ! Damping is given a time in which the moments reduce by factor of 1/e
858 IF (damping_opt > 0.0_dp) damping = 1.0_dp/damping_opt
859 ! Special case - zero damping
860 IF (damping_opt == 0.0_dp) damping = 0.0_dp
861 END IF
862
863 IF (PRESENT(subtract_initial_opt)) THEN
864 subtract_initial = subtract_initial_opt
865 ELSE
866 subtract_initial = .true.
867 END IF
868
869 ! Construct the grid
870 ! Assume series equidistant
871 delta_t = time_series(2) - time_series(1)
872 delta_omega = twopi/(time_series(n) - time_series(1))
873 ! Subtract initial value, if requested (default is to subtract the value)
874 value_subtract = 0.0_dp
875 IF (subtract_initial) value_subtract = value_series(1)
876 DO i = 1, n
877 result_series(i) = 0.0_dp
878 iresult_series(i) = 0.0_dp
879 IF (PRESENT(omega_series)) omega_series(i) = delta_omega*(i - 1)
880 DO j = 1, n
881 j_wrap = modulo(j + t0_i - 2, n) + 1
882 result_series(i) = result_series(i) + cos(twopi*(i - 1)*(j - 1)/n)* &
883 exp(-damping*delta_t*(j - 1))*(value_series(j_wrap) - value_subtract)
884 iresult_series(i) = iresult_series(i) + sin(twopi*(i - 1)*(j - 1)/n)* &
885 exp(-damping*delta_t*(j - 1))*(value_series(j_wrap) - value_subtract)
886 END DO
887 END DO
888 result_series(:) = delta_t*result_series(:)
889 iresult_series(:) = delta_t*iresult_series(:)
890
891 CALL timestop(handle)
892
893 END SUBROUTINE
894END MODULE rt_bse_io
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
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.
Definition cp_files.F:16
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.
Definition cp_files.F:308
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.
Definition cp_files.F:119
logical function, public file_exists(file_name)
Checks if file exists, considering also the file discovery mechanism.
Definition cp_files.F:501
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_transpose(matrix, matrixt)
transposes a matrix matrixt = matrix ^ T
real(kind=dp) function, public cp_fm_norm(matrix, mode)
norm of matrix using (p)dlange
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_write_unformatted(fm, unit)
...
subroutine, public cp_fm_read_unformatted(fm, unit)
...
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
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,...
Interface to the Greenx library.
subroutine, public greenx_refine_ft(fit_e_min, fit_e_max, x_fit, y_fit, x_eval, y_eval, n_pade_opt)
Refines the FT grid using Padé approximants.
subroutine, public greenx_refine_pade(e_min, e_max, x_eval, number_of_simulation_steps, number_of_pade_points, logger, ft_section, bse_unit, omega_series, ft_full_series)
Refines Pade approximants using GreenX, skips this step if GreenX is not available.
subroutine, public greenx_output_polarizability(logger, pol_section, bse_unit, pol_elements, x_eval, polarizability_refined)
Outputs the isotropic polarizability tensor element alpha _ ij = mu_i(omega)/E_j(omega),...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_bch
integer, parameter, public use_rt_restart
integer, parameter, public do_exact
integer, parameter, public rtp_bse_ham_g0w0
integer, parameter, public rtp_bse_ham_ks
objects that represent the structure of input sections and the data contained in an input section
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_path_length
Definition kinds.F:58
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
basic linear algebra operations for full matrixes
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public femtoseconds
Definition physcon.F:153
real(kind=dp), parameter, public evolt
Definition physcon.F:183
Input/output from the propagation via RT-BSE method.
Definition rt_bse_io.F:13
subroutine, public print_rtbse_header_info(rtbse_env)
Writes the header and basic info to the standard output.
Definition rt_bse_io.F:88
subroutine, public output_mos_covariant(rtbse_env, ham, print_key_section)
Outputs the matrix in MO basis for matrix components corresponding to covariant representation,...
Definition rt_bse_io.F:240
subroutine, public output_restart(rtbse_env, rho, time_index)
Outputs the restart info (last finished iteration step) + restard density matrix.
Definition rt_bse_io.F:420
subroutine, public print_etrs_info(rtbse_env, step, metric)
Writes the update after single etrs iteration - only for log level > medium.
Definition rt_bse_io.F:132
subroutine, public read_field(rtbse_env)
Reads the field from the files provided by input - useful for the continuation run.
Definition rt_bse_io.F:308
subroutine, public output_field(rtbse_env)
Prints the current field components into a file provided by input.
Definition rt_bse_io.F:278
subroutine, public print_etrs_info_header(rtbse_env)
Writes the header for the etrs iteration updates - only for log level > medium.
Definition rt_bse_io.F:149
subroutine, public output_mos_contravariant(rtbse_env, rho, print_key_section)
Outputs the matrix in MO basis for matrix coefficients corresponding to contravariant operator,...
Definition rt_bse_io.F:190
subroutine, public read_moments(rtbse_env)
Reads the moments and time traces from the save files.
Definition rt_bse_io.F:520
subroutine, public output_moments_ft(rtbse_env)
Outputs the Fourier transform of moments stored in the environment memory to the configured file.
Definition rt_bse_io.F:573
subroutine, public read_restart(rtbse_env)
Reads the density matrix from restart files and updates the starting time.
Definition rt_bse_io.F:464
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 > medium.
Definition rt_bse_io.F:164
subroutine, public output_polarizability(rtbse_env)
Outputs the isotropic polarizability tensor element alpha _ ij = mu_i(omega)/E_j(omega),...
Definition rt_bse_io.F:642
subroutine, public output_moments(rtbse_env, rho)
Outputs the expectation value of moments from a given density matrix.
Definition rt_bse_io.F:342
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.
Just to build arrays of pointers to matrices.
Represent a complex full matrix.
just to build arrays of pointers to matrices
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...