/* In this experiment I'm going to test my voltage dependent NMDA model
Its voltage dependent block provided by Mg and happens fast
Its slow unblock provided by a voltage dependent gating particle
I'm going to fit my model to the Wild Type NMDAR recordings obtained from 
Dendrites of CA1-CA3 Neurons Reported in Spruston95
*/
load_file("nrngui.hoc")
load_file("params.hoc")

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

tstop = 522
dt = .025
celsius = 18	//room temperature
v_init = 40

Tau1	= 1.4731
Tau2	= 391.64
SynWeight = 0.22903

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

objref sNMDA, stim, nc
stim = new NetStim(.5)
	stim.interval = 20	//ms (mean) time between spikes
	stim.number = 1	//(average) number of spikes
	stim.start 	= 9	//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 Exp3NMDA(.5)
nc = new NetCon(stim, sNMDA)

proc init_NMDA() {
	sNMDA.tau1	= Tau1	
    sNMDA.tau2	= Tau2	

	nc.weight = SynWeight
	nc.delay = 1
}
objref FinNMDA
FinNMDA = new FInitializeHandler(3,"init_NMDA()")
	
objref vc
vc = new VClamp(.5)
	vc.dur[0] = 56.5
	vc.amp[0] = 40
	vc.dur[1] = 48.5
	vc.amp[1] = -80
	vc.dur[2] = 500
	vc.amp[2] = 40
	
// objref iNMDA, vSoma
// iNMDA = new Graph()
// iNMDA.size(0,tstop,-.1,1)
// 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")			// displays max amplitude at soma, dend(273)
	// xvalue("Tau1")			// dend(750) when the simulation is over
	// xvalue("Tau2")
	// xvalue("SynWeight")
	// xbutton("InitRun()")
// xpanel(500,500)
// proc InitRun() {
// init()
// run()
// }

load_file("MRF-EXP3NMDA-VD.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()