pystencils
Pystencils is a symbolic domain-specific language and metaprogramming toolkit for writing high-performance numerical stencil kernels for a variety of hardware targets.
Installation
Pystencils can be installed from PyPI using pip, e.g.:
pip install pystencils~=2.0
For more information on installing pystencils, refer to the Installation Guide.
Example
Here is a code snippet that computes the average of neighboring cells:
import pystencils as ps
import numpy as np
f, g = ps.fields("f, g : [2D]")
stencil = ps.Assignment(g[0, 0],
(f[1, 0] + f[-1, 0] + f[0, 1] + f[0, -1]) / 4)
kernel = ps.create_kernel(stencil).compile()
f_arr = np.random.rand(1000, 1000)
g_arr = np.empty_like(f_arr)
kernel(f=f_arr, g=g_arr)
pystencils is mostly used for numerical simulations using finite difference or finite volume methods. It comes with automatic finite difference discretization for PDEs:
import pystencils as ps
import sympy as sp
c, v = ps.fields("c, v(2): [2D]")
adv_diff_pde = ps.fd.transient(c) - ps.fd.diffusion(c, sp.symbols("D")) + ps.fd.advection(c, v)
discretize = ps.fd.Discretization2ndOrder(dx=1, dt=0.01)
discretization = discretize(adv_diff_pde)
Documentation
Here's an overview of our documentation ressources:
Contributing
Please refer to the contribution guide for instructions on how to start contributing to pystencils.
Authors
Many thanks go to the contributors of pystencils.
Please cite us
If you use pystencils in a publication, please cite the following articles:
Overview:
- M. Bauer et al, Code Generation for Massively Parallel Phase-Field Simulations. Association for Computing Machinery, 2019. https://doi.org/10.1145/3295500.3356186
Performance Modelling:
- D. Ernst et al, Analytical performance estimation during code generation on modern GPUs. Journal of Parallel and Distributed Computing, 2023. https://doi.org/10.1016/j.jpdc.2022.11.003
Metadata
Release files for pystencils 2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pystencils-2.1.tar.gz | 350.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pystencils-2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 778.2 kB
Release files / pystencils-2.1.tar.gz
| Download URL | pystencils-2.1.tar.gz |
|---|---|
| Size | 350.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6dd4c1a640435dc27712f7f8db488a25cf644908b321d17161d044161e2b831
|
|
BLAKE2b-256 checksum How to use checksums |
718689d30d46478f757e5403ea2c1777b8630486fa55b95361270977e62de3ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / pystencils-2.1-py3-none-any.whl
| Download URL | pystencils-2.1-py3-none-any.whl |
|---|---|
| Size | 428.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3efb562ad691d1e11ffac04f7e174e4fb18bbc4dc086c46b24d6396e9f0dfd3d
|
|
BLAKE2b-256 checksum How to use checksums |
daaa6dc352b29e94bbc53dfe2aa53c558927612978affe056258ff4d9ee1d94a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for pystencils 2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.