Skip to content

Commit ca6739e

Browse files
committed
Release kernelpack-python v0.1.0
Publish a history-free, BSD-3-Clause Python distribution of the KernelPack fixed-domain numerical core. Included capabilities: - smooth and piecewise embedded geometry, RBF level sets, normals, and geometry-aware projection - fixed- and variable-radius Poisson node generation with clipping, boundary refinement, ghost nodes, and dual domains - centered and scaled Legendre polynomial bases, standard and overlapped PHS+poly RBF-FD, WLS, and divergence-free interpolation - Poisson, variable and nonlinear variable Poisson, BDF diffusion, PU diffusion, and multispecies diffusion solvers Release preparation: - remove unpublished bulk semi-Lagrangian advection, advection-diffusion, and incompressible Euler implementations and tests - replace private and machine-local documentation links with a public-reader README matching the kernelpack-matlab structure - add packaging metadata, BSD license, citation metadata, contribution and security guidance, and Python 3.11/3.12 CI - retain reproducible 2D and 3D Poisson convergence drivers and committed README figures Verification: 24 public tests pass; the README Poisson solve reproduces the manufactured solution to 4.683e-14 max error; wheel and sdist build successfully and contain no removed solver paths; all retained modules import from the built wheel.
0 parents  commit ca6739e

48 files changed

Lines changed: 8085 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitattributes‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.png binary
3+
*.jpg binary
4+
*.jpeg binary
5+
*.gif binary

‎.github/workflows/python.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Python tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.11", "3.12"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
cache: pip
24+
- name: Install package and test dependencies
25+
run: python -m pip install -e ".[dev]"
26+
- name: Run tests
27+
run: python -m pytest -q

‎.gitignore‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
__pycache__/
2+
.pytest_cache/
3+
.venv/
4+
.coverage
5+
.mypy_cache/
6+
.ruff_cache/
7+
artifacts/
8+
dist/
9+
build/
10+
*.egg-info/

‎CITATION.cff‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cff-version: 1.2.0
2+
message: "If you use kernelpack-python, please cite the software and the papers corresponding to the methods you use."
3+
title: "kernelpack-python"
4+
type: software
5+
authors:
6+
- family-names: Shankar
7+
given-names: Varun
8+
version: 0.1.0
9+
date-released: 2026-09-08
10+
license: BSD-3-Clause
11+
repository-code: "https://github.com/VarShankar/kernelpack-python"
12+
url: "https://github.com/VarShankar/kernelpack-python"
13+
keywords:
14+
- meshfree methods
15+
- RBF-FD
16+
- radial basis functions
17+
- partial differential equations

‎CONTRIBUTING.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Contributing
2+
3+
Bug reports, focused pull requests, and reproducible numerical examples are
4+
welcome.
5+
6+
## Development setup
7+
8+
```bash
9+
git clone https://github.com/VarShankar/kernelpack-python.git
10+
cd kernelpack-python
11+
python -m venv .venv
12+
python -m pip install -e ".[dev]"
13+
python -m pytest -q
14+
```
15+
16+
On Windows, activate the environment with `.venv\Scripts\activate`; on macOS
17+
or Linux, use `source .venv/bin/activate`.
18+
19+
## Pull requests
20+
21+
- Keep each change focused and explain the numerical or software motivation.
22+
- Add or update tests for changed behavior.
23+
- Include a reproducible example when proposing a new numerical method.
24+
- Run the complete test suite before opening a pull request.
25+
- Do not commit generated build products, virtual environments, or large data.
26+
27+
Changes to a discretization should document the operator convention, stencil
28+
construction, polynomial degree, boundary treatment, and validation problem.
29+
Performance claims should include the problem size and a reproducible timing
30+
procedure.

‎LICENSE‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2026, Varun Shankar and kernelpack-python contributors
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from this
18+
software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

