Tools for moments, Gaussian quadrature, orthogonal polynomials and quadrature-based moment methods for the numerical solution of spatially homogeneous population balance equations.
Project description
QuadMomPy is a library for all sorts of fun with moments, Gaussian quadratures, orthogonal polynomials and quadrature-based moment methods for the solution of spatially homogeneous population balance equations.
Installation
The QuadMomPy package can be easily installed by
pip install quadmompy
or from the project repository
pip install -e .
A comprehensive documentation and additional examples are only available in the project repository on GitLab/GitHub. Use
git clone https://gitlab.com/puetzm/quadmompy.git
to clone the code from the GitLab repository or
git clone https://github.com/puetzmi/quadmompy.git
to clone from the project mirror on GitHub.
The repository also includes a Dockerfile to run tests and use the QuadMomPy package in a docker image.
Usage
A simple example of a moment inversion using the quadrature method of moments with the Wheeler algorithm to compute a Gaussian quadrature rule from a set of moments is given below.
import numpy as np
from quadmompy import qbmm
from quadmompy.qbmm.univariate import Qmom
from quadmompy.core.inversion import Wheeler
# Create Qmom object using the Wheeler
# algorithm for moment inversion
qmom = qbmm.new(qbmm_type=Qmom, qbmm_setup={'inv_type': Wheeler})
# Nodes `x` and weights `w` of a weighted
# sum of degenerate distributions
x = np.array([-0.5, 0.1, 1., 1.4])
w = np.array([0.15, 0.4, 0.4, 0.05])
# Compute moments of the distribution
n = len(x)
moments = np.vander(x, 2*n).T[::-1]@w
# Invert moments to obtain quadrature nodes and
# weights, which should, in this particular
# equal the nodes and weights defined above.
x_quad, w_quad = qmom.moment_inversion(moments)
print(f"x = {x_quad}")
print(f"w = {w_quad}")
For more examples of how to use the numerous classes provided with this package, see the tests directory and the examples directory in the project repository on GitLab (https://gitlab.com/puetzm/quadmompy.git) and the project mirror on GitHub(https://github.com/puetzmi/quadmompy.git).
License
Copyright (c) 2022 Michele Puetz.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file quadmompy-0.9.5.tar.gz
.
File metadata
- Download URL: quadmompy-0.9.5.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cde09809afed8a20cd6b06763cd059c61ff8cf5c9ab00d8a864a3e6f3486063 |
|
MD5 | d709387941f58cb0c4219a26f2fa829c |
|
BLAKE2b-256 | ca9009932c34845fea24395df0cafe896c53919dd1b235158a9150206ca4e38e |
File details
Details for the file quadmompy-0.9.5-py3-none-any.whl
.
File metadata
- Download URL: quadmompy-0.9.5-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f60f965b484f5bc3aafb75188ab5dc78cbc29f971b421f647a887a7593cd58ba |
|
MD5 | d8c3080030ae6a4b9a7529130d58f120 |
|
BLAKE2b-256 | 83ec74764318d3028104b5ea8d787a1655227036eab83c83915cfaac49aad104 |
File details
Details for the file quadmompy-0.9.5-1-py3-none-any.whl
.
File metadata
- Download URL: quadmompy-0.9.5-1-py3-none-any.whl
- Upload date:
- Size: 68.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64fbcd28f4de9c46e5c6af0c2702b6ab52af06cd2e79a2337885d0d0764ee6d6 |
|
MD5 | 09434f4450088de8c266561acd6fef9c |
|
BLAKE2b-256 | c4955044770090adb3a9907409f2ff6ad5b339a42d3d08678fd667a194924d7e |