% Copyright (C) 2001, James B. Rawlings and John G. Ekerdt
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
% published by the Free Software Foundation; either version 2, or (at
% your option) any later version.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; see the file COPYING. If not, write to
% the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
% MA 02111-1307, USA.
k1 = 1;
k_1 = 1/2;
k2 = 10;
k_2 = 10;
c_A0 = 1;
c_B0 = 0.4;
c_C0 = 0;
% nscheme: 0 full model, 1 1st is rls, 2 2nd is rls; 3 qssa on B
nscheme = 0;
if (nscheme == 0)
% IC for full model
x0 = [c_A0; c_B0; c_C0];
elseif (nscheme == 1)
% IC for rx 1 is rls
K2 = k2/k_2;
x0 = [c_A0; 1/(1+K2)*(c_B0+c_C0); K2/(1+K2)*(c_B0+c_C0)];
elseif (nscheme == 2)
% IC for rx 2 is rls
K1 = k1/k_1;
x0 = [1/(1+K1)*(c_A0+c_B0); K1/(1+K1)*(c_A0+c_B0); c_C0];
elseif (nscheme == 3)
% IC for QSSA model
x0 = [c_A0; k1/(k_1+k2)*c_A0 + k_2/(k_1+k2)*c_C0; c_C0];
else
error ('nscheme out of range');
end
p = struct(); % Create structure to pass parameters to ode15s function
p.k1 = k1;
p.k_1 = k_1;
p.k2 = k2;
p.k_2 = k_2;
p.nscheme = nscheme;
tfinal = 5;
ntimes = 200;
tout = linspace(0, tfinal, ntimes)';
opts = odeset ('AbsTol', sqrt (eps), 'RelTol', sqrt (eps));
[tsolver, x] = ode15s (@(t,x) rhs(t,x,p), tout, x0, opts);
% compute RA RB RC production rates
RA = -k1*x(:,1) + k_1*x(:,2);
RC = k2*x(:,2) - k_2*x(:,3);
RB = -RA - RC;
table = [tout x RA RB RC];
save -ascii rls_2.dat table;
if (~ strcmp (getenv ('OMIT_PLOTS'), 'true')) % PLOTTING
plot (table(:,1),table(:,2:4));
% TITLE
end % PLOTTING