//
// Demo
// by Michele Giugliano, 7/8/2018 Trieste
//

load_file("nrngui.hoc")                   // Loading of the standard GUI controls...
load_file("graphs.hoc")            // Loading some ad-hoc proc for displaying live traces...

print "Demonstration of the ChR2-H134R model under voltage-clamp"
print "from:"
print "Williams JC, Xu J, Lu Z, Klimas A, Chen X, et al. (2013) Computational Optogenetics: Empirically-Derived Voltage- and Light-Sensitive Channelrhodopsin- 2 Model."
print "PLoS Comput Biol 9(9): e1003220. doi:10.1371/journal.pcbi.1003220"
print ""
print "Original (MATLAB) code by: John C. Williams"
print "Implemented by: Michele Giugliano, SISSA Trieste, 6/8/2018, mgiugliano@gmail.com"

celsius = 22 

objref vc1, vc2, vc3

create soma1
access soma1
insert ChR2
light_delay_ChR2 = 10.
pulse_width_ChR2 = 500.
insert pas
vc1 = new VClamp(0.5)
vc1.dur[0] = 10000.

create soma2
access soma2
insert ChR2
light_delay_ChR2 = 10.
pulse_width_ChR2 = 500.
insert pas
vc2 = new VClamp(0.5)
vc2.dur[0] = 10000.

create soma3
access soma3
insert ChR2
light_delay_ChR2 = 10.
pulse_width_ChR2 = 500.
insert pas
vc3 = new VClamp(0.5)
vc3.dur[0] = 10000.

print "Figure 2B"
// Figure 2B
access soma1
light_intensity_ChR2 = 5.5
vc1.amp[0] = -20.

access soma2
light_intensity_ChR2 = 0.34
vc2.amp[0] = -80.

access soma3
light_intensity_ChR2 = 5.5
vc3.amp[0] = -80.

t = 0. 							// ms - initial simulation time
tstart = 0. 					// ms - initial simulation time
tstop = 600 					// ms - final simulation time

addgraph("soma1.i_ChR2(0.5)", -.03, 0)
g[0].addvar("soma2.i_ChR2(0.5)", -2, 0)
g[0].addvar("soma3.i_ChR2(0.5)", -2, 0)
run()