Spaces:
Sleeping

headless_scilab / data /help /9-Comparisons.xml
notsn's picture
Deploy headless Scilab space implementation
3d893c2 verified
Raw History Blame Contribute Delete
37.3 kB
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) Scilab Enterprises - 2012 - Paul Bignier
*
* Copyright (C) 2012 - 2016 - Scilab Enterprises
*
* This file is hereby licensed under the terms of the GNU GPL v2.0,
* pursuant to article 5.3.4 of the CeCILL v.2.1.
* This file was originally licensed under the terms of the CeCILL v2.1,
* and continues to be available under such terms.
* For more information, see the COPYING file which you should have received
* along with this program.
-->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en_US" xml:id="Comparisons">
<refnamediv>
<refname>Comparisons</refname>
<refpurpose>
This page compares solvers to determine which one is best fitted for the studied problem.
</refpurpose>
</refnamediv>
<refsection>
<title>Introduction</title>
<para>
Following the type of problem, finding out which method to use is not always obvious, only general guidelines can be established. Those are discussed in this page.
</para>
<title>Variable-size and Fixed-size</title>
<para>
The solvers can be divided into two distinct main families: the <emphasis>Variable</emphasis>-size and the <emphasis>Fixed</emphasis>-size step methods.
</para>
<para>
They both compute the next simulation time as the sum of the current simulation time and a quantity known as the step size, which is constant in the Fixed-size solvers and can change in the Variable-size ones, depending on the model dynamics and the input <link linkend="Simulatemenu_Menu_entries">tolerances</link>.
</para>
<para>
If looking for stable computation time, the user should select a Fixed-size step solver, because the computation overhead for a Variable-size step method cannot be properly predicted.
</para>
<para>
Although for a simple problem (or loose tolerances) a Variable-size solver can significantly improve the simulation time by computing bigger step sizes, a Fixed-size method is preferable if the ideal step size is known and roughly constant (the user should then mention it in <link linkend="Simulatemenu_Menu_entries">max step size</link>).
</para>
<para>
<!--<informaltable border="1">
<tr>
<td align="center">
<emphasis role="bold">Variable</emphasis>
</td>
<td align="center">
<emphasis role="bold">Fixed</emphasis>
</td>
</tr>
<tr>
<td> LSodar </td>
<td> Runge-Kutta </td>
</tr>
<tr>
<td> CVode </td>
<td> Dormand-Prince </td>
</tr>
<tr>
<td> IDA </td>
<td> Implicit Runge-Kutta </td>
</tr>
</informaltable>-->
<emphasis role="bold">Variable</emphasis>-size step solvers:
<simplelist>
<member>LSodar</member>
<member>CVode</member>
<member>IDA</member>
</simplelist>
<emphasis role="bold">Fixed</emphasis>-size step solvers:
<simplelist>
<member>Runge-Kutta 4(5)</member>
<member>Dormand-Prince 4(5)</member>
<member>Implicit Runge-Kutta 4(5)</member>
<member>Crank-Nicolson 2(3)</member>
</simplelist>
</para>
<para>
Variable step-size ODE solvers are not appropriate for deterministic real-time applications because the computational overhead of taking a time step varies over the course of an application.
</para>
<title>Explicit and Implicit - Stiffness</title>
<para>
Within these two families, we can distinguish <emphasis>Explicit</emphasis> solvers from <emphasis>Implicit</emphasis> ones.
</para>
<para>
While <emphasis>explicit</emphasis> methods only use data available on the current step, the <emphasis>implicit</emphasis> ones will attempt to compute derivatives at further times. In order to do this, they use nonlinear solvers such as fixed-point iterations, functional iterations (nonstiff) or modified Newton methods (stiff).
</para>
<para>
The family choice is usually determined by the <emphasis>stiffness</emphasis> of the problem, which is, when there is a big gap between the biggest and the smallest eigen values modules of the jacobian matrix (when it is ill-conditioned). It is generally a system that is sensitive to discontinuities, meaning that the required precision is not constant.
</para>
<para>
<emphasis role="bold">Implicit</emphasis> solvers:
<simplelist>
<member>LSodar</member>
<member>CVode</member>
<member>IDA</member>
<member>Implicit Runge-Kutta 4(5)</member>
<member>Crank-Nicolson 2(3)</member>
</simplelist>
<emphasis role="bold">Explicit</emphasis> solvers:
<simplelist>
<member>Runge-Kutta 4(5)</member>
<member>Dormand-Prince 4(5)</member>
</simplelist>
</para>
<para>
To put it simply, the <emphasis>Explicit</emphasis> go straight to a computation of the solution, whereas the <emphasis>Implicit</emphasis> concentrate on stability, involving more operations, following the tolerances.
</para>
<title>So how to choose?</title>
<para>
Because it is not possible to know for sure whether a solver will be efficient for a given system or not, the best way is to run the most probable one on it and to compare their results.
</para>
<para>
The user should first establish the complexity of his problem (stability / stiffness) and if he desires high precision, rapid simulation, predictable time or an automated program.
<para>
<emphasis role="bold">Precision:</emphasis> <emphasis>CVode</emphasis>,
</para>
<para>
<emphasis role="bold">Predictable time:</emphasis> Fixed-size step,
</para>
<para>
<emphasis role="bold">Simulation time:</emphasis> <emphasis>LSodar</emphasis>,
</para>
<para>
<emphasis role="bold">Automated:</emphasis> <emphasis>LSodar</emphasis>.
</para>
</para>
</refsection>
<refsection>
<title>Examples - ODEs</title>
<para>
We will begin with a simple nonstiff example: a Sine integration.
</para>
<para>
<link type="scilab" linkend="scilab.xcos/xcos/examples/solvers/ODE_Example.zcos">
<inlinemediaobject>
<imageobject>
<imagedata align="center" fileref="../../../examples/solvers/ODE_Example.zcos" valign="middle"/>
</imageobject>
</inlinemediaobject>
</link>
<scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/examples/solvers/ODE_Example.zcos");
scs_m.props.tol(6) = 0;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
</para>
<para>
In the following script, we compare the time difference between the solvers by running the example with the nine solvers in turn (<emphasis>IDA</emphasis> doesn't handle this kind of problem):
<link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchSine.sce">
Open the script
</link>
</para>
<para>
The Scilab console displays:
<screen><![CDATA[
Time for LSodar:
10.1
Time for CVode BDF/Newton:
31
Time for CVode BDF/Functional:
30
Time for CVode Adams/Newton:
17.211
Time for CVode Adams/Functional:
16.305
Time for Dormand-Prince:
12.92
Time for Runge-Kutta:
7.663
Time for implicit Runge-Kutta:
10.881
Time for Crank-Nicolson:
7.856
]]></screen>
</para>
<para>
These results show that on a nonstiff problem and for same precision required, <emphasis>Runge-Kutta</emphasis> is fastest.
</para>
<para>
In spite of the computational overhead of the step size, <emphasis>LSodar</emphasis> is not too distant from the Fixed-size solvers because it is able to take long steps.
</para>
<para>
From the results, we can extract speed factors and set the following table:
</para>
<para>
<informaltable border="1">
<tr>
<td align="center"> </td>
<td align="center">
<emphasis>BDF / Newton</emphasis>
</td>
<td align="center">
<emphasis>BDF / Functional</emphasis>
</td>
<td align="center">
<emphasis>Adams / Newton</emphasis>
</td>
<td align="center">
<emphasis>Adams / Functional</emphasis>
</td>
<td align="center">
<emphasis>Dormand-Prince</emphasis>
</td>
<td align="center">
<emphasis>Runge-Kutta</emphasis>
</td>
<td align="center">
<emphasis>Implicit Runge-Kutta</emphasis>
</td>
<td align="center">
<emphasis>Crank-Nicolson</emphasis>
</td>
</tr>
<tr>
<td align="center">
<emphasis>LSodar</emphasis>
</td>
<td align="center"> 3.1x </td>
<td align="center"> 3x </td>
<td align="center"> 1.7x </td>
<td align="center"> 1.6x </td>
<td align="center"> 1.3x </td>
<td align="center"> 0.75x </td>
<td align="center"> 1.08x </td>
<td align="center"> .07x </td>
</tr>
<tr>
<td align="center">
<emphasis>BDF / Newton</emphasis>
</td>
<td align="center"> </td>
<td align="center"> 0.1x </td>
<td align="center"> 0.6x </td>
<td align="center"> 0.5x </td>
<td align="center"> 0.4x </td>
<td align="center"> 0.25x </td>
<td align="center"> 0.35x </td>
<td align="center"> 0.23x </td>
</tr>
<tr>
<td align="center">
<emphasis>BDF / Functional</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.6x </td>
<td align="center"> 0.5x </td>
<td align="center"> 0.4x </td>
<td align="center"> 0.25x </td>
<td align="center"> 0.4x </td>
<td align="center"> 0.24x </td>
</tr>
<tr>
<td align="center">
<emphasis>Adams / Newton</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.9x </td>
<td align="center"> 0.75x </td>
<td align="center"> 0.45x </td>
<td align="center"> 0.6x </td>
<td align="center"> 0.42x </td>
</tr>
<tr>
<td align="center">
<emphasis>Adams / Functional</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.8x </td>
<td align="center"> 0.5x </td>
<td align="center"> 0.7x </td>
<td align="center"> 0.45x </td>
</tr>
<tr>
<td align="center">
<emphasis>Dormand-Prince</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.6x </td>
<td align="center"> 0.8x </td>
<td align="center"> 0.56x </td>
</tr>
<tr>
<td align="center">
<emphasis>Runge-Kutta</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 1.4x </td>
<td align="center"> 0.95x </td>
</tr>
<tr>
<td align="center">
<emphasis>Implicit Runge-Kutta</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.67x </td>
</tr>
</informaltable>
</para>
<para>
Next, a basic controller with six continuous states is tested.
<link type="scilab" linkend="scilab.xcos/xcos/demos/Controller.zcos">
<inlinemediaobject>
<imageobject>
<imagedata align="center" fileref="../../../demos/Controller.zcos" valign="middle"/>
</imageobject>
</inlinemediaobject>
</link>
<scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/demos/Controller.zcos");
scs_m.props.tol(6) = 0;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
</para>
<para>
In the following script, we compare the time difference between the solvers by running the example with the nine solvers in turn (<emphasis>IDA</emphasis> doesn't handle this kind of problem):
<link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchBasic.sce">
Open the script
</link>
</para>
<para>
The Scilab console displays:
<screen><![CDATA[
Time for LSodar:
10
Time for CVode BDF/Newton:
28.254
Time for CVode BDF/Functional:
25.545
Time for CVode Adams/Newton:
15
Time for CVode Adams/Functional:
12.1
Time for Dormand-Prince:
2.359
Time for Runge-Kutta:
1.671
Time for implicit Runge-Kutta:
5.612
Time for Crank-Nicolson:
3.345
]]></screen>
</para>
<para>
These results show that as stiffness appears, <emphasis>BDF / Newton</emphasis> starts picking up speed. But the problem is not yet complicated enough for that method to be interesting.
</para>
<para>
The updated speed factors table is as follows:
</para>
<para>
<informaltable border="1">
<tr>
<td align="center"> </td>
<td align="center">
<emphasis>BDF / Newton</emphasis>
</td>
<td align="center">
<emphasis>BDF / Functional</emphasis>
</td>
<td align="center">
<emphasis>Adams / Newton</emphasis>
</td>
<td align="center">
<emphasis>Adams / Functional</emphasis>
</td>
<td align="center">
<emphasis>Dormand-Prince</emphasis>
</td>
<td align="center">
<emphasis>Runge-Kutta</emphasis>
</td>
<td align="center">
<emphasis>Implicit Runge-Kutta</emphasis>
</td>
<td align="center">
<emphasis>Crank-Nicolson</emphasis>
</td>
</tr>
<tr>
<td align="center">
<emphasis>LSodar</emphasis>
</td>
<td align="center"> 2.8x </td>
<td align="center"> 2.6x </td>
<td align="center"> 1.5x </td>
<td align="center"> 1.2x </td>
<td align="center"> 0.2x </td>
<td align="center"> 0.17x </td>
<td align="center"> 0.5x </td>
<td align="center"> 0.33x </td>
</tr>
<tr>
<td align="center">
<emphasis>BDF / Newton</emphasis>
</td>
<td align="center"> </td>
<td align="center"> 0.9x </td>
<td align="center"> 0.5x </td>
<td align="center"> 0.4x </td>
<td align="center"> 0.1x </td>
<td align="center"> 0.05x </td>
<td align="center"> 0.2x </td>
<td align="center"> 0.12x </td>
</tr>
<tr>
<td align="center">
<emphasis>BDF / Functional</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.6x </td>
<td align="center"> 0.5x </td>
<td align="center"> 0.1x </td>
<td align="center"> 0.07x </td>
<td align="center"> 0.2x </td>
<td align="center"> 0.13x </td>
</tr>
<tr>
<td align="center">
<emphasis>Adams / Newton</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.8x </td>
<td align="center"> 0.15x </td>
<td align="center"> 0.1x </td>
<td align="center"> 0.4x </td>
<td align="center"> 0.22x </td>
</tr>
<tr>
<td align="center">
<emphasis>Adams / Functional</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.2x </td>
<td align="center"> 0.1x </td>
<td align="center"> 0.5x </td>
<td align="center"> 0.28x </td>
</tr>
<tr>
<td align="center">
<emphasis>Dormand-Prince</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.7x </td>
<td align="center"> 2.4x </td>
<td align="center"> 1.42x </td>
</tr>
<tr>
<td align="center">
<emphasis>Runge-Kutta</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 3.4x </td>
<td align="center"> 2x </td>
</tr>
<tr>
<td align="center">
<emphasis>Implicit Runge-Kutta</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.6x </td>
</tr>
</informaltable>
</para>
<para>
Now, we use Kalman's filter, which contains fifteen continuous states.
<link type="scilab" linkend="scilab.xcos/xcos/demos/Kalman.zcos">
<inlinemediaobject>
<imageobject>
<imagedata align="center" fileref="../../../demos/Kalman.zcos" valign="middle"/>
</imageobject>
</inlinemediaobject>
</link>
<scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/demos/Kalman.zcos");
scs_m.props.tol(6) = 0;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
</para>
<para>
In the following script, we compare the time difference between the solvers by running the example with the nine solvers in turn (<emphasis>IDA</emphasis> doesn't handle this kind of problem):
<link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchKalman.sce">
Open the script
</link>
</para>
<para>
The Scilab console displays:
<screen><![CDATA[
Time for LSodar:
10
Time for CVode BDF/Newton:
21.3
Time for CVode BDF/Functional:
15.8
Time for CVode Adams/Newton:
12.5
Time for CVode Adams/Functional:
8.67
Time for Dormand-Prince:
1.244
Time for Runge-Kutta:
0.87
Time for implicit Runge-Kutta:
4
Time for Crank-Nicolson:
2.657
]]></screen>
</para>
<para>
These results show that for a bigger problem (more continuous states implies more equations), the <emphasis>Newton iteration</emphasis> starts showing interest, for it comes closer to the other solvers.
</para>
<para>
The updated speed factors table is as follows:
</para>
<para>
<informaltable border="1">
<tr>
<td align="center"> </td>
<td align="center">
<emphasis>BDF / Newton</emphasis>
</td>
<td align="center">
<emphasis>BDF / Functional</emphasis>
</td>
<td align="center">
<emphasis>Adams / Newton</emphasis>
</td>
<td align="center">
<emphasis>Adams / Functional</emphasis>
</td>
<td align="center">
<emphasis>Dormand-Prince</emphasis>
</td>
<td align="center">
<emphasis>Runge-Kutta</emphasis>
</td>
<td align="center">
<emphasis>Implicit Runge-Kutta</emphasis>
</td>
<td align="center">
<emphasis>Crank-Nicolson</emphasis>
</td>
</tr>
<tr>
<td align="center">
<emphasis>LSodar</emphasis>
</td>
<td align="center"> 2.1x </td>
<td align="center"> 1.6x </td>
<td align="center"> 1.3x </td>
<td align="center"> 0.85x </td>
<td align="center"> 0.1x </td>
<td align="center"> 0.1x </td>
<td align="center"> 0.4x </td>
<td align="center"> 0.26x </td>
</tr>
<tr>
<td align="center">
<emphasis>BDF / Newton</emphasis>
</td>
<td align="center"> </td>
<td align="center"> 0.75x </td>
<td align="center"> 0.6x </td>
<td align="center"> 0.4x </td>
<td align="center"> 0.06x </td>
<td align="center"> 0.05x </td>
<td align="center"> 0.2x </td>
<td align="center"> 0.12x </td>
</tr>
<tr>
<td align="center">
<emphasis>BDF / Functional</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.8x </td>
<td align="center"> 0.55x </td>
<td align="center"> 0.08x </td>
<td align="center"> 0.06x </td>
<td align="center"> 0.25x </td>
<td align="center"> 0.17x </td>
</tr>
<tr>
<td align="center">
<emphasis>Adams / Newton</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.7x </td>
<td align="center"> 0.1x </td>
<td align="center"> 0.07x </td>
<td align="center"> 0.3x </td>
<td align="center"> 0.21x </td>
</tr>
<tr>
<td align="center">
<emphasis>Adams / Functional</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.15x </td>
<td align="center"> 0.1x </td>
<td align="center"> 0.5x </td>
<td align="center"> 0.3x </td>
</tr>
<tr>
<td align="center">
<emphasis>Dormand-Prince</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.7x </td>
<td align="center"> 3.2x </td>
<td align="center"> 2.1x </td>
</tr>
<tr>
<td align="center">
<emphasis>Runge-Kutta</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 4.6x </td>
<td align="center"> 3.1x </td>
</tr>
<tr>
<td align="center">
<emphasis>Implicit Runge-Kutta</emphasis>
</td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> 0.66x </td>
</tr>
</informaltable>
</para>
</refsection>
<refsection>
<title>Examples - DAEs</title>
<para>
In this section we compare IDA with DDaskr.
</para>
<para>
Example: a bouncing ball.
</para>
<para>
<link type="scilab" linkend="scilab.xcos/xcos/demos/ModelicaBlocks/BouncingBall_Modelica.zcos">
<inlinemediaobject>
<imageobject>
<imagedata align="center" fileref="../../../demos/ModelicaBlocks/BouncingBall_Modelica.zcos" valign="middle"/>
</imageobject>
</inlinemediaobject>
</link>
<scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/demos/ModelicaBlocks/BouncingBall_Modelica.zcos");
// Redefining messagebox() to avoid popup
function messagebox(msg, Title)
disp(Title);
disp(msg);
endfunction
scs_m.props.tol(6) = 100;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
</para>
<para>
In the following script, we compare the time difference between the solvers by running the example with the three solvers in turn:
<link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchBouncing.sce">
Open the script
</link>
</para>
<para>
The Scilab console displays:
<screen><![CDATA[
Time for IDA:
8
Time for DDaskr - Newton:
5.6
Time for DDaskr - GMRes:
6.5
]]></screen>
</para>
<para>
This result shows that on a stiff problem, with rootfinding and for same precision required, <emphasis>DDaskr - Newton</emphasis> is fastest.
</para>
<para>
The difference in time is attributed to the powerful implementation of DDaskr and its least error control.
</para>
<para>
GMRes is slower due to the small size of the problem.
</para>
<para>
From the results, we can extract the speed factors:
</para>
<para>
<informaltable border="1">
<tr>
<td align="center"> </td>
<td align="center">
<emphasis>IDA</emphasis>
</td>
<td align="center">
<emphasis>DDaskr G</emphasis>
</td>
</tr>
<tr>
<td align="center">
<emphasis>DDaskr N</emphasis>
</td>
<td align="center"> 1.39x </td>
<td align="center"> 1.9x </td>
</tr>
</informaltable>
</para>
<para>
The next example simply corroborates the previous one, it is shorter but more thorough, since it deals with the filling and emptying of a tank.
</para>
<para>
<link type="scilab" linkend="scilab.xcos/xcos/demos/ModelicaBlocks/Hydraulics.zcos">
<inlinemediaobject>
<imageobject>
<imagedata align="center" fileref="../../../demos/ModelicaBlocks/Hydraulics.zcos" valign="middle"/>
</imageobject>
</inlinemediaobject>
</link>
<scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/demos/ModelicaBlocks/Hydraulics.zcos");
// Redefining messagebox() to avoid popup
function messagebox(msg, Title)
disp(Title);
disp(msg);
endfunction
scs_m.props.tol(6) = 100;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
</para>
<para>
In the following script, we compare the time difference between the solvers by running the example with the three solvers in turn:
<link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchHydraulics.sce">
Open the script
</link>
</para>
<para>
The Scilab console displays:
<screen><![CDATA[
Time for IDA:
3
Time for DDaskr - Newton:
0.8
Time for DDaskr - GMRes:
0.85
]]></screen>
</para>
<para>
From the results, we can extract the speed factors:
</para>
<para>
<informaltable border="1">
<tr>
<td align="center"> </td>
<td align="center">
<emphasis>IDA</emphasis>
</td>
<td align="center">
<emphasis>DDaskr G</emphasis>
</td>
</tr>
<tr>
<td align="center">
<emphasis>DDaskr N</emphasis>
</td>
<td align="center"> 3.75x </td>
<td align="center"> 1.06x </td>
</tr>
</informaltable>
</para>
</refsection>
<refsection role="see also">
<title>See also</title>
<simplelist type="inline">
<member>
<link linkend="LSodar">LSodar</link>
</member>
<member>
<link linkend="CVode">CVode</link>
</member>
<member>
<link linkend="IDA">IDA</link>
</member>
<member>
<link linkend="RK">Runge-Kutta 4(5)</link>
</member>
<member>
<link linkend="DoPri">Dormand-Prince 4(5)</link>
</member>
<member>
<link linkend="ImpRK">Implicit Runge-Kutta 4(5)</link>
</member>
<member>
<link linkend="CRANI">Crank-Nicolson 2(3)</link>
</member>
<member>
<link linkend="DDaskr">DDaskr</link>
</member>
<member>
<link linkend="ode">ode</link>
</member>
<member>
<link linkend="ode_discrete">ode_discrete</link>
</member>
<member>
<link linkend="ode_root">ode_root</link>
</member>
<member>
<link linkend="odedc">odedc</link>
</member>
<member>
<link linkend="dae">dae</link>
</member>
</simplelist>
</refsection>
</refentry>