DiffEqOperators.jl

Build Status Build status Stable Dev

DiffEqOperators.jl is a package for finite difference discretization of partial differential equations. It allows building fast lazy operators for high order non-uniform finite differences in an arbitrary number of dimensions, including vector calculus operators.

For automatic Method of Lines discretization of PDEs, better suited to nonlinear systems of equations and more complex boundary conditions, please see MethodOfLines.jl

For the operators, both centered and upwind operators are provided, for domains of any dimension, arbitrarily spaced grids, and for any order of accuracy. The cases of 1, 2, and 3 dimensions with an evenly spaced grid are optimized with a convolution routine from NNlib.jl. Care is taken to give efficiency by avoiding unnecessary allocations, using purpose-built stencil compilers, allowing GPUs and parallelism, etc. Any operator can be concretized as an Array, a BandedMatrix or a sparse matrix.

Documentation

For information on using the package, see the stable documentation. Use the in-development documentation for the version of the documentation which contains the unreleased features.

Example 1: Finite Difference Operator Solution for the Heat Equation

using DiffEqOperators, OrdinaryDiffEq

# # Heat Equation
# This example demonstrates how to combine `OrdinaryDiffEq` with `DiffEqOperators` to solve a time-dependent PDE.
# We consider the heat equation on the unit interval, with Dirichlet boundary conditions:
# āˆ‚ā‚œu = Ī”u
# u(x=0,t)  = a
# u(x=1,t)  = b
# u(x, t=0) = uā‚€(x)
#
# For `a = b = 0` and `uā‚€(x) = sin(2Ļ€x)` a solution is given by:
u_analytic(x, t) = sin(2*Ļ€*x) * exp(-t*(2*Ļ€)^2)

nknots = 100
h = 1.0/(nknots+1)
knots = range(h, step=h, length=nknots)
ord_deriv = 2
ord_approx = 2

const Ī” = CenteredDifference(ord_deriv, ord_approx, h, nknots)
const bc = Dirichlet0BC(Float64)

t0 = 0.0
t1 = 0.03
u0 = u_analytic.(knots, t0)

step(u,p,t) = Ī”*bc*u
prob = ODEProblem(step, u0, (t0, t1))
alg = KenCarp4()
sol = solve(prob, alg)

Diffeqoperators.jl

Linear operators for discretizations of differential equations and scientific machine learning (SciML)

Diffeqoperators.jl Info

ā­ Stars 235
šŸ”— Source Code github.com
šŸ•’ Last Update 4 months ago
šŸ•’ Created 5 years ago
šŸž Open Issues 53
āž— Star-Issue Ratio 4
šŸ˜Ž Author SciML