Monday 10 November 2014

Matlab Program to design Distillation column by shortcut and rigorous method

1 Function definition for the function psat() for calculating saturation temperature by using Antonie equation :

function[prhex,prhept,proct]=psat(t)
    hexa=13.8193;hexb=2696.04;hexc=-48.833;
    hepta=13.8622;heptb=2910.26;heptc=-56.718;
    octa=13.9346;octb=3123.13;octc=-63.515;
    prhex=exp(hexa-((hexb/(t+hexc))));
    prhept=exp(hepta-((heptb/(t+heptc))));
    proct=exp(octa-((octb/(t+octc))));
end

2 The main body of the programme where the function psat() has been called is:
  xihex=input('enter the composition of hexane');
    xihept=input('enter the composition of heptane');
    xioct=input('enter the composition of octane');
    pt=input('enter the total pressure');
    mlkd=(0.98*xihex)/((0.98*xihex)+(0.01*xihept));
    disp('the mole fraction of hexane in distillate is');
disp(mlkd);
mhkd=(0.01*xihept)/((0.98*xihex)+(0.01*xihept));
disp('the composition of heptane in distillate is:');
disp(mhkd);
moctd=0;
mlfrhex=((0.02*xihex)/((0.02*xihex)+(0.99*xihept)+(1*xioct)));
mlfrhept=((0.99*xihept)/((0.02*xihex)+(0.99*xihept)+(1*xioct)));
mlfroct=((1*xioct)/((0.02*xihex)+(0.99*xihept)+(1*xioct)));
    for t=250:0.1:423
            [p,q,r]=psat(t);
            kihex1=p/pt;
            kihept1=q/pt;
            kioct1=r/pt;
            sumkixi=(kihex1*mlkd)+(kihept1*mhkd)+(kioct1*moctd);
            if(sumkixi>0.99 && sumkixi<1)
                disp('temp of condenser')
                disp(t)
                break
            end
    end
    disp('the value of equilibrium constant of light key at bubble point is:');
    disp(kihex1);
    disp('the value of equilibrium constant of heavy key at bubble point is:');
    disp(kihept1);
    for temp=250:0.1:573
        [a,b,c]=psat(temp);
            kihex=a/pt;
            kihept=b/pt;
            kioct=c/pt;
            sumy=(mlfrhex/kihex)+(mlfrhept/kihept)+(mlfroct/kioct);
        if(sumy>0.99 && sumy<1)
            disp('temp of reboiler')
            disp(temp)
            break
        end
    end
alpha=kihex1/kihept1;
disp('the value of relative volatility is');
disp(alpha);

s=mlkd+mhkd+moctd;
disp('now the minimum number of stages by Fenske equation is calculated');

sum=mlfrhex+mlfrhept+mlfroct;
nmin=(log(((mlkd/mhkd)/(mlfrhex/mlfrhept)))/log(alpha))-1;
disp('the minimum number of trays required are')
disp(nmin)
disp('minimum number of stages including reboiler are')
nminn=nmin+1;
disp(nminn)
disp('now the calculation of minimum reflux by undrewood method is done:')
alpha1=kihex1/kihept1;
alpha2=kihept1/kihept1;
alpha3=kioct1/kihept1;
for phi=alpha2:0.01:alpha1
   sumf=((alpha1*xihex)/(alpha1-phi))+((alpha2*xihept)/(alpha2-phi))+((alpha3*xioct)/(alpha3-phi));
   if(sumf>-0.1&sumf<0.2)
       disp('the value of phi is')
       disp(phi)
       break;
   end;
end;
disp('the moles of all the four components in distillate are calculated below by simple material balnce calculations:')
summoles=(0.98*xihex*100)+(0.01*xihept*100)
disp('the total moles in distillate are')
disp(summoles)
sumrd=(((alpha1*mlkd)/(alpha1-phi))+((alpha2*mhkd)/(alpha2-phi))+((alpha3*moctd)/(alpha3-phi)))-1;
disp('minimum reflux ratio is')
disp(sumrd);
disp('now the calculations will be done on the basis of Gilliland corelations for claculating actual number of stages')
disp('actual reflux ration is taken as 1.5 times the minimum reflux ratio')
rd=1.5*sumrd;
x=(rd-sumrd)/(rd+1);
y=1-exp(((1+(54.4*x))/(11+(117.2*x)))*((x-1)/(x.^0.5)));
n=round((y+nminn)/(1-y));
disp('required number of stages are')
disp(n)
mlbottom=(0.02*xihex*100)+(0.99*xihept*100)+(1*xioct*100);
rationrns=[(xihept/xihex)*((mlfrhex/mhkd)^2)*(mlbottom/summoles)]^0.206;
ns=round((rationrns/(rationrns+1))*n);
nr=n-ns;
disp('stages in stripping section')
disp(ns);
disp('stages in rectifying section')
disp(nr);
for i=340:0.1:450
    [x,y,z]=psat(i);
    khex=x/pt;
    khept=y/pt;
    koct=z/pt;
    summation=(khex*mlfrhex)+(khept*mlfrhept)+(koct*mlfroct);
    if(summation>0.99 && summation<1)
        ftemp=i;
        disp('temp and composition and at tray 1 is')
        disp(ftemp)
        break
    end
