FacetsPythonCourse2008: leaky_if.py

File leaky_if.py, 0.6 KB (added by goodman, 4 years ago)
Line 
1'''
2A very simple example Brian script to show how to implement
3a leaky integrate and fire model. In this example, we also
4drive the single leaky integrate and fire neuron with
5regularly spaced spikes from the :class:`SpikeGeneratorGroup`.
6'''
7from brian import *
8
9tau = 10*ms
10Vr = -70*mV
11Vt = -55*mV
12
13model = Model(equations='''
14    dV/dt = -(V-Vr)/tau : volt
15    ''', threshold=Vt, reset=Vr)
16G = NeuronGroup(1,model)
17
18spikes = linspace(10*ms,100*ms,25)
19input = MultipleSpikeGeneratorGroup([spikes])
20
21C = Connection(input, G)
22C[0,0] = 5*mV
23
24M = StateMonitor(G, 'V', record=True)
25
26G.V = Vr
27run(100*ms)
28plot(M.times/ms,M[0]/mV)
29show()