# 11. Optical spectra: real-time TDDFT `rt_tddft:` propagates the Kohn–Sham density matrix in time after the ground-state SCF of the same run ([Runge and Gross 1984](#ref-rg84); real-time approach: [Yabana and Bertsch 1996](#ref-yb96), Gaussian-basis implementation: [Lopata and Govind 2011](#ref-lg11)). A weak delta kick excites all transitions at once; the Fourier transform of the induced dipole $\mu(t)$ is the absorption spectrum. Unlike {doc}`lr_tddft` it gives the whole spectrum, also in the nonlinear regime and with strong fields. ```{literalinclude} ../tutorials/06_rttddft/files/h2co_rt.yaml :language: yaml :start-at: "coulomb:" :end-before: "atoms:" ``` | Key (`rt_tddft:`) | Default | Meaning | |---|---|---| | `propagator` | `expm` | `expm` (exact exponential, unitary), `magnus`, or `cranknic` | | `dt`, `steps` | 0.05, 1000 | time step and number of steps (atomic units) | | `corrector_iterations` | 1 | self-consistent mid-point Fock matrix; 2 to 3 conserve the energy | | `field` | `kick` | `kick`, `gaussian`, `pulse`, `cw`, `pulse2`, `static` (finite-field α, β, γ) or `none` | | `kick`, `amplitude`, `omega`, `t0`, `sigma` | 1e-3, ... | field parameters (a.u.) | | `axis` | `z` | `x`, `y`, `z` or `xyz` (three kicks: full polarizability and isotropic spectrum) | | `spectrum` | `fft` | damped Fourier transform (`gamma`, `wmax_ev`, `dw_ev`) or `pade` ([Bruner, LaMaster, Lopata 2016](#ref-pade16)) | | `analysis` | `false` | line fit with oscillator strengths, transition densities, MO-pair assignment | | `cap` | `false` | complex absorbing potential for ionization | | `populations` | `false` | time-resolved charges and MO occupations | | `output` | `rt` | prefix of `_dipole.dat` and `_spectrum.dat` | ## Requirements and tips - Converged collinear DFT ground state, `moment_mode: fixed`, no level shift; `coulomb: method` is `eri`, `density_fitting`, `poisson` or `analytic`. Global hybrids need `density_fitting`. - The run prints the energy drift, the change of the electron number and the idempotency error at the end; with `corrector_iterations: 2` and a weak kick these should be negligible. - The spectral resolution is set by the total time: 100 a.u. resolves about 1.7 eV, 500 a.u. about 0.34 eV. - Keep the kick weak (10⁻³ a.u.) for linear response; the spectrum is then identical to the Casida one. `tools/rt_spectrum.py` post-processes the dipole files (windows, padding, Padé, overlay with a linear-response spectrum). - Nuclei are fixed here; moving nuclei are treated with `job: task: md` and `md: method: ehrenfest`. ## Example: formaldehyde In {doc}`Tutorial 6 <../tutorials/06_rttddft/index>` the RT-TDDFT peaks at 5.77, 6.63 and 10.22 eV agree with the linear-response roots at 5.79, 6.60 and 10.21 eV (PBE/aug-pc-1); the dark n→π* state at 3.84 eV gives no peak. The tutorial also shows a laser pulse tuned to the 10.2 eV peak with the time-dependent populations. Related tutorials: {doc}`../tutorials/06_rttddft/index`, {doc}`../tutorials/05_tddft/index`.