Xcos doc: Added a comparative test for DAEs 25/12225/2
Paul BIGNIER [Fri, 2 Aug 2013 14:30:01 +0000 (16:30 +0200)]
Now that DDaskrGMRes works for all the demos (especially Hyrdaulics),
use it to compare IDA with DDaskrNewton and DDaskrGMRes.

Change-Id: I488e028e2bb4d214fbc64c678a710952d1882624

scilab/modules/helptools/etc/images_md5.txt
scilab/modules/helptools/images/9-Comparaisons_5.png [new file with mode: 0644]
scilab/modules/helptools/images/9-Comparisons_5.png [new file with mode: 0644]
scilab/modules/helptools/images/Hydraulics.zcos.png [new file with mode: 0644]
scilab/modules/xcos/examples/solvers/benchBouncing.sce
scilab/modules/xcos/examples/solvers/benchHydraulics.sce [new file with mode: 0644]
scilab/modules/xcos/help/en_US/solvers/9-Comparisons.xml
scilab/modules/xcos/help/fr_FR/solvers/9-Comparaisons.xml

index 75b0f43..c60f29d 100644 (file)
 9-Comparaisons_2.png=af6502f90edbd9b38543af88fe5f38f3
 9-Comparaisons_3.png=f0a5c1ac73fbad1886c26a1175dded0f
 9-Comparaisons_4.png=155d2afc64b08b7caf19b0324b199262
+9-Comparaisons_5.png=8f30c91c51b71037aabf3b6bc14bf2a4
 9-Comparisons_1.png=1317221b1234f688e6595e11a3792d1b
 9-Comparisons_2.png=af6502f90edbd9b38543af88fe5f38f3
 9-Comparisons_3.png=f0a5c1ac73fbad1886c26a1175dded0f
 9-Comparisons_4.png=7682e302fa1460ea459dc980a030917b
+9-Comparisons_5.png=8f30c91c51b71037aabf3b6bc14bf2a4
 ABS_VALUE_1.png=14a5f86525c3b2d00b2211899dbff9ca
 BITCLEAR_1.png=65ca5a6984734c64ccc8151737cc8451
 BITCLEAR_fr_FR_1.png=32be3272a6958d5174808d3e533c70f6
diff --git a/scilab/modules/helptools/images/9-Comparaisons_5.png b/scilab/modules/helptools/images/9-Comparaisons_5.png
new file mode 100644 (file)
index 0000000..c6fbc12
Binary files /dev/null and b/scilab/modules/helptools/images/9-Comparaisons_5.png differ
diff --git a/scilab/modules/helptools/images/9-Comparisons_5.png b/scilab/modules/helptools/images/9-Comparisons_5.png
new file mode 100644 (file)
index 0000000..c6fbc12
Binary files /dev/null and b/scilab/modules/helptools/images/9-Comparisons_5.png differ
diff --git a/scilab/modules/helptools/images/Hydraulics.zcos.png b/scilab/modules/helptools/images/Hydraulics.zcos.png
new file mode 100644 (file)
index 0000000..b59d665
Binary files /dev/null and b/scilab/modules/helptools/images/Hydraulics.zcos.png differ
index e22d0a4..c6a6704 100644 (file)
@@ -7,21 +7,19 @@
 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.objs(3).graphics.exprs.paramv(1) = 0.15; // Gravity
 scs_m.objs(3).graphics.exprs.paramv(2) = 0.99; // Floor stickiness
 Info = scicos_simulate(scs_m, "nw");
 tf = 2000; // Final time
 tolerances = scs_m.props.tol;
-tolerances(1) = 10^-6; // abstol
-tolerances(2) = 10^-6; // reltol
 [%tcur, %cpr, alreadyran, needstart, needcompile, %state0] = Info(:);
 
-// Redefining messagebox() to avoid popup
-function messagebox(msg, title)
-    disp(title);
-    disp(msg);
-endfunction
-
 solverName = ["IDA" "DDaskr - Newton" "DDaskr - GMRes"];
 
 disp("--------------------------------");
@@ -44,4 +42,3 @@ for solver = 0:2
 
 end
 disp("--------------------------------");
