Numerical integration grid for molecules.
Project description
- 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 = {1},
year = {2021},
publisher = {Zenodo},
version = {v2.1.1},
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
- Python (3.8 - 3.12).
- For the Rust version: A Rust installation.
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
andmax_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:
- Lindh-Malmqvist-Gagliardi (https://dx.doi.org/10.1007/s002140100263)
- Krack-Köster (https://doi.org/10.1063/1.475719)
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file numgrid-2.1.1-cp312-none-win_amd64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp312-none-win_amd64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fd87d0208dbbe0003863c590f1415685b463bd8ed7c02bf3f0e9ef98fc3cfa9 |
|
MD5 | 428af2a9732f00ab23e14617988659e2 |
|
BLAKE2b-256 | 851d8efa5e2b25c0123391c36d45321ac5d6ed2804b9c7e24121ac77c3b7f3dd |
File details
Details for the file numgrid-2.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 568689ee8df661d6a39bc17e7000de8c03d720c5e85eee5c1b49947f819ab96e |
|
MD5 | 4cf39f38fe6120bf907786a96a71075c |
|
BLAKE2b-256 | e7e0137aa93ea6a49ff3dc909fea6058c8ce90825f77b6df4b8807f5bfcf2f9a |
File details
Details for the file numgrid-2.1.1-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62fe15c44a7bbc99640232a1ca2fa7c6f17adb8bdbfa4ea80953fd8156ff2d2b |
|
MD5 | 10e039d8c1e213acafb3e8f98a32eb25 |
|
BLAKE2b-256 | 04f691b21520d51ac333f8772975fcdb64a13fef63fe10fb1024fc6889873000 |
File details
Details for the file numgrid-2.1.1-cp311-none-win_amd64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp311-none-win_amd64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 442e84449779cc612d1f7675416e948cd0e7484cfda233ac03994d353e3e8bf5 |
|
MD5 | 450e6ae2c2f4a845b308e797bcd1c704 |
|
BLAKE2b-256 | 54801cdb62208b355262d5ab7fe7eb7f1f47eb71c998298f7e50a9fa0c0a335f |
File details
Details for the file numgrid-2.1.1-cp311-cp311-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50c97fe6baad227682555c08dd1eb10e7466b3bcce4d013b5c889d227f935744 |
|
MD5 | 72e51061c00e633ced4939228be9fa8f |
|
BLAKE2b-256 | 8cd517fc3d3fa59c7343efa9b12a8e9fa81782266c4a2269392beb11fc31a1ad |
File details
Details for the file numgrid-2.1.1-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fcbfb76b1c1eaae09b4310a2537a0e345ffcb351fa7f4169ce271c99fcee1d6 |
|
MD5 | bca24c2c3b9f6d1f4ff73dc078fa98f8 |
|
BLAKE2b-256 | 568c99cc487ed839d218657c481e3a7f1abcf8996184f7a773c62864afda2509 |
File details
Details for the file numgrid-2.1.1-cp310-none-win_amd64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp310-none-win_amd64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e41093dabed4c1589332c13cdd4741f601ad8d2bbf330a204b653a6306a3441d |
|
MD5 | bcb2dc91589ab4b37d6f95b8a4ac8968 |
|
BLAKE2b-256 | 69884226609020768073c141410bfb7d05c812798762e3bbb5a9e79e763873fb |
File details
Details for the file numgrid-2.1.1-cp310-cp310-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1db4b6dffc2f7fc1fe3d4e6408f9a4dca3d9b67562c051a296c357a6bf432ed6 |
|
MD5 | 0ea5e3acd49e5d98cdb94a4dda325eeb |
|
BLAKE2b-256 | 863790da9d0ad927bcc100f873a04bf588b6ce22714989ddf8de94ab64548979 |
File details
Details for the file numgrid-2.1.1-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecfcb3fb72d8ea007a497fa1ec82f723f1b07e2378f3bc96840fcdc2caa2c3a2 |
|
MD5 | 16eb4aeb941d547fc7f9543e72475eb2 |
|
BLAKE2b-256 | 071090026986c68c1eeb2637fc206580377c63f7a14bc75142a4f965e58cd106 |
File details
Details for the file numgrid-2.1.1-cp39-none-win_amd64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp39-none-win_amd64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dd4faea675a30d0cef52e81ec04e078d59042b402fa8fc6a8c6f4766a094a61 |
|
MD5 | 2dc14cb1040e8331c616185be3a9741c |
|
BLAKE2b-256 | 01525a673a453e238706bf643c6ae3004e627158965e09d3ab5e4edc65a70018 |
File details
Details for the file numgrid-2.1.1-cp39-cp39-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp39-cp39-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.9, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8cf5734c6cceaddedfcf6cab84e795c9514577b6b320b3e71ca63ab1d4b4b1e |
|
MD5 | ff089a963b4c7772c40f3b731faa15dd |
|
BLAKE2b-256 | 4bc596d6b102eac4c00771ac8fe582908c721e5693f0ece965999ea5ec1ef57a |
File details
Details for the file numgrid-2.1.1-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38bcce8af3bad8509446cc1e6153accef9d51c52771ae286087738c033ab1933 |
|
MD5 | dfa92f45906fedc0182bfd4bf215ab7b |
|
BLAKE2b-256 | 8cf0274c9aa83a55bd500b8d73b5e893d444768c693c3e1cae4eba3da9421c0c |
File details
Details for the file numgrid-2.1.1-cp38-none-win_amd64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp38-none-win_amd64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9f1a2a62d4a432d20d33bd8e9bbbd4afe352753f895a6b12e3c944dc9dcb5a5 |
|
MD5 | 62f24d58ba5923afd83fcabb3d4b08f0 |
|
BLAKE2b-256 | 4b23747dbb5293b279c000453c20dddb650ff1cc734ab48281785126fc738cf7 |
File details
Details for the file numgrid-2.1.1-cp38-cp38-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp38-cp38-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.8, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 691b645c51eab3638179f938577df59bb2266900a98cdde9462f35d2cbd761a4 |
|
MD5 | d512f8d6c8f6eab2a34afbea6ccfac6e |
|
BLAKE2b-256 | 2f0cda50faab27ab4dc814e5156cf18c9446157e49622e7b0e0dd2807712928d |
File details
Details for the file numgrid-2.1.1-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: numgrid-2.1.1-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e7099c35f9a274cc0015b6bd2fce0a823dd888c1154f6ff409932845303802d |
|
MD5 | 92d272ce8ade79267ef776d5cde9c1e5 |
|
BLAKE2b-256 | 8e6ca0c8b50b9ef0ecd4cebd54caf57168ca6cbd4c8dc439cc4f5240e7347161 |