Skip to content

Controlling unphysical negative values

Kyle Baron edited this page Sep 21, 2019 · 2 revisions

Source: CVodeWFtolerances in User Documentation for cvode v2.8.2
Accessed: http://lagrange.univ-lyon1.fr/docs/sundials/2.6.2/doc/cvode/cv_guide.pdf

Advice on controlling unphysical negative values

In many applications, some components in the true solution are always positive or non-negative, though at times very small. In the numerical solution, however, small negative (hence unphysical) values can then occur. In most cases, these values are harmless, and simply need to be controlled, not eliminated. The following pieces of advice are relevant.

(1) The way to control the size of unwanted negative computed values is with tighter absolute tolerances. Again this requires some knowledge of the noise level of these components, which may or may not be different for different components. Some experimentation may be needed.

(2) If output plots or tables are being generated, and it is important to avoid having negative numbers appear there (for the sake of avoiding a long explanation of them, if nothing else), then eliminate them, but only in the context of the output medium. Then the internal values carried by the solver are unaffected. Remember that a small negative value in y returned by cvode, with magnitude comparable to abstol or less, is equivalent to zero as far as the computation is concerned.

(3) The user’s right-hand side routine f should never change a negative value in the solution vector y to a non-negative value, as a ”solution” to this problem. This can cause instability. If the f routine cannot tolerate a zero or negative value (e.g. because there is a square root or log of it), then the offending value should be changed to zero or a tiny positive number in a temporary variable (not in the input y vector) for the purposes of computing f(t,y).

(4) Positivity and non-negativity constraints on components can be enforced by use of the recoverable error return feature in the user-supplied right-hand side function. However, because this option involves some extra overhead cost, it should only be exercised if the use of absolute tolerances to control the computed values is unsuccessful.

Clone this wiki locally