Metadata-Version: 2.4
Name: pystencils
Version: 2.0b1
Summary: Speeding up stencil computations on CPUs and GPUs
Author: Martin Bauer, Jan Hönig , Markus Holzer, Frederik Hennig
Author-email: cs10-codegen@fau.de
License-Expression: GPL-3.0-or-later
Project-URL: Bug Tracker, https://i10git.cs.fau.de/pycodegen/pystencils/-/issues
Project-URL: Documentation, https://pycodegen.pages.i10git.cs.fau.de/pystencils/
Project-URL: Source Code, https://i10git.cs.fau.de/pycodegen/pystencils
Project-URL: Homepage, https://pycodegen.pages.i10git.cs.fau.de/
Classifier: Development Status :: 4 - Beta
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: sympy~=1.14
Requires-Dist: numpy>=1.8.0
Requires-Dist: appdirs
Requires-Dist: joblib
Requires-Dist: pyyaml
Requires-Dist: fasteners
Provides-Extra: alltrafos
Requires-Dist: islpy; extra == "alltrafos"
Requires-Dist: py-cpuinfo; extra == "alltrafos"
Provides-Extra: bench-db
Requires-Dist: blitzdb; extra == "bench-db"
Requires-Dist: pymongo; extra == "bench-db"
Requires-Dist: pandas; extra == "bench-db"
Provides-Extra: interactive
Requires-Dist: matplotlib; extra == "interactive"
Requires-Dist: ipy_table; extra == "interactive"
Requires-Dist: imageio; extra == "interactive"
Requires-Dist: jupyter; extra == "interactive"
Requires-Dist: pyevtk; extra == "interactive"
Requires-Dist: rich; extra == "interactive"
Requires-Dist: graphviz; extra == "interactive"
Provides-Extra: use-cython
Requires-Dist: Cython; extra == "use-cython"
Provides-Extra: dev
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: black; extra == "dev"
Provides-Extra: doc
Requires-Dist: sphinx; extra == "doc"
Requires-Dist: pydata-sphinx-theme==0.15.4; extra == "doc"
Requires-Dist: sphinx-book-theme==1.1.3; extra == "doc"
Requires-Dist: sphinxcontrib-bibtex; extra == "doc"
Requires-Dist: sphinx_autodoc_typehints; extra == "doc"
Requires-Dist: pandoc; extra == "doc"
Requires-Dist: sphinx_design; extra == "doc"
Requires-Dist: myst-nb; extra == "doc"
Requires-Dist: matplotlib; extra == "doc"
Requires-Dist: graphviz; extra == "doc"
Provides-Extra: testsuite
Requires-Dist: tomli; python_version <= "3.10" and extra == "testsuite"
Requires-Dist: pytest; extra == "testsuite"
Requires-Dist: pytest-cov; extra == "testsuite"
Requires-Dist: pytest-html; extra == "testsuite"
Requires-Dist: ansi2html; extra == "testsuite"
Requires-Dist: pytest-xdist; extra == "testsuite"
Requires-Dist: flake8; extra == "testsuite"
Requires-Dist: mypy>=1.8; extra == "testsuite"
Requires-Dist: nbformat; extra == "testsuite"
Requires-Dist: nbconvert; extra == "testsuite"
Requires-Dist: ipython; extra == "testsuite"
Requires-Dist: matplotlib; extra == "testsuite"
Requires-Dist: py-cpuinfo; extra == "testsuite"
Requires-Dist: randomgen>=2.1; extra == "testsuite"
Requires-Dist: scipy; extra == "testsuite"
Dynamic: license-file

# pystencils

[![Docs](https://img.shields.io/badge/read-the_docs-brightgreen.svg)](https://pycodegen.pages.i10git.cs.fau.de/pystencils)
[![pypi-package](https://badge.fury.io/py/pystencils.svg)](https://badge.fury.io/py/pystencils)
[![pipeline status](https://i10git.cs.fau.de/pycodegen/pystencils/badges/master/pipeline.svg)](https://i10git.cs.fau.de/pycodegen/pystencils/commits/master)
[![coverage report](https://i10git.cs.fau.de/pycodegen/pystencils/badges/master/coverage.svg)](http://pycodegen.pages.i10git.cs.fau.de/pystencils/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.

> [!note]
> This is the code of repository of *pystencils 2.x*, the near-complete rework of the pystencils package.
> The legacy package *pystencils 1.4* is being supported at the [`v1.x`](https://i10git.cs.fau.de/pycodegen/pystencils/-/tree/v1.x) branch of this repository.

## Installation

Pystencils can be installed from PyPI using `pip`, e.g.:

```bash
pip install pystencils~=2.0
```

For more information on installing *pystencils*, refer to the [Installation Guide](https://pycodegen.pages.i10git.cs.fau.de/pystencils/installation.html).

## Example

Here is a code snippet that computes the average of neighboring cells:
```python
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:

```python
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:

 - [pystencils User Manual (`master`)](https://pycodegen.pages.i10git.cs.fau.de/pystencils)
 - [pycodegen Index Page](https://pycodegen.pages.i10git.cs.fau.de/)
 
## Contributing

Please refer to [the contribution guide](https://pycodegen.pages.i10git.cs.fau.de/pystencils/contributing)
for instructions on how to start contributing to *pystencils*.

## Authors

Many thanks go to the [contributors](CITATION.cff) 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
