hermite-algebra
SymPy-based Hermite tensor algebra for kinetic theory.
Rather than treating Hermite polynomials as fixed formulas, this package treats multidimensional Hermite tensors as basis elements of a polynomial space that you generate, project onto, and take moments of symbolically. That makes Grad- and Shakhov-style expansions mechanical instead of algebraic busywork.
Collision models (BGK, ES-BGK, Shakhov, semiclassical Bose/Fermi) live in the related package hermite-kinetics.
What you can do
- Generate Grad Hermite tensors recursively with
hermite(n) - Evaluate Gaussian moments via Wick’s theorem with
moment/inner(no symbolic integration) - Project velocity polynomials onto the Hermite basis with
projectandPolynomialSpace.decompose - Work in arbitrary velocity dimension with
VelocitySpace(d) - Use the results as building blocks for Grad / Shakhov expansions (in
hermite-kinetics)
Quick examples
Symbolic Hermite tensors
Generate $H^{(n)}$ recursively and print the symbolic expressions:
from hermite_algebra import hermite
import sympy as sp
for n in range(3):
print(f"H^({n}) =")
sp.pprint(hermite(n))
print()
H^(0) =
1
H^(1) =
[ξ₀ ξ₁ ξ₂]
H^(2) =
⎡ 2 ⎤
⎢ξ₀ - 1 ξ₀⋅ξ₁ ξ₀⋅ξ₂ ⎥
⎢ ⎥
⎢ 2 ⎥
⎢ ξ₀⋅ξ₁ ξ₁ - 1 ξ₁⋅ξ₂ ⎥
⎢ ⎥
⎢ 2 ⎥
⎣ ξ₀⋅ξ₂ ξ₁⋅ξ₂ ξ₂ - 1⎦
Alternative for single component:
H2 = hermite(2)
sp.pprint(H2[0, 0])
ξ₀² - 1
Contracted third-order Hermite tensor
In three dimensions, the contracted $H^{(3)}$ is $\xi_i(\xi^2 - 5)$:
from hermite_algebra import vector_part, xi, xi2
import sympy as sp
H3c = vector_part(3)
assert all(sp.simplify(H3c[i] - xi[i] * (xi2 - 5)) == 0 for i in range(3))
Orthogonality under the Gaussian weight
from hermite_algebra import hermite, inner
H1, H2, H3 = hermite(1), hermite(2), hermite(3)
inner(H2, H1) # 0
inner(H3, H2) # 0
Projection used in kinetic derivations
The identity $\xi_i\xi^2 = H_i^{(3)} + 5 H_i^{(1)}$ falls out of orthogonal projection:
from hermite_algebra import xi, xi2, project, format_projection, PolynomialSpace
format_projection(project(xi * xi2)) # "H3 + 5 H1"
PolynomialSpace().decompose(xi[0] * xi2) # same decomposition, component-wise API
Dimension-generic velocity space
from hermite_algebra import VelocitySpace
V = VelocitySpace(2)
V.project_xi_cubic() # ξ_i ξ² = H³_i + (d+2) ξ_i with d = 2
See examples/verify_classical.py for a runnable smoke check.
Installation
Requires Python ≥ 3.11.
Users (PyPI)
pip install hermite-algebra
# or
uv add hermite-algebra
from hermite_algebra import VelocitySpace, hermite, project, inner
Developers (uv, from source)
git clone https://github.com/wme7/hermite-algebra.git
cd hermite-algebra
uv sync --group dev
uv run pre-commit install
uv run pytest
uv run python examples/verify_classical.py
For an editable install into another environment:
uv pip install -e .
CI and releases
Pull requests and pushes to main run lint (ruff, ty) and tests on Python 3.11–3.14.
To publish a new version to PyPI:
- Bump
project.versioninpyproject.toml(e.g.0.1.0). - Commit, tag
v0.1.0(tag should match the version), and create a GitHub Release. - The
publish.ymlworkflow builds the package and uploads it via Trusted Publishing (OIDC; no API token in secrets).
One-time setup before the first release:
- On PyPI, create/claim the project
hermite-algebraand add a Trusted Publisher:- Owner:
wme7 - Repository:
hermite-algebra - Workflow:
publish.yml - Environment:
pypi
- Owner:
- In the GitHub repo, create an Environment named
pypi(optional: require reviewers).
Package layout
src/hermite_algebra/
├── symbols.py # global d=3 velocity symbols (ξ, δ, ξ²)
├── tensors.py # outer, contract, symmetrize, …
├── hermite.py # recursive Hermite tensors
├── gaussian.py # Wick theorem
├── moments.py # moment / inner / norm
├── project.py # project onto Hermite basis
├── space.py # PolynomialSpace
└── velocity.py # dimension-generic VelocitySpace
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hermite_algebra-0.1.0.tar.gz.
File metadata
- Download URL: hermite_algebra-0.1.0.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19c5f2592c2fefee88e484dfe18ba700342f41d9153fe3a08375a8860e3e24b2
|
|
| MD5 |
05751d6fbac5157fc3373f6a2ba0b874
|
|
| BLAKE2b-256 |
7723c6b37b79cb5cd7c66aacf233a3a6ad4901ef28ebe3619900e688ddfa997f
|
Provenance
The following attestation bundles were made for hermite_algebra-0.1.0.tar.gz:
Publisher:
publish.yml on wme7/hermite-algebra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hermite_algebra-0.1.0.tar.gz -
Subject digest:
19c5f2592c2fefee88e484dfe18ba700342f41d9153fe3a08375a8860e3e24b2 - Sigstore transparency entry: 2344044359
- Sigstore integration time:
-
Permalink:
wme7/hermite-algebra@c4efdc3727701f40c690a3028639f8065f9e7d5e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wme7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4efdc3727701f40c690a3028639f8065f9e7d5e -
Trigger Event:
release
-
Statement type:
File details
Details for the file hermite_algebra-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hermite_algebra-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e6c92ce1c0832874d5b317f4c57531c0fbef7dcad119dc15fa524c42b23a0f4
|
|
| MD5 |
e09ac38620128dd17b90da415ec68e7a
|
|
| BLAKE2b-256 |
23d7b19a5027ffdd9f059152697b3b4ff7d4c62d20239521180ff58e6c90a3b3
|
Provenance
The following attestation bundles were made for hermite_algebra-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on wme7/hermite-algebra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hermite_algebra-0.1.0-py3-none-any.whl -
Subject digest:
4e6c92ce1c0832874d5b317f4c57531c0fbef7dcad119dc15fa524c42b23a0f4 - Sigstore transparency entry: 2344044399
- Sigstore integration time:
-
Permalink:
wme7/hermite-algebra@c4efdc3727701f40c690a3028639f8065f9e7d5e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wme7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c4efdc3727701f40c690a3028639f8065f9e7d5e -
Trigger Event:
release
-
Statement type: