/* hoc.pascab5 -- test multiple branching in interior of cable
   Compare this with hoc.pascab3.
      Notice that the voltage profile is that of a uniform cable up to
      the branch point
      since the 8 branches have the same total input impedance as a
      continuation of the cable.  From then on, since the diameter is 1/4 of
      its former value, the space constant is 1/2 of its former value. */

// physical properties of the cell
nb = 1
create a,b[nb]
access a
a.nseg = 20
for i=0,nb-1 b[i].nseg = 20
a {for i=0,nb-1 connect b[i](0), .2}
a {diam = 1 diam(.201:1)=.25:.25 L = 5  insert pas g_pas=.001 e_pas=0}
for i=0,nb-1 b[i] {diam = 8^(-2/3)  L = 4  insert pas g_pas=.001 e_pas=0 rallbranch=1}
b.rallbranch = 7
forall Ra = 1e7/4

// experimental tools
objref stim
stim = new VClamp(0)

// graphical interface appearance
length = a.L
objref g
g = new Graph()
g.size(0,length,0,1)
g.color(0)
g.color(1)
proc label() {
	g.vfixed
	g.label(.315,.01, "x (Lambda)")
	g.label(0, .5, "V")
	g.label(0,.95,"Steady state voltage as function of distance for infinite cable")
	g.label("Compare current injection, voltage clamp, and analytic sol'n.")
}
label()

// simulation control

proc plotvolt() { local x
	g.color(2)
	g.beginline()
	a for (x) {
		g.line(x*L, v(x))
	}
	g.beginline()
	b for (x) {
		g.line(x*L, v(x))
	}
}

proc run() {
	a.v = 0  for i=0,nb-1 b[i].v = 0
	dt = 1e9  t=0
	stim.dur[0]=1e20 stim.amp[0]=1 stim.gain=1e9
//	fclamp(1,0) fclamp(0,1e20, 1)
	g.color(1)
	g.vfixed
	g.label(.5,.8,"8 branches at .2") 
	fadvance() plotvolt()
	g.beginline()
	g.flush()
}

// run simulation
run()






