PyLebedev: Lebedev quadrature coefficients
PyLebedev is a pure-Python package for handling integration of function over the surface of a unit sphere by means of Lebedev quadrature.
A simple example how PyLebedev works is given below
from pylebedev import PyLebedev
import numpy as np
def main():
"""
Test Lebedev quadrature for probe function
"""
# build library
leblib = PyLebedev()
# exact answer to function "testfunc"
exact = 216.0 * np.pi / 35.0
r,w = leblib.get_points_and_weights(9)
integral = 4.0 * np.pi * np.sum(w * tfunc(r[:,0], r[:,1], r[:,2]))
print('Integral: %f vs Exact: %f' % (integral, exact))
def tfunc(x,y,z):
"""
Trial function to test
Adapted from: https://cbeentjes.github.io/files/Ramblings/QuadratureSphere.pdf
This function has the exact result upon integration over a unit sphere
of 216/35 * pi
"""
return 1 + x + y**2 + x**2*y + x**4 + y**5 + x**2*y**2*z**2
if __name__ == '__main__':
main()
The result of this code is:
Integral: 19.388115 vs Exact: 19.388115
The set of available orders and corresponding number of sampling points is given in the table below.
Order |
Number of points |
---|---|
3 |
6 |
5 |
14 |
7 |
26 |
9 |
38 |
11 |
50 |
13 |
74 |
15 |
86 |
17 |
110 |
19 |
146 |
21 |
170 |
23 |
194 |
25 |
230 |
27 |
266 |
29 |
302 |
31 |
350 |
35 |
434 |
41 |
590 |
47 |
770 |
53 |
974 |
59 |
1202 |
65 |
1454 |
71 |
1730 |
77 |
2030 |
83 |
2354 |
89 |
2702 |
95 |
3074 |
101 |
3470 |
107 |
3890 |
113 |
4334 |
119 |
4802 |
125 |
5294 |
131 |
5810 |
PyLebedev has been developed at the Eindhoven University of Technology, Netherlands. PyLebedev and its development are hosted on github. Bugs and feature requests are ideally submitted via the github issue tracker.