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.2.tar.gz (7.7 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.2-cp314-cp314-win_amd64.whl (76.2 kB view details)

Uploaded CPython 3.14Windows x86-64

pyvolgrid-0.1.2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (79.5 kB view details)

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

pyvolgrid-0.1.2-cp314-cp314-macosx_11_0_arm64.whl (61.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyvolgrid-0.1.2-cp314-cp314-macosx_10_15_x86_64.whl (66.8 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

pyvolgrid-0.1.2-cp313-cp313-win_amd64.whl (74.2 kB view details)

Uploaded CPython 3.13Windows x86-64

pyvolgrid-0.1.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (79.3 kB view details)

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

pyvolgrid-0.1.2-cp313-cp313-macosx_11_0_arm64.whl (61.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyvolgrid-0.1.2-cp313-cp313-macosx_10_13_x86_64.whl (66.7 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

pyvolgrid-0.1.2-cp312-cp312-win_amd64.whl (74.3 kB view details)

Uploaded CPython 3.12Windows x86-64

pyvolgrid-0.1.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (78.9 kB view details)

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

pyvolgrid-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (61.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyvolgrid-0.1.2-cp312-cp312-macosx_10_13_x86_64.whl (66.7 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

pyvolgrid-0.1.2-cp311-cp311-win_amd64.whl (73.1 kB view details)

Uploaded CPython 3.11Windows x86-64

pyvolgrid-0.1.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (77.6 kB view details)

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

pyvolgrid-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (61.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyvolgrid-0.1.2-cp311-cp311-macosx_10_9_x86_64.whl (65.0 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: pyvolgrid-0.1.2.tar.gz
  • Upload date:
  • Size: 7.7 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.2.tar.gz
Algorithm Hash digest
SHA256 f13231af0ecfb120130c070fdb97cb0458538bd8f42541da316a04caf1840c65
MD5 d1c0bd1e3ee8c5e670643eb46a2c4cab
BLAKE2b-256 77ff33f73b794ab1afaf061f2db8db7d1e4ca67571af3d15024efa9b0c5d2782

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2.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.2-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pyvolgrid-0.1.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 76.2 kB
  • Tags: CPython 3.14, 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.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2085dc1c8b6b76d65a1b8bbe329756b5d5b108f7d5e7b1ca2d62bc90ae826d9c
MD5 8fd80b1aac4ddf3ebc2031fa290c2375
BLAKE2b-256 7a242668f36a748c3731a186d34b684518f9714c1a5c83567babef4b3df3d25b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-cp314-cp314-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.2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fca77ccfa6cb2bc5fb432e934dc43fedfe1e0c05a00b7474250b7a732aab41f4
MD5 80e334372748624d948a7a5b1e113025
BLAKE2b-256 ef854e32884b21a886de88c19c73fe94841df1827b7278a0dd348dd032bb8d21

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-cp314-cp314-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.2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad52b501594d2504504112d290e04fa09f4d70c26234058788d32c6b8a6369b4
MD5 a56177940fab435eb6ca6a36a331bfff
BLAKE2b-256 9e0bdc5a4aa1ecb70d44af9ec0254a5d295284496ce0096817795a677cfaf68d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-cp314-cp314-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.2-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7f45fdfc387fa0b4d879dd4a509804ae88b60e867a616658398dbcc8f557e854
MD5 5c1577c1b7f138a23bedfbb51473d85f
BLAKE2b-256 de1f8d3d8b113ae92bb3f6ca8ffe6a720e689be531eafb92b50cc52304619b39

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-cp314-cp314-macosx_10_15_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.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyvolgrid-0.1.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 74.2 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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3bfcac4f4774bb5c77fd820cbaead9f18ac2ffd2257124f99c7f41095a9dde1c
MD5 519b6a6f4a6065e4ed107419cb8dc1d6
BLAKE2b-256 0b64574960e9e9ec2782f4f123b7e5ae310bfae47d698c45debc470435c77443

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fad609add89430365ecd367892bdf256bf7eee25561a23db81c92989f57952bd
MD5 86d9a8ac585b5b2683c0730c9f261ef9
BLAKE2b-256 39a8755e02c874254212efb9f24515b32a7e0d1fc68a4933011eb2d6f7cf4a5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab4cd506581636ac778125ab8cbde9705c6932a4ec804730532a76bd4fe8c542
MD5 065d41c45ef9dbcf58e4f25d953351b5
BLAKE2b-256 a48b46a17a08b9aeda682c8a212fc64a09213a5a01d66dde173602bc20841c62

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ffe10f341dc030a90eefaac9f7d913ecbed06b0777f142eb4a13ec1e0088ccf8
MD5 b42ab9b85af928f9dc9d4157b4ac0709
BLAKE2b-256 608b342bdbf56434721ca902895b392ca4bce812dc4de293c2479436d128eae1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyvolgrid-0.1.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 74.3 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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f36044749e133d6ee1822e722882ef1a9fff160c50c7892eeb479efb4d3939a4
MD5 c3249cf00aeccf84fa1dad307defbe97
BLAKE2b-256 fbe01c6f961747830977829fe637ab6c28e72ffdd7d53e97db7c52e092a7bf42

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b455801ff3aa8c04ca81e6f5eb973be1f742d42dae79b48161ef3d9c059441a4
MD5 56f9849ebc7859b4b8d8f653b3c99e26
BLAKE2b-256 03f972b5a508fa4eba643a09d7d5f243764615aaa7a485f6a5dba38af56599cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e37d275bf8efe37d974e833779a8961a35cd2b56f5b79d2eebbdc01569836765
MD5 4a351d32290adba563d42116cd66aabc
BLAKE2b-256 100233f8bb4d087c526dd3cdc895f02846b7b3f81b6427531a26685b7597f87a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d3340c02d8b55d6f055fc0be977005043d63bb160d216bdac8ea9150f99236d9
MD5 a949424deaac354ceda82bb77d9ec9cb
BLAKE2b-256 6e86c439022f11f9506302fe1b38e9038316672a16974faa18784bfd9c07e31d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyvolgrid-0.1.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 73.1 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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bf6b4892a262edf82904eac504dfb95a7649e31fd65f1d4d68b0cd95bd572f76
MD5 0b9000ac3e3502cf7ae68932a5a3250a
BLAKE2b-256 c3b4e88444a5044a30ad7772048170231d4291c4472fab99aa39d7a777a1e7e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3dfc1c6a1e47a83839dc6c79671b204adce5a6ff4d8b3466495b755b18a544fb
MD5 69ab2b94513450cf4107f13709f99d75
BLAKE2b-256 a2a63ea6cb96f84e954df9a88db6924ff631092267799168b844f973d3164da4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 803944de45fa36dcb70ccc0b91345746ba786d97c16095c166b47899f5e6aaf5
MD5 0da45c34636d06812c0090df456b8db5
BLAKE2b-256 7119331d79b0e9728a3571bdd189685c835eb0579137d5153d0b31676e02238c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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.2-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyvolgrid-0.1.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 806d841d84f4e06ab1e1441f8ff8bdfdf178fa30b8acdb587214a59b6a9c2e65
MD5 4bd043eb3d9505a05638774444af5810
BLAKE2b-256 364efb9223dc205a9944dceec4a60c0c208f9b5d4695087d3cd28a95a84573e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvolgrid-0.1.2-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