https://github.com/ifilot/pylebedev
Python Library for Lebedev Quadrature points and weights
https://github.com/ifilot/pylebedev
lebedev python quadrature unit-sphere
Last synced: 4 months ago
JSON representation
Python Library for Lebedev Quadrature points and weights
- Host: GitHub
- URL: https://github.com/ifilot/pylebedev
- Owner: ifilot
- License: gpl-3.0
- Created: 2022-07-13T12:56:52.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-04T06:23:21.000Z (almost 2 years ago)
- Last Synced: 2026-01-04T11:46:08.191Z (5 months ago)
- Topics: lebedev, python, quadrature, unit-sphere
- Language: Python
- Homepage: https://pylebedev.imc-tue.nl/
- Size: 535 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyLebedev
[](https://github.com/ifilot/pylebedev/actions/workflows/build_conda.yml)
[](https://github.com/ifilot/pylebedev/actions/workflows/build_wheels.yml)
[](https://codecov.io/gh/ifilot/pylebedev)
[](https://anaconda.org/ifilot/pylebedev)
[](https://pypi.org/project/pylebedev/)
[](https://www.gnu.org/licenses/gpl-3.0)
## Purpose
PyLebedev is a python package that stores [Lebedev quadrature](https://en.wikipedia.org/wiki/Lebedev_quadrature) coefficients for integration over the unit sphere.
## Installation
### Anaconda
[](https://anaconda.org/ifilot/pylebedev)
[](https://anaconda.org/ifilot/pylebedev)
[](https://anaconda.org/ifilot/pylebedev)
Open Anaconda prompt and type
```
conda install -c ifilot pylebedev
```
### PyPi
[](https://pypi.org/project/pylebedev/)
[](https://pypi.org/project/pylebedev/)

Open a terminal and type
```
pip install pylebedev
```
## Usage
```python
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()
```