Skip to content

Commit 2fe42c3

Browse files
Merge pull request #138 from srirag-vuppala/create-demo
Add in demo files
2 parents 336797a + 5bafa20 commit 2fe42c3

File tree

4 files changed

+201
-1
lines changed

4 files changed

+201
-1
lines changed

MANIFEST.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ recursive-include docs *.md
3636
recursive-include docs *.py
3737
recursive-include docs *.rst
3838
recursive-include docs *.txt
39-
recursive-include docs Makefile
39+
recursive-include docs Makefile
40+
41+
# demo folder
42+
recursive-include demo *.ipynb
43+
recursive-include demo *.py

binder/environment.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ dependencies:
88
# runtime
99
- python >=3.8,<3.9.0a0
1010
- jupyterlab >=3.1.0rc1,<4.0.0a0
11+
- numpy
12+
- scipy
13+
- matplotlib
1114
# labextension build
1215
- nodejs >=15,<16
1316
- pip

demo/hh.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
"""
2+
Author: Srirag Vuppala
3+
A model written to graph the Hodgkin - Huxley Equations to understand the gating kinetics for ionic channels (primarily potassium and sodium) within the cardiac cells.
4+
This analysis is done on a space clamped axon.
5+
"""
6+
7+
import numpy as np
8+
9+
10+
class HodgkinHuxley():
11+
C_m = 1
12+
"""membrane capacitance, in uF/cm^2"""
13+
g_Na = 120
14+
"""Sodium (Na) maximum conductances, in mS/cm^2"""
15+
g_K = 36
16+
"""Postassium (K) maximum conductances, in mS/cm^2"""
17+
g_L = 0.3
18+
"""Leak maximum conductances, in mS/cm^2"""
19+
V_Na = 115
20+
"""Sodium (Na) Diffusion potentials, in mV"""
21+
V_K = -12
22+
"""Postassium (K) Diffusion potentials, in mV"""
23+
V_L = -11
24+
"""Leak current Diffusion potentials, in mV"""
25+
t = np.arange(0.0, 30.0, 0.01)
26+
""" The time to integrate over """
27+
28+
def alpha_m(self, V):
29+
"""Channel gating kinetics. Functions of membrane voltage"""
30+
return 0.1*(25 - V)/(np.exp((25-V) / 10) - 1)
31+
def beta_m(self, V):
32+
"""Channel gating kinetics. Functions of membrane voltage"""
33+
return 4.0*np.exp(-(V / 18.0))
34+
35+
def alpha_h(self, V):
36+
"""Channel gating kinetics. Functions of membrane voltage"""
37+
return 0.07*np.exp(-(V / 20.0))
38+
def beta_h(self, V):
39+
"""Channel gating kinetics. Functions of membrane voltage"""
40+
return 1.0/(1.0 + np.exp(-(30 - V) / 10.0))
41+
42+
def alpha_n(self, V):
43+
"""Channel gating kinetics. Functions of membrane voltage"""
44+
return 0.01*(10 - V)/(np.exp((10 - V) / 10.0) - 1)
45+
def beta_n(self, V):
46+
"""Channel gating kinetics. Functions of membrane voltage"""
47+
return 0.125*np.exp(-(V / 80.0))
48+
49+
def n_inf(self, Vm=0.0):
50+
""" Inflection point potassium conductance to easily write gK"""
51+
return self.alpha_n(Vm) / (self.alpha_n(Vm) + self.beta_n(Vm))
52+
def m_inf(self, Vm=0.0):
53+
""" Sodium activation variable """
54+
return self.alpha_m(Vm) / (self.alpha_m(Vm) + self.beta_m(Vm))
55+
def h_inf(self, Vm=0.0):
56+
""" Sodium inactivation variable """
57+
return self.alpha_h(Vm) / (self.alpha_h(Vm) + self.beta_h(Vm))
58+
59+
# Input stimulus giver
60+
def Input_stimuli(self, t):
61+
""" Current applied to create stimulus which is dependent on time, in milli Ampere(A)/cm^2 """
62+
if 0.0 < t < 5.0:
63+
return 150.0
64+
elif 10.0 < t < 30.0:
65+
return 50.0
66+
return 0.0
67+
68+
def derivatives(self, y, t0):
69+
dy = [0]*4
70+
V = y[0]
71+
n = y[1]
72+
m = y[2]
73+
h = y[3]
74+
75+
#encapsulating the remaining terms within the equation
76+
GK = (self.g_K / self.C_m) * np.power(n, 4.0)
77+
GNa = (self.g_Na / self.C_m) * np.power(m, 3.0) * h
78+
GL = self.g_L / self.C_m
79+
80+
dy[0] = (self.Input_stimuli(t0) / self.C_m) - (GK * (V - self.V_K)) - (GNa * (V - self.V_Na)) - (GL * (V - self.V_L))
81+
82+
# dn/dt
83+
dy[1] = (self.alpha_n(V) * (1.0 - n)) - (self.beta_n(V) * n)
84+
85+
# dm/dt
86+
dy[2] = (self.alpha_m(V) * (1.0 - m)) - (self.beta_m(V) * m)
87+
88+
# dh/dt
89+
dy[3] = (self.alpha_h(V) * (1.0 - h)) - (self.beta_h(V) * h)
90+
91+
return dy

0 commit comments

Comments
 (0)