Clock class

(Shortest import: from brian2 import Clock)

class brian2.core.clocks.Clock(dt, name='clock*')[source]

Bases: brian2.core.names.Nameable

An object that holds the simulation time and the time step.

Parameters:

dt : float

The time step of the simulation as a float

name : str, optional

An explicit name, if not specified gives an automatically generated name

Notes

Clocks are run in the same Network.run() iteration if t is the same. The condition for two clocks to be considered as having the same time is abs(t1-t2)<epsilon*abs(t1), a standard test for equality of floating point values. The value of epsilon is 1e-14.

Attributes

_dt The internally used dt.
dt The time step of the simulation in seconds.
dt_ The time step of the simulation as a float (in seconds)
running A bool to indicate whether the current simulation is running.
t The simulation time in seconds
t_ The simulation time as a float (in seconds)
t_end The time the simulation will end (in seconds)

Methods

tick() Advances the clock by one time step.

Details

_dt

The internally used dt. Note that right after a change of dt, this will not equal the new dt (which is stored in Clock._new_dt). Call Clock._set_t_update_t to update the internal clock representation.

dt

The time step of the simulation in seconds.

dt_

The time step of the simulation as a float (in seconds)

running

A bool to indicate whether the current simulation is running.

t

The simulation time in seconds

t_

The simulation time as a float (in seconds)

t_end

The time the simulation will end (in seconds)

set_interval(self, start, end)

Set the start and end time of the simulation.

Sets the start and end value of the clock precisely if possible (using epsilon) or rounding up if not. This assures that multiple calls to Network.run() will not re-run the same time step.

tick()[source]

Advances the clock by one time step.

Tutorials and examples using this