forked from ccluri/metabolic_spiking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel.py
53 lines (45 loc) · 1.55 KB
/
channel.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
53
from utils import AttributeDict
class Channel(object):
def __init__(self, name, Gmax, E_r, gates=[], sp_gates=[]):
self.name = name
self.Gmax = Gmax
self.E_r = E_r
self.gates = gates
self.gate_vals = AttributeDict()
self.sp_gates = sp_gates
self.I = 0
def update_curr(self, dt, v, s=None):
self.update_gates(dt, v, s)
factor = 1
for gate in self.gates:
factor *= gate.get_val()**gate.count
self.I = self.Gmax*factor*(v-self.E_r)
return
def update_rev(self, val):
self.E_r = val
def update_gates(self, dt, v, s):
for g in self.gates:
if g.name in self.sp_gates:
vv = g.update_vals(dt, v, s)
else:
vv = g.update_vals(dt, v)
self.gate_vals[g.name] = vv
return
def init_channel(self, v, s=None):
for g in self.gates:
if g.name in self.sp_gates:
vv = g.init_val(v, s)
else:
vv = g.init_val(v)
self.gate_vals[g.name] = vv
class ChannelKA(Channel):
'''ac*((1-f)*b + f)'''
def update_curr(self, dt, v, s=None):
self.update_gates(dt, v, s)
factor = 1
for gate in [self.gates[0], self.gates[2]]:
factor *= gate.get_val()**gate.count
b = self.gates[1].get_val()**self.gates[1].count
f = self.gates[3].get_val() # frac that has no N-type
self.I = self.Gmax*factor*((1-f)*b + f)*(v-self.E_r)
return