% solve differential equation
% for isothermal batch reactor
% using ode45
k = 14.7 ; % 1/(mol/L)/min
Ca0 = 0.0209 ; % mol/L
Cb0 = Ca0/3 ;
tspan = 0:0.1:20 ;
batchanon = @(t,Ca) batch(t,Ca,k,Ca0,Cb0);
[ t,Ca_soln ] = ode45(batchanon,tspan,Ca0);
Cb_soln = Cb0 - (Ca0-Ca_soln);
Cc_soln = Ca0-Ca_soln;
plot(t,Ca_soln,'b',t,Cb_soln,'m',t,Cc_soln,'g')
grid
xlabel('Time - minutes')
ylabel('Concentration - mol/L')
title('Batch Reactor Simulation')
legend('Ca','Cb','Cc')

