juliadifferential-equationsdifferentialequations.jl

Julia Differential Equations Repositories


Is there a repository (or a web page) of all differential equations coded in DifferentialEquations.jl or at least ODE in OrdinaryDiffEq.jl?

If there are no repositories, are there other sources, university classes, etc. where Julia code is used to solve differential equations and is available?


Solution

  • There are two ways to read this question. One is either looking for where the examples for the ODE definitions are contained, the other is looking for where the ODE solver codebases are found. I'll split this answer into the two possible interpretations.

    Where the ODE Problem Definition Examples are Found

    The DifferentialEquations.jl documentation (https://docs.sciml.ai/DiffEqDocs/stable/) contains many examples for defining ODEs in its tutorials and examples section. It is highly recommended that one get started with the Getting Started with Differential Equations in Julia which uses examples such as the Lorenz equation. Other pages include more examples, such as the Classical Physics soler page in the documentation which shows how to implement 5 different classical physics models using standard ODE solvers and symplectic methods. There's also pages on dosing models, the Kepler problem, and much much more.

    The ODEProblem definition page (https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/) also has an "Example Problems" section (https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#Example-Problems) with more than 10 example problems implemented, including some classic ODEs such as the Brusselator. The source for these can be found in the DiffEqProblemLibrary.jl repository:

    https://github.com/SciML/DiffEqProblemLibrary.jl

    For example, the 20 stiff ODE POLLU pollution model reference in the documentation at (https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#ODEProblemLibrary.prob_ode_pollution) can be found at this location in the DiffEqProblemLibrary (in the sublibrary for ODEProblemLibrary):

    https://github.com/SciML/DiffEqProblemLibrary.jl/blob/master/lib/ODEProblemLibrary/src/pollution_prob.jl

    All of the example problems can be found in that repository.

    Note that additional examples can be found by looking at the benchmark pages as well: https://docs.sciml.ai/SciMLBenchmarksOutput/stable/

    Where the Solver Code is Found and How it's Organized

    DifferentialEquations.jl is a metapackage which re-exports the solver codes. The solvers are documented in https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/. In the section "Full List of Methods", the first section is OrdinaryDiffEq.jl which has a few hundred methods. These are all implemented in the OrdinaryDiffEq.jl repository:

    https://github.com/SciML/OrdinaryDiffEq.jl

    However, there are many other solvers available, as documented. A good set to know about for teaching is SimpleDiffEq.jl

    https://github.com/SciML/SimpleDiffEq.jl

    This for example has a bunch of self-contained implementations which can be easier to explain. For example, the GPUATsit5 implementation is mathematically equivalent to the standard OrdinaryDiffEq.jl Tsit5, but it's built without all of the extra machinery and options and is instead implemented as a single loop here:

    https://github.com/SciML/SimpleDiffEq.jl/blob/v1.10.0/src/tsit5/gpuatsit5.jl#L104

    Thus for someone trying to understand or explain the code in a classroom setting, using GPUATsit5 instead of Tsit5 can be helpful.

    As another example of a solver library, there are the CVODE_BDF methods from Sundials which are a wrapper over the SUNDIALS C++ library, and this wrapper code is found at the Sundials.jl repository:

    https://github.com/SciML/Sundials.jl

    A greater list of different solver packages are:

    And there's more, the list is ever growing. Thus DifferentialEquations.jl is a common interface, where solve(prob, alg) works for any algorithm type that dispatches appropriately, and there's 10+ packages that are now supplying algorithm types to this interface that all solve ODEs in different ways, with some traditional methods while some of these are using neural networks or generating circuits to run on quantum computers. But all of them take the same input and choosing the solver of a different library is just a few characters change.

    This interface is kept open by using multiple dispatch on the algorithm choice. If you're curious, more information about that is here: https://www.sciencedirect.com/science/article/abs/pii/S0965997818310251. It's specifically kept open so that researchers can add new methods to the interface without requiring that they contributing to existing libraries. This allows for someone to make a self-contained ODE solver, but then just add a single dispatch function and now it presents itself as part of the DifferentialEquations.jl interface. This is the reason why there isn't a single canonical repository to point to for DifferentialEquations.jl's solvers: it's intentionally built as an expandable interface.

    Summary

    So to summarize: