Polarizabilities and hyperpolarizabilities, with SIC¶
In this tutorial
You compute the static polarizability \(\alpha\) of water analytically, and the full tensors of the first and second
hyperpolarizabilities \(\beta\) and \(\gamma\) by finite fields, first with LDA and then with Perdew–Zunger
self-interaction correction (PZ-SIC, FLOSIC with fixed FODs). You read the tensor block of the output line by line,
check the numbers against PySCF, see why the exact SIC matrix is needed, and test the field step and the Coulomb method.
Time: 8 s for the analytic \(\alpha\), 6–10 s for each LDA tensor run, about 100 s for the SIC tensors (16 cores);
the exercises add the exact-Coulomb SIC tensors, which take about 20 minutes.
Files: h2o_alpha_analytic.yaml,
h2o_tensor_lda.yaml, h2o_tensor_pz.yaml,
h2o_tensor_pz.out (reference output), h2o.fod,
h2o_tensor_lda_eri.yaml, h2o_tensor_lda_jfit.yaml,
h2o_scan_pz.yaml, h2o_scan_pz_kli.yaml,
ref_pyscf.py, run.sh.
The method¶
In a weak static field \(\mathbf F\) the dipole moment is
(the “T convention”; sums over repeated indices). Because \(\mu_i=-\partial E/\partial F_i\), the tensors are derivatives of the energy and fully symmetric: \(\alpha_{ij}\) has 6 independent elements, \(\beta_{ijk}\) has 10 and \(\gamma_{ijkl}\) has 15.
There are two ways to get them in DFTSW27.
Analytic \(\alpha\). analysis: polarizability: true solves the coupled-perturbed Kohn–Sham equations for the three field
perturbations, with the same solver as the analytic Hessian. It costs about as much as one SCF and has no field step.
Finite fields. rt_tddft: field: static with tensor: true converges the SCF in fields \(\pm h\) and \(\pm2h\) along
13 directions (the 3 axes, the 6 face diagonals and the 4 body diagonals; \(4\times13+1=53\) SCFs). From the dipole vector it forms
the directional derivatives by central differences (fourth order for \(\alpha\) and \(\beta\), second order for \(\gamma\)) and fits the
symmetric tensors by least squares. It needs no response code, so it works for every method that has an SCF, including SIC.
With SIC the dipole in a field depends on how the SIC Hamiltonian is built:
sic_potential: exactuses the exact derivative of the PZ-SIC energy with respect to the density matrix at fixed FODs. The energy is then variational and the dipole equals \(-\partial E/\partial F\).sic_potential: kliuses the approximate KLI potential, which is not the derivative of any energy.
The FODs stay fixed at their zero-field positions in all runs here. Relaxing them in the field would change the response; that is not computed in this tutorial.
The input files¶
The analytic polarizability of Static polarizability in one extra key:
functional:
exchange: pbe
correlation: pbe
basis:
name: aug-pc-2
file: basis/aug-pc-2.nw
coulomb:
method: eri
analysis:
polarizability: true
The tensor runs with the UTEP-NRLMOL basis, LDA, and PZ-SIC with the FODs of FOD optimization:
functional:
exchange: slater
correlation: pw92
basis:
name: UTEP-NRLMOL
file: basis/FLOSIC-LDA_atoms_normalized.nw
scf:
conv_tol: 1.0e-10
sic: # only in the SIC run
functional: pz_sic
solver: kli
coulomb_method: density_fitting
fod_file: tutorials/18_hyperpol/files/h2o.fod
orbital_log_file: ''
coulomb:
method: density_fitting
aux_basis_file: basis/def2-universal-JFIT.nw
rt_tddft:
field: static
amplitude: 0.002
tensor: true
sic_potential: exact # only in the SIC run
sic_relax: true # only in the SIC run
output: h2o_tensor_pz
analysis: polarizability: trueThe analytic static polarizability, printed after the SCF. It uses the same scope as the analytic Hessian: HF, LDA, GGA, meta-GGA and hybrids with exact integrals (
eri, the default for this key), pure functionals with density fitting, and solvent. Other cases print a message and skip it.rt_tddft: field: static,amplitude: 0.002The finite-field scan of Static polarizability;
amplitudeis the field step \(h\) in atomic units.rt_tddft: tensor: trueInstead of one scan along one axis, the 13-direction fit of all tensors.
axisis not used.rt_tddft: sic_potential: exact,sic_relax: trueThe exact PZ-SIC matrix in the Hamiltonian, and a re-converged ground state under that Hamiltonian before the scan (the SCF itself used the KLI potential).
sic: solver: kli,fod_fileThe ground-state SIC calculation of Self-interaction correction with FLOSIC, FLOSIC-LDA with the optimized FODs of water.
coulomb: method: density_fittingandsic: coulomb_method: density_fittingRI-J for the main Coulomb matrix and for the orbital self-Coulomb terms. This is much faster than the alternatives; see exercise 2 for its effect on \(\beta\).
Running¶
OMP_NUM_THREADS=16 ./run_dft tutorials/18_hyperpol/files/h2o_alpha_analytic.yaml > h2o_alpha_analytic.out
OMP_NUM_THREADS=16 ./run_dft tutorials/18_hyperpol/files/h2o_tensor_lda.yaml > h2o_tensor_lda.out
OMP_NUM_THREADS=16 ./run_dft tutorials/18_hyperpol/files/h2o_tensor_pz.yaml > h2o_tensor_pz.out
or tutorials/18_hyperpol/run.sh. The SIC run takes 98 s, most of it the 53 field SCFs with the exact SIC matrix.
Reading the output¶
The analytic polarizability¶
Static dipole polarizability (analytic, coupled-perturbed; a.u.)
----------------------------------------------------------------
10.661107 0.000000 -0.000000
0.000000 10.833051 -0.000000
-0.000000 -0.000000 10.617680
isotropic = 10.703946 a.u. ( 1.586161 Angstrom^3)
anisotropy = 0.197276
- The three rows
\(\alpha_{ij}\) in atomic units: 10.661, 10.833 and 10.618 on the diagonal; the off-diagonal elements vanish by symmetry (water lies in the \(yz\) plane). It is the same PBE/aug-pc-2 water as Static polarizability, whose finite-field scan gave 10.661097, 10.833050 and 10.617677: the two differ by \(10^{-5}\) at most.
isotropic\(\bar\alpha=\mathrm{tr}\,\alpha/3\): 10.704 a.u., or 1.586 Å\(^3\) (1 a.u. = 0.1482 Å\(^3\)).
anisotropy\(\Delta\alpha=\sqrt{\tfrac12[(\alpha_{xx}-\alpha_{yy})^2+(\alpha_{yy}-\alpha_{zz})^2+(\alpha_{zz}-\alpha_{xx})^2]+3(\alpha_{xy}^2+\alpha_{yz}^2+\alpha_{xz}^2)}\).
The tensor block¶
finite-field tensors: step 2.00E-03 a.u., 53 SCFs (13 field directions)
zero-field dipole (a.u.) 0.00000000 0.00000000 -0.78502451 E = -76.6789625831
finite-field tensors: step ... 53 SCFsThe field step and the number of SCFs: \(4\times13+1\).
zero-field dipole ... E =The dipole vector and the energy of the SIC ground state (with the exact matrix): the dipole points along \(-z\), from the oxygen (at \(+z\)) to the hydrogens, \(-0.785\) a.u. The energy is \(-76.6789625831\) Ha.
alpha_ij (a.u.)
6.771069 0.000000 0.000000
0.000000 8.541590 0.000000
0.000000 0.000000 7.653765
isotropic alpha = 7.655475 anisotropy = 1.533318
alpha_ij,isotropic alpha,anisotropyAs above, now for PZ-SIC: \(\bar\alpha\) = 7.655 a.u. For the same basis and geometry, LDA gives 9.383 (table below).
beta_ijk (a.u., T convention), independent elements
1 1 3 -3.033825
2 2 3 11.237768
3 3 3 5.547366
beta_vec,i = sum_j beta_ijj -0.000000 0.000000 13.751309
beta_par = 3/5 beta_vec.mu_hat = -8.250785 beta_tot = 8.250785
beta_ijk ... independent elementsThe nonzero independent elements, as
i j k valuewith 1, 2, 3 = x, y, z. Here three survive the \(C_{2v}\) symmetry: \(\beta_{xxz}=\beta_{zxx}=-3.034\), \(\beta_{yyz}=\beta_{zyy}=11.238\) and \(\beta_{zzz}=5.547\). Elements of \(\beta\) below \(10^{-4}\) are not printed (for \(\gamma\): below 0.01).beta_vec,iThe vector \(\beta_i=\sum_j\beta_{ijj}\), which carries all the information a rotationally averaged experiment can see. Only its \(z\) component is nonzero: \(-3.034+11.238+5.547=13.751\).
beta_par,beta_tot\(\beta_\parallel=\tfrac35\,\boldsymbol\beta\cdot\hat{\boldsymbol\mu}\) and \(\beta_{\rm tot}=\tfrac35|\boldsymbol\beta|\). The sign of \(\beta_\parallel\) depends on the convention; here the dipole points along \(-z\) while \(\beta_z>0\), so \(\beta_\parallel=-8.251\) and \(\beta_{\rm tot}=8.251\).
gamma_ijkl (a.u., T convention), independent elements
1 1 1 1 397.7367
1 1 2 2 79.9810
1 1 3 3 99.8051
2 2 2 2 293.1875
2 2 3 3 179.6773
3 3 3 3 335.4608
gamma_par = 1/5 sum_ij gamma_iijj = 349.0624
rms of the tensor fits (alpha, beta, gamma) = 9.98E-08 4.49E-05 2.57E-02
gamma_ijklThe six independent elements that survive the symmetry, indices as above: \(\gamma_{xxxx}\)=397.7, \(\gamma_{xxyy}\)=80.0, and so on.
gamma_parThe orientational average \(\gamma_\parallel=\tfrac15\sum_{ij}\gamma_{iijj}\): 349.06 a.u.
rms of the tensor fitsThe root-mean-square residual of each least-squares fit, in the units of the fitted derivative (\(\alpha\), \(\beta\), \(\gamma\)): \(10^{-7}\), \(4\times10^{-5}\) and 0.026. The 13 directions give 39 equations for 6, 10 and 15 unknowns, so a small residual says that the fields were weak enough and the SCFs tight enough: the tensor is symmetric and the expansion converged. (Do not interpret the \(\gamma\) residual relative to the elements of 80–400 here, it is the fit of the third derivative.)
Plotting the tensors¶
python3 tutorials/tools/dftsw27plot.py hyperpol h2o_tensor_lda.out h2o_tensor_pz.out \
--label 'LDA' 'PZ-SIC (FODs fixed)' -o hyperpol.png

