The quadraturerules Python library is available on PyPI. It can be installed by running:
python -m pip install quadraturerules
The library's function single_integral_quadrature can be used to get the points and weights of quadrature rules for a single integral. For example the following snippet will create an order 3 Xiao–Gimbutas rule on a triangle:
from quadraturerules import Domain, QuadratureRule, single_integral_quadrature
points, weights = single_integral_quadrature(
QuadratureRule.XiaoGimbutas,
Domain.Triangle,
3,
)
Note that the points returned by the library are represented using barycentric coordinates.
The Python quadraturerules library can be generated from the templates in the online encyclopedia of quadrature rules GitHub repo. First clone the repo and move into the library directory:
git clone https://github.com/quadraturerules/quadraturerules.git
cd quadraturerules/library
The Python library can then be generated by running:
python build.py python
This will create a directory called python.build containing the Python source code.
Tests can then be run by moving into this folder and using pytest:
cd python.build
python -m pytest test/