ODE Problems

Mathematical Specification of an ODE Problem

To define an ODE Problem, you simply need to give the function $f$ and the initial condition $u₀$ which define an ODE:

\[\frac{du}{dt} = f(u,p,t)\]

f should be specified as f(u,p,t) (or in-place as f(du,u,p,t)), and u₀ should be an AbstractArray (or number) whose geometry matches the desired geometry of u. Note that we are not limited to numbers or vectors for u₀; one is allowed to provide u₀ as arbitrary matrices / higher dimension tensors as well.

Problem Type

Constructors

  • ODEProblem(f::ODEFunction,u0,tspan,p=NullParameters();kwargs...)
  • ODEProblem{isinplace}(f,u0,tspan,p=NullParameters();kwargs...) : Defines the ODE with the specified functions. isinplace optionally sets whether the function is inplace or not. This is determined automatically, but not inferred.

Parameters are optional, and if not given then a NullParameters() singleton will be used which will throw nice errors if you try to index non-existent parameters. Any extra keyword arguments are passed on to the solvers. For example, if you set a callback in the problem, then that callback will be added in every solve call.

For specifying Jacobians and mass matrices, see the DiffEqFunctions page.

Fields

  • f: The function in the ODE.
  • u0: The initial condition.
  • tspan: The timespan for the problem.
  • p: The parameters.
  • kwargs: The keyword arguments passed onto the solves.

Example Problems

Example problems can be found in DiffEqProblemLibrary.jl.

To use a sample problem, such as prob_ode_linear, you can do something like:

#] add DiffEqProblemLibrary
using DiffEqProblemLibrary.ODEProblemLibrary
# load problems
ODEProblemLibrary.importodeproblems()
prob = ODEProblemLibrary.prob_ode_linear
sol = solve(prob)
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_threebodyConstant

The ThreeBody problem as written by Hairer: (Non-stiff)

\[\frac{dy₁}{dt} = y₁ + 2\frac{dy₂}{dt} - \bar{μ}\frac{y₁+μ}{D₁} - μ\frac{y₁-\bar{μ}}{D₂}\]
\[\frac{dy₂}{dt} = y₂ - 2\frac{dy₁}{dt} - \bar{μ}\frac{y₂}{D₁} - μ\frac{y₂}{D₂}\]
\[D₁ = ((y₁+μ)^2 + y₂^2)^{3/2}\]
\[D₂ = ((y₁-\bar{μ})^2+y₂^2)^{3/2}\]
\[μ = 0.012277471\]
\[\bar{μ} =1-μ\]

From Hairer Norsett Wanner Solving Ordinary Differential Equations I - Nonstiff Problems Page 129

Usually solved on $t₀ = 0.0$ and $T = 17.0652165601579625588917206249$ Periodic with that setup.

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_pleiadesConstant

Pleiades Problem (Non-stiff)

\[\\frac{d^2xᵢ}{dt^2} = \sum_{j≠i} mⱼ(xⱼ-xᵢ)/rᵢⱼ\]
\[\\frac{d^2yᵢ}{dt^2} = \sum_{j≠i} mⱼ(yⱼ-yᵢ)/rᵢⱼ\]

where

\[rᵢⱼ = ((xᵢ-xⱼ)^2 + (yᵢ-yⱼ)^2)^{3/2}\]

and initial conditions are

\[x₁(0) = 3\]
\[x₂(0) = 3\]
\[x₃(0) = -1\]
\[x₄(0) = -3\]
\[x₅(0) = 2\]
\[x₆(0) = -2\]
\[x₇(0) = 2\]
\[y₁(0) = 3\]
\[y₂(0) = -3\]
\[y₃(0) = 2\]
\[y₄(0) = 0\]
\[y₅(0) = 0\]
\[y₆(0) = -4\]
\[y₇(0) = 4\]

and with $\\frac{dxᵢ(0)}{dt}=\\frac{dyᵢ(0)}{dt}=0$ except for

