# Vibrational frequencies and IR spectrum :::{admonition} Video :class: tip [Watch the narrated video of this tutorial on YouTube](https://www.youtube.com/watch?v=quqpHAc3gCw). ::: :::{admonition} In this tutorial :class: tip You optimize water tightly and compute its harmonic frequencies, IR intensities and ideal-gas thermochemistry in one run. Then you read the vibrational analysis, plot the IR spectrum and the normal modes, and compare with PySCF and with experiment. The exercises cover isotopes, the numerical Hessian, and what an imaginary frequency means. **Time:** 7 s for the main run, about 20 s for the exercises (16 cores). **Files:** {download}`h2o_freq.yaml `, {download}`h2o_freq.out ` (reference output), {download}`d2o_freq.yaml `, {download}`h2o_numhess.yaml `, {download}`h2o_linear.yaml `, {download}`run.sh `. ::: ## The input file ```yaml job: task: opt_freq system: charge: 0 unpaired_electrons: 0 units: angstrom functional: exchange: pbe correlation: pbe basis: name: def2-TZVP file: basis/def2-TZVP.nw scf: conv_tol: 1.0e-10 optimization: max_force: 1.0e-5 rms_force: 1.0e-5 frequencies: symmetry_number: 2 temperature: 298.15 molden_file: h2o_freq.molden atoms: - element: O position: [0.000000, 0.000000, 0.117300] - element: H position: [0.000000, 0.757200, -0.469200] - element: H position: [0.000000, -0.757200, -0.469200] ``` `job: task: opt_freq` : Optimize first, then compute frequencies at the optimized geometry. `task: frequencies` skips the optimization; use it only for a geometry that is already a tightly converged minimum (or deliberately for a saddle point, exercise 3). `optimization: max_force / rms_force` : Frequencies need a much tighter minimum than energies do. {doc}`../02_geomopt/index` showed that the default criteria leave the H–O–H angle 0.1° away from the minimum. At a geometry that is not stationary the low frequencies are wrong. `scf: conv_tol: 1.0e-10` : A tighter SCF gives cleaner second derivatives. `frequencies` : `symmetry_number` is the rotational symmetry number $\sigma$: 2 for H$_2$O, 3 for NH$_3$, 12 for CH$_4$ and benzene. It is **not** detected automatically, and it changes only the rotational entropy and $G$. `temperature` and `pressure` (default 101325 Pa) set the thermochemistry. `molden_file` writes the modes for animation. The Hessian is analytic by default (`hessian: auto`). It is computed by coupled-perturbed Kohn–Sham equations for HF, LDA, GGA, the SCAN family and global and range-separated hybrids. For other methods DFTSW27 falls back to central differences of the gradient. ## Running ```bash $ OMP_NUM_THREADS=8 ./run_dft tutorials/03_freq/files/h2o_freq.yaml > h2o_freq.out ``` ## Reading the output The run first prints a geometry optimization, exactly as in tutorial 2. With the tight criteria it needs 7 gradient evaluations and ends at max $|F| = 4.9\times10^{-7}$ Ha/bohr. The frequency part follows. ### The analytic Hessian ```text frequencies: analytic Hessian and dipole derivatives (CPHF, mod_hessian.F90) hessian: skeleton (second-derivative integrals) 1.41 s hessian: first-order Fock matrices 0.63 s hessian: exchange-correlation terms 0.34 s cphf iteration 1: max residual 3.53E-01 (9 perturbations active) ... cphf iteration 10: max residual 2.67E-10 (0 perturbations active) hessian: coupled-perturbed equations 1.62 s hessian: asymmetry before symmetrization 3.02E-12 Ha/bohr^2 ``` The coupled-perturbed (CPHF/CPKS) equations give the orbital response to every nuclear displacement, $3N=9$ here; each perturbation drops out once it is converged. The same response gives the dipole derivatives, and with them the IR intensities. The asymmetry of the Hessian before symmetrization is a built-in consistency check and should be tiny. ### Frequencies, modes and intensities ```text mode frequency reduced mass force const IR intensity (cm^-1) (amu) (mdyn/A) (km/mol) 1 1583.51 1.0835 1.6007 71.2512 2 3689.14 1.0444 8.3749 2.0274 3 3800.20 1.0817 9.2035 34.1479 ``` The six translations and rotations are projected out; a nonlinear molecule has $3N-6$ vibrations. The columns are: - the harmonic frequency; - the reduced mass and force constant (Gaussian/PySCF convention); - the IR intensity in km/mol. Imaginary frequencies would be printed with an `i`. The normal-mode table that follows gives the Cartesian displacement of every atom in every mode. ```{figure} figures/modes.png :width: 90% The three normal modes: bend, symmetric stretch and antisymmetric stretch (`dftsw27plot.py modes h2o_freq.molden`). The bend has the largest dipole change and the strongest IR band. The symmetric stretch hardly changes the dipole and is almost IR-silent. ``` To animate the modes, open `h2o_freq.molden` in Molden, Jmol or Avogadro. ### Thermochemistry ```text Thermochemistry (ideal gas, rigid rotor, harmonic oscillator), T = 298.15 K, P = 101325.00 Pa rotational constants (cm^-1) = 26.56583 14.24553 9.27301 zero-point energy = 0.02066948 Ha ( 12.9703 kcal/mol) thermal correction to E = 0.02350550 Ha thermal correction to H = 0.02444968 Ha thermal correction to G = 0.00299965 Ha E(el) + ZPE = -76.35694069 Ha H = E(el) + thermal H = -76.35316049 Ha G = E(el) + thermal G = -76.37461052 Ha S (trans, rot, vib, elec) = 34.6083 10.5289 0.0082 0.0000 cal/(mol K) S total = 45.1454 cal/(mol K) ``` These are the standard ideal-gas, rigid-rotor, harmonic-oscillator expressions. Use $E+{\rm ZPE}$ for reaction energies at 0 K, and $H$ or $G$ at the chosen temperature. Imaginary modes are left out of the sums. ## The IR spectrum ```bash $ python3 tutorials/tools/dftsw27plot.py ir h2o_freq.molden -o ir.png --fwhm 20 ``` ```{figure} figures/ir.png :width: 85% IR spectra of H$_2$O and D$_2$O (exercise 1): sticks at the harmonic frequencies, broadened with Lorentzians of 20 cm$^{-1}$ full width. The axis runs from high to low wavenumber, as in experimental spectra. ``` ## How good are the numbers? | | bend | sym. stretch | antisym. stretch | ZPE (Ha) | $S$ (cal/mol K) | |---|---|---|---|---|---| | DFTSW27, PBE/def2-TZVP | 1583.5 | 3689.1 | 3800.2 | 0.0206695 | 45.145 | | PySCF, same basis and geometry | 1583.1 | 3690.0 | 3801.1 | 0.0206726 | 45.147 | | experiment, harmonic $\omega_e$ | 1648 | 3832 | 3943 | | | | experiment, fundamental $\nu$ | 1595 | 3657 | 3756 | | 45.1 | - **DFTSW27 and PySCF agree to 1 cm$^{-1}$.** The difference is the integration grid. - **PBE harmonic frequencies are about 4 % below the experimental harmonic ones.** They happen to land close to the measured fundamentals, because this error and the neglected anharmonicity roughly cancel. That cancellation is a known property of GGAs. It is not a rule to rely on. - **The entropy matches the experimental standard entropy of water vapour.** It is dominated by translation and rotation, which need only the mass and the geometry. ## Things to try ### 1. Isotopes: D$_2$O `files/d2o_freq.yaml` keeps the geometry and sets the mass of both hydrogens: ```yaml - element: H mass: 2.01410177812 position: [...] ``` :::{dropdown} What you should find The modes become 1159, 2659 and 2784 cm$^{-1}$ (ratio about $1/\sqrt2$ for modes in which only hydrogen moves), and the ZPE drops from 13.0 to 9.4 kcal/mol. The potential energy surface and the force constants per internal coordinate are unchanged; only the masses differ. ::: ### 2. Numerical Hessian Add `hessian: numerical` to the `frequencies` section (`files/h2o_numhess.yaml`). The Hessian then comes from central differences of analytic gradients, $6N$ gradient calculations, with displacements of `frequencies: step` = 0.005 bohr. :::{dropdown} What you should find The frequencies agree with the analytic ones to 0.05 cm$^{-1}$ (1583.46, 3689.18, 3800.24). The run takes 8.7 s against 4.2 s for the analytic Hessian. For larger molecules the gap grows to about a factor of ten (benzene: 155 s against 1624 s in the User Manual). Use the numerical Hessian for methods without an analytic one, and as a check. ::: ### 3. An imaginary frequency `files/h2o_linear.yaml` asks for frequencies (`task: frequencies`, no optimization) of **linear** water. :::{dropdown} What you should find ```text run_dft: WARNING -- the geometry is not a stationary point; frequencies of a non-stationary geometry are not physical (use task: opt_freq) 1 1408.59i 1.1259 -1.3162 467.3158 2 1408.59i 1.1259 -1.3162 467.3158 3 3589.80 1.0078 7.6520 0.0000 4 3967.09 1.1259 10.4398 637.3622 ``` A linear molecule has $3N-5=4$ modes. The doubly degenerate bend is imaginary, because bending lowers the energy, so this is a saddle point and not a minimum. The warning says that the geometry is not stationary: the O–H bonds are not at their optimum either. A transition state has exactly one imaginary mode; here there are two. ::: ## Troubleshooting - **Small imaginary frequencies (< 50i cm$^{-1}$) at a minimum.** Usually the optimization was not tight enough or the grid is too coarse for the soft modes. Re-optimize with `max_force: 1.0e-5` and use `opt_freq`. - **Wrong entropy or $G$.** Check `symmetry_number`. - **Not available.** Frequencies are not available with SIC, in noncollinear mode or with `moment_mode: mom`. **Next:** {doc}`../04_polar/index`.