# Multiple ODE's that are coupled

6 views (last 30 days)
Rick on 2 Nov 2014
Edited: Rick on 2 Nov 2014
Hello,
I attached a PDF of the coupled ODE's that I am trying to solve. I can make a function that runs, but I don't get the same output as the PDF for my graphs, what is going wrong?? The reaction rate plot is clearly wrong
function dz = semibatch(t,z)
k = 2.2;
V0 = 5;
v0 = 0.05;
V = @(t) V0 + v0*t;
CB0 = 0.025;
CA0 = 0.05;
dz = zeros(4,1);
dz(1) = -k*z(1).*z(2) - (v0.*z(1)./V(t));
dz(2) = -k*z(1).*z(2) + ((CB0-z(2)).*v0./V(t));
dz(3) = k*z(1).*z(2) - (v0*z(3)./V(t));
dz(4) = k*z(1).*z(2) - (v0*z(4)./V(t));
end
This is what is in my script file,
CA0 = 0.05;
CB0 = 0.025;
k = 2.2;
v0 = 0.05;
V0 = 5;
V = @(t) V0 + v0*t;
[T,Z] = ode45(@semibatch,[0 500],[CA0, CB0, 0, 0]);
plot(T,Z(:,1),T,Z(:,2),T,Z(:,3))
xlabel('time')
ylabel('C_{i}')
legend('C_{A}','C_{B}','C_{C}')
X = [];
rA = [];
for i = 1:size(Z,1)
X(i) = (CA0*V0 - Z(i,1)*V(T(i)))/(CA0*V0);
rA(i) = -k*Z(i,1)*Z(i,2);
end
figure
subplot(1,2,1)
plot(T,X)
xlabel('time')
ylabel('conversion')
subplot(1,2,2)
plot(T,rA)
xlabel('time')
ylabel('reaction rate')