Activity Coefficient Model Fitting for Binary Mixtures

Version 1.0.8 (2.94 MB) by Robby Ching
A model fitting for Activity Coefficients of Binary Mixtures given Vapor-Liquid Equilibrium (VLE) Data


Updated 27 Jun 2021

View License

NOTE: Requires Optimization toolbox for the wilson.m, nrtl.m, margules2suffix.m and margules4suffix.m to work
It includes the 2-parameter models Margules, Van Laar, and Wilson for the excess Gibbs' energy, and consequently, for the activity coefficients. VLE data for a binary mixture must be available. They are stored in the variables:
x1-equilibirum liquid mol. frac of component 1
y1-equilibirum vapor mol. frac of component 1
P-system pressure
Before running the wilson.m, van laar.m, and margules.m, make sure these variables are loaded. The saturation pressures of the pure species must also be provided. The programs will calculate model parameters, the root mean-square for performace comparison, and then plots the system pressure base on the model and compared with the given experimental data. The equations used for both programs are all based on the ones presented by Smith, Van Ness, Abbott, and Swihart in their book "Introduction to Chemical Engineering Thermodynamics (8th ed.)." The sample problem in the documentation also came from this book.
For the UNIQUAC, provide the structural and binary interaction parameters, as well as the Antoine Coefficients for the two components. The equations used are from Prausnitz, Lichtenthaler, and Gomes de Azevedo in their book "Molecular Thermodynamics for Fluid-Phase Equilibria (3rd ed)."

Cite As

Robby Ching (2023). Activity Coefficient Model Fitting for Binary Mixtures (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Thermodynamics and Heat Transfer in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Added the following models:
4-Suffix Margules
2-Suffix Margules
*The initial Margules model is 3-suffix (2 parameter model)


Updated the index of RMS, now base on the number of data points from the VLE data.


Fixed the SSE function. In the past versions, the evaluation works as: SSE(SSE(function)) since lsqnonlin already evaluates the SSE of the function. This has been fixed in this update.


Syntax 2 using polyfit is now the open code instead of mvregress for margules.m and van laar.m so no need to download the statistics and machine learning toolbox.


Update 2 on the Wilson, Van Laar and Margules Models


Updated the documentation for Wilson, Van Laar and Margules.


-Added a UNIQUAC model. All the models so far are still for isothermal conditions.
-Minor changes on Wilson, Van Laar, and Margules m files. There were indexes adjusted to n-1 instead of a value of 11.


The only data to be loaded are x1, y1 and P.