\[\\frac{dx₆(0)}{dt} = 1.75\]
\[\\frac{dx₇(0)}{dt} = -1.5\]
\[\\frac{dy₄(0)}{dt} = -1.25\]
\[\\frac{dy₅(0)}{dt} = 1\]

From Hairer Norsett Wanner Solving Ordinary Differential Equations I - Nonstiff Problems Page 244

Usually solved from 0 to 3.

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_roberConstant

The Robertson biochemical reactions: (Stiff)

\[\frac{dy₁}{dt} = -k₁y₁+k₃y₂y₃\]
\[\frac{dy₂}{dt} = k₁y₁-k₂y₂^2-k₃y₂y₃\]
\[\frac{dy₃}{dt} = k₂y₂^2\]

where $k₁=0.04$, $k₂=3\times10^7$, $k₃=10^4$. For details, see:

Hairer Norsett Wanner Solving Ordinary Differential Equations I - Nonstiff Problems Page 129

Usually solved on $[0,1e11]$

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_rigidbodyConstant

Rigid Body Equations (Non-stiff)

\[\frac{dy₁}{dt} = I₁y₂y₃\]
\[\frac{dy₂}{dt} = I₂y₁y₃\]
\[\frac{dy₃}{dt} = I₃y₁y₂\]

with $I₁=-2$, $I₂=1.25$, and $I₃=-1/2$.

The initial condition is $y=[1.0;0.0;0.9]$.

From Solving Differential Equations in R by Karline Soetaert

or Hairer Norsett Wanner Solving Ordinary Differential Equations I - Nonstiff Problems Page 244

Usually solved from 0 to 20.

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_hiresConstant

Hires Problem (Stiff)

It is in the form of

\[\frac{dy}{dt} = f(y)\]

with

\[ y(0)=y_0, \quad y \in ℝ^8, \quad 0 ≤ t ≤ 321.8122\]

where $f$ is defined by

$f(y) = \begin{pmatrix} −1.71y_1 & +0.43y_2 & +8.32y_3 & +0.0007y_4 & \\ 1.71y_1 & −8.75y_2 & & & \\ −10.03y_3 & +0.43y_4 & +0.035y_5 & & \\ 8.32y_2 & +1.71y_3 & −1.12y_4 & & \\ −1.745y_5 & +0.43y_6 & +0.43y_7 & & \\ −280y_6y_8 & +0.69y_4 & +1.71y_5 & −0.43y_6 & +0.69y_7 \\ 280y_6y_8 & −1.81y_7 & & & \\ −280y_6y_8 & +1.81y_7 & & & \end{pmatrix}$

Reference: demohires.pdf Notebook: Hires.ipynb

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_oregoConstant

Orego Problem (Stiff)

It is in the form of $\frac{dy}{dt}=f(y), \quad y(0)=y0,$ with

\[y \in ℝ^3, \quad 0 ≤ t ≤ 360\]

where $f$ is defined by

$f(y) = \begin{pmatrix} s(y_2 - y_1(1-qy_1-y_2)) \\ (y_3 - y_2(1+y_1))/s \\ w(y_1-y_3) \end{pmatrix}$

where $s=77.27$, $w=0.161$ and $q=8.375⋅10^{-6}$.

Reference: demoorego.pdf Notebook: Orego.ipynb

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_pollutionConstant

Pollution Problem (Stiff)

This IVP is a stiff system of 20 non-linear Ordinary Differential Equations. It is in the form of

\[\frac{dy}{dt}=f(y)\]

with

\[y(0)=y0, \quad y \in ℝ^20, \quad 0 ≤ t ≤ 60\]

where $f$ is defined by

$f(y) = \begin{pmatrix} -\sum_{j∈{1,10,14,23,24}} r_j + \sum_{j∈{2,3,9,11,12,22,25}} r_j \\ -r_2 - r_3 - r_9 - r_12 + r_1 + r_{21} \\ -r_{15} + r_1 + r_{17} + r_{19} + r_{22} \\ -r_2 - r_{16} - r_{17} - r_{23} + r_{15} \\ -r_3 + 2r_4 + r_6 + r_7 + r_{13} + r_{20} \\ -r_6 - r_8 - r_{14} - r_{20} + r_3 + 2r_{18} \\ -r_4 - r_5 - r_6 + r_{13} \\ r_4 + r_5 + r_6 + r_7 \\ -r_7 - r_8 \\ -r_{12} + r_7 + r_9 \\ -r_9 - r_{10} + r_8 + r_{11} \\ r_9 \\ -r_{11} + r_{10} \\ -r_{13} + r_{12} \\ r_{14} \\ -r_{18} - r_{19} + r_{16} \\ -r_{20} \\ r_{20} \\ -r{21} - r_{22} - r_{24} + r_{23} + r_{25} \\ -r_{25} + r_{24} \end{pmatrix}$

with the initial condition of

\[y0 = (0, 0.2, 0, 0.04, 0, 0, 0.1, 0.3, 0.01, 0, 0, 0, 0 ,0, 0, 0, 0.007, 0, 0, 0)^T\]

Analytical Jacobian is included.

Reference: pollu.pdf Notebook: Pollution.ipynb

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_nonlinchemConstant

Nonlinear system of reactions with an analytical solution

\[\frac{dy_1}{dt} = -y_1\]
\[\frac{dy_2}{dt} = y_1 - y_2^2\]
\[\frac{dy_3}{dt} = y_2^2\]

with initial condition $y=[1;0;0]$ on a time span of $t \in (0,20)$

From

Liu, L. C., Tian, B., Xue, Y. S., Wang, M., & Liu, W. J. (2012). Analytic solution for a nonlinear chemistry system of ordinary differential equations. Nonlinear Dynamics, 68(1-2), 17-21.

The analytical solution is implemented, allowing easy testing of ODE solvers.

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_brusselator_1dConstant

1D Brusselator

\[\frac{\partial u}{\partial t} = A + u^2v - (B+1)u + \alpha\frac{\partial^2 u}{\partial x^2}\]
\[\frac{\partial v}{\partial t} = Bu - u^2v + \alpha\frac{\partial^2 u}{\partial x^2}\]

and the initial conditions are

\[u(x,0) = 1+\sin(2π x)\]
\[v(x,0) = 3\]

with the boundary condition

\[u(0,t) = u(1,t) = 1\]
\[v(0,t) = v(1,t) = 3\]

From Hairer Norsett Wanner Solving Ordinary Differential Equations II - Stiff and Differential-Algebraic Problems Page 6

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_brusselator_2dConstant

2D Brusselator

\[\frac{\partial u}{\partial t} = 1 + u^2v - 4.4u + \alpha(\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2}) + f(x, y, t)\]
\[\frac{\partial v}{\partial t} = 3.4u - u^2v + \alpha(\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2})\]

where

$f(x, y, t) = \begin{cases} 5 & \quad \text{if } (x-0.3)^2+(y-0.6)^2 ≤ 0.1^2 \text{ and } t ≥ 1.1 \\ 0 & \quad \text{else} \end{cases}$

and the initial conditions are

\[u(x, y, 0) = 22\cdot y(1-y)^{3/2}\]
\[v(x, y, 0) = 27\cdot x(1-x)^{3/2}\]

with the periodic boundary condition

\[u(x+1,y,t) = u(x,y,t)\]
\[u(x,y+1,t) = u(x,y,t)\]

From Hairer Norsett Wanner Solving Ordinary Differential Equations II - Stiff and Differential-Algebraic Problems Page 152

DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_filamentConstant

Filament PDE Discretization

Notebook: Filament.ipynb

In this problem is a real-world biological model from a paper entitled Magnetic dipole with a flexible tail as a self-propelling microdevice. It is a system of PDEs representing a Kirchhoff model of an elastic rod, where the equations of motion are given by the Rouse approximation with free boundary conditions.