/* In this experiment desensitization of NMDAR is going to be tested
*/
load_file("nrngui.hoc")
load_file("params.hoc")

//fully activates cache efficiency
cvode.cache_efficient(1)  

tstop = 1747.875
dt = .025
celsius = 23	//room temperature in Erreger05 experiment
v_init = 40

SynWeight = 0.9242
D = 0.2
Tau_D = 2500

Tau1 = 1.0327
Tau2_0 = 25.057
Tau3_0 = 232.27
A2 = 2.2364
A3 = 43.495

// ------------------
create soma
access soma

objref sNMDA, stim, nc
stim = new NetStim(.5)
	stim.interval = 195	//ms (mean) time between spikes
	stim.number = 6	//(average) number of spikes
	stim.start 	= 88.69	//ms (most likely) start time of first spike
	stim.noise 	= 0		//---- range 0 to 1. Fractional randomness.
	//0 deterministic, 1 intervals have negexp distribution.
sNMDA = new Exp5NMDA2(.5)
nc = new NetCon(stim, sNMDA)

proc init_NMDA() {
	sNMDA.d = D
	sNMDA.tau_D = Tau_D
	
	sNMDA.tau1 = Tau1
	sNMDA.a2 = A2
	sNMDA.tau2_0 = Tau2_0
	sNMDA.a3 = A3
	sNMDA.tau3_0 = Tau3_0
	
	nc.weight = SynWeight
	nc.delay = 1
}
objref FinNMDA
FinNMDA = new FInitializeHandler(3,"init_NMDA()")
	
//----------------------------------------------------	
objref vc, vscr, tvec

vscr = new Vector(12)
tvec = new Vector(12)

vc = new VClamp(.5)
	vc.dur[0] = tstop
	vc.amp[0] = -60

// objref iNMDA, vSoma
// iNMDA = new Graph()
// iNMDA.size(0,tstop,-6,0)
// iNMDA.addvar("sNMDA.i",3,0)
// iNMDA.save_name("graphList[0].")
// graphList[0].append(iNMDA)

// vSoma = new Graph()
// vSoma.size(0,tstop,-100,50)
// vSoma.addvar("soma.v(.5)",3,0)
// vSoma.save_name("graphList[0].")
// graphList[0].append(vSoma)

// xpanel("PSP amplitudes")
	// xvalue("D1")
	// xvalue("Tau_D1")
	// xvalue("SynWeight")
	// xbutton("InitRun()")
// xpanel(500,500)

// proc InitRun() {
// init()
// run()
// }

load_file("MRF-Desen-5Hz.ses")

// objref iNMDA, iFile, time, tFile
// iNMDA = new Vector()
// iNMDA.record(&sNMDA.i)
// iFile = new File("iFile.dat")
// iFile.wopen("iFile.dat")

// time = new Vector()
// time.record(&t)
// tFile = new File("tFile.dat")
// tFile.wopen("tFile.dat")

// init()
// run()

// iNMDA.printf(iFile)
// iFile.close()

// time.printf(tFile)
// tFile.close()