## The 'continuous' flag of Vector.play()

Anything that doesn't fit elsewhere.
johneric
Posts: 6
Joined: Thu Apr 27, 2006 8:08 am

### The 'continuous' flag of Vector.play()

I have 2 queries related to the 'continuous' flag of Vector's play() function. When we run the following bit of code, we would expect the 'temp' procedure to be called once for every dt.

1) Why is it getting called every dt/2.
2) Why is 'temp' called twice for time values in tVec?

Any explanation would be welcome.

thanks,

John

Code: Select all

``````load_file("nrngui.hoc")
objref vVec, tVec
create dummy
vVec = new Vector(5)
tVec = new Vector(5)

for i=0,4 {
vVec.x[i] = i
tVec.x[i] = i
}

proc temp () {
printf("%f ", t)
}

vVec.play("temp(\$1)", tVec, 1)
steps_per_ms = 1
dt = .5
tstop = 5
run()``````
hines
Posts: 1607
Joined: Wed May 18, 2005 3:32 pm

### Re: The 'continuous' flag of Vector.play()

Vector.play for continuous is supposed to be second order correct during a simulation.
This requires that the variables that are filled by the vector sometimes need to be
evaluated at t and sometimes at t+dt/2 depending on the which part of the fixed step
method is being computed. Since Vector.play has no way of knowing which phase
the variable is used, it computes it in both phases. That is unfortunate in your example
since temp() is not setting any variable at all.

The reason for the extra call at the tVec values is that those are points of (in this case, first derivative)
discontinuities and so an explicit event is used. This is particularly important for
variable step methods. In your case they can be avoided by explicitly identifying the
discontinuities (in your case there are none but I put one in as an example instead
of using a 0 size vector).

Code: Select all

``````objref dvec
dvec = new Vector(1)
dvec.x = int(tVec.size/2)
vVec.play("temp(\$1)", tVec, dvec)
``````