Spaces:
Sleeping
Sleeping
File size: 8,127 Bytes
3d893c2 | 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 | <?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="RootFinding">
<refnamediv>
<refname>Rootfinding</refname>
<refpurpose>
Finds roots of continuous functions for Zero-crossing Blocks
</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>
Some problems require zero crossing detection of continuous functions (for instance, regulation systems), also named <emphasis>rootfinding</emphasis>.
This feature is common to all solvers, and is realized by following the same process.
</para>
<para>
Each Zero-crossing Block defines one of these functions, noted <emphasis>g(t)</emphasis>.
</para>
<para>
Generally, the feature only finds roots of odd multiplicity, corresponding to changes
in sign of <emphasis>g(t)</emphasis>. If a user root function has a root of even multiplicity (no sign change), it will probably be missed. If such a root is desired, the user should reformulate the root function so that it changes sign at the desired root.
</para>
<para>
The basic scheme used is to check for sign changes of any <emphasis>g(t)</emphasis> over each time step taken, and then (when a sign change is found) to home in on the root (or roots) with a modified secant method.
</para>
<para>
After suitable checking and adjusting has been done, the roots are to be sought within
<emphasis>
[t<subscript>lo</subscript>, t<subscript>hi</subscript>]
</emphasis>
. A loop is entered to locate the
root to within a rather tight tolerance, given by the <emphasis>unit roudoff</emphasis>, the <emphasis>current time</emphasis> and the <emphasis>step size</emphasis>.
</para>
<para>
We then determine which root function is more likely to have its roots occur first by comparing the secant method values, and set a new value
<emphasis>
t<subscript>mid</subscript>
</emphasis>
and restrain the research interval to either
<emphasis>
[t<subscript>lo</subscript>, t<subscript>mid</subscript>]
</emphasis>
or
<emphasis>
[t<subscript>mid</subscript>, t<subscript>hi</subscript>]
</emphasis>
, following which does the sign change occur in.
</para>
<para>
Since the tolerance depends on the step size, the smaller it is, the more accurate the homing in will be.
</para>
</refsection>
<refsection>
<title>Examples and Overhead</title>
<para>
<link type="scilab" linkend="scilab.xcos/xcos/demos/Threshold_ZeroCrossing.zcos">
<inlinemediaobject>
<imageobject>
<imagedata align="center" fileref="../../../demos/Threshold_ZeroCrossing.zcos" valign="middle"/>
</imageobject>
</inlinemediaobject>
</link>
<scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/demos/Threshold_ZeroCrossing.zcos");
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
</para>
<para>
Simple example of a Sine crossing zero several times:
</para>
<para>
<programlisting language="example"><![CDATA[
// Import the diagram and set the ending time
loadScicos();
loadXcosLibs();
importXcosDiagram("SCI/modules/xcos/demos/Threshold_ZeroCrossing.zcos");
// 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 blue bars represent the "positive to negative" zero crossings, while the red ones are for "negative to positive".
</para>
<para>
Now, in the two following scripts, we test the computational overhead of the rootfinding with <emphasis>LSodar</emphasis>:
</para>
<para>
First, a Sine function that crosses zero every π period:
<link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/Rootfinding.sce">
Open the script
</link>
</para>
<para>
<screen><![CDATA[
Time with rootfinding:
15.021
Time without rootfinding:
10.573
]]></screen>
</para>
<para>
Then, a simple straight line that crosses zero only once, in the middle of the interval:
<link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/RootfindingSimple.sce">
Open the script
</link>
</para>
<para>
<screen><![CDATA[
Time with rootfinding:
0.114
Time without rootfinding:
0.09
]]></screen>
</para>
<para>
Following the number of zero crossings, the aspect of the function near these crossings, the tolerances, ..., the computational overhead ranges between 25% and 45%.
</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="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>
<ulink url="https://computation.llnl.gov/casc/sundials/documentation/documentation.html">Sundials Documentation</ulink>
</para>
</refsection>
</refentry>
|