summaryrefslogtreecommitdiff
path: root/23/CH14/EX14.9/Example_14_9.sce
blob: 1c4207ed009ecc9b64c07593749c2c970b2a9bb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
clear;
clc;

//To find Approx Value
function[A]=approx(V,n)
  A=round(V*10^n)/10^n;//V-Value  n-To what place
  funcprot(0)
endfunction  

//Example 14.9
//Caption : Program to Prepare a Table of Temperature/Compostion Data
subplot(1,2,1)
P=101.33;//[kPa]
T=[333.15 343.15 348.15 353.15 353.25 363.15 373.15];
P1_sat=[52.22 73.47 86.40 101.05 101.33 136.14 180.04];
P2_sat=[19.92 31.16 38.55 47.36 47.56 70.11 101.33];
P_=P1_sat+P2_sat;
plot(P_,T,'b');

Ans=[T',P1_sat',P2_sat',P_'];
disp(Ans,'     T       P1_sat    P2_sat   P1_sat+P2_sat')
//Hence P lies between T=333.15 and 343.15
P=[101.33 101.33];
Tp=[330.15 343.15];
xgrid();
plot(P,Tp,'r--')

//Thus by interpolation
P=[50.14 104.63];
T_=[342.15 342.15];

plot(P,T_,'g--');

legend('P* vs T','P=101.33kPa','T=342.15K')
xtitle('T vs P1_sat + P2_sat','P1_sat + P2_sat(kPa)','T(K)')

T_=342.15;//[K]

subplot(1,2,2)

plot(P1_sat,T,'b')

//Hence P1_sat @ T=T_=342.15 by interpolation
P=[41 70];
Tp=[342.15 342.15];
xgrid();
plot(P,Tp,'r--')

//Thus by interpolation  P1_sat=71.3kPa
P=[71.3 71.3];
T_=[330.15 342.15];

plot(P,T_,'g--');


legend('P1_sat vs T','T=342.15K','P=71.3kPa')
xtitle('T vs P1_sat','P1_sat(kPa)','T(K)')

P_sat=71.3;
T(1)=342.15;
P=101.33;//[kPa]
P1_sat(1)=P_sat;
P2_sat(1)=P-P_sat;

y_I=approx(P1_sat/P,3);
y_II=approx(1-(P2_sat/P),3);
for(i=1:7)
  if(y_I(i)>1)
    y_I(i)=%nan;
  elseif(y_II(i)>1)
    y_II(i)=%nan;
  end
end

Ans=[T',y_I',y_II'];
disp(Ans,'      T      y1_I      y1_II')     

//End