//xopen("$(NEURONHOME)/lib/hoc/noload.hoc") 
v_init = -75
tstop = 80 
dt = 0.01
celsius = 37 
create acell_home_
access acell_home_
nsyn1=4

//  Single compartment cell 

begintemplate Grc
objref synlist, syn1[1],ampa1[1]
objref stim0 
public soma, syn1,ampa1,stim0
public synlist, connect2target
create soma 
proc init(){
nsyn =$1
objectvar syn1[nsyn],ampa1[nsyn]
synlist= new List()
soma { 
nseg = 1 
	diam = 9.76 
	L = 9.76 
	cm = 1
	Ra = 100
Area = PI*diam*L*1e-8
insert pas 
g_pas=4.11e-4
e_pas=-75
stim0 = new VClamp(0.5)

for i=0, nsyn-1 {
syn1[i]=new GrC_Glures23(0.5)
ampa1[i] = new AMPA_D2(0.5)//DCO kinetic scheme
//ampa1[i] = new AMPA_D4(0.5)  DOC kinetic scheme
setpointer ampa1[i].pglu, syn1[i].glu
}
}
for i=0, nsyn-1 {
 synlist.append(syn1[i])
}
}
proc connect2target(){soma $o2=new NetCon(&v(1),$o1)}
endtemplate Grc
begintemplate S1Gen
public pp, connect2target
external acell_home_
objref pp
proc init(){
acell_home_ pp= new SpGen2(0.5)}
proc connect2target(){$o2=new NetCon(pp,$o1)}
endtemplate S1Gen
ncells=1
nmossy=4
objref Mossy[nmossy],GrCell[ncells]
GrCell[0] = new Grc(nsyn1)
for i=0, nmossy -1 { 
Mossy[i]= new S1Gen()
}
objref cells, nclist, netcon
{cells = new List()  nclist = new List()}
func cell_append() {cells.append($o1)  
	return cells.count - 1 }
func nc_append() {//srcindex, tarcelindex, synindex
cells.object($1).connect2target(cells.object($2).synlist.object($3),netcon)
netcon.weight = $4   netcon.delay = $5
nclist.append(netcon)
return nclist.count - 1
}
//Network instantiation
for i=0, nmossy-1{
cell_append(Mossy[i])
}
cell_append(GrCell[0])
for i=0, nsyn1-1 {
nc_append(i, 4, i,  1,0)
}
load_proc("nrnmainmenu") 
nrnmainmenu() 

xopen("grcparam.hoc")
xopen("mossy.hoc") 
xopen("post2men.hoc")
xopen("pre3menu.hoc")
for(i=0;i<=3;i=i+1) {
Mossy[i].pp.t01=-20
Mossy[i].pp.APinburst=2
Mossy[i].pp.startbursting=20 
}
GrCell[0].ampa1.RelProb=1
load_file("initres.ses")

xopen("fig10.hoc")

// ***** Initialization *****

finitialize(v_init)