PyVolGrid
PyVolGrid is a Python package for estimating the total volume of overlapping spheres using a grid-based numerical approach. It is intended for applications in computational chemistry, molecular modeling, and structural bioinformatics.
(Besides its potential usefullness, this package also served as a learning project for me to get more familiar with Python packaging and distribution of precompiled wheels.)
Installation
pip install pyvolgrid
Or clone the repository and install manually (requires a C++ compiler such as clang or gcc, and cmake to be installed):
git clone https://github.com/ugSUBMARINE/pyvolgrid.git
cd pyvolgrid
pip install .
Enable Parallelization (OpenMP)
To enable multi-threading support for faster calculations, you need to compile with OpenMP.
macOS (requires libomp via Homebrew):
brew install libomp
CMAKE_ARGS="-DOpenMP_ROOT=$(brew --prefix libomp)" pip install .
Linux:
Usually works out of the box. If not, install libomp-dev (Ubuntu/Debian) or libomp-devel (RHEL/Fedora).
Windows: Supported natively by MSVC.
Usage
Basic Example
import numpy as np
from pyvolgrid import volume_from_spheres
# Define sphere centers and radii
coords = [[0, 0, 0], [1.5, 0, 0], [0, 1.5, 0]]
radii = [1.0, 0.8, 0.6]
# Calculate total volume
volume = volume_from_spheres(coords, radii, grid_spacing=0.1)
print(f"Total volume: {volume:.2f} cubic units")
Scalar Radius
Apply the same radius to all spheres by passing a single number:
# All spheres have radius 1.2
coords = [[0, 0, 0], [3, 0, 0], [0, 3, 0]]
radius = 1.2 # Single value for all spheres
volume = volume_from_spheres(coords, radius)
print(f"Volume with uniform radius: {volume:.2f}")
Flexible Input Types
PyVolGrid accepts various input formats - lists, tuples, or numpy arrays:
# Using tuples
coords = ((0, 0, 0), (2, 0, 0))
radii = (1.0, 0.5)
volume = volume_from_spheres(coords, radii)
# Using numpy arrays (any dtype, will be converted automatically)
coords = np.array([[0, 0, 0]], dtype=np.int32)
radius = np.float32(1.0)
volume = volume_from_spheres(coords, radius)
# Mixed types work too
coords = [[0, 0, 0]] # List
radius = 1 # Integer (converted to float)
volume = volume_from_spheres(coords, radius)
Performance Tips
# For optimal performance, use C-contiguous float64 arrays
coords = np.array([[0, 0, 0], [2, 0, 0]], dtype=np.float64, order='C')
radii = np.array([1.0, 0.5], dtype=np.float64)
# No copying will occur, maximizing performance
volume = volume_from_spheres(coords, radii)
Grid Spacing
Adjust the grid spacing to balance accuracy vs. performance:
coords = [[0, 0, 0]]
radius = 1.0
# Coarse grid (faster, less accurate)
volume_coarse = volume_from_spheres(coords, radius, grid_spacing=0.2)
# Fine grid (slower, more accurate)
volume_fine = volume_from_spheres(coords, radius, grid_spacing=0.05)
print(f"Coarse: {volume_coarse:.2f}, Fine: {volume_fine:.2f}")
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Metadata
Release files for pyvolgrid 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyvolgrid-0.2.0.tar.gz | 8.7 kB | With provenance | Details for pyvolgrid-0.2.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| pyvolgrid-0.2.0-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details for pyvolgrid-0.2.0-cp312-abi3-win_amd64.whl |
| pyvolgrid-0.2.0-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 | Details for pyvolgrid-0.2.0-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
| pyvolgrid-0.2.0-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details for pyvolgrid-0.2.0-cp312-abi3-macosx_11_0_arm64.whl |
| pyvolgrid-0.2.0-cp312-abi3-macosx_10_13_x86_64.whl | CPython 3.12 | abi3 | macOS 10.13+ x86-64 | Details for pyvolgrid-0.2.0-cp312-abi3-macosx_10_13_x86_64.whl |
Total release size: 313.6 kB
Release files / pyvolgrid-0.2.0.tar.gz
| Download URL | pyvolgrid-0.2.0.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd76195778bacb5e0d33d6ddc4cdb76a452df88b88f04829ba0db59a394941d3
|
|
BLAKE2b-256 checksum How to use checksums |
27f0d6874b7672c5504f2171ef538d6bea7b266917fc8541d183e46041303120
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 10, 2025.
Transparency logRelease files / pyvolgrid-0.2.0-cp312-abi3-win_amd64.whl
| Download URL | pyvolgrid-0.2.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 50.4 kB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
96d2ab8b6b158861c2800ce939289ad87d6026c64b4a9383f07d36970c8f9d3b
|
|
BLAKE2b-256 checksum How to use checksums |
8cccc455cd12edbac33992ec422e02e3132db39154b94c55e8f00d39c726eab3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 10, 2025.
Transparency logRelease files / pyvolgrid-0.2.0-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyvolgrid-0.2.0-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 163.8 kB |
| Tags | CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2dc7b52936f22f69be3047a56e9a543dc821c38449ed6a9ce50b74a2d7c2e344
|
|
BLAKE2b-256 checksum How to use checksums |
959b1e47e733d04b99c2f3cf694f361e8b893d743744e00140993a8ecb1b79bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 10, 2025.
Transparency logRelease files / pyvolgrid-0.2.0-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | pyvolgrid-0.2.0-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 43.3 kB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ebe1e666ab48ce39b934c5625e72995400dcc54e9d3ed1117050dc80e7e560fe
|
|
BLAKE2b-256 checksum How to use checksums |
b7101da96bd6fc6d05f72109063cc31499a7c0681c7d07f4d778f3e8618de257
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 10, 2025.
Transparency logRelease files / pyvolgrid-0.2.0-cp312-abi3-macosx_10_13_x86_64.whl
| Download URL | pyvolgrid-0.2.0-cp312-abi3-macosx_10_13_x86_64.whl |
|---|---|
| Size | 47.4 kB |
| Tags | CPython 3.12 abi3 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
359134ad84b4f8ed81eb8e8d8512afea40bd96c260581d844004180b73eef203
|
|
BLAKE2b-256 checksum How to use checksums |
ceab69f05cf9dac74d3cd26c4fc5c044a7496535991e961a3e688f5cd06af10f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 10, 2025.
Transparency logSecurity for pyvolgrid 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for pyvolgrid-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 10, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.