Uncertainty in the XC Energy and Potential
This page describes how SCF tracks the uncertainty in the exchange-correlation (XC) energy, \(E^{XC}\), and the AO matrix of the XC potential, \(V^{XC}\), when they are evaluated by quadrature. It is part of the uncertainty-quantified SCF effort described in Designing QCUP-SCF, and extends it from Hartree-Fock to Kohn-Sham DFT.
The uncertainty has two kinds of sources. The quantities evaluated at the grid points, e.g., the density, are uncertain; how their uncertainty is estimated is described in Uncertainty in the XC Inputs on a Grid. The quadrature itself is also approximate, because the grid is incomplete. This page covers how both reach \(E^{XC}\) and \(V^{XC}\), and how the second is estimated.
Assumption: Asymmetric Intervals
Throughout this page and Uncertainty in the XC Inputs on a Grid, the UQ type is assumed to be an asymmetric interval. It stores a lower bound, an upper bound, and a mean (the best estimate of the value), and the mean need not be the midpoint of the bounds. For a value \(x\), the bounds are \(x - \delta x^-\) and \(x + \delta x^+\), and the deviations \(\delta x^-, \delta x^+ \ge 0\) need not be equal.
The reason for this assumption is that the density can not be negative, so its
lower bound must be pinned at zero whenever an error model’s estimate would go
below it. An asymmetric interval allows this without changing the mean. A
symmetric interval stores only the bounds: pinning
\([\rho_i - r_i, \rho_i + r_i]\) at zero gives \([0, \rho_i + r_i]\),
whose midpoint, \((\rho_i + r_i)/2\), is larger than \(\rho_i\), so the
best estimate of the density would be biased upward. sigma::Interval stores
only the bounds. sigma::Triplex
stores the bounds and, independently, a nominal value, i.e., it is an
asymmetric interval. It is available in TensorWrapper as tpdouble and from a
UQ Initializer as the triplex kind.
Errors in the XC Energy and Potential
Let \(\vec{r}_i\) and \(w_i\) be the point and weight of the \(i\)-th of \(N_g\) grid points, \(\phi_{\mu i}\) the value of the \(\mu\)-th atomic orbital (AO) at \(\vec{r}_i\), and \(\rho_i\) the density at \(\vec{r}_i\). For an LDA with energy density \(f\) and \(v = \partial f / \partial \rho\), the XC energy and potential of the functional, \(\tilde{E}^{XC}\) and \(\tilde{V}^{XC}\), are:
These are the exact integrals of the chosen (approximate) functional, not the exact XC energy and potential, which are unknown. In practice, the integrals are evaluated by quadrature. Let \(E^{Quad}\) and \(V^{Quad}\) be the values obtained by exactly applying a quadrature rule:
Of note these equations assume:
The inputs (e.g., \(\rho_i\)) are evaluated at the grid points and are assumed to be exact.
The sums are over all grid points in the quadrature rule, i.e., no terms are screened out.
Subject to these assumptions, the errors in the quadratures are then:
If the sums are screened, terms are dropped from them and we actually compute \(E^{Scr}\) and \(V^{Scr}\):
where \(\mathcal{K}\) is the set of grid points that are kept in the energy, and \(\mathcal{K}_{\mu\nu}\) is the set of grid points that are kept for the AO pair \(\mu\nu\) in the potential. The latter allows for screening that drops individual AO pairs at a grid point (e.g., because \(\left|\phi_{\mu i}\phi_{\nu i}\right|\) is small), not only whole grid points. The screening errors relative to full quadrature are:
Similarly, if the inputs are approximated we actually compute \(E^{Inputs}\) and \(V^{Inputs}\) and the errors from using approximate inputs relative to full quadrature are:
Note that the total error will in general not simply be the sum of the three errors because of cross terms. For example, if both screening and approximate inputs are used, then screening out a term will also change the uncertainty from the input uncertainty to that term. Other errors, such as floating-point rounding, can be built up using the same framework, i.e., as the difference between the value computed with the error and the value computed without it.
Throughout this page, \(E^{XC}\) and \(V^{XC}\) denote the values that are actually computed, i.e., with whatever screening and approximate inputs are used, and \(\tilde{E}^{XC}\) and \(\tilde{V}^{XC}\) always denote the exact integrals, i.e., the reference values.
Statement of Need
QCUP-SCF attaches an uncertainty to every approximately computed quantity by storing it as a UQ type, and lets the uncertainty propagate through the rest of the calculation by doing arithmetic with those types. For the ERIs, an error model attaches the uncertainty, and the uncertainty in the Coulomb and exchange matrices, the Fock matrix, and the energy follows from the arithmetic.
As just motivated, the uncertainty in the computed \(E^{XC}\) and \(V^{XC}\) has three sources:
Uncertainty in the inputs. \(\rho_i\) and \(\phi_{\mu i}\) (and, for GGAs and beyond, further quantities such as \(\nabla\rho_i\)) are uncertain. If they are UQ types, the XC modules evaluate the quadratures with UQ types, and the inputs’ uncertainty propagates through the arithmetic without further consideration. Error models for attaching the uncertainty to the inputs are described in Uncertainty in the XC Inputs on a Grid. Without UQ types, we would need an error model to attach the uncertainty to \(E^{XC}\) and \(V^{XC}\) directly.
Screening of the grid. The quadrature sums are screened, so some terms are dropped. This is an error in the quadrature, but does not stem from the uncertainty in any of the inputs, so it needs an error model of its own, which attaches uncertainty to \(E^{XC}\) and \(V^{XC}\) directly.
Incompleteness of the grid. Even with exact inputs and the full quadrature, the quadrature differs from the integral. This error is attached to \(E^{XC}\) and \(V^{XC}\) by its own error model.
Error models for the first source are described in Uncertainty in the XC Inputs on a Grid. The purpose of this page is to design the infrastructure and error models for the second and third error sources. For simplicity we will refer to the latter two uncertainty sources as the error of the grid.
Considerations
Each error source is counted once
Uncertainty in the inputs is attached to the inputs; uncertainty from the grid is attached to \(E^{XC}\) and \(V^{XC}\). The error models must not double-count either source of uncertainty.
Same interface as the XC modules
The module for attaching uncertainty to \(E^{XC}\) and \(V^{XC}\) is a wrapper around an XC module. It has the same property types, so it can be leveraged wherever the XC module was leveraged.
As additional approximations are made, the module must be extendible so that it can attach uncertainty for those sources as well.
The error model is a choice
As with the ERIs, there are several ways to estimate the error from the grid. The module should facilitate choosing among them.
The uncertain type is chosen in one place
As in Designing QCUP-SCF, only the modules that create uncertainty know the uncertain type, and they get it from a
UQ Initializersubmodule. Here, those are the error models.
Ordinary DFT is unaffected
Uncertainty should be done in wrappers over ordinary DFT or rely on templated DFT kernels to propagate uncertainty.
Code meant for use with traditional DFT should not need to know about uncertainty propagation.
XC UQ Implementation
SCF adds two modules, UQ XC Energy and UQ XC Potential, that are
respectively responsible for computing the XC energy and XC potential with
uncertainty. They follow the same pattern, so this section only describes the
potential module.
As part of this design we introduce a new property type Quadrature<T>. This
PT will live in the SCF repo for now. T here will be the property type of
the quantity that is being evaluated by quadrature, e.g., for the XC
potential it is
simde::aos_xc_e_aos. In addition to taking the inputs T needs,
Quadrature<T> will also take the grid. SCF’s XC energy and potential modules
will be updated accordingly: each keeps its "Integration grid" submodule,
builds the grid with it, and passes the grid and its own inputs to a submodule
satisfying Quadrature<T>, e.g., SVWN3 Potential Quadrature for
SVWN3 Potential, which evaluates the quadrature on that grid.
The UQ XC Potential module satisfies the same property type as an XC
potential module (i.e., simde::aos_xc_e_aos). Like the XC potential
modules, it builds the grid with its own "Integration grid" submodule, so
that the quadrature and the error model see the same grid. The initial
implementation will focus on attaching the uncertainty caused by using an
incomplete grid. The current control flow is as follows:
Unwrap the inputs and build the grid with the
"Integration grid"submodule.Pass the inputs and the grid to the
"XC Potential"submodule, which satisfiesQuadrature<T>.Pass the inputs, the grid, and the result of the quadrature to a submodule that estimates the uncertainty from the incompleteness error and attaches the uncertainty.
Call submodules for other sources of uncertainty, if any (eventually screening). Module’s design dictates whether the uncertainty is attached to the results of the wrapped XC potential module or to the uncertainty from the incompleteness error.
Return the final UQ results.
XCUncertain<Quadrature<T>> will be the property type that estimates the
uncertainty from the incompleteness of the grid. The template parameter T
is the property type of the module being evaluated by quadrature, i.e., for the
XC potential it is simde::aos_xc_e_aos. XCUncertain<U> will be a PT that
lives in SCF that takes the inputs of U and the results of calling a module
satisfying U. The Uncertain<V> property type in SimDE should eventually
be updated to replace XCUncertain<U>, but is out of scope for this design.
The result of calling a module
satisfying XCUncertain<Quadrature<T>> will be the input results with
uncertainties applied, i.e., a matrix of the same size as the XC potential
matrix where each element is a UQ type object that uses the input result as the
mean of the returned result. It is the module which satisfies
XCUncertain<Quadrature<T>> that is responsible for calling
UQ Initializer.
The QCUP-SCF driver will be in charge of swapping out the error models. We
will add submodules to the QCUP-SCF driver for each source of uncertainty, e.g.,
a submodule satisfying XCUncertain<Quadrature<simde::aos_xc_e_aos>> will be
added to QCUP-SCF and targeted at the UQ XC Potential’s submodule. Users
can thus control the error models from the driver level.
To summarize, the submodules of the UQ XC Potential module are:
Hook name |
Default key |
Purpose |
|---|---|---|
|
|
Builds the grid passed to both the quadrature and the error model. |
|
|
The module that evaluates the quadrature. Satisfies |
|
|
The error model that estimates the uncertainty from the incompleteness of the grid. |
Reference Grid XC Potential Error is the “Reference Grid” error model
introduced in the next section. UQ XC Energy is the same, with
XC Energy, SVWN3 Energy Quadrature, and
Reference Grid XC Energy Error.
Incompleteness Error Models
The strategies below estimate the incompleteness errors, \(\delta E^{Quad}\) and, element-wise, \(\delta V^{Quad}\). It is assumed that no screening occurs in the grid. The value from the ordinary grid is kept as the mean, and the estimate becomes the deviations.
Reference Grid
Evaluate the quadrature a second time on a finer grid, giving
\(E^{Quad}_{\mathrm{ref}}\) (or \(V^{Quad}_{\mathrm{ref}}\)), and use
the difference, \(d = E^{Quad}_{\mathrm{ref}} - E^{Quad}\), to estimate the
size of \(\delta E^{Quad}\). The deviation is \(|d|\) on both sides of
the value. The sign of \(d\) is not used as the direction of the error:
refinement need not converge monotonically, and in the grid-incompleteness
study (the grid_incompleteness package of the QCUPDFT repository in the
QCUncertainty organization; SVWN3 for He, H2, and water in STO-3G
through aug-cc-pVQZ) the error of the quadrature changes sign as the grid is
refined, e.g., for H2 in aug-cc-pVTZ it is positive with 20 radial
points and negative with 50. A
deviation only on the side of the reference value would then exclude the exact
integral. This mirrors the Analytic Error ERI error model and its benchmark
ERIs. It is an estimate, not a bound, and costs one evaluation on the finer
grid, including the density and AOs on that grid.
The strategy is implemented as the error models
Reference Grid XC Energy Error and Reference Grid XC Potential Error
(see XC UQ Implementation), which satisfy XCUncertain<Quadrature<T>>.
Their submodules are:
Hook name |
Default key |
Purpose |
|---|---|---|
|
|
Builds the finer grid from the molecule. Must have |
|
|
Evaluates the quadrature on the finer grid. Must use the same functional as the quadrature being corrected. |
|
Integrals’ |
The kind of uncertain value returned. |
The module builds the finer grid, passes the inputs and the finer grid to the
Reference XC Module submodule, and uses the element-wise difference as the
deviation on both sides. It then converts the original result to the UQ type
with its UQ Initializer submodule, keeping the original result as the
nominal value, and returns that uncertain result, not the difference. For now,
the given result must hold doubles.
The finer grid is derived from the given grid. chemist::Grid records the
radial and angular sizes of the atom-centered product grid it was made from
(Grid From IntegratorXX sets them from its inputs), and the given grid must
record both. From them, the finer sizes are:
radial: 1.5 times the given radial size, rounded up;
angular: the size of the smallest Lebedev-Laikov grid with at least twice as many points as the given angular size, which must itself be a Lebedev-Laikov size, or 5810 (the largest Lebedev-Laikov grid) if there is no such grid. A given angular size of 5810 is thus not refined.
These steps are roughly those of the radial and angular sizes in the
grid-incompleteness study. The Reference grid submodule is run with its
Radial Size and Angular Size inputs set to the finer sizes. All of its
other inputs (e.g., the radial quadrature, pruning, and partitioning) are
used as they are, so by default it is the module which builds the given grid,
Grid From IntegratorXX, and the two grids differ only in their sizes. For
the default grid (150 radial and 194 angular points) the finer grid has 225
radial and 434 angular points, so each call costs a little more than three
times the quadrature it is estimating the error of.
Grid Extrapolation
Evaluate on a sequence of grids of increasing size and estimate the remaining
error from how quickly the values converge. This is more expensive than a
single reference grid, but gives an estimate of the error of the finest grid
rather than the difference between two grids. It is a tool for choosing the
grid and for validating the reference-grid strategy. It could be implemented
as a series of successive calls to the Reference Grid Error module, but it
is not yet implemented.
Verified Cell Enclosure
Partition space into regions, \(\Omega_i\), of known volume, and let \(\rho\left(\Omega_i\right)\) be an enclosure of every value the density takes in \(\Omega_i\). Then
evaluated with UQ types, where the last term covers space outside all of the regions and must be bounded separately, e.g., from a bound on the density far from the molecule. The enclosures \(\rho\left(\Omega_i\right)\) are computed by this error model itself, not taken from the inputs of Uncertainty in the XC Inputs on a Grid, which only carry the uncertainty of the values at the grid points; taking them from the inputs would count the variation of the density across each region twice. This converges more slowly than traditional quadrature and is thus expected to give a wider bound.
A Priori Estimates
The error of the radial and angular quadratures can be estimated from their known properties, e.g., the highest degree of spherical harmonic an angular grid integrates exactly, together with how quickly the integrand’s expansion in spherical harmonics decays around each atom. This is cheap, but needs analysis per quadrature, and is the least developed of the strategies.
Summary
Strategy |
Bound or estimate |
Extra cost |
Notes |
|---|---|---|---|
Reference grid |
estimate |
1 evaluation on a finer grid |
symmetric; finer grid derived from the given grid |
Grid extrapolation |
estimate |
several evaluations |
for validation and choosing grids |
Verified cell enclosure |
bound |
1 evaluation with region enclosures |
wide; LDA only as described |
A priori estimates |
estimate |
small |
needs analysis per quadrature |
Further Considerations
Rounding in the functional. Evaluating \(f\), \(v\), and the sums over grid points also rounds. This is only accounted for if the arithmetic of the UQ type rounds outward. It is expected to be small compared with the other sources.
Thresholds in the functionals. The XC modules need a policy for points whose uncertain density reaches below a density threshold, or zero. Pinning the lower bound of the density at zero keeps the density sound but does not bound \(\partial v/\partial\rho\). Dropping such points, as LibXC does, must itself be counted as an error, and is part of the error of the grid.
Uncertain grids.
GridFromIntegratorXXcan make grids with uncertain points and weights. Uncertain points make the inputs uncertain and are covered in Uncertainty in the XC Inputs on a Grid. Uncertain weights enter the sums directly, so their effect follows from the UQ arithmetic in the XC modules.GGAs and beyond. The inputs grow (see Uncertainty in the XC Inputs on a Grid), but the split between the inputs and the error of the grid is unchanged.