From f41031fb48922423a52cd806620bfb79f3750e1e Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Tue, 10 Oct 2023 14:03:22 +0000 Subject: [PATCH 01/14] pre-amble on GTO --- notebooks/gto_integrals.ipynb | 57 +++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index 38d7894..f35969c 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -6,13 +6,50 @@ "source": [ "*Copyright (c) 2023 Graphcore Ltd. All rights reserved.*\n", "\n", + "$$\n", + "\\renewcommand{\\br}{\\mathbf{r}}\n", + "\\renewcommand{\\bA}{\\mathbf{A}}\n", + "$$\n", + "\n", + "# Integrals over Gaussian Type Orbitals (GTO)\n", + "\n", + "Zooming straight past a number of details, a standard approach in density functional theory (DFT)\n", + "is to expand the molecular orbitals $\\{\\psi_i (\\br) \\}$ in a finite basis set:\n", + "$$\n", + "\\tag{1}\n", + "\\psi_i (\\br) = \\sum_i^N c_i \\phi_i (\\br).\n", + "$$\n", + "Typically the basis functions $\\{\\phi_i (\\br) \\}$ are taken as approximations of atomic orbitals and this is referred to as the linear combination of atomic orbitals (LCAO) method in the literature. There is some flexibility in how exactly this finite\n", + "basis is defined. Gaussian type orbitals (GTO) are perhaps\n", + "one of the most popular choices and take the following general form \n", + "$$\n", + "\\tag{2}\n", + "\\phi (\\br; \\bA, \\alpha, l, m, n) = N x_A^l y_A^m z_A^n e^{-\\alpha |\\br - \\bA|^2}.\n", + "$$\n", + "These functions are parametrised by:\n", + "* $\\bA = (X_A, Y_A, Z_A)$ is the center of the Gaussian orbital that for our current treatment will be set by the atomic positions of the molecular structure we are simulating. We use the common shorthand of $x_A = x - X_A$ in the leading polynomial term\n", + "* $\\alpha$ in the exponent determines the extent of the Gaussian orbital.\n", + "* $(l, m, n)$ are the angular momentum quantum numbers that take on non-negative integer values. \n", + "\n", + "The normalising constant $N$ is a function of $\\alpha$ and $(l, m, n)$ and is defined such that:\n", + "$$\n", + "\\tag{2}\n", + "\\int \\phi_i(\\br) \\phi_i(\\br) d\\br \\equiv 1 \n", + "$$\n", + "\n", + "The DFT optimisation problem\n", + "proceeds to find the expansion coefficients that minimise the total energy, while \n", + "maintaining orthonormality in the molecular orbitals.\n", + "\n", + "For an overview and derivation we refer the reader to the following review article:\n", "\n", - "# Integrals over Gaussian Type Orbitals (GTO)" + "> Lehtola, S., Blockhuys, F. and Van Alsenoy, C., 2020. An overview of self-consistent field calculations within finite basis sets. Molecules, 25(5), p.1218. [open access](https://doi.org/10.3390/molecules25051218)\n", + "\n" ] }, { "cell_type": "code", - "execution_count": 41, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -68,7 +105,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -96,7 +133,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -122,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -158,7 +195,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -182,7 +219,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -217,7 +254,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -254,7 +291,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -329,7 +366,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": null, "metadata": {}, "outputs": [ { From 5ab8b50f49ade04112a90772d30069c54df27f2a Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Tue, 10 Oct 2023 15:30:57 +0000 Subject: [PATCH 02/14] more elaboration --- notebooks/gto_integrals.ipynb | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index f35969c..c3408e4 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -24,22 +24,29 @@ "one of the most popular choices and take the following general form \n", "$$\n", "\\tag{2}\n", - "\\phi (\\br; \\bA, \\alpha, l, m, n) = N x_A^l y_A^m z_A^n e^{-\\alpha |\\br - \\bA|^2}.\n", + "\\phi_i (\\br; \\bA, \\alpha, l, m, n) = N x_A^l y_A^m z_A^n e^{-\\alpha |\\br - \\bA|^2}.\n", "$$\n", - "These functions are parametrised by:\n", + "These functions are parameterised by:\n", "* $\\bA = (X_A, Y_A, Z_A)$ is the center of the Gaussian orbital that for our current treatment will be set by the atomic positions of the molecular structure we are simulating. We use the common shorthand of $x_A = x - X_A$ in the leading polynomial term\n", "* $\\alpha$ in the exponent determines the extent of the Gaussian orbital.\n", - "* $(l, m, n)$ are the angular momentum quantum numbers that take on non-negative integer values. \n", + "* $(l, m, n)$ are the angular momentum quantum numbers that take on non-negative integer values.\n", + "* normalising constant $N$ is a function of $\\alpha$ and $(l, m, n)$ and is derived later in this notebook.\n", "\n", - "The normalising constant $N$ is a function of $\\alpha$ and $(l, m, n)$ and is defined such that:\n", + "Another complication that is worth mentioning up front is that we typically encounter \n", + "*contracted* Gaussian basis functions defined as:\n", "$$\n", - "\\tag{2}\n", - "\\int \\phi_i(\\br) \\phi_i(\\br) d\\br \\equiv 1 \n", + "\\tag{3}\n", + "\\phi_i (\\br; \\bA, l, m, n) = \\sum_\\mu^L d_{\\mu i} p_\\mu(\\br; \\bA, \\alpha_\\mu, l, m, n)\n", + "$$\n", + "where we introduce the *primitive* Gaussian $p_\\mu$ that take the form:\n", + "$$\n", + "p_\\mu(\\br; \\bA, \\alpha_\\mu, l, m, n) = N x_A^l y_A^m z_A^n e^{-\\alpha_\\mu |\\br - \\bA|^2}.\n", "$$\n", + "Gaussian basis functions of the form above have a few convenient properties that help\n", + "make it easier to evaluate the matrices comprised of molecular elements.\n", "\n", - "The DFT optimisation problem\n", - "proceeds to find the expansion coefficients that minimise the total energy, while \n", - "maintaining orthonormality in the molecular orbitals.\n", + "It can be useful for view DFT an optimisation problem where we search for the expansion coefficients that minimise the total energy. There are additional constraints such as maintaining orthonormality between the molecular orbitals\n", + "maintaining orthonormality in the molecular orbitals. \n", "\n", "For an overview and derivation we refer the reader to the following review article:\n", "\n", From 736cf77197dece59520eb5bedb55da153c354919 Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Wed, 11 Oct 2023 10:51:40 +0000 Subject: [PATCH 03/14] adding oxgygen basis example --- notebooks/gto_integrals.ipynb | 105 ++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 4 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index c3408e4..bc9ed20 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -17,7 +17,7 @@ "is to expand the molecular orbitals $\\{\\psi_i (\\br) \\}$ in a finite basis set:\n", "$$\n", "\\tag{1}\n", - "\\psi_i (\\br) = \\sum_i^N c_i \\phi_i (\\br).\n", + "\\psi_i (\\br) = \\sum_{i=1}^N c_i \\phi_i (\\br).\n", "$$\n", "Typically the basis functions $\\{\\phi_i (\\br) \\}$ are taken as approximations of atomic orbitals and this is referred to as the linear combination of atomic orbitals (LCAO) method in the literature. There is some flexibility in how exactly this finite\n", "basis is defined. Gaussian type orbitals (GTO) are perhaps\n", @@ -27,7 +27,7 @@ "\\phi_i (\\br; \\bA, \\alpha, l, m, n) = N x_A^l y_A^m z_A^n e^{-\\alpha |\\br - \\bA|^2}.\n", "$$\n", "These functions are parameterised by:\n", - "* $\\bA = (X_A, Y_A, Z_A)$ is the center of the Gaussian orbital that for our current treatment will be set by the atomic positions of the molecular structure we are simulating. We use the common shorthand of $x_A = x - X_A$ in the leading polynomial term\n", + "* $\\bA = (X_A, Y_A, Z_A)$ is the center of the Gaussian orbital that for our current treatment will be set by the atomic positions of the molecular structure we are simulating. We use the shorthand of $x_A = x - X_A$ in the leading polynomial term\n", "* $\\alpha$ in the exponent determines the extent of the Gaussian orbital.\n", "* $(l, m, n)$ are the angular momentum quantum numbers that take on non-negative integer values.\n", "* normalising constant $N$ is a function of $\\alpha$ and $(l, m, n)$ and is derived later in this notebook.\n", @@ -36,12 +36,109 @@ "*contracted* Gaussian basis functions defined as:\n", "$$\n", "\\tag{3}\n", - "\\phi_i (\\br; \\bA, l, m, n) = \\sum_\\mu^L d_{\\mu i} p_\\mu(\\br; \\bA, \\alpha_\\mu, l, m, n)\n", + "\\phi_i (\\br; \\bA, l, m, n) = \\sum_{\\mu=1}^{K_i} d_{\\mu i} p_\\mu(\\br; \\bA, \\alpha_\\mu, l, m, n)\n", "$$\n", - "where we introduce the *primitive* Gaussian $p_\\mu$ that take the form:\n", + "where we introduce the *primitive* Gaussian:\n", "$$\n", "p_\\mu(\\br; \\bA, \\alpha_\\mu, l, m, n) = N x_A^l y_A^m z_A^n e^{-\\alpha_\\mu |\\br - \\bA|^2}.\n", "$$\n", + "In general the length of the contraction $K_i$ have been pre-optimised alongside the contraction coefficients $d_{\\mu i}$ and the primitive exponents $\\alpha_\\mu$ to best approximate atomic orbitals. A range of Gaussian basis sets covering the periodic table with different compute time vs accuracy tradeoffs are available from the [basis set exchange](https://www.basissetexchange.org/). We use their python API in this project to provide programmatic access to these basis sets.\n", + "\n", + "To demonstrate this, we use the `basisset` function to build the atomic orbitals of a single oxygen atom. The `Basis` object built by `basisset` consists of a list of `Orbital` objects which are defined by a set of `coefficients` and corresponding `Primitive` objects." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import numpy as np\n", + "from pyscf_ipu.experimental.structure import Structure\n", + "from pyscf_ipu.experimental.basis import basisset\n", + "\n", + "basisname = \"sto-3g\"\n", + "oxygen = Structure(atomic_number=np.array([8]), position=np.zeros(3))\n", + "basis = basisset(oxygen, basisname)\n", + "basis.num_orbitals" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The number of atomic orbitals follows from the [Aufbau principle](https://en.wikipedia.org/wiki/Aufbau_principle). Applying this to a single Oxygen atom predicts the electron configuration as $1s^2 2s^2 2p^4$ which keeping in mind that the $2p$ atomic orbitals will consist of three orbitals we arrive at five atomic orbitals for a single oxygen atom.\n", + "\n", + "This rule applies when using a minimal basis set such as `\"sto-3g\"` which uses a\n", + "contraction of 3 Gaussians to approximate each atomic orbital. From this we expect a tottal of 15 primitives in the basis set for a single oxygen atom:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "15" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "basis.num_primitives" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can plot these atomic orbitals by first evaluating the basis functions on a regular grid and using py3DMol to render isosurfaces. The $1s$ and $2s$ orbitals have spherical symmetry so we plot the $2px$ orbital below." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from pyscf_ipu.experimental.mesh import uniform_mesh, molecular_orbitals\n", + "from pyscf_ipu.experimental.plot import plot_volume\n", + "\n", + "\n", + "\n", + "# Evaluate the molecular orbitals on a mesh -> [num_mesh_points, num_orbitals]\n", + "mesh, axes = uniform_mesh(n=32, b=3.0)\n", + "orbitals = molecular_orbitals(basis, mesh)\n", + "orbitals = np.asarray(orbitals)\n", + "\n", + "# Mapping between orbital label -> index in basis set\n", + "orbital_idx = dict(zip([\"1s\", \"2s\", \"2px\", \"2py\", \"2pz\"], range(5)))\n", + "plot_volume(oxygen, orbitals[:, orbital_idx[\"2px\"]], axes)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", "Gaussian basis functions of the form above have a few convenient properties that help\n", "make it easier to evaluate the matrices comprised of molecular elements.\n", "\n", From d8a75d15aeecf8df1ffe49ce8b1d506cd91886f6 Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Wed, 11 Oct 2023 11:27:19 +0000 Subject: [PATCH 04/14] basis -> matrix --- notebooks/gto_integrals.ipynb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index bc9ed20..c6cef5a 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -44,7 +44,7 @@ "$$\n", "In general the length of the contraction $K_i$ have been pre-optimised alongside the contraction coefficients $d_{\\mu i}$ and the primitive exponents $\\alpha_\\mu$ to best approximate atomic orbitals. A range of Gaussian basis sets covering the periodic table with different compute time vs accuracy tradeoffs are available from the [basis set exchange](https://www.basissetexchange.org/). We use their python API in this project to provide programmatic access to these basis sets.\n", "\n", - "To demonstrate this, we use the `basisset` function to build the atomic orbitals of a single oxygen atom. The `Basis` object built by `basisset` consists of a list of `Orbital` objects which are defined by a set of `coefficients` and corresponding `Primitive` objects." + "To demonstrate these concepts, we use the `basisset` function to build the atomic orbitals of a single oxygen atom. The `Basis` object built by `basisset` consists of a list of `Orbital` objects which are defined by a set of `coefficients` and corresponding `Primitive` objects." ] }, { @@ -121,7 +121,6 @@ "from pyscf_ipu.experimental.plot import plot_volume\n", "\n", "\n", - "\n", "# Evaluate the molecular orbitals on a mesh -> [num_mesh_points, num_orbitals]\n", "mesh, axes = uniform_mesh(n=32, b=3.0)\n", "orbitals = molecular_orbitals(basis, mesh)\n", @@ -136,7 +135,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\n", + "The above visualisation uses the formulas defined earlier to numerically evaluate\n", + "each atomic orbital from a linear combintation of primitive Gaussians. Introducing\n", + "the basis set allows us to replace the problem of solving a system partial differential equations (e.g. the Kohn-Sham equations) with an algebraic system of equations that can be solved standard matrix eigenvalue techniques. The individual\n", + "elements of the matrices in this system are integrals over pairs of basis functions:\n", + "$$\n", + "M_{ij} = \\int \\phi_i(\\br) \\hat{M}(\\br) \\phi_j(\\br) d\\br\n", + "$$\n", "\n", "\n", "Gaussian basis functions of the form above have a few convenient properties that help\n", From d0da08056161e2c5a9160e7d81f49003efe4a9e2 Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Wed, 11 Oct 2023 20:08:08 +0000 Subject: [PATCH 05/14] updating with sympy coeffs --- notebooks/gto_integrals.ipynb | 403 ++++++++++++++-------------------- 1 file changed, 159 insertions(+), 244 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index c6cef5a..56bc4d6 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -40,6 +40,7 @@ "$$\n", "where we introduce the *primitive* Gaussian:\n", "$$\n", + "\\tag{4}\n", "p_\\mu(\\br; \\bA, \\alpha_\\mu, l, m, n) = N x_A^l y_A^m z_A^n e^{-\\alpha_\\mu |\\br - \\bA|^2}.\n", "$$\n", "In general the length of the contraction $K_i$ have been pre-optimised alongside the contraction coefficients $d_{\\mu i}$ and the primitive exponents $\\alpha_\\mu$ to best approximate atomic orbitals. A range of Gaussian basis sets covering the periodic table with different compute time vs accuracy tradeoffs are available from the [basis set exchange](https://www.basissetexchange.org/). We use their python API in this project to provide programmatic access to these basis sets.\n", @@ -137,28 +138,91 @@ "source": [ "The above visualisation uses the formulas defined earlier to numerically evaluate\n", "each atomic orbital from a linear combintation of primitive Gaussians. Introducing\n", - "the basis set allows us to replace the problem of solving a system partial differential equations (e.g. the Kohn-Sham equations) with an algebraic system of equations that can be solved standard matrix eigenvalue techniques. The individual\n", - "elements of the matrices in this system are integrals over pairs of basis functions:\n", + "the basis set allows us to replace the problem of solving a system partial differential equations (e.g. the Kohn-Sham equations) with an algebraic system of equations that can be solved using standard matrix eigenvalue techniques.\n", + "The individual elements of the matrices in this system are integrals over pairs of\n", + "basis functions:\n", "$$\n", - "M_{ij} = \\int \\phi_i(\\br) \\hat{M}(\\br) \\phi_j(\\br) d\\br\n", + "\\tag{5}\n", + "M_{ij} = \\int \\phi_i(\\br) \\hat{M}(\\br) \\phi_j(\\br) d\\br.\n", "$$\n", + "We introduce the operator $\\hat{M}(\\br)$ which in its most general definition is\n", + "a function that transforms the $\\phi_j(\\br)$ basis functions to represent a physical\n", + "observable. That sounds fancy but is just a complicated way of saying we are breaking\n", + "down something we can measure (e.g. the energy, dipole moment, etc) into components\n", + "that we can evaluate through these integrals. The simplest operator is simply an \n", + "identity mapping that we name the overlap:\n", + "$$\n", + "\\tag{6}\n", + "S_{ij} = \\int \\phi_i(\\br) \\phi_j(\\br) d\\br.\n", + "$$\n", + "Recalling that each of the atomic orbitals are represented as a linear combination of primitives allows us to further expand the overlap integral as:\n", + "$$\n", + "\\tag{7}\n", + "S_{ij} = \\int \\sum_{\\mu = 1}^{K_i} \\sum_{\\nu = 1}^{K_j} d_{\\mu i} d_{\\nu j} p_\\mu(\\br) p_{\\nu}(\\br) d\\br = \\sum_{\\mu \\nu} d_{\\mu i} d_{\\nu j} \\tilde{S}_{{\\mu \\nu}}.\n", + "$$\n", + "Since we can swap the order of integration and the double-summation we are able to introduce $\\tilde{S}_{\\mu \\nu}$ as the elements of the overlap matrix in terms of the primitive functions:\n", + "$$\n", + "\\tag{8}\n", + "\\tilde{S}_{\\mu \\nu} = \\int p_\\mu(\\br) p_\\nu(\\br) d\\br.\n", + "$$\n", + "This finally sets us up to discuss the benefits of using an expansion in Gaussian type orbitals to iteratively solve Kohn-Sham equations using the self-consistent field (SCF) method. As an aside, for a nice overview and derivation of the SCF method we refer the reader to the following review article:\n", "\n", + "> Lehtola, S., Blockhuys, F. and Van Alsenoy, C., 2020. An overview of self-consistent field calculations within finite basis sets. Molecules, 25(5), p.1218. [open access](https://doi.org/10.3390/molecules25051218)\n", "\n", "Gaussian basis functions of the form above have a few convenient properties that help\n", - "make it easier to evaluate the matrices comprised of molecular elements.\n", - "\n", - "It can be useful for view DFT an optimisation problem where we search for the expansion coefficients that minimise the total energy. There are additional constraints such as maintaining orthonormality between the molecular orbitals\n", - "maintaining orthonormality in the molecular orbitals. \n", + "make it easier to evaluate integrals of the form in equation (5). To show this\n", + "we start by expanding the overlap integral into its full three-dimensional form:\n", + "$$\n", + "\\tag{9}\n", + "\\tilde{S}_{\\mu \\nu} = \\iiint p_\\mu(\\br) p_\\nu(\\br) dx dy dz,\n", + "$$\n", + "and observing that a primitive $p_\\mu(\\br)$ can be written as a product of cartesian components:\n", + "$$\n", + "\\tag{10}\n", + "p_\\mu(\\br) = N_\\mu\n", + "\\left(x_A^l e^{-\\alpha_\\mu x_A^2} \\right)\n", + "\\left(y_A^m e^{-\\alpha_\\mu y_A^2} \\right)\n", + "\\left(z_A^n e^{-\\alpha_\\mu z_A^2} \\right),\n", + "$$\n", + "we directly see that we can separate the three-dimensional integral in equation (9) as a\n", + "product of three one-dimensional integrals:\n", + "$$\n", + "\\tag{11}\n", + "\\tilde{S}_{\\mu \\nu} = N_\\mu N_\\nu \\tilde{S}_{\\mu \\nu}^{(x)} \\tilde{S}_{\\mu \\nu}^{(y)} \\tilde{S}_{\\mu \\nu}^{(z)}\n", + "$$\n", + "where we introduce the one-dimensional overlap as\n", + "$$\n", + "\\tag{12}\n", + "\\tilde{S}_{\\mu \\nu}^{(x)} = \\int_{-\\infty}^\\infty \n", + "\\left(x_A^{l_\\mu} e^{-\\alpha_\\mu x_A^2} \\right)\n", + "\\left(x_B^{l_\\nu} e^{-\\alpha_\\nu x_B^2} \\right) dx,\n", + "$$\n", + "and use the same definition for the y and z components.\n", "\n", - "For an overview and derivation we refer the reader to the following review article:\n", + "By convention each primitive is be normalised such that the \"self-overlap\" is one, or in other words the diagonal elements of the overlap matrix\n", + "will be all ones.\n", + "$$\n", + "\\tag{13}\n", + "\\tilde{S}_{\\mu \\mu} = \\int p_\\mu(\\br)^2 d\\br = 1.\n", + "$$\n", + "rearranging a bit:\n", + "$$\n", + "\\tag{14}\n", + "N_\\mu = \\left( \\tilde{S}_{\\mu \\mu}^{(x)} \\tilde{S}_{\\mu \\mu}^{(y)} \\tilde{S}_{\\mu \\mu}^{(z)} \\right)^{-\\frac12}.\n", + "$$\n", + "The one-dimensional self-overlap integral is:\n", + "$$\n", + "\\tag{15}\n", + "\\tilde{S}_{\\mu \\mu}^{(x)} = \\int_{-\\infty}^\\infty x^{2l} e^{-2 \\alpha_\\mu x^2} dx.\n", + "$$\n", + "We've made use of the translation invariance property of the integral over all $x$ when shifting by the constant $X_A$ in equation (13). \n", "\n", - "> Lehtola, S., Blockhuys, F. and Van Alsenoy, C., 2020. An overview of self-consistent field calculations within finite basis sets. Molecules, 25(5), p.1218. [open access](https://doi.org/10.3390/molecules25051218)\n", - "\n" + "These one dimensional integrals have a known analytic solution [see equation 42 of gaussian integral](https://mathworld.wolfram.com/GaussianIntegral.html), but we will lean on [SymPy](https://docs.sympy.org/latest/index.html) to help us derive a formula for normalising our primitive Gaussian functions." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -169,64 +233,21 @@ "init_printing(use_unicode=True)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Primitive GTO\n", - "\n", - "The unnormalized Cartesian GTO (Gaussian-type Orbital) primitive is defined as follows:\n", - "\\begin{align*}\n", - "\\hat p(\\mathbf{r}; l,m,n, \\alpha) =\n", - " p(\\mathbf r; \\nu) = ~ & x^l y^m z^n e^{-\\alpha |\\mathbf{r}|^2} \\\\\n", - "& \\text{where} ~ \\mathbf{r} = (x, y, z) ~ \\text{and} ~ \\nu = (l, m, n, \\alpha)\n", - "\\end{align*}\n", - "\n", - "From which the normalized primitive is\n", - "\\begin{align*}\n", - "p(\\mathbf{r}; \\nu) = & \\frac 1 {Z_\\nu} ~ \\hat p(\\mathbf{r}; \\nu)\n", - "\\end{align*}\n", - "where the normalizing constant $Z_\\nu$ is defined so that\n", - "$$\n", - "\\int_{-\\infty}^\\infty p(\\mathbf r; \\nu)^2 \\mathrm{d}\\mathbf r = 1,\n", - "$$\n", - "that is:\n", - "\\begin{aligned}\n", - "Z_\\nu^2 = \\int \\hat p(\\mathbf{r}; \\nu)^2 d\\mathbf{r}\n", - "\\end{aligned}\n", - "\n", - "So, squaring all terms in the integrand:\n", - "\\begin{aligned}\n", - "Z_\\nu^2 & = \\iiint x^{2l} y^{2m} z^{2n} e^{-2\\alpha (x^2 + y^2 + z^2)} \\text{d}z \\text{d}y \\text{d}x\\\\\n", - " & = \\iiint x^{2l} y^{2m} z^{2n} e^{-2\\alpha x^2}e^{-2\\alpha y^2}e^{-2\\alpha z^2} \\text{d}z \\text{d}y \\text{d}x\\\\\n", - " & = \\iiint x^{2l} e^{-2\\alpha x^2} y^{2m} e^{-2\\alpha y^2} z^{2n} e^{-2\\alpha z^2} \\text{d}z \\text{d}y \\text{d}x\\\\\n", - " & = \\int x^{2l} e^{-2\\alpha x^2} \\int y^{2m} e^{-2\\alpha y^2} \\int z^{2n} e^{-2\\alpha z^2} \\text{d}z \\text{d}y \\text{d}x\\\\\n", - " & = \\int x^{2l} e^{-2\\alpha x^2} \\text{d}x \n", - " \\int y^{2m} e^{-2\\alpha y^2} \\text{d}y\n", - " \\int z^{2n} e^{-2\\alpha z^2} \\text{d}z\\\\\n", - " & = ZZ(l,\\alpha) ZZ(m,\\alpha) ZZ(n,\\alpha)\n", - "\\end{aligned}\n", - "where \n", - "$$\n", - "ZZ(k, a) = \\int_{-\\infty}^{\\infty} t^{2k} e^{- 2 a t^2} dt\n", - "$$\n" - ] - }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "$\\displaystyle ZZ(k,\\alpha) = \\int\\limits_{-\\infty}^{\\infty} t^{2 k} e^{- 2 \\alpha t^{2}}\\, dt = \\left(\\frac{1}{2 \\alpha}\\right)^{k + \\frac{1}{2}} \\Gamma\\left(k + \\frac{1}{2}\\right)$" + "$\\displaystyle \\tilde{S}_{\\mu \\mu} = \\int\\limits_{-\\infty}^{\\infty} t^{2 k} e^{- 2 \\alpha t^{2}}\\, dt = \\left(\\frac{1}{2 \\alpha}\\right)^{k + \\frac{1}{2}} \\Gamma\\left(k + \\frac{1}{2}\\right)$" ], "text/plain": [ "" ] }, - "execution_count": 42, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -236,39 +257,58 @@ "k = Symbol(\"k\", integer=True, nonnegative=True)\n", "t, x, y, z = symbols(\"t x y z\", real=True)\n", "\n", - "ZZ = Integral(t**(2*k) * exp(-2 * a * t**2), (t, -oo, oo))\n", - "IPython.display.Math(r'ZZ(k,\\alpha) = ' + latex(ZZ) + ' = ' + latex(simplify(ZZ.doit())))" + "self_overlap1d = Integral(t**(2*k) * exp(-2 * a * t**2), (t, -oo, oo))\n", + "output = r'\\tilde{S}_{\\mu \\mu} = '\n", + "output += latex(self_overlap1d) \n", + "output += ' = '\n", + "output += latex(simplify(self_overlap.doit()))\n", + "IPython.display.Math(output)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "$\\displaystyle Z^2(l,m,n,\\alpha) = \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 l} e^{- 2 \\alpha t^{2}}\\, dt\\right) \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 m} e^{- 2 \\alpha t^{2}}\\, dt\\right) \\int\\limits_{-\\infty}^{\\infty} t^{2 n} e^{- 2 \\alpha t^{2}}\\, dt \\quad = \\quad \\Large \\left(\\frac{1}{2 \\alpha}\\right)^{L + \\frac{3}{2}} \\Gamma\\left(l + \\frac{1}{2}\\right) \\Gamma\\left(m + \\frac{1}{2}\\right) \\Gamma\\left(n + \\frac{1}{2}\\right)$" + "$\\displaystyle N_\\mu^2 = \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 l} e^{- 2 \\alpha t^{2}}\\, dt\\right) \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 m} e^{- 2 \\alpha t^{2}}\\, dt\\right) \\int\\limits_{-\\infty}^{\\infty} t^{2 n} e^{- 2 \\alpha t^{2}}\\, dt \\quad = \\quad \\Large \\left(\\frac{1}{2 \\alpha}\\right)^{L + \\frac{3}{2}} \\Gamma\\left(l + \\frac{1}{2}\\right) \\Gamma\\left(m + \\frac{1}{2}\\right) \\Gamma\\left(n + \\frac{1}{2}\\right)$" ], "text/plain": [ "" ] }, - "execution_count": 43, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l,m,n,L = symbols(\"l m n L\", integer=True, nonnegative=True)\n", - "Z2 = (ZZ.subs(k, l) * ZZ.subs(k, m) * ZZ.subs(k, n))\n", - "Z2_expanded = simplify(Z2.doit()).subs(l+m+n, L)\n", - "IPython.display.Math(r'Z^2(l,m,n,\\alpha) = ' + latex(Z2) + ' \\quad = \\quad \\Large ' + latex(Z2_expanded))" + "sx = self_overlap1d.subs(k, l)\n", + "sy = self_overlap1d.subs(k, m)\n", + "sz = self_overlap1d.subs(k, n)\n", + "self_overlap = sx * sy * sz\n", + "\n", + "self_overlap_expanded = simplify(self_overlap.doit()).subs(l+m+n, L)\n", + "output = r'N_\\mu^2 = '\n", + "output += latex(self_overlap) \n", + "output += ' \\quad = \\quad \\Large '\n", + "output += latex(self_overlap_expanded)\n", + "IPython.display.Math(output)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can use SymPy to generate a python function that uses the [gamma](https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.gamma.html) function from scipy" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -298,226 +338,101 @@ } ], "source": [ - "f = lambdify((l,m,n, a), Z2_expanded, modules=\"scipy\")\n", + "f = lambdify((l,m,n, a), self_overlap_expanded, modules=\"scipy\")\n", "help(f)" ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$\\displaystyle \\Large{z_{000}= \\frac{\\sqrt[4]{2} \\pi^{\\frac{3}{4}}}{2 \\alpha^{\\frac{3}{4}}}}$" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 45, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ - "z000 = sqrt(Z2).subs(((l,0), (m,0), (n,0))).doit()\n", - "IPython.display.Math(r'\\Large{' + latex(Symbol('z000')) + '= ' + latex(z000) + '}')" + "This implementation isn't quite right since it doesn't correctly substitute that $L=l+m+n$ but this\n", + "is close enough to allow us to return our attention back to the general overlap elements in equation (11). To make progress we start by rewriting the product of two\n", + "Gaussian functions as a single Gaussian:\n", + "$$\n", + "\\tag{16}\n", + "e^{-\\alpha (x - a)^2} e^{-\\beta (x - b)^2} = \n", + "e^{-\\alpha \\beta (a - b)^2 / \\gamma} e^{-\\gamma (x - c)^2}, \\\\\n", + "\\gamma = \\alpha + \\beta \\\\\n", + "c = \\frac{\\alpha a + \\beta b}{\\gamma}\n", + "$$\n", + "Next we rewrite the product of the leading polynomial terms in terms of the Gaussian product center $c$:\n", + "$$\n", + "\\tag{17}\n", + "(x - a)^i (x - b)^j = (x - c + c - a)^i (x - c + c - b)^j = (x_c + c_a)^i (x_c + c_b)^j,\n", + "$$\n", + "where introduce\n", + "$$\n", + "\\tag{18}\n", + "x_c = x - c\\\\\n", + "c_a = c - a\\\\\n", + "c_b = c - b.\n", + "$$\n", + "There isn't a universal term that covers the product of binomial expansions that we have arrived at in equation (17). Nonetheless we can expand these and collect similar powers of $x^k$ to convert this into a summation:\n", + "$$\n", + "(x_c + c_a)^i (x_c + c_b)^j = \\sum_k B(i, j, c_a, c_b, k) x^k\n", + "$$\n", + "These rewrites are used by [Fermann and Valeev](http://arxiv.org/abs/2007.12057) to introduce what they name the Gaussian product theorem. This can then be used to convert an integral over two primitives into a sum over terms that can be evaluated analytically.\n", + "\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 44, "metadata": {}, "outputs": [ { "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIoAAAAVCAYAAACZt3byAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAFkElEQVR4nO3abYycVRUH8F+BCkTUak2EWNSC2ghCNzSNfgCDAjbqB3z7oCbVKhqCQYz4Rg14PIgoQnRTFQkRaCEmimA08oH2AxjfItjKAlWpaCzWUAMqwSA2CF0/3Dvy9NnZmdndma1s+k8md+bce8895z/nuffcM7NocnLSARRk5vPxn4h4bH/b8v+CzFyCpxYdCJQDGASHdBNm5ia8Ccsj4l/za9JokJmrsBUfiohvdelfhl14VUTc1+qblo/MPAdX4qyIuHZU9o8CA3CyBI9g9UFdOldjLb60UIIEImIbfoDPZ+YRXYasxOP4fVM4AB+rartteNbODwbgZAxPYvuUQMEX8E98c1QG7kd8EUfivC59Y7g3Iva25P34WIU9+M2QbJxv9ONkR0Ts2SdQMvOVOB03RsS/R21hZq7LzMnMPHXUa0FE3In7cHZmth+SlZho2deTj8w8FMfjnoh4clh2zicvfTgZUzlp5ygfwCJ8t5vSzHwP3oLVOErZlv6AKyPiuiHZPjAycwvOwDsj4uaGfBGuw/twWURc0Jj2HXyuztvckI/hK60levKBE7AY2zJzDBfhVByGn+P8iNg+c89mjyFzshLfhnYEnY6n8MsuBjwH1+MY/BRfx/exHNdm5qdn796s8UnsVc7YgxvyKxRCrm4RQvkCKaSAzHw2jtXaUfTgo6KTn7y06p3ENfh11X9bTQjnE8PiZDGO095RKllj+N00SdsklkXEX5vCzLxQSQDfj8tm6tVcEBF3Z+YNCgFrsTEzP4PzcSPO6TLtV7V9XUN2Ym3v6QgG4ANOqu1rcHJE3NWYf3216cO4dAZuzQlD5OQ4PEsNlOaO8mIcjN3TGPBYO0iqfDcexA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{000}\\\\z_{100}= \\frac{z_{000}}{2 \\sqrt{\\alpha}}\\\\z_{010}= \\frac{z_{000}}{2 \\sqrt{\\alpha}}\\\\z_{001}= \\frac{z_{000}}{2 \\sqrt{\\alpha}}\\\\z_{110}= \\frac{z_{000}}{4 \\alpha}\\\\z_{101}= \\frac{z_{000}}{4 \\alpha}\\\\z_{011}= \\frac{z_{000}}{4 \\alpha}\\\\z_{111}= \\frac{z_{000}}{8 \\alpha^{\\frac{3}{2}}}\\\\z_{200}= \\frac{\\sqrt{3} z_{000}}{4 \\alpha}\\\\z_{220}= \\frac{3 z_{000}}{16 \\alpha^{2}}\\end{align*}" + "$\\displaystyle \\left(a + x\\right)^{i} \\left(b + x\\right)^{j}$" ], "text/plain": [ - "" + " i j\n", + "(a + x) ⋅(b + x) " ] }, - "execution_count": 55, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "out= r'\\begin{align*}~'\n", - "for vl,vm,vn in ((0,0,0),(1,0,0),(0,1,0),(0,0,1),(1,1,0),(1,0,1),(0,1,1),(1,1,1),(2,0,0),(2,2,0)):\n", - " zllm = sqrt(Z2).subs(((l,vl), (m,vm), (n,vn))).doit() / z000 * Symbol('z_000')\n", - " out += r'\\\\' + latex(Symbol(f'z{vl}{vm}{vn}')) + '= ' + latex(zllm)\n", - "out += r'\\end{align*}'\n", - "IPython.display.Latex(out)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# From factorial" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1.0 1.0\n", - "1.0 1.0\n", - "3.0000000000000004 3.0\n", - "15.000000000000004 15.0\n", - "135135.00000000003 135135.0\n", - "316234143225.00006 316234143225.0\n" - ] - } - ], - "source": [ - "import scipy\n", - "p = Symbol('p', integer=True)\n", - "\n", - "# n!! = special.gamma(n/2+1)*2**((m+1)/2)/sqrt(pi) n odd\n", - "# = 2**(n/2) * (n/2)! n even\n", - "\n", - "def fac2(n):\n", - " assert n % 2 == 1\n", - " return gamma(n/2+1)*2**((n+1)/2)/sqrt(pi) # n odd\n", - "\n", - "\n", - "for n in (-1,1,3,5,13,23):\n", - " v1 = scipy.special.factorial2(n)\n", - " v2 = float(fac2(n).evalf())\n", - " print(v1, v2)\n", - " assert np.isclose(v1, v2)\n" + "x, a, b = symbols(\"x, a, b\", real=True)\n", + "i, j = symbols(\"i, j\", nonnegative=True, integers=True)\n", + "poly_terms = (x + a)**i * (x + b) **j\n", + "poly_terms" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 62, "metadata": {}, "outputs": [ { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAcAAAAAVCAYAAADRoT5bAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAABJ0AAASdAHeZh94AAALQ0lEQVR4nO2df7BVVRXHP09UIDBTHLWUHxIpKvYuvGxsGlEDLNLSZzo4YyQ2lUORv8IxmWyx1MxGDLQpqcERnJE0gn6pUDAqaigGSagpmQiYP1PMQFMR6Y+1D5537jn3nnvPvvfcK+c7wxzePvvstc/6sfdea699bseOHTvYVaGqS4BHROTivPvSLlDV0cBUoAv4CHCOiMyt8sx0QCLFL4rIgY3oY4ECBQqkwW55dyBnlICHq1VS1bluEG8qmkW3Rjr9gUeB84H/1UBmHfDh0L+jauljgQIFCvjG7nGFqjoPGA8cIiKvN7dLfqCqXcAq4OsiMifm/oHAAcAajzQPBp4BzgTOBY4BngQmYBPHj4FPYBPI6SKyqQG0TwUmA8cCLwBfE5G7fdERkTuBOx3NuTU8+o6IvOCrH2FU0ldVvRDj+1kiMr8R9FsF1XQ+Q7ttPx7kiUIu+aIS/8smQFU9GpgITA0zVVVPB47DvKZOYC/gFhH5cooOHAA8B/wMmA50AydhXsBBwNvAI8BNwE0i8m6tLxmFiKxW1d8C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1wemqVegXaGD70NS80wE6G4Fnn25m/WeBZNkMo5JIazbSLshBogQIFChQosCvg/4NessAgH0GVAAAAAElFTkSuQmCC", - "text/latex": [ - "$\\displaystyle \\left(\\frac{1}{2 \\alpha}\\right)^{l + m + n + 1.5} \\Gamma\\left(l + \\frac{1}{2}\\right) \\Gamma\\left(m + \\frac{1}{2}\\right) \\Gamma\\left(n + \\frac{1}{2}\\right)$" - ], - "text/plain": [ - " l + m + n + 1.5 \n", - "⎛ 1 ⎞ \n", - "⎜───⎟ ⋅Γ(l + 1/2)⋅Γ(m + 1/2)⋅Γ(n + 1/2)\n", - "⎝2⋅α⎠ " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAAVCAYAAAC3+8IMAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAABJ0AAASdAHeZh94AAAKdUlEQVR4nO2de7BXVRXHPxdQYITwUaMzTvGIKA3ieq82mIqYoJEPuKZjk5FUU46PSCYcw7LFMjXKSa42hjU4gpPkYzAqEUseIgIpUISa5PgAjUjikYGPQKA/1j73nnvuOed3zu93fr9zf3C+M3fOvfu5zlpr77X3Xmuf23DgwAEKFChQoECBOPTIm4A8oaqLgc0i8pUqtX81cAUwwCW9ANwsIgtCyt4NvAe8CVwEfBz4H/AnYKqIPF8NGgsUKFAgCbrlTUDOaALWpqmgqrNVdVrC4v8Arnf9nAwsAear6qcCbTYAFwLzgVHAz4HPAJ8F3gcWqerRaegsUKBAgSwRurNQ1TnAWGCgiLxdW5Kygao2A2uAb4jIrJD8jwJHktJYpIGI/DaQ9D1VvRI4FVjvSz8F6Ak8LSLnBuicALwFnAb8vlKaomSrqpOB24HLRGRupf10dZTSjwrarfuxkycKueSLOP53MhaqegowAZgSmEwuBs4EGoHhQF/gfhH5cgICjgX+ia2Ypw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2x3eCyuDtfefPe9VcT/vt9FluAf2MhqVlgJCak0G2Rql6PEb8Oi/qJIr43NmDCYq1nYJFFUR59sPdpoEY3tbso4mRbT87trHTKjyz0o9TY8SalNSF5zTF53nl6V5dNvcrF428U7xuojwjBmvC/zVg46/kU8EF3UaxStGATfPD7SKjqjZiTZS1m5bbFtLMTu8k4WH0f4FP7xtKF7s8jY+qPcM80F1sOKpSQbRP2ddsXak5YemSlU35UrB8Jxk4TdkQQ9uXguJ2FZ2S6urGod7msD8mrp0VUTfgfvGcxD7vVdy7tF8m8Tsdj4ZxgUT4Ap6rqbPf7NhGZ4so2uLKrgsdDqno5FrW0D4tumhTiBNooIrPBBO76uAb7+urDrv8WjDn9gFHuksk9IrI60NY5rq9OjDzE0Em2LjRzKPDX4Hl5rZBUr7LUqQCy0o/QsaOqPbGw7vUuuimIZmBThAM7tyi1Qi6xRryqyGuuDaAT/8OMxVYsBveuQF4jcHkgbRDtEQObaA/vPBn4MOb8CWKge3bHLtSFYRkw2/f3ddjq91Lgm9huYwbwXWy7eB/2fyM63ERU1X4YIx+NiZQ6VBAm22HAYeS7emokmV5lrVNZ60fU2BmK8TjsXLw/dnywLCSvJxaltrZUlFqV0MjBL5cehB9BgRmLPL6VBvnOtZH8bwj+pzxVnYpFFjWJyF8iOoiFqt6KhaYOEpHcHMuq+i3ssxxniEipiJKDHlnINi9UQ6ey1o965m+5KOSSL2rJ/7B/fjQDu1Ha6YJbCrRgRxt5GoreGBPnFYaiDVnINi9kqlNV0o965m+5KOSSL2rG/07Gwt3+mwCscZeJUkNEThCRxnLqZogBwC+p7ObzQYUsZJsXqqBTA8hYP+qZv+WikEu+qCX//w8lQz8AqrJJcgAAAABJRU5ErkJggg==", "text/latex": [ - "$\\displaystyle \\left(\\frac{1}{2 \\alpha}\\right)^{L + \\frac{3}{2}} \\Gamma\\left(l + \\frac{1}{2}\\right) \\Gamma\\left(m + \\frac{1}{2}\\right) \\Gamma\\left(n + \\frac{1}{2}\\right)$" + "$\\displaystyle (a + x)^0 (b + x)^0 = \\left[ 1\\right]\\\\(a + x)^0 (b + x)^1 = \\left[ b, \\ 1\\right]\\\\(a + x)^0 (b + x)^2 = \\left[ b^{2}, \\ 2 b, \\ 1\\right]\\\\(a + x)^1 (b + x)^0 = \\left[ a, \\ 1\\right]\\\\(a + x)^1 (b + x)^1 = \\left[ a b, \\ a + b, \\ 1\\right]\\\\(a + x)^1 (b + x)^2 = \\left[ a b^{2}, \\ 2 a b + b^{2}, \\ a + 2 b, \\ 1\\right]\\\\(a + x)^2 (b + x)^0 = \\left[ a^{2}, \\ 2 a, \\ 1\\right]\\\\(a + x)^2 (b + x)^1 = \\left[ a^{2} b, \\ a^{2} + 2 a b, \\ 2 a + b, \\ 1\\right]\\\\(a + x)^2 (b + x)^2 = \\left[ a^{2} b^{2}, \\ 2 a^{2} b + 2 a b^{2}, \\ a^{2} + 4 a b + b^{2}, \\ 2 a + 2 b, \\ 1\\right]\\\\$" ], "text/plain": [ - " L + 3/2 \n", - "⎛ 1 ⎞ \n", - "⎜───⎟ ⋅Γ(l + 1/2)⋅Γ(m + 1/2)⋅Γ(n + 1/2)\n", - "⎝2⋅α⎠ " + "" ] }, + "execution_count": 62, "metadata": {}, - "output_type": "display_data" + "output_type": "execute_result" } ], "source": [ - "l,m,n = symbols(\"l m n\", integer=True, nonnegative=True)\n", - "alpha = Symbol(\"alpha\", positive=True, real=True)\n", + "from itertools import product\n", + "output = \"\"\n", + "for ival, jval in product(range(3), range(3)):\n", + " p = simplify(expand(poly_terms.subs(i, ival).subs(j, jval)))\n", + " output += f\"(a + x)^{ival} (b + x)^{jval} = \" \n", + " output += latex([p.coeff(x, n) for n in range(ival + jval + 1)])\n", + " output += r\"\\\\\"\n", "\n", - "def current_squared(l,m,n):\n", - " L = l+m+n\n", - " N = pi**1.5 / (2 * alpha) ** (L + 1.5)\n", - " N *= fac2(2*l-1) * fac2(2*m-1) * fac2(2*n-1) / 2**L\n", - " return N\n", - "\n", - "def gammabased(l,m,n):\n", - " def fac2pm1(p):\n", - " return fac2(2*p-1)\n", - " \n", - " L = l+m+n\n", - " N = pi**1.5 / (2 * alpha) ** (L + 1.5)\n", - " N *= fac2pm1(l) * fac2pm1(m) * fac2pm1(n) / 2**L\n", - " return N\n", - "\n", - "\n", - "display(current_squared(l,m,n).simplify(), Z2_expanded)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Next steps" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And now, evaluate over the range $(0,1)$ rather than $(-\\infty,\\infty)$:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIcAAAAoCAYAAADUrekxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAABJ0AAASdAHeZh94AAAHqElEQVR4nO2cf5BVZRnHPytY/lgaxyGgGKoxlYGx2Ni0GSGECjRTY8gZwwkLpEYslBxIMfXrV1HBQpdxdEomJYlqMqwBlWLUSItSskC3JmKoCC0IxDJHS4Xtj+ddOHvZu/fu7rl7uXK/M2fec877vud57nuf8/x8721oa2sjL9geB8wFmoF3AtMlLcuNQB19iiNyfl4j0ApcDrya87Pr6GM05Kk5srD9MvCluuaoXeStOep4E6EuHHUURdnCYbvBdr9KMlPHoYX+pQbYPgoQcAlwpO27gPmS9laaucMRtocBy4FBwBvAjZLurwYv5WiOpcBVwHHAscA84MoK8nS44w1gjqSRwCSgxfax1WCky2jF9iBgB9AAXJbOfwA8J2lYJ+MbgRPT5XpgIbAK2CPpb/myfhDthUCzpImVpNPXsL0JOEfS9r6mXcqsNBGCAbAC+DfwMLDL9jGSXikY/0HgZ5lrp+PbwOd6yqTt+cAUYDjwP+DXhGlrLeB1Y09pHIqw3Qz0q4ZgQGnhGJja/0rak84/UWywpHUcEKY8M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2}}\\, dx$" - ], - "text/plain": [ - "1 \n", - "⌠ \n", - "⎮ 2 \n", - "⎮ 2⋅k -α⋅x \n", - "⎮ x ⋅ℯ dx\n", - "⌡ \n", - "0 " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAANMAAAAXCAYAAACRfnp7AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAABJ0AAASdAHeZh94AAAIpUlEQVR4nO2be7BXVRXHPzx8UJqSlUyWDQyBMiFXHiGJmCljTgRcErXgKtUUk5KPBAkrv61KYypeOiQq5sUIH4X5ArF8IIKWyKORwcuAgmiZyGMsfBVw+2PtH57OPb/XOb97L1x/35k75/722Xutvc/Za6+1vnufdo2NjbQkzGwJ8JykSc2oYwgwEegHfBz4uqT6PHXnAO8ArwGjgJ7Au8BfgCmS1jVXP6toW2jfCjprgDXNrOMIYB1wGfB2vkpm1g4YDtwLfB74NfA54AvAHuARM/twM/e1ijaCji2pzMy6AMcCa8PvDwK3Aj2AUZK2VEKPpMXA4qCjvkDVAcBhwHJJZ8f6Wge8AZwKPJC1T2Y2DzgH6Crpzdi9K4DpwBhJC7LqqqIpzKwf8CzwLUlzm0NHixoT7pXeBjaYWU/gHtxLnSoprwdpRowEFknak3DvSNxz78qqxMwGAHXAxLghBfQL12ez6soKMzsXOB1/V33w5/A7SWNLaHss8A/cw/8YqAW+BPQGjgP+AzwH3AbcJmlf5UeQDEmrzOxe4Kdmdqek3fnqph1HS4d5NaETI4GngFskjW0lQwIYgYd4SZiFe9CnK6DnWuBfwI157vcN9zdWQFdW/BCYgL+rv5fZdgQ+p+4BRgO3AAOBvwIzgYXAZ4C5wN0hzG5J/BzoAlxapF6qcWT2TGb2M+AHRaqdIWkp/oI+DfwGGC7piQrJLRtm1h3oBjyccG86MBgYLGlvGvkRWT2As4C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2Ih4W1qtCH6HG0dIfB7YVnByuJYdskpbhzF4VrQBJz+OnxZsNVc9URRUVQjVnqqKKCuF/hg/HHMc7Mw0AAAAASUVORK5CYII=", - "text/latex": [ - "$\\displaystyle \\frac{\\alpha^{- k - \\frac{1}{2}} \\gamma\\left(k + \\frac{1}{2}, \\alpha\\right)}{2}$" - ], - "text/plain": [ - " -k - 1/2 \n", - "α ⋅γ(k + 1/2, α)\n", - "───────────────────────\n", - " 2 " - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "ZZ01 = Integral(x ** (2 * k) * exp(-a * x**2), (x, 0, 1))\n", - "ZZ01_expanded = simplify(ZZ01.doit())\n", - "display(ZZ01, ZZ01_expanded)" + "IPython.display.Math(output)\n" ] } ], From 52a28d11ef210c1cb94d78c9deb77137b6d2871c Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Thu, 12 Oct 2023 08:38:15 +0000 Subject: [PATCH 06/14] update --- notebooks/gto_integrals.ipynb | 108 ++++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 39 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index 56bc4d6..5f12e60 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -7,8 +7,8 @@ "*Copyright (c) 2023 Graphcore Ltd. All rights reserved.*\n", "\n", "$$\n", - "\\renewcommand{\\br}{\\mathbf{r}}\n", - "\\renewcommand{\\bA}{\\mathbf{A}}\n", + "\\def\\br{\\mathbf{r}}\n", + "\\def\\bA{\\mathbf{A}}\n", "$$\n", "\n", "# Integrals over Gaussian Type Orbitals (GTO)\n", @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -59,7 +59,7 @@ "5" ] }, - "execution_count": 6, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } @@ -136,6 +136,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "$$\n", + "\\def\\br{\\mathbf{r}}\n", + "\\def\\bA{\\mathbf{A}}\n", + "$$\n", + "\n", "The above visualisation uses the formulas defined earlier to numerically evaluate\n", "each atomic orbital from a linear combintation of primitive Gaussians. Introducing\n", "the basis set allows us to replace the problem of solving a system partial differential equations (e.g. the Kohn-Sham equations) with an algebraic system of equations that can be solved using standard matrix eigenvalue techniques.\n", @@ -215,14 +220,14 @@ "\\tag{15}\n", "\\tilde{S}_{\\mu \\mu}^{(x)} = \\int_{-\\infty}^\\infty x^{2l} e^{-2 \\alpha_\\mu x^2} dx.\n", "$$\n", - "We've made use of the translation invariance property of the integral over all $x$ when shifting by the constant $X_A$ in equation (13). \n", + "We've made use of the translation invariance property of the integral over all $x$ when shifting by the constant $X_A$ in equation (15). \n", "\n", "These one dimensional integrals have a known analytic solution [see equation 42 of gaussian integral](https://mathworld.wolfram.com/GaussianIntegral.html), but we will lean on [SymPy](https://docs.sympy.org/latest/index.html) to help us derive a formula for normalising our primitive Gaussian functions." ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -235,25 +240,25 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "$\\displaystyle \\tilde{S}_{\\mu \\mu} = \\int\\limits_{-\\infty}^{\\infty} t^{2 k} e^{- 2 \\alpha t^{2}}\\, dt = \\left(\\frac{1}{2 \\alpha}\\right)^{k + \\frac{1}{2}} \\Gamma\\left(k + \\frac{1}{2}\\right)$" + "$\\displaystyle \\tilde{S}_{\\mu \\mu} = \\int\\limits_{-\\infty}^{\\infty} t^{2 k} e^{- 2 \\alpha_{\\mu} t^{2}}\\, dt = \\left(\\frac{1}{2 \\alpha_{\\mu}}\\right)^{k + \\frac{1}{2}} \\Gamma\\left(k + \\frac{1}{2}\\right)$" ], "text/plain": [ "" ] }, - "execution_count": 13, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "a = Symbol(\"alpha\", positive=True, real=True)\n", + "a = Symbol(\"alpha_mu\", positive=True, real=True)\n", "k = Symbol(\"k\", integer=True, nonnegative=True)\n", "t, x, y, z = symbols(\"t x y z\", real=True)\n", "\n", @@ -261,25 +266,25 @@ "output = r'\\tilde{S}_{\\mu \\mu} = '\n", "output += latex(self_overlap1d) \n", "output += ' = '\n", - "output += latex(simplify(self_overlap.doit()))\n", + "output += latex(simplify(self_overlap1d.doit()))\n", "IPython.display.Math(output)" ] }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "$\\displaystyle N_\\mu^2 = \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 l} e^{- 2 \\alpha t^{2}}\\, dt\\right) \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 m} e^{- 2 \\alpha t^{2}}\\, dt\\right) \\int\\limits_{-\\infty}^{\\infty} t^{2 n} e^{- 2 \\alpha t^{2}}\\, dt \\quad = \\quad \\Large \\left(\\frac{1}{2 \\alpha}\\right)^{L + \\frac{3}{2}} \\Gamma\\left(l + \\frac{1}{2}\\right) \\Gamma\\left(m + \\frac{1}{2}\\right) \\Gamma\\left(n + \\frac{1}{2}\\right)$" + "$\\displaystyle N_\\mu^2 = \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 l} e^{- 2 \\alpha_{\\mu} t^{2}}\\, dt\\right) \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 m} e^{- 2 \\alpha_{\\mu} t^{2}}\\, dt\\right) \\int\\limits_{-\\infty}^{\\infty} t^{2 n} e^{- 2 \\alpha_{\\mu} t^{2}}\\, dt \\quad = \\quad \\Large \\left(\\frac{1}{2 \\alpha_{\\mu}}\\right)^{L + \\frac{3}{2}} \\Gamma\\left(l + \\frac{1}{2}\\right) \\Gamma\\left(m + \\frac{1}{2}\\right) \\Gamma\\left(n + \\frac{1}{2}\\right)$" ], "text/plain": [ "" ] }, - "execution_count": 25, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -308,7 +313,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -317,19 +322,19 @@ "text": [ "Help on function _lambdifygenerated:\n", "\n", - "_lambdifygenerated(l, m, n, alpha)\n", + "_lambdifygenerated(l, m, n, alpha_mu)\n", " Created with lambdify. Signature:\n", " \n", - " func(l, m, n, alpha)\n", + " func(l, m, n, alpha_mu)\n", " \n", " Expression:\n", " \n", - " (1/(2*alpha))**(L + 3/2)*gamma(l + 1/2)*gamma(m + 1/2)*gamma(n + 1/2)\n", + " (1/(2*alpha_mu))**(L + 3/2)*gamma(l + 1/2)*gamma(m + 1/2)*gamma(n + 1/2)\n", " \n", " Source code:\n", " \n", - " def _lambdifygenerated(l, m, n, alpha):\n", - " return ((1/2)/alpha)**(L + 3/2)*gamma(l + 1/2)*gamma(m + 1/2)*gamma(n + 1/2)\n", + " def _lambdifygenerated(l, m, n, alpha_mu):\n", + " return ((1/2)/alpha_mu)**(L + 3/2)*gamma(l + 1/2)*gamma(m + 1/2)*gamma(n + 1/2)\n", " \n", " \n", " Imported modules:\n", @@ -368,37 +373,39 @@ "c_a = c - a\\\\\n", "c_b = c - b.\n", "$$\n", - "There isn't a universal term that covers the product of binomial expansions that we have arrived at in equation (17). Nonetheless we can expand these and collect similar powers of $x^k$ to convert this into a summation:\n", + "There isn't a universal term that covers the product of binomial expansions that we have arrived at in equation (17),\n", + "and using the [binomial theorem](https://en.wikipedia.org/wiki/Binomial_theorem) we have:\n", "$$\n", - "(x_c + c_a)^i (x_c + c_b)^j = \\sum_k B(i, j, c_a, c_b, k) x^k\n", + "\\tag{19}\n", + "(x_c + c_a)^i = \\sum_{k=0}^i \\binom{i}{k} x_c^{i-k} c_a^k \\\\ \n", + "(x_c + c_b)^j = \\sum_{l=0}^j \\binom{j}{l} x_c^{j-l} c_b^l \n", "$$\n", - "These rewrites are used by [Fermann and Valeev](http://arxiv.org/abs/2007.12057) to introduce what they name the Gaussian product theorem. This can then be used to convert an integral over two primitives into a sum over terms that can be evaluated analytically.\n", - "\n" + "we can use SymPy to help us take the product of these expansions some values of $i$ and $j$" ] }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 8, "metadata": {}, "outputs": [ { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIoAAAAVCAYAAACZt3byAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAFkElEQVR4nO3abYycVRUH8F+BCkTUak2EWNSC2ghCNzSNfgCDAjbqB3z7oCbVKhqCQYz4Rg14PIgoQnRTFQkRaCEmimA08oH2AxjfItjKAlWpaCzWUAMqwSA2CF0/3Dvy9NnZmdndma1s+k8md+bce8895z/nuffcM7NocnLSARRk5vPxn4h4bH/b8v+CzFyCpxYdCJQDGASHdBNm5ia8Ccsj4l/za9JokJmrsBUfiohvdelfhl14VUTc1+qblo/MPAdX4qyIuHZU9o8CA3CyBI9g9UFdOldjLb60UIIEImIbfoDPZ+YRXYasxOP4fVM4AB+rartteNbODwbgZAxPYvuUQMEX8E98c1QG7kd8EUfivC59Y7g3Iva25P34WIU9+M2QbJxv9ONkR0Ts2SdQMvOVOB03RsS/R21hZq7LzMnMPHXUa0FE3In7cHZmth+SlZho2deTj8w8FMfjnoh4clh2zicvfTgZUzlp5ygfwCJ8t5vSzHwP3oLVOErZlv6AKyPiuiHZPjAycwvOwDsj4uaGfBGuw/twWURc0Jj2HXyuztvckI/hK60levKBE7AY2zJzDBfhVByGn+P8iNg+c89mjyFzshLfhnYEnY6n8MsuBjwH1+MY/BRfx/exHNdm5qdn796s8UnsVc7YgxvyKxRCrm4RQvkCKaSAzHw2jtXaUfTgo6KTn7y06p3ENfh11X9bTQjnE8PiZDGO095RKllj+N00SdsklkXEX5vCzLxQSQDfj8tm6tVcEBF3Z+YNCgFrs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QkwlNQKGp/DTwEeqlfeuwaqOdMewbmkpbZbgTG2Ny34DuZPhIE53vZCwh3gVOB3+rACDKDeImyrM23PIOwGo4F3JC2IdXYD7qP4St8fnhAe5a4EJtjuJIQK0whPe8YXbGsgVXOmNf1ZS5zxdxGeGS8lvE2zDBgpaXTNLlQH2R5FiKsPYFXo0irpuzXs1/mETMpUQiy7NfAscEFyk9OoqjXT5m+wmlprlBezNtVUQ+pfoF49jfOndtwAAAAASUVORK5CYII=", "text/latex": [ - "$\\displaystyle \\left(a + x\\right)^{i} \\left(b + x\\right)^{j}$" + "$\\displaystyle \\left(c_{a} + x_{c}\\right)^{i} \\left(c_{b} + x_{c}\\right)^{j}$" ], "text/plain": [ - " i j\n", - "(a + x) ⋅(b + x) " + " i j\n", + "(cₐ + x_c) ⋅(c_b + x_c) " ] }, - "execution_count": 44, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "x, a, b = symbols(\"x, a, b\", real=True)\n", + "x, a, b = symbols(\"x_c, c_a, c_b\", real=True)\n", "i, j = symbols(\"i, j\", nonnegative=True, integers=True)\n", "poly_terms = (x + a)**i * (x + b) **j\n", "poly_terms" @@ -406,33 +413,56 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "$\\displaystyle (a + x)^0 (b + x)^0 = \\left[ 1\\right]\\\\(a + x)^0 (b + x)^1 = \\left[ b, \\ 1\\right]\\\\(a + x)^0 (b + x)^2 = \\left[ b^{2}, \\ 2 b, \\ 1\\right]\\\\(a + x)^1 (b + x)^0 = \\left[ a, \\ 1\\right]\\\\(a + x)^1 (b + x)^1 = \\left[ a b, \\ a + b, \\ 1\\right]\\\\(a + x)^1 (b + x)^2 = \\left[ a b^{2}, \\ 2 a b + b^{2}, \\ a + 2 b, \\ 1\\right]\\\\(a + x)^2 (b + x)^0 = \\left[ a^{2}, \\ 2 a, \\ 1\\right]\\\\(a + x)^2 (b + x)^1 = \\left[ a^{2} b, \\ a^{2} + 2 a b, \\ 2 a + b, \\ 1\\right]\\\\(a + x)^2 (b + x)^2 = \\left[ a^{2} b^{2}, \\ 2 a^{2} b + 2 a b^{2}, \\ a^{2} + 4 a b + b^{2}, \\ 2 a + 2 b, \\ 1\\right]\\\\$" + "\\begin{align*}(a + x)^0 (b + x)^0 &= 1\\\\(a + x)^0 (b + x)^1 &= c_{b} + x_{c}\\\\(a + x)^0 (b + x)^2 &= c_{b}^{2} + 2 c_{b} x_{c} + x_{c}^{2}\\\\(a + x)^1 (b + x)^0 &= c_{a} + x_{c}\\\\(a + x)^1 (b + x)^1 &= c_{a} c_{b} + x_{c} \\left(c_{a} + c_{b}\\right) + x_{c}^{2}\\\\(a + x)^1 (b + x)^2 &= c_{a} c_{b}^{2} + x_{c} \\left(2 c_{a} c_{b} + c_{b}^{2}\\right) + x_{c}^{2} \\left(c_{a} + 2 c_{b}\\right) + x_{c}^{3}\\\\(a + x)^2 (b + x)^0 &= c_{a}^{2} + 2 c_{a} x_{c} + x_{c}^{2}\\\\(a + x)^2 (b + x)^1 &= c_{a}^{2} c_{b} + x_{c} \\left(c_{a}^{2} + 2 c_{a} c_{b}\\right) + x_{c}^{2} \\cdot \\left(2 c_{a} + c_{b}\\right) + x_{c}^{3}\\\\(a + x)^2 (b + x)^2 &= c_{a}^{2} c_{b}^{2} + x_{c} \\left(2 c_{a}^{2} c_{b} + 2 c_{a} c_{b}^{2}\\right) + x_{c}^{2} \\left(c_{a}^{2} + 4 c_{a} c_{b} + c_{b}^{2}\\right) + x_{c}^{3} \\cdot \\left(2 c_{a} + 2 c_{b}\\right) + x_{c}^{4}\\\\\\end{align*}" ], "text/plain": [ - "" + "" ] }, - "execution_count": 62, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from itertools import product\n", - "output = \"\"\n", + "\n", + "\n", + "# output monomial terms with ascending orders x^n, n=0, 1, 2, ...\n", + "output = r\"\\begin{align*}\"\n", "for ival, jval in product(range(3), range(3)):\n", " p = simplify(expand(poly_terms.subs(i, ival).subs(j, jval)))\n", - " output += f\"(a + x)^{ival} (b + x)^{jval} = \" \n", - " output += latex([p.coeff(x, n) for n in range(ival + jval + 1)])\n", + " output += f\"(a + x)^{ival} (b + x)^{jval} &= \"\n", + " output += \" + \".join(\n", + " [latex(p.coeff(x, n) * x**n) for n in range(ival + jval + 1)]\n", + " )\n", " output += r\"\\\\\"\n", "\n", - "IPython.display.Math(output)\n" + "output += r\"\\end{align*}\"\n", + "IPython.display.Latex(output)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "From expanding the product of binomial expansions we see that we end up with a series\n", + "$$\n", + "\\tag{20}\n", + "(x_c + c_a)^i (x_c + c_b)^j = \\sum_{s = 0}^{i+j} B(i, j, c_a, c_b, s) x^s,\n", + "$$\n", + "where we introduce $B(i, j, c_a, c_b, s)$ as the coefficient of $x^s$ in the expansion. These coefficients can be\n", + "computed from the summation:\n", + "$$\n", + "\\tag{21}\n", + "B(i, j, c_a, c_b, s) = \\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \\binom{i}{s-t} \\binom{j}{t} c_a^{i - (s - t)} c_b^{j-t}\n", + "$$" ] } ], From 50b13a87197ca1df84870ac4d241bd8d3312519e Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Thu, 12 Oct 2023 13:20:22 +0000 Subject: [PATCH 07/14] show your work --- notebooks/gto_integrals.ipynb | 37 ++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index 5f12e60..805918a 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -380,7 +380,12 @@ "(x_c + c_a)^i = \\sum_{k=0}^i \\binom{i}{k} x_c^{i-k} c_a^k \\\\ \n", "(x_c + c_b)^j = \\sum_{l=0}^j \\binom{j}{l} x_c^{j-l} c_b^l \n", "$$\n", - "we can use SymPy to help us take the product of these expansions some values of $i$ and $j$" + "\n", + "$$\n", + "\\tag{20}\n", + "(x_c + c_a)^i (x_c + c_b)^j = \\sum_{k=0}^i \\sum_{l=0}^j \\binom{i}{k} \\binom{j}{l} x_c^{i-k} x_c^{j-l} c_a^k c_b^l \n", + "$$\n", + "we can use SymPy to help us take the product of these expansions for some representative values of $i$ and $j$" ] }, { @@ -452,17 +457,35 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "From expanding the product of binomial expansions we see that we end up with a series\n", + "By using the symmetry properties of the binomial expansion we can rewrite the terms in the series of Equation (20) as:\n", "$$\n", - "\\tag{20}\n", + "\\tag{21}\n", + "\\binom{i}{k} \\binom{j}{l} x_c^{i-k} x_c^{j-l} c_a^k c_b^l = \\binom{i}{k} \\binom{j}{l} x_c^k x_c^l c_a^{i-k} c_b^{j-l}.\n", + "$$\n", + "Recognising that we want to collect terms of same power $x_c^s$ we introduce the constraint that $k+l=s$ allows us to\n", + "write the terms as:\n", + "$$\n", + "\\tag{22}\n", + "\\binom{i}{s-l} \\binom{j}{l} x_c^s c_a^{i-(s-l)} c_b^{j-l}.\n", + "$$\n", + "Replacing the summation variable $l=0, 1,\\cdots, j$ with $t$ and incorporating the constraint we arrive at:\n", + "$$\n", + "(x_c + c_a)^i (x_c + c_b)^j = \n", + "\\sum_{s = 0}^{i+j} x^s \n", + "\\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \n", + "\\binom{i}{s-t} \\binom{j}{t} c_a^{i-(s-t)} c_b^{j-t},\n", + "$$\n", + "Finally we can write this series as:\n", + "$$\n", + "\\tag{22}\n", "(x_c + c_a)^i (x_c + c_b)^j = \\sum_{s = 0}^{i+j} B(i, j, c_a, c_b, s) x^s,\n", "$$\n", - "where we introduce $B(i, j, c_a, c_b, s)$ as the coefficient of $x^s$ in the expansion. These coefficients can be\n", - "computed from the summation:\n", + "where we introduce $B(i, j, c_a, c_b, s)$ as the coefficient of $x^s$ in the expansion:\n", "$$\n", - "\\tag{21}\n", + "\\tag{23}\n", "B(i, j, c_a, c_b, s) = \\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \\binom{i}{s-t} \\binom{j}{t} c_a^{i - (s - t)} c_b^{j-t}\n", - "$$" + "$$\n", + "An evaluation strategy for this variable-sized loop is explored in an accompanying [notebook](./binom_factor_table.ipynb)." ] } ], From dd4e46aaf583640efb65f3811e4c401cfd3e44da Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Thu, 12 Oct 2023 13:35:42 +0000 Subject: [PATCH 08/14] fix eq num --- notebooks/gto_integrals.ipynb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index 805918a..a624bb8 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -470,6 +470,7 @@ "$$\n", "Replacing the summation variable $l=0, 1,\\cdots, j$ with $t$ and incorporating the constraint we arrive at:\n", "$$\n", + "\\tag{23}\n", "(x_c + c_a)^i (x_c + c_b)^j = \n", "\\sum_{s = 0}^{i+j} x^s \n", "\\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \n", @@ -477,16 +478,21 @@ "$$\n", "Finally we can write this series as:\n", "$$\n", - "\\tag{22}\n", + "\\tag{24}\n", "(x_c + c_a)^i (x_c + c_b)^j = \\sum_{s = 0}^{i+j} B(i, j, c_a, c_b, s) x^s,\n", "$$\n", "where we introduce $B(i, j, c_a, c_b, s)$ as the coefficient of $x^s$ in the expansion:\n", "$$\n", - "\\tag{23}\n", + "\\tag{25}\n", "B(i, j, c_a, c_b, s) = \\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \\binom{i}{s-t} \\binom{j}{t} c_a^{i - (s - t)} c_b^{j-t}\n", "$$\n", "An evaluation strategy for this variable-sized loop is explored in an accompanying [notebook](./binom_factor_table.ipynb)." ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] } ], "metadata": { From 7a1f1c1fdfb07b7abea180cf473d55388a0b35a8 Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Thu, 12 Oct 2023 15:35:26 +0000 Subject: [PATCH 09/14] saving progress --- notebooks/gto_integrals.ipynb | 172 ++++++++++++++++++++++++++++++++-- 1 file changed, 164 insertions(+), 8 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index a624bb8..d533d4d 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -59,7 +59,7 @@ "5" ] }, - "execution_count": 1, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -96,7 +96,7 @@ "15" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -472,27 +472,183 @@ "$$\n", "\\tag{23}\n", "(x_c + c_a)^i (x_c + c_b)^j = \n", - "\\sum_{s = 0}^{i+j} x^s \n", + "\\sum_{s = 0}^{i+j} x_c^s \n", "\\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \n", "\\binom{i}{s-t} \\binom{j}{t} c_a^{i-(s-t)} c_b^{j-t},\n", "$$\n", "Finally we can write this series as:\n", "$$\n", "\\tag{24}\n", - "(x_c + c_a)^i (x_c + c_b)^j = \\sum_{s = 0}^{i+j} B(i, j, c_a, c_b, s) x^s,\n", + "(x_c + c_a)^i (x_c + c_b)^j = \\sum_{s = 0}^{i+j} B(i, j, c_a, c_b, s) x_c^s,\n", "$$\n", "where we introduce $B(i, j, c_a, c_b, s)$ as the coefficient of $x^s$ in the expansion:\n", "$$\n", "\\tag{25}\n", "B(i, j, c_a, c_b, s) = \\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \\binom{i}{s-t} \\binom{j}{t} c_a^{i - (s - t)} c_b^{j-t}\n", "$$\n", - "An evaluation strategy for this variable-sized loop is explored in an accompanying [notebook](./binom_factor_table.ipynb)." + "An evaluation strategy for this variable-sized loop is explored in an accompanying [notebook](./binom_factor_table.ipynb).\n", + "\n", + "Combining this result with the one we derived earlier for the product of two\n", + "Gaussian functions Equation 16 gives us:\n", + "$$\n", + "\\tag{26}\n", + "\\tilde{S}_{\\mu \\nu}^{(x)} = \\int_{-\\infty}^\\infty \n", + "\\left(x_A^{l_\\mu} e^{-\\alpha_\\mu x_A^2} \\right)\n", + "\\left(x_B^{l_\\nu} e^{-\\alpha_\\nu x_B^2} \\right) dx = \\\\\n", + "\\int_{-\\infty}^\\infty \n", + " e^{-\\alpha_\\mu \\alpha_\\nu (X_A - X_B)^2 / \\gamma} e^{-\\gamma x_C^2}\n", + "\\sum_{s=0}^{l_\\mu+ l_\\nu} B(l_\\mu, l_\\nu, C_A, C_B, s) x_C^s dx\n", + "$$\n", + "Swapping the order of integration and the summation we see that we need to evaluate\n", + "integrals of the form:\n", + "$$\n", + "\\int_{-\\infty}^\\infty t^s e^{-a t^2} dt\n", + "$$\n", + "This has a known analytic solution that we can evaluate using SymPy:" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAH4AAAAkCAYAAABPNo4ZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAGpklEQVR4nO2be4xV1RXGf6Pgo2pjxFIfQRNSqxKtCPVZrRot0arR+KiPilOjJkWjsaQT6qP9+FQURO3URk3rH4qvGMnUWhTfBqnRijqCr+kDoyBtSivEIPIoyPjH2reeuXMfM3fuvXMZ7pec7HPvXmfvddY6e+211t67pbu7mya2PAyrdoO2pwLnAZ3AJOBw4GZgLTBZ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\infty} t^{s} e^{- a t^{2}}\\, dt$" + ], + "text/plain": [ + "∞ \n", + "⌠ \n", + "⎮ 2 \n", + "⎮ s -a⋅t \n", + "⎮ t ⋅ℯ dt\n", + "⌡ \n", + "-∞ " + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "s = symbols(\"s\", nonnegative=True, integer=True)\n", + "a = symbols(\"a\", positive=True, real=True)\n", + "t = symbols(\"t\", real=True)\n", + "\n", + "gint = Integral(t ** s* exp(-a * t**2), (t, -oo, oo))\n", + "gint" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAesAAAAVCAYAAABmHMZ8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAKZklEQVR4nO2de5AdRRXGf8sbgQiCRIqHRbQEFSEqsaAkKPKIESGbAEohmIilKAIFClIRqMOHghBBglWgf6AJGCBKRQGJCCQBechbQ4lAIWpEJBAiEQzKIyH+cWY3k9l53b09985d5qvamt2Z7j6np8/Xj9OnZ/vWrFlDgwYNGjRo0KC+2KDbCrwZIOlHwCvAc8AUYBfgVeBeYLqZPdJF9Ro0eNOi4WaDXkFfs7KuFpL6gH8CRwHTgbnAA0AfcA6wN/A+M3uha0o26FlImgDcANwKHByqXDPrC1VWXdFws0GVCM3N1JW1pCuAicDOZvZyu0KGC0kfBh4EvmRml6c87wNOA74I7AT8B7jTzA7roI5FOowDNgbuMrMJibzHAC8CHwV+FUCXWrTbSEeRXXYYU4FTzOyyLutRK5TsGxpujiDUjJcQmJtDBmtJ44BjgFNDG5Wkw4GPAWOBPYAtgKvM7Oi09Gb2kKTrgG9LmmtmKxNJTgOmAccDTwLbRWV3EkU69APzzWxVSt4tgPWAFfGbksq4O7Yys3/H8g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uTMwWfsRwEHAbPzEtfd9uuuX0A03CyH0PXLGi96mpuDPnLzr7PcAWwj/2BAnbBXdG3lcP2Ay36MpA0HbkraGj/zuAPudlgcQsFuIavdJH1Q0ruS6aM0u+EdwdOxR5OBN4DrU/KchRvxQ/hss9c6A6imfml2WYWc+fi+59fwM5nXFaSvu+3XXb8gaLhZGqHrlzVe9DQ3k+es5+Ffa5mAH84OCkn9+NEIgIGjEXtLmh39vtzM0qIvD8LPKg55yVkws+clLSJyTUhagB88n4g34hvAoyUiAnsBae12IjBN0r24S2Ul/sWmQ6Pnx1r0tZ7ouEE/cE8yml7SVDxYZzV+HvCklKCTJWY2O2yV8tGKLVVYv3Xssio5ZvaapJ8DxwE/toIvYdXd9uuuX2A03HR0kptDxouRwM20wXoZvsF9aZ7QYWIsHi0Xx5joB/z7vesM1pLeir/kG83sHy3KOxIPsZ8IfBX/MPvXo+vhVLQn1gWktdv1wIbAR/B/aLAJHvR3NXCBmf05ln9PYEc82CSJnaPr+sDJGfJ/S4H7pwKMpbwtBa9fhl1W+R7n4B3ClRnPk6i77dddv1BouOnoCDdzxoue5+aQ/2ctaTr+AfQPmdmwjzWFgqQT8Yi78WZ2V7f1qSvaaTdJ5+FfSxpjZq0G8dUeVdQvzS6rfI/RymAG8E3r/D9maNAGGm5mI3T9ssaLkcDNtP+6dTHwFdwtcEhVgstA0qb4C57XDNSFaKfdJgMPj8TOIELQ+uXYZWXvMeoETgtdboOOoOFmNoLVr2C86HluDllZA0jaF9gPuNC6+OlRSe/Fv9U728yWdEuPXkFd2m2ko7HLBq2i4Wb1GOm8/D9Fy7yYqnleDwAAAABJRU5ErkJggg==", + "text/latex": [ + "$\\displaystyle \\frac{\\left(-1\\right)^{s} a^{- \\frac{s}{2}} \\Gamma\\left(\\frac{s}{2} + \\frac{1}{2}\\right)}{2 \\sqrt{a}} + \\frac{a^{- \\frac{s}{2}} \\Gamma\\left(\\frac{s}{2} + \\frac{1}{2}\\right)}{2 \\sqrt{a}}$" + ], + "text/plain": [ + " -s -s \n", + " ─── ─── \n", + " s 2 ⎛s 1⎞ 2 ⎛s 1⎞\n", + "(-1) ⋅a ⋅Γ⎜─ + ─⎟ a ⋅Γ⎜─ + ─⎟\n", + " ⎝2 2⎠ ⎝2 2⎠\n", + "─────────────────── + ─────────────\n", + " 2⋅√a 2⋅√a " + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "expand(gint.doit())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Written this way we can observe that whenever $s$ is odd, the integral will be zero." + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAAQCAYAAADNo/U5AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAABEElEQVR4nJXSsUqcURCG4cfFKosYCKRSECR6BzFgJcLiTdiLQsA6xTCCrYVibiAXkNjapFK8A90Vwc5KVMSUroVn5fjrBp3mg5l5Z4ZzvpF+v++9MdpMZOYENrCET7jAH2REXMFIvSkzp3GIz9jDCb5iAV3MR8Rlc9PPAnyPiJ1q2BbWsYmVVmNLB+fYbQwL3GE5M9utqrBQdD8i7p8REbc4wAd8q6HZor3m45Q4LTpTQ+NFb4ZAg/zH1pCG/0YNDSaNv9ZY5a9rqFt0Zgj0pWivhv4W7WTms7Mzcwzz+Iejp2JEnGEfU1hrbEm08Ssi7pqOWPVoo+3MXMQx5jz+YQ8/aHivnDLppWF/G2bYt8YDKpZR3A7SAGIAAAAASUVORK5CYII=", + "text/latex": [ + "$\\displaystyle 0$" + ], + "text/plain": [ + "0" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v = symbols(\"v\", nonnegative=True, integer=True, odd=True)\n", + "gint.subs(s, v).doit()" ] }, { "cell_type": "markdown", "metadata": {}, - "source": [] + "source": [ + "when $s$ is even we have:" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKYAAAAVCAYAAADM1pWsAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAHCElEQVR4nO2af5BVZRnHPwuoMKlpmFuhFOSEzZhQQkOF9AOJ6IewCpPThCJNNTFKVjgOqfP1a2HgZGAzWtMwAZVG02xpCYXxwwRT+RE4mTDGJJETigRp66TGj/543rsczp67e+/d3bur7XfmzDvnfZ73eZ9z73OeX+9pOHr0KH3oQ2/DgJ5WoCthezwwF7gAeAtwpaRlZXi/D7wEPAtcAowAXgYeAeZJerweOvehGP16WoEuxsnA48CXgf+UY7LdAFwM3AN8CLgTeD/wEeAQsMb2G7pZ1z60g7p5zGQM1wKfA4YC/wY2SLq0q/aQtApYlfZb1g7rGOAkYKOkSTk9ZwDPAx8Aft1ZnWwvByYDwyS92Fl5ryXYvgDYAnxe0pIsrZ6h/FpgJjAb2AW8GRhVx/2zmAqslHSogHYKEUkOZidtV5KMny7pX5k1Y4AZwNzeapS2pwEfJP6LkcTz3yXpsxWsbQT+QUScm4Am4BPAu4AhwCvAn4ClwFJJR7LrJW21fQ/wDdsrJLWUaPU0zI8Bv5G0Nt3/jcjnegJTgBvL0G4HtgMPl6G7Hbkv5e7nAy8A36tGuTrjBsIgW4CngXOrWDuFeIl/AUwnnnMvsB7YAzQS+fsSYLLt6ZLyL/i3gEeBOcAtpclOGabtbwLXd8D2YUkPAL8CbrM9Evg50CxpfydlVg3b5wDDgdUFtO8A44Bxkg4XrZd0U4X7vAO4CFgiqWy+2xWwPZPwSrX8Ll8hDHIX4TnXV7G2Cfgn8CBQyttXZj2j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HpENlkXLMNcTZ/Aaih9pI59ph3Y3xxAtXGMZTobuA8NQTK8yZRxAp2PbSRCl/LCWww22fkNlkMNGHO4sI6a0L+1Ae6XTjQeCM1NAHwPa7bb89z594ziMM8um6KVobmoAjwL15gu0bCaPcSnjKSgu5sWls7akOAJD0nO11RMP0UdtriOb65MR8BHiiggqsD8fQTJx2TCIOKACuBmbafoRIi1qIU6iLE31W/jy5u2F7KtEqAyi1yt6X+Qhmv6S5ibch8T6c76jYvoIocA8TPfA5BYXY7jKfIX40rWs19myOeRlwG2GMXyIO37+axmm8yvPLHkAzkWteDtyR5u4FTgDeS3zQMpBow90NLJT0l/qrySiir5zF8HRBfNNQap2NBs4mCrA8hqWxP3BNmb1+DyzLTth+PWHs90n6e2m+oe8L9u6D7XnEhwnvkVRTq603wfYtxKnUcElPdcRfocyrge8CF0raWJp/rX0o3NuwiMgbu72HWyc0AY91oVEOIgy9OWuU0GeY3YqUk88AtqRjylc1JL1T0qguFPk24AcUnLL9D58/e412WKxuAAAAAElFTkSuQmCC", + "text/latex": [ + "$\\displaystyle a^{- s - \\frac{1}{2}} \\Gamma\\left(s + \\frac{1}{2}\\right)$" + ], + "text/plain": [ + " -s - 1/2 \n", + "a ⋅Γ(s + 1/2)" + ] + }, + "execution_count": 65, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "simplify(gint.subs(s, 2*s).doit())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Using this result allows us to write the one-dimensional overlap integral as:\n", + "$$\n", + "\\tilde{S}_{\\mu \\nu}^{(x)} = \n", + "e^{-\\alpha_\\mu \\alpha_\\nu (X_A - X_B)^2 / \\gamma}\n", + "\\sum_{s=0}^{\\lfloor(i+j)/2 \\rfloor} B(l_\\mu, l_\\nu, C_A, C_B, 2s)\n", + "\\int_{-\\infty}^\\infty \n", + "x_C^{2s} e^{-\\gamma x_C^2} dx\n", + "$$" + ] } ], "metadata": { From 9a89eb2aa999ccfd5746c988cff6cd36fc4ad43c Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Fri, 13 Oct 2023 12:17:48 +0000 Subject: [PATCH 10/14] complete 3d overlap equation --- notebooks/gto_integrals.ipynb | 51 +++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index d533d4d..d489d53 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -59,7 +59,7 @@ "5" ] }, - "execution_count": 2, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -96,7 +96,7 @@ "15" ] }, - "execution_count": 3, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -497,11 +497,12 @@ "\\left(x_B^{l_\\nu} e^{-\\alpha_\\nu x_B^2} \\right) dx = \\\\\n", "\\int_{-\\infty}^\\infty \n", " e^{-\\alpha_\\mu \\alpha_\\nu (X_A - X_B)^2 / \\gamma} e^{-\\gamma x_C^2}\n", - "\\sum_{s=0}^{l_\\mu+ l_\\nu} B(l_\\mu, l_\\nu, C_A, C_B, s) x_C^s dx\n", + "\\sum_{s=0}^{l_\\mu+ l_\\nu} B(l_\\mu, l_\\nu, CA_x, CB_x, s) x_C^s dx\n", "$$\n", "Swapping the order of integration and the summation we see that we need to evaluate\n", "integrals of the form:\n", "$$\n", + "\\tag{27}\n", "\\int_{-\\infty}^\\infty t^s e^{-a t^2} dt\n", "$$\n", "This has a known analytic solution that we can evaluate using SymPy:" @@ -509,7 +510,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -528,7 +529,7 @@ "-∞ " ] }, - "execution_count": 51, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -544,7 +545,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -563,7 +564,7 @@ " 2⋅√a 2⋅√a " ] }, - "execution_count": 52, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -581,7 +582,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -594,7 +595,7 @@ "0" ] }, - "execution_count": 57, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -613,7 +614,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -627,7 +628,7 @@ "a ⋅Γ(s + 1/2)" ] }, - "execution_count": 65, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -640,13 +641,29 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Using this result allows us to write the one-dimensional overlap integral as:\n", + "This result can also be written in terms of the [double factorial](https://en.wikipedia.org/wiki/Double_factorial#Additional_identities) which gives us two possible computation strategies for this integral:\n", + "$$\n", + "\\tag{28}\n", + "G(a, s) = \\int_{-\\infty}^{\\infty} t^{2s} e^{-a t^2} dt \\\\\n", + "= a^{-s - \\frac{1}{2}} \\Gamma\\left(s + \\frac{1}{2}\\right) \\\\\n", + "= \\frac{(2s-1)!!}{(2a)^s} \\sqrt{\\frac{\\pi}{a}}.\n", + "$$\n", + "The last form agrees with Equation (3.15) derived by [Fermann and Valeev](http://arxiv.org/abs/2007.12057).\n", + "\n", + "Using the function $G(a, s)$ allows us to write the one-dimensional overlap integral as:\n", "$$\n", "\\tilde{S}_{\\mu \\nu}^{(x)} = \n", "e^{-\\alpha_\\mu \\alpha_\\nu (X_A - X_B)^2 / \\gamma}\n", - "\\sum_{s=0}^{\\lfloor(i+j)/2 \\rfloor} B(l_\\mu, l_\\nu, C_A, C_B, 2s)\n", - "\\int_{-\\infty}^\\infty \n", - "x_C^{2s} e^{-\\gamma x_C^2} dx\n", + "\\sum_{s=0}^{\\lfloor(l_\\mu + l_\\nu)/2 \\rfloor} B(l_\\mu, l_\\nu, CA_x, CB_x, 2s)\\;G(\\gamma, 2s)\n", + "$$\n", + "substituting this back into Equation (11) gives us the overlap of two primitive Gaussians:\n", + "$$\n", + "\\tag{11}\n", + "\\tilde{S}_{\\mu \\nu} = \\iiint p_\\mu(\\br) p_\\nu(\\br) dx dy dz \\\\\n", + "= N_\\mu N_\\nu e^{-\\alpha_\\mu \\alpha_\\nu |\\mathbf{A}-\\mathbf{B}|^2 / \\gamma}\n", + "\\sum_{s=0}^{\\lfloor(l_\\mu + l_\\nu)/2 \\rfloor} B(l_\\mu, l_\\nu, CA_x, CB_x, 2s)\\;G(\\gamma, 2s) \\\\\n", + "\\times \\sum_{s=0}^{\\lfloor(m_\\mu + m_\\nu)/2 \\rfloor} B(m_\\mu, m_\\nu, CA_y, CB_y, 2s)\\;G(\\gamma, 2s)\n", + "\\sum_{s=0}^{\\lfloor(n_\\mu + n_\\nu)/2 \\rfloor} B(n_\\mu, n_\\nu, CA_z, CB_z, 2s)\\;G(\\gamma, 2s)\n", "$$" ] } From 224986b3c23c907d2401bd314e4d7b2195dcddea Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Sun, 15 Oct 2023 13:06:55 +0000 Subject: [PATCH 11/14] fix equation numbering --- notebooks/gto_integrals.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index d489d53..aafe7b1 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -652,13 +652,14 @@ "\n", "Using the function $G(a, s)$ allows us to write the one-dimensional overlap integral as:\n", "$$\n", + "\\tag{29}\n", "\\tilde{S}_{\\mu \\nu}^{(x)} = \n", "e^{-\\alpha_\\mu \\alpha_\\nu (X_A - X_B)^2 / \\gamma}\n", "\\sum_{s=0}^{\\lfloor(l_\\mu + l_\\nu)/2 \\rfloor} B(l_\\mu, l_\\nu, CA_x, CB_x, 2s)\\;G(\\gamma, 2s)\n", "$$\n", "substituting this back into Equation (11) gives us the overlap of two primitive Gaussians:\n", "$$\n", - "\\tag{11}\n", + "\\tag{30}\n", "\\tilde{S}_{\\mu \\nu} = \\iiint p_\\mu(\\br) p_\\nu(\\br) dx dy dz \\\\\n", "= N_\\mu N_\\nu e^{-\\alpha_\\mu \\alpha_\\nu |\\mathbf{A}-\\mathbf{B}|^2 / \\gamma}\n", "\\sum_{s=0}^{\\lfloor(l_\\mu + l_\\nu)/2 \\rfloor} B(l_\\mu, l_\\nu, CA_x, CB_x, 2s)\\;G(\\gamma, 2s) \\\\\n", From 39904f27689ebc5c7c04eaea5580b5844823548a Mon Sep 17 00:00:00 2001 From: Andrew Fitzgibbon Date: Mon, 16 Oct 2023 17:27:15 +0100 Subject: [PATCH 12/14] new intro --- notebooks/gto_integrals.ipynb | 317 +++++++++++++--------------------- 1 file changed, 121 insertions(+), 196 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index aafe7b1..ea68434 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -13,57 +13,101 @@ "\n", "# Integrals over Gaussian Type Orbitals (GTO)\n", "\n", - "Zooming straight past a number of details, a standard approach in density functional theory (DFT)\n", - "is to expand the molecular orbitals $\\{\\psi_i (\\br) \\}$ in a finite basis set:\n", + "We have a molecule comprising $M$ atoms (Mnemonic: $M$ for $\\text{ato}M$),\n", + "each with atomic number $Z_m$ and position $\\br_m \\in \\mathbb{R}^3$\n", "$$\n", - "\\tag{1}\n", - "\\psi_i (\\br) = \\sum_{i=1}^N c_i \\phi_i (\\br).\n", + "\\mathcal{A} = \\{ (Z_m, \\br_m) \\}_{m=1}^{M}\n", "$$\n", - "Typically the basis functions $\\{\\phi_i (\\br) \\}$ are taken as approximations of atomic orbitals and this is referred to as the linear combination of atomic orbitals (LCAO) method in the literature. There is some flexibility in how exactly this finite\n", - "basis is defined. Gaussian type orbitals (GTO) are perhaps\n", - "one of the most popular choices and take the following general form \n", + "\n", + "We will represent the electron density of the molecule as a sum of per-atom electron densities.\n", + "$$\n", + "\\psi(\\br) = \\sum_{m=1}^M \\psi_m(\\br)\n", + "$$\n", + "Atom $m$ has $N(Z_m)$ basis functions (determined by $Z_m$ and the basis set in use),\n", + "with coefficients $[c_{mi}]_{i=1}^{N(Z_m)}$:\n", + "$$\n", + "\\psi_m(\\br) = \\sum_{i=1}^{N(Z_m)} c_{mi}~ \\phi_{Z_m,i}(\\br - \\br_m)\n", + "$$\n", + "\n", + "Each function $\\phi_{z,i}$ is defined by the basis set as a fixed linear combination of primitive functions $p(\\br; \\nu)$, known as a \"contraction\":\n", "$$\n", - "These functions are parameterised by:\n", - "* $\\bA = (X_A, Y_A, Z_A)$ is the center of the Gaussian orbital that for our current treatment will be set by the atomic positions of the molecular structure we are simulating. We use the shorthand of $x_A = x - X_A$ in the leading polynomial term\n", - "* $\\alpha$ in the exponent determines the extent of the Gaussian orbital.\n", - "* $(l, m, n)$ are the angular momentum quantum numbers that take on non-negative integer values.\n", - "* normalising constant $N$ is a function of $\\alpha$ and $(l, m, n)$ and is derived later in this notebook.\n", + "\\phi_{z,i}(\\br) = \\sum_{k=1}^{K(z,i)} d_{z,i,k} ~ p_{f(z,i,k)}(\\br; \\nu_{z,i,k})\n", + "$$\n", + "The values of $d,\\nu$ and the function type $f$ are read from standard basis sets.\n", + "As these functions $\\phi$ are often taken as approximations of atomic orbitals, \n", + "this is referred to as the linear combination of atomic orbitals (LCAO) method in the literature.\n", + "In general the lengths $K(z,i)$ of the contractions have been pre-optimised alongside the contraction coefficients $d_{z,i,k}$ and the primitive exponents $\\alpha_\\mu$ to best approximate atomic orbitals. A range of Gaussian basis sets covering the periodic table with different compute-time-vs-accuracy tradeoffs are available from the [basis set exchange](https://www.basissetexchange.org/). We use their python API in this project to provide programmatic access to these basis sets.\n", + "\n", + "In this, we will consider only the function type \"GTO\", for Gaussian-type Orbital,\n", + "where the parameter packet $\\nu$ comprises three non-negative integers $(l,m,n)$, \n", + "called \"angular momentum quantum numbers\",\n", + "and a real value $\\alpha$, the \"exponent\".\n", + "The primitive is\n", + "$$\n", + "\\def\\pgto{p_{\\text{GTO}}}\n", + "\\pgto(\\br; \\nu) = \\pgto(\\br; l,m,n,\\alpha) = N(l,m,n,\\alpha) ~ x^l y^m z^n \\exp(-\\alpha\\|\\br\\|^2)\n", + "$$\n", + "where the normalizing constant $N(l,m,n,\\alpha)$ is a function of $\\alpha$ and $(l, m, n)$\n", + "and is chosen so that the function integrates to 1, as derived later in this notebook.\n", + "In the following, as we are dealing only with GTO, we will simply write $p(\\br;\\nu)$ or $p(\\br;l,m,n,\\alpha).$\n", "\n", - "Another complication that is worth mentioning up front is that we typically encounter \n", - "*contracted* Gaussian basis functions defined as:\n", + "Noting that a linear combination (LC) of LCs is just another LC, we will often \n", + "contract the two sets of coefficients, writing\n", "$$\n", - "\\tag{3}\n", - "\\phi_i (\\br; \\bA, l, m, n) = \\sum_{\\mu=1}^{K_i} d_{\\mu i} p_\\mu(\\br; \\bA, \\alpha_\\mu, l, m, n)\n", + "\\psi_m(\\br) = \\sum_{i=1}^{N(Z_m)} c_{mi} \\sum_{k=1}^{K(z,i)} d_{Z_m,i,k} ~ p(\\br - \\br_m; \\nu_{Z_m,i,k})\n", "$$\n", - "where we introduce the *primitive* Gaussian:\n", + "as\n", "$$\n", - "\\tag{4}\n", - "p_\\mu(\\br; \\bA, \\alpha_\\mu, l, m, n) = N x_A^l y_A^m z_A^n e^{-\\alpha_\\mu |\\br - \\bA|^2}.\n", + "\\psi_m(\\br) = \\sum_{j=1}^{N_m} a_{mj}~ p(\\br - \\br_m; \\nu_{mj})\n", "$$\n", - "In general the length of the contraction $K_i$ have been pre-optimised alongside the contraction coefficients $d_{\\mu i}$ and the primitive exponents $\\alpha_\\mu$ to best approximate atomic orbitals. A range of Gaussian basis sets covering the periodic table with different compute time vs accuracy tradeoffs are available from the [basis set exchange](https://www.basissetexchange.org/). We use their python API in this project to provide programmatic access to these basis sets.\n", + "where $N_m$ is just the total number of different $\\nu$ values in the basis set for atom $Z_m$.\n", + "For most basis sets, this will mean $N_m = \\sum_i K(Z_m,i)$.\n", + "\n", + "### This notebook\n", "\n", - "To demonstrate these concepts, we use the `basisset` function to build the atomic orbitals of a single oxygen atom. The `Basis` object built by `basisset` consists of a list of `Orbital` objects which are defined by a set of `coefficients` and corresponding `Primitive` objects." + "This notebook derives several key computations involved in DFT.\n", + "In particular, DFT involves integrals of the form\n", + "$$\n", + "\\def\\op{\\mathcal{Q}}\n", + "\\langle\\psi|\\op|\\psi\\rangle = \\int \\int \\psi(\\br_1) ~\\op \\psi(\\br_2) ~g(\\br_1, \\br_2) d \\br_1 d \\br_2\n", + "$$\n", + "where $\\op\\psi$ is an transformation of function $\\psi$ by an operator $\\op$, such as gradient $\\nabla$, and the function $g$ is some function of a pair of points, e.g. $g(\\mathbf r, \\mathbf s) = \\|\\mathbf r - \\mathbf s\\|^{-1}$.\n", + "Such integrals can be written in terms of the per-atom (or \"per-center\") functions $\\psi_m$\n", + "$$\n", + "\\langle\\psi|\\op|\\psi\\rangle = \\sum_{m_1=1}^M \\sum_{m_2=1}^M \\int \\int \\psi_{m_1}(\\br_1) ~\\op \\psi_{m_2}(\\br_2) ~g(\\br_1, \\br_2) d \\br_1 d \\br_2\n", + "$$\n", + "and then in terms of the primitives $p$, where again $\\op p$ is the operator $\\op$ applied to $p(\\br;...)$.\n", + "$$\n", + "\\langle\\psi|Q|\\psi\\rangle = \\sum_{m_1=1}^M \\sum_{m_2=1}^M \n", + " \\sum_{j_1=1}^{N_{m_1}} \\sum_{j_2=1}^{N_{m_2}} \n", + " a_{m_1,j_1} a_{m_2,j_2} \n", + " \\int \\int p(\\br_1 - \\br_{m_1}; \\nu_{m_1,j_1}) ~\\op p(\\br_2 - \\br_{m_2}; \\nu_{m_2,j_2}) ~ g(\\br_1, \\br_2) d \\br_1 d \\br_2\n", + "$$\n", + "all of which depends on the ability to compute integrals of the form\n", + "$$\n", + "\\def\\bB{\\mathbf B}\n", + "\\int \\int p(\\br_1 - \\bA; \\nu_A) ~\\op p(\\br_2 - \\bB; \\nu_B) ~g(\\br_1, \\br_2) ~d \\br_1 d \\br_2\n", + "$$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Basis set for a single-atom molecule\n", + "\n", + "Before deriving the integrals, we use the `basisset` function to build the atomic orbitals of a single oxygen atom $M=1$, $Z_1 = 8$, illustraiting typical values for the numbers of orbitals and consequent numbers of primitives.\n", + "The `Basis` object built by `basisset` consists of a list of `Orbital` objects which are defined by a set of `coefficients` and corresponding `Primitive` objects." ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "5" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "import numpy as np\n", "from pyscf_ipu.experimental.structure import Structure\n", @@ -87,20 +131,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "15" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "basis.num_primitives" ] @@ -129,7 +162,7 @@ "\n", "# Mapping between orbital label -> index in basis set\n", "orbital_idx = dict(zip([\"1s\", \"2s\", \"2px\", \"2py\", \"2pz\"], range(5)))\n", - "plot_volume(oxygen, orbitals[:, orbital_idx[\"2px\"]], axes)" + "plot_volume(oxygen, orbitals[:, orbital_idx[\"2px\"]], axes).spin(4)" ] }, { @@ -144,35 +177,30 @@ "The above visualisation uses the formulas defined earlier to numerically evaluate\n", "each atomic orbital from a linear combintation of primitive Gaussians. Introducing\n", "the basis set allows us to replace the problem of solving a system partial differential equations (e.g. the Kohn-Sham equations) with an algebraic system of equations that can be solved using standard matrix eigenvalue techniques.\n", - "The individual elements of the matrices in this system are integrals over pairs of\n", + "The individual elements of the matrices in this system are single integrals over pairs of\n", "basis functions:\n", "$$\n", "\\tag{5}\n", - "M_{ij} = \\int \\phi_i(\\br) \\hat{M}(\\br) \\phi_j(\\br) d\\br.\n", + "M_{ij} = \\int p(\\br - \\bA; \\nu_A) ~\\op p(\\br - \\bB; \\nu_B) d\\br.\n", "$$\n", - "We introduce the operator $\\hat{M}(\\br)$ which in its most general definition is\n", - "a function that transforms the $\\phi_j(\\br)$ basis functions to represent a physical\n", - "observable. That sounds fancy but is just a complicated way of saying we are breaking\n", + "The operator $\\op$ in its most general definition is\n", + "a function that transforms the $\\psi(\\br)$ function to represent a physical observable.\n", + "That sounds fancy but is just a complicated way of saying we are breaking\n", "down something we can measure (e.g. the energy, dipole moment, etc) into components\n", "that we can evaluate through these integrals. The simplest operator is simply an \n", - "identity mapping that we name the overlap:\n", + "identity mapping, $\\op p(\\br) := p(\\br)$, that we name the {\\em overlap}.\n", + "\n", + "## The overlap integral\n", + "\n", + "The overlap integral is defined by\n", "$$\n", "\\tag{6}\n", - "S_{ij} = \\int \\phi_i(\\br) \\phi_j(\\br) d\\br.\n", - "$$\n", - "Recalling that each of the atomic orbitals are represented as a linear combination of primitives allows us to further expand the overlap integral as:\n", - "$$\n", - "\\tag{7}\n", - "S_{ij} = \\int \\sum_{\\mu = 1}^{K_i} \\sum_{\\nu = 1}^{K_j} d_{\\mu i} d_{\\nu j} p_\\mu(\\br) p_{\\nu}(\\br) d\\br = \\sum_{\\mu \\nu} d_{\\mu i} d_{\\nu j} \\tilde{S}_{{\\mu \\nu}}.\n", + "S_{\\mu\\nu} = \\int p(\\br - \\br_\\mu; l_\\mu, m_\\mu, n_\\mu, \\alpha_\\mu) ~ p(\\br - \\br_\\nu; l_\\nu, m_\\nu, n_\\nu, \\alpha_\\nu) ~ d\\br.\n", "$$\n", - "Since we can swap the order of integration and the double-summation we are able to introduce $\\tilde{S}_{\\mu \\nu}$ as the elements of the overlap matrix in terms of the primitive functions:\n", - "$$\n", - "\\tag{8}\n", - "\\tilde{S}_{\\mu \\nu} = \\int p_\\mu(\\br) p_\\nu(\\br) d\\br.\n", - "$$\n", - "This finally sets us up to discuss the benefits of using an expansion in Gaussian type orbitals to iteratively solve Kohn-Sham equations using the self-consistent field (SCF) method. As an aside, for a nice overview and derivation of the SCF method we refer the reader to the following review article:\n", "\n", - "> Lehtola, S., Blockhuys, F. and Van Alsenoy, C., 2020. An overview of self-consistent field calculations within finite basis sets. Molecules, 25(5), p.1218. [open access](https://doi.org/10.3390/molecules25051218)\n", + "\n", "\n", "Gaussian basis functions of the form above have a few convenient properties that help\n", "make it easier to evaluate integrals of the form in equation (5). To show this\n", @@ -181,13 +209,13 @@ "\\tag{9}\n", "\\tilde{S}_{\\mu \\nu} = \\iiint p_\\mu(\\br) p_\\nu(\\br) dx dy dz,\n", "$$\n", - "and observing that a primitive $p_\\mu(\\br)$ can be written as a product of cartesian components:\n", + "and observing that a primitive $p_\\mu(\\br) = p(\\br - \\br_\\mu; l_\\mu, m_\\mu, n_\\mu, \\alpha_\\mu)$ can be written as a product of cartesian components:\n", "$$\n", "\\tag{10}\n", "p_\\mu(\\br) = N_\\mu\n", - "\\left(x_A^l e^{-\\alpha_\\mu x_A^2} \\right)\n", - "\\left(y_A^m e^{-\\alpha_\\mu y_A^2} \\right)\n", - "\\left(z_A^n e^{-\\alpha_\\mu z_A^2} \\right),\n", + "\\left((x - x_\\mu)^{l_\\mu} e^{-\\alpha_\\mu (x - x_\\mu)^2} \\right)\n", + "\\left((y - y_\\mu)^{m_\\mu} e^{-\\alpha_\\mu (y - y_\\mu)^2} \\right)\n", + "\\left((z - z_\\mu)^{n_\\mu} e^{-\\alpha_\\mu (z - z_\\mu)^2} \\right)\n", "$$\n", "we directly see that we can separate the three-dimensional integral in equation (9) as a\n", "product of three one-dimensional integrals:\n", @@ -199,8 +227,8 @@ "$$\n", "\\tag{12}\n", "\\tilde{S}_{\\mu \\nu}^{(x)} = \\int_{-\\infty}^\\infty \n", - "\\left(x_A^{l_\\mu} e^{-\\alpha_\\mu x_A^2} \\right)\n", - "\\left(x_B^{l_\\nu} e^{-\\alpha_\\nu x_B^2} \\right) dx,\n", + "\\left((x - x_\\mu)^{l_\\mu} e^{-\\alpha_\\mu (x - x_\\mu)^2} \\right)\n", + "\\left((x - x_\\nu)^{l_\\nu} e^{-\\alpha_\\nu (x - x_\\nu)^2} \\right) dx,\n", "$$\n", "and use the same definition for the y and z components.\n", "\n", @@ -218,16 +246,16 @@ "The one-dimensional self-overlap integral is:\n", "$$\n", "\\tag{15}\n", - "\\tilde{S}_{\\mu \\mu}^{(x)} = \\int_{-\\infty}^\\infty x^{2l} e^{-2 \\alpha_\\mu x^2} dx.\n", + "\\tilde{S}_{\\mu \\mu}^{(x)} = \\int_{-\\infty}^\\infty x^{2l_\\mu} e^{-2 \\alpha_\\mu x^2} dx.\n", "$$\n", - "We've made use of the translation invariance property of the integral over all $x$ when shifting by the constant $X_A$ in equation (15). \n", + "We've made use of the translation invariance property of the integral over all $x$ when shifting by the constant $x_\\mu$ in equation (15). \n", "\n", "These one dimensional integrals have a known analytic solution [see equation 42 of gaussian integral](https://mathworld.wolfram.com/GaussianIntegral.html), but we will lean on [SymPy](https://docs.sympy.org/latest/index.html) to help us derive a formula for normalising our primitive Gaussian functions." ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -240,7 +268,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -252,7 +280,7 @@ "" ] }, - "execution_count": 5, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -390,25 +418,9 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKsAAAAXCAYAAAB04L8XAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywga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sPYFXo0irpuzXs1/mETMpUQiy7NfAscEFyk9OoqjXT5m+wmlprlBezNtVUQ+pfoF49jfOndtwAAAAASUVORK5CYII=", - "text/latex": [ - "$\\displaystyle \\left(c_{a} + x_{c}\\right)^{i} \\left(c_{b} + x_{c}\\right)^{j}$" - ], - "text/plain": [ - " i j\n", - "(cₐ + x_c) ⋅(c_b + x_c) " - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "x, a, b = symbols(\"x_c, c_a, c_b\", real=True)\n", "i, j = symbols(\"i, j\", nonnegative=True, integers=True)\n", @@ -418,23 +430,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "\\begin{align*}(a + x)^0 (b + x)^0 &= 1\\\\(a + x)^0 (b + x)^1 &= c_{b} + x_{c}\\\\(a + x)^0 (b + x)^2 &= c_{b}^{2} + 2 c_{b} x_{c} + x_{c}^{2}\\\\(a + x)^1 (b + x)^0 &= c_{a} + x_{c}\\\\(a + x)^1 (b + x)^1 &= c_{a} c_{b} + x_{c} \\left(c_{a} + c_{b}\\right) + x_{c}^{2}\\\\(a + x)^1 (b + x)^2 &= c_{a} c_{b}^{2} + x_{c} \\left(2 c_{a} c_{b} + c_{b}^{2}\\right) + x_{c}^{2} \\left(c_{a} + 2 c_{b}\\right) + x_{c}^{3}\\\\(a + x)^2 (b + x)^0 &= c_{a}^{2} + 2 c_{a} x_{c} + x_{c}^{2}\\\\(a + x)^2 (b + x)^1 &= c_{a}^{2} c_{b} + x_{c} \\left(c_{a}^{2} + 2 c_{a} c_{b}\\right) + x_{c}^{2} \\cdot \\left(2 c_{a} + c_{b}\\right) + x_{c}^{3}\\\\(a + x)^2 (b + x)^2 &= c_{a}^{2} c_{b}^{2} + x_{c} \\left(2 c_{a}^{2} c_{b} + 2 c_{a} c_{b}^{2}\\right) + x_{c}^{2} \\left(c_{a}^{2} + 4 c_{a} c_{b} + c_{b}^{2}\\right) + x_{c}^{3} \\cdot \\left(2 c_{a} + 2 c_{b}\\right) + x_{c}^{4}\\\\\\end{align*}" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from itertools import product\n", "\n", @@ -510,30 +508,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAH4AAAAkCAYAAABPNo4ZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAGpklEQVR4nO2be4xV1RXGf6Pgo2pjxFIfQRNSqxKtCPVZrRot0arR+KiPilOjJkWjsaQT6qP9+FQURO3URk3rH4qvGMnUWhTfBqnRijqCr+kDoyBtSivEIPIoyPjH2reeuXMfM3fuvXMZ7pec7HPvXmfvddY6e+211t67pbu7mya2PAyrdoO2pwLnAZ3AJOBw4GZgLTBZ0l+q3WcT/cdW1WzM9gnAbsB4QvF/AGYA56frFtst1eyzicrQZ8XbbrG9dRmyg4FZklZLmglsC9whqUvSR8BfgV0r5raJqqGsqbe9HSDgp8Bw23cBV0v6ogD534ATgVdtH0MofrLtucAqYD9gRbWY39xhexTwADAS2AjcIGl2Pfruy4i/B/gFsDOwA9AGTClCOwf4pu2lwK3AWcB0YAHwLvBrSZsGyPNQwkbgKkljgAlAu+0d6tFxSymv3vZI4N9AC3Blun8UWCZpVD0Y3JJgexFwiqSPa91XuRE/llA6wEOEszYXeMH212rI15CE7Zm2nylSNx7Yuh5Kh/JzfM4RWydpZbo/uYb8DHUcCszP/9P2LsD9wKX1YqSc4ndK5apaM1IpUnjYBlwM7AV8BvxZ0pl15uM64EfAaCJn8SQwSdJa29sAq4HhwPcTbZekMba3Bf4ITJf0Sr34Laf4HVO5ut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EU1bJY1PZS35FFW97eyC31WqwRvyIVFa0SCRpLfA2MMZ2wby17aP6sKVs0CFpA/APYE/bp2brUlibe7+sY1dUfqVM/U6Z+8Ea8bmXmGb7AOBz4L1+bk9qI1bKOmw/T3wIWxGp1fHAcEl7VZHnWuJmImzssP0IsTHmWGIe/xgYRc8RX1R+pUz9jpn7wYrj5xOe7OepFP1ceZP0LBGudRACuhKYSIQ9zwMXVY/j2kLS/cSK3zLCWW0lFP49oBtYIWlJhr6o/IpuvUqLHgvTz9GSPqz6mzQxaCg14hvB1DdRI/x/jk9ZoanAR5IuI+YLiBz4yt6PNrE5I+vcfUIsMKy1fQ9wQfp/YXNL9NBDjzne9hzglDyasyR1VLPT5vm6wUf+HD+RWEhYBSwCTquB0pvn6xoAPeL4tEZ8QWHSwujvNiUy5+uAmWmv2R2SulJ7ufN1/+0PH030D9U4Jt1ObHIohaWZ++b5ugZAySNUtUAy43cDPyR2z5xN7FO7iYggJkt6rK5MbYGou+KbaAxsDpsPmqgBvgSKMHGEbds8QQAAAABJRU5ErkJggg==", - "text/latex": [ - "$\\displaystyle \\int\\limits_{-\\infty}^{\\infty} t^{s} e^{- a t^{2}}\\, dt$" - ], - "text/plain": [ - "∞ \n", - "⌠ \n", - "⎮ 2 \n", - "⎮ s -a⋅t \n", - "⎮ t ⋅ℯ dt\n", - "⌡ \n", - "-∞ " - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "s = symbols(\"s\", nonnegative=True, integer=True)\n", "a = symbols(\"a\", positive=True, real=True)\n", @@ -545,30 +522,9 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAesAAAAVCAYAAABmHMZ8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIW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vR3NXCBmf05ln9PYEc82CSJnaPr+sDJGfJ/S4H7pwKMpbwtBa9fhl1W+R7n4B3ClRnPk6i77dddv1BouOnoCDdzxoue5+aQ/2ctaTr+AfQPmdmwjzWFgqQT8Yi78WZ2V7f1qSvaaTdJ5+FfSxpjZq0G8dUeVdQvzS6rfI/RymAG8E3r/D9maNAGGm5mI3T9ssaLkcDNtP+6dTHwFdwtcEhVgstA0qb4C57XDNSFaKfdJgMPj8TOIELQ+uXYZWXvMeoETgtdboOOoOFmNoLVr2C86HluDllZA0jaF9gPuNC6+OlRSe/Fv9U728yWdEuPXkFd2m2ko7HLBq2i4Wb1GOm8/D9Fy7yYqnleDwAAAABJRU5ErkJggg==", - "text/latex": [ - "$\\displaystyle \\frac{\\left(-1\\right)^{s} a^{- \\frac{s}{2}} \\Gamma\\left(\\frac{s}{2} + \\frac{1}{2}\\right)}{2 \\sqrt{a}} + \\frac{a^{- \\frac{s}{2}} \\Gamma\\left(\\frac{s}{2} + \\frac{1}{2}\\right)}{2 \\sqrt{a}}$" - ], - "text/plain": [ - " -s -s \n", - " ─── ─── \n", - " s 2 ⎛s 1⎞ 2 ⎛s 1⎞\n", - "(-1) ⋅a ⋅Γ⎜─ + ─⎟ a ⋅Γ⎜─ + ─⎟\n", - " ⎝2 2⎠ ⎝2 2⎠\n", - "─────────────────── + ─────────────\n", - " 2⋅√a 2⋅√a " - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "expand(gint.doit())" ] @@ -582,24 +538,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAAQCAYAAADNo/U5AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAABEElEQVR4nJXSsUqcURCG4cfFKosYCKRSECR6BzFgJcLiTdiLQsA6xTCCrYVibiAXkNjapFK8A90Vwc5KVMSUroVn5fjrBp3mg5l5Z4ZzvpF+v++9MdpMZOYENrCET7jAH2REXMFIvSkzp3GIz9jDCb5iAV3MR8Rlc9PPAnyPiJ1q2BbWsYmVVmNLB+fYbQwL3GE5M9utqrBQdD8i7p8REbc4wAd8q6HZor3m45Q4LTpTQ+NFb4ZAg/zH1pCG/0YNDSaNv9ZY5a9rqFt0Zgj0pWivhv4W7WTms7Mzcwzz+Iejp2JEnGEfU1hrbEm08Ssi7pqOWPVoo+3MXMQx5jz+YQ8/aHivnDLppWF/G2bYt8YDKpZR3A7SAGIAAAAASUVORK5CYII=", - "text/latex": [ - "$\\displaystyle 0$" - ], - "text/plain": [ - "0" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "v = symbols(\"v\", nonnegative=True, integer=True, odd=True)\n", "gint.subs(s, v).doit()" @@ -614,25 +555,9 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKYAAAAVCAYAAADM1pWsAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAHCElEQVR4nO2af5BVZRnHPwuoMKlpmFuhFOSEzZhQQkOF9AOJ6IewCpPThCJNNTFKVjgOqfP1a2HgZGAzWtMwAZVG02xpCYXxwwRT+RE4mTDGJJETigRp66TGj/543rsczp67e+/d3bur7XfmzDvnfZ73eZ9z73OeX+9pOHr0KH3oQ2/DgJ5WoCthezwwF7gAeAtwpaRlZXi/D7wEPAtcAowAXgYeAeZJerweOvehGP16WoEuxsnA48CXgf+UY7LdAFwM3AN8CLgTeD/wEeAQsMb2G7pZ1z60g7p5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ystyle a^{- s - \\frac{1}{2}} \\Gamma\\left(s + \\frac{1}{2}\\right)$" - ], - "text/plain": [ - " -s - 1/2 \n", - "a ⋅Γ(s + 1/2)" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "simplify(gint.subs(s, 2*s).doit())" ] @@ -685,7 +610,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.8.17" }, "orig_nbformat": 4 }, From 42eb952d653a49f7b4f2b706d54a38536e757018 Mon Sep 17 00:00:00 2001 From: Andrew Fitzgibbon Date: Tue, 17 Oct 2023 21:10:45 +0100 Subject: [PATCH 13/14] Reorder so single integrals come first, then overlap. --- notebooks/gto_integrals.ipynb | 753 +++++++++++++++++++++++----------- 1 file changed, 517 insertions(+), 236 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index ea68434..10fc7fd 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -23,23 +23,32 @@ "$$\n", "\\psi(\\br) = \\sum_{m=1}^M \\psi_m(\\br)\n", "$$\n", - "Atom $m$ has $N(Z_m)$ basis functions (determined by $Z_m$ and the basis set in use),\n", - "with coefficients $[c_{mi}]_{i=1}^{N(Z_m)}$:\n", + "Atom $m$ has $I(Z_m)$ basis functions (determined by $Z_m$ and the basis set in use),\n", + "with coefficients $C = [c_{mi}]_{i=1}^{I(Z_m)}$:\n", "$$\n", - "\\psi_m(\\br) = \\sum_{i=1}^{N(Z_m)} c_{mi}~ \\phi_{Z_m,i}(\\br - \\br_m)\n", + "\\psi_m(\\br) = \\sum_{i=1}^{I(Z_m)} c_{mi}~ \\phi_{Z_m,i}(\\br - \\br_m)\n", "$$\n", - "\n", - "Each function $\\phi_{z,i}$ is defined by the basis set as a fixed linear combination of primitive functions $p(\\br; \\nu)$, known as a \"contraction\":\n", + "\\psi(\\br) = \\sum_{m=1}^M \\sum_{i=1}^{I(Z_m)} c_{mi} \\phi_{Z_m,i}(\\br - \\br_m),\n", "$$\n", - "\\phi_{z,i}(\\br) = \\sum_{k=1}^{K(z,i)} d_{z,i,k} ~ p_{f(z,i,k)}(\\br; \\nu_{z,i,k})\n", + "and we can think of the task of DFT as being to determine the values $C$ which minimize\n", + "total energy. That is: the task of DFT is to determine $\\psi$, and here $\\psi$ is \n", + "specified by $C$, so the task is to determine $C$, for example by iteratively solving\n", + "Kohn-Sham equations using the self-consistent field (SCF) method.\n", + "\n", + "\n", + "\n", + "Each function $\\phi_{Z,i}$ is defined by the basis set as a fixed linear combination \n", + "of primitive functions $p(\\br; \\nu)$, known as a \"contraction\":\n", "$$\n", - "The values of $d,\\nu$ and the function type $f$ are read from standard basis sets.\n", + "\\forall_{i=1}^{I(Z)}: \\phi_{Z,i}(\\br) = \\sum_{k=1}^{K(Z,i)} d_{Z,i,k} ~ p_{f(Z,i,k)}(\\br; \\nu_{Z,i,k})\n", + "$$\n", + "The values of $d,\\nu$ and the function type $f$ are read from standard tables of basis sets.\n", + "In general the lengths $K(z,i)$ of the contractions have been pre-optimised alongside the contraction coefficients $d_{z,i,k}$ and the primitive exponents $\\alpha_\\mu$ to best approximate atomic orbitals. A range of Gaussian basis sets covering the periodic table with different compute-time-vs-accuracy tradeoffs are available from the [basis set exchange](https://www.basissetexchange.org/). We use their python API in this project to provide programmatic access to these basis sets.\n", "As these functions $\\phi$ are often taken as approximations of atomic orbitals, \n", "this is referred to as the linear combination of atomic orbitals (LCAO) method in the literature.\n", - "In general the lengths $K(z,i)$ of the contractions have been pre-optimised alongside the contraction coefficients $d_{z,i,k}$ and the primitive exponents $\\alpha_\\mu$ to best approximate atomic orbitals. A range of Gaussian basis sets covering the periodic table with different compute-time-vs-accuracy tradeoffs are available from the [basis set exchange](https://www.basissetexchange.org/). We use their python API in this project to provide programmatic access to these basis sets.\n", "\n", "In this, we will consider only the function type \"GTO\", for Gaussian-type Orbital,\n", "where the parameter packet $\\nu$ comprises three non-negative integers $(l,m,n)$, \n", @@ -47,24 +56,25 @@ "and a real value $\\alpha$, the \"exponent\".\n", "The primitive is\n", "$$\n", + "\\def\\normp{N}\n", "\\def\\pgto{p_{\\text{GTO}}}\n", - "\\pgto(\\br; \\nu) = \\pgto(\\br; l,m,n,\\alpha) = N(l,m,n,\\alpha) ~ x^l y^m z^n \\exp(-\\alpha\\|\\br\\|^2)\n", + "\\pgto(\\br; \\nu) = \\pgto(\\br; l,m,n,\\alpha) = \\normp(l,m,n,\\alpha) ~ x^l y^m z^n \\exp(-\\alpha\\|\\br\\|^2)\n", "$$\n", - "where the normalizing constant $N(l,m,n,\\alpha)$ is a function of $\\alpha$ and $(l, m, n)$\n", + "where the normalizing constant $\\normp(l,m,n,\\alpha)$ is a function of $\\alpha$ and $(l, m, n)$\n", "and is chosen so that the function integrates to 1, as derived later in this notebook.\n", - "In the following, as we are dealing only with GTO, we will simply write $p(\\br;\\nu)$ or $p(\\br;l,m,n,\\alpha).$\n", + "In the following, as we are dealing only with GTO, we will simply write $p$ instead of $\\pgto$.\n", "\n", "Noting that a linear combination (LC) of LCs is just another LC, we will often \n", "contract the two sets of coefficients, writing\n", "$$\n", - "\\psi_m(\\br) = \\sum_{i=1}^{N(Z_m)} c_{mi} \\sum_{k=1}^{K(z,i)} d_{Z_m,i,k} ~ p(\\br - \\br_m; \\nu_{Z_m,i,k})\n", + "\\psi_m(\\br) = \\sum_{i=1}^{I(Z_m)} c_{mi} \\sum_{k=1}^{K(z,i)} d_{Z_m,i,k} ~ p(\\br - \\br_m; \\nu_{Z_m,i,k})\n", "$$\n", "as\n", "$$\n", - "\\psi_m(\\br) = \\sum_{j=1}^{N_m} a_{mj}~ p(\\br - \\br_m; \\nu_{mj})\n", + "\\psi_m(\\br) = \\sum_{j=1}^{I_m} a_{mj}~ p(\\br - \\br_m; \\nu_{mj})\n", "$$\n", - "where $N_m$ is just the total number of different $\\nu$ values in the basis set for atom $Z_m$.\n", - "For most basis sets, this will mean $N_m = \\sum_i K(Z_m,i)$.\n", + "where $I_m$ is just the total number of different $\\nu$ values in the basis set for atom $Z_m$.\n", + "For most basis sets, this will mean $I_m = \\sum_i K(Z_m,i)$.\n", "\n", "### This notebook\n", "\n", @@ -74,7 +84,7 @@ "\\def\\op{\\mathcal{Q}}\n", "\\langle\\psi|\\op|\\psi\\rangle = \\int \\int \\psi(\\br_1) ~\\op \\psi(\\br_2) ~g(\\br_1, \\br_2) d \\br_1 d \\br_2\n", "$$\n", - "where $\\op\\psi$ is an transformation of function $\\psi$ by an operator $\\op$, such as gradient $\\nabla$, and the function $g$ is some function of a pair of points, e.g. $g(\\mathbf r, \\mathbf s) = \\|\\mathbf r - \\mathbf s\\|^{-1}$.\n", + "where $\\op\\psi$ is a transformation of function $\\psi$ by an operator $\\op$, such as gradient $\\nabla$, and the function $g$ is some function of a pair of points, e.g. $g(\\mathbf r, \\mathbf s) = \\|\\mathbf r - \\mathbf s\\|^{-1}$.\n", "Such integrals can be written in terms of the per-atom (or \"per-center\") functions $\\psi_m$\n", "$$\n", "\\langle\\psi|\\op|\\psi\\rangle = \\sum_{m_1=1}^M \\sum_{m_2=1}^M \\int \\int \\psi_{m_1}(\\br_1) ~\\op \\psi_{m_2}(\\br_2) ~g(\\br_1, \\br_2) d \\br_1 d \\br_2\n", @@ -82,7 +92,7 @@ "and then in terms of the primitives $p$, where again $\\op p$ is the operator $\\op$ applied to $p(\\br;...)$.\n", "$$\n", "\\langle\\psi|Q|\\psi\\rangle = \\sum_{m_1=1}^M \\sum_{m_2=1}^M \n", - " \\sum_{j_1=1}^{N_{m_1}} \\sum_{j_2=1}^{N_{m_2}} \n", + " \\sum_{j_1=1}^{I_{m_1}} \\sum_{j_2=1}^{I_{m_2}} \n", " a_{m_1,j_1} a_{m_2,j_2} \n", " \\int \\int p(\\br_1 - \\br_{m_1}; \\nu_{m_1,j_1}) ~\\op p(\\br_2 - \\br_{m_2}; \\nu_{m_2,j_2}) ~ g(\\br_1, \\br_2) d \\br_1 d \\br_2\n", "$$\n", @@ -90,7 +100,8 @@ "$$\n", "\\def\\bB{\\mathbf B}\n", "\\int \\int p(\\br_1 - \\bA; \\nu_A) ~\\op p(\\br_2 - \\bB; \\nu_B) ~g(\\br_1, \\br_2) ~d \\br_1 d \\br_2\n", - "$$" + "$$\n", + "We will describe how to do so in the following, but first let's briefly look at the basis functions for a simple example." ] }, { @@ -100,23 +111,38 @@ "## Basis set for a single-atom molecule\n", "\n", "Before deriving the integrals, we use the `basisset` function to build the atomic orbitals of a single oxygen atom $M=1$, $Z_1 = 8$, illustraiting typical values for the numbers of orbitals and consequent numbers of primitives.\n", - "The `Basis` object built by `basisset` consists of a list of `Orbital` objects which are defined by a set of `coefficients` and corresponding `Primitive` objects." + "The `Basis` object built by `basisset` consists of a list of `Orbital` objects which are defined by a set of `coefficients` and corresponding `Primitive` objects.\n", + "\n", + "A Basis set should define the following quantities:\n", + "\n", + "For each atomic number $Z$, the number of basis functions, or \"orbitals\" is $I(Z)$.\n", + "\n", + "For each basis function $i \\in \\{1..I(Z)\\}$, the number of primitives is $K(Z, i)$." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The sto-3g basis for Z=8 has I(Z)=5\n" + ] + } + ], "source": [ "import numpy as np\n", "from pyscf_ipu.experimental.structure import Structure\n", "from pyscf_ipu.experimental.basis import basisset\n", "\n", + "Z = 8\n", "basisname = \"sto-3g\"\n", - "oxygen = Structure(atomic_number=np.array([8]), position=np.zeros(3))\n", + "oxygen = Structure(atomic_number=np.array([Z]), position=np.zeros(3))\n", "basis = basisset(oxygen, basisname)\n", - "basis.num_orbitals" + "print(f'The {basisname} basis for {Z=} has I(Z)={basis.num_orbitals}')" ] }, { @@ -126,16 +152,92 @@ "The number of atomic orbitals follows from the [Aufbau principle](https://en.wikipedia.org/wiki/Aufbau_principle). Applying this to a single Oxygen atom predicts the electron configuration as $1s^2 2s^2 2p^4$ which keeping in mind that the $2p$ atomic orbitals will consist of three orbitals we arrive at five atomic orbitals for a single oxygen atom.\n", "\n", "This rule applies when using a minimal basis set such as `\"sto-3g\"` which uses a\n", - "contraction of 3 Gaussians to approximate each atomic orbital. From this we expect a tottal of 15 primitives in the basis set for a single oxygen atom:" + "contraction of 3 Gaussians to approximate each atomic orbital. From this we expect a total of 15 primitives in the basis set for a single oxygen atom:" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "sto-3g for Z=8 has 5 basis functions/orbitals\n", + "phi_(8,0)= 0.154 * r**[0 0 0] * exp(-130.71 r**2) + 0.535 * r**[0 0 0] * exp(-23.81 r**2) + 0.445 * r**[0 0 0] * exp(-6.44 r**2)\n", + "phi_(8,1)= -0.100 * r**[0 0 0] * exp(-5.03 r**2) + 0.400 * r**[0 0 0] * exp(-1.17 r**2) + 0.700 * r**[0 0 0] * exp(-0.38 r**2)\n", + "phi_(8,2)= 0.156 * r**[1 0 0] * exp(-5.03 r**2) + 0.608 * r**[1 0 0] * exp(-1.17 r**2) + 0.392 * r**[1 0 0] * exp(-0.38 r**2)\n", + "phi_(8,3)= 0.156 * r**[0 1 0] * exp(-5.03 r**2) + 0.608 * r**[0 1 0] * exp(-1.17 r**2) + 0.392 * r**[0 1 0] * exp(-0.38 r**2)\n", + "phi_(8,4)= 0.156 * r**[0 0 1] * exp(-5.03 r**2) + 0.608 * r**[0 0 1] * exp(-1.17 r**2) + 0.392 * r**[0 0 1] * exp(-0.38 r**2)\n", + "Found 15 unique primitives for Z=8 in sto-3g\n" + ] + } + ], + "source": [ + "print(f'{basisname} for {Z=} has {len(basis.orbitals)} basis functions/orbitals')\n", + "for i,o in enumerate(basis.orbitals):\n", + " terms = (f'{coef:.3f} * r**{p.lmn} * exp(-{p.alpha:.2f} r**2)' for coef,p in zip(o.coefficients,o.primitives))\n", + " print(f'phi_({Z},{i})=', ' + '.join(terms))\n", + "\n", + "# Now count unique prims\n", + "prims = set()\n", + "for o in basis.orbitals:\n", + " for p in o.primitives:\n", + " prims = set.union(prims, {(*p.lmn.tolist(), float(p.alpha))})\n", + "print(f'Found {len(prims)} unique primitives for {Z=} in {basisname}')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For a basis set such as `6-31+G` we have a different number of primitives in each basis function: " ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The 6-31+G basis for Z=8 has I(Z)=13 basis functions/orbitals\n", + "phi_(8,0)= 0.002 * r**[0 0 0] * exp(-5484.67 r**2) + 0.014 * r**[0 0 0] * exp(-825.23 r**2) + 0.068 * r**[0 0 0] * exp(-188.05 r**2) + 0.233 * r**[0 0 0] * exp(-52.96 r**2) + 0.470 * r**[0 0 0] * exp(-16.90 r**2) + 0.359 * r**[0 0 0] * exp(-5.80 r**2)\n", + "phi_(8,1)= -0.111 * r**[0 0 0] * exp(-15.54 r**2) + -0.148 * r**[0 0 0] * exp(-3.60 r**2) + 1.131 * r**[0 0 0] * exp(-1.01 r**2)\n", + "phi_(8,2)= 1.000 * r**[0 0 0] * exp(-0.27 r**2)\n", + "phi_(8,3)= 1.000 * r**[0 0 0] * exp(-0.08 r**2)\n", + "phi_(8,4)= 0.071 * r**[1 0 0] * exp(-15.54 r**2) + 0.340 * r**[1 0 0] * exp(-3.60 r**2) + 0.727 * r**[1 0 0] * exp(-1.01 r**2)\n", + "phi_(8,5)= 0.071 * r**[0 1 0] * exp(-15.54 r**2) + 0.340 * r**[0 1 0] * exp(-3.60 r**2) + 0.727 * r**[0 1 0] * exp(-1.01 r**2)\n", + "phi_(8,6)= 0.071 * r**[0 0 1] * exp(-15.54 r**2) + 0.340 * r**[0 0 1] * exp(-3.60 r**2) + 0.727 * r**[0 0 1] * exp(-1.01 r**2)\n", + "phi_(8,7)= 1.000 * r**[1 0 0] * exp(-0.27 r**2)\n", + "phi_(8,8)= 1.000 * r**[0 1 0] * exp(-0.27 r**2)\n", + "phi_(8,9)= 1.000 * r**[0 0 1] * exp(-0.27 r**2)\n", + "phi_(8,10)= 1.000 * r**[1 0 0] * exp(-0.08 r**2)\n", + "phi_(8,11)= 1.000 * r**[0 1 0] * exp(-0.08 r**2)\n", + "phi_(8,12)= 1.000 * r**[0 0 1] * exp(-0.08 r**2)\n", + "Found 26 unique primitives for Z=8 in 6-31+G\n" + ] + } + ], "source": [ - "basis.num_primitives" + "basisname = \"6-31+G\"\n", + "oxygen = Structure(atomic_number=np.array([Z]), position=np.zeros(3))\n", + "basis = basisset(oxygen, basisname)\n", + "print(f'The {basisname} basis for {Z=} has I(Z)={basis.num_orbitals} basis functions/orbitals')\n", + "\n", + "for i,o in enumerate(basis.orbitals):\n", + " terms = (f'{coef:.3f} * r**{p.lmn} * exp(-{p.alpha:.2f} r**2)' for coef,p in zip(o.coefficients,o.primitives))\n", + " print(f'phi_({Z},{i})=', ' + '.join(terms))\n", + "\n", + "# Now count unique prims\n", + "prims = set()\n", + "for o in basis.orbitals:\n", + " for p in o.primitives:\n", + " prims = set.union(prims, {(*p.lmn.tolist(), float(p.alpha))})\n", + "print(f'Found {len(prims)} unique primitives for {Z=} in {basisname}')" ] }, { @@ -147,9 +249,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAUCAYAAACEYr13AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAABZklEQVR4nKXTv2tVQRDF8c+LFkaLCKYQBFFQ0yqipLLyB3b+A0khaJkqjdUwAUkT1E6QNHZaBBHsBVFQTGGX1FoEIihKgiEQn8Xb4ua+vc8i0xwYZr57Drvb6/f7DlJjB9rG4VozM5/jNs5GxHZmXsYq7kXEcnO2146QmVfwCfMR8ajRf4VpnI+IrVERHuI3nrb6iziJuU4HmXkB61iOiPuVaGs4WqL9rTm4ix5eVpzBC5zGja4I17GHjx2AD0WHAZl5DBexFhHbHYDPRa/VHJzCIWx0LIuIX9gxiDEEOFH0Zxeg1A9M1gB/ih75D2C8MbsPsNlyMlSZOYbjjdl9gA18x9SI06cMrvnLECAi+niHycw81wGYLvq25gBWit7qANw0eCevRwE2MdvezMwJ3MGbiPhWBUTELp7gamZeajFmDW5oqdms/cbH+IqFxunjeICViHg/EhARO5jBannecAbPMN+e/wf9OWdT51stdwAAAABJRU5ErkJggg==", + "text/latex": [ + "$\\displaystyle \\left( \\right)$" + ], + "text/plain": [ + "()" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "from pyscf_ipu.experimental.mesh import uniform_mesh, molecular_orbitals\n", "from pyscf_ipu.experimental.plot import plot_volume\n", @@ -161,175 +278,246 @@ "orbitals = np.asarray(orbitals)\n", "\n", "# Mapping between orbital label -> index in basis set\n", - "orbital_idx = dict(zip([\"1s\", \"2s\", \"2px\", \"2py\", \"2pz\"], range(5)))\n", - "plot_volume(oxygen, orbitals[:, orbital_idx[\"2px\"]], axes).spin(4)" + "# TODO: what is this mapping for 6-31+G?\n", + "#orbital_idx = dict(zip([\"1s\", \"2s\", \"2px\", \"2py\", \"2pz\"], range(5)))\n", + "plot_volume(oxygen, orbitals[:, 5], axes)\n", + "()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "$$\n", - "\\def\\br{\\mathbf{r}}\n", - "\\def\\bA{\\mathbf{A}}\n", - "$$\n", - "\n", - "The above visualisation uses the formulas defined earlier to numerically evaluate\n", - "each atomic orbital from a linear combintation of primitive Gaussians. Introducing\n", - "the basis set allows us to replace the problem of solving a system partial differential equations (e.g. the Kohn-Sham equations) with an algebraic system of equations that can be solved using standard matrix eigenvalue techniques.\n", - "The individual elements of the matrices in this system are single integrals over pairs of\n", - "basis functions:\n", - "$$\n", - "\\tag{5}\n", - "M_{ij} = \\int p(\\br - \\bA; \\nu_A) ~\\op p(\\br - \\bB; \\nu_B) d\\br.\n", - "$$\n", - "The operator $\\op$ in its most general definition is\n", - "a function that transforms the $\\psi(\\br)$ function to represent a physical observable.\n", - "That sounds fancy but is just a complicated way of saying we are breaking\n", - "down something we can measure (e.g. the energy, dipole moment, etc) into components\n", - "that we can evaluate through these integrals. The simplest operator is simply an \n", - "identity mapping, $\\op p(\\br) := p(\\br)$, that we name the {\\em overlap}.\n", + "## Integrals over a single primitive\n", "\n", - "## The overlap integral\n", - "\n", - "The overlap integral is defined by\n", + "The GTO primitive\n", + "$$ \n", + "p(\\br; l,m,n,\\alpha) = \\normp(l,m,n,\\alpha) ~ x^l y^m z^n e^{-\\alpha\\|\\br\\|^2}\n", "$$\n", - "\\tag{6}\n", - "S_{\\mu\\nu} = \\int p(\\br - \\br_\\mu; l_\\mu, m_\\mu, n_\\mu, \\alpha_\\mu) ~ p(\\br - \\br_\\nu; l_\\nu, m_\\nu, n_\\nu, \\alpha_\\nu) ~ d\\br.\n", + "contains a normalization $\\normp$, which should be chosen so that $p^2$ integrates to 1:\n", "$$\n", - "\n", - "\n", - "\n", - "Gaussian basis functions of the form above have a few convenient properties that help\n", - "make it easier to evaluate integrals of the form in equation (5). To show this\n", - "we start by expanding the overlap integral into its full three-dimensional form:\n", + "\\int p(\\br; l,m,n,\\alpha)^2 d\\br = 1\n", "$$\n", - "\\tag{9}\n", - "\\tilde{S}_{\\mu \\nu} = \\iiint p_\\mu(\\br) p_\\nu(\\br) dx dy dz,\n", + "That is, \n", "$$\n", - "and observing that a primitive $p_\\mu(\\br) = p(\\br - \\br_\\mu; l_\\mu, m_\\mu, n_\\mu, \\alpha_\\mu)$ can be written as a product of cartesian components:\n", + "\\normp(l,m,n,\\alpha)^2 \\int x^{2l} y^{2m} z^{2n} e^{-2\\alpha\\|\\br\\|^2} d\\br = 1\n", "$$\n", - "\\tag{10}\n", - "p_\\mu(\\br) = N_\\mu\n", - "\\left((x - x_\\mu)^{l_\\mu} e^{-\\alpha_\\mu (x - x_\\mu)^2} \\right)\n", - "\\left((y - y_\\mu)^{m_\\mu} e^{-\\alpha_\\mu (y - y_\\mu)^2} \\right)\n", - "\\left((z - z_\\mu)^{n_\\mu} e^{-\\alpha_\\mu (z - z_\\mu)^2} \\right)\n", + "We note that $x^{2l} y^{2m} z^{2n} e^{-2\\alpha\\|\\br\\|^2}$ can be written\n", "$$\n", - "we directly see that we can separate the three-dimensional integral in equation (9) as a\n", - "product of three one-dimensional integrals:\n", + "\\def\\ldp{h} % Read this \"1-D primitive\"\n", + "\\def\\ldpi{H} % read this \"1-D primitive's integral\"\n", + "x^{2l} e^{-2\\alpha x^2} \\cdot\n", + "y^{2m} e^{-2\\alpha y^2} \\cdot\n", + "z^{2n} e^{-2\\alpha z^2}\n", + "= \n", + "\\ldp(x;2l,2\\alpha) ~ \\ldp(y;2m,2\\alpha) ~ \\ldp(z;2n,2\\alpha)\n", "$$\n", - "\\tag{11}\n", - "\\tilde{S}_{\\mu \\nu} = N_\\mu N_\\nu \\tilde{S}_{\\mu \\nu}^{(x)} \\tilde{S}_{\\mu \\nu}^{(y)} \\tilde{S}_{\\mu \\nu}^{(z)}\n", + "for\n", "$$\n", - "where we introduce the one-dimensional overlap as\n", + "\\tag{defh}\n", + "\\ldp(t; 2k, \\eta) = t^{2k} e^{-\\eta t^2}\n", "$$\n", - "\\tag{12}\n", - "\\tilde{S}_{\\mu \\nu}^{(x)} = \\int_{-\\infty}^\\infty \n", - "\\left((x - x_\\mu)^{l_\\mu} e^{-\\alpha_\\mu (x - x_\\mu)^2} \\right)\n", - "\\left((x - x_\\nu)^{l_\\nu} e^{-\\alpha_\\nu (x - x_\\nu)^2} \\right) dx,\n", + "So the integral\n", "$$\n", - "and use the same definition for the y and z components.\n", - "\n", - "By convention each primitive is be normalised such that the \"self-overlap\" is one, or in other words the diagonal elements of the overlap matrix\n", - "will be all ones.\n", + "\\int x^{2l} y^{2m} z^{2n} \\exp(-2\\alpha\\|\\br\\|^2) d\\br = \\int \\ldp(x;2l,2\\alpha) ~ \\ldp(y;2m,2\\alpha) ~ \\ldp(z;2n,2\\alpha) dx dy dz\n", "$$\n", - "\\tag{13}\n", - "\\tilde{S}_{\\mu \\mu} = \\int p_\\mu(\\br)^2 d\\br = 1.\n", + "is the product of three independent integrals\n", "$$\n", - "rearranging a bit:\n", + "\\int \\ldp(x;2l,2\\alpha) dx \\cdot \n", + "\\int \\ldp(y;2m,2\\alpha) dy \\cdot\n", + "\\int \\ldp(z;2n,2\\alpha) dz\n", "$$\n", - "\\tag{14}\n", - "N_\\mu = \\left( \\tilde{S}_{\\mu \\mu}^{(x)} \\tilde{S}_{\\mu \\mu}^{(y)} \\tilde{S}_{\\mu \\mu}^{(z)} \\right)^{-\\frac12}.\n", + "Where each is of the form\n", "$$\n", - "The one-dimensional self-overlap integral is:\n", + "\\tag{defH}\n", + "H(2k, \\eta) = \\int t^{2k} e^{-\\eta t^2} dt\n", "$$\n", - "\\tag{15}\n", - "\\tilde{S}_{\\mu \\mu}^{(x)} = \\int_{-\\infty}^\\infty x^{2l_\\mu} e^{-2 \\alpha_\\mu x^2} dx.\n", - "$$\n", - "We've made use of the translation invariance property of the integral over all $x$ when shifting by the constant $x_\\mu$ in equation (15). \n", - "\n", "These one dimensional integrals have a known analytic solution [see equation 42 of gaussian integral](https://mathworld.wolfram.com/GaussianIntegral.html), but we will lean on [SymPy](https://docs.sympy.org/latest/index.html) to help us derive a formula for normalising our primitive Gaussian functions." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First, let's define the integral:" + ] + }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAO4AAAAkCAYAAACOnQbwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGli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} = \\int\\limits_{-\\infty}^{\\infty} t^{2 k} e^{- \\eta t^{2}}\\, dt$" + ], + "text/plain": [ + " ∞ \n", + " ⌠ \n", + " ⎮ 2 \n", + " ⎮ 2⋅k -η⋅t \n", + "H(2⋅k, η) = ⎮ t ⋅ℯ dt\n", + " ⌡ \n", + " -∞ " + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "import numpy as np\n", "import IPython\n", "from sympy import *\n", "\n", - "init_printing(use_unicode=True)" + "init_printing(use_unicode=True)\n", + "\n", + "eta = Symbol(\"eta\", positive=True, real=True)\n", + "k = Symbol(\"k\", integer=True, nonnegative=True)\n", + "t = Symbol(\"t\", real=True)\n", + "H = Function(\"H\")\n", + "\n", + "H_na = Integral(t**(2*k) * exp(-eta * t**2), (t, -oo, oo))\n", + "display(Eq(H(2*k, eta), H_na))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Confirm that the equation displayed is the same as that in (defH).\n", + "\n", + "And then solve it:" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 21, "metadata": {}, "outputs": [ { "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQ8AAAAXCAYAAAAV3cp8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAJdklEQVR4nO2cf7BVVRXHP4A/8Ecp4miTkwUDAk3Ek4cJKRQqmmXyQ8mmRLCZxukXYWJFZV+XJqGTAs1kDEPKm9BsRhAj0JwUUhxRJEgQKZ0i+kERQSQWkUB/rH3gvnPPOffcc+9979Hc78yd/e7Ze6+93jnfvfbaa69zux06dIgmmjCzx4GNkm5u4BijgOlAK/B24HpJCxPazQP2SZpmZjOACcAA4D/AGmCGpE2N0rOJfOje2Qo00WXQAqxv8BgnA5uALwL/TmpgZt2AK4Gl4dIHgXuB9wMXAW8CPzez0xqsaxM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Imeh6RDZvY0cJWZ9ZP0WkzZW4Db8AlwaQ73aCg+IbZIOmBmV+DHaovM7CJJZUds4V2JyaS8qRnTv8xAhiPLQXjQLikBKTqizkzQaUDMoxadm4ihElcpwL0uiPHAQeDReEWBuRihjP+R5zEQD66sl7Q/qWc4ZuuPp8gmnbUvxjPULsMz4aJ+k4OyB4BngKkJAaOt0YQ3s+NwN319NCFCEsuH8X3xMjMbkfDQo9OGtHNqOOI5Ja3i0XFo2gp/afgfyh5Ig1GLzk0kI42rRbnXUJjZOPyoGiA6qh5R8nLhTknTQ9tuoe1z8ZOraudiDGX8jyZcni3LkNB+fUp69mJ8P3ld7HqfUPbAXXolfKaUtB8MHEssAChpMx4EOgV4zMxOj40zGD9eSw0Q4RPxIMlbj7LEoAhmdgr+QH4q6Q8Z8huBQjo3kYk0rhblXqPRgnvVk3GDB57zE10rzY0ZBrwDzxiOo9q5CKTzv1s9fwzI/IdbZgJDJXVY9N/MTsXz9++W9OWCMu4DrgeGSHopVvcF4LvASEmra1S3bsjSuYlsdBZXGw0zmwnMAPpKygzuVyEzkf/1/jGg2fh7DbfVWW4ljMTTa++pQUYr/tZlu8BjSA2fASzuSoYjIFHnJnKhs7jaaIwHflVHw5HK/7p6HmGwUcBo4Dt5U9U7GyEx6HVgnaThsbpB+HsVC1WnH8WpB7J0biIfjkaudjSy+F9343E0Irz0tAa4V9LnOlufPDgadW7i/wtN49FEE00UQvMHkJtooolC+B8c22f8qZDUrAAAAABJRU5ErkJggg==", "text/latex": [ - "$\\displaystyle \\tilde{S}_{\\mu \\mu} = \\int\\limits_{-\\infty}^{\\infty} t^{2 k} e^{- 2 \\alpha_{\\mu} t^{2}}\\, dt = \\left(\\frac{1}{2 \\alpha_{\\mu}}\\right)^{k + \\frac{1}{2}} \\Gamma\\left(k + \\frac{1}{2}\\right)$" + "$\\displaystyle H{\\left(2 k,\\eta \\right)} = \\eta^{- k - \\frac{1}{2}} \\Gamma\\left(k + \\frac{1}{2}\\right)$" ], "text/plain": [ - "" + " -k - 1/2 \n", + "H(2⋅k, η) = η ⋅Γ(k + 1/2)" ] }, - "execution_count": 9, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ - "a = Symbol(\"alpha_mu\", positive=True, real=True)\n", - "k = Symbol(\"k\", integer=True, nonnegative=True)\n", - "t, x, y, z = symbols(\"t x y z\", real=True)\n", - "\n", - "self_overlap1d = Integral(t**(2*k) * exp(-2 * a * t**2), (t, -oo, oo))\n", - "output = r'\\tilde{S}_{\\mu \\mu} = '\n", - "output += latex(self_overlap1d) \n", - "output += ' = '\n", - "output += latex(simplify(self_overlap1d.doit()))\n", - "IPython.display.Math(output)" + "display(Eq(H(2*k, eta), H_na.doit().simplify()))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And, recalling that we are looking for the normalization $\\normp(l,m,n,\\alpha)$, which is given by\n", + "$$\n", + "\\normp(l,m,n,\\alpha) = \\left(\\int x^{2l} y^{2m} z^{2n} \\exp(-2\\alpha\\|\\br\\|^2) d\\br\\right)^{-\\frac12} = \\biggl(H(2l,2\\alpha)~H(2m,2\\alpha)~H(2n,2\\alpha)\\biggr)^{-\\frac12}\n", + "$$" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 22, "metadata": {}, "outputs": [ { "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlMAAAAmCAYAAADgMR6zAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAASBUlEQVR4nO2debRdVX3HP4EwJxSBMpVQRgkUeffxCqgQIC0iRa2U0gIqk1JkKBpiEQHhl68ESYhggOKyuloSEOpitExFRIbIZJgeM2kYInMUEDAEAoH0j9++vPNO7rv3nDsP+7PWW+e+ffbe53fP/d5z9/Dbvz1q2bJlRHoDSaPNbGmd65wCHAQ8ABwNfBI4E3gHmGxm99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D9gbN2J33P9tsqQNw2cznqHduSPtzyTg0sS0fkWiDiMtZBI59ZqTmUQdRhgamSo6nz+UOHcFcBM+pXVZjjp/CUyXtE6Ylts+pD+coWwx72AirQAsAR5LpS0iwzRdqTpDA21jsjWmBvF9i06SdAkwA3gZ2FLSVimHxgn4+28bzGyBpOn4yF56dK+a+l7FRx+zci2wj6Tn8Onf/fH7NBfX3OTo5NkZBOfcrc3syIqZU0QdRppNLXrNStRhpEiyMfW4mb2bOHcn8AY+v5t512oze0TSXHwO+AK84TPfzD4ayZF0GL5qcDMzW5Ao3hfyJrem6cenGZem8j2UFF2GOpORbPuB94HHK5U3s2clnQIcD3wb9yfbE7gOuAtfblvchfof8GXgbYWZ/VLSGpI2Td2bZlx7GR64MckCfH/HSGexN+7nURVRh5EmU5NeG0HUYfcyLAJ6vZC0N+4jtW2pFXyShLfI+1KNpFquWVOddSh/LPBFM9srb9lIJBKJRCKdS+69+bIQVk1cgE+llWIf4Nh6NaTqVGet5d/H9+uJRCKRSCTSQzRkZCoSiUQikUikV2jIyFQkEolEIpFIr/D/ZcTX+h+I8P4AAAAASUVORK5CYII=", "text/latex": [ - "$\\displaystyle N_\\mu^2 = \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 l} e^{- 2 \\alpha_{\\mu} t^{2}}\\, dt\\right) \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 m} e^{- 2 \\alpha_{\\mu} t^{2}}\\, dt\\right) \\int\\limits_{-\\infty}^{\\infty} t^{2 n} e^{- 2 \\alpha_{\\mu} t^{2}}\\, dt \\quad = \\quad \\Large \\left(\\frac{1}{2 \\alpha_{\\mu}}\\right)^{L + \\frac{3}{2}} \\Gamma\\left(l + \\frac{1}{2}\\right) \\Gamma\\left(m + \\frac{1}{2}\\right) \\Gamma\\left(n + \\frac{1}{2}\\right)$" + "$\\displaystyle \\frac{1}{N^{2}{\\left(l,m,n,\\alpha \\right)}} = \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 l} e^{- 2 \\alpha t^{2}}\\, dt\\right) \\left(\\int\\limits_{-\\infty}^{\\infty} t^{2 m} e^{- 2 \\alpha t^{2}}\\, dt\\right) \\int\\limits_{-\\infty}^{\\infty} t^{2 n} e^{- 2 \\alpha t^{2}}\\, dt$" ], "text/plain": [ - "" + " ∞ ∞ ∞ \n", + " ⌠ ⌠ ⌠ \n", + " ⎮ 2 ⎮ 2 ⎮ 2 \n", + " 1 ⎮ 2⋅l -2⋅α⋅t ⎮ 2⋅m -2⋅α⋅t ⎮ 2⋅n -2⋅α⋅t \n", + "────────────── = ⎮ t ⋅ℯ dt⋅⎮ t ⋅ℯ dt⋅⎮ t ⋅ℯ dt\n", + " 2 ⌡ ⌡ ⌡ \n", + "N (l, m, n, α) -∞ -∞ -∞ " ] }, - "execution_count": 6, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjEAAAAhCAYAAAAoJvpGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAQ2klEQVR4nO2dfbRVxXXAfyAJIOIXSc0HCiLRaNF34Zkuo4FIBRPMB2BwmTQ1wcQmJSYGrC4rxm53NCn5QDBdqbY19ZFUm1SxJBFjKmrwA9RI81D8KtVqUiNJEEWIIaB9/WPP4c0779x7z7137j3vvsxvLdbROXNm5s3suWefPXvPDOnp6SESiUQikUik3RhWdAPyoKrTgAuATuAtwNki0lVooyIDAlVdAnSKyMyi2xKJRCKR1tIWSgywH7AJ+Lb7F4kklIDugtvQVqjqucCngfEu6VHgChFZnZH3GmAX8CvgdOAo4PfA/cDFIrKpFW2ORCKRLIYW3YA8iMitIrJYRG4C/q/o9kQGFCXgZ9UyqWqXql7W9NYUWHcN9fwvcBEwBTgeuBNYparHpcobAnwQWAWcDPw9cCLwp8CrwBpVPThQ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{2}{\\left(l,m,n,\\alpha \\right)}} = \\left(\\frac{1}{2 \\alpha}\\right)^{l + m + n + \\frac{3}{2}} \\Gamma\\left(l + \\frac{1}{2}\\right) \\Gamma\\left(m + \\frac{1}{2}\\right) \\Gamma\\left(n + \\frac{1}{2}\\right)$" + ], + "text/plain": [ + " l + m + n + 3/2 \n", + " 1 ⎛ 1 ⎞ \n", + "────────────── = ⎜───⎟ ⋅Γ(l + 1/2)⋅Γ(m + 1/2)⋅Γ(n + 1/2)\n", + " 2 ⎝2⋅α⎠ \n", + "N (l, m, n, α) " + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "N = Function(\"N\")\n", + "a = Symbol(\"alpha\", positive=True, real=True)\n", + "l,m,n = symbols(\"l m n\", integer=True, nonnegative=True)\n", + "\n", + "H_l = H_na.subs({k:l, eta:2*a})\n", + "H_m = H_na.subs({k:m, eta:2*a})\n", + "H_n = H_na.subs({k:n, eta:2*a})\n", + "\n", + "N_val = (H_l * H_m * H_n)\n", + "display(Eq(N(l,m,n,a)**(-2), N_val))\n", + "display(Eq(N(l,m,n,a)**(-2), N_val.doit().simplify()))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We might finally ask - what is $H$ for odd arguments? And we can see: the integrand is odd, so it is zero.\n", + "And just in case, let's check: " + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAkCAYAAADM3nVnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAI/0lEQVR4nO2debAcVRWHvxACCImkQAKiQQuEhBSSF6IBDVsKiaCoVEQFJCzlUgoFhgDFpvzyE5AELEhCgSwuCYhlQYVFEKsQFKMCiiRhkbAqCaBsCVsWKZbnH+d20m94M2/mpefN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F+c9zWpLU1WwHzJe3TV+eVdFrRx0y/ZRiwMJ9Lye3fjZiwmY+UNdyfTfBBHk3lTlX275jKx6B+BWmVD9KRyr6I1/cFmW+wPqyqfDv9DauyP0ts5pWhI5WN9OcUivVBsiDKRNsb5CNZtocQc/hWEbPCqyuI7fcB2RLbVlmQLVPZtpMlG0HSatsPALvaniTp+so2abrH3VVWbLYNKaDwOBEq/oKkNVl726cSSxCgq4PecH8W7YNIetL2bcTw8DgiLJ1hYlHg5ZJWQm0LMiS33SoLkl3cc23vAqwE/tnPl4GeAvwWmGf7duABwiH/EJFhHiRpuxbK1wjnEU/sebZ/TUxj2ZfwM54GhtPVgrRLfx5L5GFm294PWExEDScQQ6s103pqRUoG57ZblQeZT0RKVqZSrDXT/RJJtxFh3HnEjXQCkejcGbgdOKZ10jWGpKuIIdAzRNDhKEIxxhPJ2WWSluTat0V/SnqSyFnNIRTjJGAHIj+1RzYPC2osubU9mrWRj+0l/bt5IpeUtCe1LEg7DLFKSlrKGh8kZUWnEctLjyXGjxBvulj+7q+WlKz/5J30l4jJcqvTqrMjUv2i8lU9Je9Vuvggtm8GDqpoc4ikeUWetHx/b0l/odIHmUxMYHsNuB/4UhOUo3x/b0m/oUseJK0JOKL7pt3Ti+Wga97fC1yQ1j7PlrQ4HS97f++LjchRUtIMivj3BzNpbDlo+f7ekn5DzVePNoM0fPoJ8DliaeZXgL2AHxERs6mSbuhToUpKqtDnClJS0p8o+hUvJSXrFf8HDd9X9cHn/0IAAAAASUVORK5CYII=", + "text/latex": [ + "$\\displaystyle \\int\\limits_{-\\infty}^{\\infty} t^{2 k + 1} e^{- \\eta t^{2}}\\, dt = 0$" + ], + "text/plain": [ + "∞ \n", + "⌠ \n", + "⎮ 2 \n", + "⎮ 2⋅k + 1 -η⋅t \n", + "⎮ t ⋅ℯ dt = 0\n", + "⌡ \n", + "-∞ " + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "l,m,n,L = symbols(\"l m n L\", integer=True, nonnegative=True)\n", - "sx = self_overlap1d.subs(k, l)\n", - "sy = self_overlap1d.subs(k, m)\n", - "sz = self_overlap1d.subs(k, n)\n", - "self_overlap = sx * sy * sz\n", - "\n", - "self_overlap_expanded = simplify(self_overlap.doit()).subs(l+m+n, L)\n", - "output = r'N_\\mu^2 = '\n", - "output += latex(self_overlap) \n", - "output += ' \\quad = \\quad \\Large '\n", - "output += latex(self_overlap_expanded)\n", - "IPython.display.Math(output)" + "H_odd = Integral(t**(2*k + 1) * exp(-eta * t**2), (t, -oo, oo))\n", + "display(Eq(H_odd, H_odd.doit()))" ] }, { @@ -341,7 +529,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -350,19 +538,19 @@ "text": [ "Help on function _lambdifygenerated:\n", "\n", - "_lambdifygenerated(l, m, n, alpha_mu)\n", + "_lambdifygenerated(l, m, n, alpha)\n", " Created with lambdify. Signature:\n", " \n", - " func(l, m, n, alpha_mu)\n", + " func(l, m, n, alpha)\n", " \n", " Expression:\n", " \n", - " (1/(2*alpha_mu))**(L + 3/2)*gamma(l + 1/2)*gamma(m + 1/2)*gamma(n + 1/2)\n", + " (1/(2*alpha))**(l + m + n + 3/2)*gamma(l + 1/2)*gamma(m + 1/2)*gamma(n + 1/2)\n", " \n", " Source code:\n", " \n", - " def _lambdifygenerated(l, m, n, alpha_mu):\n", - " return ((1/2)/alpha_mu)**(L + 3/2)*gamma(l + 1/2)*gamma(m + 1/2)*gamma(n + 1/2)\n", + " def _lambdifygenerated(l, m, n, alpha):\n", + " return ((1/2)/alpha)**(l + m + n + 3/2)*gamma(l + 1/2)*gamma(m + 1/2)*gamma(n + 1/2)\n", " \n", " \n", " Imported modules:\n", @@ -371,7 +559,7 @@ } ], "source": [ - "f = lambdify((l,m,n, a), self_overlap_expanded, modules=\"scipy\")\n", + "f = lambdify((l,m,n, a), N_val.doit().simplify(), modules=\"scipy\")\n", "help(f)" ] }, @@ -379,50 +567,173 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This implementation isn't quite right since it doesn't correctly substitute that $L=l+m+n$ but this\n", - "is close enough to allow us to return our attention back to the general overlap elements in equation (11). To make progress we start by rewriting the product of two\n", + "$$\n", + "\\def\\br{\\mathbf{r}}\n", + "\\def\\bA{\\mathbf{A}}\n", + "$$\n", + "\n", + "## Integrals over sets of basis functions\n", + "\n", + "The above visualisation uses the formulas defined earlier to numerically evaluate\n", + "each atomic orbital from a linear combintation of primitive Gaussians. Introducing\n", + "the basis set allows us to replace the problem of solving a system partial differential equations (e.g. the Kohn-Sham equations) with an algebraic system of equations that can be solved using standard matrix eigenvalue techniques.\n", + "The individual elements of the matrices in this system are single integrals over pairs of\n", + "primitives:\n", + "$$\n", + "\\tag{5}\n", + "M_{AB} = \\int p(\\br - \\bA; \\nu_A) ~\\op p(\\br - \\bB; \\nu_B) d\\br.\n", + "$$\n", + "The operator $\\op$ in its most general definition is\n", + "a function that transforms the $\\psi(\\br)$ function to represent a physical observable.\n", + "That sounds fancy but is just a complicated way of saying we are breaking\n", + "down something we can measure (e.g. the energy, dipole moment, etc) into components\n", + "that we can evaluate through these integrals. \n", + "\n", + "## The overlap integral\n", + "\n", + "The simplest operator $\\op$ is simply an \n", + "identity mapping, $\\op p(\\br) := p(\\br)$, used in conjunction with the trivial $g(\\br_1, \\br_2) = 1$, that we name the _overlap integral_:\n", + "$$\n", + "\\tag{6}\n", + "S_{\\mu\\nu} = \\int p(\\br - \\br_\\mu; l_\\mu, m_\\mu, n_\\mu, \\alpha_\\mu) ~ p(\\br - \\br_\\nu; l_\\nu, m_\\nu, n_\\nu, \\alpha_\\nu) ~ d\\br.\n", + "$$\n", + "\n", + "Gaussian basis functions of the form above have a few convenient properties that help\n", + "make it easier to evaluate integrals of the form in equation (5). To show this\n", + "we start by expanding the overlap integral into its full three-dimensional form:\n", + "$$\n", + "\\tag{9}\n", + "\\tilde{S}_{\\mu \\nu} = \\iiint p_\\mu(\\br) p_\\nu(\\br) dx dy dz,\n", + "$$\n", + "and observing that a primitive $p_\\mu(\\br) = p(\\br - \\br_\\mu; l_\\mu, m_\\mu, n_\\mu, \\alpha_\\mu)$ can be written as a product of Cartesian components:\n", + "$$\n", + "\\tag{10}\n", + "p_\\mu(\\br) = N_\\mu\n", + "h(x - x_\\mu; l_\\mu, \\alpha_\\mu)\n", + "h(y - y_\\mu; m_\\mu, \\alpha_\\mu)\n", + "h(z - z_\\mu; n_\\mu, \\alpha_\\mu)\n", + "$$\n", + "where we are using $h$ from (defh), but not assuming that $l,m,n$ are even.\n", + "We directly see that we can separate the three-dimensional integral in equation (9) as a\n", + "product of three one-dimensional integrals:\n", + "$$\n", + "\\tag{11}\n", + "\\tilde{S}_{\\mu \\nu} = N_\\mu N_\\nu \\tilde{S}_{\\mu \\nu}^{(x)} \\tilde{S}_{\\mu \\nu}^{(y)} \\tilde{S}_{\\mu \\nu}^{(z)}\n", + "$$\n", + "where we introduce the one-dimensional overlap as\n", + "$$\n", + "\\tag{12}\n", + "\\def\\twelve{\n", + "\\tilde{S}_{\\mu \\nu}^{(x)} = \\int_{-\\infty}^\\infty \n", + "\\left((t - x_\\mu)^{l_\\mu} e^{-\\alpha_\\mu (t - x_\\mu)^2} \\right)\n", + "\\left((t - x_\\nu)^{l_\\nu} e^{-\\alpha_\\nu (t - x_\\nu)^2} \\right) dt\n", + "}\n", + "\\twelve,\n", + "$$\n", + "and use the same definition for the y and z components. We note that if $\\br_\\mu=\\br_\\nu$, we have the normalization integral from (defH), because we can gather the $t - x_\\mu$ terms\n", + "$$\n", + "\\tilde{S}_{\\mu \\nu}^{(x)} = \\int_{-\\infty}^\\infty \n", + "(t - x_\\mu)^{l_\\mu + l\\nu} e^{-(\\alpha_\\mu + \\alpha_\\nu) (t - x_\\mu)^2} dt\n", + "$$\n", + "and substitite $u = t - x_\\mu$, $du = dt$ to get\n", + "$$\n", + "\\tilde{S}_{\\mu \\nu}^{(x)} = \\int_{-\\infty}^\\infty \n", + "u^{l_\\mu + l\\nu} e^{-(\\alpha_\\mu + \\alpha_\\nu) u^2} du = H(l_\\mu + l_\\nu, \\alpha_\\mu + \\alpha_\\nu)\n", + "$$\n", + "and in particular\n", + "$$\n", + "\\tilde{S}_{\\mu \\mu}^{(x)} = \\int_{-\\infty}^\\infty \n", + "u^{2l_\\mu} e^{-2\\alpha_\\mu u^2} du = H(2l_\\mu, 2\\alpha_\\mu)\n", + "$$\n", + "as before." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### The hard case: non-coincident centres\n", + "Let us return our attention back to the general overlap elements in equation (12), \n", + "repeated here: \n", + "$$\n", + "(12) = \\twelve\n", + "$$\n", + "but let's replace $\\nu,\\mu$ subscripts with more visually distinguishable symbols:\n", + "$$\n", + "\\tilde{S}((A,\\alpha,i), (B,\\beta,j)) = \\int_{-\\infty}^\\infty \n", + "\\left((t - A)^i e^{-\\alpha (t - A)^2} \\right)\n", + "\\left((t - B)^j e^{-\\beta (t - B)^2} \\right) dt\n", + "$$\n", + "and grouping the polynomial terms and the Gaussian terms we get\n", + "$$\n", + "\\tilde{S}((A,\\alpha,i), (B,\\beta,j)) = \\int_{-\\infty}^\\infty \n", + "\\biggl((t - A)^i (t - B)^j \\biggr)\n", + "\\biggl( e^{-\\alpha (t - A)^2} e^{-\\beta (t - B)^2} \\biggr)\n", + "dt\\\\\n", + "$$\n", + "To make progress we start by rewriting the product of two\n", "Gaussian functions as a single Gaussian:\n", "$$\n", "\\tag{16}\n", - "e^{-\\alpha (x - a)^2} e^{-\\beta (x - b)^2} = \n", - "e^{-\\alpha \\beta (a - b)^2 / \\gamma} e^{-\\gamma (x - c)^2}, \\\\\n", + "e^{-\\alpha (t - A)^2} e^{-\\beta (t - B)^2} = \n", + "G ~ e^{-\\gamma (t - C)^2}, \\\\\n", "\\gamma = \\alpha + \\beta \\\\\n", - "c = \\frac{\\alpha a + \\beta b}{\\gamma}\n", + "C = \\frac{\\alpha A + \\beta B}{\\gamma}\\\\\n", + "G = \\exp\\left(-\\frac{\\alpha \\beta}{\\gamma} (A - B)^2\\right) \\\\\n", "$$\n", - "Next we rewrite the product of the leading polynomial terms in terms of the Gaussian product center $c$:\n", + "Next we rewrite the product of the leading polynomial terms in terms of the Gaussian product center $C$:\n", "$$\n", + "\\def\\CA{C_A}\n", + "\\def\\CB{C_B}\n", + "\\def\\tc{t_C}\n", "\\tag{17}\n", - "(x - a)^i (x - b)^j = (x - c + c - a)^i (x - c + c - b)^j = (x_c + c_a)^i (x_c + c_b)^j,\n", + "(t - A)^i (t - B)^j = (t - C + C - A)^i (t - C + C - B)^j = (\\tc + \\CA)^i (\\tc + \\CB)^j,\n", "$$\n", - "where introduce\n", + "where we introduce\n", "$$\n", "\\tag{18}\n", - "x_c = x - c\\\\\n", - "c_a = c - a\\\\\n", - "c_b = c - b.\n", + "\\tc = t - C\\\\\n", + "\\CA = C - A\\\\\n", + "\\CB = C - B.\n", "$$\n", "There isn't a universal term that covers the product of binomial expansions that we have arrived at in equation (17),\n", "and using the [binomial theorem](https://en.wikipedia.org/wiki/Binomial_theorem) we have:\n", "$$\n", "\\tag{19}\n", - "(x_c + c_a)^i = \\sum_{k=0}^i \\binom{i}{k} x_c^{i-k} c_a^k \\\\ \n", - "(x_c + c_b)^j = \\sum_{l=0}^j \\binom{j}{l} x_c^{j-l} c_b^l \n", + "(\\tc + \\CA)^i = \\sum_{k=0}^i \\binom{i}{k} \\tc^{i-k} \\CA^k \\\\ \n", + "(\\tc + \\CB)^j = \\sum_{l=0}^j \\binom{j}{l} \\tc^{j-l} \\CB^l \n", "$$\n", "\n", "$$\n", "\\tag{20}\n", - "(x_c + c_a)^i (x_c + c_b)^j = \\sum_{k=0}^i \\sum_{l=0}^j \\binom{i}{k} \\binom{j}{l} x_c^{i-k} x_c^{j-l} c_a^k c_b^l \n", + "(\\tc + \\CA)^i (\\tc + \\CB)^j = \\sum_{k=0}^i \\sum_{l=0}^j \\binom{i}{k} \\binom{j}{l} \\tc^{i-k} \\tc^{j-l} \\CA^k \\CB^l \n", "$$\n", "we can use SymPy to help us take the product of these expansions for some representative values of $i$ and $j$" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIMAAAAVCAYAAABlol04AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/OQEPoAAAACXBIWXMAABJ0AAASdAHeZh94AAAFWUlEQVR4nO2aXagVVRTHf9c0tc9bBmVppUWRX/fgReqhwkyL6KGvlxK0WxFipJRFIlT/lmnZS4mUiZR5laAUw6iHlFCxjLSr3fwoyyBN0MhKMrUbfpwe9h4d58zMOWfO3CtX/cNhz1mzZs36r71mrzX7nLpiscjpCjO7CDgkaf/J9uVkwczqgSOS/qk7nZPhDE5E1zihmTUDdwH9JB3oWJfygZk1Ai3A45LeiTnfB9gJ3CBpa+RcIn8zGw/MBh6TNK+9/M8DFcSgHtgLDJPU0iVGYRgwBpjRGRLBzJ42s6KZjQ7LJa0HlgIvm9l5MZc2AAeBnyL2yvFv9OP6Wn3PCzXEoAAcBjYDlCQDMB3YB7ydp8PtiLTJeRW4DJgYc64AbJJ0NCIvx78RaAO2VO1p+6GWGPwoqQ0iyWBm1wEjgUWS/s3N1QSYWZPP6OE1mGkE9hN5wgEkrQO2AuPMLJr4DUBrxJ9U/mbWHRgIbJR0uAafo3ZrjUPWGBQIxSDaMzwK1AEfJjg9GrgbGAb0xi0xPwOzJb2XgURmmNkMYHJIdNTMguOxkhb64w+Al4BRwLKQfgF4PWI2lT8wGOgGrDezAvACMBzoAawBJknaXDWZjMghBg3A+8GXaKaMBI4AX8fc+HxgAdAf+AJ4E/gI6AfMM7PJ0WvaGRuAZn/8FWChz6qQ3ho/jgoEZnYucA2RlYEU/h7BcnyVt1sE3vW+jAJW+Kaso1BLDLoBA4hbGXyACsAPCY1TEegj6bew0Myexy1P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ErkJggg==", + "text/latex": [ + "$\\displaystyle \\left(a + t\\right)^{i} \\left(b + t\\right)^{j}$" + ], + "text/plain": [ + " i j\n", + "(a + t) ⋅(b + t) " + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "x, a, b = symbols(\"x_c, c_a, c_b\", real=True)\n", + "x, a, b = symbols(\"t, a, b\", real=True)\n", "i, j = symbols(\"i, j\", nonnegative=True, integers=True)\n", "poly_terms = (x + a)**i * (x + b) **j\n", "poly_terms" @@ -430,9 +741,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "\\begin{align*}(a + t)^0 (b + t)^0 &= 1\\\\(a + t)^0 (b + t)^1 &= b + t\\\\(a + t)^0 (b + t)^2 &= b^{2} + 2 b t + t^{2}\\\\(a + t)^1 (b + t)^0 &= a + t\\\\(a + t)^1 (b + t)^1 &= a b + t \\left(a + b\\right) + t^{2}\\\\(a + t)^1 (b + t)^2 &= a b^{2} + t \\left(2 a b + b^{2}\\right) + t^{2} \\left(a + 2 b\\right) + t^{3}\\\\(a + t)^2 (b + t)^0 &= a^{2} + 2 a t + t^{2}\\\\(a + t)^2 (b + t)^1 &= a^{2} b + t \\left(a^{2} + 2 a b\\right) + t^{2} \\cdot \\left(2 a + b\\right) + t^{3}\\\\(a + t)^2 (b + t)^2 &= a^{2} b^{2} + t \\left(2 a^{2} b + 2 a b^{2}\\right) + t^{2} \\left(a^{2} + 4 a b + b^{2}\\right) + t^{3} \\cdot \\left(2 a + 2 b\\right) + t^{4}\\\\\\end{align*}" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "from itertools import product\n", "\n", @@ -441,7 +766,7 @@ "output = r\"\\begin{align*}\"\n", "for ival, jval in product(range(3), range(3)):\n", " p = simplify(expand(poly_terms.subs(i, ival).subs(j, jval)))\n", - " output += f\"(a + x)^{ival} (b + x)^{jval} &= \"\n", + " output += f\"(a + t)^{ival} (b + t)^{jval} &= \"\n", " output += \" + \".join(\n", " [latex(p.coeff(x, n) * x**n) for n in range(ival + jval + 1)]\n", " )\n", @@ -458,31 +783,31 @@ "By using the symmetry properties of the binomial expansion we can rewrite the terms in the series of Equation (20) as:\n", "$$\n", "\\tag{21}\n", - "\\binom{i}{k} \\binom{j}{l} x_c^{i-k} x_c^{j-l} c_a^k c_b^l = \\binom{i}{k} \\binom{j}{l} x_c^k x_c^l c_a^{i-k} c_b^{j-l}.\n", + "\\binom{i}{k} \\binom{j}{l} \\tc^{i-k} \\tc^{j-l} \\CA^k \\CB^l = \\binom{i}{k} \\binom{j}{l} \\tc^k \\tc^l \\CA^{i-k} \\CB^{j-l}.\n", "$$\n", - "Recognising that we want to collect terms of same power $x_c^s$ we introduce the constraint that $k+l=s$ allows us to\n", + "Recognising that we want to collect terms of same power $\\tc^s$ we introduce the constraint that $k+l=s$ allows us to\n", "write the terms as:\n", "$$\n", "\\tag{22}\n", - "\\binom{i}{s-l} \\binom{j}{l} x_c^s c_a^{i-(s-l)} c_b^{j-l}.\n", + "\\binom{i}{s-l} \\binom{j}{l} \\tc^s \\CA^{i-(s-l)} \\CB^{j-l}.\n", "$$\n", "Replacing the summation variable $l=0, 1,\\cdots, j$ with $t$ and incorporating the constraint we arrive at:\n", "$$\n", "\\tag{23}\n", - "(x_c + c_a)^i (x_c + c_b)^j = \n", - "\\sum_{s = 0}^{i+j} x_c^s \n", + "(\\tc + \\CA)^i (\\tc + \\CB)^j = \n", + "\\sum_{s = 0}^{i+j} \\tc^s \n", "\\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \n", - "\\binom{i}{s-t} \\binom{j}{t} c_a^{i-(s-t)} c_b^{j-t},\n", + "\\binom{i}{s-t} \\binom{j}{t} \\CA^{i-(s-t)} \\CB^{j-t},\n", "$$\n", "Finally we can write this series as:\n", "$$\n", "\\tag{24}\n", - "(x_c + c_a)^i (x_c + c_b)^j = \\sum_{s = 0}^{i+j} B(i, j, c_a, c_b, s) x_c^s,\n", + "(\\tc + \\CA)^i (\\tc + \\CB)^j = \\sum_{s = 0}^{i+j} B(i, j, \\CA, \\CB, s) \\tc^s,\n", "$$\n", - "where we introduce $B(i, j, c_a, c_b, s)$ as the coefficient of $x^s$ in the expansion:\n", + "where we introduce $B(i, j, \\CA, \\CB, s)$ as the coefficient of $x^s$ in the expansion:\n", "$$\n", "\\tag{25}\n", - "B(i, j, c_a, c_b, s) = \\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \\binom{i}{s-t} \\binom{j}{t} c_a^{i - (s - t)} c_b^{j-t}\n", + "B(i, j, \\CA, \\CB, s) = \\sum_{\\substack{t=0 \\\\ s - i \\le t \\le j}}^s \\binom{i}{s-t} \\binom{j}{t} \\CA^{i - (s - t)} \\CB^{j-t}\n", "$$\n", "An evaluation strategy for this variable-sized loop is explored in an accompanying [notebook](./binom_factor_table.ipynb).\n", "\n", @@ -491,75 +816,31 @@ "$$\n", "\\tag{26}\n", "\\tilde{S}_{\\mu \\nu}^{(x)} = \\int_{-\\infty}^\\infty \n", - "\\left(x_A^{l_\\mu} e^{-\\alpha_\\mu x_A^2} \\right)\n", - "\\left(x_B^{l_\\nu} e^{-\\alpha_\\nu x_B^2} \\right) dx = \\\\\n", + "\\left((t - X_\\mu)^{l_\\mu} e^{-\\alpha_\\mu (t - X_\\mu)^2} \\right)\n", + "\\left((t - X_\\nu)^{l_\\nu} e^{-\\alpha_\\nu (t - X_\\nu)^2} \\right) dt = \\\\\n", "\\int_{-\\infty}^\\infty \n", - " e^{-\\alpha_\\mu \\alpha_\\nu (X_A - X_B)^2 / \\gamma} e^{-\\gamma x_C^2}\n", - "\\sum_{s=0}^{l_\\mu+ l_\\nu} B(l_\\mu, l_\\nu, CA_x, CB_x, s) x_C^s dx\n", + " e^{-\\alpha_\\mu \\alpha_\\nu (X_\\mu - X_\\nu)^2 / \\gamma} e^{-\\gamma \\tc^2}\n", + "\\sum_{s=0}^{l_\\mu+ l_\\nu} B(l_\\mu, l_\\nu, C_\\mu, C_\\nu, s) \\tc^s dt\n", "$$\n", - "Swapping the order of integration and the summation we see that we need to evaluate\n", - "integrals of the form:\n", + "Swapping the order of integration and the summation we get\n", "$$\n", - "\\tag{27}\n", - "\\int_{-\\infty}^\\infty t^s e^{-a t^2} dt\n", + " e^{-\\alpha_\\mu \\alpha_\\nu (X_\\mu - X_\\nu)^2 / \\gamma} \n", + "\\sum_{s=0}^{l_\\mu+ l_\\nu} B(l_\\mu, l_\\nu, C_\\mu, C_\\nu, s) \n", + "\\int_{-\\infty}^\\infty \\tc^s e^{-\\gamma \\tc^2} dt\n", "$$\n", - "This has a known analytic solution that we can evaluate using SymPy:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "s = symbols(\"s\", nonnegative=True, integer=True)\n", - "a = symbols(\"a\", positive=True, real=True)\n", - "t = symbols(\"t\", real=True)\n", - "\n", - "gint = Integral(t ** s* exp(-a * t**2), (t, -oo, oo))\n", - "gint" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "expand(gint.doit())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Written this way we can observe that whenever $s$ is odd, the integral will be zero." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "v = symbols(\"v\", nonnegative=True, integer=True, odd=True)\n", - "gint.subs(s, v).doit()" + "and see that we need to evaluate\n", + "integrals of the form that we already defined above at (Hdef)\n", + "$$\n", + "\\tag{27}\n", + "H(s,\\eta) = \\int_{-\\infty}^\\infty t^s e^{-\\eta t^2} dt\n", + "$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "when $s$ is even we have:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "simplify(gint.subs(s, 2*s).doit())" + "And we recall that for $s$ odd, this is zero, so we evaluate it only for $s$ even." ] }, { @@ -569,26 +850,26 @@ "This result can also be written in terms of the [double factorial](https://en.wikipedia.org/wiki/Double_factorial#Additional_identities) which gives us two possible computation strategies for this integral:\n", "$$\n", "\\tag{28}\n", - "G(a, s) = \\int_{-\\infty}^{\\infty} t^{2s} e^{-a t^2} dt \\\\\n", - "= a^{-s - \\frac{1}{2}} \\Gamma\\left(s + \\frac{1}{2}\\right) \\\\\n", - "= \\frac{(2s-1)!!}{(2a)^s} \\sqrt{\\frac{\\pi}{a}}.\n", + "H(2s, \\eta) = \\int_{-\\infty}^{\\infty} t^{2s} e^{-\\eta t^2} dt \\\\\n", + "= \\eta^{-s - \\frac{1}{2}} \\Gamma\\left(s + \\frac{1}{2}\\right) \\\\\n", + "= \\frac{(2s-1)!!}{(2\\eta)^s} \\sqrt{\\frac{\\pi}{\\eta}}.\n", "$$\n", "The last form agrees with Equation (3.15) derived by [Fermann and Valeev](http://arxiv.org/abs/2007.12057).\n", "\n", - "Using the function $G(a, s)$ allows us to write the one-dimensional overlap integral as:\n", + "Using the function $H(2s, \\eta$ allows us to write the one-dimensional overlap integral as:\n", "$$\n", "\\tag{29}\n", "\\tilde{S}_{\\mu \\nu}^{(x)} = \n", "e^{-\\alpha_\\mu \\alpha_\\nu (X_A - X_B)^2 / \\gamma}\n", - "\\sum_{s=0}^{\\lfloor(l_\\mu + l_\\nu)/2 \\rfloor} B(l_\\mu, l_\\nu, CA_x, CB_x, 2s)\\;G(\\gamma, 2s)\n", + "\\sum_{s=0}^{\\lfloor(l_\\mu + l_\\nu)/2 \\rfloor} B(l_\\mu, l_\\nu, CA_x, CB_x, 2s)\\;H(2s, \\gamma)\n", "$$\n", "substituting this back into Equation (11) gives us the overlap of two primitive Gaussians:\n", "$$\n", "\\tag{30}\n", "\\tilde{S}_{\\mu \\nu} = \\iiint p_\\mu(\\br) p_\\nu(\\br) dx dy dz \\\\\n", - "= N_\\mu N_\\nu e^{-\\alpha_\\mu \\alpha_\\nu |\\mathbf{A}-\\mathbf{B}|^2 / \\gamma}\n", - "\\sum_{s=0}^{\\lfloor(l_\\mu + l_\\nu)/2 \\rfloor} B(l_\\mu, l_\\nu, CA_x, CB_x, 2s)\\;G(\\gamma, 2s) \\\\\n", - "\\times \\sum_{s=0}^{\\lfloor(m_\\mu + m_\\nu)/2 \\rfloor} B(m_\\mu, m_\\nu, CA_y, CB_y, 2s)\\;G(\\gamma, 2s)\n", + "= N_\\mu N_\\nu \\exp\\left(-\\frac{\\alpha_\\mu \\alpha_\\nu |\\mathbf{A}-\\mathbf{B}|^2}{\\alpha_\\mu + \\alpha_\\nu}\\right) \\times\\\\\n", + "\\sum_{s=0}^{\\lfloor(l_\\mu + l_\\nu)/2 \\rfloor} B(l_\\mu, l_\\nu, CA_x, CB_x, 2s)\\;G(\\gamma, 2s) \\times \\\\\n", + "\\sum_{s=0}^{\\lfloor(m_\\mu + m_\\nu)/2 \\rfloor} B(m_\\mu, m_\\nu, CA_y, CB_y, 2s)\\;G(\\gamma, 2s) \\times \\\\\n", "\\sum_{s=0}^{\\lfloor(n_\\mu + n_\\nu)/2 \\rfloor} B(n_\\mu, n_\\nu, CA_z, CB_z, 2s)\\;G(\\gamma, 2s)\n", "$$" ] From fa04ccb2b08ae0b60dcf17931985634f31e0cdbd Mon Sep 17 00:00:00 2001 From: Hatem Helal Date: Wed, 18 Oct 2023 11:45:50 +0000 Subject: [PATCH 14/14] wip intro --- notebooks/gto_integrals.ipynb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/notebooks/gto_integrals.ipynb b/notebooks/gto_integrals.ipynb index 10fc7fd..473e58b 100644 --- a/notebooks/gto_integrals.ipynb +++ b/notebooks/gto_integrals.ipynb @@ -18,10 +18,16 @@ "$$\n", "\\mathcal{A} = \\{ (Z_m, \\br_m) \\}_{m=1}^{M}\n", "$$\n", + "Each atom in the molecule contributes both negatively charged electrons that are bound \n", + "to a positively charged nucleus. Both the number of electrons and the charge on the\n", + "nucleus can be found from the periodic table. For a concrete example, a single Oxygen\n", + "atom has atomic number 8 and this implies a charge of $Z = 8$ located at the position\n", + "$\\br$. This charge on the nucleus is balanced by eight negatively charged electrons.\n", "\n", - "We will represent the electron density of the molecule as a sum of per-atom electron densities.\n", + "\n", + "We will represent the electron density of the molecule from the eigenstates:\n", "$$\n", - "\\psi(\\br) = \\sum_{m=1}^M \\psi_m(\\br)\n", + "\\rho(\\br) = \\sum_{m=1}^M f_m | \\psi_m(\\br) |^2\n", "$$\n", "Atom $m$ has $I(Z_m)$ basis functions (determined by $Z_m$ and the basis set in use),\n", "with coefficients $C = [c_{mi}]_{i=1}^{I(Z_m)}$:\n", @@ -891,7 +897,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.17" + "version": "3.8.10" }, "orig_nbformat": 4 },