% MorrisLecar0 - Morris Lecar RHS for special case Iapp=0
%
% Parameters taken from simulator online at
%     http://math.jccc.edu:8180/webMathematica/JSP/mmartin/morlecar.jsp
% See also
%    https://en.wikipedia.org/wiki/Morris%E2%80%93Lecar_model
%    http://www.scholarpedia.org/article/Morris-Lecar_model

% (c) 2014-11-22 Philip D Loewen

function ydot = MorrisLecar0(t,y)

C    =  20;      % Capacitance

g_L  =   2;      % Conductance  --  Leakage
g_Ca =   4.4;    % Conductance  --  Calcium
g_K  =   8;      % Conductance  --  Potassium

V_L  = -50;      % Equilibrium potential  -- Leakage
V_Ca = 100;      % Equilibrium potential  -- Calcium
V_K  = -70;      % Equilibrium potential  -- Potassium

V1   =  -1;      % Fitting parameter
V2   =  15;      % Fitting parameter
V3   =   0;      % Fitting parameter
V4   =  30;      % Fitting parameter

phi  =   0.04;   % Reference frequency

tau = @(v) 1/phi/cosh((v-V3)/2/V4);
Nss = @(v) 0.5*(1+tanh((v-V3)/V4));
Mss = @(v) 0.5*(1+tanh((v-V1)/V2));


V = y(1);
N = y(2);

dN  = (Nss(V)-N)/tau(V);
CdV = -g_L*(V-V_L) - g_Ca * Mss(V) * (V - V_Ca) - g_K*N*(V-V_K);

ydot = [CdV/C; dN];
