How to save the time at each time step

General issues of interest both for network and
individual cell parallelization.

Moderator: hines

Post Reply
breakwave922

How to save the time at each time step

Post by breakwave922 »

For some reason, I need to save the time history with specific time step. I use rect.record(&t,tstep), tstep=4 to save. But then all the time values I got is zero.
Any help is appreciated.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: How to save the time at each time step

Post by ted »

If you want to sample dependent variables at 4 ms intervals, why bother recording time at all?
If, however, you want to capture the dependent variables and the corresponding time every time your simulation generates a new solution, use the plain vanilla
vdest.record(&var)
syntax for each variable you want to record. Note that there must be at least one section in order for t to be recorded.
breakwave922

Re: How to save the time at each time step

Post by breakwave922 »

Thank you very much for your kindly reply.
Let me explain my situation: In my model, I recorded the soma voltage with 4ms time_step, the total time length of the model is 1100ms. If the voltage was recorded from 0ms, then the vector should contain 1100/4 + 1 = 278 values. But what I got is 277 values. So I want to know at what time the voltage was recorded, and at what time, the recording was ended.
Then I tried to recorded the time variables at 4ms intervals, in parallel with the voltage recording, in order to figure out the time courses.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: How to save the time at each time step

Post by ted »

1100/4 = 275
Total number of points captured at 4 ms intervals, starting at 0 and ending at 1100, will be 276. I just tried that myself using this file

Code: Select all

load_file("stdrun.hoc")
create soma
access soma
objref v4vec
v4vec = new Vector()
v4vec.record(&v(0.5), 4)
tstop = 1100
run()
print "number: ", v4vec.size()
which I called test.hoc.
nrniv test.hoc
produced this output:
number: 276
breakwave922

Re: How to save the time at each time step

Post by breakwave922 »

Sorry, my typo. It supposed to be 1100/4 + 1 = 276. But what I got is 1100/4 = 275. I don't know why.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: How to save the time at each time step

Post by ted »

What is your code using for dt? What happens when you do exactly what I did in my previous post?
breakwave922

Re: How to save the time at each time step

Post by breakwave922 »

I got the same number as you got in your previous post.
My dt is the model is 0.05
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: How to save the time at each time step

Post by ted »

Suggest you run a simulation using your dt.
At the end of the simulation, execute this statement
print t - 1100
and see what value is returned.
Post Reply