Debian Codegraph @

examples/compartmental/cylinder.py

raw
1 """
2 A short cylinder with constant injection at one end.
3 """
4 from brian2 import *
5
6 defaultclock.dt = 0.01*ms
7
8 # Morphology
9 diameter = 1*um
10 length = 300*um
11 Cm = 1*uF/cm**2
12 Ri = 150*ohm*cm
13 N = 200
14 morpho = Cylinder(diameter=diameter, length=length, n=N)
15
16 # Passive channels
17 gL = 1e-4*siemens/cm**2
18 EL = -70*mV
19 eqs = '''
20 Im = gL * (EL - v) : amp/meter**2
21 I : amp (point current)
22 '''
23
24 neuron = SpatialNeuron(morphology=morpho, model=eqs, Cm=Cm, Ri=Ri,
25 method='exponential_euler')
26 neuron.v = EL
27
28 la = neuron.space_constant[0]
29 print("Electrotonic length: %s" % la)
30
31 neuron.I[0] = 0.02*nA # injecting at the left end
32 run(100*ms, report='text')
33
34 plot(neuron.distance/um, neuron.v/mV, 'kx')
35 # Theory
36 x = neuron.distance
37 ra = la * 4 * Ri / (pi * diameter**2)
38 theory = EL + ra * neuron.I[0] * cosh((length - x) / la) / sinh(length / la)
39 plot(x/um, theory/mV, 'r')
40 xlabel('x (um)')
41 ylabel('v (mV)')
42 show()