You are on page 1of 3

1/17/2018 Component activities in liquid mixture, using NRTL - File Exchange - MATLAB Central

Component activities in liquid mixture, using NRTL 5.0


1 Rating
version 1.0 (182 KB) by Nieck 10 Downloads 
Component activities in liquid mixture, using NRTL model Updated 04 Dec 2014
View License

Add to Watchlist Download

Overview Functions

This is a simple code that calculates the activities of the different components present in a liquid mixture, using the Non-Random Two Liquid model,
extended to multiple components. The code has not been verified in any way, but may still be useful for others to use. Please feel free to use, modify
and distribute the files. If you think the files are useful a positive notification would be appreciated. If the code contains errors, please let me know.

Comments and Ratings (4)


Yanru Huang 
25 May 2017

eduardo sosa I can know where you got this information


9 May 2017

Saeed Hi
19 Dec 2016
Thanks Nieck. This code is working very well.

I evaluated this code using the binary mixture of methanol and water using the eduacational version of Aspen plus v8.8. For the binary and ternary
systems (methanol+water+ethanol) compeletely similar results generated. There is only a small problem with the parameters, the cij=cji in NRTL.
While it was put at zero for cij. I update my "activity" file here for the comparison (for binary and ternary systems).

Binary
clc
clear all;

% Define some globals


% a, b, c: matrices containing the binary parameters for the NRTL
% calculations
% nc : number of components
% T : temperature [K]
global a b c nc T

% We will base the calculation on molar fractions x


%
% % Let's look at an example

% % Let's look at an example


% % methanol (1), water (2)
nc = 2 ; % here we consider a mixture of 2 components

x=zeros(1,nc);
%methanol (1) water (2) Ethanol (3)
a=[0 -0.693 ; %methanol (1)
2.7322 0 ]; %water (2)

b=[0 172.987 ;
-617.269 0 ];

c=[0 0.3;
0.3 0];

T = 300 ;

% for x(1) in a particular range, and x(2) adjusted to satisfy sum(x)=1


x_range=linspace(0,1,100);
for t=1:length(x_range)

https://www.mathworks.com/matlabcentral/fileexchange/48651-component-activities-in-liquid-mixture--using-nrtl?requestedDomain=true 1/3
1/17/2018 Component activities in liquid mixture, using NRTL - File Exchange - MATLAB Central
x(1)=x_range(t);x(2)=1-x(1);

% calculate the activity coefficients using NRTL


lng=NRTL(x);

% for plotting
X(t,:)=x;
Y(t,:)=x.*exp(lng);
G(t,:)=exp(lng);

end

figure(1)
plot(X(:,1),Y(:,1),X(:,1),Y(:,2));
figure(2)
plot(X(:,1),G(:,1),'x',X(:,2),G(:,2));

And for the ternary:

clc
clear all;

% Define some globals


% a, b, c: matrices containing the binary parameters for the NRTL
% calculations
% nc : number of components
% T : temperature [K]
global a b c nc T

% We will base the calculation on molar fractions x


%
% % Let's look at an example

% % Let's look at an example


% % methanol (1), water (2)
nc = 3 ; % here we consider a mixture of 2 components

x=zeros(1,nc);
%methanol (1) water (2) Ethanol (3)
a=[0 -0.693 4.7119 ; %methanol (1)
2.7322 0 3.4578 ;%water (2)
-2.3127 -0.8009 0 ]; %Ethanol (3)

b=[0 172.987 -1162.29 ;%methanol (1)


-617.269 0 -586.081 ;%water (2)
483.8436 246.18 0 ];%Ethanol (3)

File Exchange c=[0 0.3 0.3 ;


0.3 0 0.3 ;
0.3 0.3 0 ];

T = 300 ;

% for x(1) in a particular range, and x(2) adjusted to satisfy sum(x)=1

x(1)=0.05;
x(2)=0.05;
x(3)=0.9;

% calculate the activity coefficients using NRTL


lng=NRTL(x);

% for plotting
X=x;
Y=x.*exp(lng);
G=exp(lng);

SADEGH It seems the Transpose of matrices a, b and c should be used. 'cause methanol is (1) and water is (2), a_ij matrix follows:
24 Mar 2015 mw
m | 0 -0.6930 |
w | 2.7320 0 |

https://www.mathworks.com/matlabcentral/fileexchange/48651-component-activities-in-liquid-mixture--using-nrtl?requestedDomain=true 2/3
1/17/2018 Component activities in liquid mixture, using NRTL - File Exchange - MATLAB Central

Requires
MATLAB

MATLAB Release
MATLAB 8.4 (R2014b)

Tags
liquid mixture thermodynamics

Cancel Save

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills


 Play today

% 2014, Nieck E. Benes (n.e.benes@utwente


% Simple code for calcuating the activiti
activity.m % mixtures, using the NRTL model.
% a, b and c parameters are taken from:
% Appendix B
NRTL(x) % Understanding Distillation Using Co
% Daniel Beneke, Mark Peters, David G
Some_a_b_c.m % Wiley 2012
% Print ISBN: 9781118145401
% Online ISBN: 9781118477304

mathworks.com
© 1994-2018 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See mathworks.com/trademarks for a list of additional trademarks. Other
product or brand names may be trademarks or registered trademarks of their respective holders.

https://www.mathworks.com/matlabcentral/fileexchange/48651-component-activities-in-liquid-mixture--using-nrtl?requestedDomain=true 3/3

You might also like