Python package for solving partial differential equations
Project description
py-pde
py-pde is a Python package for solving partial differential equations (PDEs).
The package provides classes for grids on which scalar and tensor fields can be
defined. The associated differential operators are computed using finite differences,
which allows defining, inspecting, and solving typical PDEs that appear for instance in
the study of dynamical systems in physics. The focus of the package lies on easy usage
to explore the behavior of PDEs. However, core computations can be compiled
transparently using numba, jax, or torch for speed.
Installation
PyPI / pip
py-pde is available on pypi, so you should be able to install it through pip:
pip install py-pde
In order to have all features of the package available, you might want to install the following optional packages manually (all or a subset of these):
pip install h5py pandas mpi4py numba-mpi py-modelrunner napari ffmpeg-python
or using the py-pde package variants mpi, io and/or interactive (any combination):
pip install py-pde[mpi]
pip install py-pde[io]
pip install py-pde[interactive]
pip install py-pde[mpi,io,interactive]
Moreover, ffmpeg needs to be installed for creating movies.
conda
As an alternative, you can install py-pde through conda
using the conda-forge channel:
conda install -c conda-forge py-pde
Installation with conda includes the optional dependencies of py-pde.
Arch Linux package
py-pde is also available as an Arch package.
Usage
A simple example showing the evolution of the diffusion equation in 2d:
import pde
grid = pde.UnitGrid([64, 64]) # generate grid
state = pde.ScalarField.random_uniform(grid) # generate initial condition
eq = pde.DiffusionPDE(diffusivity=0.1) # define the pde
result = eq.solve(state, t_range=10) # solve the pde
result.plot() # plot the resulting field
PDEs can also be specified by simply writing expressions of the evolution rate. For instance, the Cahn-Hilliard equation can be implemented as
eq = pde.PDE({'c': 'laplace(c**3 - c - laplace(c))'})
which can be used in place of the DiffusionPDE in the example above.
More information
- Tutorial notebooks in the tutorials folder
- Examples gallery with an overview of the capabilities of the package
- The Discussions on GitHub
- Full documentation on readthedocs or as a single PDF file.
- The paper published in the Journal of Open Source Software
- Practical tutorial on pattern formation in biological cells
Project details
Release history Release notifications | RSS feed
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 py_pde-0.57.0.tar.gz.
File metadata
- Download URL: py_pde-0.57.0.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6543581f84c3948fd34cfca017f6869fd23c8c184aed037ce5561a1ea6c69fdd
|
|
| MD5 |
ac3114f8ee496c37b5ab646fe005d7c0
|
|
| BLAKE2b-256 |
fdcdec5f251f4a389ade356db1a61638317fbc07e315c961a232fdea04cf3019
|
File details
Details for the file py_pde-0.57.0-py3-none-any.whl.
File metadata
- Download URL: py_pde-0.57.0-py3-none-any.whl
- Upload date:
- Size: 460.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcccdf65d6818e8606744c44470fc48839a35e6fec217e1faa9faa7b4c250e33
|
|
| MD5 |
ea5d1a15d9c43367b4229f5976b79e97
|
|
| BLAKE2b-256 |
ad89dda395bf60597760384c54a1302dcb601fb5731193851ca13cf879b0da4e
|