From 5abc2fbf37f2cbd41dc1794669fe2f13f5c10926 Mon Sep 17 00:00:00 2001 From: leila-pujal Date: Mon, 1 Apr 2024 20:27:08 -0400 Subject: [PATCH 1/4] Add overlap screening to `from_iodata` --- gbasis/parsers.py | 2 +- gbasis/wrappers.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gbasis/parsers.py b/gbasis/parsers.py index d25aca05..91a0ed23 100644 --- a/gbasis/parsers.py +++ b/gbasis/parsers.py @@ -214,7 +214,7 @@ def make_contractions(basis_dict, atoms, coords, coord_types, tol=1e-20, overlap if not isinstance(tol, float): raise TypeError("Tolerance must be provided as a float.") if not isinstance(overlap, bool): - raise TypeError("Tolerance must be provided as True or False.") + raise TypeError("Overlap must be provided as True or False.") if len(atoms) != coords.shape[0]: raise ValueError("Number of atoms must be equal to the number of rows in the coordinates.") diff --git a/gbasis/wrappers.py b/gbasis/wrappers.py index 40cd942b..ee3443a0 100644 --- a/gbasis/wrappers.py +++ b/gbasis/wrappers.py @@ -3,13 +3,17 @@ import numpy as np -def from_iodata(mol): +def from_iodata(mol, tol=1e-20, overlap=False): """Return basis set stored within the `IOData` instance in `iodata`. Parameters ---------- mol : iodata.iodata.IOData `IOData` instance from `iodata` module. + tol : float + Tolerance used in overlap screening. + ovrlap : bool + Flag for performing overlap screening between contractions. Returns ------- @@ -114,6 +118,10 @@ def angmom_components_sph(self): "Only L2 normalization scheme is supported in `gbasis`. Given `IOData` instance uses " "primitive normalization scheme, {}".format(molbasis.primitive_normalization) ) + if not isinstance(tol, float): + raise TypeError("Tolerance must be provided as a float.") + if not isinstance(overlap, bool): + raise TypeError("Overlap must be provided as True or False.") basis = [] for shell in molbasis.shells: @@ -133,6 +141,8 @@ def angmom_components_sph(self): shell.exponents, shell.kinds[0], icenter=shell.icenter, + tol=tol, + ovr_screen=overlap ) ) From 2f6a45b9d9e9d7f1549e4e4391da2b2a2d3291ef Mon Sep 17 00:00:00 2001 From: leila-pujal Date: Mon, 1 Apr 2024 20:52:46 -0400 Subject: [PATCH 2/4] Add test to test_wrappers.py --- tests/test_wrappers.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_wrappers.py b/tests/test_wrappers.py index 81528688..1b08e8a1 100644 --- a/tests/test_wrappers.py +++ b/tests/test_wrappers.py @@ -18,6 +18,8 @@ def test_from_iodata(): coord_types = [type for type in [shell.coord_type for shell in basis]] assert coord_types == ["cartesian"] * 5 + assert basis[0].ovr_screen == False + assert basis[0].ovr_tol == 1e-20 assert all(isinstance(i, GeneralizedContractionShell) for i in basis) assert basis[0].angmom == 0 assert np.allclose(basis[0].coord, mol.atcoords[0]) @@ -28,6 +30,8 @@ def test_from_iodata(): assert np.allclose(basis[0].norm_cont, 1.0) assert basis[1].angmom == 0 + assert basis[1].ovr_screen == False + assert basis[1].ovr_tol == 1e-20 assert np.allclose(basis[1].coord, mol.atcoords[0]) assert np.allclose(basis[1].exps, np.array([5.033151319, 1.169596125, 0.3803889600])) assert np.allclose( @@ -36,6 +40,8 @@ def test_from_iodata(): assert np.allclose(basis[1].norm_cont, 1.0) assert basis[2].angmom == 1 + assert basis[2].ovr_screen == False + assert basis[2].ovr_tol == 1e-20 assert np.allclose(basis[2].coord, mol.atcoords[0]) assert np.allclose(basis[2].exps, np.array([5.033151319, 1.169596125, 0.3803889600])) assert np.allclose( @@ -44,6 +50,8 @@ def test_from_iodata(): assert np.allclose(basis[2].norm_cont, 1.0) assert basis[3].angmom == 0 + assert basis[3].ovr_screen == False + assert basis[3].ovr_tol == 1e-20 assert np.allclose(basis[3].coord, mol.atcoords[1]) assert np.allclose(basis[3].exps, np.array([3.425250914, 0.6239137298, 0.1688554040])) assert np.allclose( @@ -52,6 +60,8 @@ def test_from_iodata(): assert np.allclose(basis[3].norm_cont, 1.0) assert basis[4].angmom == 0 + assert basis[4].ovr_screen == False + assert basis[4].ovr_tol == 1e-20 assert np.allclose(basis[4].coord, mol.atcoords[2]) assert np.allclose(basis[4].exps, np.array([3.425250914, 0.6239137298, 0.1688554040])) assert np.allclose( @@ -113,6 +123,26 @@ def test_from_iodata(): mol.obasis.primitive_normalization = "L1" basis, coord_types = from_iodata(mol) +def test_from_iodata_ovlp(): + """Test gbasis.wrapper.from_iodata only for the ovr_screen and tol attributes """ + pytest.importorskip("iodata") + from iodata import load_one + + mol = load_one(find_datafile("data_iodata_water_sto3g_hf_g03.fchk")) + + basis = from_iodata(mol, tol=0.001, overlap=True) + + assert basis[0].ovr_screen == True + assert basis[0].ovr_tol == 0.001 + assert basis[1].ovr_screen == True + assert basis[1].ovr_tol == 0.001 + assert basis[2].ovr_screen == True + assert basis[2].ovr_tol == 0.001 + assert basis[3].ovr_screen == True + assert basis[3].ovr_tol == 0.001 + assert basis[4].ovr_screen == True + assert basis[4].ovr_tol == 0.001 + def test_from_pyscf(): """Test gbasis.wrapper.from_pyscf.""" From 373734956bbc9f62bc5ae9e0711302f98a4ca3d7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 00:58:45 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- gbasis/wrappers.py | 2 +- tests/test_wrappers.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gbasis/wrappers.py b/gbasis/wrappers.py index ee3443a0..22c26d02 100644 --- a/gbasis/wrappers.py +++ b/gbasis/wrappers.py @@ -142,7 +142,7 @@ def angmom_components_sph(self): shell.kinds[0], icenter=shell.icenter, tol=tol, - ovr_screen=overlap + ovr_screen=overlap, ) ) diff --git a/tests/test_wrappers.py b/tests/test_wrappers.py index 1b08e8a1..78c93031 100644 --- a/tests/test_wrappers.py +++ b/tests/test_wrappers.py @@ -123,8 +123,9 @@ def test_from_iodata(): mol.obasis.primitive_normalization = "L1" basis, coord_types = from_iodata(mol) + def test_from_iodata_ovlp(): - """Test gbasis.wrapper.from_iodata only for the ovr_screen and tol attributes """ + """Test gbasis.wrapper.from_iodata only for the ovr_screen and tol attributes""" pytest.importorskip("iodata") from iodata import load_one From 1c5e0d22fc40c389bfb60d4292c15b09afa92f99 Mon Sep 17 00:00:00 2001 From: leila-pujal Date: Mon, 15 Apr 2024 14:31:29 -0400 Subject: [PATCH 4/4] Update documentation and fix typo --- gbasis/contractions.py | 2 +- gbasis/wrappers.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gbasis/contractions.py b/gbasis/contractions.py index 3c1183e7..06c26c13 100644 --- a/gbasis/contractions.py +++ b/gbasis/contractions.py @@ -141,7 +141,7 @@ def __init__( "spherical" or "p". icenter : np.int64 or None (optional) Index for the atomic center for the contraction - ovr_tol : float + tol : float Tolerance used in overlap screening. ovr_screen : boolean Flag used for activating overlap screening. diff --git a/gbasis/wrappers.py b/gbasis/wrappers.py index 22c26d02..968ad364 100644 --- a/gbasis/wrappers.py +++ b/gbasis/wrappers.py @@ -12,7 +12,7 @@ def from_iodata(mol, tol=1e-20, overlap=False): `IOData` instance from `iodata` module. tol : float Tolerance used in overlap screening. - ovrlap : bool + overlap : bool Flag for performing overlap screening between contractions. Returns