From ed75fb71ad66f0eeace25874412a26ae97856260 Mon Sep 17 00:00:00 2001 From: ifilot Date: Wed, 17 Jan 2024 10:58:13 +0100 Subject: [PATCH 1/3] Fixing bug in build3dgrid module and putting check for this function in test suite --- pyqint/pyqint.pyx | 6 +++--- tests/test_plot_data.py | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pyqint/pyqint.pyx b/pyqint/pyqint.pyx index 82910a7..895ab92 100644 --- a/pyqint/pyqint.pyx +++ b/pyqint/pyqint.pyx @@ -596,18 +596,18 @@ cdef class PyQInt: return S, T, V, teints - def build_rectgrid3d(self, xmin:float, xmax:float, sz:float) -> npt.NDArray[np.float64]: + def build_rectgrid3d(self, xmin:float, xmax:float, npts:int) -> npt.NDArray[np.float64]: """Build three-dimensional grid Args: xmin (float): negative coordinate xmax (float): positive coordinate - sz (float): number of values + npts (int): number of sampling points per Cartesian direction Returns: npt.NDArray[np.float64]: array containing grid points """ - x = np.linspace(xmin, xmax, sz, endpoint=False) + x = np.linspace(xmin, xmax, npts, endpoint=False) grid = np.flipud(np.vstack(np.meshgrid(x, x, x, indexing='ij')).reshape(3,-1)).T return grid diff --git a/tests/test_plot_data.py b/tests/test_plot_data.py index 7bf4488..ebd2cd4 100644 --- a/tests/test_plot_data.py +++ b/tests/test_plot_data.py @@ -40,11 +40,6 @@ def test_plot_gradient(self): # construct integrator object integrator = PyQInt() - - # build grid points - x = np.linspace(-2, 2, 6, endpoint=True) - coord = np.flipud(np.vstack(np.meshgrid(x, x, x, indexing='ij')).reshape(3,-1)).T - c = np.array([0.54893397, 0.54893397]) # test couple of single points @@ -71,6 +66,7 @@ def test_plot_gradient(self): np.testing.assert_almost_equal(grad, res, 4) # test grid of points + coord = integrator.build_rectgrid3d(-2, 2, 6) grad = integrator.plot_gradient(coord, c, cgfs) self.assertEqual(grad.shape[0], 6*6*6) self.assertEqual(grad.shape[1], 3) From 1a13bb2035afadb780bc9e75e85cb2713ff23780 Mon Sep 17 00:00:00 2001 From: ifilot Date: Wed, 17 Jan 2024 11:17:49 +0100 Subject: [PATCH 2/3] Adding endpoint selection for buildgrid function --- meta.yaml | 2 +- pyqint/_version.py | 2 +- pyqint/pyqint.pyx | 5 +++-- tests/test_plot_data.py | 5 ++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/meta.yaml b/meta.yaml index 1e6bf0f..fa896fb 100644 --- a/meta.yaml +++ b/meta.yaml @@ -1,6 +1,6 @@ package: name: "pyqint" - version: "0.16.0" + version: "0.16.1" source: path: . diff --git a/pyqint/_version.py b/pyqint/_version.py index 4cef1d9..e53f767 100644 --- a/pyqint/_version.py +++ b/pyqint/_version.py @@ -1,2 +1,2 @@ -__version__ = "0.16.0" +__version__ = "0.16.1" diff --git a/pyqint/pyqint.pyx b/pyqint/pyqint.pyx index 895ab92..e2b524d 100644 --- a/pyqint/pyqint.pyx +++ b/pyqint/pyqint.pyx @@ -596,18 +596,19 @@ cdef class PyQInt: return S, T, V, teints - def build_rectgrid3d(self, xmin:float, xmax:float, npts:int) -> npt.NDArray[np.float64]: + def build_rectgrid3d(self, xmin:float, xmax:float, npts:int, endpoint:bool=False) -> npt.NDArray[np.float64]: """Build three-dimensional grid Args: xmin (float): negative coordinate xmax (float): positive coordinate npts (int): number of sampling points per Cartesian direction + endpoint (bool): whether to include the endpoint for the grid spacing Returns: npt.NDArray[np.float64]: array containing grid points """ - x = np.linspace(xmin, xmax, npts, endpoint=False) + x = np.linspace(xmin, xmax, npts, endpoint=endpoint) grid = np.flipud(np.vstack(np.meshgrid(x, x, x, indexing='ij')).reshape(3,-1)).T return grid diff --git a/tests/test_plot_data.py b/tests/test_plot_data.py index ebd2cd4..0fc5acb 100644 --- a/tests/test_plot_data.py +++ b/tests/test_plot_data.py @@ -40,6 +40,7 @@ def test_plot_gradient(self): # construct integrator object integrator = PyQInt() + c = np.array([0.54893397, 0.54893397]) # test couple of single points @@ -66,7 +67,9 @@ def test_plot_gradient(self): np.testing.assert_almost_equal(grad, res, 4) # test grid of points - coord = integrator.build_rectgrid3d(-2, 2, 6) + # x = np.linspace(-2, 2, 6, endpoint=True) + # coord = np.flipud(np.vstack(np.meshgrid(x, x, x, indexing='ij')).reshape(3,-1)).T + coord = integrator.build_rectgrid3d(-2, 2, 6, endpoint=True) grad = integrator.plot_gradient(coord, c, cgfs) self.assertEqual(grad.shape[0], 6*6*6) self.assertEqual(grad.shape[1], 3) From bc9ba032667a2aeaa0e0bef61edd1ffaeba8c397 Mon Sep 17 00:00:00 2001 From: ifilot Date: Wed, 17 Jan 2024 11:37:26 +0100 Subject: [PATCH 3/3] Expanding documentation --- docs/index.rst | 6 ++++-- docs/user_interface.rst | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index b8b7244..e833721 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,8 +3,10 @@ PyQInt: a Python package for evaluating Gaussian integrals and performing electr .. image:: https://img.shields.io/github/v/tag/ifilot/pyqint?label=version :alt: GitHub tag (latest SemVer) -.. image:: https://github.com/ifilot/pyqint/actions/workflows/build.yml/badge.svg - :target: https://github.com/ifilot/pyqint/actions/workflows/build.yml +.. image:: https://github.com/ifilot/pyqint/actions/workflows/build_wheels.yml/badge.svg + :target: https://github.com/ifilot/pyqint/actions/workflows/build_wheels.yml +.. image:: https://github.com/ifilot/pyqint/actions/workflows/build_conda.yml/badge.svg + :target: https://github.com/ifilot/pyqint/actions/workflows/build_conda.yml .. image:: https://img.shields.io/badge/License-GPLv3-blue.svg :target: https://www.gnu.org/licenses/gpl-3.0 diff --git a/docs/user_interface.rst b/docs/user_interface.rst index 235d018..b2e86d7 100644 --- a/docs/user_interface.rst +++ b/docs/user_interface.rst @@ -550,14 +550,13 @@ Parallel evaluation of integrals From a collection of Contracted Gaussian Functions, the complete set of overlap, kinetic, nuclear attraction and two-electron integrals can be quickly evaluated -using the `build_integrals` function. Using the `npar` argument, the number of -threads to be spawned can be set. +using the `build_integrals_openmp` function. The function will automatically determine +the number of available cores to allocate for this process. .. code-block:: python from pyqint import PyQInt, Molecule import numpy as np - import multiprocessing # construct integrator object integrator = PyQInt() @@ -569,8 +568,7 @@ threads to be spawned can be set. cgfs, nuclei = mol.build_basis('sto3g') # evaluate all integrals - ncpu = multiprocessing.cpu_count() - S, T, V, teint = integrator.build_integrals(cgfs, nuclei, npar=ncpu, verbose=False) + S, T, V, teint = integrator.build_integrals_openmp(cgfs, nuclei) print(S) print(T) @@ -754,6 +752,38 @@ The output of the above script yields:: Total energy: -39.72630504189621 Sum of the individual terms: -39.726305041896055 +Custom basis sets +----------------- + +Besides the basis sets offered by :program:`PyQInt`, one can also use a custom +basis set defined by the user. The :code:`rhf` routine accepts either a basis set +for its :code:`basis` argument, or alternatively a list of :code:`cgf` objects. +In the example code shown below, the latter is done. + +.. code-block:: python + + mol = Molecule() + mol.add_atom('H', 0.0000, 0.0000, 0.3561150187, unit='angstrom') + mol.add_atom('H', 0.0000, 0.0000, -0.3561150187, unit='angstrom') + nuclei = mol.get_nuclei() + + cgfs = [] + for n in nuclei: + _cgf = cgf(n[0]) + + _cgf.add_gto(0.154329, 3.425251, 0, 0, 0) + _cgf.add_gto(0.535328, 0.623914, 0, 0, 0) + _cgf.add_gto(0.444635, 0.168855, 0, 0, 0) + + cgfs.append(_cgf) + + res = HF().rhf(mol, basis=cgfs) + +.. hint:: + + A nice website to find a large collection of Gaussian Type basis set coefficients is + `https://www.basissetexchange.org/ `_. + Orbital visualization =====================