Opening the book…
There are a variety of available computational chemistry packages that provide the implementations of these methods, such as Gausian, MOLPRO, Q-Chem, and CFOUR. Unless you become a method developer in theoretical chemistry, you are unlikely to ever need to dive in and write code to perform quantum chemical calculations yourself; you can just use one of these packages. However, it is important to note that when you do a quantum chemical calculation you will always get an answer, for better or for worse. If you do not understand the principles behind the calculation, you will not be able to understand the context of the answer you get or be able to assess how “right” the answer is.
We will examine how a computer performs a Hartree-Fock SCF calculation. The process begins with the selection of a basis set. For our MO theory calculations on , our basis set was a linear combination of hydrogen atom wavefunctions centered on each atom. We found that when we set up the single-electron Hamiltonian Matrix, there were three types of integrals that we needed to evaluate:
\[S_{AB} = \braket{1s_A}{1s_B}, \nonumber\]
\[K_{AB} = \bra{1s_A}\frac{1}{r_B}+\frac{1}{R}\ket{1s_B}, \nonumber\]
\[J_{AA} = \bra{1s_A}\frac{1}{r_B}+\frac{1}{R}\ket{1s_A}. \nonumber \]
Computers can readily perform these integrals and construct the Hamiltonian matrix in numeric form, then can use linear algebra algorithms to diagonalize the matrix. After solving the single-electron problem, the computer constructs Slater determinants numerically, evaluate the two-electron repulsion integrals numerically, and iteratively rediagonalize the matrix until the SCF calculation converges. Essentially, during an SCF calculation, the computer spends its time numerically evaluating integrals involving our basis functions and diagonalizing matrices. In most cases, integral evaluation is the rate-limiting step.
Numerical integration
How does a computer evaluate integrals like these, especially if the analytical solution is not known? Recall the definition of an integral as a Riemann sum:
\[\int_a^b f(x)\, \text{d}x = \lim_{\Delta x \to 0} \sum_{i=a}^b f(x_i) \Delta x. \label{1} \]
That is, if we define an evenly-spaced grid of points (called a quadrature grid) that spans the distance from \(a\) to \(b\), evaluate the function at each point, multiply by the grid spacing, and add up the results, we have an approximation of the integral that becomes exact as the number of points in the grid approaches \(\infty\). Therefore, a computer does not need to first solve the indefinite integral; all it needs to know how to do is to calculate the value of a function. The computational cost scales with the complexity of the function (how many processor instructions are required to compute the final answer) and the number of quadrature points. However, in the few cases for which an analytical solution is known, the calculation can be greatly accelerated because the solution to the indefinite integral need only be evaluated at its endpoints.
The above calculation shows a one-dimensional function. Most integrals in quantum chemistry are multi-dimensional: integrals involving a single electron are three-dimensional (\(x\), \(y\), and \(z\) or \(r\), \(\theta\), and \(\phi\)); integrals involving two electrons (such as the electronic repulsion integrals) are six-dimensional, and so on. However, the Riemann sum approach can scale to arbitrary dimensions. For instance, a double integral can be calculated as:
\[\int_a^b\int_c^d f(x,y)\, \text{d}x \text{d}y = \lim_{\substack{\Delta x \to 0 \\[4pt] \Delta y \to 0} } \sum_{i = a}^b\sum_{j=c}^d f(x_i,y_j) \Delta x \Delta y. \label{2} \]
Now the number of calculations that needs to be done is the product of the number of quadrature points between \(a\) and \(b\) and that between \(c\) and \(d\). In the limit that the grid sizes are equal with number of points \(n\), a 2D integral requires \(n^2\) calculations (and a \(m\)-dimensional integral requires \(n^m\) calculations!).
We’ve described the “left point rule” for evaluating integrals with an evenly sampled quadrature grid. Numerous other methods exist (trapezoidal rule, Simpson’s rule, adaptive sampling), and implementations of these methods are widely available in a variety of programming languages (for Python, see NumPy, for C++, see the GNU Scientific Library). Some of these methods are shown in Figure \(\PageIndex{1}\). These tools allow for faster and more accurate calculations, but fundamentally the time that a calculation takes will still scale with the number of integrals that have to be evaluated, their complexity, their dimensionality, and the number of quadrature points involved.
12.2: Numerical Integrations are Core of Quantum Chemistry is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.
The book could not be loaded just now.