first order reversible reaction in batch reactor
August 07, 2011 at 06:56 PM | categories: odes | View Comments
first order reversible reaction in batch reactor
John Kitchin
Contents
Problem statement
forward rate law:
backward rate law:
this example illustrates a set of coupled first order ODES
function main
clc; clear all; close all; u = cmu.units; %note that using units makes this m-file run pretty slowly tspan = [0 5]*u.min; init = [1 0]*u.mol/u.L; [t,C] = ode45(@myode,tspan,init);
plot the solution
plot(t/u.min,C/(u.mol/u.L)) xlabel('Time (min)') ylabel('Concentration (mol/L)') legend C_A C_B
you need this to make the plot appear in the right place above when published. It appears you need a final cell with an output to avoid having the plot showup at the end of the published document.
disp('end')
end
function dCdt = myode(t,C) % ra = -k1*Ca % rb = -k_1*Cb % net rate for production of A: ra - rb % net rate for production of B: -ra + rb u = cmu.units; k1 = 1/u.min; k_1 = 0.5/u.min; Ca = C(1); Cb = C(2); ra = -k1*Ca; rb = -k_1*Cb; dCadt = ra - rb; dCbdt = -ra + rb; dCdt = [dCadt; dCbdt]; % categories: ODEs % tags: reaction engineering % post_id = 706; %delete this line to force new post;