Home > other >  Matlab to draw the residual curve, the great god, please help to see how do you solve this error
Matlab to draw the residual curve, the great god, please help to see how do you solve this error

Time:09-15

Zibian1. M
% Isobutene (1) Methanol MTBE (2) (3)
The function xdot=zibian1 (t, x, flag)
If isempty (flag),
T=x (4);
% the Universal gas constant (CAL/mol) (K) 8.314472 J/(k. mol)
R=1.987;
P=8 * (1.013 * 1 e + 5);
% Wilson model binary interaction parameters binary interaction parameters of Wilson model
A (1, 1)=0;
A (1, 2)=169.9953;
A (1, 3)=30.2477;
A (2, 1)=2576.8532;
A (2, 2)=0.
A (2, 3)=1483.2478;
A (3, 1)=271.5669;
A (3, 2)=406.3902;
A (3, 3)=0;
% molar volumes (cm3/mol)
V (1)=93.33;
V (2)=44.44;
V (3)=118.8;

A (1, 1)=1;
A (2, 1)=V (1)/V (2) * exp (- A (2, 1)/(R * T));
(1) A (3, 1)=V/V (3) * exp (A (3, 1)/(R * T));

A (2, 2)=1;
(2) A (1, 2)=V/V (1) * exp (- A (1, 2)/(R * T));
(2) A (3, 2)=V/V (3) * exp (A (3, 2)/(R * T));

A (3, 3)=1;
(3) A (2, 3)=V/V (2) * exp (- (2, 3)/A (R * T));
(3) A (1, 3)=V/V (1) * exp (- A (1, 3)/(R * T));

% the Activity coefficients Activity coefficient
G (1)=exp (1 - x (1) * A (1, 1)/(x (1) * A (1, 1) + x (2) * A (1, 2) + x (3) * A (1, 3))...
- x (2) * A (2, 1)/(x (1) * A (2, 1) + x (2) * A (2, 2) + x (3) * A (2, 3))...
- x (3) * A (3, 1)/(x (1) * A (3, 1) + x (2) * A (3, 2) + x (3) * A (3, 3)))...
/(x (1) * A (1, 1) + x (2) * A (1, 2) + x (3) * A (1, 3));

G (2)=exp (1 - x (1) * A (1, 2)/(x (1) * A (1, 1) + x (2) * A (1, 2) + x (3) * A (1, 3))...
- x (2) * A (2, 2)/(x (1) * A (2, 1) + x (2) * A (2, 2) + x (3) * A (2, 3))...
- x (3) * A (3, 2)/(x (1) * A (3, 1) + x (2) * A (3, 2) + x (3) * A (3, 3)))...
/(x (1) * A (2, 1) + x (2) * A (2, 2) + x (3) * A (2, 3));

G (3)=exp (1 - x (1) * A (1, 3)/(x (1) * A (1, 1) + x (2) * A (1, 2) + x (3) * A (1, 3))...
- x (2) * A (2, 3)/(x (1) * A (2, 1) + x (2) * A (2, 2) + x (3) * A (2, 3))...
- x (3) * A (3, 3)/(x (1) * A (3, 1) + x (2) * A (3, 2) + x (3) * A (3, 3)))...
/(x (1) * A (3, 1) + x (2) * A (3, 2) + x (3) * A (3, 3));

% Vapor pressure using Antoine 's Equation
A (1)=20.64559; A (2)=23.49989; A (3)=20.71616;
B (1)=2125.74886; B (2)=3643.31362; B (3)=2571.58460;
C (1)=33.160; C (2)=33.434; C (3)=48.406;

(Psat) (1)=exp (A (1) + B (1)/(T + C (1)));
(Psat), (2)=exp (A (2) + B (2)/(T + C (2)));
(Psat) (3)=exp (A (3) + B (3)/(T + C (3)));

% Equilibrium constant for the reaction of isobutene + methanol==MTBE isobutylene + methanol MTBE reaction Equilibrium constant of the

Keq=exp (10.0982 + 0.2667 + 4254.05/T * log (T));

% Modified Raoults Law

(1)=y (Psat) G (1) (1) * * x (1)/P;

(2)=y (Psat), (2) (2) * G * x (2)/P;

(3)=y (Psat) (3) * G (3) * x (3)/P;

RR=x (1) * G * x (1) (2) * (2)/G (Keq * x (3) * G (3));
V=[1, 1, 1];
Kf=74.4 * exp (- 3187/T);
Kfref=74.4 * exp (3187/333.35);

Da=0;

