You are on page 1of 10

Simulation and Optimization

Tutorial (2) solutions


Question(1):
Amna Elessaid solution:
In each of the following problems answer the following questions:

solution
1. DoF:
Independent stream variables 13
Independent component balances 4
Independent compositions 7
Streams relations 1
Basis 1
DF 0

2. Selection of independent variables:


Stream Stream 1 Stream 2 Stream 3 Stream 4 No. of
independent
variables
No. ind. 2 1 0 2 5
variables
Selected C1,D1 N2 B4,D4
variable
3. Material balance equations:
For component A:
A1+20=0.75*N2+A4 A1=0.2*((C1+D1)/0.55)) A4=0.5*((B4+D4)/0.95)) Then A
balance: 0.2*((C1+D1)/0.55) +20-0.75*N2-0.5*((B4+D4)/0.95))=0

For component B:
B1+40=0.2*N2+B4 B1=0.25*((C1+D1)/0.55))
Then B balance: 0.25*((C1+D1)/0.55))+40-0.2*N2-B4=0

For component C:
C balance: C1+140-0.05N2=0

For component D:
D balance: D1-D4=0

Stream Relations:
N1=0.3*N3 N1= (C1+D1)/0.55 (C1+D1)/0.55=0.3*200
0.3*(C1+D1)-110=0

4. MATLAB Code function


file:
Script file:

Command window:
Question(2):

Degree of freedom table:

Number of variables 12
Number of independent compositions 5
Relations 1
Splitter relation -
Basis 1
Number of material balance equations
5

DF 0

Selection:

Stream 1 2 3 4 5 6 total
No. 0 2 1 1 1 1 6
selection - S2,W2 N3 N4 N5 N6

Independent equations =6

Mixer:

For S: 310+0.0525*N6-S2=0 For w:

9690+0.9475*N6-W2=0

Reverses osmosis:

For S:

S2-5*10-4*N3-0.0525*N4=0 For w:

W2-0.9995*N3-0.9475*N4=0

Splitter:

For W:

0.9475*N4-0.9475*N5-0.9475*N6=0
Relation:

N6-0.5*N5=0

Code
Function: function f=reverses(x)
S2=x(1);W2=x(2);N3=x(3);N4=x(4);N5=x(5);N6=x(6);
f(1)=N6-0.5*N5;
f(2)= 310+0.0525*N6-S2;
f(3)= -W2+9690+0.9475*N6;
f(4)= S2-0.0525*N4-((5*10^-4)*N3);
f(5)= W2-0.9995*N3-0.9475*N4;
f(6)=0.9475*N4-0.9475*N5-0.9475*N6;
end
Script :
x0=10*ones(1,6);
x =fsolve(@reverses,x0);
xS2=x(1)/(x(1)+x(2));
xW2=x(2)/(x(1)+x(2));
xW4=(x(4)-0.0525*x(4))/x(4);
xW5=(x(5)-0.0525*x(5))/x(5);
xW6=(x(6)-0.0525*x(6))/x(6);
xW3=(x(3)-0.0005*x(3))/x(3);
fprintf('the value of xS2=%7.4f\n',xS2)
fprintf('the value of xW2=%7.4f\n',xW2)
fprintf('the value of xW3=%7.4f\n',xW3)
fprintf('the value of xW4=%7.4f\n',xW4)
fprintf('the value of xW5=%7.4f\n',xW5)
fprintf('the value of xW6=%7.4f\n',xW6)

Answer from command window:

the value of xS2= 0.0359 the value of xW2= 0.9641

the value of xW3= 0.9995 the value of xW4= 0.9475

the value of xW5= 0.9475 the value of xW6= 0.9475

>>
Question(3):
Hadeel Mamoun solutions:

1. Degree of Freedom (DF) Table:

Tower 1 Mixer Tower 2 Process Overall


No. independent
6 6 6 14 10
stream variables
Independent
component 2 2 2 6 2
balances (MB)
Basis 2 1 1 4 4
Independent
2 1 1 4 4
compositions
Relations - - - - -
DF 0 2 2 0 0

The given basis or flow rates:


Flow rate of stream (1) = 200 kg/h
Flow rate of stream (2) = 80 kg/h
Flow rate of stream (4) = 60 kg/h
Flow rate of stream (6) = 60 kg/h

2. Selection of Independent Variables:

Stream 1 2 3 4 5 6 7 Total ind. variables


No. ind. Variables - - 2 - 2 - 2 6
Selected set of ind. Variables - NA3 - NA5 NA7
NB5 - 6
-
NB3 NB7

The total number of independent equations = 6.


The total number of independent variables = 6.

3. Material Balance Equations:

All equations should be written in terms of selected set of independent variables


• Tower 1:

A balance

𝑁𝐴1 = 𝑁𝐴2 + 𝑁𝐴3 , but


