Wilson Gibbs Excess Model (thermo.wilson)¶
This module contains a class Wilson
for performing activity coefficient
calculations with the Wilson model. An older, functional calculation for
activity coefficients only is also present, Wilson_gammas
.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
Wilson Class¶
- class thermo.wilson.Wilson(T, xs, lambda_coeffs=None, ABCDEF=None, lambda_as=None, lambda_bs=None, lambda_cs=None, lambda_ds=None, lambda_es=None, lambda_fs=None)[source]¶
Bases:
thermo.activity.GibbsExcess
Class for representing an a liquid with excess gibbs energy represented by the Wilson equation. This model is capable of representing most nonideal liquids for vapor-liquid equilibria, but is not recommended for liquid-liquid equilibria.
The two basic equations are as follows; all other properties are derived from these.
- Parameters
- T
float
Temperature, [K]
- xs
list
[float
] Mole fractions, [-]
- lambda_coeffs
list
[list
[list
[float
]]],optional
Wilson parameters, indexed by [i][j] and then each value is a 6 element list with parameters (a, b, c, d, e, f); either lambda_coeffs or the lambda parameters are required, [various]
- ABCDEF
tuple
(list
[list
[float
]], 6),optional
The lamba parameters can be provided as a tuple, [various]
- lambda_as
list
[list
[float
]],optional
a parameters used in calculating
Wilson.lambdas
, [-]- lambda_bs
list
[list
[float
]],optional
b parameters used in calculating
Wilson.lambdas
, [K]- lambda_cs
list
[list
[float
]],optional
c parameters used in calculating
Wilson.lambdas
, [-]- lambda_ds
list
[list
[float
]],optional
d paraemeters used in calculating
Wilson.lambdas
, [1/K]- lambda_es
list
[list
[float
]],optional
e parameters used in calculating
Wilson.lambdas
, [K^2]- lambda_fs
list
[list
[float
]],optional
f parameters used in calculating
Wilson.lambdas
, [1/K^2]
- T
Notes
In addition to the methods presented here, the methods of its base class
thermo.activity.GibbsExcess
are available as well.Warning
If parameters are ommited for all interactions, this model reverts to
thermo.activity.IdealSolution
. In large systems it is common to only regress parameters for the most important components; set lambda parameters for other components to 0 to “ignore” them and treat them as ideal components.This class works with python lists, numpy arrays, and can be accelerated with Numba or PyPy quite effectively.
References
- 1(1,2)
Smith, H. C. Van Ness Joseph M. Introduction to Chemical Engineering Thermodynamics 4th Edition, Joseph M. Smith, H. C. Van Ness, 1987.
- 2
Kooijman, Harry A., and Ross Taylor. The ChemSep Book. Books on Demand Norderstedt, Germany, 2000.
- 3
Gmehling, Jürgen, Michael Kleiber, Bärbel Kolbe, and Jürgen Rarey. Chemical Thermodynamics for Process Simulation. John Wiley & Sons, 2019.
Examples
Example 1
This object-oriented class provides access to many more thermodynamic properties than
Wilson_gammas
, but it can also be used like that function. In the following example, gammas are calculated with both functions. The lambdas cannot be specified in this class; but fixed values can be converted with the log function so that fixed values will be obtained.>>> Wilson_gammas([0.252, 0.748], [[1, 0.154], [0.888, 1]]) [1.881492608717, 1.165577493112] >>> GE = Wilson(T=300.0, xs=[0.252, 0.748], lambda_as=[[0, log(0.154)], [log(0.888), 0]]) >>> GE.gammas() [1.881492608717, 1.165577493112]
We can check that the same lambda values were computed as well, and that there is no temperature dependency:
>>> GE.lambdas() [[1.0, 0.154], [0.888, 1.0]] >>> GE.dlambdas_dT() [[0.0, 0.0], [0.0, 0.0]]
In this case, there is no temperature dependency in the Wilson model as the lambda values are fixed, so the excess enthalpy is always zero. Other properties are not always zero.
>>> GE.HE(), GE.CpE() (0.0, 0.0) >>> GE.GE(), GE.SE(), GE.dGE_dT() (683.165839398, -2.277219464, 2.2772194646)
Example 2
ChemSep is a (partially) free program for modeling distillation. Besides being a wonderful program, it also ships with a permissive license several sets of binary interaction parameters. The Wilson parameters in it can be accessed from Thermo as follows. In the following case, we compute activity coefficients of the ethanol-water system at mole fractions of [.252, 0.748].
>>> from thermo.interaction_parameters import IPDB >>> CAS1, CAS2 = '64-17-5', '7732-18-5' >>> lambda_as = IPDB.get_ip_asymmetric_matrix(name='ChemSep Wilson', CASs=[CAS1, CAS2], ip='aij') >>> lambda_bs = IPDB.get_ip_asymmetric_matrix(name='ChemSep Wilson', CASs=[CAS1, CAS2], ip='bij') >>> GE = Wilson(T=273.15+70, xs=[.252, .748], lambda_as=lambda_as, lambda_bs=lambda_bs) >>> GE.gammas() [1.95733110, 1.1600677]
In ChemSep, the form of the Wilson lambda equation is
The parameters were converted to the form used by Thermo as follows:
This system was chosen because there is also a sample problem for the same components from the DDBST which can be found here: http://chemthermo.ddbst.com/Problems_Solutions/Mathcad_Files/P05.01a%20VLE%20Behavior%20of%20Ethanol%20-%20Water%20Using%20Wilson.xps
In that example, with different data sets and parameters, they obtain at the same conditions activity coefficients of [1.881, 1.165]. Different sources of parameters for the same system will generally have similar behavior if regressed in the same temperature range. As higher order lambda parameters are added, models become more likely to behave differently. It is recommended in [3] to regress the minimum number of parameters required.
Example 3
The DDBST has published some sample problems which are fun to work with. Because the DDBST uses a different equation form for the coefficients than this model implements, we must initialize the
Wilson
object with a different method.>>> T = 331.42 >>> N = 3 >>> Vs_ddbst = [74.04, 80.67, 40.73] >>> as_ddbst = [[0, 375.2835, 31.1208], [-1722.58, 0, -1140.79], [747.217, 3596.17, 0.0]] >>> bs_ddbst = [[0, -3.78434, -0.67704], [6.405502, 0, 2.59359], [-0.256645, -6.2234, 0]] >>> cs_ddbst = [[0.0, 7.91073e-3, 8.68371e-4], [-7.47788e-3, 0.0, 3.1e-5], [-1.24796e-3, 3e-5, 0.0]] >>> dis = eis = fis = [[0.0]*N for _ in range(N)] >>> params = Wilson.from_DDBST_as_matrix(Vs=Vs_ddbst, ais=as_ddbst, bis=bs_ddbst, cis=cs_ddbst, dis=dis, eis=eis, fis=fis, unit_conversion=False) >>> xs = [0.229, 0.175, 0.596] >>> GE = Wilson(T=T, xs=xs, lambda_as=params[0], lambda_bs=params[1], lambda_cs=params[2], lambda_ds=params[3], lambda_es=params[4], lambda_fs=params[5]) >>> GE Wilson(T=331.42, xs=[0.229, 0.175, 0.596], lambda_as=[[0.0, 3.870101271243586, 0.07939943395502425], [-6.491263271243587, 0.0, -3.276991837288562], [0.8542855660449756, 6.906801837288562, 0.0]], lambda_bs=[[0.0, -375.2835, -31.1208], [1722.58, 0.0, 1140.79], [-747.217, -3596.17, -0.0]], lambda_ds=[[-0.0, -0.00791073, -0.000868371], [0.00747788, -0.0, -3.1e-05], [0.00124796, -3e-05, -0.0]]) >>> GE.GE(), GE.dGE_dT(), GE.d2GE_dT2() (480.26392663, 4.35596276623, -0.02913038452501) >>> GE.HE(), GE.SE(), GE.dHE_dT(), GE.dSE_dT() (-963.389253354, -4.3559627662, 9.6543920392, 0.029130384525) >>> GE.gammas() [1.2233934334, 1.100945902470, 1.205289928117]
The solution given by the DDBST has the same values [1.223, 1.101, 1.205], and can be found here: http://chemthermo.ddbst.com/Problems_Solutions/Mathcad_Files/05.09%20Compare%20Experimental%20VLE%20to%20Wilson%20Equation%20Results.xps
Example 4
A simple example is given in [1]; other textbooks sample problems are normally in the same form as this - with only volumes and the a term specified. The system is 2-propanol/water at 353.15 K, and the mole fraction of 2-propanol is 0.25.
>>> T = 353.15 >>> N = 2 >>> Vs = [76.92, 18.07] # cm^3/mol >>> ais = [[0.0, 437.98],[1238.0, 0.0]] # cal/mol >>> bis = cis = dis = eis = fis = [[0.0]*N for _ in range(N)] >>> params = Wilson.from_DDBST_as_matrix(Vs=Vs, ais=ais, bis=bis, cis=cis, dis=dis, eis=eis, fis=fis, unit_conversion=True) >>> xs = [0.25, 0.75] >>> GE = Wilson(T=T, xs=xs, lambda_as=params[0], lambda_bs=params[1], lambda_cs=params[2], lambda_ds=params[3], lambda_es=params[4], lambda_fs=params[5]) >>> GE.gammas() [2.124064516, 1.1903745834]
The activity coefficients given in [1] are [2.1244, 1.1904]; matching ( with a slight deviation from their use of 1.987 as a gas constant).
- Attributes
Methods
GE
()Calculate and return the excess Gibbs energy of a liquid phase represented with the Wilson model.
d2GE_dT2
()Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phase using the Wilson activity coefficient model.
Calculate and return the temperature derivative of mole fraction derivatives of excess Gibbs energy of a liquid represented by the Wilson model.
Calculate and return the second mole fraction derivatives of excess Gibbs energy for the Wilson model.
Calculate and return the second temperature derivative of the lambda termsfor the Wilson model at the system temperature.
d3GE_dT3
()Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase using the Wilson activity coefficient model.
Calculate and return the third mole fraction derivatives of excess Gibbs energy using the Wilson model.
Calculate and return the third temperature derivative of the lambda terms for the Wilson model at the system temperature.
dGE_dT
()Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase represented by the Wilson model.
dGE_dxs
()Calculate and return the mole fraction derivatives of excess Gibbs energy for the Wilson model.
Calculate and return the temperature derivative of the lambda terms for the Wilson model at the system temperature.
from_DDBST
(Vi, Vj, a, b, c[, d, e, f, ...])Converts parameters for the wilson equation in the DDBST to the basis used in this implementation.
from_DDBST_as_matrix
(Vs[, ais, bis, cis, ...])Converts parameters for the wilson equation in the DDBST to the basis used in this implementation.
lambdas
()Calculate and return the lambda terms for the Wilson model for at system temperature.
to_T_xs
(T, xs)Method to construct a new
Wilson
instance at temperature T, and mole fractions xs with the same parameters as the existing object.- GE()[source]¶
Calculate and return the excess Gibbs energy of a liquid phase represented with the Wilson model.
- Returns
- GE
float
Excess Gibbs energy of an ideal liquid, [J/mol]
- GE
- d2GE_dT2()[source]¶
Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phase using the Wilson activity coefficient model.
- Returns
- d2GE_dT2
float
Second temperature derivative of excess Gibbs energy, [J/(mol*K^2)]
- d2GE_dT2
- d2GE_dTdxs()[source]¶
Calculate and return the temperature derivative of mole fraction derivatives of excess Gibbs energy of a liquid represented by the Wilson model.
- d2GE_dxixjs()[source]¶
Calculate and return the second mole fraction derivatives of excess Gibbs energy for the Wilson model.
- d2lambdas_dT2()[source]¶
Calculate and return the second temperature derivative of the lambda termsfor the Wilson model at the system temperature.
- Returns
Notes
These Lambda ij values (and the coefficients) are NOT symmetric.
- d3GE_dT3()[source]¶
Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase using the Wilson activity coefficient model.
- Returns
- d3GE_dT3
float
Third temperature derivative of excess Gibbs energy, [J/(mol*K^3)]
- d3GE_dT3
- d3GE_dxixjxks()[source]¶
Calculate and return the third mole fraction derivatives of excess Gibbs energy using the Wilson model.
- d3lambdas_dT3()[source]¶
Calculate and return the third temperature derivative of the lambda terms for the Wilson model at the system temperature.
- Returns
Notes
These Lambda ij values (and the coefficients) are NOT symmetric.
- dGE_dT()[source]¶
Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase represented by the Wilson model.
- Returns
- dGE_dT
float
First temperature derivative of excess Gibbs energy of a liquid phase represented by the Wilson model, [J/(mol*K)]
- dGE_dT
- dGE_dxs()[source]¶
Calculate and return the mole fraction derivatives of excess Gibbs energy for the Wilson model.
- dlambdas_dT()[source]¶
Calculate and return the temperature derivative of the lambda terms for the Wilson model at the system temperature.
- Returns
Notes
These Lambda ij values (and the coefficients) are NOT symmetric.
- static from_DDBST(Vi, Vj, a, b, c, d=0.0, e=0.0, f=0.0, unit_conversion=True)[source]¶
Converts parameters for the wilson equation in the DDBST to the basis used in this implementation.
- Parameters
- Vi
float
Molar volume of component i; needs only to be in the same units as Vj, [cm^3/mol]
- Vj
float
Molar volume of component j; needs only to be in the same units as Vi, [cm^3/mol]
- a
float
a parameter in DDBST form, [K]
- b
float
b parameter in DDBST form, [-]
- c
float
c parameter in DDBST form, [1/K]
- d
float
,optional
d parameter in DDBST form, [-]
- e
float
,optional
e parameter in DDBST form, [1/K^2]
- f
float
,optional
f parameter in DDBST form, [K^2]
- unit_conversionbool
If True, the input coefficients are in units of cal/K/mol, and a R gas constant of 1.9872042… is used for the conversion; the DDBST uses this generally, [-]
- Vi
- Returns
Notes
The units show how the different variables are related to each other.
Examples
>>> Wilson.from_DDBST(Vi=74.04, Vj=80.67, a=375.2835, b=-3.78434, c=0.00791073, d=0.0, e=0.0, f=0.0, unit_conversion=False) (3.8701012712, -375.2835, -0.0, -0.00791073, -0.0, -0.0)
- static from_DDBST_as_matrix(Vs, ais=None, bis=None, cis=None, dis=None, eis=None, fis=None, unit_conversion=True)[source]¶
Converts parameters for the wilson equation in the DDBST to the basis used in this implementation. Matrix wrapper around
Wilson.from_DDBST
.- Parameters
- Vs
list
[float
] Molar volume of component; needs only to be in consistent units, [cm^3/mol]
- ais
list
[list
[float
]] a parameters in DDBST form, [K]
- bis
list
[list
[float
]] b parameters in DDBST form, [-]
- cis
list
[list
[float
]] c parameters in DDBST form, [1/K]
- dis
list
[list
[float
]],optional
d parameters in DDBST form, [-]
- eis
list
[list
[float
]],optional
e parameters in DDBST form, [1/K^2]
- fis
list
[list
[float
]],optional
f parameters in DDBST form, [K^2]
- unit_conversionbool
If True, the input coefficients are in units of cal/K/mol, and a R gas constant of 1.9872042… is used for the conversion; the DDBST uses this generally, [-]
- Vs
- Returns
- a
list
[list
[float
]] a parameters in
Wilson
form, [-]- b
list
[list
[float
]] b parameters in
Wilson
form, [K]- c
list
[list
[float
]] c parameters in
Wilson
form, [-]- d
list
[list
[float
]] d paraemeters in
Wilson
form, [1/K]- e
list
[list
[float
]] e parameters in
Wilson
form, [K^2]- f
list
[list
[float
]] f parameters in
Wilson
form, [1/K^2]
- a
- lambdas()[source]¶
Calculate and return the lambda terms for the Wilson model for at system temperature.
Notes
These Lambda ij values (and the coefficients) are NOT symmetric.
- to_T_xs(T, xs)[source]¶
Method to construct a new
Wilson
instance at temperature T, and mole fractions xs with the same parameters as the existing object.- Parameters
- Returns
Notes
If the new temperature is the same temperature as the existing temperature, if the lambda terms or their derivatives have been calculated, they will be set to the new object as well.
Wilson Functional Calculations¶
- thermo.wilson.Wilson_gammas(xs, params)[source]¶
Calculates the activity coefficients of each species in a mixture using the Wilson method, given their mole fractions, and dimensionless interaction parameters. Those are normally correlated with temperature, and need to be calculated separately.
- Parameters
- Returns
Notes
This model needs N^2 parameters.
The original model correlated the interaction parameters using the standard pure-component molar volumes of each species at 25°C, in the following form:
If a compound is not liquid at that temperature, the liquid volume is taken at the saturated pressure; and if the component is supercritical, its liquid molar volume should be extrapolated to 25°C.
However, that form has less flexibility and offered no advantage over using only regressed parameters.
Most correlations for the interaction parameters include some of the terms shown in the following form:
The Wilson model is not applicable to liquid-liquid systems.
For this model to produce ideal acitivty coefficients (gammas = 1), all interaction parameters should be 1.
The specific process simulator implementations are as follows:
References
- 1
Wilson, Grant M. “Vapor-Liquid Equilibrium. XI. A New Expression for the Excess Free Energy of Mixing.” Journal of the American Chemical Society 86, no. 2 (January 1, 1964): 127-130. doi:10.1021/ja01056a002.
- 2
Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey. Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim: Wiley-VCH, 2012.
Examples
Ethanol-water example, at 343.15 K and 1 MPa, from [2] also posted online http://chemthermo.ddbst.com/Problems_Solutions/Mathcad_Files/P05.01a%20VLE%20Behavior%20of%20Ethanol%20-%20Water%20Using%20Wilson.xps :
>>> Wilson_gammas([0.252, 0.748], [[1, 0.154], [0.888, 1]]) [1.881492608717, 1.165577493112]
Wilson Regression Calculations¶
- thermo.wilson.wilson_gammas_binaries(xs, lambda12, lambda21, calc=None)[source]¶
Calculates activity coefficients at fixed lambda values for a binary system at a series of mole fractions. This is used for regression of lambda parameters. This function is highly optimized, and operates on multiple points at a time.
- Parameters
- xs
list
[float
] Liquid mole fractions of each species in the format x0_0, x1_0, (component 1 point1, component 2 point 1), x0_1, x1_1, (component 1 point2, component 2 point 2), … [-]
- lambda12
float
lambda parameter for 12, [-]
- lambda21
float
lambda parameter for 21, [-]
- gammas
list
[float
],optional
Array to store the activity coefficient for each species in the liquid mixture, indexed the same as xs; can be omitted or provided for slightly better performance [-]
- xs
- Returns
Notes
The lambda values are hard-coded to replace values under zero which are mathematically impossible, with a very small number. This is helpful for regression which might try to make those values negative.
Examples
>>> wilson_gammas_binaries([.1, .9, 0.3, 0.7, .85, .15], 0.1759, 0.7991) [3.42989, 1.03432, 1.74338, 1.21234, 1.01766, 2.30656]