ODE 45 with coupled ODE's in a matrix, reactor temp.

In summary: Ti = 300; % KCAi = 40; % mol/LCPi = 0; % mol/L[T4,Y4] = ode45(@parte,[0 10],[Ti CAi CPi]);subplot(1,2,1)plot(T4,[Y4(:,2),Y4(:,3)])xlabel('time (minutes)')ylabel('Concentration (lb mol/ft^{3})')legend('A','P','location','best')title('Concentration vs. time')And here is my output[T4,Y4]
  • #1
gfd43tg
Gold Member
950
50

Homework Statement


My question is regarding part (e), I just gave all the questions for reference.
upload_2015-9-9_17-47-26.png


Homework Equations

The Attempt at a Solution


These are the coupled equations I should solve (from part d)
upload_2015-9-9_17-50-15.png

My issue is using ode45 to get ##C_{A}(t)##, ##C_{P}(t)##, and ##T(t)##. Here is my m-file

Code:
function G = parte(t,x,u)

V = 150; % L
k = 0.02; % L/mol*min
beta = 0.15; % kJ L^.5 / mol^.5 min
DeltaH = -15; % kJ/mol A
rho = 4.2; % kg/L
cp = 1.2; % kJ/kg K

u = zeros(3,1);
u(1) = 1.4; % L/min
u(2) = 300; % K
u(3) = 40; % mol/LA = [-u(1)/V, u(1)*DeltaH/(rho*V*cp), beta/(2*rho*V*cp)*x(3)^(-0.5);
  0, -(u(1)/V) -2*k*x(2), 0;
  0, 2*k*x(2), -u(1)/V];

B = [(u(2)-x(1))/V + (x(2)-u(3))*DeltaH/(rho*V*cp), u(1)/V, -u(1)*DeltaH/(rho*V*cp);
  (u(3)-x(2))/V, 0, u(1)/V;
  -x(3)/V, 0, 0];

G = A*x + B*u;

end

Then I run it on my script
Code:
Ti = 300; % K
CAi = 40; % mol/L
CPi = 0; % mol/L
[T4,Y4] = ode45(@parte,[0 10],[Ti CAi CPi]);
subplot(1,2,1)
plot(T4,[Y4(:,2),Y4(:,3)])
xlabel('time (minutes)')
ylabel('Concentration (lb mol/ft^{3})')
legend('A','P','location','best')
title('Concentration vs. time')

And here is my output
Code:
[T4,Y4]

ans =

  0  300.0000  40.0000  0
  0.2500  NaN  NaN  NaN
  0.5000  NaN  NaN  NaN
  0.7500  NaN  NaN  NaN
  1.0000  NaN  NaN  NaN
  1.2500  NaN  NaN  NaN
  1.5000  NaN  NaN  NaN
  1.7500  NaN  NaN  NaN
  2.0000  NaN  NaN  NaN
  2.2500  NaN  NaN  NaN
  2.5000  NaN  NaN  NaN
  2.7500  NaN  NaN  NaN
  3.0000  NaN  NaN  NaN
  3.2500  NaN  NaN  NaN
  3.5000  NaN  NaN  NaN
  3.7500  NaN  NaN  NaN
  4.0000  NaN  NaN  NaN
  4.2500  NaN  NaN  NaN
  4.5000  NaN  NaN  NaN
  4.7500  NaN  NaN  NaN
  5.0000  NaN  NaN  NaN
  5.2500  NaN  NaN  NaN
  5.5000  NaN  NaN  NaN
  5.7500  NaN  NaN  NaN
  6.0000  NaN  NaN  NaN
  6.2500  NaN  NaN  NaN
  6.5000  NaN  NaN  NaN
  6.7500  NaN  NaN  NaN
  7.0000  NaN  NaN  NaN
  7.2500  NaN  NaN  NaN
  7.5000  NaN  NaN  NaN
  7.7500  NaN  NaN  NaN
  8.0000  NaN  NaN  NaN
  8.2500  NaN  NaN  NaN
  8.5000  NaN  NaN  NaN
  8.7500  NaN  NaN  NaN
  9.0000  NaN  NaN  NaN
  9.2500  NaN  NaN  NaN
  9.5000  NaN  NaN  NaN
  9.7500  NaN  NaN  NaN
  10.0000  NaN  NaN  NaN

I am not sure how to do this thing with the matrix format. I thought I set up my equations correctly, but can't figure out why it won't output correctly. I should note that the ##\sqrt {C_{P}}## is the concentration of P, whereas ##c_{p}## is a constant, in case that is confusing to anyone.
 
Last edited:
Physics news on Phys.org
  • #2
There is a problem with your definition of the ODE function:
Matlab:
function G = parte(t,x,u)
It has to be of the form
Matlab:
function G = parte(t,x)
 
  • #3
I decided to solve these explicitly rather than try the matrix formulation, so now I got it
 

1. What is ODE 45?

ODE 45 is a numerical integration algorithm used to solve ordinary differential equations (ODEs) in the form of first-order differential equations. It is a widely used method for accurate and efficient solutions to ODEs.

2. What are coupled ODEs?

Coupled ODEs refer to a system of ODEs that are interdependent on each other. This means that the solution of one ODE affects the solution of the others in the system. ODE 45 can handle coupled ODEs by solving them simultaneously.

3. How does ODE 45 work?

ODE 45 uses a variable time-step formula to approximate the solution of the ODEs. It starts with an initial condition, calculates the derivative at that point, and then uses the derivative to estimate the solution at the next time step. This process is repeated until the desired solution is reached.

4. What is a matrix in the context of ODE 45?

In ODE 45, a matrix represents the system of coupled ODEs. Each row of the matrix corresponds to one ODE, and the columns represent the different variables or parameters involved in the equations. The matrix is used to organize and solve the system of ODEs simultaneously.

5. How can ODE 45 be applied to reactor temperature?

ODE 45 can be used to model the temperature changes in a reactor over time. The ODEs would represent the heat transfer, cooling, and other factors affecting the reactor's temperature. By solving these equations simultaneously, ODE 45 can provide a time-dependent solution for the reactor temperature.

Similar threads

  • Programming and Computer Science
Replies
4
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Programming and Computer Science
Replies
6
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
6K
  • Astronomy and Astrophysics
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
6K
  • Programming and Computer Science
Replies
2
Views
4K
  • Biology and Chemistry Homework Help
Replies
3
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
773
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
13K
Back
Top