Skip to main content

test status license badge link to PyPI link to Zenodo/DOI

  • Changelog
  • Licensed under MPL v2.0 (except John Burkardt’s Lebedev code which is redistributed under LGPL v3.0)

Numgrid

Numgrid is a library that produces numerical integration grid for molecules based on atom coordinates, atom types, and basis set information. This library provides Rust and Python bindings.

Who are the people behind this code?

Authors

  • Radovan Bast

Contributors

  • Roberto Di Remigio (OS X testing, streamlined Travis testing, better C++, error handling)

For a list of all the contributions see https://github.com/dftlibs/numgrid/contributors.

Acknowledgements

  • Simon Neville (reporting issues)
  • Jaime Axel Rosal Sandberg (reporting issues)

This tool uses SPHERE_LEBEDEV_RULE, a C library written by John Burkardt which computes a Lebedev quadrature rule over the surface of the unit sphere in 3D, see also: http://people.sc.fsu.edu/~jburkardt/c_src/sphere_lebedev_rule/sphere_lebedev_rule.html

This library uses and acknowledges the MolSSI BSE (https://molssi-bse.github.io/basis_set_exchange/), which is a rewrite of the Basis Set Exchange (https://bse.pnl.gov/bse/portal) and is a collaboration between the Molecular Sciences Software Institute (http://www.molssi.org) and the Environmental Molecular Sciences Laboratory (https://www.emsl.pnl.gov).

Citation

If you use this tool in a program or publication, please acknowledge its author(s)

@misc{numgrid,
  author    = {Bast, Radovan},
  title     = {Numgrid: Numerical integration grid for molecules},
  month     = {7},
  year      = {2024},
  publisher = {Zenodo},
  version   = {v2.2.0},
  doi       = {10.5281/zenodo.1470276},
  url       = {https://doi.org/10.5281/zenodo.1470276}
}

@misc{sphere_lebedev_rule,
  author = {Burkardt, John},
  title  = {SPHERE_LEBEDEV_RULE: Quadrature Rules for the Unit Sphere},
  year   = {2010},
  url    = {https://people.sc.fsu.edu/~jburkardt/c_src/sphere_lebedev_rule/sphere_lebedev_rule.html}
}

I kindly ask you to also cite the latter since Numgrid is basically a "shell" around SPHERE_LEBEDEV_RULE, with added radial integration and molecular partitioning.

Would you like to contribute?

Yes please! Please follow this excellent guide. We do not require any formal copyright assignment or contributor license agreement. Any contributions intentionally sent upstream are presumed to be offered under terms of the Mozilla Public License Version 2.0.

Requirements

Installation

Installing via pip

python -m pip install numgrid

Building from sources and testing

Building the code:

cargo build --release

Testing the Rust interface:

cargo test --release

Running also the longer tests:

cargo test --release -- --ignored

Testing the Python layer:

pip install -r requirements.txt  # ideally into a virtual environment
maturin develop
pytest tests/test.py

API

The API changed

The API changed (sorry!) for easier maintenance and simpler use:

  • No initialization or deallocation necessary.

  • One-step instead of two steps (since the radial grid generation time is negligible compared to space partitioning, it did not make sense anymore to separate these steps and introduce a state).

  • alpha_min is given as dictionary which saves an argument and simplifies explaining the API.

  • The library now provides Rust and Python bindings. It used to provide C and Fortran bindings. The C/Fortran code lives on the cpp-version branch. I might bring the C interfaces back into the Rust code if there is sufficient interest/need.

Units

Coordinates are in bohr.

Python example

As an example let us generate a grid for the water molecule:

import numgrid

radial_precision = 1.0e-12
min_num_angular_points = 86
max_num_angular_points = 302

proton_charges = [8, 1, 1]

center_coordinates_bohr = [(0.0, 0.0, 0.0), (1.43, 0.0, 1.1), (-1.43, 0.0, 1.1)]

# cc-pVDZ basis
alpha_max = [
    11720.0,  # O
    13.01,  # H
    13.01,  # H
]
alpha_min = [
    {0: 0.3023, 1: 0.2753, 2: 1.185},  # O
    {0: 0.122, 1: 0.727},  # H
    {0: 0.122, 1: 0.727},  # H
]

for center_index in range(len(center_coordinates_bohr)):
    # atom grid using explicit basis set parameters
    coordinates, weights = numgrid.atom_grid(
        alpha_min[center_index],
        alpha_max[center_index],
        radial_precision,
        min_num_angular_points,
        max_num_angular_points,
        proton_charges,
        center_index,
        center_coordinates_bohr,
        hardness=3,
    )

    # atom grid using basis set name
    # this takes a second or two for the REST API request
    coordinates, weights = numgrid.atom_grid_bse(
        "cc-pVDZ",
        radial_precision,
        min_num_angular_points,
        max_num_angular_points,
        proton_charges,
        center_index,
        center_coordinates_bohr,
        hardness=3,
    )

# radial grid (LMG) using explicit basis set parameters
radii, weights = numgrid.radial_grid_lmg(
    alpha_min={0: 0.3023, 1: 0.2753, 2: 1.185},
    alpha_max=11720.0,
    radial_precision=1.0e-12,
    proton_charge=8,
)

# radial grid (LMG) using basis set name
radii, weights = numgrid.radial_grid_lmg_bse(
    basis_set="cc-pVDZ",
    radial_precision=1.0e-12,
    proton_charge=8,
)

# radial grid with 100 points using Krack-Koster approach
radii, weights = numgrid.radial_grid_kk(num_points=100)

# angular grid with 14 points
coordinates, weights = numgrid.angular_grid(num_points=14)

Notes and recommendations

  • The smaller the radial_precision, the better grid.

  • For min_num_angular_points and max_num_angular_points, see “Angular grid” below.

  • alpha_max is the steepest basis set exponent.

  • alpha_min is a dictionary and holds the smallest exponents for each angular momentum (order does not matter).

  • Using center_index we tell the code which of the atom centers is the one we have computed the grid for.

  • num_angular_grid_points has to be one of the many supported Lebedev grids (see table on the bottom of this page).

Rust interface

Needs to be documented better but the library exposes functions with the same name as the Python interface and probably the best example on how it can be used are the integration tests.

Saving grid in NumPy format

The current API makes is relatively easy to export the computed grid in NumPy format.

In this example we save the angular grid coordinates and weights to two separate files in NumPy format:

import numgrid
import numpy as np

coordinates, weights = numgrid.angular_grid(14)

np.save("angular_grid_coordinates.npy", coordinates)
np.save("angular_grid_weights.npy", weights)

Parallelization

The Becke partitioning step is parallelized using Rayon. In other words, this step should be able to use all available cores on the computer or computing node. Since grids are currently generated atom by atom, it is also possible to parallelize "outside" by the caller.

If you need to limit the number of cores used by Rayon, you can set (in this case limiting to 4 threads):

export RAYON_NUM_THREADS=4

Space partitioning

The molecular integration grid is generated from atom-centered grids by scaling the grid weights according to the Becke partitioning scheme, JCP 88, 2547 (1988). The default Becke hardness is 3.

Radial grid

Two choices are available:

Advantage of LMG scheme: The range of the radial grid is basis set dependent. The precision can be tuned with one single radial precision parameter. The smaller the radial precision, the better quality grid you obtain. The basis set (more precisely the Gaussian primitives/exponents) are used to generate the atomic radial grid range. This means that a more diffuse basis set generates a more diffuse radial grid.

Advantage of the KK scheme: parameter-free.

Angular grid

The angular grid is generated according to Lebedev and Laikov [A quadrature formula for the sphere of the 131st algebraic order of accuracy, Russian Academy of Sciences Doklady Mathematics, Volume 59, Number 3, 1999, pages 477-481].

The angular grid is pruned. The pruning is a primitive linear interpolation between the minimum number and the maximum number of angular points per radial shell. The maximum number is reached at 0.2 times the Bragg radius of the center.

The higher the values for minimum and maximum number of angular points, the better.

For the minimum and maximum number of angular points the code will use the following table and select the closest number with at least the desired precision:

{6,    14,   26,   38,   50,   74,   86,   110,  146,
 170,  194,  230,  266,  302,  350,  434,  590,  770,
 974,  1202, 1454, 1730, 2030, 2354, 2702, 3074, 3470,
 3890, 4334, 4802, 5294, 5810}

Taking the same number for the minimum and maximum number of angular points switches off pruning.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

numgrid-2.2.0-cp314-cp314-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.14Windows x86-64

numgrid-2.2.0-cp314-cp314-manylinux_2_38_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ x86-64

numgrid-2.2.0-cp314-cp314-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

numgrid-2.2.0-cp313-cp313-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.13Windows x86-64

numgrid-2.2.0-cp313-cp313-manylinux_2_38_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

numgrid-2.2.0-cp313-cp313-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

numgrid-2.2.0-cp312-cp312-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.12Windows x86-64

numgrid-2.2.0-cp312-cp312-manylinux_2_38_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

numgrid-2.2.0-cp312-cp312-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

numgrid-2.2.0-cp311-cp311-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.11Windows x86-64

numgrid-2.2.0-cp311-cp311-manylinux_2_38_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ x86-64

numgrid-2.2.0-cp311-cp311-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

numgrid-2.2.0-cp310-cp310-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.10Windows x86-64

numgrid-2.2.0-cp310-cp310-manylinux_2_38_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.38+ x86-64

numgrid-2.2.0-cp310-cp310-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file numgrid-2.2.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: numgrid-2.2.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for numgrid-2.2.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 93fa3d75f60deae957aa4d4ed61eb4f26d858f1a0e72460cc39289d150b3c0eb
MD5 94d8ff00701a6f0ac53c1b58c90865c4
BLAKE2b-256 6ab190fe01570ea1520ee1e3cc01e42545f3859f07586e393993c6b2111187be

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 0d394888ebf0d841095b6e22d5d1860ceee6149ec386e285a325fc2ca58612ac
MD5 cce3771e3c0fb554834df919afa7c109
BLAKE2b-256 7092839a0fe81848c5291c4d18fedbda33c6740c35254480c02934e848384c79

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c58b2c78f3ac97ff6b574737cd3a8649e88ce4a147119dd9051186a8d469909e
MD5 704135a2b4e91638c0759ceadf95d345
BLAKE2b-256 877a8cc192130fbc63bf5b338b83dcbfe98d4fa73c0a6ff3f3b150d70c59e5d8

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: numgrid-2.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for numgrid-2.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9ad58bb86ea6ce055d609c287c6aab384824b9b6676d5684d7c4f9b0e9b076f8
MD5 94089b9ed3ae841877be81eb70f3ef5a
BLAKE2b-256 6d164a609cf8d2efb716a5f2bb05b2cb5056a83daa497c1988316dce7dfd57ef

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 044b2b8374ece374f161b90f06acfdb7cf91c44a2d11fd9e7955bf11fba7d55d
MD5 84322525de515a01f54cca2fe0a7db50
BLAKE2b-256 f79c562ea370bae29bef0ffa6bb8825d2d5dd34c9f15ec43b84f75aaaf13f1f1

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 81757c0dd32652a03d57188a27225362f4326efb1c7c550c19b3699ae756f3d6
MD5 49afaec76c95fd0494480af7dde6e118
BLAKE2b-256 1b721557be7fd6fc223b61e15ed294c57087623530515798d92e87e3180ea237

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: numgrid-2.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for numgrid-2.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1aae4ba91db9ab2cf05f57e65b3fa9cfe47c22f91e21eb62a07133605c257cb2
MD5 6343e30151915894d3b3fe68cd918720
BLAKE2b-256 d101c03097168cafb8659dd49258f110aa43684f122cb431d51955625cf92a1b

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 42f95b666e2df50d67879d3963252e4a918088dbdce16cea30c53c9ec36e539b
MD5 7d0647d2703ab16705ef9b71e1df10ea
BLAKE2b-256 6a278beae5c925d4d77deb78afb41f2c87e11e84af179eee551608bb2b6b43df

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 50c3bac0dc449ae3a1afa83148cb3cc20d41313575440ac65fb97dbef16930c0
MD5 49a3db35695ea507425fd0dd1134e7e6
BLAKE2b-256 78f02d9fec260ee0ca0449d616bdd125598c93b3ebdabc3e57b8db17d178bb91

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: numgrid-2.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for numgrid-2.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b77f649c8370d2e92cdaaf72eeebd208e41fa11758322aacfec40e0209034b39
MD5 861777fdce4a7d0375a99cae22c5801b
BLAKE2b-256 51e63f5a3debe35d8a8d09e006199741ba42ef6b302d0f27a714a200d7c18aa8

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp311-cp311-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 86799df1bb8c002eb73b55769c72cae7d48ccb10bb22883df0f4919c5bd7ef0b
MD5 420344e5523f7deff065cedaa039b52c
BLAKE2b-256 5ddc420ffb7c073d9f0541beb1ab239ec88883cc4ffc0e33f8051a75e50a1086

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 69b333ae7c6e797d683e262d11d633de17e7dda3879ada2f9afc9ea42e09fbb2
MD5 e640fdb55138fabe6aa29d9f840c3d25
BLAKE2b-256 344995c514678c9492d57e7cd6a317e47fb594d1e55fb848b1b0141db4ca46ee

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: numgrid-2.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for numgrid-2.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8168654a3c884ab892d2328cca64090a1426098f4c6434bb80d44459ccfc27a7
MD5 c4d704ec550e89489547b2bd5bb8123d
BLAKE2b-256 f8026e56954395c5d4b8f35a4e526c67586c65a03105781b0ade936806df69a2

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp310-cp310-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 e119982bc2b31b740db154884b55e57e6e7a52c88b38a4abb0a9e3ee9ff7e207
MD5 22dd8c6ffef75dc52db31e8ef35faf38
BLAKE2b-256 c7b7f9d5ffa4f24153b341bdffae68cb4e0f0b601b43f29e05a294f6097b2d95

See more details on using hashes here.

File details

Details for the file numgrid-2.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for numgrid-2.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 83e56af8cb68e88e0bcf04e95d8b2d4624a20063542bc7de4f7a543726693eba
MD5 eb5c6d63afdbbabf379f54875863d92b
BLAKE2b-256 23c007123a1ea081d8c0e872eedb56fab49c12d7b73416bdc12d1cbf54a58fc4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.2.0 This release

15 files

2.1.2

12 files

2.1.1

15 files

2.1.0

10 files

2.0.2

10 files

2.0.1

12 files

2.0.0

9 files

1.1.2

1 file

1.1.1

1 file

1.1.0

1 file

1.0.2

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page