0% found this document useful (0 votes)
39 views7 pages

Fugacidad

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 7

Escuela: Instituto Tecnologico de Lázaro Cárdenas

Alumno: Castro Ayala Jose Antonio

Número de Control: 17560393

Profesor: Martínez Ramírez Zenaido

Asignatura: Fisicoquímica

Carrera y Grupo: Ingeniería Química 51-X

Trabajo: Programa de Matlab “Fugacidad y el


coeficiente de fugacidad”

Fecha de entrega: jueves 31 de octubre del 2019


EJERCICIO. Hacer un programa, usando la interface guide de matlab,
que calcule la fugacidad para una sustancia usando la ecuación de
Redlich-Kwong, la ecuación virial y la correlaciones de Lee-Kesler.

Ejemplo: Calcule la fugacidad del compuesto Isobutileno como un gas


a 280°C y 20 bar de presión.

Codigo de “guide” del Programa en Matlab


function varargout = fugac(varargin)
% FUGAC MATLAB code for fugac.fig
% FUGAC, by itself, creates a new FUGAC or raises the existing
% singleton*.
%
% H = FUGAC returns the handle to a new FUGAC or the handle to
% the existing singleton*.
%
% FUGAC('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FUGAC.M with the given input arguments.
%
% FUGAC('Property','Value',...) creates a new FUGAC or raises the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before fugac_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to fugac_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

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

% Last Modified by GUIDE v2.5 31-Oct-2019 10:17:10

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @fugac_OpeningFcn, ...
'gui_OutputFcn', @fugac_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 fugac is made visible.


function fugac_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 fugac (see VARARGIN)

% Choose default command line output for fugac


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes fugac wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = fugac_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;

function T_Callback(hObject, eventdata, handles)


% hObject handle to T (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of T as text


% str2double(get(hObject,'String')) returns contents of T as a
double

% --- Executes during object creation, after setting all properties.


function T_CreateFcn(hObject, eventdata, handles)
% hObject handle to T (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function P_Callback(hObject, eventdata, handles)


% hObject handle to P (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of P as text


% str2double(get(hObject,'String')) returns contents of P as a
double

% --- Executes during object creation, after setting all properties.


function P_CreateFcn(hObject, eventdata, handles)
% hObject handle to P (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function comp_Callback(hObject, eventdata, handles)


% hObject handle to comp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of comp as text


% str2double(get(hObject,'String')) returns contents of comp as a
double

% --- Executes during object creation, after setting all properties.


function comp_CreateFcn(hObject, eventdata, handles)
% hObject handle to comp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
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)
T=str2num(get(handles.T, 'string'));
P=str2num(get(handles.P, 'string'));
comp=str2num(get(handles.comp, 'string'));
Mp=xlsread('zphi.xlsx','Hoja1');
tam=size(Mp);
col=tam(2);
for j=1:col
A(1,j)=Mp(comp,j);
end
Tri=T/A(1,3);
Pri=P/A(1,4);
w=A(1,2);
M=xlsread('zphi.xlsx','phi0');
%Calcula \phi 0
D=prueb(Tri,Pri,M)
j=D(1);
jj=D(2);
Tr2=M(j,1);
Tr1=M(j-1,1);
Pr1=M(1,jj-1);
Pr2=M(1,jj);
z2=M(j,jj-1);
z1=M(j-1,jj-1);
z3=M(j-1,jj);
z4=M(j,jj);
zc1=((z2-z1)/(Tr2-Tr1))*(Tri-Tr1)+z1;
zc2=((z4-z3)/(Tr2-Tr1))*(Tri-Tr1)+z3;
phi0=((zc2-zc1)/(Pr2-Pr1))*(Pri-Pr1)+zc1;
% Calcula \phi _1
M=xlsread('zphi.xlsx','phi1');
D=prueb(Tri,Pri,M);
j=D(1);
jj=D(2);
Tr2=M(j,1);
Tr1=M(j-1,1);
Pr1=M(1,jj-1);
Pr2=M(1,jj);
z2=M(j,jj-1);
z1=M(j-1,jj-1);
z3=M(j-1,jj);
z4=M(j,jj);
zc1=((z2-z1)/(Tr2-Tr1))*(Tri-Tr1)+z1;
zc2=((z4-z3)/(Tr2-Tr1))*(Tri-Tr1)+z3;
phi1=((zc2-zc1)/(Pr2-Pr1))*(Pri-Pr1)+zc1;
phi=phi0*phi1^w;
f=P*phi

B0=0.083-(0.422/Tri^1.6);
B1=0.139-(0.172/Tri^4.2);
phiv=exp(B0*(Pri/Tri)+w*B1*(Pri/Tri));
fu=phiv*P
set(handles.fuga,'string',fu);
set(handles.coef,'string',phi);

function fuga_Callback(hObject, eventdata, handles)


% hObject handle to fuga (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of fuga as text


% str2double(get(hObject,'String')) returns contents of fuga as a
double

% --- Executes during object creation, after setting all properties.


function fuga_CreateFcn(hObject, eventdata, handles)
% hObject handle to fuga (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

function coef_Callback(hObject, eventdata, handles)


% hObject handle to coef (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of coef as text


% str2double(get(hObject,'String')) returns contents of coef as a
double
% --- Executes during object creation, after setting all properties.
function coef_CreateFcn(hObject, eventdata, handles)
% hObject handle to coef (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

Resultado

You might also like