StoppingTest
Usage Message: StoppingTest is an option for NDSolve that can be used to stop the integration of the ode when a
certain condition is found to be True. The condition can evaluate to True/False only and should contain the dependent and independent variables explicitly.
This option cannot be used for linear boundary value problems. Attributes[StoppingTest] = {Protected}
Notes: The StoppingTest option can be used when you want NDSolve
to stop as soon as the solution reaches a certain value. Here is a simple example in which NDSolve
stops when the condition f[x] < 0 evaluates to True
. Without the StoppingTest option, the calculation would have continued through the range {x, 0, 10}
In[1]:= NDSolve[{f''[x] + f[x] == 0, f[0] == 0, f'[0] == 1},
f, {x, 0, 10}, StoppingTest -> (f[x] < 0)]
Out[1]= {{f -> InterpolatingFunction[{{0., 3.15464}}, <>]}}
The value of the StoppingTest option is expected to evaluate to either True
or False
. Indeterminate values will cause the calculation to terminate just as if the value had been True
, but you will also get a warning message advising you that the value of the StoppingTest option was neither True
nor False
. Since NDSolve
may step beyond the point where the value of StoppingTest evaluates to True
, the solution may also extend beyond that point. You can use the MaxStepSize
and MaxRelativeStepSize
options to limit the size of steps using by NDSolve
. Known Bugs: The StoppingTest option in Version 3.0 of Mathematica does not correctly use the independent variable. You can avoid this problem by introducing a trivial function for which the independent variable is the solution. For example:
In[1]:= NDSolve[{f'[t] == f[t], f[1] == 1,
var'[t] == 1, var[1] == 1}, {f, var}, {t, 1, 100},
StoppingTest -> (var[t ]> 5)]
Out[1]= {{f -> InterpolatingFunction[{{1., 5.01945}}, < >],
> var -> InterpolatingFunction[{{1., 5.01945}}, < >]}}
Questions or comments? Send email to support@wolfram.com.
| |