-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-numerics.py
52 lines (41 loc) · 986 Bytes
/
test-numerics.py
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
from neuron import h
from itertools import product
def template(mech, cvode=True):
cvodes = 1 if cvode else 0
return '''
create soma_%(suffix)s
access soma_%(suffix)s
insert hh_%(suffix)s
objref iclamp
iclamp = new IClamp(.5)
iclamp.del = 200
iclamp.dur = 100
iclamp.amp = 10
dt = 0.05
tstop = 500
finitialize(-65)
cvode_active(%(cvode)s)
objref tvec, vvec, mvec
tvec = new Vector()
vvec = new Vector()
mvec = new Vector()
vvec.record(&soma_%(suffix)s.v(0.5))
mvec.record(&soma_%(suffix)s.m_hh_%(suffix)s(0.5))
tvec.record(&t)
run()
objref TV
TV = new Matrix()
TV.resize(tvec.size(),3)
TV.setcol(0, tvec)
TV.setcol(1, vvec)
TV.setcol(2, mvec)
objref dump
dump = new File()
dump.wopen("/tmp/hh_%(suffix)s_cvode%(cvode)s.dat")
TV.fprint(dump, " %%g")
dump.close()
''' % {'suffix': mech, 'cvode': cvodes}
for m in product(['cnexp', 'derivimplicit'], ['rates', 'inline', 'nopar_rates']):
n = '_'.join(m)
h(template(n, cvode=True))
h(template(n, cvode=False))