𝑁𝐴1 = 0.5𝑁1 ….. 𝑁𝐴1 = 0.5(200) = 100 kg/h
𝑁𝐴2 = 0.9𝑁2 𝑁𝐴2 = 0.9(80) = 72 kg/h
∴ 100 = 72 + 𝑁𝐴3 After rearrangement,
𝑁𝐴3 − 28 = 0 − −1

B balance

𝑁𝐵1 = 𝑁𝐵2 + 𝑁𝐵3 , but


𝑁𝐵1 = 0.5𝑁1 𝑁𝐵1 = 0.5(200) = 100 kg/h
𝑁𝐵2 = 0.1𝑁2 𝑁𝐵2 = 0.1(80) = 8 kg/h
∴ 100 = 8 + 𝑁𝐵3
After rearrangement,
𝑁𝐵3 − 92 = 0 − −2

• Mixer:

A balance
𝑁𝐴3 + 𝑁𝐴4 = 𝑁𝐴5 , but
𝑁𝐴4 = 0.3𝑁4 𝑁𝐴4 = 0.3(60) = 18 kg/h
∴ 𝑁𝐴3 + 18 = 𝑁𝐴5
After rearrangement,
𝑁𝐴3 − 𝑁𝐴5 + 18 = 0 − −3
B balance
𝑁𝐵3 + 𝑁𝐵4 = 𝑁𝐵5 , but
𝑁𝐵4 = 0.7𝑁4 𝑁𝐵4 = 0.7(60) = 42 kg/h
∴ 𝑁𝐵3 + 42 = 𝑁𝐵5
After rearrangement,
𝑁𝐵3 − 𝑁𝐵5 + 42 = 0 − −4

• Tower 2:

A balance

𝑁𝐴5 = 𝑁𝐴6 + 𝑁𝐴7 , but


𝑁𝐴6 = 0.6𝑁6 𝑁𝐴6 = 0.6(60) = 36 kg/h
∴ 𝑁𝐴5 = 36 + 𝑁𝐴7
After rearrangement,
𝑁𝐴5 − 𝑁𝐴7 − 36 = 0 − −5

B balance

𝑁𝐵5 = 𝑁𝐵6 + 𝑁𝐵7 , but


𝑁𝐵6 = 0.4𝑁6  𝑁𝐵6 = 0.4(60) = 24 kg/h
∴ 𝑁𝑏5 = 24 + 𝑁𝑏7
After rearrangement,
𝑁𝐵5 − 𝑁𝐵7 − 24 = 0 − −6

4. MATLAB Code:

Let the code symbols be as follows


A3=NA3 B3=NB3 A5=NA5 B5=NB5 A7=NA7 B7=NB7

Rewriting the equations gives:

𝐴3 − 28 = 0 − −1
𝐵3 − 92 = 0 − −2
𝐴3 − A5 + 18 = 0 − −3 𝐵3 − B5
+ 42 = 0 − −4
𝐴5 − A7 − 36 = 0 − −5
𝐵5 − B7 − 24 = 0 − −6

Function M-File:
% This is a function that return the values of flow rates in three
streams in terms of A3,B2,A5, B5,A7 and B7
function f=HW_2(x)
%Define indep. set of variables
A3=x(1);
B3=x(2);
A5=x(3);
B5=x(4);
A7=x(5);
B7=x(6);

%Define the indep. set of equations in terms of indep. set of


variables
f(1)=A3-28;
f(2)=B3-92;
f(3)=A3-A5+18;
f(4)=B3-B5+42;
f(5)=A5-A7-36;
f(6)=B5-B7-24;
end

Script M-File:
% Define intial guess
x0=10*ones(1,6);
x=fsolve(@HW_2,x0);

%Define the indep. set of variables


A3=x(1);
B3=x(2);
A5=x(3);
B5=x(4);
A7=x(5);
B7=x(6);

%Define the relations of the total flow rate in streams 3,5, and 7
N3= A3+B3;
N5=A5+B5;
N7=A7+B7;
%Define the relation to find the compositions of A and B in streams 3,5, and
7
Comp_A3=(A3/N3)*100;
Comp_B3=(B3/N3)*100;
Comp_A5=(A5/N5)*100;
Comp_B5=(B5/N5)*100;
Comp_A7=(A7/N7)*100;
Comp_B7=(B7/N7)*100;
fprintf('The compositions (Percent) of stream 3 are: A= %2.2f and B=
%2.2f \n',Comp_A3,Comp_B3)
fprintf('The compositions (Percent) of stream 5 are: A= %2.2f and B=
%2.2f \n',Comp_A5,Comp_B5)
fprintf('The compositions (Percent) of stream 7 are: A= %2.2f and B=
%2.2f \n',Comp_A7,Comp_B7)

From command window:


The compositions (Percent) of stream 3 are A= 23.33 and B= 76.67
The compositions (Percent) of stream 5 are A= 25.56 and B= 74.44
The compositions (Percent) of stream 7 are A= 8.33 and B= 91.67

You might also like