1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Sep 9, 2015 #1

    Maylis

    User Avatar
    Gold Member

    1. The problem statement, all variables and given/known data
    My question is regarding part (e), I just gave all the questions for reference.
    upload_2015-9-9_17-47-26.png

    2. Relevant equations


    3. 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 (Text):

    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/L


    A = [-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 (Text):

    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 (Text):

    [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: Sep 9, 2015
  2. jcsd
  3. Sep 10, 2015 #2

    DrClaude

    User Avatar

    Staff: Mentor

    There is a problem with your definition of the ODE function:
    Code (Matlab M):

    function G = parte(t,x,u)
     
    It has to be of the form
    Code (Matlab M):

    function G = parte(t,x)
     
     
  4. Sep 10, 2015 #3

    Maylis

    User Avatar
    Gold Member

    I decided to solve these explicitly rather than try the matrix formulation, so now I got it
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: ODE 45 with coupled ODE's in a matrix, reactor temp.
  1. RL Circuit ODE (Replies: 11)

Loading...