- #1

Will26040

- 22

- 3

- Summary
- I am trying to create MATLAB code that will find the optimal operating temperature and maximum product concentration in a PFR. I have included my current attempt.

The assignment is to find the optimal operating temperature and maximum product concentration of reactant B, assuming a constant temperature across the PFR length. Please could someone help? thanks

the reaction is a series reaction: A → B → C (liquid phase)

Here is my current code which is providing T as the initial guess value:

function Main

x0 = [100]

OPTIONS = optimoptions('fmincon','Display','iter');

x = fminunc(@fun,x0,OPTIONS)

end

function obj = fun(x)

T = x(1);

Lspan = [0 2]; %reactor 2m long

y0 = [700 0 0];

[L,y] = ode15s(@(L,y) PFR1(L,y,T),Lspan,y0);

obj = -y(end,2)

end

function f = PFR1(L,y,T)

%series reactions Y is the concentrations of species and V PFR volume

Ca= y(1);

Cb= y(2);

Cc= y(3);

%Parameters

R = 8.31; %J.mol-1K-1

u = 0.25; %m.min-1

%rate constants

k1 = (1.37*10^(10))*exp(-75000/R*T); %min-1

k2 = (1.19*10^(17))*exp(-125000/R*T); %min-1

%Reaction Rates

ra = -k1*Ca;

rb = k1*Ca-k2*Cb

rc = k2*Cb;;

%Differential Equations

dCadL = -ra/u;

dCbdL = rb/u;

dCcdL = rc/u;

f = [dCadL; dCbdL; dCcdL]

end

the reaction is a series reaction: A → B → C (liquid phase)

Here is my current code which is providing T as the initial guess value:

function Main

x0 = [100]

OPTIONS = optimoptions('fmincon','Display','iter');

x = fminunc(@fun,x0,OPTIONS)

end

function obj = fun(x)

T = x(1);

Lspan = [0 2]; %reactor 2m long

y0 = [700 0 0];

[L,y] = ode15s(@(L,y) PFR1(L,y,T),Lspan,y0);

obj = -y(end,2)

end

function f = PFR1(L,y,T)

%series reactions Y is the concentrations of species and V PFR volume

Ca= y(1);

Cb= y(2);

Cc= y(3);

%Parameters

R = 8.31; %J.mol-1K-1

u = 0.25; %m.min-1

%rate constants

k1 = (1.37*10^(10))*exp(-75000/R*T); %min-1

k2 = (1.19*10^(17))*exp(-125000/R*T); %min-1

%Reaction Rates

ra = -k1*Ca;

rb = k1*Ca-k2*Cb

rc = k2*Cb;;

%Differential Equations

dCadL = -ra/u;

dCbdL = rb/u;

dCcdL = rc/u;

f = [dCadL; dCbdL; dCcdL]

end