# Static polarizability :::{admonition} Video :class: tip [Watch the narrated video of this tutorial on YouTube](https://www.youtube.com/watch?v=juiSQURA4t0). ::: :::{admonition} In this tutorial :class: tip You compute the static dipole polarizability $\alpha$ of water, and its first and second hyperpolarizabilities, by finite fields. You read the field scans in the output, plot the induced dipole, check the result against PySCF and experiment, and see how much the basis set and the functional matter. **Time:** 14 s for the main run, about 45 s for the exercises (16 cores). **Files:** {download}`h2o_polar.yaml `, {download}`h2o_polar.out ` (reference output), {download}`h2o_polar_tzvp.yaml `, {download}`h2o_polar_pbe0.yaml `, {download}`run.sh `. ::: ## The method In a weak static electric field $F$, the dipole moment along the field changes as $$ \mu(F) = \mu_0 + \alpha F + \tfrac12 \beta F^2 + \tfrac16 \gamma F^3 + \dots $$ DFTSW27 converges the SCF in fields $0, \pm h, \pm 2h$ along each axis. It then takes $\alpha$, $\beta$ and $\gamma$ from finite differences of the dipole: fourth order for $\alpha$ and $\beta$, second order for $\gamma$. This is the field-free ground state plus four extra SCFs per axis, so any functional the SCF supports can be used, with no response code needed. ## The input file ```yaml system: charge: 0 unpaired_electrons: 0 units: angstrom functional: exchange: pbe correlation: pbe basis: name: aug-pc-2 file: basis/aug-pc-2.nw scf: conv_tol: 1.0e-10 coulomb: method: eri rt_tddft: field: static amplitude: 0.002 axis: xyz output: h2o_polar atoms: - element: O position: [0.000000, -0.000000, 0.123227] - element: H position: [0.000000, 0.766216, -0.472163] - element: H position: [0.000000, -0.766216, -0.472163] ``` The geometry is the PBE/def2-TZVP minimum from {doc}`../03_freq/index`. `rt_tddft: field: static` : The finite-field scan lives in the `rt_tddft` section because it shares the field and dipole machinery of real-time TDDFT (tutorial 6), but nothing is propagated in time. `amplitude` is the field step $h$ in atomic units (1 a.u. = $5.14\times10^{11}$ V/m). `axis: xyz` scans the three Cartesian axes and prints the diagonal of the tensor and the isotropic average $\bar\alpha=(\alpha_{xx}+\alpha_{yy}+\alpha_{zz})/3$. `axis: z` (or `x`, `y`, or a direction `x y z`) gives one component. `basis: aug-pc-2` : **Polarizabilities need diffuse functions.** The field pulls the density outwards, and a basis without diffuse functions cannot follow it (exercise 1). `scf: conv_tol: 1.0e-10` : The scan differentiates the dipole, so every SCF must be tightly converged. `coulomb: method: eri` : Exact integrals. The default numerical Poisson Coulomb gives $\bar\alpha$ within 0.005 % here, and either is fine. ## Running ```bash $ OMP_NUM_THREADS=8 ./run_dft tutorials/04_polar/files/h2o_polar.yaml > h2o_polar.out ``` ## Reading the output After the field-free SCF and its `Results` block, the `Real-time TDDFT` header announces the static field. Its `dt` and `steps` line does not apply to a static scan. Then each axis is scanned: ```text finite-field scan: step 2.00E-03 a.u., direction 1.000 0.000 0.000 field = 0 h dipole along the field = 0.0000000000 energy = -76.3853003583 field = 1 h dipole along the field = 0.0213284759 energy = -76.3853216836 field = -1 h dipole along the field = -0.0213284759 energy = -76.3853216836 field = 2 h dipole along the field = 0.0426946476 energy = -76.3853856973 field = -2 h dipole along the field = -0.0426946476 energy = -76.3853856973 alpha (a.u., along the field) = 10.661097 beta (a.u., T convention) = 0.000001 gamma (a.u., T convention) = 4711.971067 ``` The energy goes down in the field as $-\tfrac12\alpha F^2$ for $x$; check: $-\tfrac12\cdot10.66\cdot0.002^2 = -2.1\times10^{-5}$ Ha. The three scans end with a summary: ```text finite-field summary (a.u.) x y z alpha_ii 10.661097 10.833050 10.617677 beta_iii 0.000000 0.000001 19.450869 gamma_iiii 4711.971067 1333.121098 2210.453920 isotropic alpha = (xx+yy+zz)/3 = 10.703941 a.u. = 1.586160 Angstrom^3 ``` Water lies in the $yz$ plane with the $C_2$ axis along $z$. $\beta_{iii}$ is zero by symmetry along $x$ and $y$, and nonzero only along the $C_2$ axis. Polarizabilities are usually quoted in atomic units ($e^2a_0^2/E_h$) or as polarizability volumes in Å$^3$ (1 a.u. = 0.1482 Å$^3$). ```{figure} figures/ffield.png :width: 95% Left: the induced dipole is linear in the field; the slopes are the $\alpha_{ii}$. Right: what remains after subtracting $\alpha F$. Along $z$ a parabola ($\beta$, water is polar along its $C_2$ axis); along $x$ and $y$ a small odd curve ($\gamma$ only). `dftsw27plot.py ffield h2o_polar.out` ``` ## How good are the numbers? | | $\alpha_{xx}$ | $\alpha_{yy}$ | $\alpha_{zz}$ | $\bar\alpha$ (a.u.) | |---|---|---|---|---| | DFTSW27, PBE/aug-pc-2 | 10.6611 | 10.8331 | 10.6177 | 10.704 | | PySCF, same basis, same finite-field formula | 10.6612 | 10.8331 | 10.6177 | 10.704 | | experiment | | | | about 9.8 | - **Agreement with PySCF is $10^{-4}$ or better**, so the field coupling and the dipole are right. - **PBE overestimates $\bar\alpha$ by about 9 %.** Semilocal functionals put the virtual orbitals too low, which makes the molecule too easy to polarize. This is a symptom of the self-interaction error (exercise 2 and the SIC tutorials). ## Things to try ### 1. A basis without diffuse functions Run `files/h2o_polar_tzvp.yaml` (def2-TZVP, as in tutorials 1–3). ### 2. A hybrid functional Run `files/h2o_polar_pbe0.yaml`. PBE0 comes from libxc. Hybrids in `rt_tddft` need density fitting for both $J$ and the exact exchange: ```yaml functional: backend: libxc exchange: HYB_GGA_XC_PBEH correlation: none coulomb: method: density_fitting aux_basis_file: basis/def2-universal-JKFIT.nw ``` :::{dropdown} What you should find (exercises 1 and 2) ```{figure} figures/polar_methods.png :width: 85% $\alpha_{ii}$ and $\bar\alpha$ for the three runs, with the experimental isotropic value. ``` - **def2-TZVP gives $\bar\alpha = 6.97$ a.u., 35 % below aug-pc-2.** The out-of-plane component $\alpha_{xx}$ suffers most (5.56 against 10.66). A basis that is good for energies and geometries is not good for response properties. - **PBE0 gives $\bar\alpha = 9.87$ a.u., within 1 % of experiment.** Its 25 % of exact exchange reduces the self-interaction error that makes PBE too polarizable. ::: ### 3. The field step Change `amplitude` to 0.0005 and to 0.008. :::{dropdown} What you should find | $h$ (a.u.) | $\bar\alpha$ | $\beta_{zzz}$ | $\gamma_{xxxx}$ | |---|---|---|---| | 0.0005 | 10.70395 | 19.451 | 4695 | | 0.002 | 10.70394 | 19.451 | 4712 | | 0.008 | 10.70267 | 19.447 | 5007 | $\alpha$ is insensitive to the step: it changes in the fifth digit. $\gamma$ is a third derivative and changes by 6 % between $h=0.002$ and $0.008$, from the higher-order terms the formula neglects. With small steps, $\gamma$ is limited instead by the SCF convergence (keep `conv_tol` at $10^{-10}$). $h\approx 0.001$–$0.002$ is a good compromise. ::: ## Troubleshooting - **$\alpha$ much too small.** The basis has no diffuse functions. - **Noisy $\beta$ or $\gamma$.** Tighten `conv_tol`, and compare two field steps. - **Not available.** Hartree–Fock, SIC and noncollinear runs: the static scan needs a collinear DFT ground state (the run stops with a message). - **Frequency-dependent $\alpha(\omega)$.** It comes from real-time TDDFT with a kick (tutorial 6). Its zero-frequency limit is this static value. **Next:** {doc}`../05_tddft/index`.