54 USE gx_ac,
ONLY: create_thiele_pade, &
55 evaluate_thiele_pade_at, &
60#include "../base/base_uses.f90"
66 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
"rt_bse_io"
95 WRITE (rtbse_env%unit_nr, *)
''
96 WRITE (rtbse_env%unit_nr,
'(A)')
' /-----------------------------------------------'// &
97 '------------------------------\'
98 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
100 WRITE (rtbse_env%unit_nr,
'(A)')
' | Real Time Bethe-Salpeter Propagation'// &
102 WRITE (rtbse_env%unit_nr,
'(A)')
' | '// &
104 WRITE (rtbse_env%unit_nr,
'(A)')
' \-----------------------------------------------'// &
105 '------------------------------/'
106 WRITE (rtbse_env%unit_nr, *)
''
109 WRITE (rtbse_env%unit_nr,
'(A19)', advance=
"no")
' Exponential method'
110 SELECT CASE (rtbse_env%mat_exp_method)
112 WRITE (rtbse_env%unit_nr,
'(A61)')
'BCH'
114 WRITE (rtbse_env%unit_nr,
'(A61)')
'EXACT'
117 WRITE (rtbse_env%unit_nr,
'(A22)', advance=
"no")
' Reference Hamiltonian'
118 SELECT CASE (rtbse_env%ham_reference_type)
120 WRITE (rtbse_env%unit_nr,
'(A58)')
'G0W0'
122 WRITE (rtbse_env%unit_nr,
'(A58)')
'Kohn-Sham'
125 WRITE (rtbse_env%unit_nr,
'(A18,L62)')
' Apply delta pulse', &
126 rtbse_env%dft_control%rtp_control%apply_delta_pulse
128 WRITE (rtbse_env%unit_nr,
'(A)')
''
139 REAL(kind=
dp) :: metric
144 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
145 WRITE (rtbse_env%unit_nr,
'(A7,I5, E20.8E3)')
' RTBSE|', step, metric
159 IF (logger%iter_info%print_level >
medium_print_level .AND. rtbse_env%unit_nr > 0)
THEN
160 WRITE (rtbse_env%unit_nr,
'(A13, A20)')
' RTBSE| Iter.',
'Convergence'
171 REAL(kind=
dp) :: convergence
172 REAL(kind=
dp) :: electron_num_re
178 IF (logger%iter_info%print_level >
low_print_level .AND. rtbse_env%unit_nr > 0)
THEN
179 WRITE (rtbse_env%unit_nr,
'(A23,A20,A20,A17)')
" RTBSE| Simulation step",
"Convergence", &
180 "Electron number",
"ETRS Iterations"
181 WRITE (rtbse_env%unit_nr,
'(A7,I16,E20.8E3,E20.8E3,I17)')
' RTBSE|', step, convergence, &
182 electron_num_re, etrs_num
199 INTEGER :: j, rho_unit_re, rho_unit_im
200 CHARACTER(len=14),
DIMENSION(4) :: file_labels
202 file_labels(1) =
"_SPIN_A_RE.dat"
203 file_labels(2) =
"_SPIN_A_IM.dat"
204 file_labels(3) =
"_SPIN_B_RE.dat"
205 file_labels(4) =
"_SPIN_B_IM.dat"
208 DO j = 1, rtbse_env%n_spin
213 CALL multiply_fm_cfm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
214 1.0_dp, rtbse_env%S_fm, rho(j), &
215 0.0_dp, rtbse_env%rho_workspace(1))
217 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
218 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), rtbse_env%rho_workspace(1), &
219 0.0_dp, rtbse_env%rho_workspace(2))
221 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
222 1.0_dp, rtbse_env%rho_workspace(2), rtbse_env%S_fm, &
223 0.0_dp, rtbse_env%rho_workspace(1))
225 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
226 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
227 0.0_dp, rtbse_env%rho_workspace(2))
230 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
249 INTEGER :: j, rho_unit_re, rho_unit_im
250 CHARACTER(len=21),
DIMENSION(4) :: file_labels
252 file_labels(1) =
"_SPIN_A_RE.dat"
253 file_labels(2) =
"_SPIN_A_IM.dat"
254 file_labels(3) =
"_SPIN_B_RE.dat"
255 file_labels(4) =
"_SPIN_B_IM.dat"
257 DO j = 1, rtbse_env%n_spin
261 CALL multiply_fm_cfm(
"T",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
262 1.0_dp, rtbse_env%bs_env%fm_mo_coeff_Gamma(j), ham(j), &
263 0.0_dp, rtbse_env%rho_workspace(1))
265 CALL multiply_cfm_fm(
"N",
"N", rtbse_env%n_ao, rtbse_env%n_ao, rtbse_env%n_ao, &
266 1.0_dp, rtbse_env%rho_workspace(1), rtbse_env%bs_env%fm_mo_coeff_Gamma(j), &
267 0.0_dp, rtbse_env%rho_workspace(2))
270 rtbse_env%real_workspace(1), rtbse_env%real_workspace(2))
285 INTEGER :: field_unit, n, i
293 IF (field_unit /= -1)
THEN
294 WRITE (field_unit,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') rtbse_env%sim_time*
femtoseconds, &
295 rtbse_env%field(1), rtbse_env%field(2), rtbse_env%field(3)
299 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
301 rtbse_env%field_trace(i)%series(n) = rtbse_env%field(i)
303 rtbse_env%time_trace%series(n) = rtbse_env%sim_time
315 CHARACTER(len=default_path_length) :: save_name
316 INTEGER :: k, n, field_unit
323 CALL open_file(save_name, file_status=
"OLD", file_form=
"FORMATTED", file_action=
"READ", &
324 unit_number=field_unit)
325 DO k = rtbse_env%sim_start_orig, rtbse_env%sim_start
326 n = k - rtbse_env%sim_start_orig + 1
327 READ (field_unit,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') rtbse_env%time_trace%series(n), &
328 rtbse_env%field_trace(1)%series(n), rtbse_env%field_trace(2)%series(n), rtbse_env%field_trace(3)%series(n)
330 rtbse_env%time_trace%series(n) = rtbse_env%time_trace%series(n)/
femtoseconds
333 ELSE IF (.NOT. rtbse_env%dft_control%rtp_control%apply_delta_pulse .AND. &
334 rtbse_env%dft_control%rtp_control%initial_wfn ==
use_rt_restart)
THEN
335 cpwarn(
"Restart without RT field file - unknown field trace set to zero.")
350 INTEGER :: i, j, n, moments_unit_re, moments_unit_im
351 CHARACTER(len=14),
DIMENSION(4) :: file_labels
352 REAL(kind=
dp),
DIMENSION(3) :: moments
355 file_labels(1) =
"_SPIN_A_RE.dat"
356 file_labels(2) =
"_SPIN_A_IM.dat"
357 file_labels(3) =
"_SPIN_B_RE.dat"
358 file_labels(4) =
"_SPIN_B_IM.dat"
360 DO j = 1, rtbse_env%n_spin
361 moments_unit_re =
cp_print_key_unit_nr(logger, rtbse_env%moments_section, extension=file_labels(2*j - 1))
362 moments_unit_im =
cp_print_key_unit_nr(logger, rtbse_env%moments_section, extension=file_labels(2*j))
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(i))
372 moments(i) = -moments(i)*rtbse_env%spin_degeneracy
375 IF (moments_unit_re > 0)
THEN
377 IF (rtbse_env%unit_nr == moments_unit_re)
THEN
378 WRITE (moments_unit_re,
'(A18,E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
379 " MOMENTS_TRACE_RE|", rtbse_env%sim_time*
femtoseconds, moments(1), moments(2), moments(3)
381 WRITE (moments_unit_re,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
382 rtbse_env%sim_time*
femtoseconds, moments(1), moments(2), moments(3)
387 n = rtbse_env%sim_step - rtbse_env%sim_start_orig + 1
389 rtbse_env%moments_trace(i)%series(n) = cmplx(moments(i), 0.0, kind=
dp)
392 CALL cp_cfm_to_fm(msource=rho(j), mtargeti=rtbse_env%real_workspace(2))
394 CALL cp_fm_transpose(rtbse_env%moments(i), rtbse_env%real_workspace(1))
395 CALL cp_fm_trace(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), moments(i))
397 moments(i) = -moments(i)*rtbse_env%spin_degeneracy
400 IF (moments_unit_im > 0)
THEN
402 IF (rtbse_env%unit_nr == moments_unit_im)
THEN
403 WRITE (moments_unit_im,
'(A18,E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
404 " MOMENTS_TRACE_IM|", rtbse_env%sim_time*
femtoseconds, moments(1), moments(2), moments(3)
406 WRITE (moments_unit_im,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
407 rtbse_env%sim_time*
femtoseconds, moments(1), moments(2), moments(3)
414 rtbse_env%moments_trace(i)%series(n) = rtbse_env%moments_trace(i)%series(n) + cmplx(0.0, moments(i), kind=
dp)
427 INTEGER :: time_index
428 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: workspace
429 CHARACTER(len=17),
DIMENSION(4) :: file_labels
431 INTEGER :: rho_unit_nr, i
434 file_labels(1) =
"_SPIN_A_RE.matrix"
435 file_labels(2) =
"_SPIN_A_IM.matrix"
436 file_labels(3) =
"_SPIN_B_RE.matrix"
437 file_labels(4) =
"_SPIN_B_IM.matrix"
441 workspace => rtbse_env%real_workspace
443 DO i = 1, rtbse_env%n_spin
446 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i - 1), &
447 file_form=
"UNFORMATTED", file_position=
"REWIND")
451 rho_unit_nr =
cp_print_key_unit_nr(logger, rtbse_env%restart_section, extension=file_labels(2*i), &
452 file_form=
"UNFORMATTED", file_position=
"REWIND")
457 file_form=
"UNFORMATTED", file_position=
"REWIND")
458 IF (rho_unit_nr > 0)
WRITE (rho_unit_nr) time_index
471 CHARACTER(len=default_path_length) :: save_name, save_name_2
472 INTEGER :: rho_unit_nr, j
473 CHARACTER(len=17),
DIMENSION(4) :: file_labels
477 rtbse_env%restart_extracted = .false.
482 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
483 unit_number=rho_unit_nr)
484 READ (rho_unit_nr) rtbse_env%sim_start
486 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A31,I25,A24)')
" RTBSE| Starting from timestep ", &
487 rtbse_env%sim_start,
", delta kick NOT applied"
489 cpwarn(
"Restart required but no info file found - starting from sim_step given in input")
493 file_labels(1) =
"_SPIN_A_RE.matrix"
494 file_labels(2) =
"_SPIN_A_IM.matrix"
495 file_labels(3) =
"_SPIN_B_RE.matrix"
496 file_labels(4) =
"_SPIN_B_IM.matrix"
497 DO j = 1, rtbse_env%n_spin
499 extension=file_labels(2*j - 1), my_local=.false.)
501 extension=file_labels(2*j), my_local=.false.)
503 CALL open_file(save_name, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
504 unit_number=rho_unit_nr)
507 CALL open_file(save_name_2, file_status=
"OLD", file_form=
"UNFORMATTED", file_action=
"READ", &
508 unit_number=rho_unit_nr)
511 CALL cp_fm_to_cfm(rtbse_env%real_workspace(1), rtbse_env%real_workspace(2), &
513 rtbse_env%restart_extracted = .true.
515 cpwarn(
"Restart without some restart matrices - starting from SCF density.")
527 CHARACTER(len=default_path_length) :: save_name, save_name_2
528 INTEGER :: i, j, k, moments_unit_re, moments_unit_im, n
529 CHARACTER(len=17),
DIMENSION(4) :: file_labels
530 REAL(kind=
dp),
DIMENSION(3) :: moments_re, moments_im
531 REAL(kind=
dp) :: timestamp
537 file_labels(1) =
"_SPIN_A_RE.dat"
538 file_labels(2) =
"_SPIN_A_IM.dat"
539 file_labels(3) =
"_SPIN_B_RE.dat"
540 file_labels(4) =
"_SPIN_B_IM.dat"
541 DO j = 1, rtbse_env%n_spin
543 extension=file_labels(2*j - 1), my_local=.false.)
545 extension=file_labels(2*j), my_local=.false.)
547 CALL open_file(save_name, file_status=
"OLD", file_form=
"FORMATTED", file_action=
"READ", &
548 unit_number=moments_unit_re)
549 CALL open_file(save_name_2, file_status=
"OLD", file_form=
"FORMATTED", file_action=
"READ", &
550 unit_number=moments_unit_im)
552 DO k = rtbse_env%sim_start_orig, rtbse_env%sim_start
554 n = k - rtbse_env%sim_start_orig + 1
555 READ (moments_unit_re,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') timestamp, &
556 moments_re(1), moments_re(2), moments_re(3)
557 READ (moments_unit_im,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3)') timestamp, &
558 moments_im(1), moments_im(2), moments_im(3)
560 rtbse_env%moments_trace(i)%series(n) = cmplx(moments_re(i), moments_im(i), kind=
dp)
562 rtbse_env%time_trace%series(n) = timestamp
565 rtbse_env%time_trace%series(:) = rtbse_env%time_trace%series(:)/
femtoseconds
568 ELSE IF (rtbse_env%dft_control%rtp_control%initial_wfn ==
use_rt_restart)
THEN
569 cpwarn(
"Restart without previous moments - unknown moments trace set to zero.")
580 REAL(kind=
dp),
DIMENSION(:),
POINTER :: omega_series, &
586 REAL(kind=
dp),
DIMENSION(:, :),
ALLOCATABLE :: ft_full_series
587 INTEGER :: i, n, ft_unit
588#if defined (__GREENX)
589 COMPLEX(kind=dp),
DIMENSION(:),
ALLOCATABLE :: omega_complex, &
591 COMPLEX(kind=dp),
DIMENSION(:, :),
ALLOCATABLE :: moments_eval_complex
596 n = rtbse_env%sim_nsteps + 2
597 NULLIFY (omega_series)
598 ALLOCATE (omega_series(n), source=0.0_dp)
599 NULLIFY (ft_real_series)
600 ALLOCATE (ft_real_series(n), source=0.0_dp)
601 NULLIFY (ft_imag_series)
602 ALLOCATE (ft_imag_series(n), source=0.0_dp)
603 NULLIFY (value_series)
604 ALLOCATE (value_series(n), source=0.0_dp)
605 ALLOCATE (ft_full_series(6, n))
609 value_series(:) = real(rtbse_env%moments_trace(i)%series(:))
610 CALL ft_simple(rtbse_env%time_trace%series, value_series, ft_real_series, ft_imag_series, &
611 damping_opt=rtbse_env%ft_damping, t0_opt=rtbse_env%ft_start, subtract_initial_opt=.true.)
612 ft_full_series(2*i - 1, :) = ft_real_series(:)
613 ft_full_series(2*i, :) = ft_imag_series(:)
615 value_series(:) = aimag(rtbse_env%moments_trace(i)%series(:))
616 CALL ft_simple(rtbse_env%time_trace%series, value_series, ft_real_series, ft_imag_series, omega_series, &
617 damping_opt=rtbse_env%ft_damping, t0_opt=rtbse_env%ft_start, subtract_initial_opt=.true.)
618 ft_full_series(2*i - 1, :) = ft_full_series(2*i - 1, :) - ft_imag_series
619 ft_full_series(2*i, :) = ft_full_series(2*i, :) + ft_real_series
621 DEALLOCATE (value_series)
624 file_form=
"FORMATTED", file_position=
"REWIND")
625 IF (ft_unit > 0)
THEN
627 WRITE (ft_unit,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
628 omega_series(i), ft_full_series(1, i), ft_full_series(2, i), &
629 ft_full_series(3, i), ft_full_series(4, i), &
630 ft_full_series(5, i), ft_full_series(6, i)
634 DEALLOCATE (ft_real_series)
635 DEALLOCATE (ft_imag_series)
636#if defined (__GREENX)
637 IF (rtbse_env%pade_requested)
THEN
639 IF (rtbse_env%unit_nr > 0)
WRITE (rtbse_env%unit_nr,
'(A10,A27,E23.8E3,E20.8E3)') &
640 " PADE_FT| ",
"Evaluation grid bounds [eV]", rtbse_env%pade_e_min, rtbse_env%pade_e_max
641 ALLOCATE (omega_complex(n))
642 ALLOCATE (moments_ft_complex(n))
643 ALLOCATE (moments_eval_complex(3, rtbse_env%pade_npoints))
644 omega_complex(:) = cmplx(omega_series(:), 0.0, kind=
dp)
646 moments_ft_complex(:) = cmplx(ft_full_series(2*i - 1, :), &
647 ft_full_series(2*i, :), &
651 CALL refine_ft(rtbse_env%pade_fit_e_min, rtbse_env%pade_fit_e_max, &
652 omega_complex, moments_ft_complex, rtbse_env%pade_x_eval, moments_eval_complex(i, :))
656 file_form=
"FORMATTED", file_position=
"REWIND")
657 IF (ft_unit > 0)
THEN
658 DO i = 1, rtbse_env%pade_npoints
659 WRITE (ft_unit,
'(E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3,E20.8E3)') &
660 REAL(rtbse_env%pade_x_eval(i)),
REAL(moments_eval_complex(1, i)), aimag(moments_eval_complex(1, i)), &
661 REAL(moments_eval_complex(2, i)), aimag(moments_eval_complex(2, i)), &
662 REAL(moments_eval_complex(3, i)), aimag(moments_eval_complex(3, i))
666 DEALLOCATE (omega_complex)
667 DEALLOCATE (moments_ft_complex)
668 DEALLOCATE (moments_eval_complex)
671 DEALLOCATE (omega_series)
672 DEALLOCATE (ft_full_series)
682 SUBROUTINE refine_ft(fit_e_min, fit_e_max, x_fit, y_fit, x_eval, y_eval, n_pade_opt)
683 REAL(kind=
dp) :: fit_e_min, &
685 COMPLEX(kind=dp),
DIMENSION(:) :: x_fit, &
689 INTEGER,
OPTIONAL :: n_pade_opt
690#if defined (__GREENX)
691 CHARACTER(len=*),
PARAMETER :: routinen =
"refine_ft"
700 TYPE(params) :: pade_params
701 CALL timeset(routinen, handle)
704 max_fit =
SIZE(x_fit)
705 n_eval =
SIZE(x_eval)
713 IF (fit_e_max < 0) fit_end = max_fit
715 IF (fit_start == -1 .AND. real(x_fit(i)) >= fit_e_min) fit_start = i
716 IF (fit_end == -1 .AND. real(x_fit(i)) > fit_e_max) fit_end = i - 1
717 IF (fit_start > 0 .AND. fit_end > 0)
EXIT
719 IF (fit_start == -1) fit_start = 1
720 IF (fit_end == -1) fit_end = max_fit
721 n_fit = fit_end - fit_start + 1
724 IF (
PRESENT(n_pade_opt)) n_pade = n_pade_opt
727 IF (n_pade > 1000)
THEN
728 cpwarn(é
"More then 1000 Pad parameters requested - may reduce with FIT_E_MIN/FIT_E_MAX.")
732 pade_params = create_thiele_pade(n_pade, x_fit(fit_start:fit_end), y_fit(fit_start:fit_end), &
733 enforce_symmetry=
"conjugate")
736 y_eval(1:n_eval) = evaluate_thiele_pade_at(pade_params, x_eval)
738 CALL free_params(pade_params)
740 CALL timestop(handle)
749 mark_used(n_pade_opt)
750 cpabort(
"refine_ft called but CP2K compiled without GreenX - GreenX needed.")
752 END SUBROUTINE refine_ft
762 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: omega_series, &
766 COMPLEX(kind=dp),
DIMENSION(:),
ALLOCATABLE :: moment_series, &
771 COMPLEX(kind=dp),
DIMENSION(:, :),
ALLOCATABLE :: polarizability_series, &
772 polarizability_refined
773 INTEGER :: pol_unit, &
778 n = rtbse_env%sim_nsteps + 2
779 n_elems =
SIZE(rtbse_env%pol_elements, 1)
781 ALLOCATE (omega_series(n), source=0.0_dp)
782 ALLOCATE (ft_real_series(n), source=0.0_dp)
783 ALLOCATE (ft_imag_series(n), source=0.0_dp)
784 ALLOCATE (value_series(n), source=0.0_dp)
785 ALLOCATE (moment_series(n), source=cmplx(0.0, 0.0, kind=
dp))
786 ALLOCATE (field_series(n), source=cmplx(0.0, 0.0, kind=
dp))
787 ALLOCATE (polarizability_series(n_elems, n), source=cmplx(0.0, 0.0, kind=
dp))
790 IF (rtbse_env%pade_requested)
THEN
791 ALLOCATE (omega_complex(n), source=cmplx(0.0, 0.0, kind=
dp))
792 ALLOCATE (field_refined(rtbse_env%pade_npoints), source=cmplx(0.0, 0.0, kind=
dp))
793 ALLOCATE (moment_refined(rtbse_env%pade_npoints), source=cmplx(0.0, 0.0, kind=
dp))
794 ALLOCATE (polarizability_refined(n_elems, rtbse_env%pade_npoints), source=cmplx(0.0, 0.0, kind=
dp))
796 ALLOCATE (omega_complex(0), source=cmplx(0.0, 0.0, kind=
dp))
797 ALLOCATE (field_refined(0), source=cmplx(0.0, 0.0, kind=
dp))
798 ALLOCATE (moment_refined(0), source=cmplx(0.0, 0.0, kind=
dp))
799 ALLOCATE (polarizability_refined(0, 0), source=cmplx(0.0, 0.0, kind=
dp))
805 value_series(:) = real(rtbse_env%moments_trace(rtbse_env%pol_elements(k, 1))%series(:))
806 CALL ft_simple(rtbse_env%time_trace%series, value_series, ft_real_series, ft_imag_series, &
807 damping_opt=rtbse_env%ft_damping, t0_opt=rtbse_env%ft_start, subtract_initial_opt=.true.)
808 moment_series(:) = cmplx(ft_real_series(:), ft_imag_series(:), kind=
dp)
810 value_series(:) = aimag(rtbse_env%moments_trace(rtbse_env%pol_elements(k, 1))%series(:))
811 CALL ft_simple(rtbse_env%time_trace%series, value_series, ft_real_series, ft_imag_series, omega_series, &
812 damping_opt=rtbse_env%ft_damping, t0_opt=rtbse_env%ft_start, subtract_initial_opt=.true.)
813 moment_series(:) = moment_series(:) + cmplx(-ft_imag_series(:), ft_real_series(:), kind=
dp)
816 IF (rtbse_env%dft_control%rtp_control%apply_delta_pulse)
THEN
819 field_series(:) = cmplx( &
820 rtbse_env%dft_control%rtp_control%delta_pulse_direction(rtbse_env%pol_elements(k, 2))* &
821 rtbse_env%dft_control%rtp_control%delta_pulse_scale, 0.0, kind=
dp)
826 CALL ft_simple(rtbse_env%time_trace%series, rtbse_env%field_trace(rtbse_env%pol_elements(k, 2))%series, &
827 ft_real_series, ft_imag_series, omega_series, &
828 0.0_dp, rtbse_env%ft_start, .false.)
830 field_series(:) = cmplx(ft_real_series(:), ft_imag_series(:) + 1.0e-20, kind=
dp)
834 polarizability_series(k, :) = moment_series(:)/field_series(:)
837 IF (rtbse_env%pade_requested)
THEN
838 omega_complex(:) = cmplx(omega_series(:), 0.0, kind=
dp)
841 IF (rtbse_env%dft_control%rtp_control%apply_delta_pulse)
THEN
842 field_refined(:) = cmplx( &
843 rtbse_env%dft_control%rtp_control%delta_pulse_direction(rtbse_env%pol_elements(k, 2))* &
844 rtbse_env%dft_control%rtp_control%delta_pulse_scale, 0.0, kind=
dp)
846 CALL refine_ft(rtbse_env%pade_fit_e_min, rtbse_env%pade_fit_e_max, omega_complex, field_series, &
847 rtbse_env%pade_x_eval, field_refined)
849 CALL refine_ft(rtbse_env%pade_fit_e_min, rtbse_env%pade_fit_e_max, omega_complex, moment_series, &
850 rtbse_env%pade_x_eval, moment_refined)
851 polarizability_refined(k, :) = moment_refined(:)/field_refined(:)
857 value_series(:) = omega_series(:)*
evolt
860 file_form=
"FORMATTED", file_position=
"REWIND")
862 IF (pol_unit > 0)
THEN
863 IF (pol_unit == rtbse_env%unit_nr)
THEN
865 WRITE (pol_unit,
'(A16)', advance=
"no")
" POLARIZABILITY|"
868 WRITE (pol_unit,
'(A1,A19)', advance=
"no")
"#",
"omega [a.u.]"
871 WRITE (pol_unit,
'(A20)', advance=
"no")
"Energy [eV]"
873 DO k = 1, n_elems - 1
874 WRITE (pol_unit,
'(A16,I2,I2,A16,I2,I2)', advance=
"no") &
875 "Real pol.", rtbse_env%pol_elements(k, 1), rtbse_env%pol_elements(k, 2), &
876 "Imag pol.", rtbse_env%pol_elements(k, 1), rtbse_env%pol_elements(k, 2)
878 WRITE (pol_unit,
'(A16,I2,I2,A16,I2,I2)') &
879 "Real pol.", rtbse_env%pol_elements(n_elems, 1), rtbse_env%pol_elements(n_elems, 2), &
880 "Imag pol.", rtbse_env%pol_elements(n_elems, 1), rtbse_env%pol_elements(n_elems, 2)
882 IF (pol_unit == rtbse_env%unit_nr)
THEN
884 WRITE (pol_unit,
'(A16)', advance=
"no")
" POLARIZABILITY|"
887 WRITE (pol_unit,
'(E20.8E3)', advance=
"no") omega_series(i)
890 WRITE (pol_unit,
'(E20.8E3)', advance=
"no") value_series(i)
891 DO k = 1, n_elems - 1
892 WRITE (pol_unit,
'(E20.8E3,E20.8E3)', advance=
"no") &
893 REAL(polarizability_series(k, i)), aimag(polarizability_series(k, i))
896 WRITE (pol_unit,
'(E20.8E3,E20.8E3)') &
897 REAL(polarizability_series(n_elems, i)), aimag(polarizability_series(n_elems, i))
904 file_form=
"FORMATTED", file_position=
"REWIND")
906 IF (pol_unit > 0 .AND. rtbse_env%pade_requested)
THEN
907 IF (pol_unit == rtbse_env%unit_nr)
THEN
909 WRITE (pol_unit,
'(A21)', advance=
"no")
" POLARIZABILITY_PADE|"
912 WRITE (pol_unit,
'(A1,A19)', advance=
"no")
"#",
"omega [a.u.]"
915 WRITE (pol_unit,
'(A20)', advance=
"no")
"Energy [eV]"
917 DO k = 1, n_elems - 1
918 WRITE (pol_unit,
'(A16,I2,I2,A16,I2,I2)', advance=
"no") &
919 "Real pol.", rtbse_env%pol_elements(k, 1), rtbse_env%pol_elements(k, 2), &
920 "Imag pol.", rtbse_env%pol_elements(k, 1), rtbse_env%pol_elements(k, 2)
922 WRITE (pol_unit,
'(A16,I2,I2,A16,I2,I2)') &
923 "Real pol.", rtbse_env%pol_elements(n_elems, 1), rtbse_env%pol_elements(n_elems, 2), &
924 "Imag pol.", rtbse_env%pol_elements(n_elems, 1), rtbse_env%pol_elements(n_elems, 2)
925 DO i = 1,
SIZE(rtbse_env%pade_x_eval)
926 IF (pol_unit == rtbse_env%unit_nr)
THEN
928 WRITE (pol_unit,
'(A21)', advance=
"no")
" POLARIZABILITY_PADE|"
931 WRITE (pol_unit,
'(E20.8E3)', advance=
"no") real(rtbse_env%pade_x_eval(i), kind=
dp)
934 WRITE (pol_unit,
'(E20.8E3)', advance=
"no") real(rtbse_env%pade_x_eval(i), kind=
dp)*
evolt
935 DO k = 1, n_elems - 1
936 WRITE (pol_unit,
'(E20.8E3,E20.8E3)', advance=
"no") &
937 REAL(polarizability_refined(k, i)), aimag(polarizability_refined(k, i))
940 WRITE (pol_unit,
'(E20.8E3,E20.8E3)') &
941 REAL(polarizability_refined(n_elems, i)), aimag(polarizability_refined(n_elems, i))
947 DEALLOCATE (value_series)
948 DEALLOCATE (ft_real_series)
949 DEALLOCATE (ft_imag_series)
951 DEALLOCATE (field_series)
952 DEALLOCATE (moment_series)
954 DEALLOCATE (omega_series)
955 DEALLOCATE (polarizability_series)
957 DEALLOCATE (omega_complex)
958 DEALLOCATE (field_refined)
959 DEALLOCATE (moment_refined)
960 DEALLOCATE (polarizability_refined)
977 SUBROUTINE ft_simple(time_series, value_series, result_series, iresult_series, omega_series, &
978 damping_opt, t0_opt, subtract_initial_opt)
979 REAL(kind=
dp),
DIMENSION(:) :: time_series
980 REAL(kind=
dp),
DIMENSION(:) :: value_series
981 REAL(kind=
dp),
DIMENSION(:) :: result_series
982 REAL(kind=
dp),
DIMENSION(:) :: iresult_series
983 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: omega_series
984 REAL(kind=
dp),
OPTIONAL :: damping_opt
985 REAL(kind=
dp),
OPTIONAL :: t0_opt
986 LOGICAL,
OPTIONAL :: subtract_initial_opt
987 CHARACTER(len=*),
PARAMETER :: routinen =
"ft_simple"
988 INTEGER :: n, i, j, t0_i, j_wrap, handle
989 REAL(kind=
dp) :: t0, delta_t, delta_omega, damping, &
991 LOGICAL :: subtract_initial
993 CALL timeset(routinen, handle)
995 n =
SIZE(time_series)
998 IF (
PRESENT(t0_opt))
THEN
1004 IF (time_series(i) >= t0_opt)
THEN
1010 t0 = time_series(t0_i)
1013 damping = 4.0_dp/(time_series(n) - time_series(t0_i))
1014 IF (
PRESENT(damping_opt))
THEN
1016 IF (damping_opt > 0.0_dp) damping = 1.0_dp/damping_opt
1018 IF (damping_opt == 0.0_dp) damping = 0.0_dp
1021 IF (
PRESENT(subtract_initial_opt))
THEN
1022 subtract_initial = subtract_initial_opt
1024 subtract_initial = .true.
1029 delta_t = time_series(2) - time_series(1)
1030 delta_omega =
twopi/(time_series(n) - time_series(1))
1032 value_subtract = 0.0_dp
1033 IF (subtract_initial) value_subtract = value_series(1)
1035 result_series(i) = 0.0_dp
1036 iresult_series(i) = 0.0_dp
1037 IF (
PRESENT(omega_series)) omega_series(i) = delta_omega*(i - 1)
1039 j_wrap =
modulo(j + t0_i - 2, n) + 1
1040 result_series(i) = result_series(i) + cos(
twopi*(i - 1)*(j - 1)/n)* &
1041 exp(-damping*delta_t*(j - 1))*(value_series(j_wrap) - value_subtract)
1042 iresult_series(i) = iresult_series(i) + sin(
twopi*(i - 1)*(j - 1)/n)* &
1043 exp(-damping*delta_t*(j - 1))*(value_series(j_wrap) - value_subtract)
1046 result_series(:) = delta_t*result_series(:)
1047 iresult_series(:) = delta_t*iresult_series(:)
1049 CALL timestop(handle)
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.
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
real(kind=dp) function, public cp_fm_norm(matrix, mode)
norm of matrix using (p)dlange
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_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,...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
basic linear algebra operations for full matrixes
Definition of physical constants:
real(kind=dp), parameter, public femtoseconds
real(kind=dp), parameter, public evolt
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_moments(rtbse_env)
Reads the moments and time traces from the save files.
subroutine, public output_moments_ft(rtbse_env)
Outputs the Fourier transform of moments stored in the environment memory to the configured file.
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 > medium.
subroutine, public output_polarizability(rtbse_env)
Outputs the isotropic polarizability tensor element alpha _ ij = mu_i(omega)/E_j(omega),...
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.
Just to build arrays of pointers to matrices.
Represent a complex full matrix.
just to build arrays of pointers to matrices
type of a logger, at the moment it contains just a print level starting at which level it should be l...