-
diff --git a/scilab/modules/xcos/examples/solvers/benchHydraulics.sce b/scilab/modules/xcos/examples/solvers/benchHydraulics.sce
new file mode 100644 (file)
index 0000000..40f3dbd
--- /dev/null
@@ -0,0 +1,42 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+// Import the diagram, modify parameters, augment the ending time and store its compilation in Info()
+loadScicos();
+loadXcosLibs();
+importXcosDiagram("SCI/modules/xcos/demos/ModelicaBlocks/Hydraulics.zcos");
+// Redefining messagebox() to avoid popup
+function messagebox(msg, title)
+    disp(title);
+    disp(msg);
+endfunction
+
+Info = scicos_simulate(scs_m, "nw");
+tf = 50; // Final time
+tolerances = scs_m.props.tol;
+[%tcur, %cpr, alreadyran, needstart, needcompile, %state0] = Info(:);
+
+solverName = ["IDA" "DDaskr - Newton" "DDaskr - GMRes"];
+
+disp("--------------------------------");
+for solver = 0:2
+
+    disp("Time for " + solverName(solver + 1) + ":");
+    tolerances(6) = solver+100;
+
+    // Start the solver
+    [state, t] = scicosim(%state0, 0.0, tf, %cpr.sim, "start", tolerances);
+
+    // Run until the end
+    tic();
+    [state, t] = scicosim(state, 0.0, tf, %cpr.sim, "run", tolerances);
+    t = toc();
+    disp(t);
+
+    // End the solver
+    [state, t] = scicosim(state, tf, tf, %cpr.sim, "finish", tolerances);
+
+end
+disp("--------------------------------");
index 1b76302..2985133 100644 (file)
     <refsection>
         <title>Examples - ODEs</title>
         <para>
-            We will begin with a simple nonstiff example: a Sinus integration.
+            We will begin with a simple nonstiff example: a Sine integration.
         </para>
         <para>
             <link type="scilab" linkend="scilab.zcos/xcos/examples/solvers/ODE_Example.zcos">
@@ -674,13 +674,13 @@ try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
             The Scilab console displays:
             <screen><![CDATA[
 Time for IDA:
- 7.5
+ 8
 
 Time for DDaskr - Newton:
- 5.4
+ 5.6
 
 Time for DDaskr - GMRes:
- 10.2
+ 6.5
             ]]></screen>
         </para>
         <para>
@@ -693,7 +693,7 @@ Time for DDaskr - GMRes:
             GMRes is slower due to the small size of the problem.
         </para>
         <para>
-            From the result, we can extract the speed factors:
+            From the results, we can extract the speed factors:
         </para>
         <para>
             <informaltable border="1">
@@ -715,6 +715,72 @@ Time for DDaskr - GMRes:
                 </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.zcos/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>
         <title>See Also</title>
index d29cfbb..d196e56 100644 (file)
@@ -189,30 +189,30 @@ Temps pour Runge-Kutta implicite :
                 <tr>
                     <td align="center"> </td>
                     <td align="center">
-                        <emphasis>BDF / Newton</emphasis> 
+                        <emphasis>BDF / Newton</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>BDF / Functional</emphasis> 
+                        <emphasis>BDF / Functional</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Adams / Newton</emphasis> 
+                        <emphasis>Adams / Newton</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Adams / Functional</emphasis> 
+                        <emphasis>Adams / Functional</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Dormand-Prince</emphasis> 
+                        <emphasis>Dormand-Prince</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Runge-Kutta</emphasis> 
+                        <emphasis>Runge-Kutta</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Runge-Kutta Implicite</emphasis> 
+                        <emphasis>Runge-Kutta Implicite</emphasis>
                     </td>
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>LSodar</emphasis> 
+                        <emphasis>LSodar</emphasis>
                     </td>
                     <td align="center"> 3.1x </td>
                     <td align="center"> 3x </td>
@@ -224,7 +224,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>BDF / Newton</emphasis> 
+                        <emphasis>BDF / Newton</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> 0.1x </td>
@@ -236,7 +236,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>BDF / Functional</emphasis> 
+                        <emphasis>BDF / Functional</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -248,7 +248,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Adams / Newton</emphasis> 
+                        <emphasis>Adams / Newton</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -260,7 +260,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Adams / Functional</emphasis> 
+                        <emphasis>Adams / Functional</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -272,7 +272,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Dormand-Prince</emphasis> 
+                        <emphasis>Dormand-Prince</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -284,7 +284,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Runge-Kutta</emphasis> 
+                        <emphasis>Runge-Kutta</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -358,30 +358,30 @@ Temps pour Runge-Kutta implicite :
                 <tr>
                     <td align="center"> </td>
                     <td align="center">
