Optical spectra from real-time TDDFT¶
In this tutorial
Instead of solving for excited states one by one (tutorial 5), you give formaldehyde a short
electric kick, propagate its electrons in time, and Fourier-transform the induced dipole. The
result is the whole absorption spectrum at once. You check it against linear-response TDDFT
for the same functional and basis, see what sets the spectral resolution, and use the
built-in line analysis to assign the peaks.
Time: about 6 minutes for the three propagations (16 cores), 1.5 minutes for the line analysis.
Files: h2co_rt.yaml,
h2co_rt.out (reference output, step lines removed),
h2co_lr.yaml, h2co_rt_lines.yaml,
run.sh.
The method¶
At \(t=0\) a weak, instantaneous field (a “delta kick” of strength \(\kappa\) along direction \(d\)) gives every electron a small momentum. The Kohn–Sham density matrix is then propagated without a field,
and the dipole \(\mu(t)\) is recorded. Its Fourier transform gives the polarizability \(\alpha_{cd}(\omega) = \mathrm{FT}[\mu_c(t)-\mu_c(0)]/\kappa\). Three kicks (\(x\), \(y\), \(z\)) give the isotropic dipole strength function
whose integral over all frequencies is the number of electrons (Thomas–Reiche–Kuhn sum rule). Every bright excitation appears as a peak. The cost of a run does not depend on how many states you want.
The input file¶
system:
charge: 0
unpaired_electrons: 0
units: angstrom
functional:
exchange: pbe
correlation: pbe
basis:
name: aug-pc-1
file: basis/aug-pc-1.nw
scf:
conv_tol: 1.0e-9
coulomb:
method: density_fitting
aux_basis_file: basis/def2-universal-JFIT.nw
rt_tddft:
field: kick
kick: 1.0e-3
axis: xyz
dt: 0.1
steps: 5000
corrector_iterations: 2
wmax_ev: 15
output: h2co
atoms: # formaldehyde, as in tutorial 5
...
rt_tddftfield: kickwith strengthkick(a.u., small enough for linear response).axis: xyzruns three propagations from the same ground state and adds their spectra.dtis the time step (a.u.; 1 a.u. = 0.0242 fs) andstepsthe number of steps, here 500 a.u. = 12 fs per direction.corrector_iterations: 2makes the mid-point Fock matrix self-consistent, which conserves the energy to \(10^{-9}\) Ha.wmax_evis the upper end of the spectrum file. The propagator is the exact exponential (propagator: expm, the default).coulomb: density_fittingRT-TDDFT accepts
eri,density_fitting,poissonandanalytic. Density fitting is the fast choice. Hybrids need it (with a JK-fitting basis).
The ground state must be a converged collinear DFT state with moment_mode: fixed and no level
shift.
Running¶
$ OMP_NUM_THREADS=16 ./run_dft tutorials/06_rttddft/files/h2co_rt.yaml > h2co_rt.out
Reading the output¶
Each direction prints a header, a line every few steps, and a summary:
Real-time TDDFT (propagator: expm, field: kick)
dt = 0.1000 a.u. steps = 5000 total time = 500.00 a.u.
basis functions 68 orthonormal functions 68
step 10 t = 1.000 E = -114.36217008 N = 16.00000000
...
wall time: Fock builds 108.64 s ( 10001 builds; Coulomb 3.55 s, xc 104.97 s)
SIC 0.00 s propagator 7.50 s density 2.61 s basis transform 1.59 s total 124.91 s
max |E(t) - E(0)| = 9.00E-10 Ha (only meaningful with the field switched off)
max |N(t) - N(0)| = 1.49E-11
max |P^2 - P| (final) = 5.69E-12
absorption spectrum written to h2co_x_spectrum.dat
The three diagnostics are your quality check:
energy conservation after the kick;
conservation of the electron number;
idempotency of the propagated density matrix.
Here all three are at round-off level. Almost all the time goes into the exchange-correlation part of the 2 Fock builds per step.
Files written:
File |
Contents |
|---|---|
|
step, time, dipole \((x,y,z)\), \(N\), \(E\), field, work of the field |
|
spectrum of one direction |
|
\(\mathrm{Im}\,\alpha_{ij}(\omega)\), \(S(\omega)\), the photoabsorption cross section (Mb) and the running TRK sum |
The spectrum¶
tools/rt_spectrum.py turns the dipole files into a spectrum, with a choice of windows and
zero padding. It can also overlay the roots of a linear-response run:
$ python3 tools/rt_spectrum.py --prefix h2co --kick 1e-3 --gamma 0.004 --wmax 14 \
--lr h2co_lr.out --lr-broad 0.15 --plot spectrum.png
Fig. 21 Real-time spectrum (exponential window, damping 0.004 a.u.) and the 40 linear-response roots
of files/h2co_lr.yaml, broadened by 0.15 eV. Below 13 eV every peak coincides. Above that
the linear-response run simply has no more roots.¶
The peaks agree with linear response: 5.77 against 5.79 eV, 6.63 against 6.60, 10.22 against 10.21, and so on. Two things that the real-time spectrum does not show:
Dark states. The \(n\to\pi^*\) state at 3.84 eV has \(f=0\), so it gives no peak.
Triplets. A spin-free kick cannot excite them.
The TRK sum up to 14 eV is 1.10 electrons; the rest of the 16 electrons absorb at higher energies.
Things to try¶
1. How long to propagate?¶
The frequency resolution is about \(2\pi/T\). run.sh keeps only the first 1000 steps (100 a.u.)
of the same dipole files and transforms them again; no new run is needed.
What you should find
Fig. 22 The first 100 a.u. of the same signal. Neighboring peaks merge, and only the broad envelope of the spectrum is left.¶
100 a.u. resolves features about 1.7 eV apart; 500 a.u. resolves about 0.34 eV. Halving the
damping --gamma sharpens the lines only if the signal is long enough.
2. Assigning the peaks: the line analysis¶
files/h2co_rt_lines.yaml kicks along \(z\) only, for 300 a.u., with
analysis: true
analysis_lines: 8
The run fits the dipole signal to a sum of lines. For every line it reports the energy, the oscillator strength, the dominant orbital pairs, and a cube of the transition density.
What you should find
line E (eV) f(dir) f/3(LR-like) Tr[T S] dominant MO pairs (spin occ->virt share)
6 11.6070 0.51323 0.17108 -4.6E-11 (1 6-> 12 0.35) (2 6-> 12 0.35) (1 8-> 23 0.12)
3 10.2051 0.49163 0.16388 1.0E-10 (1 8-> 18 0.23) (2 8-> 18 0.23) (1 7-> 9 0.13)
1 6.5951 0.11054 0.03685 -1.9E-10 (1 8-> 11 0.50) (2 8-> 11 0.50) (1 7-> 9 0.00)
Compare f/3 with the oscillator strengths of the linear-response roots at the same energy.
10.205 eV with 0.164 matches the root at 10.207 eV with \(f=0.162\), and 6.595 eV with 0.037
matches 6.597 eV with 0.038. The MO pairs are numbered like the orbitals (8 = HOMO, 9 = LUMO).
Fig. 23 Transition density of the 10.2 eV line in the molecular plane: a charge oscillation along the C=O bond, as expected for a \(z\)-polarized transition.¶
3. A laser pulse instead of a kick¶
files/h2co_rt_pulse.yaml replaces the kick by a Gaussian pulse tuned to the 10.2 eV peak,
and records the occupations of the ground-state orbitals:
rt_tddft:
field: pulse
amplitude: 0.005 # peak field (a.u.)
omega: 0.375 # 10.2 eV
t0: 40.0 # centre of the pulse (a.u.)
sigma: 10.0 # width (a.u.)
populations: true
axis: z
steps: 1500
What you should find
max |E(t) - E(0)| = 5.01E-03 Ha (only meaningful with the field switched off)
max |E(t) - E(0) - W_field(t)| = 1.01E-06 Ha (energy balance with the field on)
The molecule absorbs 5 mHa from the pulse. The energy minus the work done by the field is conserved to \(10^{-6}\) Ha.
Fig. 24 Occupation changes of the ground-state orbitals (h2co_pulse_mopop.dat,
dftsw27plot.py mopop).¶
Electrons leave MOs 6, 7 and 8 and enter MOs 9, 10 and 18: exactly the orbital pairs that the line analysis assigned to the lines at 10.2 and 10.7 eV.
Troubleshooting¶
The energy drifts after the kick. Use
corrector_iterations: 2and checkdt. 0.1 a.u. is safe for valence spectra; very diffuse or very high-lying states need smaller steps.Peaks too broad. Propagate longer. Window damping cannot add information the signal does not contain.
Negative or odd features near 0 eV. These are artifacts of a short signal. Use more steps, or start the plot above 1 eV.
Not available. The real-time propagation refuses
moment_modeother thanfixed, level shifts and noncollinear runs.