summaryrefslogtreecommitdiff
path: root/249/CH18/EX18.5/18_05.sce
blob: deab73fbb3825d37aa3b3d35e6ba3dec8a7be7de (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
clear
clc
CAo=0.1;
eA=3;
rA=[3.4;5.4;7.6;9.1];
CA=[0.039;0.0575;0.075;0.092];
XA=zeros(4,1);
inv_rA=zeros(4,1);
for i=1:4
XA(i)=(1-CA(i)/CAo)/(1+eA*CA(i)/CAo);
inv_rA(i)=1/rA(i);
end
//W=FAo*integral(dXA/-rA) from 0 to 0.35
//Using Trapezoidal rule to find area,XA must be in increasing order
//Sorting XA and accordingly inv_rA
for i=1:4
    small=XA(i);
    for j=i:4
        next=XA(j);
        if small>next
            temp=XA(i);
            XA(i)=XA(j);
            XA(j)=temp;
            temp1=inv_rA(i);
            inv_rA(i)=inv_rA(j);
            inv_rA(j)=temp1;
        end
    end
end
plot(XA,inv_rA)
xlabel('XA');ylabel('-1/rA');
//extending points to include XA=0.35
XA(5)=0.35;inv_rA(5)=0.34;
Area=inttrap(XA,inv_rA);
W=Area*2000;
printf("Amount of catalyst needed(kg) is %f",W)
disp('The answer slightly differs from those given in book as trapezoidal rule is used for calculating area')