2.4 ODE Solver

Summary

ODE Solver app is used to provide arithmetic solution for ordinary differential equations (ODE). It is widely used in mathematics and engineering.

ODE Solver app can solve a single ordinary differential equation or a system of equations. In this tutorial, we will show you both cases. For more examples, please click ⍰ button at the top-right corner of the app dialog or press F1 to open document.

Tutorial

Ordinary Differential Equation

Here we consider a nonlinear damped vibration system, that is, the object vibrates under the elastic force of a spring and a nonlinear damping force. The dynamic equation described this system can be written as follow, in which the damping force is in proportion to the square of the velocity:

\frac {d^{2}y}{d^{2}x}= -2\beta\frac{dy}{dx}- \omega^{2}y- \gamma (\frac{dy}{dx})^{2}

where x is time, y is the displacement of the object, y' is the velocity, y'' is acceleration, ω, β, γ are parameters. In this example, we take their values as follow:

omega = 1.0 // the natural frequency of the system,
beta = 0.1 // the linear damping coefficient
gamma = 0 // the nonlinear damping coefficient

The initial conditions at x0 = 0 are:

{y|_{x=x_0} \choose y'|_{x=x_0}} = {1 \choose 0}

We want to integrate the equation in the interval of [0,100].

  1. Click the ODE Solver icon ODE Solver icon.png in the Apps Gallery.
  2. In the opened dialog,
    • choose Equation,
    • enter 2 in the Order edit box,
    • enter the 2nd derivative expression as follow in y''= edit box:
      -y-2*0.1*y'-0.1*y'^2
    • in Integration Interval branch, enter Start Value = 0 and End Value = 100.
    • in Initial Conditions branch, enter y|x=x0 = 1 and y'|x=x0 = 0.
    • in Settings branch, make sure Method is set to Runge-Kutta and RK Order and Relative Tolerance are set as default.
    • check Output Derivatives and then check y' since we want to output object's velocity.
    ODE Solver 01.png

    Click OK button.
  3. A worksheet named ODE Solution and a graph window are created.
    • The worksheet contains a XY pair solved from the ordinary differential equation we specified above. The third column contains the first derivative.
    • The graph visualizes the output results in the worksheet, that is, displacement and velocity versus time. We can tell from it how nonlinear damping force effects on a vibrating system.
    ODE Solver 02.png

System of Ordinary Differential Equations

In the second example, we consider a classic ecological model: the Lotka-Volterra competition model:

\left( \begin{matrix}\frac{dN_1}{dt} \\\\ \frac{dN_2}{dt} \end{matrix}\right)
= \left( \begin{matrix} r_1N_1\left(1-\frac{N_1+a_{12}N_2}{K_1}\right) \\\\
r_2N_2\left(1-\frac{N_2+a_{21}N_1}{K_2}\right)\end{matrix}\right)

This equation system describes the competition between two species under limited resources. N1 and N2 are the population size of two species, r1, r2, K1, K2, a12 and a21 are parameters. In this example, we take their values as follow:

r1 = 1.0  // intrinsic growth rate of species 1
r2 = 1.5  // intrinsic growth rate of species 2
K1 = 10.0  // population size of species 1
K2 = 10.0  // population size of species 2
a12 = 0.3  // competition coefficient of species 1
a21 = 0.6  // competition coefficient of species 2

The initial conditions at x0 = 0 are:

{N_1|_{t=t_0} \choose N_2|_{t=t_0}} = {10 \choose 5}

We want to integrate the equation in the interval of [0,50].

  1. Click the ODE Solver icon ODE Solver icon.png in the Apps Gallery.
  2. In the opened dialog,
    • choose System of Equations,
    • enter 2 for Number of Equations,
    • enter equations as follow:
      dy1/dx = y1*(1-(y1+0.3*y2)/10) ,
      dy2/dx = 1.5*y2*(1-(y2+0.6*y1)/10) ,
    • in Integration Interval branch, enter Start Value = 0 and End Value = 50,
    • in Initial Conditions branch, enter y1|x=x0 = 10 and y2|x=x0 = 5,
    • in Settings branch, make sure Method is set to Runge-Kutta and RK Order and Relative Tolerance is set as default.
    ODE Solver 03.png

    Click OK button.
  3. A worksheet named ODE Solution and a graph window are created.
    • The worksheet contains XY1Y2 datasets solved from the equation system we specified above.
    • The graph visualizes the output results in the worksheet. That is, the changes in the population size of two species over time. We can tell from it that after years of competition for resources, the two species may reach a relatively stable "coexistence state".
    ODE Solver 04.png