Skip to main content

Python package for estimating the total volume of overlapping spheres using a grid-based numerical approach.

Project description

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 .

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvolgrid-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyvolgrid-0.1.0-cp313-cp313-win_amd64.whl (72.1 kB view details)

Uploaded CPython 3.13Windows x86-64

pyvolgrid-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (75.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyvolgrid-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (58.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyvolgrid-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl (62.9 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

pyvolgrid-0.1.0-cp312-cp312-win_amd64.whl (72.1 kB view details)

Uploaded CPython 3.12Windows x86-64

pyvolgrid-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (75.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyvolgrid-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (58.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyvolgrid-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl (62.9 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

pyvolgrid-0.1.0-cp311-cp311-win_amd64.whl (71.0 kB view details)

Uploaded CPython 3.11Windows x86-64

pyvolgrid-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (73.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyvolgrid-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (58.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyvolgrid-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl (61.9 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

Details for the file pyvolgrid-0.1.0.tar.gz.

File metadata

  • Download URL: pyvolgrid-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyvolgrid-0.1.0.tar.gz
Algorithm Hash digest
SHA256 69bbf1031af2d533244eb372c88a44be7789108c0bc3e76dcac5d80b5130b842
MD5 fb54314fca27691c835f124815fa5cca
BLAKE2b-256 d29ba6e55950d196f62a47c70310d972f323e59fe0d622dd12d99a4c6208d2bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0.tar.gz:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyvolgrid-0.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 72.1 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyvolgrid-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d61d2b52a71ed1360264605c8c533b41253e8a524f5fe6bfeaa8ace70f983a72
MD5 b09641cd7efc34532d4cfa46073765a7
BLAKE2b-256 cc8f382a99a08280043dd4f3a2403656fc50905ef1410224523d3ab8aa7899fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp313-cp313-win_amd64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 724204d3a8a5f7b0398e3b57acd56dc47c056caf2ae789db2e2f43998bfe1226
MD5 6b7e3bce501af30b6cda1832639e8bb1
BLAKE2b-256 b3e39301c2a009cfda1aa1f94d267c350d2ef8e826d1bc1b4f3e5892b5f2f0ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f88bdcd7266b5d0c7f14d551df3d93e0d140aefaea92131c0b88a6958e2578e5
MD5 6aa41054ce9c19f305a9608ae938c3b3
BLAKE2b-256 345daac045492902b75a19886df7fda76d1eb289b0416ed279bc592b3cfe0326

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 73c2aa0423307f15a677cef1a86096949e0171e4d1c801ba17cf57d1b1618ef8
MD5 9d2e35cd389f4b1fd5d65ba389e3e251
BLAKE2b-256 12c176e73d21a8f2f375d72b3671dd758be04d25a7c6712ca78c07e450eae90e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyvolgrid-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 72.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyvolgrid-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ad7846cc734fc090cc381043d9e7717d0eccf7280c5c27cbe51ecbb4ee88fc8f
MD5 fa27b2a6bc4b96c2540f7931d163238c
BLAKE2b-256 396c8b5520da9c793c9b9fcf2657941127db99c25cc5dd727e939a849fb76f7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e23d180d9d7664be8e2228d605cbd8722b05e3ae0824738f66cb299679bae6e8
MD5 5bff0052cf60d41d642fc2bcc68cd7b1
BLAKE2b-256 ea84ae28b1588a973b58ac41f33786e931cd2513614184527b1b50cd5f73214d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d58e7540a4455897cd8e7987c92f9be4afc198645a138043b69b532b6061ce9c
MD5 14789242ddb9d21a6d73a9623281defd
BLAKE2b-256 cb5e8bf28c60f3fb6dbfc7c22466d98aa8a62e7ae650f1dbc448bf6cf376a28b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ecff95216169f980a06e2b989b3a03ebe0070023bdef9fcac2d4e859b8fb925e
MD5 953b756bc348d6b9724e82c74f89cffb
BLAKE2b-256 e90ca59d0e2c02b06fb1e904ee2743db9fef4487c96a9becc6ec242e26f4e7cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyvolgrid-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 71.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyvolgrid-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ecd4bab626997bf44c86a426a6a30c3b2e7fe4fa72f151b918b5f4eb9e517795
MD5 05b1268c1d273fd9feee1fc98b1b7ee6
BLAKE2b-256 11f237288861b719f2d6c036534a23c9e969de93a120994636ea209992bddb1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eb03a902b06f255a35955f42b03dabcc31ba63de6c41d9b55453197ca023a739
MD5 82a1115a3e511c9f0c780e053c7b4451
BLAKE2b-256 2ea1c4cb8ca7cdb163fc390ff721b0912aaaa8430eab38b18211bf5115680c41

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6bbb0b697b01882263d6e98dd9ee227e6dd4d9e0e46aee3afd3e436a830ef96c
MD5 db1c95040418809c1b610485b9034685
BLAKE2b-256 aea257f61fe729b8ad2976ee1e31aefeaa41723bdf5e0fe833e111f08eb7a1ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvolgrid-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7d46321646b8a7548024f1b59fc390068ec5e675012082ce88509a7ae79df5d1
MD5 6beb29bd8a3491e8b2d7152699662653
BLAKE2b-256 a0a9617e45577173c0849c98ff81427dd60ac026a677deb26dfbf46188153a77

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: build-wheels.yml on ugSUBMARINE/pyvolgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page