%------------------------------------------------------------------------------------------
%
% Title: 	Calcium Signals in Small Structures
% Filename:	CaSignal_DtGammaSphere.par
% Author: 	Ronald van Elburg
% 
% Associated Paper:
% Cornelisse LN, van Elburg RAJ, Meredith RM, Yuste R, Mansvelder HD (2007) 
% High Speed Two-Photon Imaging of Calcium Dynamics in Dendritic Spines: 
% Consequences for Spine Calcium Kinetics and Buffer Capacity. 
% PLoS ONE 2(10): e1073 doi:10.1371/journal.pone.0001073
%
%
%
%
%------------------------------------------------------------------------------------------
Structure			= Sphere_Structure % Make it a sphere

% Parameters for mimicking 1 compartmental model
%D_Dye		= 20
%D_Calcium	= 20
%D_EndogenousBuffer 			= 20

path = ".\"   		% If running under Windows, specify here the path to the
                           			% directory containing the script imported below
file = path "CaSignal_main.par"

include file               			% Import the simulation parameters from the main script


% Auxilary variables for monitoring concentrations at different distances from the membrane

	NoOfSteps = 6    % number of shells in the output (NOT IN THE SIMULATION, THERE THE GRIDSIZE DEFINES THE COMPARTMENTS)
	dR=R_Structure/NoOfSteps
	
	R1k=(NoOfSteps-0.5)*dR
	R6k=(NoOfSteps-5.5)*dR
	
	Ca1 := Ca[R1k] ; Dye1 := Dye[R1k] 
	Ca6 := Ca[R6k] ; Dye6 := Dye[R6k] 

	CaAverage:=Ca[] ; DyeAverage:=Dye[]

% Exporting the variables defined above to file

	Exp='DtGamma'			
	LoopVar=10*pulselength
	LoopVar2=-mingamma_0*1000
	Geom='S'


	plot point.mute  Ca1 "Output\Exp""Exp""\CSE""Exp""Geom""_Ca1_""LoopVar""_""LoopVar2"
	plot point.mute  Ca6 "Output\Exp""Exp""\CSE""Exp""Geom""_Ca6_""LoopVar""_""LoopVar2"
	plot point.mute  CaAverage "Output\Exp""Exp""\CSE""Exp""Geom""_CaAverage_""LoopVar""_""LoopVar2"
	
	plot point.mute  Dye1 "Output\Exp""Exp""\CSE""Exp""Geom""_Dye1_""LoopVar""_""LoopVar2"
	plot point.mute  Dye6 "Output\Exp""Exp""\CSE""Exp""Geom""_Dye6_""LoopVar""_""LoopVar2"
	plot point.mute  DyeAverage "Output\Exp""Exp""\CSE""Exp""Geom""_DyeAverage_""LoopVar""_""LoopVar2"

% Parameter variation
	
    for pulselength	 = 0.1 to 4 step 0.1
	for mingamma_0 = -1 to -0.025 step 0.025
	

% The adaptive integration method fails for the fast calcium change
% to overcome this problem we run the first 20 ms with a fixed timestep 
% of 0.001 ms, then after the fast changes we switch to the adaptive method 
% for optimal performance.

Run  20.0  1.0e-3 ; current CalciumCurrent

Run  adaptive 480.0  1.0e-3 accuracy; current CalciumCurrent