Home

A.1
A.2
A.3

B.1
B.2

C.1
C.2
C.3

D.1

E.1
E.2
E.3
E.4
E.5
E.6

Basic
Commands

Manual

 

Speed of Simulation

The speed of a simulation is proportional to the number of segments and inversely proportional to the time step. Therefore, to speed up a simulation, we can reduce the number of segments (by using nseg) or increase dt. However, both these measures will decrease the accuracy of the simulation. Hines and Carnevale (2001) discuss the tradeoff between accuracy and speed in an accessible fashion.

They also discuss another strategy for speeding up simulations: variable time step methods. The principle of a variable time step method is that the time step is longer when quantities are not changing much (such as between action potentials) and shorter when quantities are changing quickly (such as during an action potential). incorporates a standard variable time step method called cvode. We will show basic use of cvode in .

By default, uses fixed time step integration. The command

cvode_active()

returns 0, indicating that variable time steps are not being used. To turn on the variable time step integration we can type:

cvode_active(1)

(We could also select the Tools-VariableTimeStep dialog and click on Use variable dt.)

When you try running the simulation again, you should see that it runs much faster than before turning cvode. (On a fast machine, you may not notice the lines on the graph being drawn.) To turn off cvode, either type:

cvode_active(0)

or deselect Use variable dt in the Tools-VariableTimeStep dialog.

In the fixed-timestep method of simulation, the accuracy of the simulation can be changed by specifying the timestep. In the variable time step method, there is no one time step to change; instead we specify a tolerance, that is the maximum estimated error allowed at each time step. Smaller tolerances will lead to more accurate but longer simulations. To find what the tolerance is, we type

cvode.atol()

We see that the default value (in 5.4 and newer) is 0.001. This gives about the same accuracy as a fixed time step of 25μs on the Hodgkin-Huxley action potential simulation at 6.3°C. You can investigate the effect of changing the accuracy by setting it with

cvode.atol(0.0001)

or by setting Absolute tolerance in the Tools-VariableTimeStep dialog.

An important point to note is that this is an absolute tolerance. For quantities such as membrane potential measured in millivolts, 0.001 is small. However, if our simulation contained quantities that have very small absolute values, the absolute tolerance we have specified could be many orders of magnitude greater than these quantities. It is possible to set smaller tolerances for some variables (e.g. calcium concentration); see atolscale in the documentation.

When we are using cvode, we can still use the PickVector or record vector methods (above) to save data to file (Note: in 5.4 and earlier the record vector methods cannot be used with cvode. An alternative record method in the cvode object is provided in the earlier versions.)

Acknowledgements

Last modified on 10/29/04 by
Albert Borroni, CS/Neuoriscience Oberlin College (aborroni@oberlin.edu)

based on tutorial written by
Andrew Gillies (andrew@anc.ed.ac.uk)
David Sterratt (dcs@anc.ed.ac.uk)
which is originally based on the tutorials by Kevin E. Martin
with the assistance of Ted Carnevale and Michael Hines