Routine Name:   setupNaCa

Description:    Allocates and fills tabcurrent tables with the values needed
                to implement the Na-Ca exchanger pump.

Usage:          setupNaCa tabcurrent-element gamma Celcius Cain Caout \
                     Nain Naout -xsize n -xrange min max -ysize n \
                     -yrange min max

                tabcurrent-element  This must have been created from a
                                    tabcurrent object.

                gamma               Parameter representing the fractional
                                    position of the energy barrier within the
                                    membrane, usually taken to be 0.38.

                Celsius             Temperature in degrees Celsius.

                Cain                Ca concentration inside the compartment.
                Caout               Ca concentration outside the cell.
                Nain                Na concentration inside the compartment.
                Naout               Na concentration outside the cell.

                -xsize xdivs        Number of divisions for the x variable
                                    of the tabcurrent I_tab and G_tab tables.

                -xrange min max     Minimum and maximum values of the x
                                    variable for the I_tab and G_tab tables.

                -ysize ydivs        Number of divisions for the y variable
                                    of the tabcurrent I_tab and G_tab tables.

                -yrange min max     Minimum and maximum values of the y
                                    variable for the I_tab and G_tab tables.
                
Example:

// Assume there is a parent compartment, and a Ca_concen element Ca_conc
create tabcurrent NaCa
setfield NaCa Gindex {VOLT_C1_INDEX}
setfield NaCa Gbar {1.4e-5*compt_area} // kCaNa = 1.4e-5 Amp/(mM^4)/m^2
setupNaCa NaCa 0.38 37 0 2.4 10 125 -xsize 100 -xrange -0.1 0.05 \
    -ysize 100 -yrange 0 0.300

addmsg .. NaCa VOLTAGE Vm
addmsg Ca_conc CONCEN1 Ca
addmsg NaCa .. CHANNEL Gk Ek

Notes:

The setupNaCa routine fills the I_tab table of a tabcurrent element with
values of

 Cain*Naout^3 * exp((gamma-1)*V*F/(R*T)) - Caout*Nain^3 *exp(gamma*V*F/(R*T))

where F is the Faraday constant (9.6487e4 coul/mol), R is the gas constant
(8.314 volts*coul/(deg K * mol)), and T = Celsius + 273.15.  The G_tab table
is filled with values of -dI_tab/dV, to give the slope conductance Gk when
it is scaled by Gbar.  The concentrations should be given in mM (millimoles
per liter =  moles/m^3).

When the tabcurrent Gbar is set to the compartment area times the constant
kNaCa, this results in the expression for the Na+ - Ca2+ exchanger pump
current given by Equation (6.11) in De Schutter E., and Smolen P., "Calcium
dynamics in large neuronal models", in Methods in neuronal modeling: From ions
to networks (2nd edition), C. Koch and I. Segev editors, pp. 211-250 (1998).

This is similar to the expression used for a similar electrogenic current in
DiFrancesco, D., and Noble, D., "A model of cardiac electrical activity
incorporating ionic pumps and concentration changes", Phil. Trans. Roy. Soc.
London Ser. B 307: 353-398 (1985).

When setting the concentration parameters, either Cain or Caout (but not both)
should be set to zero.  The one that is set to zero is expected to be
delivered to the tabcurrent element with a CONCEN1 or CONCEN2 message.  In
almost every case, this will be Cain, as it will vary much more than the Ca
concentration outside the cell.  The tabcurrent Gindex field should be set to
VOLT_C1_INDEX if the Ca concentration is delivered with a CONCEN1 message, and
VOLT_C2_INDEX if it is delivered with a CONCEN2 message.  The voltage V should
be provided by a VOLTAGE message from the compartment that contains the
tabcurrent element.

The -xsize and -ysize parameters give the number of divisions in the tables,
with the first index (corresponding to voltage) running from 0 to xdivs and
the second one (corresponding to Ca concentration) from 0 to ydivs.

See also:       tabcurrent, setupghk