end
v=(summoles)*(rd+1)
l=summoles*rd
lbar=l+100
yhex1=(x/pt)*mlfrhex;
yhept1=(y/pt)*mlfrhept;
yoct1=(z/pt)*mlfroct;
x1=(yhex1+(mlbottom/v)*mlfrhex)/(lbar/v);
x2=(yhept1+(mlbottom/v)*mlfrhept)/(lbar/v);
x3=(yoct1+(mlbottom/v)*mlfroct)/(lbar/v);
k=[yhex1,yhept1,yoct1,x1,x2,x3];
disp(k);
nt=n;
for i=2:1:nt
    if(i~=2)
        x1=xnewhex;
        x2=xnewhept;
        x3=xnewoct;
    end
    xbnrhex=x1/(x1+x2+x3);
    xbnrhept=x2/(x1+x2+x3);
    xbnroct=x3/(x1+x2+x3); 
    for j=250:0.1:450
    [x,y,z]=psat(j);
    khex=x/pt;
    khept=y/pt;
    koct=z/pt;
    summation=(khex*xbnrhex)+(khept*xbnrhept)+(koct*xbnroct);
    if(summation>0.99 && summation<1)
        ftemp=j;
        disp('temp and composition at tray'); disp(i); disp('is');
        disp(ftemp)
        break
    end
    end
   
    yhex1=(x/pt)*xbnrhex;
    yhept1=(y/pt)*xbnrhept;
    yoct1=(z/pt)*xbnroct;
xnewhex=(yhex1+((mlbottom/v)*mlfrhex))/(lbar/v);
xnewhept=(yhept1+((mlbottom/v)*mlfrhept))/(lbar/v);
xnewoct=(yoct1+((mlbottom/v)*mlfroct))/(lbar/v);
t=[yhex1,yhept1,yoct1,xnewhex,xnewhept,xnewoct];
disp(t);
    if(i==ns)
    disp('the feed plate location is');
    disp(ns);
    nf=i+1;
    for j=250:0.1:450
    [x,y,z]=psat(j);
    khex=x/pt;
    khept=y/pt;
    koct=z/pt;
    summation=(khex*xnewhex)+(khept*xnewhept)+(koct*xnewoct);
    if(summation>0.99 && summation<1)
        yhex1=(x/pt)*xnewhex;
    yhept1=(y/pt)*xnewhept;
    yoct1=(z/pt)*xnewoct;
        break
    end
    end
    break
    end
end
for i=nf:1:n
    if(i~=nf)
       yhex1=ynewhex;
       yhept1=ynewhept;
       yoct1=ynewoct;
    end
    xhexr=(yhex1-(mlkd/(rd+1)))/(rd/(rd+1));
    xheptr=(yhept1-(mhkd/(rd+1)))/(rd/(rd+1));
    xoctr=(yoct1-(moctd/(rd+1)))/(rd/(rd+1));
    xnrhex=xhexr/(xhexr+xheptr+xoctr);
    xnrhept=xheptr/(xhexr+xheptr+xoctr);
    xnroct=xoctr/(xhexr+xheptr+xoctr);
    for j=150:0.1:450
    [x,y,z]=psat(j);
    khex=x/pt;
    khept=y/pt;
    koct=z/pt;
    summation=(khex*xnrhex)+(khept*xnrhept)+(koct*xnroct);
    if(summation>0.99 && summation<1)
        ftemp=j;
        disp('temp and composition at tray'); disp(i); disp('is');
        disp(ftemp)
        break
    end
    end
    ynewhex=(x/pt)*xnrhex;      
    ynewhept=(y/pt)*xnrhept;
    ynewoct=(z/pt)*xnroct;
    w=[ynewhex,ynewhept,ynewoct,xnrhex,xnrhept,xnroct];
    disp(w);

end
coded by: Ravisha Goswami, Mamta Nainwal & group; Chemical Batch 2010-14, BTKIT Dwarahat

1 comment:

  1. Hi, What kind of rigurous method are you using in your code?

    ReplyDelete