# The HH equations
# initialise the variables. V is the voltage.
V(0)=-65.0
n(0)=0.31768
m(0)=0.052934
h(0)=0.59611
#
# set the parameters
param Iapp=0
param gna=120   gk=36   gl=0.3  cm=1.0
param Vna=50   Vk=-77  Vl=-54.4
#
# define the functions
alpha_m(V)=0.1*(-40-V)/(exp((-40-V)/10)-1)
beta_m(V)=4*exp((-V-65)/18)
alpha_n(V)=0.01*(-55-V)/(exp((-55-V)/10)-1)
beta_n(V)=0.125*exp((-V-65)/80)
alpha_h(V)=0.07*exp((-V-65)/20)
beta_h(V)=1/(exp((-35-V)/10)+1)
#
# define the ODEs
V'=(1/cm)*(-gk*(n^4)*(V-Vk) - gna*(m^3)*h*(V-Vna) - gl*(V-Vl) + Iapp)
n'=alpha_n(V)*(1-n) - beta_n(V)*n
m'=alpha_m(V)*(1-m) - beta_m(V)*m
h'=alpha_h(V)*(1-h) - beta_h(V)*h
#
@ total=200, xp=t, yp=v, dt=0.1, xlo=0, xhi=200, ylo=-80, yhi=30,  
@ meth=gear, bound=1000
done
