numgrid

Numerical integration grid for molecules.

https://github.com/dftlibs/numgrid

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 14 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.4%) to scientific vocabulary

Keywords

dft grid integration molecular python-interface
Last synced: 6 months ago · JSON representation ·

Repository

Numerical integration grid for molecules.

Basic Info
  • Host: GitHub
  • Owner: dftlibs
  • License: mpl-2.0
  • Language: Rust
  • Default Branch: main
  • Homepage:
  • Size: 2.77 MB
Statistics
  • Stars: 50
  • Watchers: 6
  • Forks: 14
  • Open Issues: 7
  • Releases: 11
Topics
dft grid integration molecular python-interface
Created almost 11 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License Citation Zenodo

README.md

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 SPHERELEBEDEVRULE, 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/csrc/spherelebedevrule/spherelebedev_rule.html

This library uses and acknowledges the MolSSI BSE (https://molssi-bse.github.io/basissetexchange/), 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) ```bibtex @misc{numgrid, author = {Bast, Radovan}, title = {Numgrid: Numerical integration grid for molecules}, month = {7}, year = {2024}, publisher = {Zenodo}, version = {v2.1.1}, doi = {10.5281/zenodo.1470276}, url = {https://doi.org/10.5281/zenodo.1470276} }

@misc{spherelebedevrule, author = {Burkardt, John}, title = {SPHERELEBEDEVRULE: Quadrature Rules for the Unit Sphere}, year = {2010}, url = {https://people.sc.fsu.edu/~jburkardt/csrc/spherelebedevrule/spherelebedev_rule.html} } ```

I kindly ask you to also cite the latter since Numgrid is basically a "shell" around SPHERELEBEDEVRULE, 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

bash python -m pip install numgrid

Building from sources and testing

Building the code: bash cargo build --release

Testing the Rust interface: bash cargo test --release

Running also the longer tests: bash cargo test --release -- --ignored

Testing the Python layer: bash 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: ```python import numgrid

radialprecision = 1.0e-12 minnumangularpoints = 86 maxnumangular_points = 302

proton_charges = [8, 1, 1]

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

cc-pVDZ basis

alphamax = [ 11720.0, # O 13.01, # H 13.01, # H ] alphamin = [ {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 centerindex in range(len(centercoordinatesbohr)): # atom grid using explicit basis set parameters coordinates, weights = numgrid.atomgrid( alphamin[centerindex], alphamax[centerindex], radialprecision, minnumangularpoints, maxnumangularpoints, protoncharges, centerindex, centercoordinates_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.radialgridlmg( alphamin={0: 0.3023, 1: 0.2753, 2: 1.185}, alphamax=11720.0, radialprecision=1.0e-12, protoncharge=8, )

radial grid (LMG) using basis set name

radii, weights = numgrid.radialgridlmgbse( basisset="cc-pVDZ", radialprecision=1.0e-12, protoncharge=8, )

radial grid with 100 points using Krack-Koster approach

radii, weights = numgrid.radialgridkk(num_points=100)

angular grid with 14 points

coordinates, weights = numgrid.angulargrid(numpoints=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: ```python import numgrid import numpy as np

coordinates, weights = numgrid.angular_grid(14)

np.save("angulargridcoordinates.npy", coordinates) np.save("angulargridweights.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): bash 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.

Owner

  • Name: DFT libraries
  • Login: dftlibs
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.1.0
message: If you use Numgrid, please cite it as below.
authors:
  - family-names: Bast
    given-names: Radovan
title: "Numgrid: Numerical integration grid for molecules"
version: 2.0.0
license: MPL-2.0
doi: 10.5281/zenodo.1470276
date-released: 2021-01-03

GitHub Events

Total
  • Release event: 1
  • Watch event: 3
  • Issue comment event: 2
  • Push event: 2
  • Create event: 1
Last Year
  • Release event: 1
  • Watch event: 3
  • Issue comment event: 2
  • Push event: 2
  • Create event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 419
  • Total Committers: 5
  • Avg Commits per committer: 83.8
  • Development Distribution Score (DDS): 0.117
Top Committers
Name Email Commits
Radovan Bast b****t@u****m 370
Radovan Bast r****t@u****m 37
Roberto Di Remigio r****o@g****m 10
Roberto Di Remigio r****o@u****o 1
Anthony Scemama s****a@i****r 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 44
  • Total pull requests: 15
  • Average time to close issues: 8 months
  • Average time to close pull requests: 9 months
  • Total issue authors: 9
  • Total pull request authors: 4
  • Average comments per issue: 3.07
  • Average comments per pull request: 1.13
  • Merged pull requests: 8
  • Bot issues: 0
  • Bot pull requests: 7
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: about 3 hours
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • bast (28)
  • manassharma07 (6)
  • robertodr (3)
  • zc62 (2)
  • lnw (1)
  • susilehtola (1)
  • levineds (1)
  • gayverjr (1)
  • patrashantigopal (1)
Pull Request Authors
  • dependabot[bot] (12)
  • bast (4)
  • robertodr (4)
  • scemama (1)
Top Labels
Issue Labels
question (1)
Pull Request Labels
dependencies (12) rust (11)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 156 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 21
  • Total maintainers: 1
proxy.golang.org: github.com/dftlibs/numgrid
  • Versions: 11
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.7%
Dependent repos count: 5.9%
Last synced: 6 months ago
pypi.org: numgrid

Numerical integration grid for molecules.

  • Versions: 10
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 156 Last month
Rankings
Forks count: 9.6%
Stargazers count: 9.9%
Dependent packages count: 10.1%
Average: 13.9%
Downloads: 18.4%
Dependent repos count: 21.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

Cargo.lock cargo
  • 146 dependencies
requirements.txt pypi
  • black *
  • maturin *
  • pytest *
src/tables/requirements.txt pypi
  • black *
.github/workflows/build-wheels.yml actions
  • actions/checkout v2 composite
  • messense/maturin-action v1 composite
.github/workflows/test.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
.github/workflows/package-pypi.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
Cargo.toml cargo