Error using function and driver ODE15s: "too many input arguments"
Mostrar comentarios más antiguos
I am continuing to get the error:
Error using reactions3_2
Too many input arguments.
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 148)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in CSTRcoking (line 9)
[X,R] = ode15s(@reactions3_2,xspan,[nf_o, 0]);
Here is my function I am calling:
%function for reaction inputs
function [r] = reactions3_2(nf)
T_star = 500+273;
T = 550+273; %K
P = 1.013; %atm
%kinetic parameters
k1 = 24.5; %molCH2*g_cat^-1*h^-1*(mol_M/mol)^-2*atm^-2
k2 = 1.2*10^-5; %molCH2*g_cat^-1*h^-1(mol_M/mol)^-1*atm^-1
k3 = 1.9*10^-5; %molCH2*g_cat^-1*h^-1(mol_D/mol)^-1*atm^-1
k4 = 0.199; %molCH2*g_cat^-1*h^-1(mol_C/mol)^-1*atm^-1
k5 = 88.3; %molCH2*g_cat^-1*h^-1(mol_M*mol_O/mol^2)^-1*atm^-1
k6 = 331; %molCH2*g_cat^-1*h^-1(mol_D*mol_O/mol^2)^-1*atm^-1
k7 = 342; %molCH2*g_cat^-1*h^-1(mol_B*mol_O/mol^2)^-1*atm^-1
k8 = 228; %molCH2*g_cat^-1*h^-1(mol_P*mol_O/mol^2)^-1*atm^-1
k9 = 0.072; %molCH2*g_cat^-1*h^-1(mol_G/mol)^-1*atm^-1
k10 = 35.5; %molCH2*g_cat^-1*h^-1(mol_O/mol)^-2*atm^-2
k11 = 111; %molCH2*g_cat^-1*h^-1(mol_O/mol)^-2*atm^-2
k12 = 10.8; %molCH2*g_cat^-1*h^-1(mol_M*mol_O/mol^2)^-1*atm^-1
k13 = 60.2; %molCH2*g_cat^-1*h^-1(mol_D*mol_O/mol^2)^-1*atm^-1
E = [54.4, 4.6, 186, 111, 4.44, 53.6, 14.1, 56.5, 25.0, 4.35, 5.02, 16.2, 36.4];
k_star = [k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12, k13];
R = 0.008314;
k = [];
for i=1:length(k_star)
k(i) = k_star(i)*exp((-E(i)/R)*(1/T-1/T_star));
end
K = 2*exp(-9.76 + 3200*(1/T) + 1.07*log10(T) - (0.66*10^-3)*T + (0.49*10^-7)*T^2 + 6500*(1/T^2));
%Unpacked inputs, initial guesses
%ntotal = nf(1)+nf(2)+nf(3)+nf(4)+nf(5)+nf(6)+nf(7)+nf(8)+nf(9);
Pm = nf(1)*P;
Pd = nf(2)*P;
Pw = nf(3)*P;
Po = nf(4)*P;
Pb = nf(5)*P;
Pp = nf(6)*P;
Pg = nf(7)*P;
Pc = nf(8)*P;
C = nf(9); %coking level
%with coking
kco = 0.15; %coking rate constant
alpha = 7.0;
alphac = 3.3;
kc = kco*(1-alphac*C); %coking rate constant
for i=1:length(k)
k(i) = k;
k(i) = k(i)*(1-alpha*C); %new kinetic parameters with coking
end
%Reaction network
%rm = -k(1)*Pm^2 + ((k(1)/K)*Pd*Pw) - k(2)*Pm -k(4)*Pm - k(5)*Pm*Po - k(12)*Pm*Po;
%rw = -k(1)*Pm^2 + ((k(1)/K)*Pd*Pw);
%rd = k(1)*Pm^2 - ((k(1)/K)*Pd*Pw) - k(3)*Pd - k(4)*Pd - k(6)*Pd*Po - k(13)*Pd*Po;
%rb = -k(7)*Pb*Po + k(10)*Po^2;
%ro = k(2)*Pm + k(3)*Pd + k(5)*Pm*Po + k(6)*Pd*Po + k(7)*Pb*Po + k(8)*Pp*Po + k(9)*Pg - (k(10)+k(11))*Po^2 - k(12)*Pm*Po - k(13)*Pd*Po;
%rp = -k(8)*Pp*Po + k(11)*Po^2;
%rg = -k(9)*Pg + 2*k(12)*Pm*Po + 2*k(13)*Pd*Po;
%rc = k(4)*Pm + k4*Pd;
r=zeros(9,1);
%Reaction network [rm,rw,rd,rb,ro,rp,rg,rc]
r(1,1) = -k(1)*Pm^2/P^2 + ((k(1)/K)*Pd*Pw)/P^2 - k(2)*Pm/P -k(4)*Pm/P - k(5)*Pm*Po/P^2 - k(12)*Pm*Po/P^2;
r(2,1) = k(1)*Pm^2/P^2 - ((k(1)/K)*Pd*Pw)/P^2;
r(3,1) = k(1)*Pm^2/P^2 - ((k(1)/K)*Pd*Pw)/P^2 - k(3)*Pd/P - k(4)*Pd/P - k(6)*Pd*Po/P^2 - k(13)*Pd*Po/P^2;
r(4,1) = -k(7)*Pb*Po/P^2 + k(10)*Po^2/P^2;
r(5,1) = k(2)*Pm/P + k(3)*Pd/P + k(5)*Pm*Po/P^2 + k(6)*Pd*Po/P^2 + k(7)*Pb*Po/P^2 + k(8)*Pp*Po/P^2 + k(9)*Pg/P - (k(10)+k(11))*Po^2/P^2 - k(12)*Pm*Po/P^2 - k(13)*Pd*Po/P^2;
r(6,1) = -k(8)*Pp*Po/P^2 + k(11)*Po^2/P^2;
r(7,1) = -k(9)*Pg/P + 2*k(12)*Pm*Po/P^2 +2*k(13)*Pd*Po/P^2;
r(8,1) = k(4)*Pm/P + k(4)*Pd/P;
r(9,1) = -kc*(r(1,1)+r(3,1));
end
And here is my driver:
%CSTR with coking
clear all
clc
xspan = [0,1];
nf_o = [0.016471267595876, 3.256503613255994e-05, -0.011582869410074,...
0.545395213451505, 0.051392380787462, 0.162462564673423,...
0.214757302695374, 0.009488705759425];
[X,R] = ode15s(@reactions3_2,xspan,[nf_o, 0]);
M = R(:,1);
W = R(:,2);
D = R(:,3);
B = R(:,4);
O = R(:,5);
P = R(:,6);
G = R(:,7);
C = R(:,8);
coke = R(:,9);
plot(X,M,'k',X,D,'m',X,O,'c',X,B+P,'r',X,G,'y')
I thought that I had enough input arguments since I have 9 equations with my r's and 9 initial guesses into my function with the nf terms.
Any ideas to get rid of this error and make this thing work would be extremely appreciated!
Thanks,
knesh
Respuestas (2)
Categorías
Más información sobre Historical Contests en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!