Water, UTEP-NRLMOL basis, the same geometry and FODs; the bars are the diagonal \(\alpha\) and the independent nonzero elements of \(\beta\) and \(\gamma\) with |value| above 0.3 and 20 (a.u.).
Results¶
(a.u.) |
LDA |
PZ-SIC (FODs fixed) |
|---|---|---|
\(\alpha_{xx}\) |
8.914 |
6.771 |
\(\alpha_{yy}\) |
9.802 |
8.542 |
\(\alpha_{zz}\) |
9.433 |
7.654 |
\(\bar\alpha\) |
9.383 |
7.655 |
\(\beta_{zxx}\) |
2.382 |
−3.034 |
\(\beta_{zyy}\) |
17.604 |
11.238 |
\(\beta_{zzz}\) |
14.243 |
5.547 |
\(\beta_\parallel\) |
−20.537 |
−8.251 |
\(\gamma_\parallel\) |
810.1 |
349.1 |
At fixed FODs the PZ-SIC response is much smaller than that of LDA: \(\bar\alpha\) drops by 18 %, \(\beta_\parallel\) by 60 % and \(\gamma_\parallel\) by 57 %. A smaller response is the expected direction for a correction that removes the spurious self-repulsion of LDA, which makes the LDA density too soft. These are the numbers for frozen FODs and a basis without diffuse functions; neither is a statement about the converged complete-basis FLOSIC result.
Things to try¶
1. The exact matrix and the KLI potential. Scan along \(z\) with each (h2o_scan_pz.yaml, h2o_scan_pz_kli.yaml).
With sic_potential: exact the zero-field dipole is \(-0.7850245\) a.u. and \(-\partial E/\partial F\) from the energies in the output is \(-0.7850245\):
they agree to \(1.5\times10^{-8}\). With sic_potential: kli the dipole is \(-0.8030235\) a.u. and \(-\partial E/\partial F=-0.7907731\): they differ by
\(1.2\times10^{-2}\) a.u. (1.5 %), because the KLI potential is not the derivative of the energy. The finite-field \(\alpha_{zz}\) is then 7.581, against 7.654
with the exact matrix. For polarizabilities of SIC systems use the exact matrix.
2. Coulomb method. h2o_tensor_lda_eri.yaml and h2o_tensor_lda_jfit.yaml repeat the LDA tensor run with aug-pc-1, once with exact integrals and once with RI-J (JFIT).
Against PySCF (same recipe, own SCFs, Cartesian d functions; ref_pyscf.py):
(a.u.) |
exact ( |
RI-J (JFIT) |
PySCF |
|---|---|---|---|
\(\alpha_{xx}\) |
10.514 |
10.531 |
10.514 |
\(\beta_{zxx}\) |
6.349 |
6.594 |
6.331 |
\(\beta_{zyy}\) |
14.213 |
14.213 |
14.230 |
\(\beta_{zzz}\) |
10.853 |
10.899 |
10.853 |
The exact-integral run agrees with PySCF to 0.3 % at worst (\(\beta_{zxx}\), a small element that depends on the out-of-plane response), and \(\alpha_{xx}\) and \(\beta_{zzz}\) to better than \(10^{-4}\). The remaining differences are the integration grids. Density fitting changes the small out-of-plane element \(\beta_{zxx}\) by 4 % and \(\gamma_\parallel\) by 1.8 % (2125.6 against 2088.7). Use exact integrals or a larger auxiliary basis when you need more than a qualitative \(\beta\).
3. The field step. Rerun the SIC tensors with amplitude: 0.0005 and 0.008:
\(h\) (a.u.) |
\(\bar\alpha\) |
\(\beta_\parallel\) |
\(\gamma_\parallel\) |
|---|---|---|---|
0.0005 |
7.655476 |
−8.2497 |
346.4 |
0.002 |
7.655475 |
−8.2508 |
349.1 |
0.008 |
7.655453 |
−8.2527 |
351.7 |
\(\bar\alpha\) changes by only \(2\times10^{-5}\) over the three steps; \(\beta_\parallel\) changes by \(3\times10^{-3}\) and \(\gamma_\parallel\) by 1.5 %. The second-order stencil of \(\gamma\) is the sensitive one: a step that is too small amplifies the SCF noise (divided by \(h^3\)) and one that is too large leaves the truncation error of the stencil. The default 0.002 is a good choice.
4. Exact Coulomb with SIC. The exercise run of run.sh --exercises repeats the SIC tensors with exact integrals for the main Coulomb matrix and the analytic
self-Coulomb of the orbitals instead of RI-J (about 35 minutes on 16 cores, against 100 s):
(a.u.) |
RI-J (JFIT) |
exact |
|---|---|---|
\(\bar\alpha\) |
7.6555 |
7.6563 |
\(\beta_{zxx}\) |
−3.034 |
−3.040 |
\(\beta_{zyy}\) |
11.238 |
11.223 |
\(\beta_{zzz}\) |
5.547 |
5.538 |
\(\beta_\parallel\) |
−8.251 |
−8.232 |
\(\gamma_\parallel\) |
349.1 |
348.2 |
Every number agrees within 0.3 %, so for PZ-SIC water the density fitting is not the limiting error here (it was for the LDA out-of-plane element in exercise 2); the fixed FODs and the basis are.
Limits¶
The FODs stay at their zero-field positions: the SIC tensors here are the fixed-FOD response, not that of the relaxed functional.
Analytic \(\alpha\) is for plain HF/DFT; SIC and hyperpolarizabilities go through finite fields.
The finite-field scan sits in the
rt_tddftsection for historical reasons: it uses the same field and Hamiltonian code as the real-time propagation.