SciComp@UNC Courseware

Interactive demo:

Initialization code

(* Ion names *)
ions={"(SuperPlus[Na])","(SuperPlus[K])","(SuperMinus[Cl])"};

(* Physical constants.[J/K/mol,K,C] *)
{R,T,F}={8.314,280.,96485.};

(* Intracellular steady-state concentrations *)
ci={15.,150.,7.5};

(* Extracellular steady-state concentrations *)
co={145.,5.,110.};

(* Transmembrane potential differences.[mV] *)
V0=R T/F Log[ci/co] 10^3;
{ENa,EK,El}=V0;

(* Maximum conductances [m-mhos/cm^2] *)
{gNa,gK,gl}={70.7,24.34,0.3};

(* Sodium channel (m) *)
fa[V_,Vr_]=0.1(25-(V-Vr));am[V_,Vr_]=fa[V,Vr]/(Exp[fa[V,Vr]]-1);
bm[V_,Vr_]=4. Exp[-(V-Vr)/18.];
iNa[V_,m_,h_]=gNa m^3 h (V-ENa);
msol= DSolve[{m'[t]==am[V,Vr] (1-m[t]) - bm[V,Vr] m[t],m[0]==m0},m[t],t][[1,1]];

(* Potassium channel (n) *)
ga[V_,Vr_]=0.01(10-(V-Vr));an[V_,Vr_]=ga[V,Vr]/(Exp[ga[V,Vr]]-1);
bn[V_,Vr_]=0.125 Exp[-(V-Vr)/80.];
iK[V_,n_]=gK n^4 (V-EK);
nsol= DSolve[{n'[t]==an[V,Vr] (1-n[t]) - bn[V,Vr] n[t],n[0]==n0},n[t],t][[1,1]];

(* Chloride channel (h) *)
ah[V_,Vr_]=0.07 Exp[-0.05(V-Vr)];
bh[V_,Vr_]=1./(Exp[0.1(30-(V-Vr))]+1.);
il[V_]=gl (V-El);hsol= DSolve[{h'[t]==ah[V,Vr] (1-h[t]) - bh[V,Vr] h[t],h[0]==h0},h[t],t][[1,1]];

(* Exponential variables *)
mnh={m[t] /. msol, n[t] /. nsol, h[t] /. hsol} ;

(* Exponential variable response to rectangular voltage pulse above resting voltage Vr *)

mnhPi=mnh /. V->(Vr+P HeavisidePi[(t-t0)/δt]);

fmnh[t_,Vr_,P_,t0_,δt_,m0_,n0_,h0_]=mnhPi;

(* Currents for imposed voltage, resting voltage *)
HHcurrents[V_,Vr_]:=Module[{mt,nt,ht},
{mt,nt,ht}={m[t] /. msol, n[t] /. nsol, h[t] /. hsol};
Return[{iNa[V,mt,ht],iK[V,nt],il[V]}]
]

Manipulate

(* Manipulate is set up for Plot. Modify as needed *)
tf=10.;
Manipulate[
Plot[Evaluate[fmnh[t,Vr,P,t0,δt,m0,n0,h0]/{m0,n0,h0}],
{t,0,tf},
Frame->True,FrameLabel->{"t [ms]","m,n,h"},
PlotLabel->"Exponential variables response to V(t)=P Π((t-t0)/δt)",
GridLines->Automatic,
PlotLegends->ions],
{{P,0},-40,0},
{{t0,0.2},0,tf},
{{δt,0.05},(10^(-6)),.2},
{{Vr,-70},-80,-60},
{{m0,0.042},0.01,0.07,.0001},
{{n0,0.315},0.0,1.0,.0001},
{{h0,0.608},0.0,1.0,.0001},
SaveDefinitions->True]