File: reference-clocks.txt

package info (click to toggle)
brian 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 23,436 kB
  • sloc: python: 68,707; cpp: 29,040; ansic: 5,182; sh: 111; makefile: 61
file content (73 lines) | stat: -rw-r--r-- 2,195 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
.. index:: clock

Clocks
------

.. currentmodule:: brian

.. index::
   single: clock; default clock
   single: default clock

Many Brian objects store a clock object (always passed in the 
initialiser with the keyword ``clock=``...). If no clock is specified,
the program uses the global default clock. When Brian is initially
imported, this is the object :data:`defaultclock`, and it has a default
time step of 0.1ms. In a simple script, you can override this by
writing (for example)::

	defaultclock.dt = 1*ms

However, there are other ways to access or redefine the default
clock (see functions below).

.. index::
   single: clock; multiple clocks
   single: multiple clocks

You may wish to use multiple clocks in your program. In this case,
for each object which requires one, you have to pass a copy of its
:class:`Clock` object. The network run function automatically handles objects
with different clocks, updating them all at the appropriate time
according to their time steps (value of :attr:`~Clock.dt`).

Multiple clocks can be useful, for example, for defining a simulation
that runs with a very small ``dt``, but with some computationally
expensive operation running at a lower frequency. 

The :class:`Clock` class
~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: Clock
.. autoclass:: EventClock
.. autoclass:: FloatClock
.. autoclass:: NaiveClock
.. autoclass:: RegularClock

.. index::
   single: clock; default clock
   single: default clock

The default clock
~~~~~~~~~~~~~~~~~

.. data:: defaultclock

    The default clock object
    
    Note that this is only the default clock object if you haven't
    redefined it with the :func:`define_default_clock` function or the
    ``makedefaultclock=True`` option of a :class:`Clock` object. A safe way to
    get hold of the default clock is to use the functions:
    
    * :func:`get_default_clock`
    * :func:`reinit_default_clock`
    
    However, it is suitable for short scripts, e.g.::
    
        defaultclock.dt = 1*ms
        ...

.. autofunction:: define_default_clock
.. autofunction:: reinit_default_clock
.. autofunction:: get_default_clock