create cell_a_43, cell_b_43

forall {
	L = 200
	diam = 6

	Ra = 183
	cm = 1

	insert pas
	g_pas = 1 / 132500
	e_pas = -50

	nseg = 1	//for G-V plots; not using 51
}
v_init = e_pas

//------------------------------------------------------

objref g43[2]
for i = 0, 1 {
	g43[i] = new Gap43(0.5)	//Dummy Location
}

cell_a_43 g43[0].loc(0.9999) // just inside "distal" end of cell_a
cell_b_43 g43[1].loc(0.0001) // just inside "proximal" end of cell_b

objref pc
pc = new ParallelContext()

access cell_a_43
pc.source_var(&cell_a_43.v(0.9999), pctr)
pc.target_var(g43[1], &g43[1].vgap, pctr)
pctr = pctr + 1

access cell_b_43
pc.source_var(&cell_b_43.v(0.0001), pctr)
pc.target_var(g43[0], &g43[0].vgap, pctr)
pctr = pctr + 1

{ pc.setup_transfer() }
ParallelComputeTool[0].nthread(1)
cvode.cache_efficient(1)

//------------------------------------------------------

objref vbox_43, hbox1_43, hbox2_43
objref graph_v_43, graph_i_43, g_iv_43, g_gv_43

graph_v_43 = new Graph(0)
graph_v_43.exec_menu("Keep Lines")
addplot(graph_v_43,0)
graph_v_43.addexpr("cell_a_43.v(0.5)", 1, 2, 100, 100)

graph_i_43 = new Graph(0)
graph_i_43.exec_menu("Keep Lines")
addplot(graph_i_43,0)
graph_i_43.addexpr("g43[0].i", 5, 2, 100, 100)
//graph_i_43.addexpr("g43[1].i", 5, 2)

g_iv_43 = new Graph(0)
g_gv_43 = new Graph(0)

vbox_43 = new VBox()	//***** VBox
vbox_43.intercept(1)

hbox1_43 = new HBox()	//----- HBox1
hbox1_43.intercept(1)

graph_v_43.view(0, -170, 16000, 200, 600, 43, 600, 430)
graph_i_43.view(0, -6, 16000, 12, 1200, 43, 600, 430)

hbox1_43.intercept(0)
hbox1_43.map()			//----- HBox1

hbox2_43 = new HBox()	//----- HBox2
hbox2_43.intercept(1)

g_iv_43.view(-100, -6, 200, 12, 600, 43, 600, 430)
g_gv_43.view(-100, 0, 200, 180, 1200, 43, 600, 430)

hbox2_43.intercept(0)
hbox2_43.map()			//----- HBox2

vbox_43.intercept(0)
vbox_43.map()			//***** VBox
//------------------------------------------------------

objref stim_a_43
cell_a_43 stim_a_43 = new VClamp(0.5)
stim_a_43.amp[0] = -50

stim_a_43.amp[2] = -50
stim_a_43.dur[0] = 50
stim_a_43.dur[1] = 15000
stim_a_43.dur[2] = 500

//Stimulation stops before return to rest level
tstop= stim_a_43.dur[0]+stim_a_43.dur[1]

objref stim_b_43
cell_b_43 stim_b_43 = new VClamp (0.5)
stim_b_43.amp[0] = -50
stim_b_43.amp[1] = -50
stim_b_43.amp[2] = -50
stim_b_43.dur[0] = 50
stim_b_43.dur[1] = 15000
stim_b_43.dur[2] = 500

//------------------------------------------------------

objref rec_i_43, rec_g_43, vec_i_43, vec_g_43, vec_g_43_inst, vec_v_43

rec_i_43 = new Vector()
rec_g_43 = new Vector()
rec_i_43.record(&g43[0].i)
rec_g_43.record (&g43[0].g)

vec_i_43 = new Vector()
vec_g_43 = new Vector()
vec_g_43_inst = new Vector()
vec_v_43 = new Vector()

//------------------------------------------------------

for(i=-152.5; i<=52.5; i=i+5) {
	stim_a_43.amp[1] = i
	print "Clamp Level= ", i
	run()

	vec_g_43.append(rec_g_43.min())
	vec_i_43.append(rec_i_43.x(rec_i_43.size()-1))
	vec_v_43.append ((stim_a_43.amp[1]- stim_b_43.amp[1]))

	//Evaluate Instantaneous Conductance
	if ( (stim_a_43.amp[1]-stim_b_43.amp[1]) < 0 ) {
		vec_g_43_inst.append( 1000 * rec_i_43.min() / (stim_a_43.amp[1]- stim_b_43.amp[1]))
	} else {
		vec_g_43_inst.append( 1000 * rec_i_43.max() / (stim_a_43.amp[1]- stim_b_43.amp[1]))
	}
}

//------------------------------------------------------

vec_i_43.line(g_iv_43, vec_v_43, 2,2)
g_iv_43.exec_menu("View = plot")

vec_g_43.line(g_gv_43, vec_v_43, 3, 2)
vec_g_43_inst.line(g_gv_43, vec_v_43, 2, 2)
g_gv_43.mark(0,0,"O",1)
g_gv_43.exec_menu("View = plot")

graph_v_43.exec_menu("View = plot")
graph_i_43.exec_menu("View = plot")