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.56.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_pde-0.56.0-py3-none-any.whl (456.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_pde-0.56.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

Hashes for py_pde-0.56.0.tar.gz
Algorithm Hash digest
SHA256 dae719a934a3edffb0b6e544fd402d7ff2f9053afffd5cd45d4a16b7210e6f64
MD5 0d537d5f83eec405fb3c14a1fc96dd22
BLAKE2b-256 0cc4487216e19cd775ced42bdec3c246c22610400296c6e78bfbf9ee76819fdf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_pde-0.56.0-py3-none-any.whl
  • Upload date:
  • Size: 456.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for py_pde-0.56.0-py3-none-any.whl
Algorithm Hash digest
SHA256 769950bf4401f7928ea7938f615fe8e45288992d5de77bc29639db7eef8dc7dd
MD5 32c34bf046573820228fadc4512cf1c8
BLAKE2b-256 8c8ff686e19fdf731305e1859d6aadb52d0c72b17f58ebd214eb7e128180eda1

See more details on using hashes here.

Supported by

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