Matlab_code_for_Binary_Distillation

download Matlab_code_for_Binary_Distillation

of 9

Transcript of Matlab_code_for_Binary_Distillation

  • 8/7/2019 Matlab_code_for_Binary_Distillation

    1/9

    Assignment 01

    Process Modeling and

    Simulation

    Name:K.S.M.S.Senarath

    Index No: 050418H

    Date of Sub: 02.02.2009

  • 8/7/2019 Matlab_code_for_Binary_Distillation

    2/9

    01.Pendulum ProblemMomentum equation of a pendulum is given as below when initial faorce of

    the pendulum is zero.

    In Matlab code I took angle as y(1) and angular velocity as y(2).

    Code in Pendulum M-File

    function dydt=pendulum(t,y)g=9.81; % Gravitational Accelaration (ms-2)

    M=3; % Mass of the rod (kg)

    I=12; % Inertia (kgm2)

    R=sqrt(2*I/M); % Radius (m)

    f1=y(2);

    f2=-M*g*R*sin(y(1))/I

    dydt=[f1;f2];

    Code in Command Window

    >> y0=[pi/3,0];

    >> tspan=[0,10];

    >> [t,y]=ode45(@pendulum,tspan,y0);

    >> plot(t,y)

    >> xlabel('Time\it (S)')

    >> grid

    >>legend('\it Angular Acceleration','\it Angular

    Velocity')

  • 8/7/2019 Matlab_code_for_Binary_Distillation

    3/9

    Obtained Graph for Angular acceleration and angular Velocity

    0 1 2 3 4 5 6 7 8 9 10-2

    -1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    2

    Time (S)

    Angular Accelaration

    Angular Velocity

  • 8/7/2019 Matlab_code_for_Binary_Distillation

    4/9

    02.Temperature Variation in Plates of Binary Distillation TowerThis binary distillation tower distills Benzene and Toluene. Below equation

    will be used for construct the MatLab model.

    For the total mass balance of the system

    F = W + D

    Composition Mass Balance

    F.XF= W.XW + D.XD

    Equation of Top Operating Line

    Equation of q Line

    Where

    F Feed Rate (kmol/hr)

    X- Liquid composition of Benzene

    Y- Gas Composition of Benzene

    D Distilled product (kmol/hr)

    D, XD

    V, XD

    F, XF

    Lo

    W, XW

  • 8/7/2019 Matlab_code_for_Binary_Distillation

    5/9

    W - Bottom Product (kmol/hr)

    In M-File

    %-------------K.S.M.S.Senarath----------------%

    %--------------------------050418H----------------------%

    clear all

    %--Liquid & Gas composition data for Benzene & Toluene--%

    X= [0.000 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800

    0.900 0.950 1.000];

    %Composition of liquid (Benzene)

    Y= [0.000 0.208 0.372 0.507 0.612 0.713 0.791 0.857 0.912

    0.959 0.980 1.000];

    %Composition of gas (Benzene)

    T= [110 105.3 101.5 98.0 95.1 92.3 89.7 87.3 85.0 82.7

    81.4 80.1];

    %Boiling points of mixtures

    %--------Data of Distillation Tower----------%

    F=120; %Feed rate (kmol/hr)

    D=23.75; %Product Rate (kmol/hr)

    Xf=0.45; %Feed composition

    Xd=0.98; %Distillate composition

    P=1; % Operating pressure (atm)

    R=1.5; %Reflux Ratio

    %---------Calculate W, Xw and coefficients of BOL--------%

    W=F-D; %Bottom Flow Rate (kmol/hr)

    Xw=(F*Xf-D*Xd)/W; %Bottom Composition

  • 8/7/2019 Matlab_code_for_Binary_Distillation

    6/9

    Yf=R*Xf/(R+1)+Xd/(R+1); %Point of Intersection of TOL &

    BOL

    m=(Yf -Xw)/(Xf -Xw); %Gradient

    c=Xw-m*Xw; %Intersection

    fprintf ('Bottom Flow rate: %.2f kmol/hr \n',W)fprintf ('Bottom Composition: %.2f \n',Xw)

    %----------Polynomials of Equilibrium Curves-----------%

    A= polyfit(X,Y,5);

    %Coefficients of the Polynomial (Y vs X)

    B= polyfit(X,T,5);

    %Coefficients of the Polynomial (Temperaturevs. X)

    comp_temp=zeros(50,2);

    %-----Composition Calculation of Partial Condenser)-----%

    Z=zeros(1,6);

    Z=A;

    Z(6)=A(6)-Xd;

    r=roots(Z);

    for i=1:5

    if (r(i,1)0)&(imag(r(i,1))==0)

    x=r(i,1);

    comp_temp (1,1)=x;

    end

    end

    %--------------Plate Calculation-------------%

    for i=1:49

    x=comp_temp(i,1);

    y=R*x/(R+1) + Xd/(R+1);

    %Top Operating Line Equation

    Z(6)=A(6)-y;

  • 8/7/2019 Matlab_code_for_Binary_Distillation

    7/9

    a=roots(Z);

    for j=1:5

    if (a(j,1)0)&(imag(a(j,1))==0)

    %Find the Correct between 0 & 1

    x=a(j,1);if x>=Xf

    %check the condition for feed composition

    comp_temp(i+1,1)=x;

    else

    y=m*x + c;

    %bottom operating line

    Z(6)=A(6)-y;

    a=roots (Z);

    for k=1:5

    if

    (a(k,1)0)&(imag(a(k,1))==0)

    %Correct Root

    x=a(k,1);

    if Xw 0

    comp(k,1)=comp_temp(k,1);

    else

    break

  • 8/7/2019 Matlab_code_for_Binary_Distillation

    8/9

    end

    end

    N=length(comp);

    NN=1:1:N;T=polyval(B,comp);

    subplot(2,1,1),plot(NN,comp,'r')

    grid on

    xlabel ('Plate No.(From Top)')

    ylabel ('Liquid Composition-Benzene')

    subplot (2,1,2),plot(NN,T,'b')

    grid onxlabel ('Plate No:(From Top)')

    ylabel ('Plate Temperature(0C)')

    fprintf ('No of plates: %.0f \n',N-2)

    Comp_Temp= [Composition T]

    return

    end

    end

    end

    end

  • 8/7/2019 Matlab_code_for_Binary_Distillation

    9/9

    Results

    In Command Window

    >> Bottom Flow rate: 96.25 kmol/hr

    Bottom Composition: 0.32

    No of plates: 12

    Temperature Variation in plates of distillation tower