-
Notifications
You must be signed in to change notification settings - Fork 58
/
HH_functions.py
48 lines (38 loc) · 1.14 KB
/
HH_functions.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
import numpy as np
import math
def alphaM(V):
return (2.5-0.1*(V+65)) / (np.exp(2.5-0.1*(V+65)) -1)
def betaM(V):
return 4*np.exp(-(V+65)/18)
def alphaH(V):
return 0.07*np.exp(-(V+65)/20)
def betaH(V):
return 1/(np.exp(3.0-0.1*(V+65))+1)
def alphaN(V):
return (0.1-0.01*(V+65)) / (np.exp(1-0.1*(V+65)) -1)
def betaN(V):
return 0.125*np.exp(-(V+65)/80)
def HH(I0,T0):
dt = 0.01;
T = math.ceil(T0/dt) # [ms]
gNa0 = 120 # [mS/cm^2]
ENa = 115; # [mV]
gK0 = 36; # [mS/cm^2]
EK = -12; # [mV]
gL0 = 0.3; # [mS/cm^2]
EL = 10.6; # [mV]
t = np.arange(0,T)*dt
V = np.zeros([T,1])
m = np.zeros([T,1])
h = np.zeros([T,1])
n = np.zeros([T,1])
V[0]=-70.0
m[0]=0.05
h[0]=0.54
n[0]=0.34
for i in range(0,T-1):
V[i+1] = V[i] + dt*(gNa0*m[i]**3*h[i]*(ENa-(V[i]+65)) + gK0*n[i]**4*(EK-(V[i]+65)) + gL0*(EL-(V[i]+65)) + I0);
m[i+1] = m[i] + dt*(alphaM(V[i])*(1-m[i]) - betaM(V[i])*m[i]);
h[i+1] = h[i] + dt*(alphaH(V[i])*(1-h[i]) - betaH(V[i])*h[i]);
n[i+1] = n[i] + dt*(alphaN(V[i])*(1-n[i]) - betaN(V[i])*n[i]);
return V,m,h,n,t