Skip to main content

Python package for solving partial differential equations

Project description

py-pde

PyPI version Conda Version Documentation Status DOI Binder

Build Status codecov Language grade: Python Code style: black License: MIT

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 out 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 also want to install the following optional packages:

pip install h5py pandas tqdm

Moreover, ffmpeg needs to be installed for creating movies.

As an alternative, you can install py-pde through conda using conda-forge channel:

conda install -c conda-forge py-pde

Installation with conda includes all required dependencies to have all features 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for py-pde, version 0.13.3
Filename, size File type Python version Upload date Hashes
Filename, size py_pde-0.13.3-py3-none-any.whl (302.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size py-pde-0.13.3.tar.gz (1.1 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page