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)
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: Error estimation via accuracy order comparison
Added in version 0.15: Time-dependent PDE solving via Method of Lines
Added in version 0.16: GPU / JAX / CuPy backend support for operator application