image thumbnail
from Absorption of Acetone in Air Using Water by Housam Binous
computes the number of equilibrium stages for absorption operation

binousAAW(varargin)
function varargout = binousAAW(varargin)
% BINOUSAAW M-file for binousAAW.fig
%      BINOUSAAW, by itself, creates a new BINOUSAAW or raises the existing
%      singleton*.
%
%      H = BINOUSAAW returns the handle to a new BINOUSAAW or the handle to
%      the existing singleton*.
%
%      BINOUSAAW('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in BINOUSAAW.M with the given input arguments.
%
%      BINOUSAAW('Property','Value',...) creates a new BINOUSAAW or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before binousAAW_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to binousAAW_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help binousAAW

% Last Modified by GUIDE v2.5 02-Dec-2007 08:38:01

% Begin initialization code - DO NOT EDIT

clc

global YT TBL1 TBL2 x X Y oplin imax AcetoneGasB recoveryfactor options

options=optimset('Display','off');

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @binousAAW_OpeningFcn, ...
                   'gui_OutputFcn',  @binousAAW_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before binousAAW is made visible.
function binousAAW_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to binousAAW (see VARARGIN)

global YT TBL1 TBL2 x X Y oplin imax AcetoneGasB recoveryfactor options

% Choose default command line output for binousAAW
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

AcetoneGasB=10;
recoveryfactor=0.9;

tbl1=[0 3.30*10^-2 7.20*10^-2 11.7*10^-2 17.1*10^-2];
tbl2=[0 30.00/760. 62.80/760. 85.4/760. 103/760.];
TBL1=tbl1./(1-tbl1);
TBL2=tbl2./(1-tbl2);

AirGasB=100-AcetoneGasB;
YB=AcetoneGasB/AirGasB;
AcetoneGasT=AcetoneGasB*(1-recoveryfactor);
YT=AcetoneGasT/AirGasB;

X=fsolve(@Lmin,[0.05,1.05],options);

LoverGmin=X(2);

LoverG=1.25*LoverGmin;

Y(1)=YB;i=1;

while (Y(i)> YT && i<100)
    X(i)=(Y(i)-YT)/LoverG;
    Y(i+1)=feval(@eqAAW,X(i));
    i=i+1;
end

X(i)=0;

imax=i;

x=0:0.01:0.2;
oplin=LoverG*x+YT;

% UIWAIT makes binousAAW wait for user response (see UIRESUME)
% uiwait(handles.figure1);

if strcmp(get(hObject,'Visible'),'off') 
        
      plot(TBL1,TBL2,'r')
      hold on
      plot(x,oplin,'b')

    for i=1:imax-1
    h=line([X(i+1),X(i)],[Y(i+1),Y(i+1)]);
    set(h,'color','g')
    end

    for i=2:imax-1
    h=line([X(i),X(i)],[Y(i),Y(i+1)]);
    set(h,'color','g')
    end
      
    text(0.01,Y(1)+0.035,'number of stages: ','HorizontalAlignment','left')
    text(0.01,Y(1)+0.025,num2str(imax-1),'HorizontalAlignment','left')
    
    axis([0 X(1)+0.05 0 Y(1)+0.05])
    
end


% --- Outputs from this function are returned to the command line.
function varargout = binousAAW_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global YT TBL1 TBL2 x X Y oplin imax AcetoneGasB recoveryfactor

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
set(hObject,'Min',0.8)
set(hObject,'Max',0.95)
recoveryfactor=get(hObject,'Value');

% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global YT TBL1 TBL2 x X Y oplin imax AcetoneGasB recoveryfactor

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
set(hObject,'Min',1)
set(hObject,'Max',15)
AcetoneGasB=get(hObject,'Value');

% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end




% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global YT TBL1 TBL2 x X Y oplin imax AcetoneGasB recoveryfactor options

axes(handles.axes1);
cla;

tbl1=[0 3.30*10^-2 7.20*10^-2 11.7*10^-2 17.1*10^-2];
tbl2=[0 30.00/760. 62.80/760. 85.4/760. 103/760.];
TBL1=tbl1./(1-tbl1);
TBL2=tbl2./(1-tbl2);

AirGasB=100-AcetoneGasB;
YB=AcetoneGasB/AirGasB;
AcetoneGasT=AcetoneGasB*(1-recoveryfactor);
YT=AcetoneGasT/AirGasB;

X=fsolve(@Lmin,[0.05,1.05],options);

LoverGmin=X(2);

LoverG=1.25*LoverGmin;

Y(1)=YB;i=1;

while (Y(i)> YT && i<100)
    X(i)=(Y(i)-YT)/LoverG;
    Y(i+1)=feval(@eqAAW,X(i));
    i=i+1;
end

X(i)=0;

imax=i;

x=0:0.01:0.2;
oplin=LoverG*x+YT;

      plot(TBL1,TBL2,'r')
      hold on
      plot(x,oplin,'b')

    for i=1:imax-1
    h=line([X(i+1),X(i)],[Y(i+1),Y(i+1)]);
    set(h,'color','g')
    end

    for i=2:imax-1
    h=line([X(i),X(i)],[Y(i),Y(i+1)]);
    set(h,'color','g')
    end
   
    text(0.01,Y(1)+0.035,'number of stages: ','HorizontalAlignment','left')
    text(0.01,Y(1)+0.025,num2str(imax-1),'HorizontalAlignment','left')
    
    axis([0 X(1)+0.05 0 Y(1)+0.05])
    

Contact us at files@mathworks.com