‎README.md‎

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# kernelpack-python
2+
3+
[![Python tests](https://github.com/VarShankar/kernelpack-python/actions/workflows/python.yml/badge.svg)](https://github.com/VarShankar/kernelpack-python/actions/workflows/python.yml)
4+
[![Latest release](https://img.shields.io/github/v/release/VarShankar/kernelpack-python)](https://github.com/VarShankar/kernelpack-python/releases/latest)
5+
[![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](LICENSE)
6+
[![Python 3.11+](https://img.shields.io/badge/Python-3.11%2B-3776ab.svg)](#requirements)
7+
8+
**Meshfree geometry, RBF-FD, partition-of-unity methods, and PDE solvers for
9+
Python.**
10+
11+
`kernelpack-python` provides Python implementations of meshfree geometry,
12+
scattered-node discretizations, and PDE solvers on embedded fixed domains. It
13+
combines reusable geometry and node-generation tools with standard and
14+
overlapped PHS+poly RBF-FD, weighted least squares, localized
15+
partition-of-unity approximations, and sparse elliptic and diffusion solvers.
16+
17+
The package is the Python member of the KernelPack family. The companion
18+
[`kernelpack-matlab`](https://github.com/VarShankar/kernelpack-matlab)
19+
repository includes the moving-surface implementation accompanying the
20+
preprint [*A high-order, meshless, Lagrangian--Eulerian RBF-FD method for
21+
advection--diffusion--reaction on moving manifolds*](https://arxiv.org/abs/2608.19384)
22+
by Matthew Lowery, Grady B. Wright, and Varun Shankar. This Python release is
23+
focused on the fixed-domain numerical core and does not claim that
24+
moving-surface solver.
25+
26+
![Poisson solution and nodal error on an embedded domain](docs/readme_assets/poisson_solution.png)
27+
28+
The figure shows an end-to-end Poisson solve on a geometry-defined scattered
29+
node set: the geometric model supplies the boundary and normals, the node
30+
generator fills the domain, and PHS+poly RBF-FD supplies the differential and
31+
boundary operators.
32+
33+
[Install](#installation) | [First solve](#first-solve) |
34+
[Examples](#examples) | [Tests](#verification) |
35+
[Papers](#research-foundations) | [Citation](#citation)
36+
37+
## Who this is for
38+
39+
This package is intended for numerical PDE researchers and Python users who
40+
want to:
41+
42+
- prototype PHS+poly RBF-FD or weighted-least-squares discretizations;
43+
- generate scattered nodes and differential operators on embedded domains;
44+
- compare standard and overlapped local assembly;
45+
- solve elliptic and diffusion problems without constructing a volume mesh;
46+
- build localized PU or divergence-free RBF approximations; or
47+
- extend a tested, inspectable numerical research codebase.
48+
49+
It is research software, not a general-purpose finite-element package.
50+
51+
## At a glance
52+
53+
| Component | What the public release provides |
54+
| --- | --- |
55+
| Geometry models | Smooth and piecewise-smooth embedded boundaries and surfaces, PHS geometric fits, RBF level sets, normals, projection, and geometry-aware bounding data |
56+
| Node generation | Seeded fixed- and variable-radius Poisson sampling in boxes, clipping by embedded geometry, boundary and ghost nodes, boundary-zone outer refinement, and dual node sets |
57+
| Local approximation | Centered and scaled Legendre polynomial bases, standard and overlapped PHS+poly RBF-FD, weighted-least-squares stencils, and local divergence-free PHS interpolation |
58+
| Fixed-domain solvers | Poisson, variable-coefficient and nonlinear variable-coefficient Poisson, BDF1--BDF3 diffusion, localized PU diffusion, and homogeneous or heterogeneous multispecies diffusion |
59+
| Numerical infrastructure | SciPy KD trees and sparse matrices, cached local polynomial templates, and targeted Numba kernels for repeated geometry, polynomial, and stencil calculations |
60+
61+
The main namespaces are `kernelpack.geometry`, `kernelpack.nodes`,
62+
`kernelpack.domain`, `kernelpack.poly`, `kernelpack.rbffd`,
63+
`kernelpack.divfree`, and `kernelpack.solvers`.
64+
65+
## Requirements
66+
67+
- Python 3.11 or newer
68+
- NumPy 2.0 or newer
69+
- SciPy 1.14 or newer
70+
- Numba 0.61 or newer
71+
- Matplotlib 3.9 or newer for examples and figures
72+
73+
## Installation
74+
75+
### Clone the repository
76+
77+
```bash
78+
git clone https://github.com/VarShankar/kernelpack-python.git
79+
cd kernelpack-python
80+
python -m venv .venv
81+
```
82+
83+
Activate the environment on macOS or Linux:
84+
85+
```bash
86+
source .venv/bin/activate
87+
```
88+
89+
Activate it on Windows:
90+
91+
```powershell
92+
.venv\Scripts\Activate.ps1
93+
```
94+
95+
Install the package and example dependencies:
96+
97+
```bash
98+
python -m pip install -e ".[examples]"
99+
```
100+
101+
For development, install the test and build tools as well:
102+
103+
```bash
104+
python -m pip install -e ".[dev]"
105+
```
106+
107+
## First solve
108+
109+
This example constructs a disk from boundary samples, generates interior and
110+
ghost nodes, solves $-\Delta u = 4$ with $u=0$ on the boundary, and plots the
111+
numerical solution.
112+
113+
```python
114+
import matplotlib.pyplot as plt
115+
import matplotlib.tri as mtri
116+
import numpy as np
117+
118+
from kernelpack.geometry import EmbeddedSurface
119+
from kernelpack.nodes import DomainNodeGenerator
120+
from kernelpack.solvers import PoissonSolver
121+
122+
t = np.linspace(0.0, 2.0 * np.pi, 200, endpoint=False)
123+
surface = EmbeddedSurface()
124+
surface.set_data_sites(np.column_stack([np.cos(t), np.sin(t)]))
125+
surface.build_closed_geometric_model_ps(2, 0.08, t.size)
126+
surface.build_level_set_from_geometric_model()
127+
128+
generator = DomainNodeGenerator()
129+
domain = generator.build_domain_descriptor_from_geometry(
130+
surface, 0.08, seed=17, strip_count=5
131+
)
132+
133+
solver = PoissonSolver(
134+
lap_assembler="fd",
135+
bc_assembler="fd",
136+
lap_stencil="rbf",
137+
bc_stencil="rbf",
138+
)
139+
solver.init(domain, 4)
140+
141+
forcing = lambda x: 4.0 * np.ones(x.shape[0])
142+
neumann = lambda xb: np.zeros(xb.shape[0])
143+
dirichlet = lambda xb: np.ones(xb.shape[0])
144+
boundary_data = lambda neu, diri, normals, xb: np.zeros(xb.shape[0])
145+
result = solver.solve(forcing, neumann, dirichlet, boundary_data)
146+
147+
x = domain.get_int_bdry_nodes()
148+
tri = mtri.Triangulation(x[:, 0], x[:, 1])
149+
plt.tripcolor(tri, result["u"], shading="gouraud")
150+
plt.gca().set_aspect("equal")
151+
plt.colorbar(label="u")
152+
plt.title("Poisson solution")
153+
plt.show()
154+
```
155+
156+
![Geometry-clipped interior, boundary, and ghost nodes](docs/readme_assets/geometry_domain.png)
157+
158+
## Solver workflows
159+
160+
All solvers use a `DomainDescriptor`, so geometry, node generation, and local
161+
operator construction remain separate from the PDE definition. A target
162+
spatial order `xi` determines the polynomial reproduction degree and the lower
163+
odd-degree PHS used by the local stencil builders.
164+
165+
The elliptic solver family supports Dirichlet, Neumann, and mixed boundary
166+
rows. Pure-Neumann systems use an explicit null-space augmentation. The
167+
variable-coefficient solver assembles the divergence-form operator, while the
168+
nonlinear variant applies Newton iterations with sparse linear solves.
169+
170+
`DiffusionSolver` advances fixed-domain problems with BDF1, BDF2, or BDF3 and
171+
reuses time-independent operators and preconditioners where possible. The PU
172+
variants localize approximation and support single- or multispecies diffusion,
173+
including distinct diffusivities by species.
174+
175+
![Diffusion solution, error, and time history](docs/readme_assets/diffusion_solution.png)
176+
177+
## Examples
178+
179+
Complete convergence drivers live in [`examples`](examples):
180+
181+
| Goal | Example |
182+
| --- | --- |
183+
| Verify a two-dimensional pure-Neumann Poisson solve | [`poisson_convergence_2d_neumann.py`](examples/poisson_convergence_2d_neumann.py) |
184+
| Verify a three-dimensional pure-Neumann Poisson solve | [`poisson_convergence_3d_neumann.py`](examples/poisson_convergence_3d_neumann.py) |
185+
186+
Run a study from the repository root, for example:
187+
188+
```bash
189+
python examples/poisson_convergence_2d_neumann.py --orders 2 4 6
190+
```
191+
192+
Generated tables, JSON data, and figures are written under `artifacts/`, which
193+
is intentionally excluded from version control. The committed README figures
194+
can be regenerated with:
195+
196+
```bash
197+
python scripts/render_readme_examples.py
198+
```
199+
200+
## Verification
201+
202+
Install the development dependencies and run the complete public suite:
203+
204+
```bash
205+
python -m pip install -e ".[dev]"
206+
python -m pytest -q
207+
```
208+
209+
The same suite runs on Python 3.11 and 3.12 in GitHub Actions for every push
210+
and pull request.
211+
212+
## Research foundations
213+
214+
`kernelpack-python` brings together methods developed across several papers.
215+
Please cite the publications corresponding to the parts of the library used in
216+
your work.
217+
218+
| Code or method | Publication |
219+
| --- | --- |
220+
| Overlapped RBF-FD assembly (`kernelpack.rbffd.FDODiffOp`) | V. Shankar, [*The overlapped radial basis function-finite difference (RBF-FD) method: A generalization of RBF-FD*](https://doi.org/10.1016/j.jcp.2017.04.037), Journal of Computational Physics 342 (2017), 211--228 |
221+
| PHS geometric models and Poisson node generation (`kernelpack.geometry`, `kernelpack.nodes`) | V. Shankar, R. M. Kirby, and A. L. Fogelson, [*Robust node generation for mesh-free discretizations on irregular domains and surfaces*](https://doi.org/10.1137/17M114090X), SIAM Journal on Scientific Computing 40 (2018), A2584--A2608 |
222+
| Lower odd-degree PHS selection used by the solver stencil defaults | V. Shankar and A. L. Fogelson, [*Hyperviscosity-based stabilization for radial basis function-finite difference (RBF-FD) discretizations of advection-diffusion equations*](https://doi.org/10.1016/j.jcp.2018.06.036), Journal of Computational Physics 372 (2018), 616--639 |
223+
224+
For moving-surface ADR, surface hyperviscosity, and the associated research
225+
drivers, see the public
226+
[`kernelpack-matlab`](https://github.com/VarShankar/kernelpack-matlab)
227+
release and its research-foundations table.
228+
229+
## Citation
230+
231+
Software citation metadata are provided in [`CITATION.cff`](CITATION.cff).
232+
Please also cite the method papers corresponding to the components used in
233+
your work.
234+
235+
## Contributing
236+
237+
Bug reports, focused pull requests, and reproducible numerical examples are
238+
welcome. See [`CONTRIBUTING.md`](CONTRIBUTING.md) for the development workflow
239+
and [`SECURITY.md`](SECURITY.md) for responsible vulnerability reporting.
240+
241+
## License
242+
243+
`kernelpack-python` is released under the [BSD 3-Clause License](LICENSE),
244+
which permits academic and commercial use, modification, and redistribution
245+
subject to its terms.

‎SECURITY.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Security policy
2+
3+
Please report security issues privately through GitHub's **Report a
4+
vulnerability** link on the repository Security page. Do not open a public
5+
issue for a vulnerability that has not yet been addressed.
6+
7+
This research software is provided without a warranty of fitness for safety-
8+
critical, clinical, or production use. See the BSD 3-Clause License for the
9+
full terms.
122 KB
Loading
108 KB
Loading

0 commit comments

Comments
 (0)