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

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

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

Tau1	= 3.5093	
Tau2	= 436.9
SynWeight = 0.40323

// ------------------
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 Exp2NMDA(.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, 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()

load_file("MRF-EXP3NMDA-VD.ses")