//  ******************************************************
// 
//     File generated by: neuroConstruct v1.1.2
// 
//  ******************************************************

load_file("nrngui.hoc")

objectvar allCells
allCells = new List()


//  A flag to signal simulation was generated by neuroConstruct 

nC = 1


//  Including neuroConstruct utilities file 

load_file("nCtools.hoc")

//  Including neuroConstruct cell check file 

load_file("cellCheck.hoc")


//  Simulation running in serial mode, setting default host id

hostid = 0


//  Initializes random-number generator

use_mcell_ran4(1)

mcell_ran4_init(1285953529)

//////////////////////////////////////////////////////////////////////
//   Cell group 0: CellGroup_1 has cells of type: dm1_combined_13
//////////////////////////////////////////////////////////////////////


//  Adding cell template file: dm1_combined_13.hoc for cell group CellGroup_1

load_file("dm1_morph_3.hoc")

//  Adding 1 cells of type dm1_combined_13 in region SampleRegion

n_CellGroup_1 = 1

objectvar a_CellGroup_1[n_CellGroup_1]

proc addCell_CellGroup_1() {
    strdef reference
    sprint(reference, "CellGroup_1_%d", $1)
    a_CellGroup_1[$1] = new dm1_combined_13(reference, "dm1_combined_13", "")
    allCells.append(a_CellGroup_1[$1])
}

for i = 0, n_CellGroup_1-1 {
    addCell_CellGroup_1(i)

}


//  Placing these cells in a region described by: Rectangular Box from point: (0.0, 0.0, 0.0) to (100.0, 50.0, 100.0)


//  Packing has been generated by: Random: num: 1, edge: 1, overlap: 1, other overlap: 1

a_CellGroup_1[0].position(65.192154,8.772564,21.455801)



//////////////////////////////////////////////////////////////////////
//   Setting initial parameters
//////////////////////////////////////////////////////////////////////

strdef simConfig
simConfig = "Default Simulation Configuration"

proc initialiseValues() {


//  Setting initial vals in cell group: CellGroup_1 which has 1 cells


//  Giving all cells an initial potential of: -60.0

    for i = 0, n_CellGroup_1-1 {
        forsec a_CellGroup_1[i].all  v = -60.0

    }


}

objref fih
fih = new FInitializeHandler(0, "initialiseValues()")


access dm1_combined_13[0].cable_0

//////////////////////////////////////////////////////////////////////
//   Load other hoc and ses files
//////////////////////////////////////////////////////////////////////

load_file("electrode_circuit_step_d3.ses")
load_file("fit_params.hoc")

//////////////////////////////////////////////////////////////////////
//   Set cell parameters
//////////////////////////////////////////////////////////////////////

Rm = 26400
Cm = 0.61
Ri = 311


//////////////////////////////////////////////////////////////////////
//   Settings for running the simulation
//////////////////////////////////////////////////////////////////////

objref steady_state_clamp
steady_state_clamp = new SEClamp(.5)
steady_state_clamp.dur1 = 1
steady_state_clamp.amp1 = -60.0
steady_state_clamp.dur2 = 200
steady_state_clamp.amp2 = 0.0

forall insert atten

load_file("steady_state_shape.ses")
PlotShape[0].exec_menu("Shape Plot")
PlotShape[0].exec_menu("Show Diam")
PlotShape[0].scale(0,1)

tstop = 200
dt = 0.01
steps_per_ms = 100.00000223517424


//   This code pops up a simple Run Control

{
xpanel("RunControl", 0)
v_init = -60.0
xbutton("Init & Run","run()")
xbutton("Stop","stoprun=1")
t = 0
xvalue("t","t", 2 )
tstop = 200
xvalue("Tstop","tstop", 1,"tstop_changed()", 0, 1 )
dt = 0.01
 xvalue("dt","dt", 1,"setdt()", 0, 1 )
xpanel(80,80)
}

init()
run()