Spaces:
Sleeping

File size: 10,061 Bytes
39e01c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?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="LSodar">
    <refnamediv>
        <refname>LSodar</refname>
        <refpurpose>
            <emphasis>LSodar</emphasis> (short for Livermore Solver for Ordinary Differential equations, with Automatic method switching for stiff and nonstiff problems, and with Root-finding) is a numerical solver providing an efficient and stable method to solve Ordinary Differential Equations (ODEs) Initial Value Problems.
        </refpurpose>
    </refnamediv>
    <refsection>
        <title>Description</title>
        <para>
            Called by <link linkend="xcos">xcos</link>, <emphasis>LSodar</emphasis> (short for Livermore Solver for Ordinary Differential equations, with Automatic method switching for stiff and nonstiff problems, and with Root-finding) is a numerical solver providing an efficient and stable variable-size step method to solve Initial Value Problems of the form:
        </para>
        <para>
            <latex>
                \begin{eqnarray}
                \dot{y} = f(t,y), \hspace{3 mm} y(t_0) = y_0, \hspace{3 mm} y \in R^N
                \end{eqnarray}
            </latex>
        </para>
        <para>
            LSodar is similar to <emphasis>CVode</emphasis> in many ways:
            <itemizedlist>
                <listitem>
                    It uses variable-size steps,
                </listitem>
                <listitem>
                    It can potentially use <emphasis>BDF</emphasis> and <emphasis>Adams</emphasis> integration methods,
                </listitem>
                <listitem>
                    <emphasis>BDF</emphasis> and <emphasis>Adams</emphasis> being implicit stable methods, <emphasis>LSodar</emphasis> is suitable for stiff and nonstiff problems,
                </listitem>
                <listitem>
                    They both look for roots over the integration interval.
                </listitem>
            </itemizedlist>
        </para>
        <para>
            The main difference though is that <emphasis>LSodar</emphasis> is <emphasis role="bold">fully automated</emphasis>, and chooses between <emphasis>BDF</emphasis> and <emphasis>Adams</emphasis> itself, by checking for stiffness at every step.
        </para>
        <para>
            If the step is considered stiff, then <emphasis>BDF</emphasis> (with max order set to 5) is used and the Modified Newton method <emphasis>'Chord'</emphasis> iteration is selected.
        </para>
        <para>
            Otherwise, the program uses <emphasis>Adams</emphasis> integration (with max order set to 12) and <emphasis>Functional</emphasis> iterations.
        </para>
        <para>
            The stiffness detection is done by step size attempts with both methods.
        </para>
        <para>
            First, if we are in <emphasis>Adams</emphasis> mode and the order is greater than 5, then we assume the problem is nonstiff and proceed with <emphasis>Adams</emphasis>.
        </para>
        <para>
            The first twenty steps use <emphasis>Adams / Functional</emphasis> method.
            Then <emphasis>LSodar</emphasis> computes the ideal step size of both methods. If the step size advantage is at least <emphasis>ratio = 5</emphasis>, then the current method switches (<emphasis>Adams / Functional</emphasis> to <emphasis>BDF / Chord Newton</emphasis> or vice versa).
        </para>
        <para>
            After every switch, <emphasis>LSodar</emphasis> takes twenty steps, then starts comparing the step sizes at every step.
        </para>
        <para>
            Such strategy induces a minor overhead computational cost if the problem stiffness is known, but is very effective on problems that require differentiate precision. For instance, discontinuities-sensitive problems.
        </para>
        <para>
            Concerning precision, the two integration/iteration methods being close to <emphasis>CVode</emphasis>'s, the results are very similar.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <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>
            The integral block returns its continuous state, we can evaluate it with <emphasis>LSodar</emphasis> by running the example:
        </para>
        <para>
            <programlisting language="example"><![CDATA[
      // Import the diagram and set the ending time
      loadScicos();
      loadXcosLibs();
      importXcosDiagram("SCI/modules/xcos/examples/solvers/ODE_Example.zcos");
      scs_m.props.tf = 5000;

      // Select the LSodar solver
      scs_m.props.tol(6) = 0;

      // Start the timer, launch the simulation and display time
      tic();
      try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
      t = toc();
      disp("Time for LSodar:", t);
      ]]></programlisting>
        </para>
        <para>
            The Scilab console displays:
            <screen><![CDATA[
Time for LSodar:
 9.546
            ]]></screen>
        </para>
        <para>
            Now, in the following script, we compare the time difference between <emphasis>LSodar</emphasis> and <emphasis>CVode</emphasis> by running the example with the five solvers in turn:
            <link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/integLSodar.sce">
                Open the script
            </link>
        </para>
        <para>
            <screen><![CDATA[
Time for LSodar:
 6.115

Time for BDF / Newton:
 18.894

Time for BDF / Functional:
 18.382

Time for Adams / Newton:
 10.368

Time for Adams / Functional:
 9.815
            ]]></screen>
        </para>
        <para>
            These results show that on a nonstiff problem, for the same precision required, <emphasis>LSodar</emphasis> is significantly faster. Other tests prove the proximity of the results. Indeed, we find that the solution difference order between <emphasis>LSodar</emphasis> and <emphasis>CVode</emphasis> is close to the order of the highest tolerance (
            <emphasis>
                y<subscript>lsodar</subscript> - y<subscript>cvode</subscript>
            </emphasis>
            ≈ <emphasis>max(reltol, abstol)</emphasis> ).
        </para>
        <para>
            Variable-size step 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>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <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="Comparisons">Comparisons</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>
    <refsection>
        <title>Bibliography</title>
        <para>
            ACM SIGNUM Newsletter, Volume 15, Issue 4, December 1980, Pages 10-11 <ulink url="http://dl.acm.org/citation.cfm?id=1218052.1218054&amp;coll=DL&amp;dl=GUIDE">LSode - LSodi</ulink>
        </para>
        <para>
            <ulink url="https://computation.llnl.gov/casc/sundials/documentation/documentation.html">Sundials Documentation</ulink>
        </para>
    </refsection>
    <refsection>
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>5.4.1</revnumber>
                <revdescription>LSodar solver added</revdescription>
            </revision>
        </revhistory>
    </refsection>
</refentry>