Multiple ODE's that are coupled

1 次查看(过去 30 天)
Rick
Rick 2014-11-2
编辑: Rick 2014-11-2
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')

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by