findiff
A Python package for finite difference numerical derivatives and partial differential equations in any number of dimensions.
Features
Differentiate arrays of any number of dimensions along any axis with any desired accuracy order
Accurate treatment of grid boundary
Includes standard operators from vector calculus like gradient, divergence and curl
Can handle uniform and non-uniform grids
Can handle arbitrary linear combinations of derivatives with constant and variable coefficients
Fully vectorized for speed
GPU / JAX / CuPy support for operator application — combine with
jax.jitfor accelerationCalculate raw finite difference coefficients for any order and accuracy
Generate matrix representations of arbitrary linear differential operators
Solve partial differential equations with Dirichlet, Neumann or Robin boundary conditions
Solve eigenvalue problems (e.g. Schrodinger equation, vibration modes)
Generate differential operators for arbitrary stencils
Symbolic representation of finite difference schemes
Periodic boundary conditions for differential operators and PDEs
Compact (implicit) finite differences with spectral-like resolution
Estimate truncation error by comparing accuracy orders
Solve time-dependent PDEs with the Method of Lines (Forward Euler, RK4, Backward Euler, Crank-Nicolson), including wave equations (Stoermer-Verlet), time-dependent boundary values and source terms
Added in version 0.11: Comfortable new API via Diff (the old FinDiff API remains available)
Added in version 0.12: Periodic boundary conditions for differential operators and PDEs
Added in version 0.13: Compact (implicit) finite differences with spectral-like resolution
Added in version 0.14: Time-dependent PDE solving via Method of Lines, GPU / JAX / CuPy backend support for operator application, eigenvalue problems, iterative solvers, Robin boundary conditions and error estimation via accuracy order comparison
Added in version 0.15: Compact finite differences on non-uniform grids, optimal and spectral-like compact schemes
Added in version 0.16: Wave equations (second order in time), time-dependent boundary values and source terms for time-dependent PDEs, stable boundary treatment for high-order operators, much faster implicit time stepping