-                        <emphasis>BDF / Newton</emphasis> 
+                        <emphasis>BDF / Newton</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>BDF / Functional</emphasis> 
+                        <emphasis>BDF / Functional</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Adams / Newton</emphasis> 
+                        <emphasis>Adams / Newton</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Adams / Functional</emphasis> 
+                        <emphasis>Adams / Functional</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Dormand-Prince</emphasis> 
+                        <emphasis>Dormand-Prince</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Runge-Kutta</emphasis> 
+                        <emphasis>Runge-Kutta</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Runge-Kutta Implicite</emphasis> 
+                        <emphasis>Runge-Kutta Implicite</emphasis>
                     </td>
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>LSodar</emphasis> 
+                        <emphasis>LSodar</emphasis>
                     </td>
                     <td align="center"> 2.8x </td>
                     <td align="center"> 2.6x </td>
@@ -393,7 +393,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>BDF / Newton</emphasis> 
+                        <emphasis>BDF / Newton</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> 0.9x </td>
@@ -405,7 +405,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>BDF / Functional</emphasis> 
+                        <emphasis>BDF / Functional</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -417,7 +417,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Adams / Newton</emphasis> 
+                        <emphasis>Adams / Newton</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -429,7 +429,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Adams / Functional</emphasis> 
+                        <emphasis>Adams / Functional</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -441,7 +441,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Dormand-Prince</emphasis> 
+                        <emphasis>Dormand-Prince</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -453,7 +453,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Runge-Kutta</emphasis> 
+                        <emphasis>Runge-Kutta</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -527,30 +527,30 @@ Temps pour Runge-Kutta implicite :
                 <tr>
                     <td align="center"> </td>
                     <td align="center">
-                        <emphasis>BDF / Newton</emphasis> 
+                        <emphasis>BDF / Newton</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>BDF / Functional</emphasis> 
+                        <emphasis>BDF / Functional</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Adams / Newton</emphasis> 
+                        <emphasis>Adams / Newton</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Adams / Functional</emphasis> 
+                        <emphasis>Adams / Functional</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Dormand-Prince</emphasis> 
+                        <emphasis>Dormand-Prince</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Runge-Kutta</emphasis> 
+                        <emphasis>Runge-Kutta</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>Runge-Kutta Implicite</emphasis> 
+                        <emphasis>Runge-Kutta Implicite</emphasis>
                     </td>
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>LSodar</emphasis> 
+                        <emphasis>LSodar</emphasis>
                     </td>
                     <td align="center"> 2.1x </td>
                     <td align="center"> 1.6x </td>
@@ -562,7 +562,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>BDF / Newton</emphasis> 
+                        <emphasis>BDF / Newton</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> 0.75x </td>
@@ -574,7 +574,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>BDF / Functional</emphasis> 
+                        <emphasis>BDF / Functional</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -586,7 +586,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Adams / Newton</emphasis> 
+                        <emphasis>Adams / Newton</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -598,7 +598,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Adams / Functional</emphasis> 
+                        <emphasis>Adams / Functional</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -610,7 +610,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Dormand-Prince</emphasis> 
+                        <emphasis>Dormand-Prince</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -622,7 +622,7 @@ Temps pour Runge-Kutta implicite :
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>Runge-Kutta</emphasis> 
+                        <emphasis>Runge-Kutta</emphasis>
                     </td>
                     <td align="center"> </td>
                     <td align="center"> </td>
@@ -695,21 +695,87 @@ Temps pour DDaskr - GMRes :
                 <tr>
                     <td align="center"> </td>
                     <td align="center">
-                        <emphasis>IDA</emphasis> 
+                        <emphasis>IDA</emphasis>
                     </td>
                     <td align="center">
-                        <emphasis>DDaskr G</emphasis> 
+                        <emphasis>DDaskr G</emphasis>
                     </td>
                 </tr>
                 <tr>
                     <td align="center">
-                        <emphasis>DDaskr N</emphasis> 
+                        <emphasis>DDaskr N</emphasis>
                     </td>
                     <td align="center"> 1.39x </td>
                     <td align="center"> 1.9x </td>
                 </tr>
             </informaltable>
         </para>
+        <para>
+            L'exemple suivant corrobore le précédent, il est plus court mais plus complet, parce-qu'il traite du remplissage et vidage s'une cuve.
+        </para>
+        <para>
+            <link type="scilab" linkend="scilab.zcos/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>
+            Dans le script suivant, on compare la différence de temps entre les solveurs en lançant les trois solveurs tout à tour:
+            <link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchHydraulics.sce">
+                Ouverture du script
+            </link>
+        </para>
+        <para>
+            La console Scilab affiche :
+            <screen><![CDATA[
+Temps pour IDA :
+ 3
+
+Temps pour DDaskr - Newton :
+ 0.8
+
+Temps pour DDaskr - GMRes :
+ 0.85
+            ]]></screen>
+        </para>
+        <para>
+            Des résultats on extrait les facteurs de vitesse :
+        </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>
         <title>Voir Aussi</title>