2.6 ODE SolverODE-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:
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:
We want to integrate the equation in the interval of [0,100].
- Click the ODE Solver icon in the Apps Gallery.
- 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.
Click OK button.
- 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.
System of Ordinary Differential Equations
In the second example, we consider a classic ecological model: the Lotka-Volterra competition model:
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:
We want to integrate the equation in the interval of [0,50].
- Click the ODE Solver icon in the Apps Gallery.
- 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.
Click OK button.
- 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".
Dialog Settings
Type
|
- Solve ordinary differential equation
- Solve system of first order differential equations
|
Order/Number of Equations
|
If Equation is selected for Type, this specifies order of the differential equation.
If System of Equations is selected for Type, this specifies number of equations of the system.
|
Equation(s)
For differential equation, valid variables are .
For system of differential equations, valid variables are where neq is the number of equations.
Integration Interval
Start Value
|
Specify start value of integration interval. This is the initial value of the independent variable.
|
End Value
|
Specify end value of integration interval. End value should be different from start value.
|
Number of Points
|
Specify number of points to output. The points are evenly sampled from the integration interval.
|
Initial Conditions
Specify initial conditions at the initial value of the independent variable. For differential equation, specify initial conditions for . For system of differential equations, specify initial conditions for .
Settings
Specify integration algorithm and error control
Output Derivatives
Specify derivatives to output. This branch is available only when Equation has been selected for Type and Order is larger than 1. User can choose whether to output derivatives .
ODE Solution
Specify output worksheet for ODE solution.
Algorithm
- Algorithm for Runge-Kutta: nag_ode_ivp_rk_setup (d02pvc), nag_ode_ivp_rk_range (d02pcc).
- Algorithm for Adams: nag_ode_ivp_adams_gen (d02cjc).
- Algorithm for BDF(Stiff): nag_ode_ivp_bdf_gen (d02ejc).
|