Skip to main content

Python package for solving partial differential equations

Project description

py-pde

PyPI version Conda Version License: MIT Build Status codecov Binder Documentation Status DOI

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 a numba-compiled implementation of finite differences. This 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 for speed.

Try it online!

Installation

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:

pip install h5py pandas mpi4py numba-mpi

Moreover, ffmpeg needs to be installed for creating movies.

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 all dependencies of py-pde.

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

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

py_pde-0.45.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

py_pde-0.45.0-py3-none-any.whl (333.7 kB view details)

Uploaded Python 3

File details

Details for the file py_pde-0.45.0.tar.gz.

File metadata

  • Download URL: py_pde-0.45.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for py_pde-0.45.0.tar.gz
Algorithm Hash digest
SHA256 36c4ec37a89b676db706f95c5629607277dbb3937fa3e3edfd956b00adf7f7e7
MD5 b26045f1e04e0f0d58d71b207014e306
BLAKE2b-256 901d661c8bf5305bba46cf24d8b7c07c21e515d3aa562f0332143f9a6fd2954c

See more details on using hashes here.

File details

Details for the file py_pde-0.45.0-py3-none-any.whl.

File metadata

  • Download URL: py_pde-0.45.0-py3-none-any.whl
  • Upload date:
  • Size: 333.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for py_pde-0.45.0-py3-none-any.whl
Algorithm Hash digest
SHA256 872aecded78a70c7a3c19e001e7450141684988b47ada09542439b684cae4cbd
MD5 8eb2f7544f6cebf68f30a8a5050a7bf9
BLAKE2b-256 4f620ff5e3d0322ad0d961688bab6c6f039cd7ac0bfb965308f89410e2b4486c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page