ODE Problems

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(t,u)\]

f should be specified as f(t,u) (or in-place as f(t,u,du)), 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,u0,tspan,callback=CallbackSet(),mass_matrix=I) : Defines the ODE with the specified functions.

Fields

Refined ODE Problems

The refined ODE types are types that specify the ODE to a much greater degree of detail, and thus give the solver more information and make it easier to optimize. There are three different kinds of refined problems: split (IMEX) problems, partitioned problems, and constrained problems.

Mathematical Specification of a Split ODE Problem

To define a ODEProblem in split form, you simply need to give a tuple of functions $(f_1,f_2,\ldots,f_n)$ and the initial condition $u₀$ which define an ODE:

\[\frac{du}{dt} = f_1(t,u) + f_2(t,u) + \ldots + f_n(t,u)\]

f should be specified as f(t,u) (or in-place as f(t,u,du)), 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.

Mathematical Specification of a Partitioned ODE Problem

To define a Partitioned ODEProblem, you need to give a tuple of functions $(f_1,f_2,\ldots,f_n)$ and the tuple of initial conditions $(u₀,v₀,...)$ (tuple of the same size) which define an ODE:

\[\frac{du}{dt} = f_1(t,u,v,...) \\ \frac{dv}{dt} = f_2(t,u,v,...) \\ ...\]

f should be specified as f(t,u,v,...) (or in-place as f(t,u,v,...,du)), and the initial conditions should be AbstractArrays (or numbers) 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. In some cases, the solvers may specify the functions in a split form, for example:

\[\frac{du}{dt} = f_1(t,u,v,...) + f_2(t,u,v,...) \\ \frac{dv}{dt} = f_3(t,u,v,...) \\ ...\]

See the solver's documentation for the form it is expecting.

Mathematical Specification of an Second Order ODE Problem

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

\[u'' = f(t,u,u')\]

f should be specified as f(t,u,du) (or in-place as f(t,u,du,ddu)), 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.

From this form, a partitioned ODE

\[u' = v \\ v' = f(t,u,v) \\\]

is generated.

Constructors

SecondOrderODEProblem(f,u0,du0,tspan,callback=CallbackSet(),mass_matrix=I) : Defines the ODE with the specified functions.

Fields

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:

# Pkg.add("DiffEqProblemLibrary")
using DiffEqProblemLibrary
prob = prob_ode_linear
sol = solve(prob)

Linear ODE

\[\frac{du}{dt} = αu\]

with initial condition $u0=1/2$, $α=1.01$, and solution

\[u(t) = u0e^{αt}\]

with Float64s

source

4x2 version of the Linear ODE

\[\frac{du}{dt} = αu\]

with initial condition $u0=1/2$, $α=1.01$, and solution

\[u(t) = u0e^{αt}\]

with Float64s

source

Linear ODE

\[\frac{du}{dt} = αu\]

with initial condition $u0=1/2$, $α=1.01$, and solution

\[u(t) = u0e^{αt}\]

with BigFloats

source

4x2 version of the Linear ODE

\[\frac{du}{dt} = αu\]

with initial condition $u0=1/2$, $α=1.01$, and solution

\[u(t) = u0e^{αt}\]

with BigFloats

source

100x100 version of the Linear ODE

\[\frac{du}{dt} = αu\]

with initial condition $u0=1/2$, $α=1.01$, and solution

\[u(t) = u0e^{αt}\]

with Float64s

source

4x2 version of the Linear ODE

\[\frac{du}{dt} = αu\]

with initial condition $u0=1/2$, $α=1.01$, and solution

\[u(t) = u0e^{αt}\]

on Float64. Purposefully not in-place as a test.

source

The ThreeBody problem as written by Hairer:

\[\begin{align} y₁′′ &= y₁ + 2y₂′ - μ′\frac{y₁+μ}{D₁} - μ\frac{y₁-μ′}{D₂} \\ y₂′′ &= y₂ - 2y₁′ - μ′\frac{y₂}{D₁} - μ\frac{y₂}{D₂} \\ D₁ &= ((y₁+μ)^2 + y₂^2)^{3/2} \\ D₂ &= ((y₁-μ′)^2+y₂^2)^{3/2} \\ μ &= 0.012277471 \\ μ′ &=1-μ \end{align}\]

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

Usually solved on t₀ = 0.0; T = parse(BigFloat,"17.0652165601579625588917206249") Periodic with that setup.

source

Pleides Problem

\[\begin{align} xᵢ′′ &= \sum_{j≠i} mⱼ(xⱼ-xᵢ)/rᵢⱼ \\ yᵢ′′ &= \sum_{j≠i} mⱼ(yⱼ-yᵢ)/rᵢⱼ \end{align}\]

where

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

and inital condtions are

\[\begin{align} 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 \end{align}\]

and with $xᵢ′(0)=yᵢ′(0)=0$ except for

\[\begin{align} x₆′(0)&=1.75 \\ x₇′(0)&=-1.5 \\ y₄′(0)&=-1.25 \\ y₅′(0)&=1 \end{align}\]

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

Usually solved from 0 to 3.

source

Van der Pol Equations

\[\begin{align} \frac{dx}{dt} &= y \\ \frac{dy}{dt} &= μ(1-x^2)y -x \end{align}\]

with $μ=1.0$ and $u0=[0,\sqrt{3}]$

Non-stiff parameters.

source

Van der Pol Equations

\[\begin{align} \frac{dx}{dt} &= y \\ \frac{dy}{dt} &= μ(1-x^2)y -x \end{align}\]

with $μ=10^6$ and $u0=[0,\sqrt{3}]$

Stiff parameters.

source

The Robertson biochemical reactions:

\[\begin{align} \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 \end{align}\]

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

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

Usually solved on [0,1e11]

source

Rigid Body Equations

\[\begin{align} \frac{dy₁}{dt} &= I₁y₂y₃ \\ \frac{dy₂}{dt} &= I₂y₁y₃ \\ \frac{dy₃}{dt} &= I₃y₁y₂ \end{align}\]

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 Euations I - Nonstiff Problems Page 244

Usually solved from 0 to 20.

source