NRTL Gibbs Excess Model (thermo.nrtl)¶
This module contains a class NRTL
for performing activity coefficient
calculations with the NRTL model. An older, functional calculation for
activity coefficients only is also present, NRTL_gammas
.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
NRTL Class¶
- class thermo.nrtl.NRTL(T, xs, tau_coeffs=None, alpha_coeffs=None, ABEFGHCD=None, tau_as=None, tau_bs=None, tau_es=None, tau_fs=None, tau_gs=None, tau_hs=None, alpha_cs=None, alpha_ds=None)[source]¶
Bases:
thermo.activity.GibbsExcess
Class for representing an a liquid with excess gibbs energy represented by the NRTL equation. This model is capable of representing VL and LL behavior. [1] and [2] are good references on this model.
- Parameters
- T
float
Temperature, [K]
- xs
list
[float
] Mole fractions, [-]
- tau_coeffs
list
[list
[list
[float
]]],optional
NRTL parameters, indexed by [i][j] and then each value is a 6 element list with parameters [a, b, e, f, g, h]; either (tau_coeffs and alpha_coeffs) or ABEFGHCD are required, [-]
- alpha_coeffs
list
[list
[float
]],optional
NRTL alpha parameters, []
- ABEFGHCD
tuple
[list
[list
[float
]], 8],optional
Contains the following. One of (tau_coeffs and alpha_coeffs) or ABEFGHCD or some of the tau or alpha parameters are required, [-]
- tau_as
list
[list
[float
]],optional
a parameters used in calculating
NRTL.taus
, [-]- tau_bs
list
[list
[float
]],optional
b parameters used in calculating
NRTL.taus
, [K]- tau_es
list
[list
[float
]],optional
e parameters used in calculating
NRTL.taus
, [-]- tau_fs
list
[list
[float
]],optional
f paraemeters used in calculating
NRTL.taus
, [1/K]- tau_gs
list
[list
[float
]],optional
e parameters used in calculating
NRTL.taus
, [K^2]- tau_hs
list
[list
[float
]],optional
f parameters used in calculating
NRTL.taus
, [1/K^2]- alpha_cs
list
[list
[float
]],optional
c parameters used in calculating
NRTL.alphas
, [-]- alpha_ds
list
[list
[float
]],optional
d paraemeters used in calculating
NRTL.alphas
, [1/K]
- T
Notes
In addition to the methods presented here, the methods of its base class
thermo.activity.GibbsExcess
are available as well.References
- 1
Poling, Bruce E., John M. Prausnitz, and John P. O`Connell. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.
- 2(1,2)
Gmehling, Jürgen, Michael Kleiber, Bärbel Kolbe, and Jürgen Rarey. Chemical Thermodynamics for Process Simulation. John Wiley & Sons, 2019.
Examples
The DDBST has published numerous problems showing this model a simple binary system, Example P05.01b in [2], shows how to use parameters from the DDBST which are in units of calorie and need the gas constant as a multiplier:
>>> from scipy.constants import calorie, R >>> N = 2 >>> T = 70.0 + 273.15 >>> xs = [0.252, 0.748] >>> tausA = tausE = tausF = tausG = tausH = alphaD = [[0.0]*N for i in range(N)] >>> tausB = [[0, -121.2691/R*calorie], [1337.8574/R*calorie, 0]] >>> alphaC = [[0, 0.2974],[.2974, 0]] >>> ABEFGHCD = (tausA, tausB, tausE, tausF, tausG, tausH, alphaC, alphaD) >>> GE = NRTL(T=T, xs=xs, ABEFGHCD=ABEFGHCD) >>> GE.gammas() [1.93605165145, 1.15366304520] >>> GE NRTL(T=343.15, xs=[0.252, 0.748], tau_bs=[[0, -61.0249799309399], [673.2359767282798, 0]], alpha_cs=[[0, 0.2974], [0.2974, 0]]) >>> GE.GE(), GE.dGE_dT(), GE.d2GE_dT2() (780.053057219, 0.5743500022, -0.003584843605528) >>> GE.HE(), GE.SE(), GE.dHE_dT(), GE.dSE_dT() (582.964853938, -0.57435000227, 1.230139083237, 0.0035848436055)
The solution given by the DDBST has the same values [1.936, 1.154], and can be found here: http://chemthermo.ddbst.com/Problems_Solutions/Mathcad_Files/P05.01b%20VLE%20Behavior%20of%20Ethanol%20-%20Water%20Using%20NRTL.xps
Methods
GE
()Calculate and return the excess Gibbs energy of a liquid phase represented by the NRTL model.
Gs
()Calculates and return the G terms in the NRTL model for a specified temperature.
alphas
()Calculates and return the alpha terms in the NRTL model for a specified temperature.
d2GE_dT2
()Calculate and return the second tempreature derivative of excess Gibbs energy of a liquid phase represented by the NRTL model.
Calculate and return the temperature derivative of mole fraction derivatives of excess Gibbs energy of a liquid represented by the NRTL model.
Calculate and return the second mole fraction derivatives of excess Gibbs energy of a liquid represented by the NRTL model.
d2Gs_dT2
()Calculates and return the second temperature derivative of G terms in the NRTL model for a specified temperature.
Calculate and return the second temperature derivative of the tau terms for the NRTL model for a specified temperature.
d3Gs_dT3
()Calculates and return the third temperature derivative of G terms in the NRTL model for a specified temperature.
Calculate and return the third temperature derivative of the tau terms for the NRTL model for a specified temperature.
dGE_dT
()Calculate and return the first tempreature derivative of excess Gibbs energy of a liquid phase represented by the NRTL model.
dGE_dxs
()Calculate and return the mole fraction derivatives of excess Gibbs energy of a liquid represented by the NRTL model.
dGs_dT
()Calculates and return the first temperature derivative of G terms in the NRTL model for a specified temperature.
dtaus_dT
()Calculate and return the temperature derivative of the tau terms for the NRTL model for a specified temperature.
taus
()Calculate and return the tau terms for the NRTL model for a specified temperature.
to_T_xs
(T, xs)Method to construct a new
NRTL
instance at temperature T, and mole fractions xs with the same parameters as the existing object.- to_T_xs(T, xs)[source]¶
Method to construct a new
NRTL
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 tau, Gs, or alphas terms or their derivatives have been calculated, they will be set to the new object as well.
- taus()[source]¶
Calculate and return the tau terms for the NRTL model for a specified temperature.
Notes
These tau ij values (and the coefficients) are NOT symmetric.
- dtaus_dT()[source]¶
Calculate and return the temperature derivative of the tau terms for the NRTL model for a specified temperature.
- d2taus_dT2()[source]¶
Calculate and return the second temperature derivative of the tau terms for the NRTL model for a specified temperature.
- d3taus_dT3()[source]¶
Calculate and return the third temperature derivative of the tau terms for the NRTL model for a specified temperature.
- alphas()[source]¶
Calculates and return the alpha terms in the NRTL model for a specified temperature.
Notes
alpha values (and therefore cij and dij are normally symmetrical; but this is not strictly required.
Some sources suggest the c term should be fit to a given system; but the d term should be fit for an entire chemical family to avoid overfitting.
Recommended values for cij according to one source are:
0.30 Nonpolar substances with nonpolar substances; low deviation from ideality. 0.20 Hydrocarbons that are saturated interacting with polar liquids that do not associate, or systems that for multiple liquid phases which are immiscible 0.47 Strongly self associative systems, interacting with non-polar substances
alpha_coeffs should be a list[list[cij, dij]] so a 3d array
- dGs_dT()[source]¶
Calculates and return the first temperature derivative of G terms in the NRTL model for a specified temperature.
Notes
Derived with SymPy:
>>> from sympy import * >>> T = symbols('T') >>> alpha, tau = symbols('alpha, tau', cls=Function) >>> diff(exp(-alpha(T)*tau(T)), T)
- d2Gs_dT2()[source]¶
Calculates and return the second temperature derivative of G terms in the NRTL model for a specified temperature.
- Returns
Notes
Derived with SymPy:
>>> from sympy import * >>> T = symbols('T') >>> alpha, tau = symbols('alpha, tau', cls=Function) >>> diff(exp(-alpha(T)*tau(T)), T, 2)
- d3Gs_dT3()[source]¶
Calculates and return the third temperature derivative of G terms in the NRTL model for a specified temperature.
Notes
Derived with SymPy:
>>> from sympy import * >>> T = symbols('T') >>> alpha, tau = symbols('alpha, tau', cls=Function) >>> diff(exp(-alpha(T)*tau(T)), T, 3)
- GE()[source]¶
Calculate and return the excess Gibbs energy of a liquid phase represented by the NRTL model.
- Returns
- GE
float
Excess Gibbs energy, [J/mol]
- GE
- dGE_dT()[source]¶
Calculate and return the first tempreature derivative of excess Gibbs energy of a liquid phase represented by the NRTL model.
- Returns
- dGE_dT
float
First temperature derivative of excess Gibbs energy, [J/(mol*K)]
- dGE_dT
- d2GE_dT2()[source]¶
Calculate and return the second tempreature derivative of excess Gibbs energy of a liquid phase represented by the NRTL model.
- Returns
- d2GE_dT2
float
Second temperature derivative of excess Gibbs energy, [J/(mol*K^2)]
- d2GE_dT2
- dGE_dxs()[source]¶
Calculate and return the mole fraction derivatives of excess Gibbs energy of a liquid represented by the NRTL model.
NRTL Functional Calculations¶
- thermo.nrtl.NRTL_gammas(xs, taus, alphas)[source]¶
Calculates the activity coefficients of each species in a mixture using the Non-Random Two-Liquid (NRTL) method, given their mole fractions, dimensionless interaction parameters, and nonrandomness constants. Those are normally correlated with temperature in some form, and need to be calculated separately.
- Parameters
- Returns
Notes
This model needs N^2 parameters.
One common temperature dependence of the nonrandomness constants is:
Most correlations for the interaction parameters include some of the terms shown in the following form:
The original form of this model used the temperature dependence of taus in the form (values can be found in the literature, often with units of calories/mol):
For this model to produce ideal acitivty coefficients (gammas = 1), all interaction parameters should be 0; the value of alpha does not impact the calculation when that is the case.
References
- 1
Renon, Henri, and J. M. Prausnitz. “Local Compositions in Thermodynamic Excess Functions for Liquid Mixtures.” AIChE Journal 14, no. 1 (1968): 135-144. doi:10.1002/aic.690140124.
- 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:
>>> NRTL_gammas(xs=[0.252, 0.748], taus=[[0, -0.178], [1.963, 0]], ... alphas=[[0, 0.2974],[.2974, 0]]) [1.9363183763514304, 1.1537609663170014]
NRTL Regression Calculations¶
- thermo.nrtl.NRTL_gammas_binaries(xs, tau12, tau21, alpha12, alpha21, gammas=None)[source]¶
Calculates activity coefficients at fixed tau and alpha values for a binary system at a series of mole fractions. This is used for regression of tau and alpha 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), … [-]
- tau12
float
tau parameter for 12, [-]
- tau21
float
tau parameter for 21, [-]
- alpha12
float
alpha parameter for 12, [-]
- alpha21
float
alpha 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
Examples
>>> NRTL_gammas_binaries([.1, .9, 0.3, 0.7, .85, .15], 0.1759, 0.7991, .2, .3) [2.121421, 1.011342, 1.52177, 1.09773, 1.016062, 1.841391]