py-gcp is a fast implementation of the Geometrical Counterpoise (gCP) correction for basis‑set superposition error (BSSE). It provides:
- NumPy/Numba CPU kernels for molecular and periodic systems
- Optional CUDA/Torch paths (molecular; SRB/base for PBC)
- An ASE calculator wrapper
- A gcp64‑like CLI (
pygcp) that auto‑detects PBC
Requires Python 3.10+.
pip install ./
- CLI:
pygcp -l dft/def2-TZVP H2O.xyz # non-PBC
pygcp -l dft/def2-TZVP POSCAR # auto PBC via ASE
pygcp -l hf3c --pbc POSCAR # force PBC
pygcp -l dft/def2-TZVP --no-pbc H2O.xyz # force non-PBC
- Python API:
from py_gcp import gcp_energy_numpy
from ase.build import molecule
at = molecule('H2O')
Z = at.get_atomic_numbers()
xyz = at.get_positions() # Angstrom
E = gcp_energy_numpy(Z, xyz, method='dft/def2tzvp', units='Angstrom')
- ASE calculator:
from ase.build import molecule
from py_gcp.ase_calculator import PyGCP
at = molecule('H2O')
at.calc = PyGCP(method='dft/def2tzvp') # auto PBC from Atoms.pbc
E_eV = at.get_potential_energy()
- Molecular/PBC gCP:
dft/sv,dft/sv(p),dft/svp,dft/dz,dft/dzp,dft/631gd,dft/def2tzvp - HF analogues:
hf/sv,hf/sv(p),hf/dz,hf/dzp,hf/631gd,hf/def2tzvp - 3c:
b97-3c(SRB),hf3c(base),def2mtzvpp(damped)
The gCP correction adds a pairwise term to approximate the residual BSSE of a finite basis calculation. For a molecule, the energy is
where
-
$\epsilon(Z)$ is the per‑element emissivity (method dependent), -
$v_j = n_\mathrm{bas}(Z_j) - \tfrac{1}{2}Z_j$ is the virtual count (with specific overrides for some 3c variants), -
$s_{ab}(r; Z_i,Z_j)$ is the s‑type Slater overlap between the valence shells (1s/2s/3s) of$Z_i$ and$Z_j$ with exponents$\zeta_a,\zeta_b$ fromsetzet, - and
$p_1, p_2, p_3, p_4$ are the method parameters ($p_2$ is the scaling for$\zeta$ ).
The Slater overlap
For damped 3c variants (e.g., PBEh‑3c, HSE‑3c, mTZVPP), we multiply the pair contribution by a short‑range damping function
with element‑pair radii
Units: Coordinates are accepted in Angstrom or Bohr; energy is returned in Hartree (CLI also prints kcal/mol).
- Molecular (NumPy/Numba): typically 10–15× faster than
gcp64on small/medium systems; exact within ~1e−8 Ha. - PBC (NumPy/Numba): 3–18× faster depending on method/size; hf‑3c, b97‑3c supported including SR terms.
- Torch/CUDA: available for molecular non‑damped methods; SRB/base PBC on GPU. CPU fallback for damped.
- Run tests:
pip install -e .[ase] pytestthenpytest -q. - Benchmarks:
python3 tools/bench_suite.py(NumPy/torch vs gcp-fortran),python3 tools/bench_torch_modes.py.