CVode warnings: what's the cause and how can I turn them off

Anything that doesn't fit elsewhere.
Post Reply
bsuter
Posts: 41
Joined: Fri May 28, 2010 9:04 am

CVode warnings: what's the cause and how can I turn them off

Post by bsuter » Wed Feb 13, 2013 4:32 pm

Hello,
During my simulations a very large number of warnings appear in the console. The warnings seem to occur around the times when action potentials occur in my simulation, which is also when the adaptive integration method uses short time steps. The warnings always look like this:
CVode-- Warning: Internal t = xxx.x and h = y.yyyyy
are such that t + h = t on the next step.
The solver will continue anyway.
Where xxx.x is between 200 and 300 ms, based on my simulation parameters.
Where y.yyyyy is usually from 1.yyyyye-17 to 9.yyyyye-19 (roughly eye-balled).

I have a couple of concerns that I'm hoping someone here can address.

1. I'm concerned that the warnings are slowing my simulation. I don't know how to confirm this, since I haven't figured out a way to turn the warnings off. My past experience in other types of programming taught me that printing to the screen takes some time, enough to introduce timing bugs in an embedded environment ... not sure how the time required to print + scroll these warnings compares to the execution time for a single time-step?

2. The warnings flood my console, so I am unable to easily see my earlier console commands and statements. However, I can still use the cursors to scroll through the commands I issued, but I can't go back and see other print statements that preceed the first warnings. This is merely inconvenient.

3. Even though these are "warnings" (not "errors"), I'm not sure how to interpret the "anyway" portion of the message. Aside from issues #1 and #2 above, is it safe to ignore these warnings? In other words, could the conditions that lead to the warnings also be affecting my simulation result?

How can I turn off these warnings, or avoid the conditions that lead to them?

Thank you very much!

PS: Looks like the warnings may be generated at L280 in src/scopmath/csoda.c

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: CVode warnings: what's the cause and how can I turn them

Post by hines » Thu Feb 14, 2013 1:47 pm

I suspect that the solver is not getting enough jacobian information to have a stable time step.
Or perhaps it is trying to integrate past a singularity. dt=0 should never happen and the
cause of it should be determined. I would also expect that the time it takes to print the notices
is negligible compared to the performance hit of not being able to do the simulation with
reasonable time steps. The diagnostic procedure I would use on my linux machine would be to
first invoke in nrn/src/oc/hoc.c
#define NRN_FLOAT_EXCEPTION (defined(SUN4)||defined(linux)) && 0
by changing the 0 to a 1 and seeing if there are any of those during the simulation.
If not, then I'd simulate to just before a warning and start looking at the index of the maximum absolute value of
the cvode.dstate vector to see if anything is way out of normal range (or cvode.state to see if anything is changing
violently)
An alternative is start with no mechanisms inserted and then add them back a few at a time in hopes of isolating
the problem to a particular mechanism. At that point one can put printf statements into the mod file to follow some of
the variables that look interesting.

The message is occurring on line 1700 of src/sundials/cvodes/cvodes.c

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: CVode warnings: what's the cause and how can I turn them

Post by hines » Thu Feb 14, 2013 1:53 pm

If you would like me to take a look at the reason for the message, send me a zip file with the necessary hoc, ses, mod files
and what file to launch. Send to michael dot hines at yale dot edu

bsuter
Posts: 41
Joined: Fri May 28, 2010 9:04 am

Re: CVode warnings: what's the cause and how can I turn them

Post by bsuter » Thu Mar 07, 2013 4:05 pm

Posting an update and solution in case someone else runs into similar errors. Michael Hines and Michele Migliore both helped in diagnosing the cause of the problem and proposing solutions.

1. Quick answer: A time constant in one of my mechanisms (h.mod) came so close to zero that cvode required a very small dt, which resulted in the warnings (since t+dt == t). A simple solution is to add a small constant value to the time constant, preventing it from reaching the tiny values that lead to this problem. In my case, the change was as follows in h.mod, and with this change, the warnings no longer occur, and my simulation experienced a significant performance increase.

Code: Select all

: taul    = bett(v)/(qtl*qt*a0t*(1+a))
taul    = bett(v)/(qtl*qt*a0t*(1+a)) + 1e-8
2. More detail: The root cause are the exponential functions used to model the mechanism. When membrane potential "v" enters a region that causes the exponentials to be very low or very high, the numerical integration algorithm becomes problematic. The solution described above (#1) solves this in a pragmatic way. The value added to tau (1e-8) is small enough to not appreciably affect the mechanism's role in the simulation, but large enough to avoid these CVode warnings. A more principled solution requires a closer look at this particular case: here my mechanism has a very steep decrease of tau, becoming very low above membrane potentials of ~-50 mV. With that in mind, an alternative solution is to explicitly check for this voltage region and adjust tau only sometimes. With this solution, the conditional test may need to be modified in the future if one changes the voltage-dependence of tau.

Code: Select all

: taul    = bett(v)/(qtl*qt*a0t*(1+a))
if (v>-50) {taul=1e-6} else {taul= bett(v)/(qtl*qt*a0t*(1+a))}

Post Reply