#D.P.Dougherty 2010
#Model of mouse ORN
#The XPP file is configured to demonstrate the slow transduction
#current generated during a prolonged odorant presentation


#Alphabetically sorted listing of all model parameters (descriptions given below).
 
param cap=0.0035
param cc1lin=2.6
param cc2=40.231
param ck1lin=40
param ck2=2.412
param clmax=0.8294
param cnmax=3.6417
param ef=7.832
param gl=15.4267
param hmc1=1.5965
param hmc2=7.6415
param inf=1.4654
param inhmax=0.98
param k1=2.2748
param k2lin=42.0896
param kI=16.5304
param kinh=1.3875
param kinhcng=0.2242
param n1=5.6384
param n2=3.4161
param ninh=8.4067
param ninhcng=0.6306
param pd=7.3132
param r1=9.4574
param r2=12.5485
param smax=63.0987
param vcl=-7.3248
param vcng=0.4641
param vl=-69.6653


#cap	  #Capacitance of ORN ciliary membrane# nF 										   
#cc1lin   #Rate at which Ca2+ associates with CaM to form CaCaM # s^-1							   
#cc2	  #Rate at which CaCaM dissociates to Ca2+ and CaM # s^-1 							   
#ck1lin   #Rate at which CaCaM activates CaMK	# s^-1								   
#ck2	  #Rate at which active CaMK deactivates # s^-1										   
#clmax    #Maximal conductance of ANO2 Cl(Ca) channels # nS								   
#cnmax    #Maximal conductance of CNG channels # nS							   
#ef	  #Maximum calcium efflux (assumed sodium & potassium independent) #s^-1				   
#gl	  #Maximum leak (generic) conductance # nS									   
#hmc1	  #Concentration of cAMP needed to achieve half-maximal activation (K1/2) of the CNG channel # uM						   
#hmc2	  #Concentration of Ca2+ needed to achieve half-maximal activation (K1/2) of the Cl(Ca) channel| # uM							   
#inf	  #Net calcium inward flux via CNG channel # uM*pC^-1								   
#inhmax   #Maximum inhibition of CNG by CaCAM # unitless								   
#k1	  #Receptor affinity for ligand # (um*s)^-1								   
#k2lin    #Rate of G-protein activation per bound receptor complex  # s^-1						   
#kinh	  #Concentration of aCaMK needed for half-maximal inhibition (IC50) of cAMP production # uM							   
#kinhcng  #Concentration of CaCaM needed for half-maximal inhibition of the CNG channel # uM							   
#n1	  #Hill coefficient of the CNG channel activation function #	unitless						   
#n2	  #Hill coefficient of the Cl(Ca) channel activation function	# unitless							   
#ninh	  #Steepness of the decreasing sigmoid representing aCaMK-mediated inhibition of cAMP synthesis	 # unitless					   
#ninhcng  #Steepness of the sigmoid inhcng representing inhibition of CNG channel by CaCaM # unitless				   
#pd	  #Rate at which a cAMP molecule is degraded by phosphodiesterase # s^-1									   
#r1	  #Rate of unbinding of odorant from receptor	 # s^-1								   
#r2	  #Rate at which a G-protein becomes deactivate rate # s^-1								   
#smax	  #Maximal (uninhibited) rate of cAMP production by adenylyl cyclase per active G-protein # uM*s^-1						   
#vcl	  #Reversal potential of Cl(Ca) channels  # mV							   
#vcng	  #Reversal potential of CNG channels # mV								   
#vl	  #Effective reversal potential for leak current # mV 							   


 
#Below here are non-physiological parameters related to the experimental design: 
 
#Micromolar concentration of odorant at full concentration
param ostim=100 
#Sharpness of odorant plume          
param SHARPNESS=0.0001    

%hv defines a "heaviside-like" pulse but with adjustable steepness parameter.  
%Use this to describe a smeared odorant plume reaching the neuron.

hv(x,s)=1/(1+exp(-x/s))
PULSE(t)=(hv(t-1,SHARPNESS) - hv(t-60,SHARPNESS))			   			   
OD(t) = ostim*PULSE(t)

#The vertebrate ORN model has 3 compartments i) Cilia, ii) Dendrite, and iii) Soma.


#### Cilia Compartment ####
dbLR/dt       = k1*OD(t)*(1-bLR)-r1*bLR
daG/dt        = k2lin*bLR*(1-aG) - r2*aG
dcAMP/dt      = (aG*smax)/(1 + ((CAMK/kinh)^ninh)) - pd*cAMP
dCa/dt        = inf*Icng(cAMP,Vcilia) - ef*Ca + (-cc1lin*Ca + cc2*CaCAM)
dCaCAM/dt     = cc1lin*Ca - cc2*CaCAM
dCAMK/dt      = ck1lin*CaCAM - ck2*CAMK
dVcilia/dt    = (1/cap)*(Icng(cAMP,Vcilia) + Icacl(Ca,Vcilia) + Il(Vcilia))

inhcng(CaCAM) = 1+(inhmax-1)*((CaCAM^ninhcng)/(CaCAM^ninhcng + kinhcng^ninhcng))

#Current models:
Icng(cAMP,Vcilia) = ((cnmax*cAMP^n1)/(cAMP^n1 + (inhcng(CaCAM)*hmc1)^n1))*(vcng-Vcilia)
Icacl(Ca,Vcilia)  = ((clmax*Ca^n2)/(Ca^n2 + hmc2^n2))*(vcl-Vcilia)
Il(Vcilia)     = gl*(vl-Vcilia)


#These auxilliary functions simply model what is actually measured by suction pipette recording
#from whole cell.

aux Icilia = -(Icng(cAMP,Vcilia) + Icacl(Ca,Vcilia))
aux WholeCell = -(Icng(cAMP,Vcilia) + Icacl(Ca,Vcilia))
aux Odorant = 100*PULSE(t)

#The number 100 is used above simply to give the pulses a nice magnitude when plotted in the 
#same axes as the currrents.  A double y-axis is not possible in XPP apparently.

#Initial conditions.  Note that we actually run the model to steady-state in the absence 
#of odorant for a second before simulation of the experiment. See T0 option below.

init bLR=1.e-6
init aG=1.e-6
init cAMP=1.e-6
init Ca=1.e-6
init CaCAM=1.e-6
init CAMK=1.e-6
init Vcilia=-70

@ BUT=RunModel:ig,BUT=FitAxes:wf,MAXSTOR=8000000
@ meth=cvode,T0=-1,DT=0.0001,DTMIN=0.0001, DTMAX=2,NOUT=100000
@ TOTAL=60.0,BOUND=100000,XLO=0,XHI=60,YLO=-300,YHI=110
@ NPLOT=2,YP=WholeCell,YP2=Odorant

done