Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

MSO PRACTICAL NO.

5
GURUNATH EPILI PROGRAM:
60011120011

clc;
ka1=307.527;
//equilibrium constant k1
ka2=0.019196; //equilibrium constant k2
P=20;
// bar
i=1;
for r=3:100;
x1=0.5; x2=0.5;
disp(r,'Recovery=');
X=[x1;x2];
disp(X,'X=')

//steam to methane ratio

f1=ka1*(r-x1-x2)*(1-x1)*((r+1+2*x1)^2)-(x1x2)*((3*x1+x2)^3)*(P^2); //function 1
f2=ka2*(x1-x2)*(r-x1-x2)-x2*(3*x1+x2); //function 2
f=[f1;f2]; //Function matrix
df1dx1=ka1*(4*(r-x1-x2)*(1-x1)*(r+1+2*x1)((r+1+2*x1)^2)*(r+1-2*x1-x2))-(P^2)*(9*(x1x2)*((3*x1+x2)^2)+((3*x1+x2)^3)); //derivative of f1 w.r.t. x1
df1dx2=-ka1*(1-x1)*((r+1+2*x1)^2)-(P^2)*(3*(x1x2)*((3*x1+x2)^2)-((3*x1+x2)^3));
//derivative of f2 w.r.t. x2
df2dx1=ka2*(r-2*x1)-3*x2;
//derivative
of f2 w.r.t. x1
df2dx2=-ka2*(r-2*x2)-(3*x1+2*x2);
//derivative of f2 w.r.t. x2
df=[df1dx1,df1dx2;df2dx1,df2dx2]; //Jacobian matrix
disp(f,'f=');
disp(df,'df=');
dx=-1*((df)^(-1))*f;
Xnew=X+dx;
disp(Xnew,'Xnew=')
E=0.001;

//error limit

disp(E,'E=');
disp(i,'Iteration=');
while abs(E(1,1))>0.0001

X=Xnew;
x1=X(1,1);
x2=X(2,1);
f1=ka1*(r-x1-x2)*(1-x1)*((r+1+2*x1)^2)-(x1x2)*((3*x1+x2)^3)*(P^2); //function 1
f2=ka2*(x1-x2)*(r-x1-x2)-x2*(3*x1+x2); //function 2
df1dx1=ka1*(4*(r-x1-x2)*(1-x1)*(r+1+2*x1)((r+1+2*x1)^2)*(r+1-2*x1-x2))-(P^2)*(9*(x1x2)*((3*x1+x2)^2)+((3*x1+x2)^3));
df1dx2=-ka1*(1-x1)*((r+1+2*x1)^2)-(P^2)*(3*(x1x2)*((3*x1+x2)^2)-((3*x1+x2)^3));
df2dx1=ka2*(r-2*x1)-3*x2;
df2dx2=-ka2*(r-2*x2)-(3*x1+2*x2);
df=[df1dx1,df1dx2;df2dx1,df2dx2];
f=[f1;f2];
dx=-1*((df)^(-1))*f;

//Formula

Xnew=X+dx; //New values


E=Xnew-X;
disp(f,'f=');
disp(df,'df=');
disp(E,'E=');
disp(Xnew,'Xnew=');
end
X1(i)=x1;
X2(i)=x2;
R(i)=r;
i=i+1;
end

plot(R,X1,'red');
plot(R,X2,'blue');
ylabel('Conversion,X');
xlabel('Recovery,R')
legend('R v/s X1','R v/s X2');
xtitle('Recovery v/s Conversion');

output:
Recovery=

df= - 41651.218 - 1843.0987


- 0.0140339 - 2.469729
Xnew=

0.7950851
0.0137006

Recovery= 4
df= - 69426.266 - 1704.0585
- 0.0143990 - 2.7017637
Xnew=

0.8623324
0.0193602

Recovery=
df=

- 106439.35 - 1478.589
- 0.0140310 - 2.8605228

Xnew=

0.9051099
0.0250877

Recovery=
df=

- 154730.49 - 1228.0057
- 0.0131029 - 2.9742293

[ JACOBIAN MATRIX ]

Xnew=

0.9328645
0.0308215

You might also like