Xdot (1) (1) - (1) y=x + kf/kfref * (v (1) - the sum (v) * x (1)) * Da * RR.
Xdot (2) (2) - (2) y=x + kf/kfref * (v (2) - the sum (v) * x (2)) * Da * RR.
Xdot (3) (3) - (3) y=x + kf/kfref * (v (3) - the sum (v) * x (3)) * Da * RR.
Xdot (4)=x (1) + x (2) + x (3) - 1;

Xdot % xdot=xdot 'must be a column vector

The else

% Return M the mass matirx Return mass matrix
M=zeros (4, 4);
M (1, 1)=1;
M (2, 2)=1;
M (3, 3)=1;

Xdot=M;
End

Zibian2. M
% Isobutene (1) Methanol MTBE (2) (3)
The function xdot=zibian2 (t, x, flag)
If isempty (flag),
T=x (4);
% the Universal gas constant (CAL/mol) (K) 8.314472 J/(k. mol)
R=1.987;
P=8 * (1.013 * 1 e + 5);
% Wilson model binary interaction parameters binary interaction parameters of Wilson model
A (1, 1)=0;
A (1, 2)=169.9953;
A (1, 3)=30.2477;
A (2, 1)=2576.8532;
A (2, 2)=0.
A (2, 3)=1483.2478;
A (3, 1)=271.5669;
A (3, 2)=406.3902;
A (3, 3)=0;
% molar volumes (cm3/mol)
V (1)=93.33;
V (2)=44.44;
V (3)=118.8;

A (1, 1)=1;
A (2, 1)=V (1)/V (2) * exp (- A (2, 1)/(R * T));
(1) A (3, 1)=V/V (3) * exp (A (3, 1)/(R * T));

A (2, 2)=1;
(2) A (1, 2)=V/V (1) * exp (- A (1, 2)/(R * T));
(2) A (3, 2)=V/V (3) * exp (A (3, 2)/(R * T));

A (3, 3)=1;
(3) A (2, 3)=V/V (2) * exp (- (2, 3)/A (R * T));
(3) A (1, 3)=V/V (1) * exp (- A (1, 3)/(R * T));

% the Activity coefficients Activity coefficient
G (1)=exp (1 - x (1) * A (1, 1)/(x (1) * A (1, 1) + x (2) * A (1, 2) + x (3) * A (1, 3))...
- x (2) * A (2, 1)/(x (1) * A (2, 1) + x (2) * A (2, 2) + x (3) * A (2, 3))...
- x (3) * A (3, 1)/(x (1) * A (3, 1) + x (2) * A (3, 2) + x (3) * A (3, 3)))...
/(x (1) * A (1, 1) + x (2) * A (1, 2) + x (3) * A (1, 3));

G (2)=exp (1 - x (1) * A (1, 2)/(x (1) * A (1, 1) + x (2) * A (1, 2) + x (3) * A (1, 3))...
- x (2) * A (2, 2)/(x (1) * A (2, 1) + x (2) * A (2, 2) + x (3) * A (2, 3))...
- x (3) * A (3, 2)/(x (1) * A (3, 1) + x (2) * A (3, 2) + x (3) * A (3, 3)))...
/(x (1) * A (2, 1) + x (2) * A (2, 2) + x (3) * A (2, 3));

G (3)=exp (1 - x (1) * A (1, 3)/(x (1) * A (1, 1) + x (2) * A (1, 2) + x (3) * A (1, 3))...
- x (2) * A (2, 3)/(x (1) * A (2, 1) + x (2) * A (2, 2) + x (3) * A (2, 3))...
- x (3) * A (3, 3)/(x (1) * A (3, 1) + x (2) * A (3, 2) + x (3) * A (3, 3)))...
/(x (1) * A (3, 1) + x (2) * A (3, 2) + x (3) * A (3, 3));

% Vapor pressure using Antoine 's Equation
A (1)=20.64559; A (2)=23.49989; A (3)=20.71616;
B (1)=2125.74886; B (2)=3643.31362; B (3)=2571.58460;
C (1)=33.160; C (2)=33.434; C (3)=48.406;

(Psat) (1)=exp (A (1) + B (1)/(T + C (1)));
(Psat), (2)=exp (A (2) + B (2)/(T + C (2)));
(Psat) (3)=exp (A (3) + B (3)/(T + C (3)));

% Equilibrium constant for the reaction of isobutene + methanol==MTBE isobutylene + methanol MTBE reaction Equilibrium constant of the

Keq=exp (10.0982 + 0.2667 + 4254.05/T * log (T));
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related