// This experiment is to test the sensitivity of V_S

load_file("nrngui.hoc")
load_file("simulation_base.hoc")
dt = 0.001

objref cutoff_file
strdef cutoff_file_name,run_file_name

// want parameters to be set specifically by arguments,
// otherwise fail
// ratio, vs
// assume g_basket=0, g_chand=0, reversal potentials are -70, -50 respectively
// vary soma leak is g_pas=2e-3, e_pas=-80 mV, -70 mV, -60 mV, -50 mV
// assume IS leak is (-70,1e-3)
// vary distance of gap junction from soma

load_gj_axons(2,layer,1,0,g_gj)
print "loaded axons"
//setup_gj_session()
if(test_axon.stim_loc==0){ quit() }

set_soma_leak(axon1,vs,2e-3)
set_soma_leak(axon2,vs,2e-3)
forsec "axon" {
    g_pas = 1e-4
}

cutoff_file = new File()
//sprint(cutoff_file_name,"vs-expcellgj_gj%g-vs%d.out",g_gj,vs)
sprint(cutoff_file_name,"/projectnb/msprfmun/neuron/vs-expcellgj_L%d_gL%g_gj%g-vs%d.out",layer,axon1.axon[1].g_pas,g_gj,vs)
cutoff_file.wopen(cutoff_file_name)

stim1.amp=2
stim2.amp=2

d_dist = 0.2
n_iter = (dist1_end-dist1_beg)/d_dist + 1

for(j=0;j<n_iter;j=j+1){    
    dist = dist1_beg + j*d_dist
    print "distance=", dist
    cutoff_file.printf("%g\t",dist)
    //sprint(run_file_name,"vs-expcellgj-run_gj%g-vs%d-d%d.out",g_gj,vs,dist)
    sprint(run_file_name,"/projectnb/msprfmun/neuron/vs-expcellgj/vs-expcellgj-run_L%d_gL%1.1e_gj%g-vs%d-d%g.out",layer,axon1.axon[1].g_pas,g_gj,vs,dist)
    gj.reset_loc(dist/axon1.main_length)
    run_search(cutoff_file,run_file_name,3)
    //refine_search(cutoff_file,run_file_name,3)
}

quit()