create a
a	{nseg=1 diam=5 L=5 
	insert ka ek=-90
	insert pas g_pas=1/10000 Ra=150 cm=1}
access a

tstop=100
vlow=-120
vhigh=30
dt=0.1
celsius=22

objref gk, b,gt,vc, gs,c, gf,ic
b = new VBox()
c = new VBox()
b.intercept(1)
gk = new Graph(0)
gk.view(vlow,0,vhigh-vlow,1,0,0,100,200)
gk.exec_menu("New Axis")
gk.exec_menu("10% Zoom out")
gk.label(0.1,0.9,"Fig.3D: steady-state")
gk.addexpr("ninf_ka",3,2, 2*tstop,0,2)
gk.addexpr("linf_ka",2,2, 2*tstop,0,2)

gt = new Graph(0)
gt.view(vlow,0,vhigh-vlow,30,0,0,100,200)
gt.exec_menu("New Axis")
gt.exec_menu("10% Zoom out")
gt.label(0.1,0.9,"time constants")
gt.addexpr("taun_ka*10",3,2, 2*tstop,0,2)
gt.addexpr("taul_ka",2,2, 2*tstop,0,2)

xpanel("")
xbutton("run ", "run()")
xpanel()
b.intercept(0)
b.map("K-A kinetics from Beck, Ficker and Heinemann (1992)",100,0,200,400)

c.intercept(1)
gs = new Graph(0)
gs.view(0,0,tstop,500,0,0,100,200)
gs.exec_menu("New Axis")
gs.exec_menu("10% Zoom out")
gs.label(0.1,0.9,"activation (pA), Fig.3A, step from -110mV")
gs.exec_menu("Keep Lines")

gf = new Graph(0)
gf.view(0,0,tstop,500,0,0,100,200)
gf.exec_menu("New Axis")
gf.exec_menu("10% Zoom out")
gf.label(0.1,0.9,"inactivation (pA), Fig.3C, step to +30mV ")
gf.exec_menu("Keep Lines")

c.intercept(0)
c.map("activation and inactivation",390,0,500,370)

vc = new SEClamp(0.5)

proc run() {
gk.begin()
for (v=vlow; v<vhigh; v=v+1) {
    rates_ka(v)
    gk.plot(v)
}
gk.flush()
doNotify()

gt.begin()
gt.color(2)
gt.label(0.1,0.2,"tau_inact.")
gt.color(3)
gt.label(0.6,0.2,"tau_act.*10")
gt.mark(30,7.53,"+",12,4,2)
gt.mark(10,7.56,"+",12,4,2)
gt.mark(-10,8.57,"+",12,4,2)
gt.mark(-30,15.68,"+",12,4,2)
for (v=vlow; v<vhigh; v=v+1) {
    rates_ka(v)
    gt.plot(v)
}
gt.flush()
doNotify()

gkabar_ka=0.005

gs.addexpr("ik*area(0.5)*10",1,1, 2*tstop,0,2) // *10=pA, *1e-2=nA
gs.label(0.19,0.75,"+30")
gs.label(0.19,0.4,"+10")
gs.label(0.19,0.29,"-10")
gs.label(0.19,0.19,"-30")
gf.addexpr("ik*area(0.5)*10",1,1, 2*tstop,0,2) // *10=pA, *1e-2=nA
gf.label(0.19,0.75,"-110")
gf.label(0.19,0.36,"-70")

gs.begin()
k=-30
while (k<31) {
t=0
vc.amp1=-110
vc.dur1=2
vc.amp2=k
vc.dur2=tstop
forall {finitialize(vc.amp1)}
while (t<tstop) {
    fadvance()
    gs.plot(t)
    }
print " 3A ", k
gs.flush()
doNotify()
k=k+20
gs.begin()
}
vc.dur1=0
vc.dur2=0
vc.dur3=0

k=-50
while (k>=-115) {
t=0
vc.amp1=k
vc.dur1=2
vc.amp2=30
vc.dur2=tstop
forall {finitialize(k)}
while (t<tstop) {
    fadvance()
    gf.plot(t)
    }
print "3C, k ",k
gf.flush()
doNotify()
if (k>-80) {k=k-10} else {k=k-30}
gf.begin()
}
vc.dur1=0
vc.dur2=0
vc.dur3=0
}