%------------------------------------------------------------------------------------------
%
% Title: 	Calcium Signals in Small Structures
% Filename:	CaSignal_Exp8GbDisc.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			= Disc_Structure
%

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

% Fluorescent Dye
	buffer DiffusableEndogenousBuffer                     				% Create diffusable Endogenous Buffer : Parvalbumin
	DiffusableEndogenousBuffer.D    = 0.043  								% diffusable Endogenous Buffer diffusion coefficient (um^2/ms)
	
	DiffusableEndogenousBuffer.total =Total_DiffusableEndogenousBuffer							% Total diffusable Endogenous Buffer concentration (uM)

	% Binding/Unbinding Rate Constants
	DiffusableEndogenousBuffer.kplus = 0.019								% diffusable Endogenous Buffer calcium binding rate (1/(ms uM))
	DiffusableEndogenousBuffer.KD = 0.0514								% diffusable Endogenous Buffer calcium affinity (uM)
        	
	% Boundary Conditions
	DiffusableEndogenousBuffer.bc all Neumann								% No flux of diffusable Endogenous Buffer through the boundary


% 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
	
	CaBoundary:=Ca[R_Source]
	Ca1 := Ca[R1k] ; Dye1 := Dye[R1k] 	; BndDye1 := Total_Dye-Dye[R1k] 	;EndoB1 := EndogenousBuffer	[R1k]
	Ca6 := Ca[R6k] ; Dye6 := Dye[R6k] 	; BndDye6 := Total_Dye-Dye[R6k] 	;EndoB6 := EndogenousBuffer	[R6k]
	CaAverage:=Ca[] ; DyeAverage:=Dye[] ; BndDyeAverage:=Total_Dye-Dye[] 	;EndoBAverage := EndogenousBuffer	[]



% Exporting the variables defined above to file, the first three variables need 
% adjustment defining new scripts, to prevent these scripts from overwriting old 
% results and using the wrong Loop variables, make sure that the LoopVars are 
% integer version of the real loopvars used in for loops.
 
	Exp='B8Gb'			
	LoopVar=Total_DiffusableEndogenousBuffer
	Geom='D' 

	plot point.mute  CaBoundary "Output\Exp""Exp""\CSE""Exp""Geom""_CaBoundary_""LoopVar"

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

	plot point.mute  BndDye1 "Output\Exp""Exp""\CSE""Exp""Geom""_BndDye1_""LoopVar"
	plot point.mute  BndDye6 "Output\Exp""Exp""\CSE""Exp""Geom""_BndDye6_""LoopVar"
	plot point.mute  BndDyeAverage "Output\Exp""Exp""\CSE""Exp""Geom""_BndDyeAverage_""LoopVar"
	
	plot point.mute  EndoB1 "Output\Exp""Exp""\CSE""Exp""Geom""_EndoB1_""LoopVar"
	plot point.mute  EndoB6 "Output\Exp""Exp""\CSE""Exp""Geom""_EndoB6_""LoopVar"
	plot point.mute  EndoBAverage "Output\Exp""Exp""\CSE""Exp""Geom""_EndoBAverage_""LoopVar"

% Parameter variation
	
	for Total_DiffusableEndogenousBuffer  = 0 to 200 step 40

% 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