// Moore, Joyner, Brill, Waxman, and Najar-Joa. (1978) Simulations of
// conduction in uniform myelinated fibers: Relative sensitivity to
// changes in nodal and internodal parameters.
// Biophys. J. 21:147-160.

// Derived, with very few changes, from the NEURON implementation of the
// model of
// Brill, Waxman, Moore, and Joyner. (1977) Conduction velocity and spike
// configuration in myelinated fibres: Computed dependence on internode distance
// J. Neurology, Neurosurgery, and Psychiatry. 40: 769-774

create node[1], myelin[1]
objref nodes, myelins

// topol(nnode) connects an alternating sequence of node/myelin pairs.

proc topol() {local i
	nnode = $1
	create node[nnode], myelin[nnode-1]
	nodes = new SectionList()
	myelins = new SectionList()
	forsec "node" nodes.append
	forsec "myelin" myelins.append
	access node[0]
	for i=0, nnode-2 {
		connect myelin[i](0), node[i](1)
		connect node[i+1](0), myelin[i](1)
	}
	forsec myelins { nseg = 10 }
}

proc geom() {
	forsec nodes { // area = 100 um2
		L = 3.183
		diam = 10
	}
	forsec myelins {
		L = $1
		diam = 10
	}
}

proc biophys() {local fac
	// ohm/cm must be converted to ohm-cm by multiplying by
	// cross sectional area
	fac = PI*diam^2/4 * 1e-8
	forall {
		Ra = 100
	}
	// paper relative to rest=0 but following values relative to -65
	forsec nodes {
		insert hh
		gnabar_hh = 1.2
		gkbar_hh = .36
		gl_hh = .003
		ena = 115 - 65
		ek = -12 - 65
		cm = 1 // uF/cm2
	}
	forsec myelins {
		insert pas
		e_pas = -65
		g_pas = 1.5e-6 // S/cm2
		cm = .005 // uF/cm2
	}
	celsius = 18.5
}


proc make() {
	topol($1)
	geom($2)
	biophys()
}

make(20, 2000) // appropriate down to 25um internode length