// 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
// vs,layer,g_gj
// 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,0,0,g_gj)
print "loaded axons"
//setup_gj_session()
if(test_axon.stim_loc==0){ quit() }

cutoff_file = new File()
sprint(cutoff_file_name,"vs-expcellgjsISgNa_L%d_gj%g-vs%d.out",layer,g_gj,vs)
cutoff_file.wopen(cutoff_file_name)

set_soma_leak(axon1,vs,2e-3)
set_soma_leak(axon2,vs,2e-3)

axon1.soma{
    stim1 = new IClamp(0.5)
    stim2 = new IClamp(0.5)
}
stim1.amp=3
stim1.dur=1
stim1.del=5
stim2.amp=3
stim2.dur=1
stim2.del=10

d_dist = 5
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-expcellgjsISgNa-run_L%d-gj%g-vs%d-d%d.out",layer,g_gj,vs,dist)
    gj.reset_loc(dist/axon1.axon[axon1.IS].L)
    run_search(cutoff_file,run_file_name,2,1)
    // 1 for running through different g_Na in the IS
    //refine_search(cutoff_file,run_file_name,3,1)
}

//quit() //uncomment for batch runs