Hodgkin-Huxley Action Potential Model

Manipulate[
Module[
{peaks, t, st, dt, gnmax, gleak, gkmax, iinj, vna, vk, vleak, c, aVt, m, n, h, ipi, pd, runFor, ina, ik, itot, plotCounter, plotEvery, gateM,gateH, gateN, v},
peaks={};gateM = {}; gateH = {}; gateN = {};
(* INITIAL SEETING OF VARIABLES *)
v = -63.0076; 
t = 0.; 
st = 0; 
dt = 0.02; 
plotCounter = 0; (* sample for plotting *) 
plotEvery = 2; 
(* MODEL CONSTANTS *)
gnmax = 20; 
gkmax = 12; 
gleak = 0.1; 
iinj = 0; 
vna = 50.; 
vk = -90.; 
vleak = -60.; 
c = 1.; 
(* INITIALIZING LISTS FOR NUMBER STORAGE *) 
aVt = {};
(* SETTING INTIAL GATES TO THEIR STEADY-STATE *)
m = am[v]/(am[v] + bm[v]); 
n = an[v]/(an[v] + bn[v]); 
h = ah[v]/(ah[v] + bh[v]); 
(* USER INPUT FOR SIMULATION LENGTH, STIMULUS, ETC.. *)
ipi = 20; (* Input[" interpulse interval duration in msecs (20)"]; *)
pd = .5; (* Input[" pulse duration in msecs (1)"];*) 
runFor = 40; (* Input[" Key in desired runtime in msecs (100)"]; *)
(* MAIN LOOP *) 
While[t < runFor,
m = m + dt*(am[v]*(1 - m) - bm[v]*m);
h = h + dt*(ah[v]*(1 - h) - bh[v]*h);
n = n + dt*(an[v]*(1 - n) - bn[v]*n); 
If[st > ipi, iinj = amp, iinj = 0]; (* stimulation *)
ina = m^3 h gnmax (v - vna);
ik = n^4 gkmax (v - vk ); 
itot = ina + ik + gleak (v - vleak) - iinj; 
v = v - (itot dt)/c; 
If[ 
plotCounter == plotEvery,AppendTo[aVt, {t, v}]; AppendTo[gateM, {t, 20 m}]; AppendTo[gateH, {t, 20 h}]; AppendTo[gateN, {t, 20 n}]; plotCounter = 1,plotCounter = plotCounter + 1
 ]; 
If[ (* checking for time for removal of stimulus *) 
 	st > ipi + pd, 
 	st = 0
]; 
st = st + dt; 
t = t + dt
];
Show[{
ListPlot[{aVt,gateM, gateH, gateN}, PlotRange -> {{19, runFor}, {-100, 30}}, AxesOrigin -> {20, -90}, Joined -> True, Axes -> None, PlotStyle -> { {ColorData[1,1]}, {ColorData[1,2]}, {ColorData[1,3]}, {ColorData[1,4]}}], 
Graphics[
{{Thick,  Line[{{20, -85}, {22, -85}}] (* Plot time bar at hight -90 mV, 0.5 mS *)},
Text[Style["2 mS", 14], {21, -90}],
Line[{{35, -50}, {35, -40}}],Line[{{35, -50}, {35.2, -50}}],
Text[Style["-40 mV", 14, Black], {37, -40}],
Line[{{35, -40}, {35.2, -40}}](* Plot amplitude bar *),
Text[Style["-50 ", 14, Black], {36.7, -50}],
Line[{{ipi, -70}, {ipi, -30}}] (* vertical line start stim *), 
Line[{{ipi+pd, -70}, {ipi+pd, -30}}] (* vertical line end stim *),
Text[Style["m", 16,Italic, ColorData[1,2]], {21.5,20}],Text[Style["h", 16, Italic,ColorData[1,3]], {22.2,20}],Text[Style["n", 16,Italic, ColorData[1,4]], {22.8,20}],Text[Style["- 1 -", 14, Black], {19.75,20}],Text[Style["- 0 -", 14, Black], {19.75,0}]
}]}, 
ImageSize->{500,400}]
],
{{amp,15, "stimulus amplitude"}, -10, 50,1,Appearance->"Labeled"},
SynchronousUpdating-> False,
Initialization:> (
am = Compile[{v}, (0.1*(v + 40))/(1 - Exp[-0.1*(v + 40)])];bm = Compile[{v}, 4*Exp[-0.05*(v + 65)]]; an = Compile[{v}, -((0.01*(v+55))/(Exp[-0.1*(v + 55)] - 1))]; bn = Compile[{v}, 0.25*Exp[-0.0125*(v + 65)]]; 
ah = Compile[{v}, 0.07*Exp[-(1/20)*(v + 65)]]; 
bh = Compile[{v}, 1/(Exp[-(1/10)*(v + 35)] + 1)]; )
]

The voltage across membranes of excitable cells (e.g. nervous system, muscles, heart, endocrine system) transiently changes, creating a pulse-like wave called an "action potential". The action potential serves as a major signal for the initiation of many cellular and intercellular processes. The canonical mathematical-physical model of the phenomenon was presented by Alan Hodgkin and Andrew Huxley in 1952 in a series of seminal papers [2], where membrane potenial dynamics is described in terms of voltage-dependent ionic conductance, dominated by four coupled ordinary differential equations. In the Demonstration presented here, the action potential is trigerred by a short current stimulus. Shown are time evolutions of membrane voltage (blue trace) and conductance gates (m, h, and n).

Units: msec, mS, mV, and μF/(cm^2).

Rate functions:

(Subscript[α, m])=0.1 (v+40)/(1-exp(-0.1(v+40)));
(Subscript[β, m])=4 exp(-0.05(v+65));

(Subscript[α, n])=-0.01(v+55)/((exp(-0.1(v+55))-1);
(Subscript[β, n]) =0.25 exp(-0.0125(v+65));

(Subscript[α, h])=0.07 exp(-0.05(v+65));
(Subscript[β, h]) =1/((exp(-0.1(v+55))+1)

Parameters:

Maximal conductances are 20, 12, and 0.1 for sodium, potassium, and leak, respectively. Nernst equilibrium potentials are 50, -90, and -60 for sodium, potassium, and leak, respectively. Membrane capacitance is set to 1.

References

[1] B. Hille, Ion Channels of Excitable Membranes, Sunderland, MA: Sinauer, 2001.

[2] A. L. Hodgkin and A. F. Huxley, "A Quantitative Description of Membrane Current and Its Application to Conduction and Excitation in Nerve," Journal of Physiology, 117, 1952 pp. 500–544.

Contributed by: Shimon Marom