Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions gbasis/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
"""Module for evaluating, differentiating, and integrating Gaussian functions."""

from .wrapper_iodata import from_iodata
from .wrapper_pyscf import from_pyscf
141 changes: 11 additions & 130 deletions gbasis/wrappers.py → gbasis/wrapper_iodata.py
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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`.

Expand Down Expand Up @@ -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
65 changes: 65 additions & 0 deletions gbasis/wrapper_pyscf.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion tests/test_libcint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion tests/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down