sgratiy wrote:Do I understand correctly that using Vector's play method is preferred when using the variable time step?
No. Here is what I wrote:
If your goal is to force cai to follow a parameterized function of time, it would be better to implement a mechanism with NMODL that WRITEs cai, where the values of cai are generated by a FUNCTION block.
Forcing functions used in computational modeling are typically either experimentally recorded variables that were sampled at discrete times, or actual mathematical functions of time. Vector play is most convenient for the former, regardless of the integration method; with adaptive integration, it would be a good idea to use Vector play with interpolation (read
http://www.neuron.yale.edu/neuron/stati ... .html#play
especially with regard to the "continuous" argument), but interpolation treats the data stream as break points of a piecewise linear function. For an actual mathematical function of time, it is often best to implement the function with NMODL. This has the advantage of providing the exact value of the function at any particular time t, and, depending on the function, preserving continuity of derivatives, which are useful attributes when using adaptive integration. An example of a driving force specified by a function in NMODL is the zap function ("chirp" or swept-frequency sinusoid), which is discussed in this post
http://www.neuron.yale.edu/phpBB/viewto ... 2404#p9483
which also links to source code for a demonstration program
http://www.neuron.yale.edu/ftp/ted/neuron/izap.zip
Also, assuming that I only care about [Ca]_i in the soma and assuming that at each point in time the somatic [Ca]_i is uniform
There is no need to customize proc advance(). Suppose your (t_j, cai_j) values are contained in two Vectors called tcaivec and caivec, respectively, and soma has nseg = 1. All you have to do is
caivec.play(&soma.cai(0.5), tcaivec, 1)
after model setup. Now each time you execute
run()
soma.cai will follow the piecewise linear function defined by the sequence of (t_j, cai_j) values.
If soma has nseg>1, the statement would be
for (x,0) caivec.play(&soma.cai(x), tcaivec, 1)
which skips the nodes at 0 and 1. Recall that attempting to assign a value to a range variable at 0 or 1 results in assignment to the variable at the nearest internal node.
The only caveats, which I quote from the Programmer's Reference:
Note that if there are discontinuities in the function itself, then tvec should have adjacent elements with the same time value. As of version 6.2, when a value is greater than the range of the t vector, linear extrapolation of the last two points is used instead of a constant last value. If a constant outside the range is desired, make sure the last two points have the same y value and have different t values (if the last two values are at the same time, the constant average will be returned).