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:
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.isinplaceoptionally 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_linear — ConstantLinear ODE
with initial condition $u_0=\frac{1}{2}$, $α=1.01$, and solution
with Float64s. The parameter is $α$
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_2Dlinear — Constant4x2 version of the Linear ODE
with initial condition $u_0$ as all uniformly distributed random numbers, $α=1.01$, and solution
with Float64s
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_bigfloatlinear — ConstantLinear ODE
with initial condition $u_0=\frac{1}{2}$, $α=1.01$, and solution
with BigFloats
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_bigfloat2Dlinear — Constant4x2 version of the Linear ODE
with initial condition $u_0$ as all uniformly distributed random numbers, $α=1.01$, and solution
with BigFloats
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_large2Dlinear — Constant100x100 version of the Linear ODE
with initial condition $u_0$ as all uniformly distributed random numbers, $α=1.01$, and solution
with Float64s
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_2Dlinear_notinplace — Constant4x2 version of the Linear ODE
with initial condition $u_0$ as all uniformly distributed random numbers, $α=1.01$, and solution
on Float64. Purposefully not in-place as a test.
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_lotkavoltera — ConstantLotka-Voltera Equations (Non-stiff)
with initial condition $x=y=1$
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_fitzhughnagumo — ConstantFitzhugh-Nagumo (Non-stiff)
with initial condition $v=w=1$
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_threebody — ConstantThe ThreeBody problem as written by Hairer: (Non-stiff)
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_pleiades — ConstantPleiades Problem (Non-stiff)
where
and initial conditions are
and with $\\frac{dxᵢ(0)}{dt}=\\frac{dyᵢ(0)}{dt}=0$ except for
From Hairer Norsett Wanner Solving Ordinary Differential Equations I - Nonstiff Problems Page 244
Usually solved from 0 to 3.
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_vanderpol — ConstantVan der Pol Equations
with $μ=1.0$ and $u_0=[0,\sqrt{3}]$
Non-stiff parameters.
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_vanstiff — ConstantVan der Pol Equations
with $μ=10^6$ and $u_0=[0,\sqrt{3}]$
Stiff parameters.
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_rober — ConstantThe Robertson biochemical reactions: (Stiff)
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_rigidbody — ConstantRigid Body Equations (Non-stiff)
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_hires — ConstantHires Problem (Stiff)
It is in the form of
with
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_orego — ConstantOrego Problem (Stiff)
It is in the form of $\frac{dy}{dt}=f(y), \quad y(0)=y0,$ with
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_pollution — ConstantPollution Problem (Stiff)
This IVP is a stiff system of 20 non-linear Ordinary Differential Equations. It is in the form of
with
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
Analytical Jacobian is included.
Reference: pollu.pdf Notebook: Pollution.ipynb
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_nonlinchem — ConstantNonlinear system of reactions with an analytical solution
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_1d — Constant1D Brusselator
and the initial conditions are
with the boundary condition
From Hairer Norsett Wanner Solving Ordinary Differential Equations II - Stiff and Differential-Algebraic Problems Page 6
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_brusselator_2d — Constant2D Brusselator
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
with the periodic boundary condition
From Hairer Norsett Wanner Solving Ordinary Differential Equations II - Stiff and Differential-Algebraic Problems Page 152
DiffEqProblemLibrary.ODEProblemLibrary.prob_ode_filament — ConstantFilament 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.