# Solvation with a polarizable continuum :::{admonition} Video :class: tip [Watch the narrated video of this tutorial on YouTube](https://www.youtube.com/watch?v=8tPFFWa_EBM). ::: :::{admonition} In this tutorial :class: tip Most chemistry happens in solution. A polarizable continuum model (PCM) replaces the solvent by a dielectric that responds to the solute's charge distribution, at the cost of a few hundred surface charges. You compute the hydration free energy of water with C-PCM, check it against PySCF and experiment, and see how it depends on the solvent and on the charge of the solute. **Time:** about 1 s per run (8–16 cores). **Files:** {download}`h2o_gas.yaml `, {download}`h2o_water.yaml `, {download}`h2o_water.out ` (reference output), exercise inputs `files/h2o_water_iefpcm.yaml`, `files/nh4_{gas,water}.yaml`, {download}`run.sh `. ::: ## The model The solute sits in a cavity built from overlapping atomic spheres, the van der Waals radii scaled by 1.2. Its electrons and nuclei polarize the dielectric outside. The model represents that response by charges $q_i$ on the cavity surface, which act back on the solute through a reaction-field term in the Fock matrix, self-consistently. In the conductor-like model C-PCM the charges are those of a perfect conductor, scaled by $$ f(\varepsilon) = \frac{\varepsilon-1}{\varepsilon}. $$ The SCF energy then includes the electrostatic solvation free energy. Cavitation, dispersion and repulsion terms are not included. ## The input files The solvation free energy is a difference of two runs at the same geometry (the PBE/def2-TZVP minimum of tutorial 3). The solvated one adds a single section: ```yaml 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 print_energies: true solvent: model: cpcm solvent: water 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] ``` `solvent` : `model` is `cpcm` (default), `cosmo` or `iefpcm`. `solvent` takes a name (water, methanol, ethanol, acetonitrile, dmso, acetone, dichloromethane, chloroform, thf, toluene, benzene, hexane, cyclohexane), or set `epsilon:` directly. `vdw_scale` (1.2) and `lebedev` (29, i.e. 302 points per sphere) control the cavity. `print_energies: true` : Prints the solvation term at every SCF iteration. ## Running ```bash $ OMP_NUM_THREADS=8 ./run_dft tutorials/12_solvation/files/h2o_gas.yaml > h2o_gas.out $ OMP_NUM_THREADS=8 ./run_dft tutorials/12_solvation/files/h2o_water.yaml > h2o_water.out ``` ## Reading the output ```text run_dft: solvent: SCF stability analysis disabled (it lacks the reaction-field term) implicit solvent (C-PCM): epsilon = 78.3553, 556 surface points ... e_solvation (C-PCM) = -0.0117614978 ... TOTAL ENERGY = -76.3880296186 |mu| = 0.932745 a.u. = 2.370802 Debye ``` The cavity of water has 556 surface points. `e_solvation` is the interaction of the solute with its reaction field; it is already included in the total energy. The **solvation free energy** is the difference of the two total energies: $$ \Delta G_{\rm solv} = E_{\rm water} - E_{\rm gas} = -76.3880296 - (-76.3776092) = -0.0104204\ {\rm Ha} = -6.54\ {\rm kcal/mol}. $$ It is smaller in magnitude than `e_solvation` ($-7.38$ kcal/mol). The difference, 0.84 kcal/mol, is the cost of polarizing the solute's own electron density: the dipole grows from 2.04 D in the gas phase to 2.37 D in water. :::{admonition} How good is it? :class: note **Against PySCF.** PySCF's C-PCM with the same Cartesian basis, functional and dielectric constant gives $\Delta G_{\rm solv}=-6.5394$ kcal/mol, against $-6.5389$ here. The difference of $8\times10^{-7}$ Ha is grid error. **Against experiment.** The experimental hydration free energy of water is $-6.3$ kcal/mol. The agreement is partly fortunate: the model has only the electrostatic part, and the non-electrostatic terms it leaves out are of the same order. Continuum models are most reliable for differences between similar species. ::: ## Things to try ### 1. The solvent `run.sh` repeats the calculation in ten more solvents. :::{dropdown} What you should find ```{figure} figures/dg_vs_solvent.png :width: 85% $\Delta G_{\rm solv}$ of water against $f(\varepsilon)$. Hexane ($\varepsilon=1.88$) gives $-2.9$ kcal/mol; above $\varepsilon\approx20$ the curve saturates, and water gives $-6.5$. ``` The scaling factor $f(\varepsilon)$ is 0.47 for hexane and 0.99 for water. Beyond about $\varepsilon=20$ every polar solvent gives nearly the same electrostatic stabilization; the differences between polar solvents come from specific interactions (hydrogen bonds) that a continuum does not have. ::: ### 2. The model `files/h2o_water_iefpcm.yaml` uses IEF-PCM (`model: iefpcm`); `model: cosmo` works the same way. :::{dropdown} What you should find | model | $\Delta G_{\rm solv}$ (kcal/mol) | |---|---| | C-PCM | $-6.539$ | | COSMO | $-6.492$ | | IEF-PCM | $-6.497$ | The three differ only in how the dielectric response is approximated, and for a high-$\varepsilon$ solvent they agree to 0.05 kcal/mol. ::: ### 3. An ion `files/nh4_gas.yaml` and `files/nh4_water.yaml` do the same for the ammonium ion. :::{dropdown} What you should find $\Delta G_{\rm solv}({\rm NH_4^+}) = -81.8$ kcal/mol, twelve times that of neutral water. Experimental estimates are around $-80$ kcal/mol. For a charge $q$ in a cavity of radius $a$ the Born model gives $-\frac{q^2}{2a}\left(1-\frac1\varepsilon\right)$. The total charge dominates, which is why reaction energies that change the charge (acid–base reactions, redox) are strongly solvent dependent. ::: ## Beyond energies The same `solvent` section works with: - **`task: gradient`, `optimize` and `frequencies`.** Analytic forces and Hessian. The solvent shifts the bend of water by $-33$ cm$^{-1}$. - **TDDFT.** The non-equilibrium response with the optical dielectric constant, or the equilibrium response. - **Self-interaction correction**, with all SIC solvers. See the User Manual, `solvent` section. ## Troubleshooting - **Not available** with PDSCF/CDFT, DFT+U, noncollinear mode, and magnetic anisotropy or the g-tensor (the run stops with a message). - **SCF stability analysis** is switched off with a solvent. - **Large molecules.** The surface matrix is dense; for long molecules `far_field: true` speeds up the reaction-field kernels. **Next:** {doc}`../14_x2c/index`.