dgasmith / gau2grid

Fast computation of a gaussian and its derivative on a grid.
https://gau2grid.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
29 stars 15 forks source link
c collocations grid numpy python

Travis CI Appveyor Codecov Documentation Status

gau2grid

A collocation code for computing gaussians on a grid of the form:

out_Lp = x^l y^m z^n \sum_i coeff_i e^(exponent_i * (|center - p|)^2)

Where the returned matrix dimension are the angular momentum (L) by number of requested points (p).

import gau2grid
import numpy as np

# Build coordinates along the Z axis
>>> xyz = np.zeros((3, 5))
>>> xyz[2] = np.arange(5)

# Compute a 's' gaussian with a scaling and exponent of one at the origin
>>> ret = gau2grid.collocation(xyz, 0, [1], [1], [0, 0, 0])
>>> print(ret["PHI"])
[[  1.00000e+00   3.67879e-01   1.83156e-02   1.23409e-04   1.12535e-07]]

# Compute a 'p' gaussian with a scaling and exponent of one at the origin
>>> ret = gau2grid.collocation(xyz, 1, [1], [1], [0, 0, 0], spherical=False)
>>> print(ret["PHI"])
[[  0.00000e+00   0.00000e+00   0.00000e+00   0.00000e+00   0.00000e+00]
 [  0.00000e+00   0.00000e+00   0.00000e+00   0.00000e+00   0.00000e+00]
 [  0.00000e+00   3.67879e-01   3.66312e-02   3.70229e-04   4.50140e-07]]

# Note that the X and Y components are zero as they are orthogonal to our Z vector.

The returned matrix can be in either cartesian or regular solid harmonics. There are currently three algorithms in which to compute these collocation matrices:

See the documentation for more information!

Building Gau2Grid

The C library is built with CMake and has C no required dependancies other than the standard library. A CMake and build example can found below:

cmake -H. -Bobjdir
cd objdir; make -j2

Several common CMake options are as follow:

Python installation

The gau2grid program (without the optimized C library) can be installed using the canonical setup.py script,

python setup.py install

Authors

This code was inspired by a number of folks and quite a few provided excellent advice.