celsius = 35

Rm = 28000
RmDend = Rm
RmSoma = Rm
RmAx = Rm

Cm    = 1
CmSoma = Cm
CmAx = Cm
CmDend = Cm

RaAll = 150
RaSoma =150  
RaAx = 50
Vrest =-65

forsec "axon" {
	insert pas e_pas=Vrest g_pas = 1/RmAx Ra=RaAx cm=CmAx
}

forsec "soma" {
	insert pas e_pas=Vrest g_pas = 1/RmSoma Ra=RaSoma cm=CmSoma
}

forsec "dendrite" {
	insert pas e_pas=Vrest g_pas = 1/RmDend Ra=RaAll cm=CmDend
}

forsec "user5" {
	insert pas e_pas=Vrest g_pas = 1/RmDend Ra=RaAll cm=CmDend
}


load_file("setnseg.hoc")

access soma
distance()

gna = 0.025
AXONM = 5
gkdr = 0.01
KMULT = 0.03
KMULTP =  0.03
ghd = 0.00005

forsec "axon" {   
	insert nax gbar_nax=gna*AXONM
	insert kdr gkdrbar_kdr=gkdr
	insert kap gkabar_kap=KMULTP
}

forsec "soma" { 
	insert ds
	insert ds2 
	insert hd ghdbar_hd=ghd vhalfl_hd=-73
	insert na3 gbar_na3=gna
	insert kdr gkdrbar_kdr=gkdr
	insert kap gkabar_kap=KMULTP				
}

for i = 0, numbasal - 1 dendrite[i] {
	insert hd ghdbar_hd=ghd vhalfl_hd=-73
	insert na3 gbar_na3=gna
	insert kdr gkdrbar_kdr=gkdr
	insert kap gkabar_kap=0
	insert kad gkabar_kad=0
	for(x) if(x > 0 && x < 1) {
		xdist = distance(x)
		ghdbar_hd(x) = ghd*(1+3*xdist/100)
		if(xdist > 100){
			vhalfl_hd=-81
			gkabar_kad(x) = KMULT*(1+xdist/100)
		} else {
			vhalfl_hd=-73
			gkabar_kap(x) = KMULTP*(1+xdist/100)
		}
	}
}

forsec "apical_dendrite" {
	insert ds
	insert ds2
	insert hd ghdbar_hd=ghd
	insert na3 gbar_na3=gna
	insert kdr gkdrbar_kdr=gkdr
	insert kap gkabar_kap=0
	insert kad gkabar_kad=0
	for(x) if(x > 0 && x < 1) {
		xdist = distance(x)
		ghdbar_hd(x) = ghd*(1+3*xdist/100)
		if(xdist > 100) {
			vhalfl_hd=-81
			gkabar_kad(x) = KMULT*(1+xdist/100)
		} else {
			vhalfl_hd=-73
			gkabar_kap(x) = KMULTP*(1+xdist/100)
		}
	}
}

forsec "user5" {
	insert ds
	insert hd ghdbar_hd=ghd
	insert na3 gbar_na3=gna
	insert kdr gkdrbar_kdr=gkdr
	insert kap gkabar_kap=0
	insert kad gkabar_kad=0

	for(x) if(x > 0 && x < 1) {
		xdist = distance(x)
		ghdbar_hd(x) = ghd*(1+3*xdist/100)
		if(xdist > 100) {
			vhalfl_hd=-81
			gkabar_kad(x) = KMULT*(1+xdist/100)
		} else {
			vhalfl_hd=-73
			gkabar_kap(x) = KMULTP*(1+xdist/100)
		}
	}
}