Skip to main content

pystencils

Docs pypi-package pipeline status coverage report

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:

Performance Modelling:

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)

Source distribution for pystencils 2.1
File Size Uploaded
pystencils-2.1.tar.gz 350.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pystencils 2.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

2.1 This release

2 release files

2.0

2 release files

1.4

2 release files

1.3.7

2 release files

1.3.6

1 release file

1.3.5

1 release file

1.3.4

1 release file

1.3.3

1 release file

1.3.2

1 release file

1.3.1

1 release file

1.3

1 release file

1.2

1 release file

1.1.1

1 release file

1.1

1 release file

1.0.1

1 release file

1.0

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.15

1 release file

0.2.14

1 release file

0.2.13

1 release file

0.2.12

1 release file

0.2.11

1 release file

0.2.10

1 release file

0.2.9

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

2 release files

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page