diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml new file mode 100644 index 00000000..1d40d462 --- /dev/null +++ b/.github/workflows/build_wheels.yml @@ -0,0 +1,30 @@ +name: GBasis Build Wheels Prototype + +on: + workflow_dispatch: + +jobs: + build_wheels: + name: Build wheels on ubuntu-latest + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.22.0 + env: + CIBW_BUILD: cp311-manylinux_x86_64 + CIBW_BUILD_VERBOSITY: 1 + CIBW_BEFORE_ALL: > + yum install -y cmake git && + git clone https://github.com/sunqm/libcint.git && + cd libcint && + mkdir build && cd build && + cmake -DCMAKE_INSTALL_PREFIX=/usr .. && + make && make install + + - uses: actions/upload-artifact@v4 + with: + name: gbasis-wheels + path: ./wheelhouse/*.whl \ No newline at end of file diff --git a/gbasis/__init__.py b/gbasis/__init__.py index 3fbac1ef..fc8abc02 100644 --- a/gbasis/__init__.py +++ b/gbasis/__init__.py @@ -1 +1,4 @@ """Module for evaluating, differentiating, and integrating Gaussian functions.""" + +from .wrapper_iodata import from_iodata +from .wrapper_pyscf import from_pyscf \ No newline at end of file diff --git a/gbasis/wrappers.py b/gbasis/wrapper_iodata.py similarity index 68% rename from gbasis/wrappers.py rename to gbasis/wrapper_iodata.py index f006a4a7..65a50e11 100644 --- a/gbasis/wrappers.py +++ b/gbasis/wrapper_iodata.py @@ -1,7 +1,6 @@ -"""Module for interfacing to other quantum chemistry packages.""" +"""Module for interfacing to the IOData quantum chemistry package.""" import numpy as np - from gbasis.contractions import GeneralizedContractionShell CONVENTIONS_LIBCINT = { @@ -14,78 +13,22 @@ (2, "c"): ["xx", "xy", "xz", "yy", "yz", "zz"], (3, "c"): ["xxx", "xxy", "xxz", "xyy", "xyz", "xzz", "yyy", "yyz", "yzz", "zzz"], (4, "c"): [ - "xxxx", - "xxxy", - "xxxz", - "xxyy", - "xxyz", - "xxzz", - "xyyy", - "xyyz", - "xyzz", - "xzzz", - "yyyy", - "yyyz", - "yyzz", - "yzzz", - "zzzz", + "xxxx", "xxxy", "xxxz", "xxyy", "xxyz", "xxzz", "xyyy", "xyyz", "xyzz", + "xzzz", "yyyy", "yyyz", "yyzz", "yzzz", "zzzz", ], (5, "c"): [ - "xxxxx", - "xxxxy", - "xxxxz", - "xxxyy", - "xxxyz", - "xxxzz", - "xxyyy", - "xxyyz", - "xxyzz", - "xxzzz", - "xyyyy", - "xyyyz", - "xyyzz", - "xyzzz", - "xzzzz", - "yyyyy", - "yyyyz", - "yyyzz", - "yyzzz", - "yzzzz", - "zzzzz", + "xxxxx", "xxxxy", "xxxxz", "xxxyy", "xxxyz", "xxxzz", "xxyyy", "xxyyz", + "xxyzz", "xxzzz", "xyyyy", "xyyyz", "xyyzz", "xyzzz", "xzzzz", "yyyyy", + "yyyyz", "yyyzz", "yyzzz", "yzzzz", "zzzzz", ], (6, "c"): [ - "xxxxxx", - "xxxxxy", - "xxxxxz", - "xxxxyy", - "xxxxyz", - "xxxxzz", - "xxxyyy", - "xxxyyz", - "xxxyzz", - "xxxzzz", - "xxyyyy", - "xxyyyz", - "xxyyzz", - "xxyzzz", - "xxzzzz", - "xyyyyy", - "xyyyyz", - "xyyyzz", - "xyyzzz", - "xyzzzz", - "xzzzzz", - "yyyyyy", - "yyyyyz", - "yyyyzz", - "yyyzzz", - "yyzzzz", - "yzzzzz", - "zzzzzz", + "xxxxxx", "xxxxxy", "xxxxxz", "xxxxyy", "xxxxyz", "xxxxzz", "xxxyyy", + "xxxyyz", "xxxyzz", "xxxzzz", "xxyyyy", "xxyyyz", "xxyyzz", "xxyzzz", + "xxzzzz", "xyyyyy", "xyyyyz", "xyyyzz", "xyyzzz", "xyzzzz", "xzzzzz", + "yyyyyy", "yyyyyz", "yyyyzz", "yyyzzz", "yyzzzz", "yzzzzz", "zzzzzz", ], } - def from_iodata(mol): """Return basis set stored within the `IOData` instance in `iodata`. @@ -254,66 +197,4 @@ def permutation_libcint(self): ) ) - return basis - - -def from_pyscf(mol): - """Return basis set stored within the `Mole` instance in `pyscf`. - - Parameters - ---------- - mol : pyscf.gto.mole.Mole - `Mole` object in `pyscf`. - - Returns - ------- - basis : tuple of gbasis.contraciton.GeneralizedContractionShell - Contractions for each atom. - Contractions are ordered by the atom first, then the contractions as ordered in `pyscf`. - - Raises - ------ - ValueError - If `mol` is not a `pyscf.gto.mole.Mole` instance. - - Notes - ----- - This function touches the internal components of `pyscf`, which may or may not be documented. - This function will break as soon as the internal components change. If so, please raise an issue - at https://github.com/theochem/gbasis. It is supported for, at least, `pyscf` version 1.6.1. - - """ - # pylint: disable=W0212 - if not (mol.__class__.__name__ == "Mole" and hasattr(mol, "_basis")): - raise ValueError("`mol` must be a `pyscf.gto.mole.Mole` instance.") - - # assign the coordinate types (which can be either Cartesian or Spherical) - # it seems like pyscf does not support mixed "cartesian" and "spherical" basis. - coord_types = "cartesian" if mol.cart else "spherical" - - class PyscfShell(GeneralizedContractionShell): - """Shell object that is compatible with gbasis' shell object. - - See `gbasis.contractions.GeneralizedContractionShell` for the documentation. - - """ - - @property - def angmom_components_sph(self): - """Return the ordering of the magnetic quantum numbers for the given angmom in pyscf.""" - if self.angmom == 1: - return ("c1", "s1", "c0") - return super().angmom_components_sph - - basis = [] - for atom, coord in mol._atom: - basis_info = mol._basis[atom] - - for shell in basis_info: - angmom = shell[0] - exps_coeffs = np.vstack(shell[1:]) - exps = np.array(exps_coeffs[:, 0]) - coeffs = np.array(exps_coeffs[:, 1:]) - basis.append(PyscfShell(angmom, np.array(coord), coeffs, exps, coord_types)) - - return tuple(basis) + return basis \ No newline at end of file diff --git a/gbasis/wrapper_pyscf.py b/gbasis/wrapper_pyscf.py new file mode 100644 index 00000000..468b4cbd --- /dev/null +++ b/gbasis/wrapper_pyscf.py @@ -0,0 +1,65 @@ +"""Module for interfacing to the PySCF quantum chemistry package.""" + +import numpy as np +from gbasis.contractions import GeneralizedContractionShell + +def from_pyscf(mol): + """Return basis set stored within the `Mole` instance in `pyscf`. + + Parameters + ---------- + mol : pyscf.gto.mole.Mole + `Mole` object in `pyscf`. + + Returns + ------- + basis : tuple of gbasis.contraciton.GeneralizedContractionShell + Contractions for each atom. + Contractions are ordered by the atom first, then the contractions as ordered in `pyscf`. + + Raises + ------ + ValueError + If `mol` is not a `pyscf.gto.mole.Mole` instance. + + Notes + ----- + This function touches the internal components of `pyscf`, which may or may not be documented. + This function will break as soon as the internal components change. If so, please raise an issue + at https://github.com/theochem/gbasis. It is supported for, at least, `pyscf` version 1.6.1. + + """ + # pylint: disable=W0212 + if not (mol.__class__.__name__ == "Mole" and hasattr(mol, "_basis")): + raise ValueError("`mol` must be a `pyscf.gto.mole.Mole` instance.") + + # assign the coordinate types (which can be either Cartesian or Spherical) + # it seems like pyscf does not support mixed "cartesian" and "spherical" basis. + coord_types = "cartesian" if mol.cart else "spherical" + + class PyscfShell(GeneralizedContractionShell): + """Shell object that is compatible with gbasis' shell object. + + See `gbasis.contractions.GeneralizedContractionShell` for the documentation. + + """ + + @property + def angmom_components_sph(self): + """Return the ordering of the magnetic quantum numbers for the given angmom in pyscf.""" + if self.angmom == 1: + return ("c1", "s1", "c0") + return super().angmom_components_sph + + basis = [] + for atom, coord in mol._atom: + basis_info = mol._basis[atom] + + for shell in basis_info: + angmom = shell[0] + exps_coeffs = np.vstack(shell[1:]) + exps = np.array(exps_coeffs[:, 0]) + coeffs = np.array(exps_coeffs[:, 1:]) + basis.append(PyscfShell(angmom, np.array(coord), coeffs, exps, coord_types)) + + return tuple(basis) \ No newline at end of file diff --git a/tests/test_libcint.py b/tests/test_libcint.py index 1d1deddb..36756751 100644 --- a/tests/test_libcint.py +++ b/tests/test_libcint.py @@ -25,7 +25,7 @@ from gbasis.integrals.point_charge import point_charge_integral from gbasis.parsers import make_contractions, parse_nwchem -from gbasis.wrappers import from_iodata +from gbasis.wrapper_iodata import from_iodata from utils import find_datafile diff --git a/tests/test_wrappers.py b/tests/test_wrappers.py index a5b8ba1c..93855779 100644 --- a/tests/test_wrappers.py +++ b/tests/test_wrappers.py @@ -2,7 +2,8 @@ from gbasis.contractions import GeneralizedContractionShell from gbasis.parsers import make_contractions, parse_nwchem -from gbasis.wrappers import from_iodata, from_pyscf +from gbasis.wrapper_iodata import from_iodata +from gbasis.wrapper_pyscf import from_pyscf import numpy as np import pytest from utils import find_datafile