Download latest PDF - Read the Docs

Transcript
CHAPTER 4
User manual
The SciPy, NumPy and PyLab packages are documented on the following web sites:
• http://www.scipy.org/Getting_Started
• http://www.scipy.org/Documentation
• http://docs.scipy.org/
• http://matplotlib.sourceforge.net/
Brian itself is documented in the following sections:
4.1 Units
4.1.1 Basics
Brian has a system for physical quantities with units built in, and most of the library functions require that variables
have the right units. This restriction is useful in catching hard to find errors based on using incorrect units, and ensures
that simulated models are physically meaningful. For example, running the following code causes an error:
>>> from brian import *
>>> c = Clock(t=0)
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
c = Clock(t=0)
File "C:\Documents and Settings\goodman\Mes documents\Programming\Python simulator\Brian\units.py",
raise DimensionMismatchError("Function " + f.__name__ + " variable " + k + " should have dimensio
DimensionMismatchError: Function __init__ variable t should have dimensions of s, dimensions were (1)
You can see that Brian raises a DimensionMismatchError exception, because the Clock object expects t to
have units of time. The correct thing to write is:
>>> from brian import *
>>> c = Clock(t=0*second)
Similarly, attempting to do numerical operations with inconsistent units will raise an error:
>>> from brian import *
>>> 3*second+2*metre
Traceback (most recent call last):
189