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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The GSL Team.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections and no cover texts. A copy of the license is
included in the section entitled "GNU Free Documentation License". -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Scientific Library – Reference Manual: Adaptive Step-size Control</title>
<meta name="description" content="GNU Scientific Library – Reference Manual: Adaptive Step-size Control">
<meta name="keywords" content="GNU Scientific Library – Reference Manual: Adaptive Step-size Control">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Function-Index.html#Function-Index" rel="index" title="Function Index">
<link href="Ordinary-Differential-Equations.html#Ordinary-Differential-Equations" rel="up" title="Ordinary Differential Equations">
<link href="Evolution.html#Evolution" rel="next" title="Evolution">
<link href="Stepping-Functions.html#Stepping-Functions" rel="previous" title="Stepping Functions">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Adaptive-Step_002dsize-Control"></a>
<div class="header">
<p>
Next: <a href="Evolution.html#Evolution" accesskey="n" rel="next">Evolution</a>, Previous: <a href="Stepping-Functions.html#Stepping-Functions" accesskey="p" rel="previous">Stepping Functions</a>, Up: <a href="Ordinary-Differential-Equations.html#Ordinary-Differential-Equations" accesskey="u" rel="up">Ordinary Differential Equations</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Adaptive-Step_002dsize-Control-1"></a>
<h3 class="section">26.3 Adaptive Step-size Control</h3>
<a name="index-Adaptive-step_002dsize-control_002c-differential-equations"></a>
<p>The control function examines the proposed change to the solution
produced by a stepping function and attempts to determine the optimal
step-size for a user-specified level of error.
</p>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005fstandard_005fnew"></a>Function: <em>gsl_odeiv2_control *</em> <strong>gsl_odeiv2_control_standard_new</strong> <em>(double <var>eps_abs</var>, double <var>eps_rel</var>, double <var>a_y</var>, double <var>a_dydt</var>)</em></dt>
<dd><a name="index-gsl_005fodeiv2_005fcontrol"></a>
<a name="index-gsl_005fodeiv2_005fcontrol_005ftype"></a>
<p>The standard control object is a four parameter heuristic based on
absolute and relative errors <var>eps_abs</var> and <var>eps_rel</var>, and
scaling factors <var>a_y</var> and <var>a_dydt</var> for the system state
<em>y(t)</em> and derivatives <em>y'(t)</em> respectively.
</p>
<p>The step-size adjustment procedure for this method begins by computing
the desired error level <em>D_i</em> for each component,
and comparing it with the observed error <em>E_i = |yerr_i|</em>. If the
observed error <var>E</var> exceeds the desired error level <var>D</var> by more
than 10% for any component then the method reduces the step-size by an
appropriate factor,
where <em>q</em> is the consistency order of the method (e.g. <em>q=4</em> for
4(5) embedded RK), and <em>S</em> is a safety factor of 0.9. The ratio
<em>E/D</em> is taken to be the maximum of the ratios
<em>E_i/D_i</em>.
</p>
<p>If the observed error <em>E</em> is less than 50% of the desired error
level <var>D</var> for the maximum ratio <em>E_i/D_i</em> then the algorithm
takes the opportunity to increase the step-size to bring the error in
line with the desired level,
This encompasses all the standard error scaling methods. To avoid
uncontrolled changes in the stepsize, the overall scaling factor is
limited to the range <em>1/5</em> to 5.
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005fy_005fnew"></a>Function: <em>gsl_odeiv2_control *</em> <strong>gsl_odeiv2_control_y_new</strong> <em>(double <var>eps_abs</var>, double <var>eps_rel</var>)</em></dt>
<dd><p>This function creates a new control object which will keep the local
error on each step within an absolute error of <var>eps_abs</var> and
relative error of <var>eps_rel</var> with respect to the solution <em>y_i(t)</em>.
This is equivalent to the standard control object with <var>a_y</var>=1 and
<var>a_dydt</var>=0.
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005fyp_005fnew"></a>Function: <em>gsl_odeiv2_control *</em> <strong>gsl_odeiv2_control_yp_new</strong> <em>(double <var>eps_abs</var>, double <var>eps_rel</var>)</em></dt>
<dd><p>This function creates a new control object which will keep the local
error on each step within an absolute error of <var>eps_abs</var> and
relative error of <var>eps_rel</var> with respect to the derivatives of the
solution <em>y'_i(t)</em>. This is equivalent to the standard control
object with <var>a_y</var>=0 and <var>a_dydt</var>=1.
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005fscaled_005fnew"></a>Function: <em>gsl_odeiv2_control *</em> <strong>gsl_odeiv2_control_scaled_new</strong> <em>(double <var>eps_abs</var>, double <var>eps_rel</var>, double <var>a_y</var>, double <var>a_dydt</var>, const double <var>scale_abs</var>[], size_t <var>dim</var>)</em></dt>
<dd><p>This function creates a new control object which uses the same algorithm
as <code>gsl_odeiv2_control_standard_new</code> but with an absolute error
which is scaled for each component by the array <var>scale_abs</var>.
The formula for <em>D_i</em> for this control object is,
where <em>s_i</em> is the <em>i</em>-th component of the array <var>scale_abs</var>.
The same error control heuristic is used by the Matlab <small>ODE</small> suite.
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005falloc"></a>Function: <em>gsl_odeiv2_control *</em> <strong>gsl_odeiv2_control_alloc</strong> <em>(const gsl_odeiv2_control_type * <var>T</var>)</em></dt>
<dd><p>This function returns a pointer to a newly allocated instance of a
control function of type <var>T</var>. This function is only needed for
defining new types of control functions. For most purposes the standard
control functions described above should be sufficient.
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005finit"></a>Function: <em>int</em> <strong>gsl_odeiv2_control_init</strong> <em>(gsl_odeiv2_control * <var>c</var>, double <var>eps_abs</var>, double <var>eps_rel</var>, double <var>a_y</var>, double <var>a_dydt</var>)</em></dt>
<dd><p>This function initializes the control function <var>c</var> with the
parameters <var>eps_abs</var> (absolute error), <var>eps_rel</var> (relative
error), <var>a_y</var> (scaling factor for y) and <var>a_dydt</var> (scaling
factor for derivatives).
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005ffree"></a>Function: <em>void</em> <strong>gsl_odeiv2_control_free</strong> <em>(gsl_odeiv2_control * <var>c</var>)</em></dt>
<dd><p>This function frees all the memory associated with the control function
<var>c</var>.
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005fhadjust"></a>Function: <em>int</em> <strong>gsl_odeiv2_control_hadjust</strong> <em>(gsl_odeiv2_control * <var>c</var>, gsl_odeiv2_step * <var>s</var>, const double <var>y</var>[], const double <var>yerr</var>[], const double <var>dydt</var>[], double * <var>h</var>)</em></dt>
<dd><p>This function adjusts the step-size <var>h</var> using the control function
<var>c</var>, and the current values of <var>y</var>, <var>yerr</var> and <var>dydt</var>.
The stepping function <var>step</var> is also needed to determine the order
of the method. If the error in the y-values <var>yerr</var> is found to be
too large then the step-size <var>h</var> is reduced and the function returns
<code>GSL_ODEIV_HADJ_DEC</code>. If the error is sufficiently small then
<var>h</var> may be increased and <code>GSL_ODEIV_HADJ_INC</code> is returned. The
function returns <code>GSL_ODEIV_HADJ_NIL</code> if the step-size is
unchanged. The goal of the function is to estimate the largest
step-size which satisfies the user-specified accuracy requirements for
the current point.
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005fname"></a>Function: <em>const char *</em> <strong>gsl_odeiv2_control_name</strong> <em>(const gsl_odeiv2_control * <var>c</var>)</em></dt>
<dd><p>This function returns a pointer to the name of the control function.
For example,
</p>
<div class="example">
<pre class="example">printf ("control method is '%s'\n",
gsl_odeiv2_control_name (c));
</pre></div>
<p>would print something like <code>control method is 'standard'</code>
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005ferrlevel"></a>Function: <em>int</em> <strong>gsl_odeiv2_control_errlevel</strong> <em>(gsl_odeiv2_control * <var>c</var>, const double <var>y</var>, const double <var>dydt</var>, const double <var>h</var>, const size_t <var>ind</var>, double * <var>errlev</var>)</em></dt>
<dd><p>This function calculates the desired error level of the <var>ind</var>-th component to <var>errlev</var>. It requires the value (<var>y</var>) and value of the derivative (<var>dydt</var>) of the component, and the current step size <var>h</var>.
</p></dd></dl>
<dl>
<dt><a name="index-gsl_005fodeiv2_005fcontrol_005fset_005fdriver"></a>Function: <em>int</em> <strong>gsl_odeiv2_control_set_driver</strong> <em>(gsl_odeiv2_control * <var>c</var>, const gsl_odeiv2_driver * <var>d</var>)</em></dt>
<dd><p>This function sets a pointer of the driver object <var>d</var> for control
object <var>c</var>.
</p></dd></dl>
<hr>
<div class="header">
<p>
Next: <a href="Evolution.html#Evolution" accesskey="n" rel="next">Evolution</a>, Previous: <a href="Stepping-Functions.html#Stepping-Functions" accesskey="p" rel="previous">Stepping Functions</a>, Up: <a href="Ordinary-Differential-Equations.html#Ordinary-Differential-Equations" accesskey="u" rel="up">Ordinary Differential Equations</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|