[Question] cvode active and setting h.tstop #1773
-
Hello! I have a brief question about using adaptive integration and using Is the expected recorded vector supposed to be a certain length? I've been using Thanks in advance for all your support. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
This is expected behavior. If you're using CVode, by definition the time steps are not evenly spaced and you could have more or less of them than in your fixed-step case. Always record time as well as voltage; e.g. t = h.Vector().record(h._ref_t)
v = h.Vector().record(soma(0.5)._ref_v) If you really want values interpolated to a regular interval (but you may not need this), you can always record as above and then use e.g. numpy.interp to do the interpolation after-the-fact. One other suggestion: h.cvode.active(True) |
Beta Was this translation helpful? Give feedback.
-
Thanks so much for responding so quickly. I see that I will have to do the interpolation which makes sense given the design of adaptive dt. This answers my question so I'll close this. |
Beta Was this translation helpful? Give feedback.
-
Just a small caution about piece-wise linear interpolation. I don't know any situation where it matters, but there will be a small loss of accuracy compared to the use of https://nrn.readthedocs.io/en/latest/python/simctrl/cvode.html#CVode.solve at specific tout request times, as the latter uses the current cvode integration order interpolation formulae to calculate the state values at the tout value of
variants which will accomplish recording with cvode's current order at the moment of recording, but comes at the cost of a full cvode interpolation along with an extra calculation of the system f(y, t) at each of those time points. |
Beta Was this translation helpful? Give feedback.
This is expected behavior.
If you're using CVode, by definition the time steps are not evenly spaced and you could have more or less of them than in your fixed-step case. Always record time as well as voltage; e.g.
If you really want values interpolated to a regular interval (but you may not need this), you can always record as above and then use e.g. numpy.interp to do the interpolation after-the-fact.
One other suggestion:
True
andFalse
are probably more intuitive than 1 and 0 here, so consider writing: