Jump to content



Featured Articles

Check out the latest featured articles.

File Library

Check out the latest downloads available in the File Library.

New Article

Product Viscosity vs. Shear

Featured File

Vertical Tank Selection

New Blog Entry

Low Flow in Pipes- posted in Ankur's blog

Using Euler's Method To Make A Plot Of Pa Vs Time For A Reaction

eulers matlab

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic
Share this topic:
| More

#1 limonade

limonade

    Brand New Member

  • Members
  • 1 posts

Posted 09 April 2014 - 10:31 PM

Hi there. 


I am trying to use MATLAB to make a plot of PA vs time for the problem ( see picture #1)



I am able to get a component balance in terms of conversion, but when I integrate and use MATLAB to plot the conversion vs time I get the result = infinity for conversion. I do not know what is going wrong with my code. 


I have attached the problem statement, my work on how I arrived at the equations, and my MATLAB code. 

I am really really stuck here and would appreciate any help...




The code is here

clear all
clc

k = 1*10^-3; 
KA = 10;
W = 0.1;
T = 400;
P = 100;
yA0 = 0.5;
yB0 = 0.5;
NA0 = .5       % Assuming a basis of 1 mol to start
Ptot = 100;
PA0 = 50;
V = 100,000; %cm3
R = 8.314*10^3 %units cm3 kPA K-1mol-1
i = 1; % initial array index
x(i) = 0; % dimensionless, initial conversion
t(i) = 0; % s, initial time
dt = 0.5; % s, step size
trxn = 5000; % s, final time

while t(i) <= trxn
dxdt = W*k*((PA0*(1-x)).^2)/(1+KA*(PA0*(1-x))*(PA0*V/R*T));
x(i+1) = x(i) + dxdt * dt
t(i+1) = t(i) + dt;
i = i+1; % increment array index
end

plot(t,x)
tt = sprintf('Conversion vs. time, X is %4.4f at trxn = %4.2f', max(x),trxn)
title(tt)
ylabel('X'), xlabel('time (s)')
axis([0 ceil(max(t)) 0 1])
max(x)

modify_inline.gif

 

Attached Files

  • Attached File  1.PNG   472KB   2 downloads
  • Attached File  3.PNG   701.5KB   2 downloads
  • Attached File  2.PNG   410.23KB   2 downloads





Similar Topics